Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

539 lines
16 KiB

  1. /********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990-2000 **/
  4. /********************************************************************/
  5. /* :ts=4 */
  6. //** LLIPIF.H - Lower layer IP interface definitions.
  7. //
  8. // This file contains the definitions defining the interface between IP
  9. // and a lower layer, such as ARP or SLIP.
  10. /*
  11. This file defines a new and improved IP to ARP Module interface definition and will replace llipif.h.
  12. This will also retire the IOCTL method of registering ARP interfaces. The main points are:
  13. - It simplifies setup such that the ARP Modules do not have their own bindings in addition to IP bindings.
  14. - Lets ARP Modules expose multiple IP interfaces per binding.
  15. - Adds version numbering for future compatibility.
  16. - Adds Multi-send capability to ARP
  17. - Lets ARP indicate a packet up in NDIS 4.0 style and IP hang onto the packet and avoid copying.
  18. The flow today is:
  19. ------------------
  20. ARP gets a bind indication from NDIS.
  21. ARP calls IPAddInterface
  22. IP calls ARP_REGISTER
  23. The proposed flow is:
  24. ---------------------
  25. ARP Registers itself with IP via IPRegisterARP(). The ARP is identified by its Name which is case insensitive.
  26. IP gets a bind indication from NDIS. It opens the config section and read the ARP name. Empty name implies
  27. built in ARP as usual.
  28. IP calls ARP's bind handler passing in the config handle.
  29. ARP then opens the adapter and adds one or more IP interfaces via IP_ADD_INTERFACE. For each of up-call ARP
  30. passes in the config-handle for that interface to IP. In most cases it is the same handle which IP passed
  31. to ARP. In case of multiple IP interfaces per adapter it is not.
  32. Calls IPBindComplete() when done.
  33. */
  34. #pragma once
  35. #ifndef LLIPIF_INCLUDED
  36. #define LLIPIF_INCLUDED
  37. #define IP_ARP_BIND_VERSION 0x50000
  38. //
  39. // IP Interface routines called by the ARP interface.
  40. //
  41. typedef
  42. void
  43. (__stdcall *IPRcvRtn)(
  44. IN void * IpInterfaceContext,
  45. IN void * Data,
  46. IN uint DataSize,
  47. IN uint TotalSize,
  48. IN NDIS_HANDLE LinkContext1,
  49. IN uint LinkContext2,
  50. IN uint Bcast,
  51. IN void * LinkCtxt
  52. );
  53. typedef
  54. void
  55. (__stdcall *IPRcvPktRtn)(
  56. void *,
  57. void *,
  58. uint ,
  59. uint ,
  60. NDIS_HANDLE ,
  61. uint,
  62. uint,
  63. uint,
  64. PMDL,
  65. uint *,
  66. void *
  67. );
  68. typedef
  69. void
  70. (__stdcall *IPRcvCmpltRtn)(void);
  71. typedef
  72. void
  73. (__stdcall *IPTxCmpltRtn)(
  74. IN void * IpInterfaceContext,
  75. IN PNDIS_PACKET Packet,
  76. IN NDIS_STATUS CompletionStatus
  77. );
  78. typedef
  79. void
  80. (__stdcall *IPTDCmpltRtn)(
  81. IN void * IpInterfaceContext,
  82. PNDIS_PACKET DestinationPacket,
  83. NDIS_STATUS Status,
  84. uint BytesCopied
  85. );
  86. typedef
  87. void
  88. (__stdcall *IPStatusRtn)(
  89. IN void * IpInterfaceContext,
  90. IN uint StatusCode,
  91. IN void * Buffer,
  92. IN uint BufferSize,
  93. IN void * LinkCtxt
  94. );
  95. typedef
  96. NDIS_STATUS
  97. (__stdcall *IP_PNP)(
  98. IN void * IpInterfaceContext,
  99. IN PNET_PNP_EVENT NetPnPEvent
  100. );
  101. typedef
  102. void
  103. (__stdcall *IPAddAddrCmpltRtn)(
  104. IN IPAddr Address,
  105. IN void *Context,
  106. IN IP_STATUS Status
  107. );
  108. typedef struct _IP_HANDLERS
  109. {
  110. IPRcvRtn IpRcvHandler;
  111. IPRcvCmpltRtn IpRcvCompleteHandler;
  112. IPTxCmpltRtn IpTxCompleteHandler;
  113. IPTDCmpltRtn IpTransferCompleteHandler;
  114. IPStatusRtn IpStatusHandler;
  115. IP_PNP IpPnPHandler;
  116. IPRcvPktRtn IpRcvPktHandler;
  117. IPAddAddrCmpltRtn IpAddAddrCompleteRtn; // called when arp detects address conflicts.
  118. } IP_HANDLERS, *PIP_HANDLERS;
  119. #define LLIP_ADDR_LOCAL 0
  120. #define LLIP_ADDR_MCAST 1
  121. #define LLIP_ADDR_BCAST 2
  122. #define LLIP_ADDR_PARP 4
  123. //
  124. // ARP Handlers passed to IP when IP_ADD_INTERFACE is called.
  125. //
  126. typedef
  127. NDIS_STATUS
  128. (__stdcall *ARP_TRANSMIT)(
  129. IN void * ARPInterfaceContext,
  130. #ifdef NT
  131. IN PNDIS_PACKET * PacketArray,
  132. IN uint NumberOfPackets,
  133. #else
  134. IN PNDIS_PACKET Packet,
  135. #endif
  136. IN IPAddr IpAddr,
  137. IN RouteCacheEntry * Rce OPTIONAL,
  138. IN void * ArpCtxt
  139. );
  140. typedef
  141. NDIS_STATUS
  142. (__stdcall *ARP_TRANSFER)(
  143. IN void * ARPInterfaceContext,
  144. IN NDIS_HANDLE TransferContext,
  145. IN uint HdrOffset,
  146. IN uint ProtocolOffset,
  147. IN uint BytesNeeded,
  148. IN PNDIS_PACKET DestinationPacket,
  149. OUT uint * BytesCopied
  150. );
  151. typedef
  152. void
  153. (__stdcall *ARP_RETURN_PKT)(
  154. IN void * ARPInterfaceContext,
  155. IN PNDIS_PACKET Packet
  156. );
  157. typedef
  158. void
  159. (__stdcall *ARP_CLOSE)(
  160. IN void * ArpInterfaceContext
  161. );
  162. typedef
  163. uint
  164. (__stdcall *ARP_ADDADDR)(
  165. IN void * ArpInterfaceContext,
  166. IN uint AddressType,
  167. IN IPAddr IpAddress,
  168. IN IPMask IpMask,
  169. IN void * Context
  170. );
  171. typedef
  172. uint
  173. (__stdcall *ARP_DELADDR)(
  174. IN void * ArpInterfaceContext,
  175. IN uint AddressType,
  176. IN IPAddr IpAddress,
  177. IN IPMask IpMask
  178. );
  179. typedef
  180. void
  181. (__stdcall *ARP_INVALIDATE)(
  182. IN void * ArpInterfaceContext,
  183. IN RouteCacheEntry * Rce
  184. );
  185. typedef
  186. void
  187. (__stdcall *ARP_OPEN)(
  188. IN void * ArpInterfaceContext
  189. );
  190. typedef
  191. int
  192. (__stdcall *ARP_QINFO)(
  193. IN void * ArpInterfaceContext,
  194. IN struct TDIObjectID * pId,
  195. IN PNDIS_BUFFER Buffer,
  196. IN OUT uint * BufferSize,
  197. IN void * QueryContext
  198. );
  199. typedef
  200. int
  201. (__stdcall *ARP_SETINFO)(
  202. IN void * ArpInterfaceContext,
  203. IN struct TDIObjectID * pId,
  204. IN void * Buffer,
  205. IN uint BufferSize
  206. );
  207. typedef
  208. int
  209. (__stdcall *ARP_GETELIST)(
  210. IN void * ArpInterfaceContext,
  211. IN void * pEntityList,
  212. IN OUT PUINT pEntityListSize
  213. );
  214. typedef
  215. NDIS_STATUS
  216. (__stdcall *ARP_DONDISREQ)(
  217. IN void * ArpInterfaceContext,
  218. IN NDIS_REQUEST_TYPE RT,
  219. IN NDIS_OID OID,
  220. IN void * Info,
  221. IN uint Length,
  222. IN uint * Needed,
  223. IN BOOLEAN Blocking
  224. );
  225. typedef
  226. void
  227. (__stdcall *ARP_CANCEL)(
  228. IN void * ArpInterfaceContext,
  229. IN void * CancelCtxt
  230. );
  231. //
  232. // Structure of information returned from ARP register call.
  233. //
  234. struct LLIPBindInfo {
  235. PVOID lip_context; // LL context handle.
  236. uint lip_mss; // Maximum segment size.
  237. uint lip_speed; // Speed of this i/f.
  238. uint lip_index; // Interface index ID.
  239. uint lip_txspace; // Space required in the packet header for ARP use
  240. ARP_TRANSMIT lip_transmit;
  241. ARP_TRANSFER lip_transfer;
  242. ARP_RETURN_PKT lip_returnPkt;
  243. ARP_CLOSE lip_close;
  244. ARP_ADDADDR lip_addaddr;
  245. ARP_DELADDR lip_deladdr;
  246. ARP_INVALIDATE lip_invalidate;
  247. ARP_OPEN lip_open;
  248. ARP_QINFO lip_qinfo;
  249. ARP_SETINFO lip_setinfo;
  250. ARP_GETELIST lip_getelist;
  251. ARP_DONDISREQ lip_dondisreq;
  252. uint lip_flags; // Flags for this interface.
  253. uint lip_addrlen; // Length in bytes of address.
  254. uchar * lip_addr; // Pointer to interface address.
  255. uint lip_OffloadFlags; // IP offload capabilities flag
  256. uint lip_IPSecOffloadFlags; // IPSec offload capabilities flag
  257. ulong lip_ffpversion; // Version of FFP Supported or 0
  258. ULONG_PTR lip_ffpdriver; // Corr. NDIS driver handle for IF
  259. NDIS_STATUS (__stdcall *lip_setndisrequest)(void *, NDIS_OID, uint);
  260. NDIS_STATUS (__stdcall *lip_dowakeupptrn)(void *, PNET_PM_WAKEUP_PATTERN_DESC, USHORT, BOOLEAN);
  261. void (__stdcall *lip_pnpcomplete)(void *, NDIS_STATUS, PNET_PNP_EVENT);
  262. NDIS_STATUS (__stdcall *lip_arpresolveip)(void *, IPAddr, void *);
  263. uint lip_MaxOffLoadSize;
  264. uint lip_MaxSegments;
  265. BOOLEAN (__stdcall *lip_arpflushate)(void *, IPAddr );
  266. void (__stdcall *lip_arpflushallate)(void *);
  267. void (__stdcall *lip_closelink)(void *, void *);
  268. uint lip_pnpcap;
  269. #if !MILLEN
  270. ARP_CANCEL lip_cancelpackets;
  271. #endif
  272. };
  273. #define LIP_COPY_FLAG 1 // Copy lookahead flag.
  274. #define LIP_P2P_FLAG 2 // Interface is point to point
  275. #define LIP_NOIPADDR_FLAG 4 // Unnumbered interface
  276. #define LIP_P2MP_FLAG 8 // P2MP interface
  277. #define LIP_NOLINKBCST_FLAG 0x10 // No link bcast
  278. #define LIP_UNI_FLAG 0x20 // Uni-direction adapter.
  279. typedef struct LLIPBindInfo LLIPBindInfo;
  280. //* Status codes from the lower layer.
  281. #define LLIP_STATUS_MTU_CHANGE 1
  282. #define LLIP_STATUS_SPEED_CHANGE 2
  283. #define LLIP_STATUS_ADDR_MTU_CHANGE 3
  284. //* The LLIP_STATUS_MTU_CHANGE passed a pointer to this structure.
  285. struct LLIPMTUChange {
  286. uint lmc_mtu; // New MTU.
  287. }; /* LLIPMTUChange */
  288. typedef struct LLIPMTUChange LLIPMTUChange;
  289. //* The LLIP_STATUS_SPEED_CHANGE passed a pointer to this structure.
  290. struct LLIPSpeedChange {
  291. uint lsc_speed; // New speed.
  292. }; /* LLIPSpeedChange */
  293. typedef struct LLIPSpeedChange LLIPSpeedChange;
  294. //* The LLIP_STATUS_ADDR_MTU_CHANGE passed a pointer to this structure.
  295. struct LLIPAddrMTUChange {
  296. uint lam_mtu; // New MTU.
  297. uint lam_addr; // Address that changed.
  298. }; /* LLIPAddrMTUChange */
  299. typedef struct LLIPAddrMTUChange LLIPAddrMTUChange;
  300. typedef
  301. int
  302. (__stdcall *LLIPRegRtn)(
  303. IN PNDIS_STRING InterfaceName,
  304. IN void * IpInterfaceContext,
  305. IN struct _IP_HANDLERS * IpHandlers,
  306. OUT struct LLIPBindInfo * ARPBindInfo,
  307. IN uint InterfaceNumber
  308. );
  309. //
  310. // ARP Module interface prototypes used during IP <-> ARP interface initialization.
  311. //
  312. typedef
  313. IP_STATUS
  314. (__stdcall *IP_ADD_INTERFACE)(
  315. IN PNDIS_STRING DeviceName,
  316. IN PNDIS_STRING IfName, OPTIONAL
  317. IN PNDIS_STRING ConfigurationHandle,
  318. IN void * PNPContext,
  319. IN void * ARPInterfaceContext,
  320. IN LLIPRegRtn RegRtn,
  321. IN struct LLIPBindInfo * ARPBindInfo,
  322. IN UINT RequestedIndex,
  323. IN ULONG MediaType,
  324. IN UCHAR AccessType,
  325. IN UCHAR ConnectionType
  326. );
  327. typedef
  328. void
  329. (__stdcall *IP_DEL_INTERFACE)(
  330. IN void * IPInterfaceContext,
  331. IN BOOLEAN DeleteIndex
  332. );
  333. typedef
  334. void
  335. (__stdcall *IP_BIND_COMPLETE)(
  336. IN IP_STATUS BindStatus,
  337. IN void * BindContext
  338. );
  339. typedef
  340. int
  341. (__stdcall *ARP_BIND)(
  342. IN PNDIS_STATUS RetStatus,
  343. IN NDIS_HANDLE BindContext,
  344. IN PNDIS_STRING AdapterName,
  345. IN PVOID SS1,
  346. IN PVOID SS2
  347. );
  348. typedef
  349. IP_STATUS
  350. (__stdcall *IP_ADD_LINK)(
  351. IN void *IpIfCtxt,
  352. IN IPAddr NextHop,
  353. IN void *ArpLinkCtxt,
  354. OUT void **IpLnkCtxt,
  355. IN uint mtu
  356. );
  357. typedef
  358. IP_STATUS
  359. (__stdcall *IP_DELETE_LINK)(
  360. IN void *IpIfCtxt,
  361. IN void *LnkCtxt
  362. );
  363. typedef
  364. NTSTATUS
  365. (__stdcall *IP_RESERVE_INDEX)(
  366. IN ULONG ulNumIndices,
  367. OUT PULONG pulStartIndex,
  368. OUT PULONG pulLongestRun
  369. );
  370. typedef
  371. VOID
  372. (__stdcall *IP_DERESERVE_INDEX)(
  373. IN ULONG ulNumIndices,
  374. IN ULONG ulStartIndex
  375. );
  376. typedef
  377. NTSTATUS
  378. (__stdcall *IP_CHANGE_INDEX)(
  379. IN PVOID pvContext,
  380. IN ULONG ulNewIndex,
  381. IN PUNICODE_STRING pusNewName OPTIONAL
  382. );
  383. //
  384. // Exported IP interface used by the ARP modules
  385. //
  386. NTSTATUS
  387. __stdcall
  388. IPRegisterARP(
  389. IN PNDIS_STRING ARPName,
  390. IN uint Version, /* Suggested value of 0x50000 for NT 5.0 and memphis */
  391. IN ARP_BIND ARPBindHandler,
  392. OUT IP_ADD_INTERFACE * IpAddInterfaceHandler,
  393. OUT IP_DEL_INTERFACE * IpDeleteInterfaceHandler,
  394. OUT IP_BIND_COMPLETE * IpBindCompleteHandler,
  395. OUT IP_ADD_LINK * IpAddLinkHandler,
  396. OUT IP_DELETE_LINK * IpDeleteLinkHandler,
  397. OUT IP_CHANGE_INDEX * IpChangeIndex,
  398. OUT IP_RESERVE_INDEX * IpReserveIndex,
  399. OUT IP_DERESERVE_INDEX * IpDereserveIndex,
  400. OUT HANDLE * ARPRegisterHandle
  401. );
  402. NTSTATUS
  403. __stdcall
  404. IPDeregisterARP(
  405. IN HANDLE ARPRegisterHandle
  406. );
  407. //
  408. // exported via Dll entrypoints.
  409. //
  410. extern IP_STATUS
  411. IPAddInterface(
  412. PNDIS_STRING DeviceName,
  413. PNDIS_STRING IfName, OPTIONAL
  414. PNDIS_STRING ConfigName,
  415. void *PNP,
  416. void *Context,
  417. LLIPRegRtn RegRtn,
  418. LLIPBindInfo *BindInfo,
  419. UINT RequestedIndex,
  420. ULONG MediaType,
  421. UCHAR AccessType,
  422. UCHAR ConnectionType
  423. );
  424. extern void IPDelInterface(void *Context , BOOLEAN DeleteIndex);
  425. extern IP_STATUS IPAddLink(void *IpIfCtxt, IPAddr NextHop, void *ArpLinkCtxt, void **IpLnkCtxt, uint mtu);
  426. extern IP_STATUS IPDeleteLink(void *IpIfCtxt, void *LnkCtxt);
  427. //
  428. // Registration IOCTL code definition -
  429. //
  430. // This IOCTL is issued to a lower layer driver to retrieve the address
  431. // of its registration function. There is no input buffer. The output
  432. // buffer will contain a LLIPIF_REGISTRATION_DATA structure. This
  433. // buffer is pointed to by Irp->AssociatedIrp.SystemBuffer and should be
  434. // filled in before completion.
  435. //
  436. //
  437. // structure passed in the registration IOCTL.
  438. //
  439. typedef struct llipif_registration_data {
  440. LLIPRegRtn RegistrationFunction;
  441. } LLIPIF_REGISTRATION_DATA;
  442. typedef IP_ADD_INTERFACE IPAddInterfacePtr;
  443. typedef IP_DEL_INTERFACE IPDelInterfacePtr;
  444. //* Structure used in IOCTL_IP_GET_PNP_ARP_POINTERS ioctl sent to \device\ip by ARP modules
  445. //
  446. typedef struct ip_get_arp_pointers {
  447. IPAddInterfacePtr IPAddInterface ; // Pointer to IP's add interface routine
  448. IPDelInterfacePtr IPDelInterface ; // Pointer to IP's del interface routine
  449. } IP_GET_PNP_ARP_POINTERS, *PIP_GET_PNP_ARP_POINTERS ;
  450. #define FSCTL_LLIPIF_BASE FILE_DEVICE_NETWORK
  451. #define _LLIPIF_CTL_CODE(function, method, access) \
  452. CTL_CODE(FSCTL_LLIPIF_BASE, function, method, access)
  453. #define IOCTL_LLIPIF_REGISTER \
  454. _LLIPIF_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  455. #endif // LLIPIF_INCLUDED