home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / packet.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  2KB  |  64 lines

  1. #ifndef __brloader_packet_h
  2. #define __brloader_packet_h
  3.  
  4. #include <assert.h>
  5.  
  6. #define    PACKET_ADDRESS_MAX    16
  7.  
  8. struct PACKET_BUFFER;
  9.  
  10. typedef void (*PACKET_COMPLETION_FUNC) (struct PACKET_BUFFER *, DWORD);
  11.  
  12. #define    PACKET_COMPLETE_SUCCESS        0x0000
  13. #define    PACKET_COMPLETE_FAILURE        0x0001        // unspecified error
  14. #define    PACKET_COMPLETE_OVERFLOW    0x0002
  15. #define    PACKET_COMPLETE_NO_ROUTE    0x0003
  16.  
  17. typedef struct PACKET_BUFFER {
  18.     LPBYTE    Data;        // storage for packet data
  19.     DWORD    Start;        // where the data begins
  20.     DWORD    End;        // where the data ends
  21.     DWORD    Max;        // the physical length of Data
  22.     DWORD    Context;
  23.  
  24.     // I hate to put this here, but I hate to put it elsewhere even more.
  25.     WORD    Protocol;
  26.     WORD    AddressLength;
  27.     BYTE    Address        [PACKET_ADDRESS_MAX];
  28.     PACKET_COMPLETION_FUNC    CompletionFunc;
  29. } PACKET_BUFFER;
  30.  
  31. // this is the protocol argument for msbdnOutputSendPacket
  32. #define    PACKET_BUFFER_PROTOCOL_IP            0x0000
  33. #define    PACKET_BUFFER_PROTOCOL_VBI_RAW        0x0001
  34. #define    PACKET_BUFFER_PROTOCOL_DSS_ARP        0x0002
  35. #define    PACKET_BUFFER_PROTOCOL_DSS_RAW        0x0003
  36. #define    PACKET_BUFFER_PROTOCOL_DSS_MPT        0x0004
  37.  
  38. // PACKET_BUFFER_PROTOCOL_IP
  39. // packet body is a full IP packet, including header and body
  40. // IP address should be extracted from the message body
  41. // address field is not used
  42.  
  43. // PACKET_BUFFER_PROTOCOL_DSS_RAW
  44. // the address field is not used
  45. // the packet length must be 130 bytes.
  46. // the packet is a standard DSS frame: 3 bytes of header
  47. // and 127 bytes of payload
  48.  
  49. // PACKET_BUFFER_PROTOCOL_DSS_MPT
  50. // the address field may or may not be specified
  51. // the address field is the sub-SCID ID
  52. // if the address is not specified, the output driver should build the
  53. // sub-SCID like an Ethernet MAC address.  this only works for multicast packets,
  54. // which have a fixed, deterministic IP address to MAC address mapping.
  55. // if the address field exists (length is not zero), then the
  56. // address length must be 6 and the address must contain an MPT sub-SCID ID.
  57.  
  58. static __inline void PacketBufferComplete (PACKET_BUFFER * packet, DWORD status) {
  59.     assert (packet);
  60.     if (packet -> CompletionFunc)
  61.         (*packet -> CompletionFunc) (packet, status);
  62. }
  63.  
  64. #endif // __brloader_packet_h