summaryrefslogtreecommitdiffstats
path: root/private/ntos/ndis/testprot/tpdrvr/media.h
blob: 8bc1e567784dfed14f49a6f77d4cd29ee4b14df7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*++

Copyright (c) 1990  Microsoft Corporation

Module Name:

    media.h

Abstract:

    Functions used to determine information about a specific MAC, it's
    packet size, and other media specifici information.

Author:

    Tom Adams (tomad) 14-Jul-1990

Environment:

    Kernel mode, FSD

Revision History:

    Tom Adams (tomad) 03-Jan-1991 Changed to support all MAC types.

    SanjeevK (sanjeevk) 04-06-1993
        1. Added Arcnet support

--*/

//
// Medium array is used during NdisOpenAdapter to determine the
// media being supported by the card.
//
#define   NDIS_MEDIUM_ARRAY_SIZE     5

extern    NDIS_MEDIUM NdisMediumArray[NDIS_MEDIUM_ARRAY_SIZE];

//
// Media Specific Information used to describe the form of a packet and
// the device being used in this instance.
//
// The Media of interest are
//
//    802.3
//    802.5 (TokenRing)
//    FDDI
//    ARCNET
//
// No special differentiation will be made between 802.3 and DIX
//

typedef struct _TP_MEDIA_INFO {
    NDIS_MEDIUM MediumType;         // MAC type being used
    USHORT      HeaderSize;         // Packet Header size if (exists)
    USHORT      Padding;            // Pad to align TP_PACKET_HEADER
    USHORT      AddressLen;         // Address length for the Media
    USHORT      SrcAddrOffset;
    USHORT      DestAddrOffset;
    ULONG       MaxPacketLen;       // Maximum packet length for Media
} TP_MEDIA_INFO, *PTP_MEDIA_INFO;

//
// Ethernet Specific Information
//
// The Ethernet Packet Header is constructed as follows:
//
// +------------------------------------------+
// |  Dest  |  Src   | Sz |       Data        |
// +------------------------------------------+
//
// The Src and Dest fields represent the source and destination addresses
// and are 6 bytes long each, the Sz field represents represents the size
// of the Data, and finally there is the Data area itself.
//

#define ETHERNET_ADDRESS_LEN            6

#define ETHERNET_SRC_ADDRESS_OFFSET     ETHERNET_ADDRESS_LEN

#define ETHERNET_DEST_ADDRESS_OFFSET    0

#define ETHERNET_DATASIZE_LEN           2

#define ETHERNET_DATA_LEN               1500

#define ETHERNET_HEADER_SIZE            (( ETHERNET_ADDRESS_LEN * 2 ) + \
                                           ETHERNET_DATASIZE_LEN )

#define ETHERNET_PACKET_SIZE            ( ETHERNET_HEADER_SIZE + \
                                          ETHERNET_DATA_LEN )

#define ETHERNET_MIN_DATA_LEN           46

#define ETHERNET_MIN_PACKET_SIZE        ( ETHERNET_HEADER_SIZE + \
                                          ETHERNET_MIN_DATA_LEN )

#define ETHERNET_PADDING                2

//
// Default Adapter name to be input from Configuration Manager
//
//#define ETHERNET_ADAPTER_NAME    "\\device\\elnkii"

//
// TokenRing Specific Information
//
//
// The Token Ring Packet Header is constructed as follows:
//
// +---------------------------------------------------+
// | AC | FC |   Dest   |   Src    |       Data        |
// +---------------------------------------------------+
//
// The AC and FC fields are used to store tokenring information, each is
// one byte long.  The Src and Dest fields represent the source and
// destination addresses and are 6 bytes long each, and finally there
// is the Data area itself.
//

#define TOKENRING_ACFC_SIZE             2

#define TOKENRING_ADDRESS_LEN           6

#define TOKENRING_SRC_ADDRESS_OFFSET    ( TOKENRING_ADDRESS_LEN + \
                                          TOKENRING_ACFC_SIZE )

#define TOKENRING_DEST_ADDRESS_OFFSET   TOKENRING_ACFC_SIZE

#define TOKENRING_HEADER_SIZE           (( TOKENRING_ADDRESS_LEN * 2) + \
                                           TOKENRING_ACFC_SIZE )

#define TOKENRING_DATA_LEN              ( 8192 - TOKENRING_HEADER_SIZE )
// 17K if 16MB or 8K if 4MB

#define TOKENRING_PACKET_SIZE           ( TOKENRING_HEADER_SIZE + \
                                          TOKENRING_DATA_LEN )

#define TOKENRING_PADDING               2

//
// FDDI Specific Information
//
//
// The FDDI Packet Header is constructed as follows:
//
// +----------------------------------------------+
// | XX |   Dest   |   Src    |       Data        |
// +----------------------------------------------+
//
// The XX field is used to store fddi information, it is one byte
// long.  The Src and Dest fields represent the source and destination
// addresses and are 6 bytes long each, and finally there is the
// Data area itself.
//

#define FDDI_XX_SIZE                1

#define FDDI_ADDRESS_LEN            6

#define FDDI_SRC_ADDRESS_OFFSET     ( FDDI_ADDRESS_LEN + FDDI_XX_SIZE )

#define FDDI_DEST_ADDRESS_OFFSET    FDDI_XX_SIZE

#define FDDI_HEADER_SIZE            (( FDDI_ADDRESS_LEN * 2) + FDDI_XX_SIZE )

#define FDDI_DATA_LEN               8192   // 17K if 16MB or 8K if 4MB

#define FDDI_PACKET_SIZE            ( FDDI_HEADER_SIZE + FDDI_DATA_LEN )

