home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / nb_agent / name.h < prev    next >
C/C++ Source or Header  |  1992-07-09  |  4KB  |  127 lines

  1. /*
  2. ----------------------------------------------------------------------------
  3.  
  4.         Copyright (C) 1990 Novell, Inc.
  5.     
  6.         This software may be freely copied and distributed, provided the 
  7.         above copyright notice is included. It may not be sold, in whole
  8.         or in part, without the prior written consent of Novell, Inc.
  9.  
  10. ----------------------------------------------------------------------------
  11. */
  12.  
  13. #define    IP_DGRAM_SZ    576
  14. #define    IP_HDR_SZ    20
  15. #define    UDP_HDR_SZ    8
  16. #define SZ_BUFFER    (IP_DGRAM_SZ - IP_HDR_SZ - UDP_HDR_SZ)
  17. #define    SZ_MAXPKTDATA    576    /* maximum data in a packet */
  18.  
  19. /****************************************************************************
  20.  * Domain Name Packet Definitions
  21.  ***************************************************************************/
  22.  
  23.  
  24. #define    NM_REG_REQ    0x2910
  25. #define    NM_RES        0xad80
  26. #define    NM_QRY        0x0110
  27. #define    NM_QRY_RES    0x8500
  28. #define NM_QRY_RES1    0x8580
  29. #define    NODE_STATUS_REQ    0x0010
  30. #define    NODE_STATUS_RES 0x8400
  31. #define    NM_OVR_REQ    0x2810
  32. #define    NM_RLS_REQ    0x3010
  33. #define PKT_MSK        0xfdf0    /* Mask of bits used for packet type. */
  34. #define RCODE_MSK    0x000f    /* Mask of bits used for rcode */
  35.  
  36. /*
  37.  * Mask values for NM_FLAGS. These values treat the fields,
  38.  * OPCODE, NM_FLAGS, and RCODE as one word (16 bits).
  39.  */
  40.  
  41. #define    NS_BROADCAST    0x0001
  42. #define    NS_RESRVD1    0x0002
  43. #define    NS_RESRVD2    0x0004
  44. #define    NS_RA        0x0008
  45. #define    NS_RD        0x1000
  46. #define    NS_TC        0x2000    /* truncation bit */
  47. #define    NS_AA        0x4000
  48.  
  49. /* error codes for RCODE field in packet header */
  50.  
  51. #define    FMT_ERR    0x1    /* Invalidly Formatted Request */
  52. #define    SRV_ERR    0x2    /* Server Failure */
  53. #define    IMP_ERR    0x4    /* Unsupported Request */
  54. #define    RFS_ERR    0x5    /* Registration Refusal */
  55. #define    ACT_ERR    0x6    /* Active erroe, name is owned by another node. */
  56. #define    CFT_ERR    0x7    /* Name is in conflict */
  57.  
  58. /* type values */
  59.  
  60. #define    NS_A        0x0100    /* IP address RR */
  61. #define    NS_NS        0x0002    /* Name Server RR */
  62. #define    NS_NB        0x0020    /* General Name Service RR */
  63. #define    NS_NBSTAT    0x0021    /* Node Status RR */
  64. #define    NS_NULL        0x000a    /* NULL RR - see WACK definition */
  65. #define NS_IN        0x0001  /* Internet class */
  66.  
  67. /* values for NB_FLAG field in RR data */
  68.  
  69. #define NS_GROUP    0x8000    /* Group Bit, 1 == Group Netbios Name */
  70. #define NS_MNODE    0x4000
  71. #define NS_PNODE    0x2000
  72. #define NS_DRG        0x1000
  73. #define NS_BNODE    0x0000
  74. #define NS_CNF        0x0800
  75. #define NS_ACT        0x0400
  76. #define NS_PRM        0x0200
  77.  
  78. /* masks for NB_FLAG field in name data entry */
  79.  
  80. #define NS_GROUPMSK    ~0x8000    /* Group Name Flag */
  81. #define NS_ONTMSK    ~0x6000    /* Owner Node Type */
  82. #define NS_STATEMSK    ~0x1d00    /* Name State Bits */
  83.  
  84.  
  85. /****************************************************************************
  86.  * Question Section trailer: preceded by a compressed Netbios name
  87.  ***************************************************************************/
  88.  
  89. struct quest_trailer {
  90.     unsigned short type;
  91.     unsigned short class;
  92. }; /* 4 bytes long */
  93.  
  94. /****************************************************************************
  95.  * Resource Record trailer: preceded by a compressed Netbios name, followed
  96.  * by a variable data section
  97.  ***************************************************************************/
  98.  
  99. struct rr_trailer {
  100.     unsigned short  type;
  101.     unsigned short  class;
  102.     unsigned long ttl;
  103.     unsigned short  length;
  104. }; /* 10 bytes long */
  105.  
  106. struct rr_info {
  107.     struct rr_trailer    trailer;
  108.     unsigned short       flags;
  109.     long          nbaddr;
  110. }; /* 16 bytes long */
  111.  
  112. struct nmpkt_hdr {
  113.     unsigned short nm_tid;    /* transaction id */
  114.     unsigned short status;    /* opcode, flags, return code */
  115.     unsigned short qdcount;    /* number of question entries */
  116.     unsigned short ancount;    /* number of answer records */
  117.     unsigned short nscount;    /* number of authority records */
  118.     unsigned short arcount;    /* number of additional records */
  119. }; /* 12 bytes long */
  120.  
  121. struct namepkt {
  122.     struct nmpkt_hdr header;    
  123.     unsigned char records[SZ_BUFFER - sizeof(struct nmpkt_hdr)];
  124. };
  125.  
  126. #define    NAME_SERVICE_UDP_PORT    137
  127.