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

  1. //*++
  2. //
  3. // Copyright 1991-1998 Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. //  nb30.h
  8. //
  9. // Abstract:
  10. //
  11. //  This module contains the definitions for portable NetBIOS 3.0
  12. //  support.
  13. //
  14. //--*/
  15.  
  16. #ifndef NCB_INCLUDED
  17. #define NCB_INCLUDED
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. /****************************************************************
  24.  *                                                              *
  25.  *              Data structure templates                        *
  26.  *                                                              *
  27.  ****************************************************************/
  28.  
  29. #define NCBNAMSZ        16    /* absolute length of a net name           */
  30. #define MAX_LANA       254    /* lana's in range 0 to MAX_LANA inclusive */
  31.  
  32. /*
  33.  * Network Control Block
  34.  */
  35.  
  36. typedef struct _NCB {
  37.     UCHAR   ncb_command;            /* command code                   */
  38.     UCHAR   ncb_retcode;            /* return code                    */
  39.     UCHAR   ncb_lsn;                /* local session number           */
  40.     UCHAR   ncb_num;                /* number of our network name     */
  41.     PUCHAR  ncb_buffer;             /* address of message buffer      */
  42.     WORD    ncb_length;             /* size of message buffer         */
  43.     UCHAR   ncb_callname[NCBNAMSZ]; /* blank-padded name of remote    */
  44.     UCHAR   ncb_name[NCBNAMSZ];     /* our blank-padded netname       */
  45.     UCHAR   ncb_rto;                /* rcv timeout/retry count        */
  46.     UCHAR   ncb_sto;                /* send timeout/sys timeout       */
  47.     void (CALLBACK *ncb_post)( struct _NCB * ); /* POST routine address        */
  48.     UCHAR   ncb_lana_num;           /* lana (adapter) number          */
  49.     UCHAR   ncb_cmd_cplt;           /* 0xff => commmand pending       */
  50.     UCHAR   ncb_reserve[10];        /* reserved, used by BIOS         */
  51.     HANDLE  ncb_event;              /* HANDLE to Win32 event which    */
  52.                                     /* will be set to the signalled   */
  53.                                     /* state when an ASYNCH command   */
  54.                                     /* completes                      */
  55. } NCB, *PNCB;
  56.  
  57. /*
  58.  *  Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
  59.  *  by an array of NAME_BUFFER structures.
  60.  */
  61.  
  62. typedef struct _ADAPTER_STATUS {
  63.     UCHAR   adapter_address[6];
  64.     UCHAR   rev_major;
  65.     UCHAR   reserved0;
  66.     UCHAR   adapter_type;
  67.     UCHAR   rev_minor;
  68.     WORD    duration;
  69.     WORD    frmr_recv;
  70.     WORD    frmr_xmit;
  71.  
  72.     WORD    iframe_recv_err;
  73.  
  74.     WORD    xmit_aborts;
  75.     DWORD   xmit_success;
  76.     DWORD   recv_success;
  77.  
  78.     WORD    iframe_xmit_err;
  79.  
  80.     WORD    recv_buff_unavail;
  81.     WORD    t1_timeouts;
  82.     WORD    ti_timeouts;
  83.     DWORD   reserved1;
  84.     WORD    free_ncbs;
  85.     WORD    max_cfg_ncbs;
  86.     WORD    max_ncbs;
  87.     WORD    xmit_buf_unavail;
  88.     WORD    max_dgram_size;
  89.     WORD    pending_sess;
  90.     WORD    max_cfg_sess;
  91.     WORD    max_sess;
  92.     WORD    max_sess_pkt_size;
  93.     WORD    name_count;
  94. } ADAPTER_STATUS, *PADAPTER_STATUS;
  95.  
  96. typedef struct _NAME_BUFFER {
  97.     UCHAR   name[NCBNAMSZ];
  98.     UCHAR   name_num;
  99.     UCHAR   name_flags;
  100. } NAME_BUFFER, *PNAME_BUFFER;
  101.  
  102. //  values for name_flags bits.
  103.  
  104. #define NAME_FLAGS_MASK 0x87
  105.  
  106. #define GROUP_NAME      0x80
  107. #define UNIQUE_NAME     0x00
  108.  
  109. #define REGISTERING     0x00
  110. #define REGISTERED      0x04
  111. #define DEREGISTERED    0x05
  112. #define DUPLICATE       0x06
  113. #define DUPLICATE_DEREG 0x07
  114.  
  115. /*
  116.  *  Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
  117.  *  by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
  118.  *  asterisk then an array of these structures is returned containing the
  119.  *  status for all names.
  120.  */
  121.  
  122. typedef struct _SESSION_HEADER {
  123.     UCHAR   sess_name;
  124.     UCHAR   num_sess;
  125.     UCHAR   rcv_dg_outstanding;
  126.     UCHAR   rcv_any_outstanding;
  127. } SESSION_HEADER, *PSESSION_HEADER;
  128.  
  129. typedef struct _SESSION_BUFFER {
  130.     UCHAR   lsn;
  131.     UCHAR   state;
  132.     UCHAR   local_name[NCBNAMSZ];
  133.     UCHAR   remote_name[NCBNAMSZ];
  134.     UCHAR   rcvs_outstanding;
  135.     UCHAR   sends_outstanding;
  136. } SESSION_BUFFER, *PSESSION_BUFFER;
  137.  
  138. //  Values for state
  139.  
  140. #define LISTEN_OUTSTANDING      0x01
  141. #define CALL_PENDING            0x02
  142. #define SESSION_ESTABLISHED     0x03
  143. #define HANGUP_PENDING          0x04
  144. #define HANGUP_COMPLETE         0x05
  145. #define SESSION_ABORTED         0x06
  146.  
  147. /*
  148.  *  Structure returned to the NCB command NCBENUM.
  149.  *
  150.  *  On a system containing lana's 0, 2 and 3, a structure with
  151.  *  length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
  152.  */
  153.  
  154. typedef struct _LANA_ENUM {
  155.     UCHAR   length;         //  Number of valid entries in lana[]
  156.     UCHAR   lana[MAX_LANA+1];
  157. } LANA_ENUM, *PLANA_ENUM;
  158.  
  159. /*
  160.  *  Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
  161.  *  by an array of FIND_NAME_BUFFER structures.
  162.  */
  163.  
  164. typedef struct _FIND_NAME_HEADER {
  165.     WORD    node_count;
  166.     UCHAR   reserved;
  167.     UCHAR   unique_group;
  168. } FIND_NAME_HEADER, *PFIND_NAME_HEADER;
  169.  
  170. typedef struct _FIND_NAME_BUFFER {
  171.     UCHAR   length;
  172.     UCHAR   access_control;
  173.     UCHAR   frame_control;
  174.     UCHAR   destination_addr[6];
  175.     UCHAR   source_addr[6];
  176.     UCHAR   routing_info[18];
  177. } FIND_NAME_BUFFER, *PFIND_NAME_BUFFER;
  178.  
  179. /*
  180.  *  Structure provided with NCBACTION. The purpose of NCBACTION is to provide
  181.  *  transport specific extensions to netbios.
  182.  */
  183.  
  184. typedef struct _ACTION_HEADER {
  185.     ULONG   transport_id;
  186.     USHORT  action_code;
  187.     USHORT  reserved;
  188. } ACTION_HEADER, *PACTION_HEADER;
  189.  
  190. //  Values for transport_id
  191.  
  192. #define ALL_TRANSPORTS  "M\0\0\0"
  193. #define MS_NBF          "MNBF"
  194.  
  195.  
  196. /****************************************************************
  197.  *                                                              *
  198.  *              Special values and constants                    *
  199.  *                                                              *
  200.  ****************************************************************/
  201.  
  202. /*
  203.  *      NCB Command codes
  204.  */
  205.  
  206. #define NCBCALL         0x10            /* NCB CALL                           */
  207. #define NCBLISTEN       0x11            /* NCB LISTEN                         */
  208. #define NCBHANGUP       0x12            /* NCB HANG UP                        */
  209. #define NCBSEND         0x14            /* NCB SEND                           */
  210. #define NCBRECV         0x15            /* NCB RECEIVE                        */
  211. #define NCBRECVANY      0x16            /* NCB RECEIVE ANY                    */
  212. #define NCBCHAINSEND    0x17            /* NCB CHAIN SEND                     */
  213. #define NCBDGSEND       0x20            /* NCB SEND DATAGRAM                  */
  214. #define NCBDGRECV       0x21            /* NCB RECEIVE DATAGRAM               */
  215. #define NCBDGSENDBC     0x22            /* NCB SEND BROADCAST DATAGRAM        */
  216. #define NCBDGRECVBC     0x23            /* NCB RECEIVE BROADCAST DATAGRAM     */
  217. #define NCBADDNAME      0x30            /* NCB ADD NAME                       */
  218. #define NCBDELNAME      0x31            /* NCB DELETE NAME                    */
  219. #define NCBRESET        0x32            /* NCB RESET                          */
  220. #define NCBASTAT        0x33            /* NCB ADAPTER STATUS                 */
  221. #define NCBSSTAT        0x34            /* NCB SESSION STATUS                 */
  222. #define NCBCANCEL       0x35            /* NCB CANCEL                         */
  223. #define NCBADDGRNAME    0x36            /* NCB ADD GROUP NAME                 */
  224. #define NCBENUM         0x37            /* NCB ENUMERATE LANA NUMBERS         */
  225. #define NCBUNLINK       0x70            /* NCB UNLINK                         */
  226. #define NCBSENDNA       0x71            /* NCB SEND NO ACK                    */
  227. #define NCBCHAINSENDNA  0x72            /* NCB CHAIN SEND NO ACK              */
  228. #define NCBLANSTALERT   0x73            /* NCB LAN STATUS ALERT               */
  229. #define NCBACTION       0x77            /* NCB ACTION                         */
  230. #define NCBFINDNAME     0x78            /* NCB FIND NAME                      */
  231. #define NCBTRACE        0x79            /* NCB TRACE                          */
  232.  
  233.  
  234. #define ASYNCH          0x80            /* high bit set == asynchronous       */
  235.  
  236. /*
  237.  *      NCB Return codes
  238.  */
  239.  
  240. #define NRC_GOODRET     0x00    /* good return                                */
  241.                                 /* also returned when ASYNCH request accepted */
  242. #define NRC_BUFLEN      0x01    /* illegal buffer length                      */
  243. #define NRC_ILLCMD      0x03    /* illegal command                            */
  244. #define NRC_CMDTMO      0x05    /* command timed out                          */
  245. #define NRC_INCOMP      0x06    /* message incomplete, issue another command  */
  246. #define NRC_BADDR       0x07    /* illegal buffer address                     */
  247. #define NRC_SNUMOUT     0x08    /* session number out of range                */
  248. #define NRC_NORES       0x09    /* no resource available                      */
  249. #define NRC_SCLOSED     0x0a    /* session closed                             */
  250. #define NRC_CMDCAN      0x0b    /* command cancelled                          */
  251. #define NRC_DUPNAME     0x0d    /* duplicate name                             */
  252. #define NRC_NAMTFUL     0x0e    /* name table full                            */
  253. #define NRC_ACTSES      0x0f    /* no deletions, name has active sessions     */
  254. #define NRC_LOCTFUL     0x11    /* local session table full                   */
  255. #define NRC_REMTFUL     0x12    /* remote session table full                  */
  256. #define NRC_ILLNN       0x13    /* illegal name number                        */
  257. #define NRC_NOCALL      0x14    /* no callname                                */
  258. #define NRC_NOWILD      0x15    /* cannot put * in NCB_NAME                   */
  259. #define NRC_INUSE       0x16    /* name in use on remote adapter              */
  260. #define NRC_NAMERR      0x17    /* name deleted                               */
  261. #define NRC_SABORT      0x18    /* session ended abnormally                   */
  262. #define NRC_NAMCONF     0x19    /* name conflict detected                     */
  263. #define NRC_IFBUSY      0x21    /* interface busy, IRET before retrying       */
  264. #define NRC_TOOMANY     0x22    /* too many commands outstanding, retry later */
  265. #define NRC_BRIDGE      0x23    /* ncb_lana_num field invalid                 */
  266. #define NRC_CANOCCR     0x24    /* command completed while cancel occurring   */
  267. #define NRC_CANCEL      0x26    /* command not valid to cancel                */
  268. #define NRC_DUPENV      0x30    /* name defined by anther local process       */
  269. #define NRC_ENVNOTDEF   0x34    /* environment undefined. RESET required      */
  270. #define NRC_OSRESNOTAV  0x35    /* required OS resources exhausted            */
  271. #define NRC_MAXAPPS     0x36    /* max number of applications exceeded        */
  272. #define NRC_NOSAPS      0x37    /* no saps available for netbios              */
  273. #define NRC_NORESOURCES 0x38    /* requested resources are not available      */
  274. #define NRC_INVADDRESS  0x39    /* invalid ncb address or length > segment    */
  275. #define NRC_INVDDID     0x3B    /* invalid NCB DDID                           */
  276. #define NRC_LOCKFAIL    0x3C    /* lock of user area failed                   */
  277. #define NRC_OPENERR     0x3f    /* NETBIOS not loaded                         */
  278. #define NRC_SYSTEM      0x40    /* system error                               */
  279.  
  280. #define NRC_PENDING     0xff    /* asynchronous command is not yet finished   */
  281.  
  282. /****************************************************************
  283.  *                                                              *
  284.  *              main user entry point for NetBIOS 3.0           *
  285.  *                                                              *
  286.  * Usage: result = Netbios( pncb );                             *
  287.  ****************************************************************/
  288.  
  289. UCHAR
  290. APIENTRY
  291. Netbios(
  292.     PNCB pncb
  293.     );
  294.  
  295. /****************************************************************
  296.  *                                                              *
  297.  *              Prefix for callback routines                    *
  298.  *                                                              *
  299.  * Usage in a declaration: NCB_POST MyPostRoutine( PNCB pncb ); *
  300.  ****************************************************************/
  301.  
  302. #define NCB_POST void CALLBACK
  303.  
  304. #ifdef __cplusplus
  305. }
  306. #endif
  307.  
  308. #endif /* NCB_INCLUDED */
  309.