#define FDDI_PADDING                2



//
// STARTCHANGE
//

//
// ARCNET Specific Information
//
//
// The ARCNET Software Packet Header is constructed as follows:
//
// +----------------------------------------------------------+
// | Source | Destination | ProtocolID |         Data         |
// +----------------------------------------------------------+
//      1          1            1        0 - 120*504 or 60480
//
// CURRENT ARCNET SOFTWARE HEADER
//
// The ARCNET Software Packet Header is constructed as follows:
//
// +----------------------------------------------------------+
// | Source | Destination | ProtocolID |         Data         |
// +----------------------------------------------------------+
//      1          1            1        0 - 3*504 or 1512
//
//
// The Src and Dest fields represent the source and destination
// addresses and are 1 byte long each. The ProtocolID represent
// the ID of the protocol communicating with the Arcnet MAC driver
// And finally there is Data area itself.
//
// An actual Arcnet Software packet looks like the following. The current provisions
// for the native ARCNET driver will be responsible for handling these type internally
// thereby providing ease of packet exchange between the MAC(N) and the layer above the MAC(N+1)
//
// SHORT PACKET     (Octet)
//                  +---+
// Source           | 1 |
//                  +---+
// Destination      | 1 |
//                  +---+
// ByteOffset       | 1 |
//                  +---------+
// Unused           | 0 - 249 |         PACKET CONSTANT LENGTH  = 256 octets
//                  +---------+         MAXIMUM # of FRAGEMENTS = 120
// ProcolID         | 1 |
//                  +---+
// Split Flag       | 1 |
//                  +---+---+
// Seqence #        |   2   |
//                  +----------+
// Data             | 0 - 249  |
//                  +----------+
//
// EXCEPTION PACKET (Octet)
//                  +---+
// Source           | 1 |
//                  +---+
// Destination      | 1 |
//                  +---+
// Long Packet Flag | 1 | = 0
//                  +---+
// ByteOffset       | 1 |
//                  +-----------+
// Unused           | 248 - 250 |       PACKET CONSTANT LENGTH  = 512 octets
//                  +-----------+       MAXIMUM # of FRAGEMENTS = 120
// Pad1 ProcolID    | 1 |
//                  +---+
// Pad2 Split Flag  | 1 | = FF
//                  +---+
// Pad3             | 1 |
//                  +---+
// Pad4             | 1 |
//                  +---+
// ProcolID         | 1 |
//                  +---+
// Split Flag       | 1 |
//                  +---+---+
// Seqence #        |   2   |
//                  +-----------+
// Data             | 250 - 252 |
//                  +-----------+
//
//
// LONG PACKET      (Octet)
//                  +---+
// Source           | 1 |
//                  +---+
// Destination      | 1 |
//                  +---+
// Long Packet Flag | 1 | = 0
//                  +---+
// ByteOffset       | 1 |
//                  +---------+
// Unused           | 0 - 251 |         PACKET CONSTANT LENGTH  = 512 octets
//                  +---------+         MAXIMUM # of FRAGEMENTS = 120
// ProcolID         | 1 |
//                  +---+
// Split Flag       | 1 |
//                  +---+---+
// Seqence #        |   2   |
//                  +-----------+
// Data             | 253 - 504 |
//                  +-----------+
//
// The software packet is further broken down into 5 different categories on the wire
// The frame formats are:
//
//   INVITATION TO TRANSMIT (ASCII EOT)
//   FREE BUFFER ENQUIRY    (ASCII ENQ)
//   PACKET-DATA            (ASCII SOH)
//   ACK                    (ASCII ACK)
//   NACK                   (ASCII NAK)
// The Destination octet is duplicated on the wire, the unused data buffer is not transmitted
// and a 2 octect CRC is generated with the PACKET-DATA format.
//

#define ARCNET_ADDRESS_LEN          1

#define ARCNET_SRC_ADDRESS_OFFSET   0

#define ARCNET_DEST_ADDRESS_OFFSET  ARCNET_ADDRESS_LEN

#define ARCNET_PROTID_OFFSET        ARCNET_DEST_ADDRESS_OFFSET + ARCNET_ADDRESS_LEN

#define ARCNET_PROTID_LEN           1

#define ARCNET_HEADER_SIZE          (( ARCNET_ADDRESS_LEN * 2) + ARCNET_PROTID_LEN )

#define ARCNET_DATA_LEN             1512

#define ARCNET_PACKET_SIZE          ( ARCNET_HEADER_SIZE + ARCNET_DATA_LEN )

#define ARCNET_MIN_DATA_LEN         0

#define ARCNET_MIN_PACKET_SIZE      ( ARCNET_HEADER_SIZE + ARCNET_MIN_DATA_LEN )

#define ARCNET_PADDING              0

//
// STOPCHANGE
//


//
// Media Initialization routine.
//

NDIS_STATUS
TpInitMedia(
    POPEN_BLOCK OpenP,
    ULONG FrameSize
    );

BOOLEAN
TpInitMediaHeader(
    PFUNC1_PACKET  F1Packet,
    PTP_MEDIA_INFO Media,
    PUCHAR         DestAddr,
    PUCHAR         SrcAddr,
    INT            PacketSize
    );

VOID
TpInitPoolMediaHeader(
    PFUNC1_PACKET  F1Packet,
    PTP_MEDIA_INFO Media,
    PUCHAR         DestAddr
    );

VOID
TpInitTruncatedMediaHeader(
    PFUNC1_PACKET  F1Packet,
    PTP_MEDIA_INFO Media,
    PUCHAR         DestAddr,
    INT            PacketSize
    );