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.

1325 lines
36 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. llcapi.h
  5. Abstract:
  6. This module defined the kernel API of data link driver.
  7. All function prototypes and typedefs of the interface
  8. have been defined here.
  9. Author:
  10. Antti Saarenheimo (o-anttis) 17-MAY-1991
  11. Revision History:
  12. --*/
  13. #ifndef _LLC_API_
  14. #define _LLC_API_
  15. #include "llcmem.h"
  16. //
  17. // The debug switches
  18. //
  19. //
  20. // LLC_DBG:
  21. //
  22. // 0 => No debug code is generated
  23. // 1 => Enables the memory allocation accounting, state machine tracing,
  24. // procedure call tracing and internal consistency checks
  25. // 2 => Enables memory block overflow checking
  26. //
  27. //
  28. #define LLC_DBG 0
  29. #define DBG_MP 0 // enables the MP safe versions of the accounting macros
  30. #define DLC_TRACE_ENABLED 1 // Procedure call tracing, debug only.
  31. extern NDIS_SPIN_LOCK DlcDriverLock;
  32. //
  33. // ANY_IRQL: pseudo value used in ASSUME_IRQL to mean routine is not IRQL sensitive.
  34. // Use this value with ASSUME_IRQL instead of omitting ASSUME_IRQL from a routine
  35. // (shows that we didn't forget this routine)
  36. //
  37. #define ANY_IRQL ((ULONG)-1)
  38. #if defined(LOCK_CHECK)
  39. extern LONG DlcDriverLockLevel;
  40. extern ULONG __line;
  41. extern PCHAR __file;
  42. extern LONG __last;
  43. extern HANDLE __process;
  44. extern HANDLE __thread;
  45. //
  46. // _strip - quick functionette to strip out the path garbage from __FILE__
  47. //
  48. __inline char* _strip(char* s) {
  49. char* e = s + strlen(s) - 1;
  50. while (e != s) {
  51. if (*e == '\\') {
  52. return e + 1;
  53. }
  54. --e;
  55. }
  56. return s;
  57. }
  58. #define $$_PLACE "%s!%d"
  59. #define $$_FILE_AND_LINE _strip(__FILE__), __LINE__
  60. //
  61. // ACQUIRE_DRIVER_LOCK - acquires the global DLC driver Spin Lock, using
  62. // NdisAcquireSpinLock(). We also check for re-entrancy and incorrect ordering
  63. // of spin lock calls
  64. //
  65. #define ACQUIRE_DRIVER_LOCK() \
  66. { \
  67. KIRQL currentIrql; \
  68. HANDLE hprocess; \
  69. HANDLE hthread; \
  70. \
  71. currentIrql = KeGetCurrentIrql(); \
  72. if (currentIrql == PASSIVE_LEVEL) { \
  73. \
  74. PETHREAD pthread; \
  75. \
  76. pthread = PsGetCurrentThread(); \
  77. hprocess = pthread->Cid.UniqueProcess; \
  78. hthread = pthread->Cid.UniqueThread; \
  79. } else { \
  80. hprocess = (HANDLE)-1; \
  81. hthread = (HANDLE)-1; \
  82. } \
  83. NdisAcquireSpinLock(&DlcDriverLock); \
  84. if (++DlcDriverLockLevel != 1) { \
  85. __last = DlcDriverLockLevel; \
  86. DbgPrint("%d.%d:" $$_PLACE ": ACQUIRE_DRIVER_LOCK: level = %d. Last = %d.%d:" $$_PLACE "\n", \
  87. hprocess, \
  88. hthread, \
  89. $$_FILE_AND_LINE, \
  90. DlcDriverLockLevel, \
  91. __process, \
  92. __thread, \
  93. __file, \
  94. __line \
  95. ); \
  96. DbgBreakPoint(); \
  97. } \
  98. __file = _strip(__FILE__); \
  99. __line = __LINE__; \
  100. __process = hprocess; \
  101. __thread = hthread; \
  102. ASSUME_IRQL(DISPATCH_LEVEL); \
  103. }
  104. //
  105. // RELEASE_DRIVER_LOCK - releases the global DLC driver Spin Lock, using
  106. // NdisReleaseSpinLock(). We also check for re-entrancy and incorrect ordering
  107. // of spin lock calls
  108. //
  109. #define RELEASE_DRIVER_LOCK() \
  110. if (DlcDriverLockLevel != 1) { \
  111. DbgPrint($$_PLACE ": RELEASE_DRIVER_LOCK: level = %d. Last = %d.%d:" $$_PLACE "\n", \
  112. $$_FILE_AND_LINE, \
  113. DlcDriverLockLevel, \
  114. __process, \
  115. __thread, \
  116. __file, \
  117. __line \
  118. ); \
  119. DbgBreakPoint(); \
  120. } \
  121. --DlcDriverLockLevel; \
  122. __file = _strip(__FILE__); \
  123. __line = __LINE__; \
  124. NdisReleaseSpinLock(&DlcDriverLock);
  125. //
  126. // ASSUME_IRQL - used to check that a routine is being called at the IRQL we
  127. // expect. Due to the design of DLC, most functions are called at raised IRQL
  128. // (DISPATCH_LEVEL). Used mainly to assure that IRQL is at PASSIVE_LEVEL when
  129. // we do something which may incur a page fault e.g.
  130. //
  131. #define ASSUME_IRQL(level) \
  132. if (((level) != ANY_IRQL) && (KeGetCurrentIrql() != (level))) { \
  133. DbgPrint($$_PLACE ": ASSUME_IRQL(%d): Actual is %d\n", \
  134. $$_FILE_AND_LINE, \
  135. level, \
  136. KeGetCurrentIrql() \
  137. ); \
  138. DbgBreakPoint(); \
  139. }
  140. //
  141. // MY_ASSERT - since ASSERT only expands to something meaningful in the checked
  142. // build, we use this when we want an assertion check in a free build
  143. //
  144. #define MY_ASSERT(x) \
  145. if (!(x)) { \
  146. DbgPrint($$_PLACE ": Assertion Failed: " # x "\n", \
  147. $$_FILE_AND_LINE \
  148. ); \
  149. DbgBreakPoint(); \
  150. }
  151. //
  152. // IF_LOCK_CHECK - conditional compilation made cleaner
  153. //
  154. #define IF_LOCK_CHECK \
  155. if (TRUE)
  156. #else
  157. #define ACQUIRE_DRIVER_LOCK() NdisAcquireSpinLock(&DlcDriverLock)
  158. #define RELEASE_DRIVER_LOCK() NdisReleaseSpinLock(&DlcDriverLock)
  159. #define ASSUME_IRQL(level) /* NOTHING */
  160. #define MY_ASSERT(x) /* NOTHING */
  161. #define IF_LOCK_CHECK if (FALSE)
  162. #endif
  163. //
  164. // in the Unilock DLC, we do not need the LLC spin-lock
  165. //
  166. #if defined(DLC_UNILOCK)
  167. #define ACQUIRE_LLC_LOCK(i)
  168. #define RELEASE_LLC_LOCK(i)
  169. #define ACQUIRE_SPIN_LOCK(p)
  170. #define RELEASE_SPIN_LOCK(p)
  171. #define ALLOCATE_SPIN_LOCK(p)
  172. #define DEALLOCATE_SPIN_LOCK(p)
  173. #else
  174. #define ACQUIRE_LLC_LOCK(i) KeAcquireSpinLock(&LlcSpinLock, (i))
  175. #define RELEASE_LLC_LOCK(i) KeReleaseSpinLock(&LlcSpinLock, (i))
  176. #define ACQUIRE_SPIN_LOCK(p) NdisAcquireSpinLock((p))
  177. #define RELEASE_SPIN_LOCK(p) NdisReleaseSpinLock((p))
  178. #define ALLOCATE_SPIN_LOCK(p) KeInitializeSpinLock(&(p)->SpinLock)
  179. #define DEALLOCATE_SPIN_LOCK(p)
  180. #endif
  181. //
  182. // IS_SNA_DIX_FRAME - TRUE if the frame just received & therefore described in
  183. // the ADAPTER_CONTEXT (p) has DIX framing (SNA)
  184. //
  185. #define IS_SNA_DIX_FRAME(p) \
  186. (((PADAPTER_CONTEXT)(p))->IsSnaDixFrame)
  187. //
  188. // IS_AUTO_BINDING - TRUE if the BINDING_CONTEXT was created with
  189. // LLC_ETHERNET_TYPE_AUTO
  190. //
  191. #define IS_AUTO_BINDING(p) \
  192. (((PBINDING_CONTEXT)(p))->EthernetType == LLC_ETHERNET_TYPE_AUTO)
  193. #define FRAME_MASK_LLC_LOCAL_DEST 0x0001
  194. #define FRAME_MASK_NON_LLC_LOCAL_DEST 0x0002
  195. #define FRAME_MASK_NON_LOCAL_DEST 0x0004
  196. #define FRAME_MASK_ALL_FRAMES 0x0007
  197. #define LLC_EXCLUSIVE_ACCESS 0x0001
  198. #define LLC_HANDLE_XID_COMMANDS 0x0002
  199. //
  200. // Direct station receive flags (bits 0 and 1 are inverted from dlcapi!!!)
  201. //
  202. #define DLC_RCV_SPECIFIC_DIX 0
  203. #define DLC_RCV_MAC_FRAMES 1
  204. #define DLC_RCV_8022_FRAMES 2
  205. #define DLC_RCV_DIX_FRAMES 4
  206. #define LLC_VALID_RCV_MASK 7
  207. #define DLC_RCV_OTHER_DESTINATION 8
  208. #define MAX_LLC_FRAME_TYPES 10
  209. //
  210. // The DLC link states reported by DLC API
  211. //
  212. enum _DATA_LINK_STATES {
  213. //
  214. // Primary states
  215. //
  216. LLC_LINK_CLOSED = 0x80,
  217. LLC_DISCONNECTED = 0x40,
  218. LLC_DISCONNECTING = 0x20,
  219. LLC_LINK_OPENING = 0x10,
  220. LLC_RESETTING = 0x08,
  221. LLC_FRMR_SENT = 0x04,
  222. LLC_FRMR_RECEIVED = 0x02,
  223. LLC_LINK_OPENED = 0x01,
  224. //
  225. // Secondary states (when primary state is LLC_LINK_OPENED)
  226. //
  227. LLC_CHECKPOINTING = 0x80,
  228. LLC_LOCAL_BUSY_USER_SET = 0x40,
  229. LLC_LOCAL_BUSY_BUFFER_SET = 0x20,
  230. LLC_REMOTE_BUSY = 0x10,
  231. LLC_REJECTING = 0x08,
  232. LLC_CLEARING = 0x04,
  233. LLC_DYNMIC_WIN_ALG_RUNNIG = 0x02,
  234. LLC_NO_SECONDARY_STATE = 0
  235. };
  236. //
  237. // LAN802_ADDRESS - 8 bytes of frame address. Typically 6 bytes LAN address
  238. // plus 1 byte destination SAP, plus 1 byte source SAP
  239. //
  240. typedef union {
  241. struct {
  242. UCHAR DestSap;
  243. UCHAR SrcSap;
  244. USHORT usHigh;
  245. ULONG ulLow;
  246. } Address;
  247. struct {
  248. ULONG High;
  249. ULONG Low;
  250. } ul;
  251. struct {
  252. USHORT Raw[4];
  253. } aus;
  254. struct {
  255. UCHAR DestSap;
  256. UCHAR SrcSap;
  257. UCHAR auchAddress[6];
  258. } Node;
  259. UCHAR auchRawAddress[8];
  260. } LAN802_ADDRESS, *PLAN802_ADDRESS;
  261. //
  262. // Structure is used by DlcNdisRequest function
  263. //
  264. typedef struct {
  265. NDIS_STATUS AsyncStatus;
  266. KEVENT SyncEvent;
  267. NDIS_REQUEST Ndis;
  268. } LLC_NDIS_REQUEST, *PLLC_NDIS_REQUEST;
  269. #define NDIS_INFO_BUF_SIZE 20
  270. #define DLC_ANY_STATION (-1)
  271. //
  272. // Internal event flags used by Timer, DlcConnect
  273. // and DlcClose commands.
  274. //
  275. #define DLC_REPEATED_FLAGS 0x0700
  276. #define LLC_TIMER_TICK_EVENT 0x0100
  277. #define LLC_STATUS_CHANGE_ON_SAP 0x0800
  278. //
  279. // These enum types are used also as the index of a mapping table!
  280. //
  281. enum _LLC_OBJECT_TYPES {
  282. LLC_DIRECT_OBJECT,
  283. LLC_SAP_OBJECT,
  284. LLC_GROUP_SAP_OBJECT,
  285. LLC_LINK_OBJECT,
  286. LLC_DIX_OBJECT
  287. };
  288. //
  289. // We moved these defines here because the macro is used by data link
  290. //
  291. #define MIN_DLC_BUFFER_SEGMENT 256
  292. ////#define MAX_DLC_BUFFER_SEGMENT 4096
  293. //#define MAX_DLC_BUFFER_SEGMENT 8192
  294. #define MAX_DLC_BUFFER_SEGMENT PAGE_SIZE
  295. #define BufGetPacketSize( PacketSize ) \
  296. (((PacketSize) + 2 * MIN_DLC_BUFFER_SEGMENT - 1) & \
  297. -MIN_DLC_BUFFER_SEGMENT)
  298. //
  299. // READ Event flags:
  300. //
  301. #define DLC_READ_FLAGS 0x007f
  302. #define LLC_SYSTEM_ACTION 0x0040
  303. #define LLC_NETWORK_STATUS 0x0020
  304. #define LLC_CRITICAL_EXCEPTION 0x0010
  305. #define LLC_STATUS_CHANGE 0x0008
  306. #define LLC_RECEIVE_DATA 0x0004
  307. #define LLC_TRANSMIT_COMPLETION 0x0002
  308. #define DLC_COMMAND_COMPLETION 0x0001
  309. #define ALL_DLC_EVENTS -1
  310. //
  311. // LLC_STATUS_CHANGE indications:
  312. //
  313. #define INDICATE_LINK_LOST 0x8000
  314. #define INDICATE_DM_DISC_RECEIVED 0x4000
  315. #define INDICATE_FRMR_RECEIVED 0x2000
  316. #define INDICATE_FRMR_SENT 0x1000
  317. #define INDICATE_RESET 0x0800
  318. #define INDICATE_CONNECT_REQUEST 0x0400
  319. #define INDICATE_REMOTE_BUSY 0x0200
  320. #define INDICATE_REMOTE_READY 0x0100
  321. #define INDICATE_TI_TIMER_EXPIRED 0x0080
  322. #define INDICATE_DLC_COUNTER_OVERFLOW 0x0040
  323. #define INDICATE_ACCESS_PRTY_LOWERED 0x0020
  324. #define INDICATE_LOCAL_STATION_BUSY 0x0001
  325. //
  326. // LLC Command completion indications.
  327. //
  328. enum _LLC_COMPLETION_CODES {
  329. LLC_RECEIVE_COMPLETION,
  330. LLC_SEND_COMPLETION,
  331. LLC_REQUEST_COMPLETION,
  332. LLC_CLOSE_COMPLETION,
  333. LLC_RESET_COMPLETION,
  334. LLC_CONNECT_COMPLETION,
  335. LLC_DISCONNECT_COMPLETION
  336. };
  337. typedef union {
  338. LLC_ADAPTER_INFO Adapter;
  339. DLC_LINK_PARAMETERS LinkParms;
  340. LLC_TICKS Timer;
  341. DLC_LINK_LOG LinkLog;
  342. DLC_SAP_LOG SapLog;
  343. UCHAR PermanentAddress[6];
  344. UCHAR auchBuffer[1];
  345. } LLC_QUERY_INFO_BUFFER, *PLLC_QUERY_INFO_BUFFER;
  346. typedef union {
  347. DLC_LINK_PARAMETERS LinkParms;
  348. LLC_TICKS Timers;
  349. UCHAR auchFunctionalAddress[4];
  350. UCHAR auchGroupAddress[4];
  351. UCHAR auchBuffer[1];
  352. } LLC_SET_INFO_BUFFER, *PLLC_SET_INFO_BUFFER;
  353. //
  354. // LLC_FRMR_INFORMATION - 5 bytes of FRaMe Reject code
  355. //
  356. typedef struct {
  357. UCHAR Command; // format: mmmpmm11, m=modifiers, p=poll/final.
  358. UCHAR Ctrl; // control field of rejected frame.
  359. UCHAR Vs; // our next send when error was detected.
  360. UCHAR Vr; // our next receive when error was detected.
  361. UCHAR Reason; // reason for sending FRMR: 000VZYXW.
  362. } LLC_FRMR_INFORMATION, *PLLC_FRMR_INFORMATION;
  363. //
  364. // DLC_STATUS_TABLE - format of status information returned in a READ command
  365. //
  366. typedef struct {
  367. USHORT StatusCode;
  368. LLC_FRMR_INFORMATION FrmrData;
  369. UCHAR uchAccessPriority;
  370. UCHAR auchRemoteNode[6];
  371. UCHAR uchRemoteSap;
  372. UCHAR uchLocalSap;
  373. PVOID hLlcLinkStation;
  374. } DLC_STATUS_TABLE, *PDLC_STATUS_TABLE;
  375. typedef struct {
  376. ULONG IsCompleted;
  377. ULONG Status;
  378. } ASYNC_STATUS, *PASYNC_STATUS;
  379. union _LLC_OBJECT;
  380. typedef union _LLC_OBJECT LLC_OBJECT, *PLLC_OBJECT;
  381. struct _BINDING_CONTEXT;
  382. typedef struct _BINDING_CONTEXT BINDING_CONTEXT, *PBINDING_CONTEXT;
  383. //
  384. // LLC packet headers
  385. //
  386. //
  387. // LLC_XID_INFORMATION - 3 information bytes in a standard LLC XID packet
  388. //
  389. typedef struct {
  390. UCHAR FormatId; // format of this XID frame.
  391. UCHAR Info1; // first information byte.
  392. UCHAR Info2; // second information byte.
  393. } LLC_XID_INFORMATION, *PLLC_XID_INFORMATION;
  394. //
  395. // LLC_TEST_INFORMATION - information field for TEST frame
  396. //
  397. typedef struct {
  398. UCHAR Padding[4];
  399. PMDL pMdl; // we keep test MDL in the same slot as U-MDL
  400. } LLC_TEST_INFORMATION, *PLLC_TEST_INFORMATION;
  401. typedef union {
  402. LLC_XID_INFORMATION Xid; // XID information.
  403. LLC_FRMR_INFORMATION Frmr; // FRMR information.
  404. LLC_TEST_INFORMATION Test; // Test MDL pointer
  405. UCHAR Padding[8]; //
  406. } LLC_RESPONSE_INFO, *PLLC_RESPONSE_INFO;
  407. //
  408. // LLC_U_HEADER - Unnumbered format frame LLC header
  409. //
  410. typedef struct {
  411. UCHAR Dsap; // Destination Service Access Point.
  412. UCHAR Ssap; // Source Service Access Point.
  413. UCHAR Command; // command code.
  414. } LLC_U_HEADER, *PLLC_U_HEADER;
  415. //
  416. // LLC_S_HEADER - Supervisory format frame LLC header
  417. //
  418. typedef struct {
  419. UCHAR Dsap; // Destination Service Access Point.
  420. UCHAR Ssap; // Source Service Access Point.
  421. UCHAR Command; // RR, RNR, REJ command code.
  422. UCHAR Nr; // receive seq #, bottom bit is poll/final.
  423. } LLC_S_HEADER, *PLLC_S_HEADER;
  424. //
  425. // LLC_I_HEADER - Information frame LLC header
  426. //
  427. typedef struct {
  428. UCHAR Dsap; // Destination Service Access Point.
  429. UCHAR Ssap; // Source Service Access Point.
  430. UCHAR Ns; // send sequence number, bottom bit 0.
  431. UCHAR Nr; // rcv sequence number, bottom bit p/f.
  432. } LLC_I_HEADER, *PLLC_I_HEADER;
  433. typedef struct {
  434. LLC_U_HEADER U; // normal U- frame
  435. UCHAR Type; // its lan header conversion type
  436. } LLC_U_PACKET_HEADER, *PLLC_U_PACKET_HEADER;
  437. typedef union {
  438. LLC_S_HEADER S;
  439. LLC_I_HEADER I;
  440. LLC_U_HEADER U;
  441. ULONG ulRawLLc;
  442. UCHAR auchRawBytes[4];
  443. USHORT EthernetType;
  444. } LLC_HEADER, *PLLC_HEADER;
  445. typedef struct _LLC_PACKET {
  446. struct _LLC_PACKET* pNext;
  447. struct _LLC_PACKET* pPrev;
  448. UCHAR CompletionType;
  449. UCHAR cbLlcHeader;
  450. USHORT InformationLength;
  451. PBINDING_CONTEXT pBinding;
  452. union {
  453. struct {
  454. PUCHAR pLanHeader;
  455. LLC_HEADER LlcHeader;
  456. PLLC_OBJECT pLlcObject;
  457. PMDL pMdl;
  458. } Xmit;
  459. struct {
  460. PUCHAR pLanHeader;
  461. UCHAR TranslationType;
  462. UCHAR Dsap;
  463. UCHAR Ssap;
  464. UCHAR Command;
  465. PLLC_OBJECT pLlcObject;
  466. PMDL pMdl;
  467. } XmitU;
  468. struct {
  469. PUCHAR pLanHeader;
  470. UCHAR TranslationType;
  471. UCHAR EthernetTypeHighByte;
  472. UCHAR EthernetTypeLowByte;
  473. UCHAR Padding;
  474. PLLC_OBJECT pLlcObject;
  475. PMDL pMdl;
  476. } XmitDix;
  477. struct {
  478. PUCHAR pLanHeader;
  479. UCHAR TranslationType;
  480. UCHAR Dsap;
  481. UCHAR Ssap;
  482. UCHAR Command;
  483. LLC_RESPONSE_INFO Info;
  484. } Response;
  485. //
  486. // Link station data packet may be acknowledged by the other
  487. // side, before it is completed by NDIS. Ndis completion
  488. // routine expects to find pLlcObject link => we must not change
  489. // that field, when the xmit packet is translated to
  490. // a completion packet. Otherwise is corrupt pFileContext pointer,
  491. // when NdisSendCount is incremented.
  492. //
  493. struct {
  494. ULONG Status;
  495. ULONG CompletedCommand;
  496. PLLC_OBJECT pLlcObject;
  497. PVOID hClientHandle;
  498. } Completion;
  499. } Data;
  500. } LLC_PACKET, *PLLC_PACKET;
  501. //
  502. // DLC API return codes
  503. //
  504. // The base value of the error codes is not compatible with the other
  505. // nt error codes, but it doesn't matter because these are internal
  506. // for DLC driver (and its data link layer).
  507. // 16 bit- error codes are used, because in MIPS they need less
  508. // instructions (MIPS cannot load directly over 16 bits constants)
  509. // and this code can also be emuulated on OS/2.
  510. //
  511. typedef enum _DLC_STATUS {
  512. DLC_STATUS_SUCCESS = 0,
  513. DLC_STATUS_ERROR_BASE = 0x6000,
  514. DLC_STATUS_INVALID_COMMAND = 0x01 + DLC_STATUS_ERROR_BASE,
  515. DLC_STATUS_DUPLICATE_COMMAND = 0x02 + DLC_STATUS_ERROR_BASE,
  516. DLC_STATUS_ADAPTER_OPEN = 0x03 + DLC_STATUS_ERROR_BASE,
  517. DLC_STATUS_ADAPTER_CLOSED = 0x04 + DLC_STATUS_ERROR_BASE,
  518. DLC_STATUS_PARAMETER_MISSING = 0x05 + DLC_STATUS_ERROR_BASE,
  519. DLC_STATUS_INVALID_OPTION = 0x06 + DLC_STATUS_ERROR_BASE,
  520. DLC_STATUS_COMMAND_CANCELLED_FAILURE = 0x07 + DLC_STATUS_ERROR_BASE,
  521. DLC_STATUS_CANCELLED_BY_USER = 0x0A + DLC_STATUS_ERROR_BASE,
  522. DLC_STATUS_SUCCESS_NOT_OPEN = 0x0C + DLC_STATUS_ERROR_BASE,
  523. DLC_STATUS_TIMER_ERROR = 0x11 + DLC_STATUS_ERROR_BASE,
  524. DLC_STATUS_NO_MEMORY = 0x12 + DLC_STATUS_ERROR_BASE,
  525. DLC_STATUS_LOST_LOG_DATA = 0x15 + DLC_STATUS_ERROR_BASE,
  526. DLC_STATUS_BUFFER_SIZE_EXCEEDED = 0x16 + DLC_STATUS_ERROR_BASE,
  527. DLC_STATUS_INVALID_BUFFER_LENGTH = 0x18 + DLC_STATUS_ERROR_BASE,
  528. DLC_STATUS_INADEQUATE_BUFFERS = 0x19 + DLC_STATUS_ERROR_BASE,
  529. DLC_STATUS_USER_LENGTH_TOO_LARGE = 0x1A + DLC_STATUS_ERROR_BASE,
  530. DLC_STATUS_INVALID_CCB_POINTER = 0x1B + DLC_STATUS_ERROR_BASE,
  531. DLC_STATUS_INVALID_POINTER = 0x1C + DLC_STATUS_ERROR_BASE,
  532. DLC_STATUS_INVALID_ADAPTER = 0x1D + DLC_STATUS_ERROR_BASE,
  533. DLC_STATUS_INVALID_FUNCTIONAL_ADDRESS = 0x1E + DLC_STATUS_ERROR_BASE,
  534. DLC_STATUS_LOST_DATA_NO_BUFFERS = 0x20 + DLC_STATUS_ERROR_BASE,
  535. DLC_STATUS_TRANSMIT_ERROR_FS = 0x22 + DLC_STATUS_ERROR_BASE,
  536. DLC_STATUS_TRANSMIT_ERROR = 0x23 + DLC_STATUS_ERROR_BASE,
  537. DLC_STATUS_UNAUTHORIZED_MAC = 0x24 + DLC_STATUS_ERROR_BASE,
  538. DLC_STATUS_LINK_NOT_TRANSMITTING = 0x27 + DLC_STATUS_ERROR_BASE,
  539. DLC_STATUS_INVALID_FRAME_LENGTH = 0x28 + DLC_STATUS_ERROR_BASE,
  540. DLC_STATUS_INVALID_NODE_ADDRESS = 0x32 + DLC_STATUS_ERROR_BASE,
  541. DLC_STATUS_INVALID_RECEIVE_BUFFER_LENGTH = 0x33 + DLC_STATUS_ERROR_BASE,
  542. DLC_STATUS_INVALID_TRANSMIT_BUFFER_LENGTH = 0x34 + DLC_STATUS_ERROR_BASE,
  543. DLC_STATUS_INVALID_STATION_ID = 0x40 + DLC_STATUS_ERROR_BASE,
  544. DLC_STATUS_LINK_PROTOCOL_ERROR = 0x41 + DLC_STATUS_ERROR_BASE,
  545. DLC_STATUS_PARMETERS_EXCEEDED_MAX = 0x42 + DLC_STATUS_ERROR_BASE,
  546. DLC_STATUS_INVALID_SAP_VALUE = 0x43 + DLC_STATUS_ERROR_BASE,
  547. DLC_STATUS_INVALID_ROUTING_INFO = 0x44 + DLC_STATUS_ERROR_BASE,
  548. DLC_STATUS_LINK_STATIONS_OPEN = 0x47 + DLC_STATUS_ERROR_BASE,
  549. DLC_STATUS_INCOMPATIBLE_COMMAND_IN_PROGRESS = 0x4A + DLC_STATUS_ERROR_BASE,
  550. DLC_STATUS_CONNECT_FAILED = 0x4D + DLC_STATUS_ERROR_BASE,
  551. DLC_STATUS_INVALID_REMOTE_ADDRESS = 0x4F + DLC_STATUS_ERROR_BASE,
  552. DLC_STATUS_CCB_POINTER_FIELD = 0x50 + DLC_STATUS_ERROR_BASE,
  553. DLC_STATUS_INADEQUATE_LINKS = 0x57 + DLC_STATUS_ERROR_BASE,
  554. DLC_STATUS_INVALID_PARAMETER_1 = 0x58 + DLC_STATUS_ERROR_BASE,
  555. DLC_STATUS_DIRECT_STATIONS_NOT_AVAILABLE = 0x5C + DLC_STATUS_ERROR_BASE,
  556. DLC_STATUS_DEVICE_DRIVER_NOT_INSTALLED = 0x5d + DLC_STATUS_ERROR_BASE,
  557. DLC_STATUS_ADAPTER_NOT_INSTALLED = 0x5e + DLC_STATUS_ERROR_BASE,
  558. DLC_STATUS_CHAINED_DIFFERENT_ADAPTERS = 0x5f + DLC_STATUS_ERROR_BASE,
  559. DLC_STATUS_INIT_COMMAND_STARTED = 0x60 + DLC_STATUS_ERROR_BASE,
  560. DLC_STATUS_CANCELLED_BY_SYSTEM_ACTION = 0x62 + DLC_STATUS_ERROR_BASE,
  561. DLC_STATUS_MEMORY_LOCK_FAILED = 0x69 + DLC_STATUS_ERROR_BASE,
  562. //
  563. // New Nt DLC specific error codes begin from 0x80
  564. // These error codes are for new Windows/Nt DLC apps.
  565. // This far we have tried too much use the OS/2 error codes,
  566. // that results often uninformative return codes.
  567. //
  568. DLC_STATUS_INVALID_BUFFER_ADDRESS = 0x80 + DLC_STATUS_ERROR_BASE,
  569. DLC_STATUS_BUFFER_ALREADY_RELEASED = 0x81 + DLC_STATUS_ERROR_BASE,
  570. DLC_STATUS_INVALID_VERSION = 0xA1 + DLC_STATUS_ERROR_BASE,
  571. DLC_STATUS_INVALID_BUFFER_HANDLE = 0xA2 + DLC_STATUS_ERROR_BASE,
  572. DLC_STATUS_NT_ERROR_STATUS = 0xA3 + DLC_STATUS_ERROR_BASE,
  573. //
  574. // These error codes are just internal for LLC- kernel level interface
  575. // and they are not returned to application level.
  576. //
  577. DLC_STATUS_UNKNOWN_MEDIUM = 0xC0 + DLC_STATUS_ERROR_BASE,
  578. DLC_STATUS_DISCARD_INFO_FIELD = 0xC1 + DLC_STATUS_ERROR_BASE,
  579. DLC_STATUS_NO_ACTION = 0xC2 + DLC_STATUS_ERROR_BASE,
  580. DLC_STATUS_ACCESS_DENIED = 0xC3 + DLC_STATUS_ERROR_BASE,
  581. DLC_STATUS_IGNORE_FRAME = 0xC4 + DLC_STATUS_ERROR_BASE,
  582. DLC_STATUS_WAIT_TIMEOUT = 0xC5 + DLC_STATUS_ERROR_BASE,
  583. DLC_STATUS_NO_RECEIVE_COMMAND = 0xC6 + DLC_STATUS_ERROR_BASE,
  584. DLC_STATUS_FILE_CONTEXT_DELETED = 0xC7 + DLC_STATUS_ERROR_BASE,
  585. DLC_STATUS_EXPAND_BUFFER_POOL = 0xC8 + DLC_STATUS_ERROR_BASE,
  586. DLC_STATUS_INTERNAL_ERROR = 0xC9 + DLC_STATUS_ERROR_BASE,
  587. DLC_STATUS_ASYNC_DATA_TRANSFER_FAILED = 0xCA + DLC_STATUS_ERROR_BASE,
  588. DLC_STATUS_OUT_OF_RCV_BUFFERS = 0xCB + DLC_STATUS_ERROR_BASE,
  589. DLC_STATUS_PENDING = 0xFF + DLC_STATUS_ERROR_BASE,
  590. DLC_STATUS_MAX_ERROR = 0xFF + DLC_STATUS_ERROR_BASE
  591. } DLC_STATUS;
  592. //
  593. // Data link indication handler prototypes.
  594. // The protocols registering to data link driver
  595. // must provide these entry points.
  596. //
  597. typedef
  598. DLC_STATUS
  599. (*PFLLC_RECEIVE_INDICATION)(
  600. IN PVOID hClientContext,
  601. IN PVOID hClientHandle,
  602. IN NDIS_HANDLE MacReceiveContext,
  603. IN USHORT FrameType,
  604. IN PVOID pLookBuf,
  605. IN UINT cbLookBuf
  606. );
  607. typedef
  608. VOID
  609. (*PFLLC_COMMAND_COMPLETE)(
  610. IN PVOID hClientContext,
  611. IN PVOID hClientHandle,
  612. IN PVOID hPacket
  613. );
  614. typedef
  615. VOID
  616. (*PFLLC_EVENT_INDICATION)(
  617. IN PVOID hClientContext,
  618. IN PVOID hClientHandle,
  619. IN UINT uiEvent,
  620. IN PVOID pDlcStatus,
  621. IN ULONG SecondaryInformation
  622. );
  623. UINT
  624. LlcBuildAddressFromLanHeader(
  625. IN NDIS_MEDIUM NdisMedium,
  626. IN PUCHAR pRcvFrameHeader,
  627. IN OUT PUCHAR pLanHeader
  628. );
  629. DLC_STATUS
  630. LlcInitialize(
  631. VOID
  632. );
  633. UINT
  634. LlcBuildAddress(
  635. IN NDIS_MEDIUM NdisMedium,
  636. IN PUCHAR DestinationAddress,
  637. IN PVOID pSrcRouting,
  638. IN OUT PUCHAR pLanHeader
  639. );
  640. USHORT
  641. LlcGetMaxInfoField(
  642. IN NDIS_MEDIUM NdisMedium,
  643. IN PVOID hBinding,
  644. IN PUCHAR pLanHeader
  645. );
  646. DLC_STATUS
  647. LlcQueryInformation(
  648. IN PVOID hObject,
  649. IN UINT InformationType,
  650. IN PLLC_QUERY_INFO_BUFFER pQuery,
  651. IN UINT QueryBufferSize
  652. );
  653. DLC_STATUS
  654. LlcSetInformation(
  655. IN PVOID hObject,
  656. IN UINT InformationType,
  657. IN PLLC_SET_INFO_BUFFER pSetInfo,
  658. IN UINT ParameterBufferSize
  659. );
  660. DLC_STATUS
  661. LlcNdisRequest(
  662. IN PVOID hBindingContext,
  663. IN PLLC_NDIS_REQUEST pDlcParms
  664. );
  665. DLC_STATUS
  666. LlcOpenAdapter(
  667. IN PWSTR pAdapterName,
  668. IN PVOID hClientContext,
  669. IN PFLLC_COMMAND_COMPLETE pfCommandComplete,
  670. IN PFLLC_RECEIVE_INDICATION pfReceiveIndication,
  671. IN PFLLC_EVENT_INDICATION pfEventIndication,
  672. IN NDIS_MEDIUM NdisMedium,
  673. IN LLC_ETHERNET_TYPE EthernetType,
  674. IN UCHAR AdapterNumber,
  675. OUT PVOID *phBindingContext,
  676. OUT PUINT puiOpenStatus,
  677. OUT PUSHORT puiMaxFrameLength,
  678. OUT PNDIS_MEDIUM pActualNdisMedium
  679. );
  680. #define LlcOpenSap(Context, Handle, Sap, Options, phSap) \
  681. LlcOpenStation(Context, Handle, (USHORT)(Sap), LLC_SAP_OBJECT, (USHORT)(Options), phSap)
  682. #define LlcOpenDirectStation(Context, Handle, Sap, phSap) \
  683. LlcOpenStation(Context, Handle, (USHORT)(Sap), LLC_DIRECT_OBJECT, 0, phSap)
  684. #define LlcOpenDixStation(Context, Handle, Sap, phSap) \
  685. LlcOpenStation(Context, Handle, (USHORT)(Sap), LLC_DIX_OBJECT, 0, phSap)
  686. VOID
  687. RemoveFromLinkList(
  688. OUT PVOID* ppBase,
  689. IN PVOID pElement
  690. );
  691. VOID
  692. LlcSleep(
  693. IN LONG lMicroSeconds
  694. );
  695. VOID
  696. LlcTerminate(
  697. VOID
  698. );
  699. VOID
  700. LlcDereferenceObject(
  701. IN PVOID pStation
  702. );
  703. VOID
  704. LlcReferenceObject(
  705. IN PVOID pStation
  706. );
  707. DLC_STATUS
  708. LlcTraceInitialize(
  709. IN PVOID UserTraceBuffer,
  710. IN ULONG UserTraceBufferSize,
  711. IN ULONG TraceFlags
  712. );
  713. VOID
  714. LlcTraceClose(
  715. VOID
  716. );
  717. VOID
  718. LlcTraceWrite(
  719. IN UINT Event,
  720. IN UCHAR AdapterNumber,
  721. IN UINT DataBufferSize,
  722. IN PVOID DataBuffer
  723. );
  724. VOID
  725. LlcTraceDump(
  726. IN UINT LastEvents,
  727. IN UINT AdapterNumber,
  728. IN PUCHAR pRemoteNode
  729. );
  730. VOID
  731. LlcTraceDumpAndReset(
  732. IN UINT LastEvents,
  733. IN UINT AdapterNumber,
  734. IN PUCHAR pRemoteNode
  735. );
  736. #if DBG
  737. typedef struct {
  738. USHORT Input;
  739. USHORT Time;
  740. PVOID pLink;
  741. } LLC_SM_TRACE;
  742. #define LLC_INPUT_TABLE_SIZE 500
  743. extern ULONG AllocatedNonPagedPool;
  744. extern ULONG LockedPageCount;
  745. extern ULONG AllocatedMdlCount;
  746. extern ULONG AllocatedPackets;
  747. extern NDIS_SPIN_LOCK MemCheckLock;
  748. extern ULONG cExAllocatePoolFailed;
  749. extern ULONG FailedMemoryLockings;
  750. VOID PrintMemStatus(VOID);
  751. extern ULONG cFramesReceived;
  752. extern ULONG cFramesIndicated;
  753. extern ULONG cFramesReleased;
  754. extern ULONG cLockedXmitBuffers;
  755. extern ULONG cUnlockedXmitBuffers;
  756. extern LLC_SM_TRACE aLast[];
  757. extern UINT InputIndex;
  758. #endif
  759. //
  760. // The inline memcpy and memset functions are faster,
  761. // in x386 than RtlMoveMemory
  762. //
  763. #if defined(i386)
  764. #define LlcMemCpy(Dest, Src, Len) memcpy(Dest, Src, Len)
  765. #define LlcZeroMem(Ptr, Len) memset(Ptr, 0, Len)
  766. #else
  767. #define LlcMemCpy(Dest, Src, Len) RtlMoveMemory(Dest, Src, Len)
  768. #define LlcZeroMem(Ptr, Len) RtlZeroMemory(Ptr, Len)
  769. #endif
  770. //
  771. //
  772. // PVOID
  773. // PopEntryList(
  774. // IN PQUEUE_PACKET ListHead,
  775. // );
  776. //
  777. #define PopFromList(ListHead) \
  778. (PVOID)(ListHead); \
  779. (ListHead) = (PVOID)(ListHead)->pNext;
  780. //
  781. // VOID
  782. // PushToList(
  783. // IN PQUEUE_PACKET ListHead,
  784. // IN PQUEUE_PACKET Entry
  785. // );
  786. //
  787. #define PushToList(ListHead,Entry) { \
  788. (Entry)->pNext = (PVOID)(ListHead); \
  789. (ListHead) = (Entry); \
  790. }
  791. //
  792. // About 30% of all bugs are related with the invalid operations with
  793. // packets. A packet may be inserted to another list before it
  794. // has been removed from the previous one, etc.
  795. // The debug version of the list macroes reset the next pointer
  796. // every time it is removed from the list and check it when it is
  797. // inserted to a new list or released to a packet pool. The packet
  798. // alloc will reset the next pointer automatically.
  799. // Problem: the packets are used for many other purposes as well =>
  800. // we must do quite a lot conditional code.
  801. //
  802. #if LLC_DBG
  803. #if LLC_DBG_MP
  804. #define DBG_INTERLOCKED_INCREMENT(Count) \
  805. InterlockedIncrement( \
  806. (PLONG)&(Count) \
  807. )
  808. #define DBG_INTERLOCKED_DECREMENT(Count) \
  809. InterlockedDecrement( \
  810. (PLONG)&(Count) \
  811. )
  812. #define DBG_INTERLOCKED_ADD(Added, Value) \
  813. ExInterlockedAddUlong( \
  814. (PULONG)&(Added), \
  815. (ULONG)(Value), \
  816. &MemCheckLock.SpinLock \
  817. )
  818. #else
  819. #define DBG_INTERLOCKED_INCREMENT(Count) (Count)++
  820. #define DBG_INTERLOCKED_DECREMENT(Count) (Count)--
  821. #define DBG_INTERLOCKED_ADD(Added, Value) (Added) += (Value)
  822. #endif // LLC_DBG_MP
  823. #else
  824. #define DBG_INTERLOCKED_INCREMENT(Count)
  825. #define DBG_INTERLOCKED_DECREMENT(Count)
  826. #define DBG_INTERLOCKED_ADD(Added, Value)
  827. #endif // LLC_DBG
  828. #if LLC_DBG
  829. VOID LlcBreakListCorrupt( VOID );
  830. #define LlcRemoveHeadList(ListHead) \
  831. (PVOID)(ListHead)->Flink; \
  832. { \
  833. PLIST_ENTRY FirstEntry; \
  834. FirstEntry = (ListHead)->Flink; \
  835. FirstEntry->Flink->Blink = (ListHead); \
  836. (ListHead)->Flink = FirstEntry->Flink; \
  837. FirstEntry->Flink = NULL; \
  838. }
  839. #define LlcRemoveTailList(ListHead) \
  840. (ListHead)->Blink; \
  841. { \
  842. PLIST_ENTRY FirstEntry; \
  843. FirstEntry = (ListHead)->Blink; \
  844. FirstEntry->Blink->Flink = (ListHead); \
  845. (ListHead)->Blink = FirstEntry->Blink; \
  846. FirstEntry->Flink = NULL; \
  847. }
  848. #define LlcRemoveEntryList(Entry) \
  849. { \
  850. RemoveEntryList((PLIST_ENTRY)Entry); \
  851. ((PLIST_ENTRY)(Entry))->Flink = NULL; \
  852. }
  853. #define LlcInsertTailList(ListHead,Entry) \
  854. if (((PLIST_ENTRY)(Entry))->Flink != NULL){ \
  855. LlcBreakListCorrupt(); \
  856. } \
  857. InsertTailList(ListHead, (PLIST_ENTRY)Entry)
  858. #define LlcInsertHeadList(ListHead,Entry) \
  859. if (((PLIST_ENTRY)(Entry))->Flink != NULL) { \
  860. LlcBreakListCorrupt(); \
  861. } \
  862. InsertHeadList(ListHead,(PLIST_ENTRY)Entry)
  863. /*
  864. #define DeallocatePacket( PoolHandle, pBlock ) { \
  865. if (((PLIST_ENTRY)pBlock)->Flink != NULL) { \
  866. LlcBreakListCorrupt(); \
  867. } \
  868. DBG_INTERLOCKED_DECREMENT( AllocatedPackets ); \
  869. ExFreeToZone( \
  870. &(((PEXTENDED_ZONE_HEADER)PoolHandle)->Zone), \
  871. pBlock); \
  872. }
  873. */
  874. #else
  875. //
  876. // PVOID
  877. // LlcRemoveHeadList(
  878. // IN PLIST_ENTRY ListHead
  879. // );
  880. //
  881. #define LlcRemoveHeadList(ListHead) (PVOID)RemoveHeadList(ListHead)
  882. //
  883. // PLIST_ENTRY
  884. // LlcRemoveTailList(
  885. // IN PLIST_ENTRY ListHead
  886. // );
  887. //
  888. #define LlcRemoveTailList(ListHead) \
  889. (ListHead)->Blink; { \
  890. PLIST_ENTRY FirstEntry; \
  891. FirstEntry = (ListHead)->Blink; \
  892. FirstEntry->Blink->Flink = (ListHead); \
  893. (ListHead)->Blink = FirstEntry->Blink; \
  894. }
  895. //
  896. // VOID
  897. // LlcRemoveEntryList(
  898. // IN PVOID Entry
  899. // );
  900. //
  901. #define LlcRemoveEntryList(Entry) RemoveEntryList((PLIST_ENTRY)Entry)
  902. //
  903. // VOID
  904. // LlcInsertTailList(
  905. // IN PLIST_ENTRY ListHead,
  906. // IN PVOID Entry
  907. // );
  908. //
  909. #define LlcInsertTailList(ListHead,Entry) \
  910. InsertTailList(ListHead, (PLIST_ENTRY)Entry)
  911. //
  912. // VOID
  913. // LlcInsertHeadList(
  914. // IN PLIST_ENTRY ListHead,
  915. // IN PVOID Entry
  916. // );
  917. //
  918. #define LlcInsertHeadList(ListHead,Entry) \
  919. InsertHeadList(ListHead,(PLIST_ENTRY)Entry)
  920. //
  921. // VOID
  922. // DeallocatePacket(
  923. // PEXTENDED_ZONE_HEADER PoolHandle,
  924. // PVOID pBlock
  925. // );
  926. //
  927. /*
  928. #define DeallocatePacket( PoolHandle, pBlock ) { \
  929. ExFreeToZone( &(((PEXTENDED_ZONE_HEADER)PoolHandle)->Zone), \
  930. pBlock); \
  931. }
  932. */
  933. #endif // DBG
  934. #if LLC_DBG == 2
  935. VOID LlcMemCheck(VOID);
  936. #define MEM_CHECK() LlcMemCheck()
  937. #else
  938. #define MEM_CHECK()
  939. #endif
  940. VOID LlcInvalidObjectType(VOID);
  941. /*++
  942. Trace codes
  943. Big letters are reserved for actions, small letters are used to identify
  944. objects and packet types. The trace macroes simply writes to DLC
  945. trace tree (remember: we have another trace for the state machine!!!)
  946. 'a' = dix stations
  947. 'b' = direct station
  948. 'c' = link station
  949. 'd' = sap station
  950. 'e' = Connect command
  951. 'f' = Close command
  952. 'g' = Disconnect command
  953. 'h' = Receive command
  954. 'i' = transmit command
  955. 'j' = Type1 packet
  956. 'k' = type 2 packet
  957. 'l' = data link packet
  958. 'A' = CompleteSendAndLock
  959. 'B' = LlcCommandCompletion
  960. 'C' = LlcCloseStation
  961. 'D' = LlcReceiveIndication
  962. 'E' = LlcEventIndication
  963. 'F' = DlcDeviceIoControl
  964. 'G' = DlcDeviceIoControl sync exit
  965. 'H' = DlcDeviceIoControl async exit
  966. 'I' = LlcSendI
  967. 'J' = DirCloseAdapter
  968. 'K' = CompleteDirCloseAdapter
  969. 'L' = LlcDereferenceObject
  970. 'M' = LlcReferenceObject
  971. 'N' = CompleteCloseStation (final)
  972. 'O' = DereferenceLlcObject (in dlc)
  973. 'P' = CompleteLlcObjectClose (final)
  974. 'Q' = DlcReadCancel
  975. 'R' =
  976. 'S' =
  977. 'T' = DlcTransmit
  978. 'U' = LlcSendU
  979. 'V' =
  980. 'W' =
  981. 'X' =
  982. 'Y' =
  983. 'Z' =
  984. --*/
  985. #if DBG & DLC_TRACE_ENABLED
  986. #define LLC_TRACE_TABLE_SIZE 0x400 // this must be exponent of 2!
  987. extern UINT LlcTraceIndex;
  988. extern UCHAR LlcTraceTable[];
  989. #define DLC_TRACE(a) {\
  990. LlcTraceTable[LlcTraceIndex] = (a);\
  991. LlcTraceIndex = (LlcTraceIndex + 1) & (LLC_TRACE_TABLE_SIZE - 1);\
  992. }
  993. #else
  994. #define DLC_TRACE(a)
  995. #endif // LLC_DBG
  996. //
  997. // the following functions can be macros if DLC and LLC live in the same driver
  998. // and each knows about the other's structures
  999. //
  1000. #if DLC_AND_LLC
  1001. //
  1002. // UINT
  1003. // LlcGetReceivedLanHeaderLength(
  1004. // IN PVOID pBinding
  1005. // );
  1006. //
  1007. #if 0
  1008. //
  1009. // this gives the wrong length for DIX lan header
  1010. //
  1011. #define LlcGetReceivedLanHeaderLength(pBinding) \
  1012. ((((PBINDING_CONTEXT)(pBinding))->pAdapterContext->NdisMedium == NdisMedium802_3) \
  1013. ? (((PBINDING_CONTEXT)(pBinding))->pAdapterContext->FrameType == LLC_DIRECT_ETHERNET_TYPE) \
  1014. ? 12 \
  1015. : 14 \
  1016. : (((PBINDING_CONTEXT)(pBinding))->pAdapterContext->NdisMedium == NdisMediumFddi) \
  1017. ? 14 \
  1018. : ((PBINDING_CONTEXT)(pBinding))->pAdapterContext->RcvLanHeaderLength)
  1019. #else
  1020. //
  1021. // this always returns 14 as the DIX lan header length
  1022. //
  1023. #define LlcGetReceivedLanHeaderLength(pBinding) \
  1024. ((((PBINDING_CONTEXT)(pBinding))->pAdapterContext->NdisMedium == NdisMedium802_3) \
  1025. ? 14 \
  1026. : (((PBINDING_CONTEXT)(pBinding))->pAdapterContext->NdisMedium == NdisMediumFddi) \
  1027. ? 14 \
  1028. : ((PBINDING_CONTEXT)(pBinding))->pAdapterContext->RcvLanHeaderLength)
  1029. #endif
  1030. //
  1031. // USHORT
  1032. // LlcGetEthernetType(
  1033. // IN PVOID hContext
  1034. // );
  1035. //
  1036. #define LlcGetEthernetType(hContext) \
  1037. (((PBINDING_CONTEXT)(hContext))->pAdapterContext->EthernetType)
  1038. //
  1039. // UINT
  1040. // LlcGetCommittedSpace(
  1041. // IN PVOID hLink
  1042. // );
  1043. //
  1044. #define LlcGetCommittedSpace(hLink) \
  1045. (((PDATA_LINK)(hLink))->BufferCommitment)
  1046. #else
  1047. //
  1048. // separation of church and state, or DLC and LLC even
  1049. //
  1050. UINT
  1051. LlcGetReceivedLanHeaderLength(
  1052. IN PVOID pBinding
  1053. );
  1054. USHORT
  1055. LlcGetEthernetType(
  1056. IN PVOID hContext
  1057. );
  1058. UINT
  1059. LlcGetCommittedSpace(
  1060. IN PVOID hLink
  1061. );
  1062. #endif // DLC_AND_LLC
  1063. #endif // _LLC_API_
  1064.