protostructs.h

Go to the documentation of this file.
00001 ///
00002 /// \file       protostructs.h
00003 ///             USB Blackberry bulk protocol API.  This is split out from
00004 ///             protocol.h so that low level, packed structs can be
00005 ///             compiled separately from the application.  This prevents
00006 ///             aliasing problems in the application, or using
00007 ///             -fno-strict-aliasing, which the library only needs.
00008 ///
00009 ///             Do not include this in any Barry library header.
00010 ///             This may only be included from .cc files, in order
00011 ///             to hide aliasing concernes from the application.
00012 ///
00013 
00014 /*
00015     Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)
00016 
00017     This program is free software; you can redistribute it and/or modify
00018     it under the terms of the GNU General Public License as published by
00019     the Free Software Foundation; either version 2 of the License, or
00020     (at your option) any later version.
00021 
00022     This program is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00025 
00026     See the GNU General Public License in the COPYING file at the
00027     root directory of this project for more details.
00028 */
00029 
00030 #ifndef __BARRY_PROTOSTRUCTS_H__
00031 #define __BARRY_PROTOSTRUCTS_H__
00032 
00033 #include <stdint.h>
00034 #include <sys/types.h>
00035 
00036 // forward declarations
00037 namespace Barry { class Data; }
00038 
00039 namespace Barry { namespace Protocol {
00040 
00041 ///////////////////////////////////////////////////////////////////////////////
00042 union SizePacket
00043 {
00044         uint16_t size;
00045         char buffer[4];
00046 } __attribute__ ((packed));
00047 
00048 
00049 ///////////////////////////////////////////////////////////////////////////////
00050 // Record sub-field structs
00051 
00052 struct GroupLink                                // used for Contacts records
00053 {
00054         uint32_t        uniqueId;
00055         uint16_t        unknown;
00056 } __attribute__ ((packed));
00057 
00058 struct MessageAddress                           // used for Message records
00059 {
00060         uint8_t         unknown[8];
00061         uint8_t         addr[1];        // 2 null terminated strings: first
00062                                         // contains full name, second contains
00063                                         // the email address
00064 } __attribute__ ((packed));
00065 
00066 
00067 
00068 ///////////////////////////////////////////////////////////////////////////////
00069 // Record Field Formats
00070 
00071 struct CommonField
00072 {
00073         uint16_t        size;                   // including null terminator
00074         uint8_t         type;
00075 
00076         union CommonFieldData
00077         {
00078 
00079                 GroupLink       link;
00080                 MessageAddress  addr;
00081                 uint32_t        uint32;
00082                 int32_t         min1900;
00083                 uint16_t        code;
00084                 uint8_t         raw[1];
00085                 int16_t         int16;
00086 
00087         } __attribute__ ((packed)) u;
00088 
00089 } __attribute__ ((packed));
00090 #define COMMON_FIELD_HEADER_SIZE        (sizeof(Barry::Protocol::CommonField) - sizeof(Barry::Protocol::CommonField::CommonFieldData))
00091 #define COMMON_FIELD_MIN1900_SIZE       (sizeof(int32_t))
00092 
00093 struct CommandTableField
00094 {
00095         uint8_t         size;           // no null terminator
00096         uint8_t         code;
00097         uint8_t         name[1];
00098 } __attribute__ ((packed));
00099 #define COMMAND_FIELD_HEADER_SIZE       (sizeof(Barry::Protocol::CommandTableField) - 1)
00100 
00101 struct OldDBDBField
00102 {
00103         uint16_t        dbNumber;
00104         uint8_t         unknown1;
00105         uint32_t        dbSize;                 // assumed from Cassis docs...
00106                                                 // always 0 in USB
00107         uint16_t        dbRecordCount;
00108         uint16_t        unknown2;
00109         uint16_t        nameSize;               // includes null terminator
00110         uint8_t         name[1];
00111 } __attribute__ ((packed));
00112 #define OLD_DBDB_FIELD_HEADER_SIZE      (sizeof(Barry::Protocol::OldDBDBField) - 1)
00113 
00114 struct DBDBField
00115 {
00116         uint16_t        dbNumber;
00117         uint8_t         unknown1;
00118         uint32_t        dbSize;                 // assumed from Cassis docs...
00119                                                 // always 0 in USB
00120         uint32_t        dbRecordCount;
00121         uint16_t        unknown2;
00122         uint16_t        nameSize;               // includes null terminator
00123         uint8_t         unknown3;
00124         uint8_t         name[1];                // followed by 2 zeros!
00125         uint16_t        unknown;                // this comes after the
00126                                                 // null terminated name, but
00127                                                 // is here for size calcs
00128 } __attribute__ ((packed));
00129 #define DBDB_FIELD_HEADER_SIZE  (sizeof(Barry::Protocol::DBDBField) - 1)
00130 
00131 struct RecordStateTableField
00132 {
00133         uint8_t         rectype;                // it is unknown exactly what
00134                                                 // this field does, but it
00135                                                 // shows up here and in the
00136                                                 // tagged record header, and
00137                                                 // for some of the records
00138                                                 // they must match when writing
00139         uint16_t        index;
00140         uint32_t        uniqueId;               // matches the uniqueId of say,
00141                                                 // address book records
00142         uint8_t         flags;                  // bit 0x01 is the dirty flag
00143                                                 // don't know if any other bits
00144                                                 // are used
00145 #define BARRY_RSTF_DIRTY        0x01
00146         uint8_t         unknown2[4];
00147 } __attribute__ ((packed));
00148 
00149 struct CalendarRecurrenceDataField  // as documented in the Cassis project spec
00150 {
00151         uint8_t         type;
00152 #define CRDF_TYPE_DAY           0x01
00153 #define CRDF_TYPE_MONTH_BY_DATE 0x03
00154 #define CRDF_TYPE_MONTH_BY_DAY  0x04
00155 #define CRDF_TYPE_YEAR_BY_DATE  0x05
00156 #define CRDF_TYPE_YEAR_BY_DAY   0x06
00157 #define CRDF_TYPE_WEEK          0x0c
00158 
00159         uint8_t         unknown;                // always 0x01
00160         uint16_t        interval;
00161         uint32_t        startTime;
00162         uint32_t        endTime;                // 0xFFFFFFFF for never
00163 
00164         union Additional
00165         {
00166                 // Note: blank fields should be set to 0
00167 
00168                 struct Day
00169                 {
00170                         uint8_t day[6];         // always zeros!
00171                 } __attribute__ ((packed)) day;
00172 
00173                 struct MonthByDate
00174                 {
00175                         uint8_t monthDay;       // day of month to recur on
00176                                                 // (1-31)
00177                         uint8_t blank[5];
00178                 } __attribute__ ((packed)) month_by_date;
00179 
00180                 struct MonthByDay
00181                 {
00182                         uint8_t weekDay;        // day of week to recur on (0-6)
00183                         uint8_t week;           // week of month to recur on
00184                                                 // (1 to 5, first week, second
00185                                                 // week, etc)
00186                         uint8_t blank[4];
00187                 } __attribute__ ((packed)) month_by_day;
00188 
00189                 struct YearByDate
00190                 {
00191                         uint8_t monthDay;       // day of month to recur on
00192                                                 // (1-31)
00193                         uint8_t blank;
00194                         uint8_t month;          // month to recur on (1-12)
00195                         uint8_t blank_[3];
00196                 } __attribute__ ((packed)) year_by_date;
00197 
00198                 struct YearByDay
00199                 {
00200                         uint8_t weekDay;        // day of week to recur on (0-6)
00201                         uint8_t week;           // week of month (1 to 5)
00202                         uint8_t month;          // (1-12)
00203                         uint8_t blank[3];
00204                 } __attribute__ ((packed)) year_by_day;
00205 
00206                 struct Week
00207                 {
00208                         uint8_t days;           // bitmask
00209                         #define CRDF_WD_SUN     0x01
00210                         #define CRDF_WD_MON     0x02
00211                         #define CRDF_WD_TUE     0x04
00212                         #define CRDF_WD_WED     0x08
00213                         #define CRDF_WD_THU     0x10
00214                         #define CRDF_WD_FRI     0x20
00215                         #define CRDF_WD_SAT     0x40
00216 
00217                         uint8_t blank[5];
00218                 } __attribute__ ((packed)) week;
00219 
00220         } __attribute__ ((packed)) u;
00221 
00222 } __attribute__ ((packed));
00223 #define CALENDAR_RECURRENCE_DATA_FIELD_SIZE     sizeof(Barry::Protocol::CalendarRecurrenceDataField)
00224 
00225 
00226 
00227 ///////////////////////////////////////////////////////////////////////////////
00228 // Packed field structures - odd format used with Service Book records
00229 
00230 struct PackedField_02
00231 {
00232         uint8_t         code;
00233         uint8_t         size;
00234         uint8_t         type;
00235         uint8_t         raw[1];
00236 } __attribute__ ((packed));
00237 #define PACKED_FIELD_02_HEADER_SIZE     (sizeof(Barry::Protocol::PackedField_02) - 1)
00238 
00239 struct PackedField_10
00240 {
00241         uint8_t         type;
00242         uint8_t         size;
00243         uint8_t         raw[1];
00244 } __attribute__ ((packed));
00245 #define PACKED_FIELD_10_HEADER_SIZE     (sizeof(Barry::Protocol::PackedField_10) - 1)
00246 
00247 
00248 
00249 
00250 ///////////////////////////////////////////////////////////////////////////////
00251 // Service Book field and record structures
00252 
00253 struct ServiceBookConfigField
00254 {
00255         uint8_t         format;
00256         uint8_t         fields[1];
00257 } __attribute__ ((packed));
00258 #define SERVICE_BOOK_CONFIG_FIELD_HEADER_SIZE (sizeof(Barry::Protocol::ServiceBookConfigField) - 1)
00259 
00260 
00261 ///////////////////////////////////////////////////////////////////////////////
00262 // DB Command Parameter structures
00263 
00264 struct DBC_Record
00265 {
00266         uint16_t        recordIndex;    // index comes from RecordStateTable
00267         uint8_t         data[1];
00268 } __attribute__ ((packed));
00269 #define DBC_RECORD_HEADER_SIZE          (sizeof(Barry::Protocol::DBC_Record) - 1)
00270 
00271 struct DBC_RecordFlags
00272 {
00273         uint8_t         unknown;
00274         uint16_t        index;
00275         uint8_t         unknown2[5];
00276 } __attribute__ ((packed));
00277 #define DBC_RECORD_FLAGS_SIZE           (sizeof(Barry::Protocol::DBC_RecordFlags))
00278 
00279 struct DBC_TaggedUpload
00280 {
00281         uint8_t         rectype;                // it is unknown exactly what
00282                                                 // this field does, but it
00283                                                 // shows up here and in the
00284                                                 // RecordStateTable, and
00285                                                 // for some of the records
00286                                                 // they must match when writing
00287         uint32_t        uniqueId;
00288         uint8_t         unknown2;
00289         uint8_t         data[1];
00290 } __attribute__ ((packed));
00291 #define DBC_TAGGED_UPLOAD_HEADER_SIZE   (sizeof(Barry::Protocol::DBC_TaggedUpload) - 1)
00292 
00293 struct DBC_IndexedUpload
00294 {
00295         uint8_t         unknown;        // observed: 00 or 05
00296         uint16_t        index;
00297         uint8_t         data[1];
00298 } __attribute__ ((packed));
00299 #define DBC_INDEXED_UPLOAD_HEADER_SIZE  (sizeof(Barry::Protocol::DBC_IndexedUpload) - 1)
00300 
00301 struct PasswordChallenge
00302 {
00303         uint8_t         remaining_tries;        // number of password attempts
00304                                                 // the device will accept before
00305                                                 // committing suicide...
00306                                                 // starts at 10 and counts down
00307                                                 // on each bad password
00308         uint8_t         unknown;                // observed as 0... probably just
00309                                                 // the top byte of a uint16
00310                                                 // remaining_tries, but I don't
00311                                                 // want to take that chance
00312         uint16_t        param;                  // seems to be a secondary command
00313                                                 // of some kind, observed as 0x14
00314                                                 // or 0x04, but purpose unknown
00315                                                 // possibly a send/receive flag
00316                                                 // bit (0x10/0x00)
00317         union Hash
00318         {
00319                 uint32_t        seed;
00320                 uint8_t         hash[20];
00321         } __attribute__ ((packed)) u;
00322 
00323 } __attribute__ ((packed));
00324 #define PASSWORD_CHALLENGE_HEADER_SIZE  (sizeof(Barry::Protocol::PasswordChallenge) - sizeof(Barry::Protocol::PasswordChallenge::Hash))
00325 #define PASSWORD_CHALLENGE_SEED_SIZE    (PASSWORD_CHALLENGE_HEADER_SIZE + sizeof(uint32_t))
00326 #define PASSWORD_CHALLENGE_SIZE         (sizeof(Barry::Protocol::PasswordChallenge))
00327 
00328 struct AttributeFetch
00329 {
00330         uint16_t        object;
00331         uint16_t        attribute;
00332         uint8_t         raw[1];                 // used only in response
00333 } __attribute__ ((packed));
00334 #define ATTRIBUTE_FETCH_COMMAND_SIZE    (sizeof(Barry::Protocol::AttributeFetch) - 1)
00335 
00336 struct ModeSelect
00337 {
00338         uint8_t         name[16];
00339         struct ResponseBlock
00340         {
00341                 uint8_t         unknown[20];
00342         } __attribute__ ((packed)) response;
00343 } __attribute__ ((packed));
00344 
00345 
00346 ///////////////////////////////////////////////////////////////////////////////
00347 // Protocol command structures
00348 
00349 struct SocketCommand
00350 {
00351         uint16_t        socket;
00352         uint8_t         sequence;               // incremented on each socket 0
00353                                                 // communication, replies return
00354                                                 // the same number from command
00355 
00356         union PacketData
00357         {
00358 
00359                 PasswordChallenge       password;
00360                 AttributeFetch          fetch;
00361                 ModeSelect              mode;
00362                 uint8_t                 raw[1];
00363 
00364         } __attribute__ ((packed)) u;
00365 } __attribute__ ((packed));
00366 #define SOCKET_COMMAND_HEADER_SIZE              (sizeof(Barry::Protocol::SocketCommand) - sizeof(Barry::Protocol::SocketCommand::PacketData))
00367 
00368 struct SequenceCommand
00369 {
00370         uint8_t         unknown1;
00371         uint8_t         unknown2;
00372         uint8_t         unknown3;
00373         uint32_t        sequenceId;
00374 } __attribute__ ((packed));
00375 
00376 struct DBCommand
00377 {
00378         uint8_t         operation;      // see below
00379         uint16_t        databaseId;     // value from the Database Database
00380 
00381         union Parameters
00382         {
00383 
00384                 DBC_Record              record;
00385                 DBC_RecordFlags         flags;
00386                 DBC_TaggedUpload        tag_upload;
00387                 DBC_IndexedUpload       index_upload;
00388                 uint8_t                 raw[1];
00389 
00390         } __attribute__ ((packed)) u;
00391 } __attribute__ ((packed));
00392 #define DB_COMMAND_HEADER_SIZE          (sizeof(Barry::Protocol::DBCommand) - sizeof(Barry::Protocol::DBCommand::Parameters))
00393 
00394 
00395 
00396 ///////////////////////////////////////////////////////////////////////////////
00397 // Protocol response parameter structures
00398 
00399 struct DBR_OldDBDBRecord
00400 {
00401         uint16_t        count;                  // number of fields in record
00402         OldDBDBField    field[1];
00403 } __attribute__ ((packed));
00404 #define OLD_DBDB_RECORD_HEADER_SIZE     (sizeof(Barry::Protocol::DBR_OldDBDBRecord) - sizeof(Barry::Protocol::OldDBDBField))
00405 
00406 struct DBR_DBDBRecord
00407 {
00408         uint16_t        count;
00409         uint8_t         unknown[3];
00410         DBDBField       field[1];
00411 } __attribute__ ((packed));
00412 #define DBDB_RECORD_HEADER_SIZE         (sizeof(Barry::Protocol::DBR_DBDBRecord) - sizeof(Barry::Protocol::DBDBField))
00413 
00414 // Records with a uniqueId.  This covers the following records:
00415 //
00416 //      Old Contact records
00417 //      Old Service Book records
00418 //      Old Calendar records
00419 //
00420 struct DBR_OldTaggedRecord
00421 {
00422         uint8_t         rectype;
00423         uint16_t        index;
00424         uint32_t        uniqueId;
00425         uint8_t         unknown2;
00426 
00427         union TaggedData
00428         {
00429                 CommonField     field[1];
00430         } __attribute__ ((packed)) u;
00431 } __attribute__ ((packed));
00432 #define DBR_OLD_TAGGED_RECORD_HEADER_SIZE (sizeof(Barry::Protocol::DBR_OldTaggedRecord) - sizeof(Barry::Protocol::DBR_OldTaggedRecord::TaggedData))
00433 
00434 struct MessageRecord
00435 {
00436         uint8_t         field1;         // always 'j'
00437         uint32_t        field2;         // always 0x00000000
00438         uint32_t        flags;          // flags
00439         uint32_t        field4;         // normal email and pin recv this is 0x7ff
00440                                         // changes on sent and reply to 0x01ffffff
00441                                         // and 0x003fffff on pin send
00442         uint32_t        field5;         // always 0x00000000
00443         uint32_t        field6;         // always 0x00000000
00444         uint32_t        field7;         // always 0x00000000
00445         uint32_t        field8;         // always 0x00000000
00446         uint16_t        field9;         // always 0x0000
00447         
00448         uint16_t        dateReceived;   // the first two of these time fields are always the same
00449         uint16_t        timeReceived;   // 
00450         uint16_t        dateDuplicate;  // On mail sent from the BB all three fields are identical
00451         uint16_t        timeDuplicate;  // (time sent)
00452         uint16_t        dateSent;       
00453         uint16_t        timeSent;
00454         
00455         uint16_t        priority;       // priority field
00456         uint32_t        field14;        // always 0x00000000
00457         uint32_t        field15;        // always 0x00000000
00458         uint16_t        field16;        // always 0x0000
00459         uint32_t        field13;        // PIN reply 0x00000000 other time 0xffffffff or 0xfffffffe
00460         uint16_t        messageSize;    // Message size, 0x0000 if Reply or Saved, 0xffff if below ????
00461         uint32_t        field18;        // 0x0's and 0xF'x
00462         uint32_t        field19;        // 0x0's and 0xF's
00463         uint16_t        field20;        // always 0x0000
00464         uint16_t        field21;        // 0x01 unless PIN reply then 0x00
00465         uint32_t        inReplyTo;      // reply to message?
00466         uint32_t        field22;        // always 0x00000000
00467         uint16_t        field23;        // FIXME
00468         
00469         uint32_t        folderOne;      // these are the 'folders' the message is in
00470         uint32_t        folderTwo;      //
00471          
00472         uint16_t        replyMessageFlags;      // 0xfffe on recvd messages
00473                                         // 0x001b on reply
00474                                         // 0x0015 on send
00475                                         // 0x3 pin send
00476                                         // 0x2 on pin recv
00477         uint16_t        field27;        // set to 0x00000004 on PIN reply, 0x00000005 otherwise
00478         uint32_t        headerUID;      // yet another copy of the UID (RecId)  
00479         
00480         uint32_t        field29;        // always 0x00000000
00481         uint16_t        field30;        // always 0x0002
00482         uint16_t        field31;        // always 0x00000000
00483         uint16_t        field32;        // always 0x0004
00484         uint16_t        field34;        // always 0x0000
00485         uint8_t         field33;        // always 'd'
00486         uint32_t        timeBlock;      // FIXME
00487         CommonField     field[1];
00488 } __attribute__ ((packed));
00489 #define MESSAGE_RECORD_HEADER_SIZE (sizeof(Barry::Protocol::MessageRecord) - sizeof(Barry::Protocol::CommonField))
00490 
00491 
00492 
00493 ///////////////////////////////////////////////////////////////////////////////
00494 // Protocol response structures
00495 
00496 struct DBResponse
00497 {
00498         uint8_t         operation;
00499 
00500         union Parameters
00501         {
00502 
00503                 DBR_OldTaggedRecord     tagged;
00504                 DBR_OldDBDBRecord       old_dbdb;
00505                 DBR_DBDBRecord          dbdb;
00506 
00507         } __attribute__ ((packed)) u;
00508 
00509 } __attribute__ ((packed));
00510 #define DB_RESPONSE_HEADER_SIZE         (sizeof(Barry::Protocol::DBResponse) - sizeof(Barry::Protocol::DBResponse::Parameters))
00511 
00512 
00513 
00514 ///////////////////////////////////////////////////////////////////////////////
00515 // Database access command structure
00516 
00517 // even fragmented packets have a tableCmd
00518 struct DBAccess
00519 {
00520         uint8_t         tableCmd;
00521 
00522         union DBData
00523         {
00524                 DBCommand               command;
00525                 DBResponse              response;
00526                 CommandTableField       table[1];
00527                 uint8_t                 return_code;
00528                 uint8_t                 fragment[1];
00529 
00530         } __attribute__ ((packed)) u;
00531 } __attribute__ ((packed));
00532 #define SB_DBACCESS_HEADER_SIZE                 (sizeof(Barry::Protocol::DBAccess) - sizeof(Barry::Protocol::DBAccess::DBData))
00533 #define SB_DBACCESS_RETURN_CODE_SIZE            (1)
00534 
00535 
00536 
00537 ///////////////////////////////////////////////////////////////////////////////
00538 // Main packet struct
00539 
00540 struct Packet
00541 {
00542         uint16_t        socket;         // socket ID... 0 exists by default
00543         uint16_t        size;           // total size of data packet
00544         uint8_t         command;
00545 
00546         union PacketData
00547         {
00548 
00549                 SocketCommand           socket;
00550                 SequenceCommand         sequence;
00551                 DBAccess                db;
00552                 uint8_t                 raw[1];
00553 
00554         } __attribute__ ((packed)) u;
00555 } __attribute__ ((packed));
00556 #define SB_PACKET_HEADER_SIZE                   (sizeof(Barry::Protocol::Packet) - sizeof(Barry::Protocol::Packet::PacketData))
00557 
00558 // minimum required sizes for various responses
00559 #define MIN_PACKET_SIZE         6
00560 
00561 
00562 // maximum sizes
00563 #define MAX_PACKET_SIZE         0x400   // anything beyond this needs to be
00564                                         // fragmented
00565 
00566 /////////////////////////////////////////////////////////////////////////////
00567 //
00568 // various useful sizes
00569 //
00570 
00571 #define SB_PACKET_DBACCESS_HEADER_SIZE          (SB_PACKET_HEADER_SIZE + SB_DBACCESS_HEADER_SIZE)
00572 #define SB_FRAG_HEADER_SIZE                     SB_PACKET_DBACCESS_HEADER_SIZE
00573 
00574 #define SB_PACKET_COMMAND_HEADER_SIZE           (SB_PACKET_DBACCESS_HEADER_SIZE + DB_COMMAND_HEADER_SIZE)
00575 #define SB_PACKET_RESPONSE_HEADER_SIZE          (SB_PACKET_DBACCESS_HEADER_SIZE + DB_RESPONSE_HEADER_SIZE)
00576 
00577 #define SB_PACKET_DBDB_HEADER_SIZE              (SB_PACKET_RESPONSE_HEADER_SIZE + DBDB_RECORD_HEADER_SIZE)
00578 #define SB_PACKET_OLD_DBDB_HEADER_SIZE          (SB_PACKET_RESPONSE_HEADER_SIZE + OLD_DBDB_RECORD_HEADER_SIZE)
00579 
00580 #define SB_PACKET_UPLOAD_HEADER_SIZE            (SB_PACKET_DBACCESS_HEADER_SIZE + UPLOAD_HEADER_SIZE)
00581 
00582 #define SB_SEQUENCE_PACKET_SIZE                 (SB_PACKET_HEADER_SIZE + sizeof(Barry::Protocol::SequenceCommand))
00583 #define SB_SOCKET_PACKET_HEADER_SIZE            (SB_PACKET_HEADER_SIZE + SOCKET_COMMAND_HEADER_SIZE)
00584 #define SB_MODE_PACKET_COMMAND_SIZE             (SB_SOCKET_PACKET_HEADER_SIZE + sizeof(Barry::Protocol::ModeSelect) - sizeof(Barry::Protocol::ModeSelect::ResponseBlock))
00585 #define SB_MODE_PACKET_RESPONSE_SIZE            (SB_SOCKET_PACKET_HEADER_SIZE + sizeof(Barry::Protocol::ModeSelect))
00586 
00587 
00588 // Macros
00589 #define COMMAND(data)                           (((const Barry::Protocol::Packet *)data.GetData())->command)
00590 #define IS_COMMAND(data, cmd)                   (COMMAND(data) == cmd)
00591 #define MAKE_PACKET(var, data)                  const Barry::Protocol::Packet *var = (const Barry::Protocol::Packet *) (data).GetData()
00592 #define MAKE_PACKETPTR_BUF(var, ptr)            Barry::Protocol::Packet *var = (Barry::Protocol::Packet *)ptr
00593 #define MAKE_RECORD(type,var,data,off)          type *var = (type *) ((data).GetData() + (off))
00594 #define MAKE_RECORD_PTR(type,var,data,off)      type *var = (type *) ((data) + (off))
00595 
00596 // fragmentation protocol
00597 // send DATA first, then keep sending DATA packets, FRAGMENTing
00598 // as required until finished, then send DONE.  Both sides behave
00599 // this way, so different sized data can be sent in both
00600 // directions
00601 //
00602 // the fragmented piece only has a the param header, and then continues
00603 // right on with the data
00604 
00605 
00606 
00607 // checks packet size and throws BError if not right
00608 void CheckSize(const Barry::Data &packet, size_t requiredsize = MIN_PACKET_SIZE);
00609 unsigned int GetSize(const Barry::Data &packet);
00610 
00611 }} // namespace Barry::Protocol
00612 
00613 #endif
00614 

Generated on Mon Jan 12 10:51:13 2009 for Barry by  doxygen 1.5.7.1