jwawsnwlink.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. {******************************************************************************}
  2. { }
  3. { Winsock2 IPX/SPX Extensions API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: wsipx.h, released June 2000. The original Pascal }
  9. { code is: WSIpxpas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaWSNwLink.pas,v 1.5 2005/09/08 07:49:25 marquardt Exp $
  43. unit JwaWSNwLink;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "wsnwlink.h"'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows;
  52. // Microsoft Windows
  53. // Copyright (C) Microsoft Corporation, 1992-1999.
  54. // Microsoft-specific extensions to the Windows NT IPX/SPX Windows
  55. // Sockets interface. These extensions are provided for use as
  56. // necessary for compatibility with existing applications. They are
  57. // otherwise not recommended for use, as they are only guaranteed to
  58. // work * over the Microsoft IPX/SPX stack. An application which
  59. // uses these * extensions may not work over other IPX/SPX
  60. // implementations. Include this header file after winsock.h and
  61. // wsipx.h.
  62. //
  63. // To open an IPX socket where a particular packet type is sent in
  64. // the IPX header, specify NSPROTO_IPX + n as the protocol parameter
  65. // of the socket() API. For example, to open an IPX socket that
  66. // sets the packet type to 34, use the following socket() call:
  67. //
  68. // s = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX + 34);
  69. //
  70. // Below are socket option that may be set or retrieved by specifying
  71. // the appropriate manifest in the "optname" parameter of getsockopt()
  72. // or setsockopt(). Use NSPROTO_IPX as the "level" argument for the
  73. // call.
  74. //
  75. //
  76. // Set/get the IPX packet type. The value specified in the
  77. // optval argument will be set as the packet type on every IPX
  78. // packet sent from this socket. The optval parameter of
  79. // getsockopt()/setsockopt() points to an int.
  80. //
  81. const
  82. IPX_PTYPE = $4000;
  83. {$EXTERNALSYM IPX_PTYPE}
  84. //
  85. // Set/get the receive filter packet type. Only IPX packets with
  86. // a packet type equal to the value specified in the optval
  87. // argument will be returned; packets with a packet type that
  88. // does not match are discarded. optval points to an int.
  89. //
  90. IPX_FILTERPTYPE = $4001;
  91. {$EXTERNALSYM IPX_FILTERPTYPE}
  92. //
  93. // Stop filtering on packet type set with IPX_FILTERPTYPE.
  94. //
  95. IPX_STOPFILTERPTYPE = $4003;
  96. {$EXTERNALSYM IPX_STOPFILTERPTYPE}
  97. //
  98. // Set/get the value of the datastream field in the SPX header on
  99. // every packet sent. optval points to an int.
  100. //
  101. IPX_DSTYPE = $4002;
  102. {$EXTERNALSYM IPX_DSTYPE}
  103. //
  104. // Enable extended addressing. On sends, adds the element
  105. // "unsigned char sa_ptype" to the SOCKADDR_IPX structure,
  106. // making the total length 15 bytes. On receives, add both
  107. // the sa_ptype and "unsigned char sa_flags" to the SOCKADDR_IPX
  108. // structure, making the total length 16 bytes. The current
  109. // bits defined in sa_flags are:
  110. //
  111. // 0x01 - the received frame was sent as a broadcast
  112. // 0x02 - the received frame was sent from this machine
  113. //
  114. // optval points to a BOOL.
  115. //
  116. IPX_EXTENDED_ADDRESS = $4004;
  117. {$EXTERNALSYM IPX_EXTENDED_ADDRESS}
  118. //
  119. // Send protocol header up on all receive packets. optval points
  120. // to a BOOL.
  121. //
  122. IPX_RECVHDR = $4005;
  123. {$EXTERNALSYM IPX_RECVHDR}
  124. //
  125. // Get the maximum data size that can be sent. Not valid with
  126. // setsockopt(). optval points to an int where the value is
  127. // returned.
  128. //
  129. IPX_MAXSIZE = $4006;
  130. {$EXTERNALSYM IPX_MAXSIZE}
  131. //
  132. // Query information about a specific adapter that IPX is bound
  133. // to. In a system with n adapters they are numbered 0 through n-1.
  134. // Callers can issue the IPX_MAX_ADAPTER_NUM getsockopt() to find
  135. // out the number of adapters present, or call IPX_ADDRESS with
  136. // increasing values of adapternum until it fails. Not valid
  137. // with setsockopt(). optval points to an instance of the
  138. // IPX_ADDRESS_DATA structure with the adapternum filled in.
  139. //
  140. IPX_ADDRESS = $4007;
  141. {$EXTERNALSYM IPX_ADDRESS}
  142. // mvb LongBool's in the following record changed to Boolean's (JCP)
  143. type
  144. _IPX_ADDRESS_DATA = record
  145. adapternum: Integer; // input: 0-based adapter number
  146. netnum: array [0..3] of UCHAR; // output: IPX network number
  147. nodenum: array [0..5] of UCHAR; // output: IPX node address
  148. wan: Boolean; // output: TRUE = adapter is on a wan link
  149. status: Boolean; // output: TRUE = wan link is up (or adapter is not wan)
  150. maxpkt: Integer; // output: max packet size, not including IPX header
  151. linkspeed: ULONG; // output: link speed in 100 bytes/sec (i.e. 96 == 9600 bps)
  152. end;
  153. {$EXTERNALSYM _IPX_ADDRESS_DATA}
  154. IPX_ADDRESS_DATA = _IPX_ADDRESS_DATA;
  155. {$EXTERNALSYM IPX_ADDRESS_DATA}
  156. PIPX_ADDRESS_DATA = ^IPX_ADDRESS_DATA;
  157. {$EXTERNALSYM PIPX_ADDRESS_DATA}
  158. TIpxAddressData = IPX_ADDRESS_DATA;
  159. PIpxAddressData = PIPX_ADDRESS_DATA;
  160. //
  161. // Query information about a specific IPX network number. If the
  162. // network is in IPX's cache it will return the information directly,
  163. // otherwise it will issue RIP requests to find it. Not valid with
  164. // setsockopt(). optval points to an instance of the IPX_NETNUM_DATA
  165. // structure with the netnum filled in.
  166. //
  167. const
  168. IPX_GETNETINFO = $4008;
  169. {$EXTERNALSYM IPX_GETNETINFO}
  170. type
  171. _IPX_NETNUM_DATA = record
  172. netnum: array [0..3] of UCHAR; // input: IPX network number
  173. hopcount: USHORT; // output: hop count to this network, in machine order
  174. netdelay: USHORT; // output: tick count to this network, in machine order
  175. cardnum: Integer; // output: 0-based adapter number used to route to this net;
  176. // can be used as adapternum input to IPX_ADDRESS
  177. router: array [0..5] of UCHAR; // output: MAC address of the next hop router, zeroed if
  178. // the network is directly attached
  179. end;
  180. {$EXTERNALSYM _IPX_NETNUM_DATA}
  181. IPX_NETNUM_DATA = _IPX_NETNUM_DATA;
  182. {$EXTERNALSYM IPX_NETNUM_DATA}
  183. PIPX_NETNUM_DATA = ^IPX_NETNUM_DATA;
  184. {$EXTERNALSYM PIPX_NETNUM_DATA}
  185. TIpxNetNumData = IPX_NETNUM_DATA;
  186. PIpxNetNumData = PIPX_NETNUM_DATA;
  187. //
  188. // Like IPX_GETNETINFO except it *does not* issue RIP requests. If the
  189. // network is in IPX's cache it will return the information, otherwise
  190. // it will fail (see also IPX_RERIPNETNUMBER which *always* forces a
  191. // re-RIP). Not valid with setsockopt(). optval points to an instance of
  192. // the IPX_NETNUM_DATA structure with the netnum filled in.
  193. //
  194. const
  195. IPX_GETNETINFO_NORIP = $4009;
  196. {$EXTERNALSYM IPX_GETNETINFO_NORIP}
  197. //
  198. // Get information on a connected SPX socket. optval points
  199. // to an instance of the IPX_SPXCONNSTATUS_DATA structure.
  200. //
  201. // All numbers are in Novell (high-low) order.
  202. //
  203. IPX_SPXGETCONNECTIONSTATUS = $400B;
  204. {$EXTERNALSYM IPX_SPXGETCONNECTIONSTATUS}
  205. type
  206. _IPX_SPXCONNSTATUS_DATA = record
  207. ConnectionState: UCHAR;
  208. WatchDogActive: UCHAR;
  209. LocalConnectionId: USHORT;
  210. RemoteConnectionId: USHORT;
  211. LocalSequenceNumber: USHORT;
  212. LocalAckNumber: USHORT;
  213. LocalAllocNumber: USHORT;
  214. RemoteAckNumber: USHORT;
  215. RemoteAllocNumber: USHORT;
  216. LocalSocket: USHORT;
  217. ImmediateAddress: array [0..5] of UCHAR;
  218. RemoteNetwork: array [0..3] of UCHAR;
  219. RemoteNode: array [0..5] of UCHAR;
  220. RemoteSocket: USHORT;
  221. RetransmissionCount: USHORT;
  222. EstimatedRoundTripDelay: USHORT; // In milliseconds
  223. RetransmittedPackets: USHORT;
  224. SuppressedPacket: USHORT;
  225. end;
  226. {$EXTERNALSYM _IPX_SPXCONNSTATUS_DATA}
  227. IPX_SPXCONNSTATUS_DATA = _IPX_SPXCONNSTATUS_DATA;
  228. {$EXTERNALSYM IPX_SPXCONNSTATUS_DATA}
  229. PIPX_SPXCONNSTATUS_DATA = ^IPX_SPXCONNSTATUS_DATA;
  230. {$EXTERNALSYM PIPX_SPXCONNSTATUS_DATA}
  231. TIpxSpcConnStatusData = IPX_SPXCONNSTATUS_DATA;
  232. PIpxSpcConnStatusData = PIPX_SPXCONNSTATUS_DATA;
  233. //
  234. // Get notification when the status of an adapter that IPX is
  235. // bound to changes. Typically this will happen when a wan line
  236. // goes up or down. Not valid with setsockopt(). optval points
  237. // to a buffer which contains an IPX_ADDRESS_DATA structure
  238. // followed immediately by a HANDLE to an unsignaled event.
  239. //
  240. // When the getsockopt() query is submitted, it will complete
  241. // successfully. However, the IPX_ADDRESS_DATA pointed to by
  242. // optval will not be updated at that point. Instead the
  243. // request is queued internally inside the transport.
  244. //
  245. // When the status of an adapter changes, IPX will locate a
  246. // queued getsockopt() query and fill in all the fields in the
  247. // IPX_ADDRESS_DATA structure. It will then signal the event
  248. // pointed to by the HANDLE in the optval buffer. This handle
  249. // should be obtained before calling getsockopt() by calling
  250. // CreateEvent(). If multiple getsockopts() are submitted at
  251. // once, different events must be used.
  252. //
  253. // The event is used because the call needs to be asynchronous
  254. // but currently getsockopt() does not support this.
  255. //
  256. // WARNING: In the current implementation, the transport will
  257. // only signal one queued query for each status change. Therefore
  258. // only one service which uses this query should be running at
  259. // once.
  260. //
  261. const
  262. IPX_ADDRESS_NOTIFY = $400C;
  263. {$EXTERNALSYM IPX_ADDRESS_NOTIFY}
  264. //
  265. // Get the maximum number of adapters present. If this call returns
  266. // n then the adapters are numbered 0 through n-1. Not valid
  267. // with setsockopt(). optval points to an int where the value
  268. // is returned.
  269. //
  270. IPX_MAX_ADAPTER_NUM = $400D;
  271. {$EXTERNALSYM IPX_MAX_ADAPTER_NUM}
  272. //
  273. // Like IPX_GETNETINFO except it forces IPX to re-RIP even if the
  274. // network is in its cache (but not if it is directly attached to).
  275. // Not valid with setsockopt(). optval points to an instance of
  276. // the IPX_NETNUM_DATA structure with the netnum filled in.
  277. //
  278. IPX_RERIPNETNUMBER = $400E;
  279. {$EXTERNALSYM IPX_RERIPNETNUMBER}
  280. //
  281. // A hint that broadcast packets may be received. The default is
  282. // TRUE. Applications that do not need to receive broadcast packets
  283. // should set this sockopt to FALSE which may cause better system
  284. // performance (note that it does not necessarily cause broadcasts
  285. // to be filtered for the application). Not valid with getsockopt().
  286. // optval points to a BOOL.
  287. //
  288. IPX_RECEIVE_BROADCAST = $400F;
  289. {$EXTERNALSYM IPX_RECEIVE_BROADCAST}
  290. //
  291. // On SPX connections, don't delay before sending ack. Applications
  292. // that do not tend to have back-and-forth traffic over SPX should
  293. // set this; it will increase the number of acks sent but will remove
  294. // delays in sending acks. optval points to a BOOL.
  295. //
  296. IPX_IMMEDIATESPXACK = $4010;
  297. {$EXTERNALSYM IPX_IMMEDIATESPXACK}
  298. implementation
  299. end.