home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / SHSUCD11.ZIP / NETBIOS.INC < prev    next >
Encoding:
Text File  |  1993-02-24  |  6.6 KB  |  245 lines

  1. ;************************************************************************
  2. ;
  3. ;  NETBIOS.INC
  4. ;
  5. ;  An include file which implements a NETBIOS interface for
  6. ;    the CDNET program.
  7. ;
  8. ;  CDNET is a copyright-reserved, free use program.
  9. ;  (c)John H. McCoy, 1993, Sam Houston St. Univ., TX 77341-2206
  10. ;
  11. ;************************************************************************
  12.  
  13. option nokeyword:<length name>
  14. option expr16
  15.  
  16. IFNDEF AsciiNul
  17.   AsciiNul   equ    0
  18. ENDIF
  19.  
  20. ; ** NetBIOS Status codes
  21.  
  22. NB_Ok                      equ  00h
  23. NB_InvalidBufferLength     equ  01h
  24. NB_InvalidCommand          equ  03h
  25. NB_CommandTimeOut          equ  05h
  26. NB_InvalidSessionNumber    equ  08h
  27. NB_NoResourcesAvailable    equ  09h
  28. NB_SessionClosed           equ  0Ah
  29. NB_CommandCanceled         equ  0Bh
  30. NB_DuplicateLocalName      equ  0Dh
  31. NB_NameTableFull           equ  0Eh
  32. NB_ActiveNameDeregistered  equ  0Fh
  33. NB_SessionTableFull        equ  11h
  34. NB_IllegalNameNumber       equ  13h
  35. NB_NoAnswer                equ  14h
  36. NB_NameNotFound            equ  15h
  37. NB_NameAlreadyClaimed      equ  16h
  38. NB_NameDeleted             equ  17h
  39. NB_SessionEndedAbnormally  equ  18h
  40. NB_NameConflictDetected    equ  19h
  41. NB_InterfaceBusy           equ  21h
  42. NB_ToManyCommandsQueued    equ  22h
  43. NB_NetBiosNotLoaded        equ 0FBh
  44. NB_CommandPending          equ 0FFh
  45.  
  46. ; ** NetBIOS Command codes
  47.  
  48. NB_AddName                 equ 30h
  49. NB_AddName_NoWait          equ B0h
  50. NB_DelName                 equ 31h
  51. NB_DelName_NoWait          equ B1h
  52. NB_Call                    equ 10h
  53. NB_Call_NoWait             equ 90h
  54. NB_Listen                  equ 11h
  55. NB_Listen_NoWait           equ 91h
  56. NB_Hangup                  equ 12h
  57. NB_Hangup_NoWait           equ 92h
  58. NB_Send                    equ 14h
  59. NB_Send_NoWait             equ 94h
  60. NB_Receive                 equ 15h
  61. NB_Receive_NoWait          equ 95h
  62.  
  63. fptr  typedef  far ptr word
  64. nptr  typedef  near ptr word
  65.  
  66. ; ** NetBIOS Command Block
  67.  
  68. NetBiosCmdBlks struc 2
  69.    Command              byte     ?
  70.    ReturnCode           byte     ?
  71.    LocalSession         byte     ?
  72.    NameNumber           byte     ?
  73.    BufferPtr            fptr     ?
  74.    Bufferlength         word     ?
  75.    CallName             byte     16 dup(?)
  76.    Name                 byte     16 dup(?)
  77.    ReceiveTimeOut       byte     ?                    ; in half seconds
  78.    SendTimeOut          byte     ?
  79.    PostCallBackPtr      fptr     ?
  80.    LanAdapter           byte     ?
  81.    CommandStatus        byte     ?
  82.    Reserved             byte     14 dup(?)
  83. NetBiosCmdBlks ends
  84.  
  85. NCB    NetBiosCmdBlks  <>   ; going to initialize it to nulls anyway
  86.  
  87. ClearNCB    Macro
  88.       cld
  89.       mov   ax, ds
  90.       mov   es, ax
  91.       lea   si, NCB
  92.       mov   di, si
  93.       mov   cx, (sizeof NCB - 1)
  94.       mov   word ptr es:[di], AsciiNul
  95.       inc   di
  96.       rep   movsb
  97. endM
  98.  
  99. ;
  100. ;  NetName (Command: byte; Name: nptr)
  101. ;
  102. ;  Sets up NCB and calls NetBIOS for adding or deleting local names
  103. ;
  104. ;  Returns:    al    ReturnCode
  105. ;
  106.  
  107. NetName    proc  near syscall uses es bx cx dx, Command:byte, Name:nptr
  108.  
  109.       ClearNCB
  110.       mov   al, NB_NetBiosNotLoaded
  111.       mov   NCB.ReturnCode, al
  112.       mov   al, Command
  113.       mov   NCB.Command, al
  114.       lea   di, NCB.Name
  115.       mov   si, Name
  116.       mov   cx, 16
  117.       rep   movsb
  118.       lea   bx, NCB
  119.       int      5Ch                  ; NetBIOS Call
  120.       mov   al, NCB.ReturnCode
  121.       ret
  122.  
  123. NetName    endp
  124.  
  125. NetAddName    proc  near syscall  Name:nptr
  126.  
  127.       INVOKE NetName, NB_AddName, Name
  128.       ret                              ; returns ReturnCode in al
  129.  
  130. NetAddName    endp
  131.  
  132. NetDelName    proc  near syscall  Name:nptr
  133.  
  134.       INVOKE NetName, NB_DelName, Name
  135.       ret                              ; returns ReturnCode in al
  136.  
  137. NetDelName    endp
  138.  
  139. ;
  140. ;  NetHangup (Session: byte)
  141. ;
  142. ;  Sets up NCB and calls NetBIOS to terminate specified session
  143. ;
  144. ;  Returns:    al    ReturnCode
  145. ;
  146.  
  147. NetHangup    proc  near syscall uses es bx cx dx, Session:byte
  148.  
  149.       ClearNCB
  150.       mov   al, NB_NetBiosNotLoaded
  151.       mov   NCB.ReturnCode, al
  152.       mov   al, NB_Hangup
  153.       mov   NCB.Command, al
  154.       mov   al, Session
  155.       mov   NCB.LocalSession, al
  156.       lea   bx, NCB
  157.       int      5Ch                  ; NetBIOS Call
  158.       mov   al, NCB.ReturnCode
  159.       ret
  160.  
  161. NetHangup    endp
  162.  
  163. ;
  164. ;  NetCall(LocalName: nptr; RemoteName: nptr);
  165. ;
  166. ;  Attempts to establish a session between LocalName and RemoteName
  167. ;
  168. ;  Returns:    al    ReturnCode
  169. ;              ah    Session   ( if established)
  170. ;
  171.  
  172. NetCall    proc  near syscall uses es bx cx dx,
  173.                                    LocalName:nptr,
  174.                                    RemoteName:nptr
  175.       ClearNCB
  176.       mov   al, NB_NetBiosNotLoaded
  177.       mov   NCB.ReturnCode, al
  178.       mov   al, NB_Call
  179.       mov   NCB.Command, al
  180.       lea   di, NCB.Name
  181.       mov   si, LocalName
  182.       mov   cx, 16
  183.       rep   movsb
  184.       lea   di, NCB.CallName
  185.       mov   si, RemoteName
  186.       mov   cx, 16
  187.       rep   movsb
  188.       mov   NCB.ReceiveTimeOut, 0
  189.       mov   NCB.SendTimeOut, 0
  190.       lea   bx, NCB
  191.       int      5Ch                  ; NetBIOS Call
  192.       mov   al, NCB.ReturnCode
  193.       mov   ah, NCB.LocalSession
  194.       ret
  195.  
  196. NetCall    endp
  197.  
  198. ;
  199. ;  NetTransfer(Command: byte; DTA: fptr; Length: word; Session: byte);
  200. ;
  201. ;  Sets up NCB and transfers data in DTA for specified session.
  202. ;  Returns:    al    ReturnCode
  203. ;
  204.  
  205. NetTransfer    proc  near syscall uses es bx cx dx,
  206.                                     Command:byte,
  207.                                     DTA:fptr,
  208.                                     Length:word,
  209.                                     Session:byte
  210.  
  211.       ClearNCB
  212.       mov   al, NB_NetBiosNotLoaded
  213.       mov   NCB.ReturnCode, al
  214.       mov   al, Command
  215.       mov   NCB.Command, al
  216.       mov   ax, Length
  217.       mov   NCB.BufferLength, ax
  218.       mov   ax, word ptr DTA
  219.       mov   word ptr NCB.BufferPtr, ax
  220.       mov   ax, word ptr DTA+2
  221.       mov   word ptr NCB.BufferPtr+2, ax
  222.       mov   al, Session
  223.       mov   NCB.LocalSession, al
  224.       lea   bx, NCB
  225.       int      5Ch                  ; NetBIOS Call
  226.       mov   al, NCB.ReturnCode
  227.       ret
  228.  
  229. NetTransfer    endp
  230.  
  231. NetSend     proc  near syscall DTA:fptr, Length:word, Session:byte
  232.  
  233.       INVOKE NetTransfer, NB_Send, DTA, Length, Session
  234.       ret                              ; returns ReturnCode in al
  235.  
  236. NetSend endp
  237.  
  238. NetReceive     proc  near syscall DTA:fptr, Length:word, Session:byte
  239.  
  240.       INVOKE NetTransfer, NB_Receive, DTA, Length, Session
  241.       ret                              ; returns ReturnCode in al
  242.  
  243. NetReceive endp
  244.  
  245. ; no end statement in include files