home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / nb30.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  12.6 KB  |  319 lines

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