home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / NET / NETBIOS.H
C/C++ Source or Header  |  1996-07-03  |  9KB  |  217 lines

  1. /****************************************************************************
  2.     $Id: netbios.h 501.0 1995/03/07 12:26:52 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:     Ron van der Wal
  8.  
  9.     Declarations for NetBIOS network protocol functions.
  10.  
  11.     $Log: netbios.h $
  12.     Revision 501.0  1995/03/07 12:26:52  RON
  13.     Updated for TLX 5.01
  14.     Revision 1.2  1995/01/31 16:29:02  RON
  15.     Update for release 012
  16.     Added partial support for SunPro C++ compiler
  17.     Revision 1.1  1995/01/05  15:36:13  ron
  18.     Initial revision
  19.  
  20. ****************************************************************************/
  21.  
  22. #ifndef _TLX_NETBIOS_H
  23. #define _TLX_NETBIOS_H
  24.  
  25. #ifndef _TLX_TLX_H
  26. #include <tlx\501\tlx.h>
  27. #endif
  28.  
  29. // Compile only if DOS or Windows
  30.  
  31. #if OS_DOSXXX || OS_WINXXX
  32.  
  33. // Make sure that all items are packed correctly
  34.  
  35. #if defined(__TURBOC__)
  36.     #pragma option -a-
  37. #elif defined(_MSC_VER) || defined(__WATCOMC__)
  38. #pragma pack(push, 1)
  39. #elif defined(__IBMC__) || defined(__IBMCPP__)
  40.     #pragma CompactStorage(1)
  41. #elif defined(__ZTC__)
  42.     #pragma align 1
  43. #else
  44.     #error Unsupported compiler
  45. #endif
  46.  
  47. /*---------------------------------------------------------------------------
  48.     Auxiliary definitions:
  49.  
  50.     - NetBIOS error messages
  51.     - NetBIOS command ID's
  52.     - various types and parameters
  53. ---------------------------------------------------------------------------*/
  54.  
  55. // NetBIOS error return messages
  56.  
  57. extern char *           gNetBIOSMessage[];
  58.  
  59. // Symbolic names for NetBIOS error codes
  60.  
  61. #define NB_ERR_BADCOMMAND               0x03
  62. #define NB_ERR_TIMEDOUT                 0x05
  63. #define NB_ERR_BADADAPTER               0x23
  64. #define NB_ERR_INPROGRESS               0xFF
  65.  
  66. // Symbolic names for NetBIOS commands
  67.  
  68. #define NB_NOWAIT                       0x80
  69.  
  70. #define NB_RESET                        0x32
  71. #define NB_CANCEL                       0x35
  72. #define NB_STATUS                       0x33
  73. #define NB_TRACE                        0x79
  74. #define NB_UNLINK                       0x70
  75. #define NB_ADDNAME                      0x30
  76. #define NB_ADDGROUP                     0x36
  77. #define NB_DELETENAME                   0x31
  78. #define NB_CALL                         0x10
  79. #define NB_LISTEN                       0x11
  80. #define NB_HANGUP                       0x12
  81. #define NB_SEND                         0x14
  82. #define NB_SENDNOACK                    0x71
  83. #define NB_CHAINSEND                    0x17
  84. #define NB_CHAINSENDNOACK               0x72
  85. #define NB_RECEIVE                      0x15
  86. #define NB_RECEIVEANY                   0x16
  87. #define NB_SESSIONSTATUS                0x34
  88. #define NB_SENDDATAGRAM                 0x20
  89. #define NB_SENDBROADCAST                0x22
  90. #define NB_RECEIVEDATAGRAM              0x21
  91. #define NB_RECEIVEBROADCAST             0x23
  92.  
  93. #define NB_NAMELEN      16              // Includes terminating '\0'
  94.  
  95. typedef void _Far *callback_f;
  96.  
  97. /*---------------------------------------------------------------------------
  98.     TLNCB -
  99.  
  100.     NetBIOS Network Control Block, used for all NetBIOS commands.
  101. ---------------------------------------------------------------------------*/
  102.  
  103. typedef struct TLNCB
  104. {
  105.     uint8               mCommand;       /* Command code */
  106.     uint8               mResult;        /* Immediate return code */
  107.     uint8               mLSN;           /* Local Session Number */
  108.     uint8               mNameNo;        /* Name number */
  109.     void _Far * mBuffer;        /* Pointer to data buffer */
  110.     uint16              mSize;          /* Size of the data buffer */
  111.     char                mRemoteName[16];/* Name of the remote station */
  112.     char                mLocalName[16]; /* Name of the local station */
  113.     uint8               mRcvTimeOut;    /* Receive time-out */
  114.     uint8               mSndTimeOut;    /* Send time-out */
  115.     callback_f          mCallBack;      /* TLCountedPtr to call-back function */
  116.     uint8               mAdapter;       /* Adapter number */
  117.     uint8               mCompletion;    /* Final completion code */
  118.     uint8               mReserved[14];
  119. } TLNCB;
  120.  
  121. /*---------------------------------------------------------------------------
  122.     TLAdapterStatus -
  123.  
  124.     NetBIOS adapter status information block, filled by NBAdapterStatus().
  125. ---------------------------------------------------------------------------*/
  126.  
  127. typedef struct TLAdapterStatus
  128. {
  129.     uint8               mCardID[6];     /* Card identification */
  130.     uint8               mLevel;         /* Release level */
  131.     uint8               mReserved1;
  132.     uint8               mType;          /* Adapter type */
  133.     uint8               mOldNewFlag;    /* Old or new parameters */
  134.     uint16              mReportPeriod;
  135.     uint16              mRcvRejects;    /* # rejected receive frames */
  136.     uint16              mSndRejects;    /* # rejected send frames */
  137.     uint16              mRcvFrameErrors;/* # receive frame errors */
  138.     uint16              mSndErrors;     /* # send errors */
  139.     uint32              mSndCount;      /* # successful sends */
  140.     uint32              mRcvCount;      /* # successful receives */
  141.     uint16              mRetransCount;  /* # retransmissions */
  142.     uint16              mExhaustCount;  /* # exhausted resources */
  143.     uint16              mT1Expirations; /* # T1 timer expirations */
  144.     uint16              mT2Expirations; /* # T2 timer expirations */
  145.     uint8               mReserved2[4];
  146.     uint16              mNCBAvailable;  /* # available NCBs */
  147.     uint16              mNCBConfig;     /* Maximum configured # NCBs */
  148.     uint16              mNCBPossible;   /* Maximum possible # NCBs */
  149.     uint16              mBusyCount;
  150.     uint16              mMaxDataSize;   /* Maximum datagram size */
  151.     uint16              mSesPending;    /* # pending sessions */
  152.     uint16              mSesConfig;     /* Maximum configured # sessions */
  153.     uint16              mSesPossible;   /* Maximum possible # sessions */
  154.     uint16              mMaxFrameSize;  /* Maximum frame size */
  155.     int16               mNameCount;     /* Number of valid names in table */
  156.     struct
  157.     {
  158.         char            mTblName[16];   /* Name in the table */
  159.         uint8           mTblNumber;     /* Associated name number */
  160.         uint8           mTblStatus;     /* Associated name status */
  161.     }                   mNameTable[20]; /* Table of known names */
  162. } TLAdapterStatus;
  163.  
  164. /*---------------------------------------------------------------------------
  165.     NetBIOS functions
  166. ---------------------------------------------------------------------------*/
  167.  
  168. bool    _TLXFUNC NBInstalled(void);
  169. uint16  _TLXFUNC NBExecute(TLNCB _Far *);
  170. uint16  _TLXFUNC NBCancel(TLNCB _Far *);
  171. uint16  _TLXFUNC NBReset(uint8 maxSes, uint8 maxNCB, uint8 adapt);
  172. uint16  _TLXFUNC NBAdapterStatus(const char *, TLAdapterStatus _Far *);
  173. uint16  _TLXFUNC NBAddNameNW(TLNCB _Far *, const char *, callback_f);
  174. uint16  _TLXFUNC NBAddName(const char *, uint8 *);
  175. uint16  _TLXFUNC NBAddGroupNW(TLNCB _Far *, const char *, callback_f);
  176. uint16  _TLXFUNC NBAddGroup(const char *, uint8 *);
  177. uint16  _TLXFUNC NBDeleteNameNW(TLNCB _Far *, const char *, callback_f);
  178. uint16  _TLXFUNC NBDeleteName(const char *);
  179. uint16  _TLXFUNC NBSendDatagram(TLNCB _Far *);
  180. uint16  _TLXFUNC NBSendDatagramNW(TLNCB _Far *);
  181.  
  182. // Auxiliary functions
  183.  
  184. char *  _TLXFUNC NBGetName(char *, const char *);
  185. char *  _TLXFUNC NBSetName(char *, const char *);
  186. char *  _TLXFUNC NBGetLocalName(TLNCB _Far *, char *);
  187. char *  _TLXFUNC NBGetRemoteName(TLNCB _Far *, char *);
  188. void    _TLXFUNC NBSetLocalName(TLNCB _Far *, const char *);
  189. void    _TLXFUNC NBSetRemoteName(TLNCB _Far *, const char *);
  190.  
  191. void            _TLXFUNC NBClearNCB(TLNCB _Far *);
  192. const char *    _TLXFUNC NBErrorMsg(uint16);
  193.  
  194. /*
  195. uint16  _TLXFUNC NBPostAddName(TLNCB _Far *, const char *, callback_f);
  196. uint16  _TLXFUNC NBPostAddGroup(TLNCB _Far *, const char *, callback_f);
  197. uint16  _TLXFUNC NBPostDeleteName(TLNCB _Far *, const char *, callback_f);
  198. uint16  _TLXFUNC NBExecAddName(TLNCB _Far *, const char *, uint8 *);
  199. uint16  _TLXFUNC NBExecAddGroup(TLNCB _Far *, const char *, uint8 *);
  200. uint16  _TLXFUNC NBExecDeleteName(TLNCB _Far *, const char *);
  201. */
  202.  
  203. #if defined(__TURBOC__)
  204.     #pragma option -a.
  205. #elif defined(_MSC_VER) || defined(__WATCOMC__)
  206. #pragma pack(pop)
  207. #elif defined(__IBMC__) || defined(__IBMCPP__)
  208.     #pragma CompactStorage()
  209. #elif defined(__ZTC__)
  210.     /*#pragma align 1*/
  211. #else
  212.     #error Unsupported compiler
  213. #endif
  214.  
  215. #endif  // OS_DOSXXX || OS_WINXXX
  216. #endif  // _TLX_NETBIOS_H
  217.