home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / geninc32.pak / NB30.H < prev    next >
C/C++ Source or Header  |  1997-07-23  |  13KB  |  322 lines

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