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.

3355 lines
95 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. priv.h
  5. Abstract:
  6. Private structure definitions and function templates for the 1394 ARP module.
  7. Author:
  8. Revision History:
  9. Who When What
  10. -------- -------- ----
  11. josephj 11-17-98 created
  12. --*/
  13. #define ARP1394_SYMBOLIC_NAME L"\\DosDevices\\ARP1394"
  14. #define ARP1394_DEVICE_NAME L"\\Device\\ARP1394"
  15. #define ARP1394_UL_NAME L"ARP1394"
  16. #define ARP1394_LL_NAME L"TCPIP_ARP1394"
  17. #define ARP1394_NDIS_MAJOR_VERSION 5
  18. #define ARP1394_NDIS_MINOR_VERSION 0
  19. // The physical address length, as reported to IP in the following places:
  20. //
  21. // IFEntry.if_physaddr (on WIN98, IFEntry.if_physaddr is truncated to 6 bytes)
  22. // LLIPBindInfo.lip_addr
  23. // IPNetToMediaEntry.inme_physaddr
  24. //
  25. // Note that may be (and in fact currently is) less then the actual length of
  26. // the actual IEEE1394 FIFO physical-address length.
  27. //
  28. #define ARP1394_IP_PHYSADDR_LEN 6 // TODO: make 8
  29. // The levels of the various types of locks
  30. //
  31. enum
  32. {
  33. LOCKLEVEL_GLOBAL=1, // Must start > 0.
  34. LOCKLEVEL_ADAPTER,
  35. LOCKLEVEL_IF_SEND
  36. };
  37. #define ARP1394_GLOBALS_SIG 'G31A'
  38. // TODO: read this from configuration. Set default based on the ip/1394 standard.
  39. //
  40. #define ARP1394_ADAPTER_MTU 1520
  41. #define ARP1394_MAX_PROTOCOL_PKTS 1000
  42. #define ARP1394_MAX_PROTOCOL_PACKET_SIZE 1600 // We need to forward between ICS.
  43. #define ARP1394_ADDRESS_RESOLUTION_TIMEOUT 1000 // Ms
  44. #define ARP1394_MAX_ETHERNET_PKTS 4
  45. // Delay between polling for connect status.
  46. //
  47. #define ARP1394_WAIT_FOR_CONNECT_STATUS_TIMEOUT 5000
  48. //
  49. // Packet flags for packets allocated by us.
  50. // Go into protocol-context (pc_common.pc_flags) of the packet.
  51. //
  52. #define ARP1394_PACKET_FLAGS_ARP 0
  53. #define ARP1394_PACKET_FLAGS_ICS 1
  54. #define ARP1394_PACKET_FLAGS_MCAP 2
  55. #define ARP1394_PACKET_FLAGS_DBGCOPY 3
  56. #define ARP1394_PACKET_FLAGS_IOCTL 4
  57. //
  58. // Pre allocation constants to avoid low memory condition
  59. //
  60. #define ARP1394_BACKUP_TASKS 4
  61. // Forward references
  62. //
  63. typedef struct _ARP1394_INTERFACE ARP1394_INTERFACE;
  64. typedef struct _ARPCB_LOCAL_IP ARPCB_LOCAL_IP;
  65. typedef struct _ARPCB_REMOTE_IP ARPCB_REMOTE_IP;
  66. typedef struct _ARPCB_REMOTE_ETH ARPCB_REMOTE_ETH;
  67. typedef struct _ARPCB_DEST ARPCB_DEST, *PARPCB_DEST;
  68. typedef IPAddr IP_ADDRESS, *PIP_ADDRESS;
  69. typedef IPMask IP_MASK, *PIP_MASK;
  70. typedef int MYBOOL; // Like BOOL
  71. typedef struct _ARP1394_GLOBALS
  72. {
  73. RM_OBJECT_HEADER Hdr;
  74. RM_LOCK Lock;
  75. // Driver global state
  76. //
  77. struct
  78. {
  79. // Handle to Driver Object for ARP1394
  80. //
  81. PVOID pDriverObject;
  82. // Handle to the single device object representing this driver.
  83. //
  84. PVOID pDeviceObject;
  85. } driver;
  86. // Global NDIS State
  87. //
  88. struct
  89. {
  90. // NDIS' protocol handle, returned in NdisRegisterProtocol
  91. //
  92. NDIS_HANDLE ProtocolHandle;
  93. // NDIS Protocol characteristics
  94. //
  95. NDIS_PROTOCOL_CHARACTERISTICS PC;
  96. // NDIS Client characteristics
  97. NDIS_CLIENT_CHARACTERISTICS CC;
  98. } ndis;
  99. // Global IP State
  100. //
  101. struct
  102. {
  103. // Handle returned by IPRegisterARP
  104. //
  105. HANDLE ARPRegisterHandle;
  106. // Following are callback's into IP, set in IPRegisterARP
  107. //
  108. IP_ADD_INTERFACE pAddInterfaceRtn; // add an interface
  109. IP_DEL_INTERFACE pDelInterfaceRtn; // delete an interface
  110. IP_BIND_COMPLETE pBindCompleteRtn; // inform of bind cmpl
  111. IP_ADD_LINK pAddLinkRtn;
  112. IP_DELETE_LINK pDeleteLinkRtn;
  113. } ip;
  114. // Global adapter list
  115. //
  116. struct {
  117. RM_GROUP Group;
  118. } adapters;
  119. // Global List of backup tasks
  120. SLIST_HEADER BackupTasks;
  121. NDIS_SPIN_LOCK BackupTaskLock;
  122. UINT NumTasks;
  123. }
  124. ARP1394_GLOBALS;
  125. extern ARP1394_GLOBALS ArpGlobals;
  126. typedef struct // ARP1394_ADAPTER
  127. {
  128. RM_OBJECT_HEADER Hdr;
  129. RM_LOCK Lock;
  130. //
  131. // PRIMARY_STATE flags (in Hdr.State)
  132. //
  133. // PRIMARY_STATE is the primary state of the adapter.
  134. //
  135. #define ARPAD_PS_MASK 0x00f
  136. #define ARPAD_PS_DEINITED 0x000
  137. #define ARPAD_PS_INITED 0x001
  138. #define ARPAD_PS_FAILEDINIT 0x002
  139. #define ARPAD_PS_INITING 0x003
  140. #define ARPAD_PS_REINITING 0x004
  141. #define ARPAD_PS_DEINITING 0x005
  142. #define SET_AD_PRIMARY_STATE(_pAD, _IfState) \
  143. RM_SET_STATE(_pAD, ARPAD_PS_MASK, _IfState)
  144. #define CHECK_AD_PRIMARY_STATE(_pAD, _IfState) \
  145. RM_CHECK_STATE(_pAD, ARPAD_PS_MASK, _IfState)
  146. #define GET_AD_PRIMARY_STATE(_pAD) \
  147. RM_GET_STATE(_pAD, ARPAD_PS_MASK)
  148. //
  149. // ACTIVE_STATE flags (in Hdr.State)
  150. //
  151. // ACTIVE_STATE is a secondary state of the adapter.
  152. // Primary state takes precedence over secondary sate. For example,
  153. // the interface is REINITING and ACTIVE, one should not actively use the
  154. // interface.
  155. //
  156. // NOTE: When the primary state is INITED, the secondary state WILL be
  157. // ACTIVATED. It is thus usually only necessary to look at the primary state.
  158. //
  159. #define ARPAD_AS_MASK 0x0f0
  160. #define ARPAD_AS_DEACTIVATED 0x000
  161. #define ARPAD_AS_ACTIVATED 0x010
  162. #define ARPAD_AS_FAILEDACTIVATE 0x020
  163. #define ARPAD_AS_DEACTIVATING 0x030
  164. #define ARPAD_AS_ACTIVATING 0x040
  165. #define SET_AD_ACTIVE_STATE(_pAD, _IfState) \
  166. RM_SET_STATE(_pAD, ARPAD_AS_MASK, _IfState)
  167. #define CHECK_AD_ACTIVE_STATE(_pAD, _IfState) \
  168. RM_CHECK_STATE(_pAD, ARPAD_AS_MASK, _IfState)
  169. #define GET_AD_ACTIVE_STATE(_pAD) \
  170. RM_GET_STATE(_pAD, ARPAD_AS_MASK)
  171. // BRIDGE (Ethernet Emulation) state (in Hdr.State)
  172. //
  173. #define ARPAD_BS_MASK 0x100
  174. #define ARPAD_BS_ENABLED 0x100
  175. #define ARP_ENABLE_BRIDGE(_pAD) \
  176. RM_SET_STATE(_pAD, ARPAD_BS_MASK, ARPAD_BS_ENABLED)
  177. #define ARP_BRIDGE_ENABLED(_pAD) \
  178. RM_CHECK_STATE(_pAD, ARPAD_BS_MASK, ARPAD_BS_ENABLED)
  179. #define SET_BS_FLAG(_pAD, _IfState) \
  180. RM_SET_STATE(_pAD, ARPAD_BS_MASK, _IfState)
  181. #define CHECK_BS_FLAG(_pAD, _IfState) \
  182. RM_CHECK_STATE(_pAD, ARPAD_BS_MASK, _IfState)
  183. #define GET_BS_ACTIVE_STATE(_pAD) \
  184. RM_GET_STATE(_pAD, ARPAD_BS_MASK)
  185. #define ARPAD_POWER_MASK 0xf000
  186. #define ARPAD_POWER_LOW_POWER 0x1000
  187. #define ARPAD_POWER_NORMAL 0x0000
  188. #define SET_POWER_STATE(_pAD, _PoState) \
  189. RM_SET_STATE(_pAD, ARPAD_POWER_MASK , _PoState)
  190. #define CHECK_POWER_STATE(_pAD, _PoState) \
  191. RM_CHECK_STATE(_pAD, ARPAD_POWER_MASK, _PoState)
  192. #define GET_POWER_ACTIVE_STATE(_pAD) \
  193. RM_GET_STATE(_pAD, ARPAD_POWER_MASK)
  194. // NDIS bind info.
  195. //
  196. struct
  197. {
  198. NDIS_STRING ConfigName;
  199. NDIS_STRING DeviceName;
  200. PVOID IpConfigHandle;
  201. NDIS_HANDLE BindContext;
  202. // Init/Deinit/Reinit task
  203. //
  204. PRM_TASK pPrimaryTask;
  205. // Activate/Deactivate task
  206. //
  207. PRM_TASK pSecondaryTask;
  208. NDIS_HANDLE AdapterHandle;
  209. // This is read from the configuration information in the registry.
  210. // It is a multisz string, in theory it could contain the config-strings
  211. // of multiple interfaces, although IP/1394 only provides one.
  212. //
  213. NDIS_STRING IpConfigString;
  214. } bind;
  215. // Information about the adapter, obtained by querying it.
  216. // Note: MTU is the MTU reported by the adapter, and is not the same
  217. // as the MTU reported up to ip (the latter MTU is in the ARP1394_INTERFACE
  218. // structure).
  219. //
  220. struct
  221. {
  222. ULONG MTU;
  223. // Maximum speed, in bytes per second, that the local host controller
  224. // is capable of.
  225. //
  226. ULONG Speed;
  227. #if OBSOLETE
  228. // Minimum size (in bytes) of:
  229. // -- Max individual async write to any remote node
  230. // -- Max individual async write to any channel
  231. // -- Max block we can receive on our recv FIFO
  232. // -- Max block we can receive on any channel
  233. //
  234. ULONG MaxBlockSize;
  235. #endif // 0
  236. // max_rec (Maximum bus data record size)
  237. // size == 2^(max_rec+1).
  238. // (Macro IP1394_MAXREC_TO_SIZE in rfc.h)
  239. //
  240. //
  241. ULONG MaxRec;
  242. ULONG MaxSpeedCode;
  243. //NIC1394_FIFO_ADDRESS LocalHwAddress;
  244. UINT64 LocalUniqueID;
  245. UCHAR * szDescription;
  246. UINT DescriptionLength; // including null termination.
  247. // This address is synthesized using the adapter's EU64 unique ID.
  248. //
  249. ENetAddr EthernetMacAddress;
  250. } info;
  251. struct
  252. {
  253. //
  254. // Current Power State
  255. //
  256. NET_DEVICE_POWER_STATE State;
  257. NDIS_EVENT Complete;
  258. //
  259. // Boolean variable to track the state on resume
  260. //
  261. BOOLEAN bReceivedSetPowerD0;
  262. BOOLEAN bReceivedAf;
  263. BOOLEAN bReceivedUnbind;
  264. BOOLEAN bResuming;
  265. BOOLEAN bFailedResume;
  266. }PoMgmt;
  267. // The IP interface control block (only one per adapter).
  268. //
  269. ARP1394_INTERFACE *pIF;
  270. // Bus Topology of the 1394 card below this adapter
  271. //
  272. EUID_TOPOLOGY EuidMap;
  273. //
  274. // Set when a Workitem is queued to query Node Addresses
  275. //
  276. MYBOOL fQueryAddress;
  277. }
  278. ARP1394_ADAPTER, *PARP1394_ADAPTER;
  279. // This structure maintains a pool of buffers, all pointing to
  280. // the same area of memory (whose contents are expected to be CONSTANT).
  281. // The primary use of this structure is to maintain a pool of encapsulation headers
  282. // buffers.
  283. //
  284. typedef struct _ARP_CONST_BUFFER_POOL
  285. {
  286. NDIS_HANDLE NdisHandle; // Buffer pool handle
  287. PRM_OBJECT_HEADER pOwningObject; // ptr to object that owns this list
  288. // Following stuff just for statistics gathering.
  289. // TODO: consider conditionally-compiling this.
  290. //
  291. struct
  292. {
  293. UINT TotBufAllocs; // # allocs from buffer pool
  294. UINT TotCacheAllocs; // # allocs from cache list
  295. UINT TotAllocFails; // # failed allocs
  296. } stats;
  297. UINT NumBuffersToCache; // Number to keep inited and cached
  298. UINT MaxBuffers; // Max number to allocate
  299. UINT cbMem; // Size in bytes of mem below...
  300. const VOID* pvMem; // Ptr to memory containg encap data
  301. UINT NumAllocd; // # outstanding allocs from pool
  302. UINT NumInCache; // # items sitting in cache.
  303. NDIS_SPIN_LOCK NdisLock; // Spinlock protecting the list below
  304. SLIST_HEADER BufferList; // List of available, inited bufs
  305. } ARP_CONST_BUFFER_POOL;
  306. // This structure is used when calling NdisRequest.
  307. //
  308. typedef struct _ARP_NDIS_REQUEST
  309. {
  310. NDIS_REQUEST Request; // The NDIS request structure.
  311. NDIS_EVENT Event; // Event to signal when done.
  312. PRM_TASK pTask; // Task to resume when done.
  313. NDIS_STATUS Status; // Status of completed request.
  314. } ARP_NDIS_REQUEST, *PARP_NDIS_REQUEST;
  315. // Static set of information associated with a VC, mainly co-ndis call handlers.
  316. //
  317. typedef struct
  318. {
  319. PCHAR Description;
  320. CO_SEND_COMPLETE_HANDLER CoSendCompleteHandler;
  321. // CO_STATUS_HANDLER CoStatusHandler;
  322. CO_RECEIVE_PACKET_HANDLER CoReceivePacketHandler;
  323. // CO_AF_REGISTER_NOTIFY_HANDLER CoAfRegisterNotifyHandler;
  324. // CL_MAKE_CALL_COMPLETE_HANDLER ClMakeCallCompleteHandler;
  325. // CL_CLOSE_CALL_COMPLETE_HANDLER ClCloseCallCompleteHandler;
  326. CL_INCOMING_CLOSE_CALL_HANDLER ClIncomingCloseCallHandler;
  327. // Vc type is currently used just for stats. We may get rid of some of the
  328. // handlers above and use the vctype instead.
  329. //
  330. enum
  331. {
  332. ARPVCTYPE_SEND_FIFO,
  333. ARPVCTYPE_RECV_FIFO,
  334. ARPVCTYPE_BROADCAST_CHANNEL,
  335. ARPVCTYPE_MULTI_CHANNEL,
  336. ARPVCTYPE_ETHERNET,
  337. ARPVCTYPE_SEND_CHANNEL,
  338. ARPVCTYPE_RECV_CHANNEL,
  339. } VcType;
  340. BOOLEAN IsDestVc;
  341. } ARP_STATIC_VC_INFO, *PARP_STATIC_VC_INFO;
  342. // ARP's protocol vc context has this common header.
  343. //
  344. typedef struct
  345. {
  346. PARP_STATIC_VC_INFO pStaticInfo;
  347. // Ndis VC handle associated with the VC.
  348. //
  349. NDIS_HANDLE NdisVcHandle;
  350. // These two tasks are for making and tearingdown the VC,
  351. // respectively.
  352. //
  353. PRM_TASK pMakeCallTask;
  354. PRM_TASK pCleanupCallTask;
  355. } ARP_VC_HEADER, *PARP_VC_HEADER;
  356. typedef struct
  357. {
  358. // Channel number.
  359. //
  360. UINT Channel;
  361. // IP multicast group address bound to this channel.
  362. //
  363. IP_ADDRESS GroupAddress;
  364. // Absolute time at which this information was updated,
  365. // in seconds.
  366. //
  367. UINT UpdateTime;
  368. // Absolute time at which this mapping will expire.
  369. // In seconds.
  370. //
  371. UINT ExpieryTime;
  372. UINT SpeedCode;
  373. // TBD
  374. //
  375. UINT Flags; // One of the MCAP_CHANNEL_FLAGS_*
  376. #define MCAP_CHANNEL_FLAGS_LOCALLY_ALLOCATED 0x1
  377. // NodeID of owner of this channel.
  378. //
  379. UINT NodeId;
  380. } MCAP_CHANNEL_INFO, *PMCAP_CHANNEL_INFO;
  381. // The IP interface control block.
  382. //
  383. typedef struct _ARP1394_INTERFACE
  384. {
  385. RM_OBJECT_HEADER Hdr;
  386. //
  387. // PRIMARY_STATE flags (in Hdr.State)
  388. //
  389. // PRIMARY_STATE is the primary state of the interface.
  390. //
  391. #define ARPIF_PS_MASK 0x00f
  392. #define ARPIF_PS_DEINITED 0x000
  393. #define ARPIF_PS_INITED 0x001
  394. #define ARPIF_PS_FAILEDINIT 0x002
  395. #define ARPIF_PS_INITING 0x003
  396. #define ARPIF_PS_REINITING 0x004
  397. #define ARPIF_PS_DEINITING 0x005
  398. #define ARPIF_PS_LOW_POWER 0x006
  399. #define SET_IF_PRIMARY_STATE(_pIF, _IfState) \
  400. RM_SET_STATE(_pIF, ARPIF_PS_MASK, _IfState)
  401. #define CHECK_IF_PRIMARY_STATE(_pIF, _IfState) \
  402. RM_CHECK_STATE(_pIF, ARPIF_PS_MASK, _IfState)
  403. #define GET_IF_PRIMARY_STATE(_pIF) \
  404. RM_GET_STATE(_pIF, ARPIF_PS_MASK)
  405. //
  406. // ACTIVE_STATE flags (in Hdr.State)
  407. //
  408. // ACTIVE_STATE is a secondary state of the interface.
  409. // Primary state takes precedence over secondary sate. For example,
  410. // the interface is REINITING and ACTIVE, one should not actively use the
  411. // interface.
  412. //
  413. // NOTE: When the primary state is INITED, the secondary state WILL be
  414. // ACTIVATED. It is thus usually only necessary to look at the primary state.
  415. //
  416. #define ARPIF_AS_MASK 0x0f0
  417. #define ARPIF_AS_DEACTIVATED 0x000
  418. #define ARPIF_AS_ACTIVATED 0x010
  419. #define ARPIF_AS_FAILEDACTIVATE 0x020
  420. #define ARPIF_AS_DEACTIVATING 0x030
  421. #define ARPIF_AS_ACTIVATING 0x040
  422. #define SET_IF_ACTIVE_STATE(_pIF, _IfState) \
  423. RM_SET_STATE(_pIF, ARPIF_AS_MASK, _IfState)
  424. #define CHECK_IF_ACTIVE_STATE(_pIF, _IfState) \
  425. RM_CHECK_STATE(_pIF, ARPIF_AS_MASK, _IfState)
  426. #define GET_IF_ACTIVE_STATE(_pIF) \
  427. RM_GET_STATE(_pIF, ARPIF_AS_MASK)
  428. //
  429. // IP_STATE flags (in Hdr.State)
  430. //
  431. // This state is set to OPEN when our open handler (ArpIpOpen) is called, and
  432. // to CLOSED when our close handler (ArpIpClose) is called
  433. //
  434. #define ARPIF_IPS_MASK 0xf00
  435. #define ARPIF_IPS_CLOSED 0x000
  436. #define ARPIF_IPS_OPEN 0x100
  437. #define SET_IF_IP_STATE(_pIF, _IfState) \
  438. RM_SET_STATE(_pIF, ARPIF_IPS_MASK, _IfState)
  439. #define CHECK_IF_IP_STATE(_pIF, _IfState) \
  440. RM_CHECK_STATE(_pIF, ARPIF_IPS_MASK, _IfState)
  441. #define GET_IF_IP_STATE(_pIF) \
  442. RM_GET_STATE(_pIF, ARPIF_IPS_MASK)
  443. // Init/Deinit/Reinit task
  444. //
  445. PRM_TASK pPrimaryTask;
  446. // Activate/Deactivate task
  447. //
  448. PRM_TASK pActDeactTask;
  449. // Maintenance task
  450. //
  451. PRM_TASK pMaintenanceTask;
  452. // Ndis-provided handlers and handles.
  453. //
  454. struct
  455. {
  456. // Cashed value of the adapter handle.
  457. //
  458. NDIS_HANDLE AdapterHandle;
  459. // The address family handle.
  460. //
  461. NDIS_HANDLE AfHandle;
  462. } ndis;
  463. // Stuff directly relating to interaction with IP.
  464. //
  465. struct
  466. {
  467. //
  468. // Following passed in from IP.
  469. //
  470. PVOID Context; // Use in calls to IP
  471. ULONG IFIndex; // Interface number
  472. IPRcvRtn RcvHandler; // Indicate Receive
  473. IPTxCmpltRtn TxCmpltHandler; // Transmit Complete
  474. IPStatusRtn StatusHandler;
  475. IPTDCmpltRtn TDCmpltHandler; // Transfer Data Complete
  476. IPRcvCmpltRtn RcvCmpltHandler; // Receive Complete
  477. IPRcvPktRtn RcvPktHandler; // Indicate Receive Packet
  478. IPAddAddrCmpltRtn AddAddrCmplRtn; // called when arp detects address conflicts.
  479. IP_PNP PnPEventHandler;
  480. //
  481. // Following passed up to IP.
  482. //
  483. ULONG MTU; // Max Transmision Unit (bytes)
  484. NDIS_STRING ConfigString;
  485. // Following are for IP's query/set info functionality.
  486. //
  487. UINT ATInstance; // Instance # for this AT Entity
  488. UINT IFInstance; // Instance # for this IF Entity
  489. //
  490. // Other stuff ...
  491. //
  492. // Defaults to all-1's, but may be set by ip to be something different
  493. // (actually the only other possibility is all-0's, when the stack is
  494. // running in "BSD compatibility mode".
  495. // This field is used to decide where a given destination address is
  496. // unicast or not.
  497. //
  498. //
  499. IP_ADDRESS BroadcastAddress;
  500. // This address is used in filling out ARP requests.
  501. //
  502. IP_ADDRESS DefaultLocalAddress;
  503. } ip;
  504. // Statistics
  505. //
  506. // WARNING: arpResetIfStats() zeros this entire structure, then
  507. // selectively re-inits some fields, such as StatsResetTime.
  508. //
  509. struct
  510. {
  511. // Following for MIB stats
  512. //
  513. ULONG LastChangeTime; // Time of last state change
  514. ULONG InOctets; // Input octets
  515. ULONG InUnicastPkts; // Input Unicast packets
  516. ULONG InNonUnicastPkts; // Input Non-unicast packets
  517. ULONG OutOctets; // Output octets
  518. ULONG OutUnicastPkts; // Output Unicast packets
  519. ULONG OutNonUnicastPkts; // Output Non-unicast packets
  520. ULONG InDiscards;
  521. ULONG InErrors;
  522. ULONG UnknownProtos;
  523. ULONG OutDiscards;
  524. ULONG OutErrors;
  525. ULONG OutQlen;
  526. //
  527. // Following for our private statistics gathering.
  528. //
  529. // Timestamp since the last reset of statistics collection.
  530. // Set by a call to NdisGetCurrentSystemTime.
  531. //
  532. LARGE_INTEGER StatsResetTime; // In 100-nanoseconds.
  533. LARGE_INTEGER PerformanceFrequency; // In Hz.
  534. //
  535. // Some send pkt stats
  536. //
  537. struct
  538. {
  539. UINT TotSends;
  540. UINT FastSends;
  541. UINT MediumSends;
  542. UINT SlowSends;
  543. UINT BackFills;
  544. // UINT HeaderBufUses;
  545. // UINT HeaderBufCacheHits;
  546. ARP1394_PACKET_COUNTS SendFifoCounts;
  547. ARP1394_PACKET_COUNTS SendChannelCounts;
  548. } sendpkts;
  549. //
  550. // Some recv pkt stats
  551. //
  552. struct
  553. {
  554. UINT TotRecvs;
  555. UINT NoCopyRecvs;
  556. UINT CopyRecvs;
  557. UINT ResourceRecvs;
  558. ARP1394_PACKET_COUNTS RecvFifoCounts;
  559. ARP1394_PACKET_COUNTS RecvChannelCounts;
  560. } recvpkts;
  561. //
  562. // Task statistics
  563. //
  564. struct
  565. {
  566. UINT TotalTasks;
  567. UINT CurrentTasks;
  568. UINT TimeCounts[ARP1394_NUM_TASKTIME_SLOTS];
  569. } tasks;
  570. //
  571. // Arp cache stats
  572. //
  573. struct {
  574. UINT TotalQueries;
  575. UINT SuccessfulQueries;
  576. UINT FailedQueries;
  577. UINT TotalResponses;
  578. UINT TotalLookups;
  579. // UINT TraverseRatio; << this is picked up by looking into the
  580. // << hash table data structure.
  581. } arpcache;
  582. //
  583. // Call stats
  584. //
  585. struct
  586. {
  587. //
  588. // FIFO-related call stats.
  589. //
  590. UINT TotalSendFifoMakeCalls;
  591. UINT SuccessfulSendFifoMakeCalls;
  592. UINT FailedSendFifoMakeCalls;
  593. UINT IncomingClosesOnSendFifos;
  594. //
  595. // Channel-related call stats.
  596. //
  597. UINT TotalChannelMakeCalls;
  598. UINT SuccessfulChannelMakeCalls;
  599. UINT FailedChannelMakeCalls;
  600. UINT IncomingClosesOnChannels;
  601. } calls;
  602. } stats;
  603. // Group containing local ip addresses, of type ARPCB_LOCAL_IP
  604. //
  605. RM_GROUP LocalIpGroup;
  606. // Group containing remote ip addresses, of type ARPCB_REMOTE_IP
  607. // (this is the arp cache)
  608. //
  609. RM_GROUP RemoteIpGroup;
  610. // Group containing remote ethernet destinations. This group is only used
  611. // if the adapter is operating in bridge mode.
  612. // This is the Ethernet address cache.
  613. //
  614. RM_GROUP RemoteEthGroup;
  615. // Group containing remote h/w distinations, of type ARPCB_DEST
  616. // (each ARPCB_DEST has a group of VCs)
  617. //
  618. RM_GROUP DestinationGroup;
  619. // Group containing the table (bridge only) of dhcp session, and their
  620. // associated physical addresses
  621. //
  622. RM_GROUP EthDhcpGroup;
  623. // Stuff relating to the receive FIFO, which is owned by the interface.
  624. //
  625. //
  626. struct {
  627. ARP_VC_HEADER VcHdr;
  628. // Address offset of the receive VC
  629. //
  630. struct
  631. {
  632. ULONG Off_Low;
  633. USHORT Off_High;
  634. } offset;
  635. } recvinfo;
  636. // This maintains interface-wide information relevant to the send path.
  637. //
  638. struct
  639. {
  640. // Lock used exclusively for sending.
  641. // Protects the following:
  642. // ??? this->sendinfo.listPktsWaitingForHeaders
  643. // ??? this->sendinfo.NumSendPacketsWaiting
  644. // pLocalIp->sendinfo
  645. // pDest->sendinfo
  646. //
  647. //
  648. RM_LOCK Lock;
  649. // List of send packets waiting for header buffers to become available.
  650. //
  651. LIST_ENTRY listPktsWaitingForHeaders;
  652. // Length of the above list
  653. //
  654. UINT NumSendPacketsWaiting;
  655. // Pool of header buffer pool. This is seralized by its OWN lock,
  656. // not by sendinfo.Lock.
  657. //
  658. ARP_CONST_BUFFER_POOL HeaderPool;
  659. // Pool of Channel header buffers. This is serialized by its OWN lock,
  660. // not by sendinfo.Lock
  661. //
  662. ARP_CONST_BUFFER_POOL ChannelHeaderPool;
  663. } sendinfo;
  664. //
  665. // Following 3 are "special" destinations ....
  666. //
  667. // Pointer to the broadcast-channel destination object.
  668. //
  669. PARPCB_DEST pBroadcastDest;
  670. // Pointer to the multi-channel destination object.
  671. //
  672. PARPCB_DEST pMultiChannelDest;
  673. // Pointer to the ethernet destination object.
  674. //
  675. PARPCB_DEST pEthernetDest;
  676. // Stuff relating to running the ARP protocol
  677. // (All serialized by the IF lock (not the IF SEND lock).
  678. //
  679. struct
  680. {
  681. // The NDIS packet pool for ARP pkts.
  682. //
  683. NDIS_HANDLE PacketPool;
  684. // The NDIS buffer pool for ARP pkts.
  685. //
  686. NDIS_HANDLE BufferPool;
  687. // Number of currently allocated packets.
  688. //
  689. LONG NumOutstandingPackets;
  690. // Maximum size of the packet that can be allocated from this pool.
  691. //
  692. UINT MaxBufferSize;
  693. } arp;
  694. // Stuff relating to the Ethernet VC, which is owned by the interface.
  695. //
  696. struct {
  697. // The NDIS packet pool for Ethernet pkts.
  698. //
  699. NDIS_HANDLE PacketPool;
  700. // The NDIS buffer pool for Ethernet packet headers.
  701. //
  702. NDIS_HANDLE BufferPool;
  703. } ethernet;
  704. #define ARP_NUM_CHANNELS 64
  705. struct
  706. {
  707. // Information about each channel. Information includes:
  708. // IP multicast group address and expiry time.
  709. //
  710. MCAP_CHANNEL_INFO rgChannelInfo[ARP_NUM_CHANNELS];
  711. } mcapinfo;
  712. struct
  713. {
  714. PRM_TASK pAfPendingTask;
  715. } PoMgmt;
  716. }
  717. ARP1394_INTERFACE, *PARP1394_INTERFACE;
  718. #define ARP_OBJECT_IS_INTERFACE(_pHdr) ((_pHdr)->Sig == MTAG_INTERFACE)
  719. #define ASSERT_VALID_INTERFACE(_pIF) ASSERT((_pIF)->Hdr.Sig == MTAG_INTERFACE)
  720. #define ARP_WRITELOCK_IF_SEND_LOCK(_pIF, _psr) \
  721. RmDoWriteLock(&(_pIF)->sendinfo.Lock, (_psr))
  722. #define ARP_READLOCK_IF_SEND_LOCK(_pIF, _psr) \
  723. RmDoReadLock(&(_pIF)->sendinfo.Lock, (_psr))
  724. #define ARP_UNLOCK_IF_SEND_LOCK(_pIF, _psr) \
  725. RmDoUnlock(&(_pIF)->sendinfo.Lock, (_psr))
  726. #define ARP_FASTREADLOCK_IF_SEND_LOCK(_pIF) \
  727. NdisAcquireSpinLock(&(_pIF)->sendinfo.Lock.OsLock)
  728. #define ARP_FASTUNLOCK_IF_SEND_LOCK(_pIF) \
  729. NdisReleaseSpinLock(&(_pIF)->sendinfo.Lock.OsLock)
  730. /*++
  731. VOID
  732. ARP_IF_STAT_INCR(
  733. IN ARP1394_INTERFACE * _pIF
  734. IN OPAQUE StatsCounter
  735. )
  736. Increment the specified StatsCounter on an Interface by 1.
  737. --*/
  738. #define ARP_IF_STAT_INCR(_pIF, StatsCounter) \
  739. NdisInterlockedIncrement(&(_pIF)->stats.StatsCounter)
  740. /*++
  741. VOID
  742. ARP_IF_STAT_ADD(
  743. IN ARP1394_INTERFACE * _pIF
  744. IN OPAQUE StatsCounter,
  745. IN ULONG IncrValue
  746. )
  747. Increment the specified StatsCounter on an Interface by the specified IncrValue.
  748. Take a lock on the interface to do so.
  749. --*/
  750. #if BINARY_COMPATIBLE
  751. #define ARP_IF_STAT_ADD(_pIF, StatsCounter, IncrValue) \
  752. ((_pIF)->stats.StatsCounter += (IncrValue))
  753. #else // !BINARY_COMPATIBLE
  754. #define ARP_IF_STAT_ADD(_pIF, StatsCounter, IncrValue) \
  755. InterlockedExchangeAdd(&(_pIF)->stats.StatsCounter, IncrValue)
  756. #endif // !BINARY_COMPATIBLE
  757. //
  758. // This is the table used to store the DHCP entries used in the bridge mode
  759. //
  760. typedef struct _ARP1394_ETH_DHCP_ENTRY
  761. {
  762. RM_OBJECT_HEADER Hdr;
  763. //
  764. // xid - per dhcp session (e.g discover, offer)
  765. //
  766. ULONG xid;
  767. //
  768. // HW address in the dhcp packet.
  769. //
  770. ENetAddr requestorMAC;
  771. //
  772. // New HW address that arp1394 inserts in the dhcp packet
  773. //
  774. ENetAddr newMAC;
  775. //
  776. // Time last checked to be used for aging purposes
  777. //
  778. UINT TimeLastChecked;
  779. //
  780. // Task used in unloading DhcpEntry
  781. //
  782. PRM_TASK pUnloadTask;
  783. }ARP1394_ETH_DHCP_ENTRY, *PARP1394_ETH_DHCP_ENTRY;
  784. typedef enum _ARP_RESUME_CAUSE {
  785. Cause_SetPowerD0,
  786. Cause_AfNotify,
  787. Cause_Unbind
  788. } ARP_RESUME_CAUSE;
  789. //=========================================================================
  790. // N D I S H A N D L E R S
  791. //=========================================================================
  792. INT
  793. ArpNdBindAdapter(
  794. OUT PNDIS_STATUS pStatus,
  795. IN NDIS_HANDLE BindContext,
  796. IN PNDIS_STRING pDeviceName,
  797. IN PVOID SystemSpecific1,
  798. IN PVOID SystemSpecific2
  799. );
  800. VOID
  801. ArpNdUnbindAdapter(
  802. OUT PNDIS_STATUS pStatus,
  803. IN NDIS_HANDLE ProtocolBindingContext,
  804. IN NDIS_HANDLE UnbindContext
  805. );
  806. VOID
  807. ArpNdOpenAdapterComplete(
  808. IN NDIS_HANDLE ProtocolBindingContext,
  809. IN NDIS_STATUS Status,
  810. IN NDIS_STATUS OpenErrorStatus
  811. );
  812. VOID
  813. ArpNdCloseAdapterComplete(
  814. IN NDIS_HANDLE ProtocolBindingContext,
  815. IN NDIS_STATUS Status
  816. );
  817. VOID
  818. ArpNdResetComplete(
  819. IN NDIS_HANDLE ProtocolBindingContext,
  820. IN NDIS_STATUS Status
  821. );
  822. VOID
  823. ArpNdReceiveComplete(
  824. IN NDIS_HANDLE ProtocolBindingContext
  825. );
  826. VOID
  827. ArpNdRequestComplete(
  828. IN NDIS_HANDLE ProtocolBindingContext,
  829. IN PNDIS_REQUEST pNdisRequest,
  830. IN NDIS_STATUS Status
  831. );
  832. VOID
  833. ArpNdStatus(
  834. IN NDIS_HANDLE ProtocolBindingContext,
  835. IN NDIS_STATUS GeneralStatus,
  836. IN PVOID pStatusBuffer,
  837. IN UINT StatusBufferSize
  838. );
  839. VOID
  840. ArpNdStatusComplete(
  841. IN NDIS_HANDLE ProtocolBindingContext
  842. );
  843. VOID
  844. ArpNdSendComplete(
  845. IN NDIS_HANDLE ProtocolBindingContext,
  846. IN PNDIS_PACKET pNdisPacket,
  847. IN NDIS_STATUS Status
  848. );
  849. //
  850. // Following are some connectionless handlers we provide because we're calling
  851. // connectionless entrypoints.
  852. //
  853. NDIS_STATUS
  854. ArpNdReceive (
  855. NDIS_HANDLE ProtocolBindingContext,
  856. NDIS_HANDLE Context,
  857. VOID *Header,
  858. UINT HeaderSize,
  859. VOID *Data,
  860. UINT Size,
  861. UINT TotalSize
  862. );
  863. INT
  864. ArpNdReceivePacket (
  865. NDIS_HANDLE ProtocolBindingContext,
  866. PNDIS_PACKET Packet
  867. );
  868. NDIS_STATUS
  869. ArpNdPnPEvent(
  870. IN NDIS_HANDLE ProtocolBindingContext,
  871. IN PNET_PNP_EVENT pNetPnPEvent
  872. );
  873. VOID
  874. ArpNdUnloadProtocol(
  875. VOID
  876. );
  877. VOID
  878. ArpCoSendComplete(
  879. IN NDIS_STATUS Status,
  880. IN NDIS_HANDLE ProtocolVcContext,
  881. IN PNDIS_PACKET pNdisPacket
  882. );
  883. VOID
  884. ArpCoStatus(
  885. IN NDIS_HANDLE ProtocolBindingContext,
  886. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  887. IN NDIS_STATUS GeneralStatus,
  888. IN PVOID pStatusBuffer,
  889. IN UINT StatusBufferSize
  890. );
  891. UINT
  892. ArpCoReceivePacket(
  893. IN NDIS_HANDLE ProtocolBindingContext,
  894. IN NDIS_HANDLE ProtocolVcContext,
  895. IN PNDIS_PACKET pNdisPacket
  896. );
  897. VOID
  898. ArpCoAfRegisterNotify(
  899. IN NDIS_HANDLE ProtocolBindingContext,
  900. IN PCO_ADDRESS_FAMILY pAddressFamily
  901. );
  902. NDIS_STATUS
  903. ArpCoCreateVc(
  904. IN NDIS_HANDLE ProtocolAfContext,
  905. IN NDIS_HANDLE NdisVcHandle,
  906. OUT PNDIS_HANDLE pProtocolVcContext
  907. );
  908. NDIS_STATUS
  909. ArpCoDeleteVc(
  910. IN NDIS_HANDLE ProtocolVcContext
  911. );
  912. NDIS_STATUS
  913. ArpCoIncomingCall(
  914. IN NDIS_HANDLE ProtocolSapContext,
  915. IN NDIS_HANDLE ProtocolVcContext,
  916. IN OUT PCO_CALL_PARAMETERS pCallParameters
  917. );
  918. VOID
  919. ArpCoCallConnected(
  920. IN NDIS_HANDLE ProtocolVcContext
  921. );
  922. VOID
  923. ArpCoIncomingClose(
  924. IN NDIS_STATUS CloseStatus,
  925. IN NDIS_HANDLE ProtocolVcContext,
  926. IN PVOID pCloseData OPTIONAL,
  927. IN UINT Size OPTIONAL
  928. );
  929. VOID
  930. ArpCoQosChange(
  931. IN NDIS_HANDLE ProtocolVcContext,
  932. IN PCO_CALL_PARAMETERS pCallParameters
  933. );
  934. VOID
  935. ArpCoOpenAfComplete(
  936. IN NDIS_STATUS Status,
  937. IN NDIS_HANDLE ProtocolAfContext,
  938. IN NDIS_HANDLE NdisAfHandle
  939. );
  940. VOID
  941. ArpCoCloseAfComplete(
  942. IN NDIS_STATUS Status,
  943. IN NDIS_HANDLE ProtocolAfContext
  944. );
  945. VOID
  946. ArpCoMakeCallComplete(
  947. IN NDIS_STATUS Status,
  948. IN NDIS_HANDLE ProtocolVcContext,
  949. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  950. IN PCO_CALL_PARAMETERS pCallParameters
  951. );
  952. VOID
  953. ArpCoCloseCallComplete(
  954. IN NDIS_STATUS Status,
  955. IN NDIS_HANDLE ProtocolVcContext,
  956. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL
  957. );
  958. VOID
  959. ArpCoModifyQosComplete(
  960. IN NDIS_STATUS Status,
  961. IN NDIS_HANDLE ProtocolVcContext,
  962. IN PCO_CALL_PARAMETERS pCallParameters
  963. );
  964. NDIS_STATUS
  965. ArpCoRequest(
  966. IN NDIS_HANDLE ProtocolAfContext,
  967. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  968. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  969. IN OUT PNDIS_REQUEST pNdisRequest
  970. );
  971. VOID
  972. ArpCoRequestComplete(
  973. IN NDIS_STATUS Status,
  974. IN NDIS_HANDLE ProtocolAfContext,
  975. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  976. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  977. IN PNDIS_REQUEST pNdisRequest
  978. );
  979. //=========================================================================
  980. // I P H A N D L E R S
  981. //=========================================================================
  982. INT
  983. ArpIpDynRegister(
  984. IN PNDIS_STRING pAdapterString,
  985. IN PVOID IpContext,
  986. IN struct _IP_HANDLERS * pIpHandlers,
  987. IN struct LLIPBindInfo * pBindInfo,
  988. IN UINT InterfaceNumber
  989. );
  990. VOID
  991. ArpIpOpen(
  992. IN PVOID Context
  993. );
  994. VOID
  995. ArpIpClose(
  996. IN PVOID Context
  997. );
  998. UINT
  999. ArpIpAddAddress(
  1000. IN PVOID Context,
  1001. IN UINT AddressType,
  1002. IN IP_ADDRESS IpAddress,
  1003. IN IP_MASK Mask,
  1004. IN PVOID Context2
  1005. );
  1006. UINT
  1007. ArpIpDelAddress(
  1008. IN PVOID Context,
  1009. IN UINT AddressType,
  1010. IN IP_ADDRESS IpAddress,
  1011. IN IP_MASK Mask
  1012. );
  1013. NDIS_STATUS
  1014. ArpIpMultiTransmit(
  1015. IN PVOID Context,
  1016. IN PNDIS_PACKET * pNdisPacketArray,
  1017. IN UINT NumberOfPackets,
  1018. IN IP_ADDRESS Destination,
  1019. IN RouteCacheEntry * pRCE OPTIONAL,
  1020. IN VOID * ArpCtxt
  1021. );
  1022. NDIS_STATUS
  1023. ArpIpTransmit(
  1024. IN PVOID Context,
  1025. IN PNDIS_PACKET pNdisPacket,
  1026. IN IP_ADDRESS Destination,
  1027. IN RouteCacheEntry * pRCE OPTIONAL,
  1028. IN VOID * ArpCtxt
  1029. );
  1030. NDIS_STATUS
  1031. ArpIpTransfer(
  1032. IN PVOID Context,
  1033. IN NDIS_HANDLE Context1,
  1034. IN UINT ArpHdrOffset,
  1035. IN UINT ProtoOffset,
  1036. IN UINT BytesWanted,
  1037. IN PNDIS_PACKET pNdisPacket,
  1038. OUT PUINT pTransferCount
  1039. );
  1040. VOID
  1041. ArpIpInvalidate(
  1042. IN PVOID Context,
  1043. IN RouteCacheEntry * pRCE
  1044. );
  1045. INT
  1046. ArpIpQueryInfo(
  1047. IN PVOID Context,
  1048. IN TDIObjectID * pID,
  1049. IN PNDIS_BUFFER pNdisBuffer,
  1050. IN OUT PUINT pBufferSize,
  1051. IN PVOID QueryContext
  1052. );
  1053. INT
  1054. ArpIpSetInfo(
  1055. IN PVOID Context,
  1056. IN TDIObjectID * pID,
  1057. IN PVOID pBuffer,
  1058. IN UINT BufferSize
  1059. );
  1060. INT
  1061. ArpIpGetEList(
  1062. IN PVOID Context,
  1063. IN TDIEntityID * pEntityList,
  1064. IN OUT PUINT pEntityListSize
  1065. );
  1066. VOID
  1067. ArpIpPnPComplete(
  1068. IN PVOID Context,
  1069. IN NDIS_STATUS Status,
  1070. IN PNET_PNP_EVENT pNetPnPEvent
  1071. );
  1072. NDIS_STATUS
  1073. ArpSendARPApi(
  1074. void * pInterface,
  1075. IPAddr Destination,
  1076. void * pControlBlock
  1077. );
  1078. // The following structure has the general form of NDIS_CO_MEDIA_PARAMETERS.
  1079. // To properly track changes in NDIS_CO_MEDIA_PARAMETERS (however unlikeley!),
  1080. // code which uses any field in this structure should assert that the field is at
  1081. // the same offset as the corresponding NDIS structure.
  1082. // For example:
  1083. // ASSERT(FIELD_OFFSET(ARP1394_CO_MEDIA_PARAMETERS, Parameters)
  1084. // == FIELD_OFFSET(CO_MEDIA_PARAMETERS, MediaSpecific.Parameters))
  1085. //
  1086. //
  1087. typedef struct
  1088. {
  1089. // First 3 fields of CO_MEDIA_PARAMETERS
  1090. //
  1091. ULONG Flags; // TRANSMIT_VC and/or RECEIVE_VC
  1092. ULONG ReceivePriority; // 0 (unused)
  1093. ULONG ReceiveSizeHint; // 0 (unused)
  1094. // Followed by 1st 2 fields of CO_SPECIFIC_PARAMETERS
  1095. //
  1096. ULONG POINTER_ALIGNMENT ParamType; // Set to NIC1394_MEDIA_SPECIFIC
  1097. ULONG Length; // Set to sizeof(NIC1394_MEDIA_PARAMETERS)
  1098. // Followed by the NIC1394-specific media parameters.
  1099. // Note: we can't directly put the NIC1394_MEDIA_PARAMETERS structure here because
  1100. // it (currently) requires 8-byte alignment.
  1101. //
  1102. UCHAR Parameters[sizeof(NIC1394_MEDIA_PARAMETERS)];
  1103. } ARP1394_CO_MEDIA_PARAMETERS;
  1104. typedef enum _TASK_CAUSE {
  1105. SetLowPower = 1,
  1106. SetPowerOn
  1107. }TASK_CAUSE ;
  1108. typedef struct
  1109. {
  1110. RM_TASK TskHdr;
  1111. // Used to save the true return status (typically a failure status,
  1112. // which we don't want to forget during async cleanup).
  1113. //
  1114. NDIS_STATUS ReturnStatus;
  1115. } TASK_ADAPTERINIT, *PTASK_ADAPTERINIT;
  1116. typedef struct
  1117. {
  1118. RM_TASK TskHdr;
  1119. ARP_NDIS_REQUEST ArpNdisRequest;
  1120. NIC1394_LOCAL_NODE_INFO LocalNodeInfo;
  1121. // Following is used to switch to PASSIVE before calling IP's add interface
  1122. // Rtn.
  1123. //
  1124. NDIS_WORK_ITEM WorkItem;
  1125. } TASK_ADAPTERACTIVATE, *PTASK_ADAPTERACTIVATE;
  1126. typedef struct
  1127. {
  1128. RM_TASK TskHdr;
  1129. NDIS_HANDLE pUnbindContext;
  1130. } TASK_ADAPTERSHUTDOWN, *PTASK_ADAPTERSHUTDOWN;
  1131. // This is the task structure to be used with arpTaskActivateInterface
  1132. //
  1133. typedef struct
  1134. {
  1135. RM_TASK TskHdr;
  1136. #if ARP_DEFERIFINIT
  1137. // Following is used when waiting for the adapter to go to connected status
  1138. //
  1139. //
  1140. NDIS_TIMER Timer;
  1141. #endif // ARP_DEFERIFINIT
  1142. // Following is used to switch to PASSIVE before calling IP's add interface
  1143. // Rtn.
  1144. //
  1145. NDIS_WORK_ITEM WorkItem;
  1146. } TASK_ACTIVATE_IF, *PTASK_ACTIVATE_IF;
  1147. // This is the task structure to be used with arpTaskDeactivateInterface
  1148. //
  1149. typedef struct
  1150. {
  1151. RM_TASK TskHdr;
  1152. BOOLEAN fPendingOnIpClose;
  1153. TASK_CAUSE Cause;
  1154. // Following is used to switch to PASSIVE before calling IP's del interface
  1155. // Rtn.
  1156. //
  1157. NDIS_WORK_ITEM WorkItem;
  1158. } TASK_DEACTIVATE_IF, *PTASK_DEACTIVATE_IF;
  1159. // This is the task structure to be used with arpTaskReinitInterface
  1160. //
  1161. typedef struct
  1162. {
  1163. RM_TASK TskHdr;
  1164. NDIS_HANDLE pUnbindContext;
  1165. // Net PnP event to complete when reinit task is done.
  1166. //
  1167. PNET_PNP_EVENT pNetPnPEvent;
  1168. } TASK_REINIT_IF, *PTASK_REINIT_IF;
  1169. typedef struct
  1170. {
  1171. RM_TASK TskHdr;
  1172. // Ndis call params and media params for this call.
  1173. //
  1174. CO_CALL_PARAMETERS CallParams;
  1175. ARP1394_CO_MEDIA_PARAMETERS MediaParams;
  1176. } TASK_MAKECALL;
  1177. // This is the task structure to be used with arpTaskResolveIpAddress
  1178. //
  1179. typedef struct
  1180. {
  1181. RM_TASK TskHdr;
  1182. // Number of retry attempts left before we declare an address resolution failure.
  1183. //
  1184. UINT RetriesLeft;
  1185. // Used for the response timeout
  1186. //
  1187. NDIS_TIMER Timer;
  1188. } TASK_RESOLVE_IP_ADDRESS, *PTASK_RESOLVE_IP_ADDRESS;
  1189. typedef struct
  1190. {
  1191. RM_TASK TskHdr;
  1192. MYBOOL Quit; // If set, task will quit.
  1193. NDIS_TIMER Timer; // Used for the periodically sending out packets.
  1194. PNDIS_PACKET p1394Pkt; // Used for testing forward to ethernet
  1195. PNDIS_PACKET pEthPkt; // Used for sending connectionless ethernet pkts.
  1196. UINT Delay; // Delay (ms) in between sending packets.
  1197. UINT PktType; // Type of operation: do nothing, send over ethernet
  1198. // etc.
  1199. } TASK_ICS_TEST, *PTASK_ICS_TEST;
  1200. typedef struct
  1201. {
  1202. RM_TASK TskHdr;
  1203. MYBOOL Quit; // If set, task will quit.
  1204. NDIS_TIMER Timer; // Used for periodically waking up to do stuff.
  1205. UINT Delay; // Current value of delay (seconds). Can change.
  1206. UINT RemoteIpMaintenanceTime; // Absolute time in seconds
  1207. UINT RemoteEthMaintenanceTime; // Absolute time in seconds
  1208. UINT LocalIpMaintenanceTime; // Absolute time in seconds.
  1209. UINT McapDbMaintenanceTime; // Absolute time in seconds.
  1210. UINT DhcpTableMaintainanceTime; // Absolute time in seconds
  1211. } TASK_IF_MAINTENANCE, *PTASK_IF_MAINTENANCE;
  1212. typedef struct _TASK_BACKUP
  1213. {
  1214. RM_TASK Hdr;
  1215. //
  1216. // We are using Backup Task flag at position 31 because we do
  1217. // not want to conflict with the ResumeDelayed flags
  1218. //
  1219. #define ARP_BACKUP_TASK_MASK 0x80000000
  1220. #define ARP_BACKUP_TASK_FLAG 0x80000000
  1221. #define MARK_TASK_AS_BACKUP(_pT) \
  1222. RM_SET_STATE(_pT, ARP_BACKUP_TASK_MASK , ARP_BACKUP_TASK_FLAG )
  1223. #define CHECK_TASK_IS_BACKUP(_pT) \
  1224. RM_CHECK_STATE(_pT, ARP_BACKUP_TASK_MASK , ARP_BACKUP_TASK_FLAG )
  1225. #define GET_TASK_BACKUP_STATE(_pT) \
  1226. RM_GET_STATE(_pT, ARP_BACKUP_TASK_MASK )
  1227. DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) SLIST_ENTRY List; // Linked list pointing to next task
  1228. } TASK_BACKUP, *PTASK_BACKUP;
  1229. // This structure is used to check whether the IP address assigned to
  1230. // this interface is unique on the subnet
  1231. //
  1232. typedef struct TASK_CONFLICT_IP
  1233. {
  1234. RM_TASK TskHdr;
  1235. // Remote Ip used to resolve the Local IP address
  1236. //
  1237. ARPCB_REMOTE_IP *pRemoteIp;
  1238. //
  1239. // Did this thread create the Remote Ip.
  1240. //
  1241. BOOLEAN fRemoteIpCreated;
  1242. BOOLEAN fLinkedRemoteIp;
  1243. //
  1244. // IP Status to be indicated with the AddAddrCompletion routine
  1245. //
  1246. ULONG IpStatus;
  1247. //
  1248. // Work Item to bring us down to passive
  1249. //
  1250. NDIS_WORK_ITEM WorkItem;
  1251. }TASK_CONFLICT_IP,*PTASK_CONFLICT_IP;
  1252. // This is the task structure to be used with arpTaskResolveIpAddress
  1253. //
  1254. typedef struct
  1255. {
  1256. RM_TASK TskHdr;
  1257. NDIS_WORK_ITEM WorkItem;
  1258. } TASK_UNLOAD_REMOTE, *PTASK_UNLOAD_REMOTE;
  1259. typedef void (*ArpRtn)(void *, IP_STATUS Status);
  1260. typedef struct ARPControlBlock {
  1261. struct ARPControlBlock *next;
  1262. ArpRtn CompletionRtn;
  1263. ulong status;
  1264. ulong PhyAddrLen;
  1265. ulong *PhyAddr;
  1266. } ARPControlBlock;
  1267. typedef struct _TASK_SEND_ARP_API
  1268. {
  1269. RM_TASK TskHdr;
  1270. // Remote Ip used to resolve the Local IP address
  1271. //
  1272. ARPCB_REMOTE_IP *pRemoteIp;
  1273. //
  1274. // Did this thread create the Remote Ip.
  1275. //
  1276. BOOLEAN fRemoteIpCreated;
  1277. BOOLEAN fLinkedRemoteIp;
  1278. //
  1279. // IP Status to be indicated with the AddAddrCompletion routine
  1280. //
  1281. ULONG IpStatus;
  1282. //
  1283. // Arp control block associated with this address
  1284. //
  1285. ARPControlBlock* pSendArpCB;
  1286. //
  1287. // Destination
  1288. //
  1289. IPAddr IPDest;
  1290. //
  1291. // Unique ID of the Destination
  1292. //
  1293. UINT64 UniqueID;
  1294. }TASK_SEND_ARP_API, *PTASK_SEND_ARP_API;
  1295. //
  1296. // This task is used during a SetPower.
  1297. // It contains structures that will be track of the
  1298. // the numbero of calls that are closed /opened
  1299. // and the events that need to be waited for.
  1300. //
  1301. typedef struct _CALL_COUNT
  1302. {
  1303. // Count of Destination that will closeVc
  1304. //
  1305. ULONG DestCount;
  1306. // Event which the Close VC will wait on.
  1307. //
  1308. NDIS_EVENT VcEvent;
  1309. } CALL_COUNT, *PCALL_COUNT;
  1310. typedef struct _TASK_POWER {
  1311. RM_TASK Hdr;
  1312. // Status of the Task
  1313. //
  1314. PNDIS_STATUS pStatus;
  1315. // Power state we are transitioning to
  1316. //
  1317. NET_DEVICE_POWER_STATE PowerState;
  1318. //
  1319. //WorkItem to switch to passive
  1320. NDIS_WORK_ITEM WorkItem;
  1321. //
  1322. // Last working Stage of task - dbg purpose only
  1323. //
  1324. UINT LastStage;
  1325. //
  1326. // Previous state of parent object. This is used so
  1327. // that the object can be placed back into its previous
  1328. // state.
  1329. //
  1330. UINT PrevState;
  1331. } TASK_POWER, *PTASK_POWER;
  1332. //
  1333. // This structure is used to keep track of a close call
  1334. // that originated becuase of a SetPower
  1335. //
  1336. typedef struct _TASK_SET_POWER_CALL
  1337. {
  1338. RM_TASK Hdr;
  1339. TASK_CAUSE Cause;
  1340. // The Call Call Count is used as place to count the number of outstanding close calls
  1341. // It uses DestCount as a place to store this information
  1342. //
  1343. PCALL_COUNT pCount;
  1344. }TASK_SET_POWER_CALL, *PTASK_SET_POWER_CALL;
  1345. //
  1346. // ARP1394_TASK is the union of all tasks structures used in arp1394.
  1347. // arpAllocateTask allocates memory of sizeof(ARP1394_TASK), which is guaranteed
  1348. // to be large enough to hold any task.
  1349. //
  1350. typedef union
  1351. {
  1352. RM_TASK TskHdr;
  1353. TASK_ADAPTERINIT AdapterInit;
  1354. TASK_ADAPTERSHUTDOWN AdapterShutdown;
  1355. TASK_ADAPTERACTIVATE AdapterActivate;
  1356. TASK_ACTIVATE_IF ActivateIf;
  1357. TASK_DEACTIVATE_IF DeactivateIf;
  1358. TASK_REINIT_IF ReinitIf;
  1359. TASK_MAKECALL MakeFifoCall;
  1360. TASK_RESOLVE_IP_ADDRESS ResolveIpAddress;
  1361. TASK_IF_MAINTENANCE IfMaintenance;
  1362. TASK_BACKUP Backup;
  1363. TASK_CONFLICT_IP Conflict;
  1364. TASK_SEND_ARP_API SendArp;
  1365. TASK_UNLOAD_REMOTE Unload;
  1366. TASK_SET_POWER_CALL CloseCall;
  1367. TASK_POWER TaskPower;
  1368. } ARP1394_TASK;
  1369. //
  1370. // ---------------------------- DESTINATION (REMOTE) KEY --------------
  1371. //
  1372. #pragma pack (push, 1)
  1373. typedef union _REMOTE_DEST_KEY
  1374. {
  1375. ENetAddr ENetAddress;
  1376. IPAddr IpAddress;
  1377. UCHAR Addr[ARP_802_ADDR_LENGTH];
  1378. struct
  1379. {
  1380. ULONG u32;
  1381. USHORT u16;
  1382. } u;
  1383. } REMOTE_DEST_KEY, *PREMOTE_DEST_KEY;
  1384. #pragma pack (pop)
  1385. #define REMOTE_DEST_IP_ADDRESS_FLAG 0xffff
  1386. #define IS_REMOTE_DEST_IP_ADDRESS(_R) ((_R)->u.u16 == REMOTE_DEST_IP_ADDRESS_FLAG )
  1387. #define REMOTE_DEST_IP_ADDRESS(_R) ((&(_R)->IpAddress))
  1388. #define REMOTE_DEST_ETH_ADDRESS(_R) ((&(_R)->ENetAddress))
  1389. #define REMOTE_DEST_KEY_INIT(_R) { (_R)->u.u32 = 0; (_R)->u.u16=REMOTE_DEST_IP_ADDRESS_FLAG ; };
  1390. //const REMOTE_DEST_KEY DefaultRemoteDestKey = {0,0,0,0,0xff,0xff};
  1391. //
  1392. // ---------------------------- DESTINATION (REMOTE) IP CONTROL BLOCK --------------
  1393. //
  1394. // Contains information about one destination (remote) IP address.
  1395. //
  1396. // Parent Object: pInterface
  1397. // Lock: It's own lock.
  1398. //
  1399. // There is atmost one ARP Table entry for a given IP address.
  1400. //
  1401. // The IP Entry participates in two lists:
  1402. // (1) A list of all entries that hash to the same bucket in the ARP Table
  1403. // (2) A list of all entries that resolve to the same destination H/W Address --
  1404. // this is only if the IP address is unicast.
  1405. //
  1406. // A pointer to this structure is also used as our context value in the
  1407. // Route Cache Entry prepared by the higher layer protocol(s).
  1408. //
  1409. // Reference Count: We add one to its ref count for each of the following:
  1410. // TBD:
  1411. //
  1412. typedef struct _ARPCB_REMOTE_IP
  1413. {
  1414. RM_OBJECT_HEADER Hdr; // Common header
  1415. //
  1416. // State flags for RemoteIp (in Hdr.State)
  1417. //
  1418. #define ARPREMOTEIP_RESOLVED_MASK 0x0f
  1419. #define ARPREMOTEIP_UNRESOLVED 0x00
  1420. #define ARPREMOTEIP_RESOLVED 0x01
  1421. #define ARPREMOTEIP_SDTYPE_MASK 0x10 // "SD" == Static/Dynamic
  1422. #define ARPREMOTEIP_STATIC 0x00
  1423. #define ARPREMOTEIP_DYNAMIC 0x10
  1424. #define ARPREMOTEIP_FCTYPE_MASK 0x20 // "FC" == FIFO/Channel
  1425. #define ARPREMOTEIP_FIFO 0x00
  1426. #define ARPREMOTEIP_CHANNEL 0x20
  1427. #define ARPREMOTEIP_MCAP_MASK 0x40 // "FC" == FIFO/Channel
  1428. #define ARPREMOTEIP_MCAP_CAPABLE 0x40
  1429. #define SET_REMOTEIP_RESOLVE_STATE(_pRIp, _IfState) \
  1430. RM_SET_STATE(_pRIp, ARPREMOTEIP_RESOLVED_MASK, _IfState)
  1431. #define CHECK_REMOTEIP_RESOLVE_STATE(_pRIp, _IfState) \
  1432. RM_CHECK_STATE(_pRIp, ARPREMOTEIP_RESOLVED_MASK, _IfState)
  1433. #define SET_REMOTEIP_SDTYPE(_pRIp, _IfState) \
  1434. RM_SET_STATE(_pRIp, ARPREMOTEIP_SDTYPE_MASK, _IfState)
  1435. #define CHECK_REMOTEIP_SDTYPE(_pRIp, _IfState) \
  1436. RM_CHECK_STATE(_pRIp, ARPREMOTEIP_SDTYPE_MASK, _IfState)
  1437. #define SET_REMOTEIP_FCTYPE(_pRIp, _IfState) \
  1438. RM_SET_STATE(_pRIp, ARPREMOTEIP_FCTYPE_MASK, _IfState)
  1439. #define CHECK_REMOTEIP_FCTYPE(_pRIp, _IfState) \
  1440. RM_CHECK_STATE(_pRIp, ARPREMOTEIP_FCTYPE_MASK, _IfState)
  1441. #define SET_REMOTEIP_MCAP(_pRIp, _IfState) \
  1442. RM_SET_STATE(_pRIp, ARPREMOTEIP_MCAP_MASK, _IfState)
  1443. #define CHECK_REMOTEIP_MCAP(_pRIp, _IfState) \
  1444. RM_CHECK_STATE(_pRIp, ARPREMOTEIP_MCAP_MASK, _IfState)
  1445. IP_ADDRESS IpAddress; // IP Address
  1446. LIST_ENTRY linkSameDest; // List of entries pointing to
  1447. // the same destination.
  1448. ARPCB_DEST *pDest; // Pointer to destination CB.
  1449. REMOTE_DEST_KEY Key; // Ip address or Mac Address
  1450. #if TODO
  1451. // Timers are: (all exclusive)
  1452. // - Aging timer
  1453. // - Waiting for ARP reply
  1454. // - Waiting for InARP reply
  1455. // - Delay after NAK
  1456. // - Waiting for MARS MULTI
  1457. // - Delay before marking for reval
  1458. #endif // TODO
  1459. ULONG RetriesLeft;
  1460. // The information in this struct is protected by the IF send lock,
  1461. // EXCEPT as noted.
  1462. //
  1463. struct
  1464. {
  1465. // Singly-linked list of Route Cache Entries (no space in RCE to hold
  1466. // a doubly-linked list, unfortunately.)
  1467. //
  1468. RouteCacheEntry *pRceList;
  1469. // listSendPkts is NOT protected by the IF send lock. Instead it is protected
  1470. // by this object(pRemoteIp)'s lock.
  1471. //
  1472. LIST_ENTRY listSendPkts;
  1473. // This entry is NOT protected by any lock. It is set to ZERO
  1474. // each time a packet is sent to this address and is set to the
  1475. // current system time periodically by the garbage collecting task.
  1476. //
  1477. UINT TimeLastChecked;
  1478. } sendinfo;
  1479. PRM_TASK pSendPktsTask;// Points to the task (if any)
  1480. // Attempting to send queued packets.
  1481. PRM_TASK pResolutionTask;// Points to the task (if any)
  1482. // attempting to resolve
  1483. // this destination IP address.
  1484. PRM_TASK pUnloadTask; // Unload (shutdown) this object.
  1485. } ARPCB_REMOTE_IP, *PARPCB_REMOTE_IP;
  1486. #define ASSERT_VALID_REMOTE_IP(_pRemoteIp) \
  1487. ASSERT((_pRemoteIp)->Hdr.Sig == MTAG_REMOTE_IP)
  1488. #define VALID_REMOTE_IP(_pRemoteIp) ((_pRemoteIp)->Hdr.Sig == MTAG_REMOTE_IP)
  1489. //
  1490. // --------------------- DESTINATION (REMOTE) ETHERNET CONTROL BLOCK --------------
  1491. // Creation Params -- passed into the function that creates an
  1492. // instance of a remote ethernet control block.
  1493. //
  1494. typedef struct
  1495. {
  1496. ENetAddr EthAddress;
  1497. IP_ADDRESS IpAddress;
  1498. } ARP_REMOTE_ETH_PARAMS, *PARP_REMOTE_ETH_PARAMS;
  1499. //
  1500. // Contains information about one destination (remote) Ethernet address.
  1501. //
  1502. // Parent Object: pInterface
  1503. // Lock: pInterface
  1504. //
  1505. // There is atmost one Ethernet Table entry for a given Remote ethernet address.
  1506. //
  1507. // The Ethernet entry participates in one group:
  1508. // A list of all entries that hash to the same bucket in the Ethernet Table
  1509. //
  1510. typedef struct _ARPCB_REMOTE_ETH
  1511. {
  1512. RM_OBJECT_HEADER Hdr; // Common header
  1513. IP_ADDRESS IpAddress; // Remote IP address
  1514. ENetAddr EthAddress; // Remote Ethernet MAC addres
  1515. PRM_TASK pUnloadTask; // Unload (shutdown) this object.
  1516. // This entry is NOT protected by any lock. It is set to ZERO
  1517. // each time a packet is sent to this address and is set to the
  1518. // current system time periodically by the garbage collecting task.
  1519. //
  1520. UINT TimeLastChecked;
  1521. } ARPCB_REMOTE_ETH, *PARPCB_REMOTE_ETH;
  1522. #define ASSERT_VALID_REMOTE_ETH(_pRemoteEth) \
  1523. ASSERT((_pRemoteEth)->Hdr.Sig == MTAG_REMOTE_ETH)
  1524. //
  1525. // ---------------------------- LOCAL IP CONTROL BLOCK --------------
  1526. //
  1527. // Contains information about one local IP address.
  1528. //
  1529. // Parent Object: pInterface
  1530. // Lock: uses parent's (pInterface's) lock.
  1531. //
  1532. typedef struct _ARPCB_LOCAL_IP
  1533. {
  1534. RM_OBJECT_HEADER Hdr; // Common header
  1535. //
  1536. // State flags for LocalIp (in Hdr.State)
  1537. //
  1538. #define ARPLOCALIP_MCAP_MASK 0x40
  1539. #define ARPLOCALIP_MCAP_CAPABLE 0x40
  1540. #define SET_LOCALIP_MCAP(_pLIp, _IfState) \
  1541. RM_SET_STATE(_pLIp, ARPLOCALIP_MCAP_MASK, _IfState)
  1542. #define CHECK_LOCALIP_MCAP(_pLIp, _IfState) \
  1543. RM_CHECK_STATE(_pLIp, ARPLOCALIP_MCAP_MASK, _IfState)
  1544. UINT IpAddressType; // One of the LLIP_ADDR_* consts
  1545. IP_ADDRESS IpAddress; // The Address
  1546. IP_MASK IpMask; // Mask for the above.
  1547. UINT AddAddressCount; // No of times address was added
  1548. PVOID pContext2; // context passed into ArpIpAddAddress
  1549. PRM_TASK pRegistrationTask; // Points to the task (if any)
  1550. // that is doing the unsolicited
  1551. // ARP request to report and
  1552. // validate this IP address is
  1553. // owned by the local interface.
  1554. PRM_TASK pUnloadTask; // Unload (shutdown) this object.
  1555. PRM_TASK pConflictTask; // Task to check for Conflicts
  1556. LIST_ENTRY linkSameDest; // List of entries pointing to
  1557. ARPCB_DEST *pDest; // Pointer to destination CB.
  1558. } ARPCB_LOCAL_IP, *PARPCB_LOCAL_IP;
  1559. // Returns true IFF pLocalIp is in the process of going away (assumes
  1560. // pLocalIp's lock is held) ...
  1561. //
  1562. #define ARP_LOCAL_IP_IS_UNLOADING(pLocalIp) (pLocalIp->pUnloadTask != NULL)
  1563. typedef struct
  1564. {
  1565. NIC1394_DESTINATION HwAddr; // Must be 1st for hash function.
  1566. UINT ChannelSeqNo;
  1567. BOOLEAN ReceiveOnly;
  1568. BOOLEAN AcquireChannel;
  1569. } ARP_DEST_PARAMS, *PARP_DEST_PARAMS;
  1570. //
  1571. // ---------------------------- DESTINATION CONTROL BLOCK --------------
  1572. //
  1573. // All information about an remote destination, including list of VCs to it.
  1574. // This is used for both unicast destinations and multicast/broadcast
  1575. // destinations.
  1576. //
  1577. // Parent Object: PARCB_INTERFACE (Interface control block).
  1578. // Lock: uses parent's (Interface).
  1579. //
  1580. typedef struct _ARPCB_DEST
  1581. {
  1582. RM_OBJECT_HEADER Hdr; // Common header
  1583. LIST_ENTRY listIpToThisDest; // List of IP entries that
  1584. // point to this entry
  1585. LIST_ENTRY listLocalIp; // List of local IP entries
  1586. // related to this dest. that
  1587. // (Currently only related to
  1588. // MCAP recv channels, but
  1589. // could be extended to
  1590. // using async stream for
  1591. // FIFO as well!).
  1592. ARP_DEST_PARAMS Params; // Dest HW Address, etc.
  1593. ARP_VC_HEADER VcHdr; // Single VC associated
  1594. // with this object.
  1595. PRM_TASK pUnloadTask; // Unload (shutdown) this object.
  1596. // The following structure is protected by the IF send lock.
  1597. // It contains all the information required for the fast send path.
  1598. //
  1599. struct
  1600. {
  1601. PRM_TASK pSuspendedCleanupCallTask;
  1602. UINT NumOutstandingSends;
  1603. BOOLEAN OkToSend;
  1604. BOOLEAN IsFifo;
  1605. } sendinfo;
  1606. #define ARP_DEST_IS_FIFO(_pDest) ((_pDest)->sendinfo.IsFifo != 0)
  1607. #define ARP_CAN_SEND_ON_DEST(_pDest) ((_pDest)->sendinfo.OkToSend != 0)
  1608. } ARPCB_DEST, *PARPCB_DEST;
  1609. #define ARP_OBJECT_IS_DEST(_pHdr) ((_pHdr)->Sig == MTAG_DEST)
  1610. #define ASSERT_VALID_DEST(_pDest) \
  1611. ASSERTEX((_pDest)->Hdr.Sig == MTAG_DEST, (_pDest))
  1612. #if OBSOLETE
  1613. //
  1614. // ---------------------------- RECV CHANNEL CONTROL BLOCK --------------
  1615. //
  1616. // All information about a receive channel destination.
  1617. //
  1618. // Parent Object: PARCB_INTERFACE (Interface control block).
  1619. // Lock: uses parent's (Interface).
  1620. //
  1621. typedef struct _ARPCB_RCVCH
  1622. {
  1623. RM_OBJECT_HEADER Hdr; // Common header
  1624. LIST_ENTRY listLIpToThisDest; // List of Local IP entries
  1625. // that point to this entry
  1626. NIC1394_DESTINATION HwAddr; // Destination HW Address.
  1627. ARP_VC_HEADER VcHdr; // Single VC associated
  1628. // with this object.
  1629. PRM_TASK pUnloadTask; // Unload (shutdown) this object.
  1630. } ARPCB_DEST, *PARPCB_RCVCH;
  1631. #endif // OBSOLETE
  1632. // Following sits in the miniport-reserved portion of send-pkts, before they
  1633. // are sent out. We have 4 UINT_PTRs of space available to us.
  1634. //
  1635. typedef struct
  1636. {
  1637. LIST_ENTRY linkQueue;
  1638. union
  1639. {
  1640. struct
  1641. {
  1642. IP_ADDRESS IpAddress;
  1643. ULONG Flags;
  1644. #define ARPSPI_BACKFILLED 0x1
  1645. #define ARPSPI_HEADBUF 0x2
  1646. #define ARPSPI_FIFOPKT 0x4
  1647. #define ARPSPI_CHANNELPKT 0x8
  1648. } IpXmit;
  1649. };
  1650. } ARP_SEND_PKT_MPR_INFO;
  1651. //
  1652. // Various macros for getting and setting information saved in the
  1653. // MiniportReserved portion of packets waiting to be sent...
  1654. //
  1655. #define ARP_OUR_CTXT_FROM_SEND_PACKET(_pPkt) \
  1656. ((ARP_SEND_PKT_MPR_INFO *) &(_pPkt)->MiniportReserved)
  1657. #define ARP_SEND_PKT_FROM_OUR_CTXT(_pCtxt) \
  1658. CONTAINING_RECORD((_pCtxt), NDIS_PACKET, MiniportReserved)
  1659. // Our context in the IP RouteCacheEntry.
  1660. // (Max 2 UINT_PTRs available)
  1661. // Since we also want to keep the destination type (FIFO or CHANNEL) in the RCE,
  1662. // we resort to the questionable technique of saving the FIFO/CHANNEL info in
  1663. // LSB bit of the UINT_PTR used for storing the pointer to the RemoteIp object.
  1664. // We want to keep the FIFO/CHANNEL info in the RCE so that we can prepend
  1665. // the correct header block WITHOUT holding the send lock. We want to keep
  1666. // the send lock held for as little time as possible.
  1667. //
  1668. typedef struct
  1669. {
  1670. ARPCB_REMOTE_IP *pRemoteIp; // Ptr to pRemoteIp
  1671. RouteCacheEntry *pNextRce; // Ptr to next RCE associated with the above
  1672. // RemoteIP
  1673. } ARP_RCE_CONTEXT;
  1674. #define ARP_OUR_CTXT_FROM_RCE(_pRCE) \
  1675. ((ARP_RCE_CONTEXT*) &(_pRCE)->rce_context)
  1676. // Parsed version of the IP/1394 ARP packet.
  1677. //
  1678. typedef struct
  1679. {
  1680. NIC1394_FIFO_ADDRESS SenderHwAddr; // requires 8-byte alignment.
  1681. UINT OpCode;
  1682. UINT SenderMaxRec;
  1683. UINT SenderMaxSpeedCode;
  1684. IP_ADDRESS SenderIpAddress;
  1685. IP_ADDRESS TargetIpAddress;
  1686. UCHAR SourceNodeAdddress;
  1687. UCHAR fPktHasNodeAddress;
  1688. ENetAddr SourceMacAddress;
  1689. } IP1394_ARP_PKT_INFO, *PIP1394_ARP_PKT_INFO;
  1690. // Parsed version of the IP/1394 MCAP Group Descriptor
  1691. //
  1692. typedef struct
  1693. {
  1694. UINT Expiration;
  1695. UINT Channel;
  1696. UINT SpeedCode;
  1697. IP_ADDRESS GroupAddress;
  1698. } IP1394_MCAP_GD_INFO, * PIP1394_MCAP_GD_INFO;
  1699. // Parsed version of an IP/1394 MCAP packet.
  1700. //
  1701. typedef struct
  1702. {
  1703. UINT SenderNodeID;
  1704. UINT OpCode;
  1705. UINT NumGroups;
  1706. PIP1394_MCAP_GD_INFO pGdis;
  1707. // Space for storing up-to 4 GD_INFOs
  1708. //
  1709. IP1394_MCAP_GD_INFO GdiSpace[4];
  1710. } IP1394_MCAP_PKT_INFO, *PIP1394_MCAP_PKT_INFO;
  1711. typedef struct _EUID_NODE_MAC_TABLE_WORKITEM
  1712. {
  1713. // WorkItem used in the request
  1714. NDIS_WORK_ITEM WorkItem;
  1715. } EUID_NODE_MAC_TABLE_WORKITEM, *PEUID_NODE_MAC_TABLE_WORKITEM;
  1716. typedef struct _ARP1394_WORK_ITEM ARP1394_WORK_ITEM, *PARP1394_WORK_ITEM;
  1717. typedef
  1718. NDIS_STATUS
  1719. (*ARP_WORK_ITEM_PROC)(
  1720. struct _ARP1394_WORK_ITEM*,
  1721. PRM_OBJECT_HEADER,
  1722. PRM_STACK_RECORD
  1723. );
  1724. typedef struct _ARP1394_WORK_ITEM
  1725. {
  1726. union
  1727. {
  1728. EUID_TOPOLOGY Euid;
  1729. NDIS_WORK_ITEM NdisWorkItem;
  1730. } u;
  1731. ARP_WORK_ITEM_PROC pFunc;
  1732. } ARP1394_WORK_ITEM, *PARP1394_WORK_ITEM;
  1733. // Structure to express the information carried in an IP header
  1734. typedef struct _ARP_IP_HEADER_INFO
  1735. {
  1736. UCHAR protocol;
  1737. IP_ADDRESS ipSource, ipTarget;
  1738. USHORT headerSize;
  1739. ULONG IpHeaderOffset;
  1740. ULONG IpPktLength;
  1741. } ARP_IP_HEADER_INFO, *PARP_IP_HEADER_INFO;
  1742. //=========================================================================
  1743. // I N T E R N A L P R O T O T Y P E S
  1744. //=========================================================================
  1745. NTSTATUS
  1746. ArpDeviceIoControl(
  1747. IN PDEVICE_OBJECT pDeviceObject,
  1748. IN PIRP pIrp
  1749. );
  1750. NTSTATUS
  1751. ArpWmiDispatch(
  1752. IN PDEVICE_OBJECT pDeviceObject,
  1753. IN PIRP pIrp
  1754. );
  1755. NTSTATUS
  1756. ArpHandleIoctlRequest(
  1757. IN PIRP pIrp,
  1758. IN PIO_STACK_LOCATION pIrpSp
  1759. );
  1760. NDIS_STATUS
  1761. arpCfgGetInterfaceConfiguration(
  1762. IN ARP1394_INTERFACE * pIF,
  1763. IN PRM_STACK_RECORD pSR
  1764. );
  1765. NDIS_STATUS
  1766. arpCfgReadAdapterConfiguration(
  1767. IN ARP1394_ADAPTER * pAdapter,
  1768. IN PRM_STACK_RECORD pSR
  1769. );
  1770. NDIS_STATUS
  1771. arpCfgReadInterfaceConfiguration(
  1772. IN NDIS_HANDLE InterfaceConfigHandle,
  1773. IN ARP1394_INTERFACE * pF,
  1774. IN PRM_STACK_RECORD pSR
  1775. );
  1776. NDIS_STATUS
  1777. arpAllocateTask(
  1778. IN PRM_OBJECT_HEADER pParentObject,
  1779. IN PFN_RM_TASK_HANDLER pfnHandler,
  1780. IN UINT Timeout,
  1781. IN const char * szDescription, OPTIONAL
  1782. OUT PRM_TASK *ppTask,
  1783. IN PRM_STACK_RECORD pSR
  1784. );
  1785. VOID
  1786. arpFreeTask(
  1787. IN PRM_TASK pTask,
  1788. IN PRM_STACK_RECORD pSR
  1789. );
  1790. NDIS_STATUS
  1791. arpTaskInitInterface(
  1792. IN PRM_TASK pTask,
  1793. IN RM_TASK_OPERATION Code,
  1794. IN UINT_PTR UserParam, // Unused
  1795. IN PRM_STACK_RECORD pSR
  1796. );
  1797. NDIS_STATUS
  1798. arpTaskDeinitInterface(
  1799. IN PRM_TASK pTask,
  1800. IN RM_TASK_OPERATION Code,
  1801. IN UINT_PTR UserParam, // Unused
  1802. IN PRM_STACK_RECORD pSR
  1803. );
  1804. NDIS_STATUS
  1805. arpTaskReinitInterface(
  1806. IN PRM_TASK pTask,
  1807. IN RM_TASK_OPERATION Code,
  1808. IN UINT_PTR UserParam, // Unused
  1809. IN PRM_STACK_RECORD pSR
  1810. );
  1811. NDIS_STATUS
  1812. arpTaskActivateInterface(
  1813. IN PRM_TASK pTask,
  1814. IN RM_TASK_OPERATION Code,
  1815. IN UINT_PTR UserParam, // Unused
  1816. IN PRM_STACK_RECORD pSR
  1817. );
  1818. NDIS_STATUS
  1819. arpTaskDeactivateInterface(
  1820. IN PRM_TASK pTask,
  1821. IN RM_TASK_OPERATION Code,
  1822. IN UINT_PTR UserParam, // Unused
  1823. IN PRM_STACK_RECORD pSR
  1824. );
  1825. NDIS_STATUS
  1826. arpTaskMakeRecvFifoCall(
  1827. IN PRM_TASK pTask,
  1828. IN RM_TASK_OPERATION Code,
  1829. IN UINT_PTR UserParam, // Unused
  1830. IN PRM_STACK_RECORD pSR
  1831. );
  1832. NDIS_STATUS
  1833. arpTaskCleanupRecvFifoCall(
  1834. IN PRM_TASK pTask,
  1835. IN RM_TASK_OPERATION Code,
  1836. IN UINT_PTR UserParam, // Unused
  1837. IN PRM_STACK_RECORD pSR
  1838. );
  1839. NDIS_STATUS
  1840. arpTaskMakeCallToDest(
  1841. IN PRM_TASK pTask,
  1842. IN RM_TASK_OPERATION Code,
  1843. IN UINT_PTR UserParam, // Unused
  1844. IN PRM_STACK_RECORD pSR
  1845. );
  1846. NDIS_STATUS
  1847. arpTaskCleanupCallToDest(
  1848. IN PRM_TASK pTask,
  1849. IN RM_TASK_OPERATION Code,
  1850. IN UINT_PTR UserParam, // Unused
  1851. IN PRM_STACK_RECORD pSR
  1852. );
  1853. NDIS_STATUS
  1854. arpTaskResolveIpAddress(
  1855. IN struct _RM_TASK * pTask,
  1856. IN RM_TASK_OPERATION Code,
  1857. IN UINT_PTR UserParam,
  1858. IN PRM_STACK_RECORD pSR
  1859. );
  1860. PRM_OBJECT_HEADER
  1861. arpAdapterCreate(
  1862. PRM_OBJECT_HEADER pParentObject,
  1863. PVOID pCreateParams,
  1864. PRM_STACK_RECORD psr
  1865. );
  1866. VOID
  1867. arpDeinitIf(
  1868. PARP1394_INTERFACE pIF,
  1869. PRM_TASK pCallingTask, // OPTIONAL
  1870. UINT SuspendCode, // OPTIONAL
  1871. PRM_STACK_RECORD pSR
  1872. );
  1873. NDIS_STATUS
  1874. arpTaskUnloadLocalIp(
  1875. IN PRM_TASK pTask,
  1876. IN RM_TASK_OPERATION Code,
  1877. IN UINT_PTR UserParam, // Unused
  1878. IN PRM_STACK_RECORD pSR
  1879. );
  1880. NDIS_STATUS
  1881. arpTaskUnloadRemoteIp(
  1882. IN PRM_TASK pTask,
  1883. IN RM_TASK_OPERATION Code,
  1884. IN UINT_PTR UserParam, // Unused
  1885. IN PRM_STACK_RECORD pSR
  1886. );
  1887. NDIS_STATUS
  1888. arpTaskUnloadRemoteEth(
  1889. IN PRM_TASK pTask,
  1890. IN RM_TASK_OPERATION Code,
  1891. IN UINT_PTR UserParam, // Unused
  1892. IN PRM_STACK_RECORD pSR
  1893. );
  1894. NDIS_STATUS
  1895. arpTaskUnloadDestination(
  1896. IN PRM_TASK pTask,
  1897. IN RM_TASK_OPERATION Code,
  1898. IN UINT_PTR UserParam, // Unused
  1899. IN PRM_STACK_RECORD pSR
  1900. );
  1901. VOID
  1902. arpObjectDelete (
  1903. PRM_OBJECT_HEADER pObj,
  1904. PRM_STACK_RECORD psr
  1905. );
  1906. VOID
  1907. arpAdapterDelete (
  1908. PRM_OBJECT_HEADER pObj,
  1909. PRM_STACK_RECORD psr
  1910. );
  1911. NDIS_STATUS
  1912. arpCopyUnicodeString(
  1913. OUT PNDIS_STRING pDest,
  1914. IN PNDIS_STRING pSrc,
  1915. BOOLEAN fUpCase
  1916. );
  1917. NDIS_STATUS
  1918. arpTaskInitializeAdapter(
  1919. IN PRM_TASK pTask,
  1920. IN RM_TASK_OPERATION Code,
  1921. IN UINT_PTR UserParam,
  1922. IN PRM_STACK_RECORD pSR
  1923. );
  1924. NDIS_STATUS
  1925. arpTaskShutdownAdapter(
  1926. IN PRM_TASK pTask,
  1927. IN RM_TASK_OPERATION Code,
  1928. IN UINT_PTR UserParam,
  1929. IN PRM_STACK_RECORD pSR
  1930. );
  1931. NDIS_STATUS
  1932. arpTaskActivateAdapter(
  1933. IN PRM_TASK pTask,
  1934. IN RM_TASK_OPERATION Code,
  1935. IN UINT_PTR UserParam,
  1936. IN PRM_STACK_RECORD pSR
  1937. );
  1938. NDIS_STATUS
  1939. arpTaskDeactivateAdapter(
  1940. IN PRM_TASK pTask,
  1941. IN RM_TASK_OPERATION Code,
  1942. IN UINT_PTR UserParam,
  1943. IN PRM_STACK_RECORD pSR
  1944. );
  1945. NDIS_STATUS
  1946. arpTaskInterfaceTimer(
  1947. IN PRM_TASK pTask,
  1948. IN RM_TASK_OPERATION Code,
  1949. IN UINT_PTR UserParam,
  1950. IN PRM_STACK_RECORD pSR
  1951. );
  1952. NDIS_STATUS
  1953. arpTaskInterfaceTimer(
  1954. IN PRM_TASK pTask,
  1955. IN RM_TASK_OPERATION Code,
  1956. IN UINT_PTR UserParam,
  1957. IN PRM_STACK_RECORD pSR
  1958. );
  1959. NDIS_STATUS
  1960. arpTaskIfMaintenance(
  1961. IN struct _RM_TASK * pTask,
  1962. IN RM_TASK_OPERATION Code,
  1963. IN UINT_PTR UserParam,
  1964. IN PRM_STACK_RECORD pSR
  1965. );
  1966. NDIS_STATUS
  1967. arpInitializeConstBufferPool(
  1968. IN UINT NumBuffersToCache,
  1969. IN UINT MaxBuffers,
  1970. IN const VOID* pvMem,
  1971. IN UINT cbMem,
  1972. IN PRM_OBJECT_HEADER pOwningObject,
  1973. IN OUT ARP_CONST_BUFFER_POOL * pHdrPool,
  1974. IN PRM_STACK_RECORD pSR
  1975. );
  1976. VOID
  1977. arpDeinitializeConstBufferPool(
  1978. IN ARP_CONST_BUFFER_POOL * pHdrPool,
  1979. IN PRM_STACK_RECORD pSR
  1980. );
  1981. PNDIS_BUFFER
  1982. arpAllocateConstBuffer(
  1983. ARP_CONST_BUFFER_POOL * pHdrPool
  1984. );
  1985. VOID
  1986. arpDeallocateConstBuffer(
  1987. ARP_CONST_BUFFER_POOL * pHdrPool,
  1988. PNDIS_BUFFER pNdisBuffer
  1989. );
  1990. VOID
  1991. arpCompleteSentPkt(
  1992. IN NDIS_STATUS Status,
  1993. IN ARP1394_INTERFACE * pIF,
  1994. IN ARPCB_DEST * pDest,
  1995. IN PNDIS_PACKET pNdisPacket
  1996. );
  1997. NDIS_STATUS
  1998. arpParseArpPkt(
  1999. IN PIP1394_ARP_PKT pArpPkt,
  2000. IN UINT cbBufferSize,
  2001. OUT PIP1394_ARP_PKT_INFO pPktInfo
  2002. );
  2003. VOID
  2004. arpPrepareArpPkt(
  2005. IN PIP1394_ARP_PKT_INFO pArpPktInfo,
  2006. // IN UINT SenderMaxRec,
  2007. OUT PIP1394_ARP_PKT pArpPkt
  2008. );
  2009. NDIS_STATUS
  2010. arpPrepareArpResponse(
  2011. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2012. IN PIP1394_ARP_PKT_INFO pArpRequest,
  2013. OUT PIP1394_ARP_PKT_INFO pArpResponse,
  2014. IN PRM_STACK_RECORD pSR
  2015. );
  2016. NDIS_STATUS
  2017. arpAddOneStaticArpEntry(
  2018. IN PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2019. IN IP_ADDRESS IpAddress,
  2020. IN PNIC1394_FIFO_ADDRESS pFifoAddr,
  2021. IN PRM_STACK_RECORD pSR
  2022. );
  2023. VOID
  2024. arpSetPrimaryIfTask(
  2025. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2026. PRM_TASK pTask,
  2027. ULONG PrimaryState,
  2028. PRM_STACK_RECORD pSR
  2029. );
  2030. VOID
  2031. arpClearPrimaryIfTask(
  2032. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2033. PRM_TASK pTask,
  2034. ULONG PrimaryState,
  2035. PRM_STACK_RECORD pSR
  2036. );
  2037. VOID
  2038. arpSetSecondaryIfTask(
  2039. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2040. PRM_TASK pTask,
  2041. ULONG SecondaryState,
  2042. PRM_STACK_RECORD pSR
  2043. );
  2044. VOID
  2045. arpClearSecondaryIfTask(
  2046. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2047. PRM_TASK pTask,
  2048. ULONG SecondaryState,
  2049. PRM_STACK_RECORD pSR
  2050. );
  2051. VOID
  2052. arpSetPrimaryAdapterTask(
  2053. PARP1394_ADAPTER pAdapter, // LOCKIN LOCKOUT
  2054. PRM_TASK pTask,
  2055. ULONG PrimaryState,
  2056. PRM_STACK_RECORD pSR
  2057. );
  2058. VOID
  2059. arpClearPrimaryAdapterTask(
  2060. PARP1394_ADAPTER pAdapter, // LOCKIN LOCKOUT
  2061. PRM_TASK pTask,
  2062. ULONG PrimaryState,
  2063. PRM_STACK_RECORD pSR
  2064. );
  2065. VOID
  2066. arpSetSecondaryAdapterTask(
  2067. PARP1394_ADAPTER pAdapter, // LOCKIN LOCKOUT
  2068. PRM_TASK pTask,
  2069. ULONG SecondaryState,
  2070. PRM_STACK_RECORD pSR
  2071. );
  2072. VOID
  2073. arpClearSecondaryAdapterTask(
  2074. PARP1394_ADAPTER pAdapter, // LOCKIN LOCKOUT
  2075. PRM_TASK pTask,
  2076. ULONG SecondaryState,
  2077. PRM_STACK_RECORD pSR
  2078. );
  2079. NDIS_STATUS
  2080. arpTryReconfigureIf(
  2081. PARP1394_INTERFACE pIF,
  2082. PNET_PNP_EVENT pNetPnPEvent,
  2083. PRM_STACK_RECORD pSR
  2084. );
  2085. VOID
  2086. arpResetIfStats(
  2087. IN PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2088. IN PRM_STACK_RECORD pSR
  2089. );
  2090. VOID
  2091. arpGetPktCountBins(
  2092. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2093. IN PNDIS_PACKET pNdisPacket,
  2094. OUT PULONG pSizeBin,
  2095. OUT PULONG pTimeBin
  2096. );
  2097. VOID
  2098. arpLogSendFifoCounts(
  2099. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2100. IN PNDIS_PACKET pNdisPacket,
  2101. IN NDIS_STATUS Status
  2102. );
  2103. VOID
  2104. arpLogRecvFifoCounts(
  2105. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2106. IN PNDIS_PACKET pNdisPacket
  2107. );
  2108. VOID
  2109. arpLogSendChannelCounts(
  2110. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2111. IN PNDIS_PACKET pNdisPacket,
  2112. IN NDIS_STATUS Status
  2113. );
  2114. VOID
  2115. arpLogRecvChannelCounts(
  2116. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2117. IN PNDIS_PACKET pNdisPacket
  2118. );
  2119. NDIS_STATUS
  2120. arpInitializeVc(
  2121. PARP1394_INTERFACE pIF,
  2122. PARP_STATIC_VC_INFO pVcInfo,
  2123. PRM_OBJECT_HEADER pOwner,
  2124. PARP_VC_HEADER pVcHdr,
  2125. PRM_STACK_RECORD pSR
  2126. );
  2127. VOID
  2128. arpDeinitializeVc(
  2129. PARP1394_INTERFACE pIF,
  2130. PARP_VC_HEADER pVcHdr,
  2131. PRM_OBJECT_HEADER pOwner, // NOLOCKIN NOLOCKOUT
  2132. PRM_STACK_RECORD pSR
  2133. );
  2134. NDIS_STATUS
  2135. arpAllocateControlPacketPool(
  2136. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2137. UINT MaxBufferSize,
  2138. PRM_STACK_RECORD pSR
  2139. );
  2140. VOID
  2141. arpFreeControlPacketPool(
  2142. PARP1394_INTERFACE pIF, // LOCKIN LOCKOUT
  2143. PRM_STACK_RECORD pSR
  2144. );
  2145. NDIS_STATUS
  2146. arpAllocateControlPacket(
  2147. IN PARP1394_INTERFACE pIF,
  2148. IN UINT cbBufferSize,
  2149. IN UINT PktFlags,
  2150. OUT PNDIS_PACKET *ppNdisPacket,
  2151. OUT PVOID *ppvData,
  2152. PRM_STACK_RECORD pSR
  2153. );
  2154. VOID
  2155. arpFreeControlPacket(
  2156. PARP1394_INTERFACE pIF,
  2157. PNDIS_PACKET pNdisPacket,
  2158. PRM_STACK_RECORD pSR
  2159. );
  2160. VOID
  2161. arpRefSendPkt(
  2162. PNDIS_PACKET pNdisPacket,
  2163. PARPCB_DEST pDest
  2164. );
  2165. VOID
  2166. arpProcessArpPkt(
  2167. PARP1394_INTERFACE pIF,
  2168. PIP1394_ARP_PKT pArpPkt,
  2169. UINT cbBufferSize
  2170. );
  2171. VOID
  2172. arpProcessMcapPkt(
  2173. PARP1394_INTERFACE pIF,
  2174. PIP1394_MCAP_PKT pMcapPkt,
  2175. UINT cbBufferSize
  2176. );
  2177. VOID
  2178. arpLinkRemoteIpToDest(
  2179. ARPCB_REMOTE_IP *pRemoteIp,
  2180. ARPCB_DEST *pDest,
  2181. PRM_STACK_RECORD pSR
  2182. );
  2183. VOID
  2184. arpUnlinkRemoteIpFromDest(
  2185. ARPCB_REMOTE_IP *pRemoteIp, // LOCKIN LOCKOUT
  2186. PRM_STACK_RECORD pSR
  2187. );
  2188. VOID
  2189. arpUnlinkAllRemoteIpsFromDest(
  2190. ARPCB_DEST *pDest, // LOCKIN LOCKOUT
  2191. PRM_STACK_RECORD pSR
  2192. );
  2193. VOID
  2194. arpLinkLocalIpToDest(
  2195. ARPCB_LOCAL_IP * pLocalIp,
  2196. ARPCB_DEST *pDest,
  2197. PRM_STACK_RECORD pSR
  2198. );
  2199. VOID
  2200. arpUnlinkLocalIpFromDest(
  2201. ARPCB_LOCAL_IP *pLocalIp, // LOCKIN LOCKOUT
  2202. PRM_STACK_RECORD pSR
  2203. );
  2204. VOID
  2205. arpUnlinkAllLocalIpsFromDest(
  2206. ARPCB_DEST *pDest, // LOCKIN LOCKOUT
  2207. PRM_STACK_RECORD pSR
  2208. );
  2209. #if 0
  2210. NDIS_STATUS
  2211. arpCopyAnsiStringToUnicodeString(
  2212. OUT PNDIS_STRING pDest,
  2213. IN PANSI_STRING pSrc
  2214. );
  2215. NDIS_STATUS
  2216. arpCopyUnicodeStringToAnsiString(
  2217. OUT PANSI_STRING pDest,
  2218. IN PNDIS_STRING pSrc
  2219. );
  2220. #endif // 0
  2221. VOID
  2222. arpUpdateReceiveMultichannels(
  2223. PARP1394_INTERFACE pIF,
  2224. UINT SecondsSinceLastCall,
  2225. PRM_STACK_RECORD pSR
  2226. );
  2227. NDIS_STATUS
  2228. arpPrepareAndSendNdisRequest(
  2229. IN PARP1394_ADAPTER pAdapter,
  2230. IN PARP_NDIS_REQUEST pArpNdisRequest,
  2231. IN PRM_TASK pTask, // OPTIONAL
  2232. IN UINT PendCode,
  2233. IN NDIS_OID Oid,
  2234. IN PVOID pBuffer,
  2235. IN ULONG BufferLength,
  2236. IN NDIS_REQUEST_TYPE RequestType,
  2237. IN PRM_STACK_RECORD pSR
  2238. );
  2239. typedef enum
  2240. {
  2241. ARP_ICS_FORWARD_TO_1394,
  2242. ARP_ICS_FORWARD_TO_ETHERNET,
  2243. } ARP_ICS_FORWARD_DIRECTION;
  2244. VOID
  2245. arpEthReceivePacket(
  2246. ARP1394_INTERFACE * pIF,
  2247. PNDIS_PACKET Packet
  2248. );
  2249. NDIS_STATUS
  2250. arpAllocateEthernetPools(
  2251. IN PARP1394_INTERFACE pIF,
  2252. IN PRM_STACK_RECORD pSR
  2253. );
  2254. VOID
  2255. arpFreeEthernetPools(
  2256. IN PARP1394_INTERFACE pIF,
  2257. IN PRM_STACK_RECORD pSR
  2258. );
  2259. VOID
  2260. arpDbgIncrementReentrancy(
  2261. PLONG pReentrancyCount
  2262. );
  2263. VOID
  2264. arpDbgDecrementReentrancy(
  2265. PLONG pReentrancyCount
  2266. );
  2267. VOID
  2268. arpHandleControlPktSendCompletion(
  2269. IN ARP1394_INTERFACE * pIF,
  2270. IN PNDIS_PACKET pNdisPacket
  2271. );
  2272. VOID
  2273. arpStartIfMaintenanceTask(
  2274. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2275. PRM_STACK_RECORD pSR
  2276. );
  2277. NDIS_STATUS
  2278. arpTryStopIfMaintenanceTask(
  2279. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2280. IN PRM_TASK pTask, // task to pend until M task completes
  2281. IN UINT PendCode, // Pend code to suspend task.
  2282. PRM_STACK_RECORD pSR
  2283. );
  2284. UINT
  2285. arpGetSystemTime(VOID);
  2286. BOOLEAN
  2287. arpCanTryMcap(
  2288. IP_ADDRESS IpAddress
  2289. );
  2290. UINT
  2291. arpFindAssignedChannel(
  2292. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2293. IN IP_ADDRESS IpAddress,
  2294. IN UINT CurrentTime,
  2295. PRM_STACK_RECORD pSR
  2296. );
  2297. VOID
  2298. arpUpdateRemoteIpDest(
  2299. IN PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2300. IN PARPCB_REMOTE_IP pRemoteIp,
  2301. IN PARP_DEST_PARAMS pDestParams,
  2302. PRM_STACK_RECORD pSR
  2303. );
  2304. MYBOOL
  2305. arpIsActiveMcapChannel(
  2306. PMCAP_CHANNEL_INFO pMci,
  2307. UINT CurrentTime
  2308. );
  2309. VOID
  2310. arpSendControlPkt(
  2311. IN ARP1394_INTERFACE * pIF, // LOCKIN NOLOCKOUT (IF send lk)
  2312. IN PNDIS_PACKET pNdisPacket,
  2313. IN PARPCB_DEST pDest,
  2314. IN PRM_STACK_RECORD pSR
  2315. );
  2316. NDIS_STATUS
  2317. arpCreateMcapPkt(
  2318. IN PARP1394_INTERFACE pIF,
  2319. IN PIP1394_MCAP_PKT_INFO pPktInfo,
  2320. OUT PNDIS_PACKET *ppNdisPacket,
  2321. PRM_STACK_RECORD pSR
  2322. );
  2323. UINT
  2324. arpProcessReceivedPacket(
  2325. IN PARP1394_INTERFACE pIF,
  2326. IN PNDIS_PACKET pNdisPacket,
  2327. IN MYBOOL IsChannel
  2328. );
  2329. VOID
  2330. arpUpdateArpCache(
  2331. PARP1394_INTERFACE pIF, // NOLOCKIN NOLOCKOUT
  2332. IP_ADDRESS RemoteIpAddress,
  2333. ENetAddr *pRemoteEthAddress,
  2334. PARP_DEST_PARAMS pDestParams,
  2335. MYBOOL fCreateIfRequired,
  2336. PRM_STACK_RECORD pSR
  2337. );
  2338. UINT
  2339. arpEthernetReceivePacket(
  2340. IN NDIS_HANDLE ProtocolBindingContext,
  2341. IN NDIS_HANDLE ProtocolVcContext,
  2342. IN PNDIS_PACKET pNdisPacket
  2343. );
  2344. VOID
  2345. arpEthReceive1394Packet(
  2346. IN PARP1394_INTERFACE pIF,
  2347. IN PNDIS_PACKET pNdisPacket,
  2348. IN PVOID pvHeader,
  2349. IN UINT HeaderSize,
  2350. IN MYBOOL IsChannel
  2351. );
  2352. NDIS_STATUS
  2353. arpSlowIpTransmit(
  2354. IN ARP1394_INTERFACE * pIF,
  2355. IN PNDIS_PACKET pNdisPacket,
  2356. IN REMOTE_DEST_KEY Destination,
  2357. IN RouteCacheEntry * pRCE OPTIONAL
  2358. );
  2359. VOID
  2360. arpDelRceList(
  2361. IN PARPCB_REMOTE_IP pRemoteIp, // IF send lock WRITELOCKIN WRITELOCKOUTD
  2362. IN PRM_STACK_RECORD pSR
  2363. );
  2364. VOID
  2365. arpGenericWorkItem(
  2366. struct _NDIS_WORK_ITEM * pWorkItem,
  2367. PVOID pContext
  2368. );
  2369. VOID
  2370. arpQueueWorkItem (
  2371. PARP1394_WORK_ITEM pWorkItem,
  2372. ARP_WORK_ITEM_PROC pFunc,
  2373. PRM_OBJECT_HEADER pHdr,
  2374. PRM_STACK_RECORD pSR
  2375. );
  2376. NDIS_STATUS
  2377. arpGetEuidTopology (
  2378. IN PARP1394_ADAPTER pAdapter,
  2379. PRM_STACK_RECORD pSR
  2380. );
  2381. VOID
  2382. arpNdProcessBusReset(
  2383. IN PARP1394_ADAPTER pAdapter
  2384. );
  2385. VOID
  2386. arpReturnBackupTask (
  2387. IN ARP1394_TASK* pTask
  2388. );
  2389. VOID
  2390. arpAllocateBackupTasks (
  2391. ARP1394_GLOBALS* pGlobals
  2392. );
  2393. VOID
  2394. arpFreeBackupTasks (
  2395. ARP1394_GLOBALS* pGlobals
  2396. );
  2397. ARP1394_TASK *
  2398. arpGetBackupTask (
  2399. IN ARP1394_GLOBALS* pGlobals
  2400. );
  2401. NTSTATUS
  2402. arpDelArpEntry(
  2403. PARP1394_INTERFACE pIF,
  2404. IPAddr IpAddress,
  2405. PRM_STACK_RECORD pSR
  2406. );
  2407. VOID
  2408. arpAddBackupTasks (
  2409. IN ARP1394_GLOBALS* pGlobals,
  2410. UINT Num
  2411. );
  2412. VOID
  2413. arpRemoveBackupTasks (
  2414. IN ARP1394_GLOBALS* pGlobals,
  2415. UINT Num
  2416. );
  2417. MYBOOL
  2418. arpNeedToCleanupDestVc(
  2419. ARPCB_DEST *pDest // LOCKING LOCKOUT
  2420. );
  2421. VOID
  2422. arpLowPowerCloseAllCalls (
  2423. ARP1394_INTERFACE *pIF,
  2424. PRM_STACK_RECORD pSR
  2425. );
  2426. VOID
  2427. arpDeactivateIf(
  2428. PARP1394_INTERFACE pIF,
  2429. PRM_TASK pCallingTask, // OPTIONAL
  2430. UINT SuspendCode, // OPTIONAL
  2431. PRM_STACK_RECORD pSR
  2432. );
  2433. NDIS_STATUS
  2434. arpTaskLowPower(
  2435. IN struct _RM_TASK * pTask,
  2436. IN RM_TASK_OPERATION Code,
  2437. IN UINT_PTR UserParam,
  2438. IN PRM_STACK_RECORD pSR
  2439. );
  2440. NDIS_STATUS
  2441. arpSetupSpecialDest(
  2442. IN PARP1394_INTERFACE pIF,
  2443. IN NIC1394_ADDRESS_TYPE AddressType,
  2444. IN PRM_TASK pParentTask,
  2445. IN UINT PendCode,
  2446. OUT PARPCB_DEST * ppSpecialDest,
  2447. IN PRM_STACK_RECORD pSR
  2448. );
  2449. NDIS_STATUS
  2450. arpResume (
  2451. IN ARP1394_ADAPTER* pAdapter,
  2452. IN ARP_RESUME_CAUSE Cause,
  2453. IN PRM_STACK_RECORD pSR
  2454. );
  2455. NDIS_STATUS
  2456. arpTaskOnPower (
  2457. IN PRM_TASK pTask,
  2458. IN RM_TASK_OPERATION Code,
  2459. IN UINT_PTR UserParam, // Unused
  2460. IN PRM_STACK_RECORD pSR
  2461. );
  2462. NDIS_STATUS
  2463. arpMakeCallOnDest(
  2464. IN PARPCB_REMOTE_IP pRemoteIp,
  2465. IN PARPCB_DEST pDest,
  2466. IN PRM_TASK pTaskToPend,
  2467. IN ULONG PEND_StageMakeCallComplete,
  2468. IN PRM_STACK_RECORD pSR
  2469. );
  2470. //=========================================================================
  2471. // G L O B A L D A T A
  2472. //=========================================================================
  2473. extern
  2474. RM_STATIC_OBJECT_INFO
  2475. ArpGlobals_AdapterStaticInfo;
  2476. extern const
  2477. NIC1394_ENCAPSULATION_HEADER
  2478. Arp1394_IpEncapHeader;
  2479. // Warning -- FAIL(NDIS_STATUS_PENDING) == TRUE
  2480. //
  2481. #define FAIL(_Status) ((_Status) != NDIS_STATUS_SUCCESS)
  2482. #define PEND(_Status) ((_Status) == NDIS_STATUS_PENDING)
  2483. #if RM_EXTRA_CHECKING
  2484. #define LOCKHDR(_pHdr, _psr) \
  2485. RmWriteLockObject((_pHdr), dbg_func_locid, (_psr))
  2486. #else // !RM_EXTRA_CHECKING
  2487. #define LOCKHDR(_pHdr, _psr) \
  2488. RmWriteLockObject((_pHdr), (_psr))
  2489. #endif // !RM_EXTRA_CHECKING
  2490. #define LOCKOBJ(_pObj, _psr) \
  2491. LOCKHDR(&(_pObj)->Hdr, (_psr))
  2492. #define UNLOCKHDR(_pHdr, _psr) \
  2493. RmUnlockObject((_pHdr), (_psr))
  2494. #define UNLOCKOBJ(_pObj, _psr) \
  2495. UNLOCKHDR(&(_pObj)->Hdr, (_psr))
  2496. #define ARP_ALLOCSTRUCT(_p, _tag) \
  2497. NdisAllocateMemoryWithTag(&(_p), sizeof(*(_p)), (_tag))
  2498. #define ARP_FREE(_p) NdisFreeMemory((_p), 0, 0)
  2499. #define ARP_ZEROSTRUCT(_p) \
  2500. NdisZeroMemory((_p), sizeof(*(_p)))
  2501. #define ARRAY_LENGTH(_array) (sizeof(_array)/sizeof((_array)[0]))
  2502. #if RM_EXTRA_CHECKING
  2503. #define DBG_ADDASSOC(_phdr, _e1, _e2, _assoc, _fmt, _psr)\
  2504. RmDbgAddAssociation( \
  2505. dbg_func_locid, \
  2506. (_phdr), \
  2507. (UINT_PTR) (_e1), \
  2508. (UINT_PTR) (_e2), \
  2509. (_assoc), \
  2510. (_fmt), \
  2511. (_psr) \
  2512. )
  2513. #define DBG_DELASSOC(_phdr, _e1, _e2, _assoc, _psr) \
  2514. RmDbgDeleteAssociation( \
  2515. dbg_func_locid, \
  2516. (_phdr), \
  2517. (UINT_PTR) (_e1), \
  2518. (UINT_PTR) (_e2), \
  2519. (_assoc), \
  2520. (_psr) \
  2521. )
  2522. // (debug only) Enumeration of types of associations.
  2523. //
  2524. enum
  2525. {
  2526. ARPASSOC_IP_OPEN, // IP has called ArpIpOpen
  2527. ARPASSOC_LINK_IPADDR_OF_DEST,
  2528. ARPASSOC_LINK_DEST_OF_IPADDR,
  2529. ARPASSOC_LOCALIP_UNLOAD_TASK,
  2530. ARPASSOC_REMOTEIP_UNLOAD_TASK,
  2531. ARPASSOC_REMOTEETH_UNLOAD_TASK,
  2532. ARPASSOC_DEST_UNLOAD_TASK,
  2533. ARPASSOC_CBUFPOOL_ALLOC,
  2534. ARPASSOC_EXTLINK_DEST_TO_PKT,
  2535. ARPASSOC_EXTLINK_RIP_TO_RCE,
  2536. ARPASSOC_EXTLINK_TO_NDISVCHANDLE,
  2537. ARPASSOC_REMOTEIP_SENDPKTS_TASK,
  2538. ARPASSOC_IF_MAKECALL_TASK,
  2539. ARPASSOC_IF_CLEANUPCALL_TASK,
  2540. ARPASSOC_DEST_MAKECALL_TASK,
  2541. ARPASSOC_DEST_CLEANUPCALL_TASK,
  2542. ARPASSOC_DEST_CLEANUPCALLTASK_WAITING_ON_SENDS,
  2543. ARPASSOC_PKTS_QUEUED_ON_REMOTEIP,
  2544. ARPASSOC_PRIMARY_IF_TASK,
  2545. ARPASSOC_ACTDEACT_IF_TASK,
  2546. ARPASSOC_IF_OPENAF,
  2547. ARPASSOC_PRIMARY_AD_TASK,
  2548. ARPASSOC_ACTDEACT_AD_TASK,
  2549. ARPASSOC_LINK_IF_OF_BCDEST,
  2550. ARPASSOC_LINK_BCDEST_OF_IF,
  2551. ARPASSOC_IF_PROTOPKTPOOL,
  2552. ARPASSOC_IF_PROTOBUFPOOL,
  2553. ARPASSOC_RESOLUTION_IF_TASK,
  2554. ARPASSOC_LINK_IF_OF_MCDEST,
  2555. ARPASSOC_LINK_MCDEST_OF_IF,
  2556. ARPASSOC_LINK_IF_OF_ETHDEST,
  2557. ARPASSOC_LINK_ETHDEST_OF_IF,
  2558. ARPASSOC_IF_ETHPKTPOOL,
  2559. ARPASSOC_IF_ETHBUFPOOL,
  2560. ARPASSOC_ETH_SEND_PACKET,
  2561. ARPASSOC_IF_MAINTENANCE_TASK,
  2562. ARPASSOC_WORK_ITEM,
  2563. ARPASSOC_ETHDHCP_UNLOAD_TASK,
  2564. ARPASSOC_REMOTEIP_RESOLVE_TASK,
  2565. ARPASSOC_TASK_TO_RESOLVE_REMOTEIP
  2566. };
  2567. #else // !RM_EXTRA_CHECKING
  2568. #define DBG_ADDASSOC(_phdr, _e1, _e2, _assoc, _fmt, _psr) (0)
  2569. #define DBG_DELASSOC(_phdr, _e1, _e2, _assoc, _psr) (0)
  2570. #endif // !RM_EXTRA_CHECKING
  2571. #define ARPDBG_REF_EVERY_PACKET 1
  2572. #define ARPDBG_REF_EVERY_RCE 1
  2573. // USHORT
  2574. // SWAPBYTES_USHORT(USHORT Val )
  2575. //
  2576. #define SWAPBYTES_USHORT(Val) \
  2577. ((((Val) & 0xff) << 8) | (((Val) & 0xff00) >> 8))
  2578. // ULONG
  2579. // SWAPBYTES_ULONG(ULONG Val )
  2580. //
  2581. #define SWAPBYTES_ULONG(Val) \
  2582. ((((Val) & 0x000000ff) << 24) | \
  2583. (((Val) & 0x0000ff00) << 8) | \
  2584. (((Val) & 0x00ff0000) >> 8) | \
  2585. (((Val) & 0xff000000) >> 24) )
  2586. #define N2H_USHORT(Val) SWAPBYTES_USHORT(Val)
  2587. #define H2N_USHORT(Val) SWAPBYTES_USHORT(Val)
  2588. #define N2H_ULONG(Val) SWAPBYTES_ULONG(Val)
  2589. #define H2N_ULONG(Val) SWAPBYTES_ULONG(Val)
  2590. #define ARP_ATPASSIVE() (KeGetCurrentIrql()==PASSIVE_LEVEL)
  2591. #define LOGSTATS_NoCopyRecvs(_pIF, _pNdisPacket) \
  2592. NdisInterlockedIncrement(&((_pIF)->stats.recvpkts.NoCopyRecvs))
  2593. #define LOGSTATS_CopyRecvs(_pIF, _pNdisPacket) \
  2594. NdisInterlockedIncrement(&((_pIF)->stats.recvpkts.CopyRecvs))
  2595. #define LOGSTATS_ResourceRecvs(_pIF, _pNdisPacket) \
  2596. NdisInterlockedIncrement(&((_pIF)->stats.recvpkts.ResourceRecvs))
  2597. #define LOGSTATS_TotRecvs(_pIF, _pNdisPacket) \
  2598. NdisInterlockedIncrement(&((_pIF)->stats.recvpkts.TotRecvs))
  2599. #define LOGSTATS_RecvFifoCounts(_pIF, _pNdisPacket) \
  2600. arpLogRecvFifoCounts(_pIF, _pNdisPacket)
  2601. #define LOGSTATS_RecvChannelCounts(_pIF, _pNdisPacket) \
  2602. arpLogRecvChannelCounts(_pIF, _pNdisPacket)
  2603. #define LOGSTATS_TotalSendFifoMakeCalls(_pIF) \
  2604. NdisInterlockedIncrement(&((_pIF)->stats.calls.TotalSendFifoMakeCalls))
  2605. #define LOGSTATS_SuccessfulSendFifoMakeCalls(_pIF) \
  2606. NdisInterlockedIncrement(&((_pIF)->stats.calls.SuccessfulSendFifoMakeCalls))
  2607. #define LOGSTATS_FailedSendFifoMakeCalls(_pIF) \
  2608. NdisInterlockedIncrement(&((_pIF)->stats.calls.FailedSendFifoMakeCalls))
  2609. #define LOGSTATS_IncomingClosesOnSendFifos(_pIF) \
  2610. NdisInterlockedIncrement(&((_pIF)->stats.calls.IncomingClosesOnSendFifos))
  2611. #define LOGSTATS_TotalChannelMakeCalls(_pIF) \
  2612. NdisInterlockedIncrement(&((_pIF)->stats.calls.TotalChannelMakeCalls))
  2613. #define LOGSTATS_SuccessfulChannelMakeCalls(_pIF) \
  2614. NdisInterlockedIncrement(&((_pIF)->stats.calls.SuccessfulChannelMakeCalls))
  2615. #define LOGSTATS_FailedChannelMakeCalls(_pIF) \
  2616. NdisInterlockedIncrement(&((_pIF)->stats.calls.FailedChannelMakeCalls))
  2617. #define LOGSTATS_IncomingClosesOnChannels(_pIF) \
  2618. NdisInterlockedIncrement(&((_pIF)->stats.calls.IncomingClosesOnChannels))
  2619. #define IF_FROM_LOCALIP(_pLIp) \
  2620. (PARP1394_INTERFACE) RM_PARENT_OBJECT(_pLIp)
  2621. #define IF_FROM_REMOTEIP(_pRIp) \
  2622. (PARP1394_INTERFACE) RM_PARENT_OBJECT(_pRIp)
  2623. #define IF_FROM_DEST(_pDest) \
  2624. (PARP1394_INTERFACE) RM_PARENT_OBJECT(_pDest)
  2625. #if RM_EXTRA_CHECKING
  2626. #define OBJLOG0(_pObj, _szFmt) \
  2627. RmDbgLogToObject( \
  2628. &(_pObj)->Hdr, \
  2629. NULL, (_szFmt), \
  2630. 0, 0, 0, 0, NULL, NULL \
  2631. )
  2632. #define OBJLOG1(_pObj, _szFmt, _P1) \
  2633. RmDbgLogToObject( \
  2634. &(_pObj)->Hdr, \
  2635. NULL, (_szFmt), \
  2636. (UINT_PTR) (_P1), \
  2637. 0, 0, 0, NULL, NULL \
  2638. )
  2639. #define OBJLOG2(_pObj, _szFmt, _P1, _P2) \
  2640. RmDbgLogToObject( \
  2641. &(_pObj)->Hdr, \
  2642. NULL, (_szFmt), \
  2643. (UINT_PTR) (_P1), \
  2644. (UINT_PTR) (_P2), \
  2645. 0, 0, NULL, NULL \
  2646. )
  2647. #else // !RM_EXTRA_CHECKING
  2648. #define OBJLOG0(_pObj, _szFmt) (0)
  2649. #define OBJLOG1(_pObj, _szFmt, _P1) (0)
  2650. #define OBJLOG2(_pObj, _szFmt, _P1, _P2) (0)
  2651. #endif // !RM_EXTRA_CHECKING
  2652. #if ARP_DO_TIMESTAMPS
  2653. void
  2654. arpTimeStamp(
  2655. char *szFormatString,
  2656. UINT Val
  2657. );
  2658. #define TIMESTAMPX(_FormatString) \
  2659. arpTimeStamp("TIMESTAMP %lu:%lu.%lu ARP1394 " _FormatString "\n", 0)
  2660. #if ARP_DO_ALL_TIMESTAMPS
  2661. #define TIMESTAMP(_FormatString) \
  2662. arpTimeStamp("TIMESTAMP %lu:%lu.%lu ARP1394 " _FormatString "\n", 0)
  2663. #define TIMESTAMP1(_FormatString, _Val) \
  2664. arpTimeStamp("TIMESTAMP %lu:%lu.%lu ARP1394 " _FormatString "\n", (_Val))
  2665. #else
  2666. #define TIMESTAMP(_FormatString)
  2667. #define TIMESTAMP1(_FormatString, _Val)
  2668. #endif
  2669. #else // !ARP_DO_TIMESTAMPS
  2670. #define TIMESTAMP(_FormatString)
  2671. #define TIMESTAMPX(_FormatString)
  2672. #define TIMESTAMP1(_FormatString, _Val)
  2673. #endif // !ARP_DO_TIMESTAMPS