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.

766 lines
26 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. mac.h
  5. Abstract:
  6. This header file defines manifest constants and necessary macros for use
  7. by transports dealing with multiple MAC cards through the NDIS interface.
  8. Author:
  9. David Beaver (dbeaver) 02-Oct-1990
  10. Revision History:
  11. --*/
  12. #ifndef _MAC_
  13. #define _MAC_
  14. //
  15. // MAC-specific definitions, some of which get used below
  16. //
  17. #define MAX_MAC_HEADER_LENGTH 32
  18. #define MAX_SOURCE_ROUTING 18
  19. #define MAX_DEFAULT_SR 2
  20. #define ETHERNET_ADDRESS_LENGTH 6
  21. #define ETHERNET_PACKET_LENGTH 1514 // max size of an ethernet packet
  22. #define ETHERNET_HEADER_LENGTH 14 // size of the ethernet MAC header
  23. #define ETHERNET_DATA_LENGTH_OFFSET 12
  24. #define ETHERNET_DESTINATION_OFFSET 0
  25. #define ETHERNET_SOURCE_OFFSET 6
  26. #define TR_ADDRESS_LENGTH 6
  27. #define TR_ADDRESS_OFFSET 2
  28. #define TR_SPECIFIC_OFFSET 0
  29. #define TR_PACKET_LENGTH 1514 // max size of a TR packet
  30. #define TR_HEADER_LENGTH 36 // size of the MAC header w/o source routing
  31. #define TR_DATA_LENGTH_OFFSET 0
  32. #define TR_DESTINATION_OFFSET 2
  33. #define TR_SOURCE_OFFSET 8
  34. #define TR_ROUTING_OFFSET 14 // starts at the 14th byte
  35. #define TR_GR_BCAST_LENGTH 2
  36. #define TR_GR_BROADCAST 0xC270 // what a general route b'cast looks like
  37. #define TR_ROUTING_LENGTH_MASK 0x1F // low 5 bits in byte
  38. #define TR_DIRECTION_MASK 0x80 // returns direction bit
  39. #define TR_PREAMBLE_AC 0x10 // how would these be specified?
  40. #define TR_PREAMBLE_FC 0x40
  41. #define TR_HEADER_BYTE_0 0x10
  42. #define TR_HEADER_BYTE_1 0x40
  43. #define FDDI_ADDRESS_LENGTH 6
  44. #define FDDI_HEADER_BYTE 0x57
  45. //
  46. // We need this to define information about the MAC. Note that
  47. // it is a strange structure in that the first four elements
  48. // are for use internally by the nbfmac routines, while the
  49. // DeviceContext knows about and uses the last two.
  50. //
  51. typedef struct _NBF_NDIS_IDENTIFICATION {
  52. NDIS_MEDIUM MediumType;
  53. BOOLEAN SourceRouting;
  54. BOOLEAN MediumAsync;
  55. BOOLEAN QueryWithoutSourceRouting;
  56. BOOLEAN AllRoutesNameRecognized;
  57. ULONG DestinationOffset;
  58. ULONG SourceOffset;
  59. ULONG AddressLength;
  60. ULONG TransferDataOffset;
  61. ULONG MaxHeaderLength;
  62. BOOLEAN CopyLookahead;
  63. BOOLEAN ReceiveSerialized;
  64. BOOLEAN TransferSynchronous;
  65. BOOLEAN SingleReceive;
  66. } NBF_NDIS_IDENTIFICATION, *PNBF_NDIS_IDENTIFICATION;
  67. VOID
  68. MacConstructHeader(
  69. IN PNBF_NDIS_IDENTIFICATION MacInfo,
  70. IN PUCHAR Buffer,
  71. IN PUCHAR DestinationAddress,
  72. IN PUCHAR SourceAddress,
  73. IN UINT PacketLength,
  74. IN PUCHAR SourceRouting,
  75. IN UINT SourceRoutingLength,
  76. OUT PUINT HeaderLength
  77. );
  78. VOID
  79. MacReturnMaxDataSize(
  80. IN PNBF_NDIS_IDENTIFICATION MacInfo,
  81. IN PUCHAR SourceRouting,
  82. IN UINT SourceRoutingLength,
  83. IN UINT DeviceMaxFrameSize,
  84. IN BOOLEAN AssumeWorstCase,
  85. OUT PUINT MaxFrameSize
  86. );
  87. VOID
  88. MacInitializeMacInfo(
  89. IN NDIS_MEDIUM MacType,
  90. IN BOOLEAN UseDix,
  91. OUT PNBF_NDIS_IDENTIFICATION MacInfo
  92. );
  93. extern UCHAR SingleRouteSourceRouting[];
  94. extern UCHAR GeneralRouteSourceRouting[];
  95. extern ULONG DefaultSourceRoutingLength;
  96. //++
  97. //
  98. // VOID
  99. // MacReturnDestinationAddress(
  100. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  101. // IN PVOID Packet,
  102. // OUT PVOID * DestinationAddress
  103. // );
  104. //
  105. // Routine Description:
  106. //
  107. // Returns the a pointer to the destination address in the packet.
  108. //
  109. // Arguments:
  110. //
  111. // MacInfo - Describes the MAC we wish to decode.
  112. //
  113. // Packet - The packet data.
  114. //
  115. // DestinationAddress - Returns the start of the destination address.
  116. //
  117. // Return Value:
  118. //
  119. // None.
  120. //
  121. //--
  122. #define MacReturnDestinationAddress(_MacInfo, _Packet, _DestinationAddress) \
  123. *(_DestinationAddress) = ((PUCHAR)(_Packet)) + (_MacInfo)->DestinationOffset
  124. //++
  125. //
  126. // VOID
  127. // MacReturnSourceAddress(
  128. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  129. // IN PVOID Packet,
  130. // OUT PHARDWARE_ADDRESS SourceAddressBuffer,
  131. // OUT PHARDWARE_ADDRESS * SourceAddress,
  132. // OUT BOOLEAN * Multicast OPTIONAL
  133. // );
  134. //
  135. // Routine Description:
  136. //
  137. // Copies the source address in the packet into SourceAddress.
  138. // NOTE THAT IT MAY COPY THE DATA, UNLIKE ReturnDestinationAddress
  139. // AND ReturnSourceRouting. Optionally, indicates whether the
  140. // destination address is a multicast address.
  141. //
  142. // Arguments:
  143. //
  144. // MacInfo - Describes the MAC we wish to decode.
  145. //
  146. // Packet - The packet data.
  147. //
  148. // SourceAddressBuffer - A buffer to hold the source address,
  149. // if needed.
  150. //
  151. // SourceAddress - Returns a pointer to the source address.
  152. //
  153. // Multicast - Optional pointer to a BOOLEAN to receive indication
  154. // of whether the destination was a multicast address.
  155. //
  156. // Return Value:
  157. //
  158. // None.
  159. //
  160. //--
  161. //
  162. // NOTE: The default case below handles Ethernet and FDDI.
  163. //
  164. #define MacReturnSourceAddress(_MacInfo, _Packet, _SourceAddressBuffer, \
  165. _SourceAddress, _Multicast) \
  166. { \
  167. PUCHAR TmpPacket = (PUCHAR)(_Packet); \
  168. PUCHAR SrcBuffer = (PUCHAR)(_SourceAddressBuffer); \
  169. \
  170. switch ((_MacInfo)->MediumType) { \
  171. case NdisMedium802_5: \
  172. if (ARGUMENT_PRESENT(_Multicast)) { \
  173. *(PBOOLEAN)(_Multicast) = TmpPacket[2] & 0x80; \
  174. } \
  175. if (TmpPacket[8] & 0x80) { \
  176. *(PULONG)SrcBuffer = *(ULONG UNALIGNED *)(&TmpPacket[8]) & ~0x80;\
  177. SrcBuffer[4] = TmpPacket[12]; \
  178. SrcBuffer[5] = TmpPacket[13]; \
  179. *(_SourceAddress) = (PHARDWARE_ADDRESS)SrcBuffer; \
  180. } else { \
  181. *(_SourceAddress) = (PHARDWARE_ADDRESS)(TmpPacket + 8); \
  182. } \
  183. break; \
  184. default: \
  185. if (ARGUMENT_PRESENT(_Multicast)) { \
  186. *(PBOOLEAN)(_Multicast) = TmpPacket[0] & 0x01; \
  187. } \
  188. *(_SourceAddress) = (PHARDWARE_ADDRESS)(TmpPacket + \
  189. (_MacInfo)->SourceOffset); \
  190. break; \
  191. } \
  192. }
  193. //++
  194. //
  195. // VOID
  196. // MacReturnSourceRouting(
  197. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  198. // IN PVOID Packet,
  199. // OUT PVOID * SourceRouting
  200. // OUT PUINT SourceRoutingLength
  201. // );
  202. //
  203. // Routine Description:
  204. //
  205. // Returns the a pointer to the source routing info in the packet.
  206. //
  207. // Arguments:
  208. //
  209. // MacInfo - Describes the MAC we wish to decode.
  210. //
  211. // Packet - The packet data.
  212. //
  213. // SourceRouting - Returns the start of the source routing information,
  214. // or NULL if none is present.
  215. //
  216. // SourceRoutingLength - Returns the length of the source routing
  217. // information.
  218. //
  219. // Return Value:
  220. //
  221. // None.
  222. //
  223. //--
  224. #define MacReturnSourceRouting(_MacInfo, _Packet, _SourceRouting, _SourceRoutingLength) \
  225. { \
  226. PUCHAR TmpPacket = (PUCHAR)(_Packet); \
  227. *(_SourceRoutingLength) = 0; \
  228. if ((_MacInfo)->SourceRouting) { \
  229. if (TmpPacket[8] & 0x80) { \
  230. *(_SourceRouting) = TmpPacket + 14; \
  231. *(_SourceRoutingLength) = TmpPacket[14] & 0x1f; \
  232. } else { \
  233. *(_SourceRouting) = NULL; \
  234. } \
  235. } else { \
  236. *(_SourceRouting) = NULL; \
  237. } \
  238. }
  239. //++
  240. //
  241. // VOID
  242. // MacIsMulticast(
  243. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  244. // IN PVOID Packet,
  245. // OUT PBOOLEAN Multicast
  246. // );
  247. //
  248. // Routine Description:
  249. //
  250. // Returns TRUE if the packet is sent to the multicast address.
  251. //
  252. // Arguments:
  253. //
  254. // MacInfo - Describes the MAC we wish to decode.
  255. //
  256. // Packet - The packet data.
  257. //
  258. // Multicast - Returns the result.
  259. //
  260. // Return Value:
  261. //
  262. // None.
  263. //
  264. //--
  265. #define MacIsMulticast(_MacInfo, _Packet, _Multicast) \
  266. { \
  267. PUCHAR TmpPacket = (PUCHAR)(_Packet); \
  268. \
  269. switch ((_MacInfo)->MediumType) { \
  270. case NdisMedium802_5: \
  271. *(_Multicast) = ((TmpPacket[2] & 0x80) != 0); \
  272. break; \
  273. default: \
  274. *(_Multicast) = ((TmpPacket[0] & 0x01) != 0); \
  275. break; \
  276. } \
  277. }
  278. //++
  279. //
  280. // VOID
  281. // MacReturnPacketLength(
  282. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  283. // IN PVOID Header,
  284. // IN UINT PacketLength,
  285. // OUT PUINT DataLength
  286. // );
  287. //
  288. // Routine Description:
  289. //
  290. // Returns the length of data in the packet given the header.
  291. //
  292. // Arguments:
  293. //
  294. // MacInfo - Describes the MAC we wish to decode.
  295. //
  296. // Header - The packet header.
  297. //
  298. // PacketLength - The length of the data (not including header).
  299. //
  300. // DataLength - Returns the length of the data. Unchanged if the
  301. // packet is not recognized. Should be initialized by caller to 0.
  302. //
  303. // Return Value:
  304. //
  305. // None.
  306. //
  307. //--
  308. #define MacReturnPacketLength(_MacInfo, _Header, _HeaderLength, _PacketLength, _DataLength, _LookaheadBuffer, _LookaheadBufferLength) \
  309. { \
  310. PUCHAR TmpPacket = (PUCHAR)(_Header); \
  311. UINT TmpLength; \
  312. \
  313. switch ((_MacInfo)->MediumType) { \
  314. case NdisMedium802_3: \
  315. if ((_HeaderLength) >= 14) { \
  316. TmpLength = (TmpPacket[12] << 8) | TmpPacket[13]; \
  317. if (TmpLength <= 0x600) { \
  318. if (TmpLength <= (_PacketLength)) { \
  319. *(_DataLength) = TmpLength; \
  320. } \
  321. } \
  322. } \
  323. break; \
  324. case NdisMedium802_5: \
  325. if (((_HeaderLength) >= 14) && \
  326. (!(TmpPacket[8] & 0x80) || \
  327. ((_HeaderLength) >= \
  328. (UINT)(14 + (TmpPacket[14] & 0x1f))))) { \
  329. *(_DataLength) = (_PacketLength); \
  330. } \
  331. break; \
  332. case NdisMediumFddi: \
  333. if ((_HeaderLength) >= 13) { \
  334. *(_DataLength) = (_PacketLength); \
  335. } \
  336. break; \
  337. case NdisMediumDix: \
  338. if ((TmpPacket[12] == 0x80) && (TmpPacket[13] == 0xd5)) { \
  339. if (*(_LookaheadBufferLength) >= 3) { \
  340. TmpPacket = (PUCHAR)(*(_LookaheadBuffer)); \
  341. TmpLength = (TmpPacket[0] << 8) | TmpPacket[1]; \
  342. if (TmpLength <= (_PacketLength)-3) { \
  343. *(_DataLength) = TmpLength; \
  344. *(_LookaheadBuffer) = (PVOID)(TmpPacket + 3); \
  345. *(_LookaheadBufferLength) -= 3; \
  346. } \
  347. } \
  348. } \
  349. break; \
  350. } \
  351. }
  352. //++
  353. //
  354. // VOID
  355. // MacReturnHeaderLength(
  356. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  357. // IN PVOID Packet,
  358. // OUT PVOID HeaderLength,
  359. // );
  360. //
  361. // Routine Description:
  362. //
  363. // Returns the length of the MAC header in a packet (this
  364. // is used for loopback indications to separate header
  365. // and data).
  366. //
  367. // Arguments:
  368. //
  369. // MacInfo - Describes the MAC we wish to decode.
  370. //
  371. // Header - The packet header.
  372. //
  373. // HeaderLength - Returns the length of the header.
  374. //
  375. // Return Value:
  376. //
  377. // None.
  378. //
  379. //--
  380. #define MacReturnHeaderLength(_MacInfo, _Header, _HeaderLength) \
  381. { \
  382. PUCHAR TmpPacket = (PUCHAR)(_Header); \
  383. \
  384. switch ((_MacInfo)->MediumType) { \
  385. case NdisMedium802_3: \
  386. case NdisMediumDix: \
  387. *(_HeaderLength) = 14; \
  388. break; \
  389. case NdisMedium802_5: \
  390. if (TmpPacket[8] & 0x80) { \
  391. *(_HeaderLength) = (TmpPacket[14] & 0x1f) + 14; \
  392. } else { \
  393. *(_HeaderLength) = 14; \
  394. } \
  395. break; \
  396. case NdisMediumFddi: \
  397. *(_HeaderLength) = 13; \
  398. break; \
  399. } \
  400. }
  401. //++
  402. //
  403. // VOID
  404. // MacReturnSingleRouteSR(
  405. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  406. // OUT PVOID * SingleRouteSR,
  407. // OUT PUINT SingleRouteSRLength
  408. // );
  409. //
  410. // Routine Description:
  411. //
  412. // Returns the a pointer to the standard single route broadcast
  413. // source routing information for the media type. This is used
  414. // for ADD_NAME_QUERY, DATAGRAM, NAME_IN_CONFLICT, NAME_QUERY,
  415. // and STATUS_QUERY frames.
  416. //
  417. // Arguments:
  418. //
  419. // MacInfo - Describes the MAC we wish to decode.
  420. //
  421. // SingleRouteSR - Returns a pointer to the data.
  422. //
  423. // SingleRouteSRLength - The length of SingleRouteSR.
  424. //
  425. // Return Value:
  426. //
  427. // None.
  428. //
  429. //--
  430. #define MacReturnSingleRouteSR(_MacInfo, _SingleRouteSR, _SingleRouteSRLength) \
  431. { \
  432. switch ((_MacInfo)->MediumType) { \
  433. case NdisMedium802_5: \
  434. *(_SingleRouteSR) = SingleRouteSourceRouting; \
  435. *(_SingleRouteSRLength) = DefaultSourceRoutingLength; \
  436. break; \
  437. default: \
  438. *(_SingleRouteSR) = NULL; \
  439. break; \
  440. } \
  441. }
  442. //++
  443. //
  444. // VOID
  445. // MacReturnGeneralRouteSR(
  446. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  447. // OUT PVOID * GeneralRouteSR,
  448. // OUT PUINT GeneralRouteSRLength
  449. // );
  450. //
  451. // Routine Description:
  452. //
  453. // Returns the a pointer to the standard general route broadcast
  454. // source routing information for the media type. This is used
  455. // for NAME_RECOGNIZED frames.
  456. //
  457. // Arguments:
  458. //
  459. // MacInfo - Describes the MAC we wish to decode.
  460. //
  461. // GeneralRouteSR - Returns a pointer to the data.
  462. //
  463. // GeneralRouteSRLength - The length of GeneralRouteSR.
  464. //
  465. // Return Value:
  466. //
  467. // None.
  468. //
  469. //--
  470. #define MacReturnGeneralRouteSR(_MacInfo, _GeneralRouteSR, _GeneralRouteSRLength) \
  471. { \
  472. switch ((_MacInfo)->MediumType) { \
  473. case NdisMedium802_5: \
  474. *(_GeneralRouteSR) = GeneralRouteSourceRouting; \
  475. *(_GeneralRouteSRLength) = DefaultSourceRoutingLength; \
  476. break; \
  477. default: \
  478. *(_GeneralRouteSR) = NULL; \
  479. break; \
  480. } \
  481. }
  482. #if 0
  483. //++
  484. //
  485. // VOID
  486. // MacCreateGeneralRouteReplySR(
  487. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  488. // IN PUCHAR ExistingSR,
  489. // IN UINT ExistingSRLength,
  490. // OUT PUCHAR * NewSR
  491. // );
  492. //
  493. // Routine Description:
  494. //
  495. // This modifies an existing source routing entry to make
  496. // it into a general-route source routing entry. The assumption
  497. // is that is to reply to existing source routing, so the
  498. // direction bit is also reversed. In addition, if it is
  499. // determined that no source routing is needed in the reply,
  500. // then NULL is returned.
  501. //
  502. // Note that the information is modified in-place, but a
  503. // separate pointer is returned (to allow NULL to be returned).
  504. //
  505. // Arguments:
  506. //
  507. // MacInfo - Describes the MAC we wish to decode.
  508. //
  509. // ExistingSR - The existing source routing to be modified.
  510. //
  511. // Return Value:
  512. //
  513. // None.
  514. //
  515. //--
  516. #define MacCreateGeneralRouteReplySR(_MacInfo, _ExistingSR, _ExistingSRLength, _NewSR) \
  517. { \
  518. if (_ExistingSR) { \
  519. PUCHAR TmpSR = (PUCHAR)(_ExistingSR); \
  520. switch ((_MacInfo)->MediumType) { \
  521. case NdisMedium802_5: \
  522. TmpSR[0] = (TmpSR[0] & 0x1f) | 0x80; \
  523. TmpSR[1] = (TmpSR[1] ^ 0x80); \
  524. *(_NewSR) = (_ExistingSR); \
  525. break; \
  526. default: \
  527. *(_NewSR) = (_ExistingSR); \
  528. break; \
  529. } \
  530. } else { \
  531. *(_NewSR) = NULL; \
  532. } \
  533. }
  534. #endif
  535. //++
  536. //
  537. // VOID
  538. // MacCreateNonBroadcastReplySR(
  539. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  540. // IN PUCHAR ExistingSR,
  541. // IN UINT ExistingSRLength,
  542. // OUT PUCHAR * NewSR
  543. // );
  544. //
  545. // Routine Description:
  546. //
  547. // This modifies an existing source routing entry to make
  548. // it into a non-broadcast source routing entry. The assumption
  549. // is that is to reply to existing source routing, so the
  550. // direction bit is also reversed. In addition, if it is
  551. // determined that no source routing is needed in the reply,
  552. // then NULL is returned.
  553. //
  554. // Note that the information is modified in-place, but a
  555. // separate pointer is returned (to allow NULL to be returned).
  556. //
  557. // Arguments:
  558. //
  559. // MacInfo - Describes the MAC we wish to decode.
  560. //
  561. // ExistingSR - The existing source routing to be modified.
  562. //
  563. // Return Value:
  564. //
  565. // None.
  566. //
  567. //--
  568. #define MacCreateNonBroadcastReplySR(_MacInfo, _ExistingSR, _ExistingSRLength, _NewSR) \
  569. { \
  570. if (_ExistingSR) { \
  571. PUCHAR TmpSR = (PUCHAR)(_ExistingSR); \
  572. switch ((_MacInfo)->MediumType) { \
  573. case NdisMedium802_5: \
  574. if ((_ExistingSRLength) == 2) { \
  575. *(_NewSR) = NULL; \
  576. } else { \
  577. TmpSR[0] = (TmpSR[0] & 0x1f); \
  578. TmpSR[1] = (TmpSR[1] ^ 0x80); \
  579. *(_NewSR) = (_ExistingSR); \
  580. } \
  581. break; \
  582. default: \
  583. *(_NewSR) = (_ExistingSR); \
  584. break; \
  585. } \
  586. } else { \
  587. *(_NewSR) = NULL; \
  588. } \
  589. }
  590. //++
  591. //
  592. // VOID
  593. // MacModifyHeader(
  594. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  595. // IN PUCHAR Header,
  596. // IN UINT PacketLength
  597. // );
  598. //
  599. // Routine Description:
  600. //
  601. // Modifies a pre-built packet header to include the
  602. // packet length. Used for connection-oriented traffic
  603. // where the header is pre-built.
  604. //
  605. // Arguments:
  606. //
  607. // MacInfo - Describes the MAC we wish to decode.
  608. //
  609. // Header - The header to modify.
  610. //
  611. // PacketLength - Packet length (not including the header).
  612. // Currently this is the only field that cannot be pre-built.
  613. //
  614. // Return Value:
  615. //
  616. // None.
  617. //
  618. //--
  619. #define MacModifyHeader(_MacInfo, _Header, _PacketLength) \
  620. { \
  621. switch ((_MacInfo)->MediumType) { \
  622. case NdisMedium802_3: \
  623. (_Header)[12] = (UCHAR)((_PacketLength) >> 8); \
  624. (_Header)[13] = (UCHAR)((_PacketLength) & 0xff); \
  625. break; \
  626. case NdisMediumDix: \
  627. (_Header)[14] = (UCHAR)((_PacketLength) >> 8); \
  628. (_Header)[15] = (UCHAR)((_PacketLength) & 0xff); \
  629. break; \
  630. } \
  631. }
  632. //++
  633. //
  634. // VOID
  635. // MacReturnMagicAddress(
  636. // IN PNBF_NDIS_IDENTIFICATION MacInfo,
  637. // IN PVOID Address,
  638. // OUT PULARGE_INTEGER Magic
  639. // );
  640. //
  641. // Routine Description:
  642. //
  643. // MacReturnMagicAddress returns the link as a 64 bit number.
  644. // We then find the link in the link trees by doing a large
  645. // integer comparison.
  646. //
  647. // The number is constructed by assigning the last four bytes of
  648. // the address as the low longword, and the first two bytes as
  649. // the high one. For 802_5 we need to mask off the source routing
  650. // bit in byte 0 of the address.
  651. //
  652. // Arguments:
  653. //
  654. // MacInfo - Describes the MAC we wish to decode.
  655. //
  656. // Address - The address we are encoding.
  657. //
  658. // Magic - Returns the magic number for this address.
  659. //
  660. // Return Value:
  661. //
  662. // None.
  663. //
  664. //--
  665. #define MacReturnMagicAddress(_MacInfo, _Address, _Magic) \
  666. { \
  667. PUCHAR TempAddr = (PUCHAR)(_Address); \
  668. \
  669. (_Magic)->LowPart = *((LONG UNALIGNED *)(TempAddr + 2)); \
  670. if ((_MacInfo)->MediumType == NdisMedium802_5) { \
  671. (_Magic)->HighPart = ((TempAddr[0] & 0x7f) << 8) + TempAddr[1]; \
  672. } else { \
  673. (_Magic)->HighPart = (TempAddr[0] << 8) + TempAddr[1]; \
  674. } \
  675. }
  676. VOID
  677. MacSetNetBIOSMulticast (
  678. IN NDIS_MEDIUM Type,
  679. IN PUCHAR Buffer
  680. );
  681. // VOID
  682. // NbfSetNdisPacketLength (
  683. // IN NDIS_PACKET Packet,
  684. // IN ULONG Length
  685. // );
  686. //
  687. // NB: This is not a general purpose macro; it assumes that we are setting the
  688. // length of an NDIS packet with only one NDIS_BUFFER chained. We do
  689. // this to save time during the sending of short control packets.
  690. //
  691. #define NbfSetNdisPacketLength(_packet,_length) { \
  692. PNDIS_BUFFER NdisBuffer; \
  693. NdisQueryPacket((_packet), NULL, NULL, &NdisBuffer, NULL); \
  694. NdisAdjustBufferLength(NdisBuffer, (_length)); \
  695. NdisRecalculatePacketCounts(_packet); \
  696. }
  697. #endif // ifdef _MAC_