Source code of Windows XP (NT5)
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.

538 lines
15 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. int
  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; //HW check sum capabilities flag
  256. ulong lip_ffpversion; // Version of FFP Supported or 0
  257. ULONG_PTR lip_ffpdriver; // Corr. NDIS driver handle for IF
  258. NDIS_STATUS (__stdcall *lip_setndisrequest)(void *, NDIS_OID, uint);
  259. NDIS_STATUS (__stdcall *lip_dowakeupptrn)(void *, PNET_PM_WAKEUP_PATTERN_DESC, USHORT, BOOLEAN);
  260. void (__stdcall *lip_pnpcomplete)(void *, NDIS_STATUS, PNET_PNP_EVENT);
  261. NDIS_STATUS (__stdcall *lip_arpresolveip)(void *, IPAddr, void *);
  262. uint lip_MaxOffLoadSize;
  263. uint lip_MaxSegments;
  264. BOOLEAN (__stdcall *lip_arpflushate)(void *, IPAddr );
  265. void (__stdcall *lip_arpflushallate)(void *);
  266. void (__stdcall *lip_closelink)(void *, void *);
  267. uint lip_pnpcap;
  268. #if !MILLEN
  269. ARP_CANCEL lip_cancelpackets;
  270. #endif
  271. };
  272. #define LIP_COPY_FLAG 1 // Copy lookahead flag.
  273. #define LIP_P2P_FLAG 2 // Interface is point to point
  274. #define LIP_NOIPADDR_FLAG 4 // Unnumbered interface
  275. #define LIP_P2MP_FLAG 8 // P2MP interface
  276. #define LIP_NOLINKBCST_FLAG 0x10 // No link bcast
  277. #define LIP_UNI_FLAG 0x20 // Uni-direction adapter.
  278. typedef struct LLIPBindInfo LLIPBindInfo;
  279. //* Status codes from the lower layer.
  280. #define LLIP_STATUS_MTU_CHANGE 1
  281. #define LLIP_STATUS_SPEED_CHANGE 2
  282. #define LLIP_STATUS_ADDR_MTU_CHANGE 3
  283. //* The LLIP_STATUS_MTU_CHANGE passed a pointer to this structure.
  284. struct LLIPMTUChange {
  285. uint lmc_mtu; // New MTU.
  286. }; /* LLIPMTUChange */
  287. typedef struct LLIPMTUChange LLIPMTUChange;
  288. //* The LLIP_STATUS_SPEED_CHANGE passed a pointer to this structure.
  289. struct LLIPSpeedChange {
  290. uint lsc_speed; // New speed.
  291. }; /* LLIPSpeedChange */
  292. typedef struct LLIPSpeedChange LLIPSpeedChange;
  293. //* The LLIP_STATUS_ADDR_MTU_CHANGE passed a pointer to this structure.
  294. struct LLIPAddrMTUChange {
  295. uint lam_mtu; // New MTU.
  296. uint lam_addr; // Address that changed.
  297. }; /* LLIPAddrMTUChange */
  298. typedef struct LLIPAddrMTUChange LLIPAddrMTUChange;
  299. typedef
  300. int
  301. (__stdcall *LLIPRegRtn)(
  302. IN PNDIS_STRING InterfaceName,
  303. IN void * IpInterfaceContext,
  304. IN struct _IP_HANDLERS * IpHandlers,
  305. OUT struct LLIPBindInfo * ARPBindInfo,
  306. IN uint InterfaceNumber
  307. );
  308. //
  309. // ARP Module interface prototypes used during IP <-> ARP interface initialization.
  310. //
  311. typedef
  312. IP_STATUS
  313. (__stdcall *IP_ADD_INTERFACE)(
  314. IN PNDIS_STRING DeviceName,
  315. IN PNDIS_STRING IfName, OPTIONAL
  316. IN PNDIS_STRING ConfigurationHandle,
  317. IN void * PNPContext,
  318. IN void * ARPInterfaceContext,
  319. IN LLIPRegRtn RegRtn,
  320. IN struct LLIPBindInfo * ARPBindInfo,
  321. IN UINT RequestedIndex,
  322. IN ULONG MediaType,
  323. IN UCHAR AccessType,
  324. IN UCHAR ConnectionType
  325. );
  326. typedef
  327. void
  328. (__stdcall *IP_DEL_INTERFACE)(
  329. IN void * IPInterfaceContext,
  330. IN BOOLEAN DeleteIndex
  331. );
  332. typedef
  333. void
  334. (__stdcall *IP_BIND_COMPLETE)(
  335. IN IP_STATUS BindStatus,
  336. IN void * BindContext
  337. );
  338. typedef
  339. int
  340. (__stdcall *ARP_BIND)(
  341. IN PNDIS_STATUS RetStatus,
  342. IN NDIS_HANDLE BindContext,
  343. IN PNDIS_STRING AdapterName,
  344. IN PVOID SS1,
  345. IN PVOID SS2
  346. );
  347. typedef
  348. IP_STATUS
  349. (__stdcall *IP_ADD_LINK)(
  350. IN void *IpIfCtxt,
  351. IN IPAddr NextHop,
  352. IN void *ArpLinkCtxt,
  353. OUT void **IpLnkCtxt,
  354. IN uint mtu
  355. );
  356. typedef
  357. IP_STATUS
  358. (__stdcall *IP_DELETE_LINK)(
  359. IN void *IpIfCtxt,
  360. IN void *LnkCtxt
  361. );
  362. typedef
  363. NTSTATUS
  364. (__stdcall *IP_RESERVE_INDEX)(
  365. IN ULONG ulNumIndices,
  366. OUT PULONG pulStartIndex,
  367. OUT PULONG pulLongestRun
  368. );
  369. typedef
  370. VOID
  371. (__stdcall *IP_DERESERVE_INDEX)(
  372. IN ULONG ulNumIndices,
  373. IN ULONG ulStartIndex
  374. );
  375. typedef
  376. NTSTATUS
  377. (__stdcall *IP_CHANGE_INDEX)(
  378. IN PVOID pvContext,
  379. IN ULONG ulNewIndex,
  380. IN PUNICODE_STRING pusNewName OPTIONAL
  381. );
  382. //
  383. // Exported IP interface used by the ARP modules
  384. //
  385. NTSTATUS
  386. __stdcall
  387. IPRegisterARP(
  388. IN PNDIS_STRING ARPName,
  389. IN uint Version, /* Suggested value of 0x50000 for NT 5.0 and memphis */
  390. IN ARP_BIND ARPBindHandler,
  391. OUT IP_ADD_INTERFACE * IpAddInterfaceHandler,
  392. OUT IP_DEL_INTERFACE * IpDeleteInterfaceHandler,
  393. OUT IP_BIND_COMPLETE * IpBindCompleteHandler,
  394. OUT IP_ADD_LINK * IpAddLinkHandler,
  395. OUT IP_DELETE_LINK * IpDeleteLinkHandler,
  396. OUT IP_CHANGE_INDEX * IpChangeIndex,
  397. OUT IP_RESERVE_INDEX * IpReserveIndex,
  398. OUT IP_DERESERVE_INDEX * IpDereserveIndex,
  399. OUT HANDLE * ARPRegisterHandle
  400. );
  401. NTSTATUS
  402. __stdcall
  403. IPDeregisterARP(
  404. IN HANDLE ARPRegisterHandle
  405. );
  406. //
  407. // exported via Dll entrypoints.
  408. //
  409. extern IP_STATUS
  410. IPAddInterface(
  411. PNDIS_STRING DeviceName,
  412. PNDIS_STRING IfName, OPTIONAL
  413. PNDIS_STRING ConfigName,
  414. void *PNP,
  415. void *Context,
  416. LLIPRegRtn RegRtn,
  417. LLIPBindInfo *BindInfo,
  418. UINT RequestedIndex,
  419. ULONG MediaType,
  420. UCHAR AccessType,
  421. UCHAR ConnectionType
  422. );
  423. extern void IPDelInterface(void *Context , BOOLEAN DeleteIndex);
  424. extern IP_STATUS IPAddLink(void *IpIfCtxt, IPAddr NextHop, void *ArpLinkCtxt, void **IpLnkCtxt, uint mtu);
  425. extern IP_STATUS IPDeleteLink(void *IpIfCtxt, void *LnkCtxt);
  426. //
  427. // Registration IOCTL code definition -
  428. //
  429. // This IOCTL is issued to a lower layer driver to retrieve the address
  430. // of its registration function. There is no input buffer. The output
  431. // buffer will contain a LLIPIF_REGISTRATION_DATA structure. This
  432. // buffer is pointed to by Irp->AssociatedIrp.SystemBuffer and should be
  433. // filled in before completion.
  434. //
  435. //
  436. // structure passed in the registration IOCTL.
  437. //
  438. typedef struct llipif_registration_data {
  439. LLIPRegRtn RegistrationFunction;
  440. } LLIPIF_REGISTRATION_DATA;
  441. typedef IP_ADD_INTERFACE IPAddInterfacePtr;
  442. typedef IP_DEL_INTERFACE IPDelInterfacePtr;
  443. //* Structure used in IOCTL_IP_GET_PNP_ARP_POINTERS ioctl sent to \device\ip by ARP modules
  444. //
  445. typedef struct ip_get_arp_pointers {
  446. IPAddInterfacePtr IPAddInterface ; // Pointer to IP's add interface routine
  447. IPDelInterfacePtr IPDelInterface ; // Pointer to IP's del interface routine
  448. } IP_GET_PNP_ARP_POINTERS, *PIP_GET_PNP_ARP_POINTERS ;
  449. #define FSCTL_LLIPIF_BASE FILE_DEVICE_NETWORK
  450. #define _LLIPIF_CTL_CODE(function, method, access) \
  451. CTL_CODE(FSCTL_LLIPIF_BASE, function, method, access)
  452. #define IOCTL_LLIPIF_REGISTER \
  453. _LLIPIF_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  454. #endif // LLIPIF_INCLUDED