1 /* CTCADPT.H (c) Copyright James A. Pierson, 2002-2012 */
2 /* (c) Copyright Roger Bowler, 2000-2012 */
3 /* (c) Copyright Willem Konynenberg, 2000-2009 */
4 /* (c) Copyright Vic Cross, 2001-2009 */
5 /* (c) Copyright David B. Trout, 2002-2009 */
6 /* Hercules Channel-to-Channel Emulation Support */
7
8 #ifndef __CTCADPT_H_
9 #define __CTCADPT_H_
10
11 // --------------------------------------------------------------------
12 // Pack all structures to byte boundary...
13 // --------------------------------------------------------------------
14
15 #undef ATTRIBUTE_PACKED
16 #if defined(_MSVC_)
17 #pragma pack(push)
18 #pragma pack(1)
19 #define ATTRIBUTE_PACKED
20 #else
21 #define ATTRIBUTE_PACKED __attribute__((packed))
22 #endif
23
24 // --------------------------------------------------------------------
25 // Definitions for 3088 model numbers
26 // --------------------------------------------------------------------
27
28 #define CTC_3088_01 0x308801 // 3172 XCA
29 #define CTC_3088_04 0x308804 // 3088 model 1 CTCA
30 #define CTC_3088_08 0x308808 // 3088 model 2 CTCA
31 #define CTC_3088_1F 0x30881F // 3172 LCS
32 #define CTC_3088_60 0x308860 // OSA or 8232 LCS
33 #define CTC_3088_61 0x308861 // CLAW device
34
35 // --------------------------------------------------------------------
36 // Media Access Control address (MAC address)
37 // --------------------------------------------------------------------
38
39 #ifndef IFHWADDRLEN // (only predefined on Linux)
40 #define IFHWADDRLEN 6 // Ethernet MAC address length
41 #endif
42
43 typedef uint8_t MAC[ IFHWADDRLEN ]; // Data Type for MAC Addresses
44
45 // --------------------------------------------------------------------
46 // External Declarations
47 // --------------------------------------------------------------------
48
49 extern int CTCX_Init( DEVBLK* pDEVBLK, int argc, char *argv[] );
50 extern int CTCX_Close( DEVBLK* pDEVBLK );
51 extern void CTCX_Query( DEVBLK* pDEVBLK, char** ppszClass,
52 int iBufLen, char* pBuffer );
53 extern void CTCX_ExecuteCCW( DEVBLK* pDEVBLK, BYTE bCode,
54 BYTE bFlags, BYTE bChained,
55 U16 sCount, BYTE bPrevCode,
56 int iCCWSeq, BYTE* pIOBuf,
57 BYTE* pMore, BYTE* pUnitStat,
58 U16* pResidual );
59
60 extern int CTCI_Init( DEVBLK* pDEVBLK, int argc, char *argv[] );
61 extern int CTCI_Close( DEVBLK* pDEVBLK );
62 extern void CTCI_Query( DEVBLK* pDEVBLK, char** ppszClass,
63 int iBufLen, char* pBuffer );
64 extern void CTCI_ExecuteCCW( DEVBLK* pDEVBLK, BYTE bCode,
65 BYTE bFlags, BYTE bChained,
66 U16 sCount, BYTE bPrevCode,
67 int iCCWSeq, BYTE* pIOBuf,
68 BYTE* pMore, BYTE* pUnitStat,
69 U16* pResidual );
70
71 extern void CTCI_Read( DEVBLK* pDEVBLK, U16 sCount,
72 BYTE* pIOBuf, BYTE* UnitStat,
73 U16* pResidual, BYTE* pMore );
74 extern void CTCI_Write( DEVBLK* pDEVBLK, U16 sCount,
75 BYTE* pIOBuf, BYTE* UnitStat,
76 U16* pResidual );
77
78 extern int LCS_Init( DEVBLK* pDEVBLK, int argc, char *argv[] );
79 extern int LCS_Close( DEVBLK* pDEVBLK );
80 extern void LCS_Query( DEVBLK* pDEVBLK, char** ppszClass,
81 int iBufLen, char* pBuffer );
82 extern void LCS_ExecuteCCW( DEVBLK* pDEVBLK, BYTE bCode,
83 BYTE bFlags, BYTE bChained,
84 U16 sCount, BYTE bPrevCode,
85 int iCCWSeq, BYTE* pIOBuf,
86 BYTE* pMore, BYTE* pUnitStat,
87 U16* pResidual );
88
89 extern void LCS_Read( DEVBLK* pDEVBLK, U16 sCount,
90 BYTE* pIOBuf, BYTE* UnitStat,
91 U16* pResidual, BYTE* pMore );
92 extern void LCS_Write( DEVBLK* pDEVBLK, U16 sCount,
93 BYTE* pIOBuf, BYTE* UnitStat,
94 U16* pResidual );
95 extern void LCS_SDC( DEVBLK* pDEVBLK, BYTE bOpCode,
96 U16 sCount, BYTE* pIOBuf,
97 BYTE* UnitStat, U16* pResidual,
98 BYTE* pMore );
99
100 extern int ParseMAC( char* pszMACAddr, BYTE* pbMACAddr );
101 extern void packet_trace( BYTE *addr, int len );
102
103
104
105 /**********************************************************************\
106 **********************************************************************
107 ** **
108 ** STANDARD ETHERNET FRAMES LAYOUT **
109 ** **
110 **********************************************************************
111 \**********************************************************************/
112
113
114 // --------------------------------------------------------------------
115 // Ethernet Frame Header (network byte order)
116 // --------------------------------------------------------------------
117
118 struct _ETHFRM
119 {
120 MAC bDestMAC; // 0x00
121 MAC bSrcMAC; // 0x06
122 HWORD hwEthernetType; // 0x0C (see below #defines)
123 BYTE bData[FLEXIBLE_ARRAY]; // 0x0E
124 } ATTRIBUTE_PACKED;
125
126
127 typedef struct _ETHFRM ETHFRM, *PETHFRM;
128
129
130 #define ETH_TYPE_IP 0x0800
131 #define ETH_TYPE_ARP 0x0806
132 #define ETH_TYPE_RARP 0x0835
133 #define ETH_TYPE_SNA 0x80D5
134
135
136 // --------------------------------------------------------------------
137 // IP Version 4 Frame Header (Type 0x0800) (network byte order)
138 // --------------------------------------------------------------------
139
140 struct _IP4FRM
141 {
142 BYTE bVersIHL; // 0x00 Vers:4, IHL:4
143 BYTE bTOS; // 0x01
144 HWORD hwTotalLength; // 0x02
145 HWORD hwIdentification; // 0x04
146 U16 bFlagsFragOffset; // 0x06 Flags:3, FragOffset:13
147 BYTE bTTL; // 0x08
148 BYTE bProtocol; // 0x09
149 HWORD hwChecksum; // 0x0A
150 U32 lSrcIP; // 0x0C
151 U32 lDstIP; // 0x10
152 BYTE bData[FLEXIBLE_ARRAY]; // 0x14
153 } ATTRIBUTE_PACKED;
154
155
156 typedef struct _IP4FRM IP4FRM, *PIP4FRM;
157
158
159 // --------------------------------------------------------------------
160 // Address Resolution Protocol Frame (Type 0x0806) (network byte order)
161 // --------------------------------------------------------------------
162
163 struct _ARPFRM
164 {
165 HWORD hwHardwareType; // 0x00
166 HWORD hwProtocolType; // 0x02
167 BYTE bHardwareSize; // 0x04
168 BYTE bProtocolSize; // 0x05
169 HWORD hwOperation; // 0x06
170 MAC bSendEthAddr; // 0x08
171 U32 lSendIPAddr; // 0x12
172 MAC bTargEthAddr; // 0x16
173 U32 lTargIPAddr; // 0x1C
174 } ATTRIBUTE_PACKED;
175
176
177 typedef struct _ARPFRM ARPFRM, *PARPFRM;
178
179
180 #define ARP_REQUEST 0x01
181 #define ARP_REPLY 0x02
182 #define RARP_REQUEST 0x03
183 #define RARP_REPLY 0x04
184
185
186
187 /**********************************************************************\
188 **********************************************************************
189 ** **
190 ** CTCI DEVICE CONTROL BLOCKS **
191 ** **
192 **********************************************************************
193 \**********************************************************************/
194
195
196 #define MAX_CTCI_FRAME_SIZE( pCTCBLK ) \
197 ( \
198 pCTCBLK->iMaxFrameBufferSize /* (whatever CTCI_Init defined) */ \
199 - sizeof( CTCIHDR ) \
200 - sizeof( CTCISEG ) \
201 - sizeof_member(CTCIHDR,hwOffset) \
202 )
203
204
205 #define MAX_LCS_ETH_FRAME_SIZE( pLCSDEV ) \
206 ( \
207 pLCSDEV->iMaxFrameBufferSize /* (whatever LCS_Startup defined) */ \
208 - sizeof( LCSETHFRM ) \
209 - sizeof_member(LCSHDR,hwOffset) \
210 )
211
212 // PROGRAMMING NOTE: the following frame buffer size should always be
213 // no smaller than the maximum frame buffer size possible for an LCS
214 // device (currently hard-coded in S390 Linux to be 0x5000 via the
215 // #define LCS_IOBUFFERSIZE). Also note that the minimum and maximum
216 // frame buffer size, according to IBM documentation, is 16K to 64K.
217
218 #define CTC_FRAME_BUFFER_SIZE (0x5000) // 20K CTCI/LCS frame buffer
219
220 #define CTC_MIN_FRAME_BUFFER_SIZE (0x4000) // Minimum frame buffer size
221 #define CTC_MAX_FRAME_BUFFER_SIZE (0xFFFF) // Maximum frame buffer size
222
223 #define CTC_READ_TIMEOUT_SECS (5) // five seconds
224
225 #define CTC_DELAY_USECS (100) // 100 microseconds delay; used
226 // mostly by enqueue frame buffer
227 // full delay loop...
228
229 struct _CTCBLK;
230 struct _CTCIHDR;
231 struct _CTCISEG;
232
233 typedef struct _CTCBLK CTCBLK, *PCTCBLK;
234 typedef struct _CTCIHDR CTCIHDR,*PCTCIHDR;
235 typedef struct _CTCISEG CTCISEG,*PCTCISEG;
236
237
238 // --------------------------------------------------------------------
239 // CTCBLK - (host byte order)
240 // --------------------------------------------------------------------
241
242 struct _CTCBLK
243 {
244 int fd; // TUN/TAP fd
245 TID tid; // Read Thread ID
246 pid_t pid; // Read Thread pid
247
248 DEVBLK* pDEVBLK[2]; // 0 - Read subchannel
249 // 1 - Write subchannel
250
251 U16 iMaxFrameBufferSize; // Device Buffer Size
252 BYTE bFrameBuffer[CTC_FRAME_BUFFER_SIZE]; // (this really SHOULD be dynamically allocated!)
253 U16 iFrameOffset; // Curr Offset into Buffer
254 U16 sMTU; // Max MTU
255
256 LOCK Lock; // Data LOCK
257 LOCK EventLock; // Condition LOCK
258 COND Event; // Condition signal
259
260 u_int fDebug:1; // Debugging
261 u_int fOldFormat:1; // Old Config Format
262 u_int fCreated:1; // Interface Created
263 u_int fStarted:1; // Startup Received
264 u_int fDataPending:1; // Data is pending for
265 // read device
266 u_int fCloseInProgress:1; // Close in progress
267
268 int iKernBuff; // Kernel buffer in K bytes.
269 int iIOBuff; // I/O buffer in K bytes.
270 char szGuestIPAddr[32]; // IP Address (Guest OS)
271 char szDriveIPAddr[32]; // IP Address (Driver)
272 char szNetMask[32]; // Netmask for P2P link
273 char szMTU[32];
274 char szTUNCharName[256]; // TUN/TAP char filename
275 char szTUNDevName[IFNAMSIZ]; // Network Device Name
276 char szMACAddress[32]; // MAC Address
277 };
278
279
280
281 /**********************************************************************\
282 **********************************************************************
283 ** **
284 ** CTCI DEVICE FRAMES **
285 ** **
286 **********************************************************************
287 \**********************************************************************/
288
289
290 // --------------------------------------------------------------------
291 // CTCI Block Header (host byte order)
292 // --------------------------------------------------------------------
293
294 struct _CTCIHDR // CTCI Block Header
295 {
296 HWORD hwOffset; // Offset of next block
297 BYTE bData[FLEXIBLE_ARRAY]; // start of data (CTCISEG)
298 } ATTRIBUTE_PACKED;
299
300
301 // --------------------------------------------------------------------
302 // CTCI Segment Header (host byte order)
303 // --------------------------------------------------------------------
304
305 struct _CTCISEG // CTCI Segment Header
306 {
307 HWORD hwLength; // Segment length including
308 // this header
309 HWORD hwType; // Ethernet packet type
310 HWORD _reserved; // Unused, set to zeroes
311 BYTE bData[FLEXIBLE_ARRAY]; // Start of data (IP pakcet)
312 } ATTRIBUTE_PACKED;
313
314
315
316 /**********************************************************************\
317 **********************************************************************
318 ** **
319 ** LCS DEVICE CONTROL BLOCKS **
320 ** **
321 **********************************************************************
322 \**********************************************************************/
323
324
325 #define LCS_MAX_PORTS 4
326
327
328 struct _LCSBLK;
329 struct _LCSDEV;
330 struct _LCSPORT;
331 struct _LCSRTE;
332 struct _LCSHDR;
333 struct _LCSCMDHDR;
334 struct _LCSSTDFRM;
335 struct _LCSSTRTFRM;
336 struct _LCSQIPFRM;
337 struct _LCSLSTFRM;
338 struct _LCSIPMPAIR;
339 struct _LCSIPMFRM;
340 struct _LCSETHFRM;
341
342
343 typedef struct _LCSBLK LCSBLK, *PLCSBLK;
344 typedef struct _LCSDEV LCSDEV, *PLCSDEV;
345 typedef struct _LCSPORT LCSPORT, *PLCSPORT;
346 typedef struct _LCSRTE LCSRTE, *PLCSRTE;
347 typedef struct _LCSHDR LCSHDR, *PLCSHDR;
348 typedef struct _LCSCMDHDR LCSCMDHDR, *PLCSCMDHDR;
349 typedef struct _LCSSTDFRM LCSSTDFRM, *PLCSSTDFRM;
350 typedef struct _LCSSTRTFRM LCSSTRTFRM, *PLCSSTRTFRM;
351 typedef struct _LCSQIPFRM LCSQIPFRM, *PLCSQIPFRM;
352 typedef struct _LCSLSTFRM LCSLSTFRM, *PLCSLSTFRM;
353 typedef struct _LCSIPMPAIR LCSIPMPAIR, *PLCSIPMPAIR;
354 typedef struct _LCSIPMFRM LCSIPMFRM, *PLCSIPMFRM;
355 typedef struct _LCSETHFRM LCSETHFRM, *PLCSETHFRM;
356
357
358 // --------------------------------------------------------------------
359 // LCS Device (host byte order)
360 // --------------------------------------------------------------------
361
362 struct _LCSDEV
363 {
364 U16 sAddr; // Device Base Address
365 BYTE bMode; // (see below #defines)
366 BYTE bPort; // Relative Adapter No.
367 BYTE bType; // (see below #defines)
368 char* pszIPAddress; // IP Address (string)
369
370 U32 lIPAddress; // IP Address (binary),
371 // (network byte order)
372
373 PLCSBLK pLCSBLK; // -> LCSBLK
374 DEVBLK* pDEVBLK[2]; // 0 - Read subchannel
375 // 1 - Write cubchannel
376
377 U16 iMaxFrameBufferSize; // Device Buffer Size
378 BYTE bFrameBuffer[CTC_FRAME_BUFFER_SIZE]; // (this really SHOULD be dynamically allocated!)
379 U16 iFrameOffset; // Curr Offset into Buffer
380
381 LOCK Lock; // Data LOCK
382 LOCK EventLock; // Condition LOCK
383 COND Event; // Condition signal
384
385 u_int fCreated:1; // DEVBLK(s) Created
386 u_int fStarted:1; // Device Started
387 u_int fRouteAdded:1; // Routing Added
388 u_int fReplyPending:1; // Cmd Reply is Pending
389 u_int fDataPending:1; // Data is Pending
390
391 PLCSDEV pNext; // Next device
392 };
393
394
395
396 #define LCSDEV_MODE_IP 0x01
397 #define LCSDEV_MODE_SNA 0x02
398
399
400 #define LCSDEV_TYPE_NONE 0x00
401 #define LCSDEV_TYPE_PRIMARY 0x01
402 #define LCSDEV_TYPE_SECONDARY 0x02
403
404
405 // --------------------------------------------------------------------
406 // LCS Port (or Relative Adapter) (host byte order)
407 // --------------------------------------------------------------------
408
409 struct _LCSPORT
410 {
411 BYTE bPort; // Relative Adapter No
412 MAC MAC_Address; // MAC Address of Adapter
413 PLCSRTE pRoutes; // -> Routes chain
414 PLCSBLK pLCSBLK; // -> LCSBLK
415
416 U16 sIPAssistsSupported; // IP Assist Info
417 U16 sIPAssistsEnabled;
418
419 LOCK Lock; // Data LOCK
420 LOCK EventLock; // Condition LOCK
421 COND Event; // Condition signal
422
423 u_int fUsed:1; // Port is used
424 u_int fLocalMAC:1; // MAC is specified in OAT
425 u_int fCreated:1; // Interface Created
426 u_int fStarted:1; // Startup Received
427 u_int fRouteAdded:1; // Routing Added
428 u_int fCloseInProgress:1; // Close in progress
429
430 int fd; // TUN/TAP fd
431 TID tid; // Read Thread ID
432 pid_t pid; // Read Thread pid
433 int icDevices; // Device count
434 char szNetDevName[IFNAMSIZ]; // Network Device Name
435 char szMACAddress[32]; // MAC Address
436 char szGWAddress[32]; // Gateway for W32
437 };
438
439
440 // --------------------------------------------------------------------
441 // LCSRTE - Routing Entries (host byte order)
442 // --------------------------------------------------------------------
443
444 struct _LCSRTE
445 {
446 char* pszNetAddr;
447 char* pszNetMask;
448 PLCSRTE pNext;
449 };
450
451
452 // --------------------------------------------------------------------
453 // LCSBLK - Common Storage for LCS Emulation (host byte order)
454 // --------------------------------------------------------------------
455
456 struct _LCSBLK
457 {
458 // Config line parameters
459 char* pszTUNDevice; // TUN/TAP char device
460 char* pszOATFilename; // OAT Filename
461 char* pszIPAddress; // IP Address
462 char* pszMACAddress; // MAC Address (string)
463 MAC MAC_Address; // MAC Address (binary)
464
465 u_int fDebug:1;
466
467 int icDevices; // Number of devices
468 int iKernBuff; // Kernel buffer in K bytes.
469 int iIOBuff; // I/O buffer in K bytes.
470
471 PLCSDEV pDevices; // -> Device chain
472 LCSPORT Port[LCS_MAX_PORTS]; // Port Blocks
473
474 // Self Describing Component Information
475 char szSerialNumber[13];
476 };
477
478
479
480 /**********************************************************************\
481 **********************************************************************
482 ** **
483 ** LCS DEVICE FRAMES **
484 ** **
485 **********************************************************************
486 \**********************************************************************/
487
488
489 // --------------------------------------------------------------------
490 // LCS Frame Header (network byte order)
491 // --------------------------------------------------------------------
492
493 struct _LCSHDR // *ALL* LCS Frames start with the following header
494 {
495 HWORD hwOffset; // Offset to next frame or 0
496 BYTE bType; // (see below #defines)
497 BYTE bSlot; // (i.e. port)
498 } ATTRIBUTE_PACKED;
499
500
501 #define LCS_FRMTYP_CMD 0x00 // LCS command mode
502 #define LCS_FRMTYP_ENET 0x01 // Ethernet Passthru
503 #define LCS_FRMTYP_TR 0x02 // Token Ring
504 #define LCS_FRMTYP_FDDI 0x07 // FDDI
505 #define LCS_FRMTYP_AUTO 0xFF // auto-detect
506
507
508 // --------------------------------------------------------------------
509 // LCS Command Frame Header (network byte order)
510 // --------------------------------------------------------------------
511
512 struct _LCSCMDHDR // All LCS *COMMAND* Frames start with this header
513 {
514 LCSHDR bLCSHdr; // LCS Frame header
515
516 BYTE bCmdCode; // (see below #defines)
517 BYTE bInitiator;
518 HWORD hwSequenceNo;
519 HWORD hwReturnCode;
520
521 BYTE bLanType; // usually LCS_FRMTYP_ENET
522 BYTE bRelAdapterNo; // (i.e. port)
523 } ATTRIBUTE_PACKED;
524
525
526 #define LCS_CMD_TIMING 0x00 // Timing request
527 #define LCS_CMD_STRTLAN 0x01 // Start LAN
528 #define LCS_CMD_STOPLAN 0x02 // Stop LAN
529 #define LCS_CMD_GENSTAT 0x03 // Generate Stats
530 #define LCS_CMD_LANSTAT 0x04 // LAN Stats
531 #define LCS_CMD_LISTLAN 0x06 // List LAN
532 #define LCS_CMD_STARTUP 0x07 // Start Host
533 #define LCS_CMD_SHUTDOWN 0x08 // Shutdown Host
534 #define LCS_CMD_LISTLAN2 0x0B // List LAN (another version)
535 #define LCS_CMD_QIPASSIST 0xB2 // Query IP Assists
536 #define LCS_CMD_SETIPM 0xB4 // Set IP Multicast
537 #define LCS_CMD_DELIPM 0xB5 // Delete IP Multicast
538
539
540 // --------------------------------------------------------------------
541 // LCS Standard Command Frame (network byte order)
542 // --------------------------------------------------------------------
543
544 struct _LCSSTDFRM
545 {
546 LCSCMDHDR bLCSCmdHdr; // LCS Command Frame header
547
548 HWORD hwParameterCount;
549 BYTE bOperatorFlags[3];
550 BYTE _reserved[3];
551 BYTE bData[FLEXIBLE_ARRAY];
552 } ATTRIBUTE_PACKED;
553
554
555 // --------------------------------------------------------------------
556 // LCS Startup Command Frame (network byte order)
557 // --------------------------------------------------------------------
558
559 struct _LCSSTRTFRM
560 {
561 LCSCMDHDR bLCSCmdHdr; // LCS Command Frame header
562
563 HWORD hwBufferSize;
564 BYTE _unused2[6];
565 } ATTRIBUTE_PACKED;
566
567
568 // --------------------------------------------------------------------
569 // LCS Query IP Assists Command Frame (network byte order)
570 // --------------------------------------------------------------------
571
572 struct _LCSQIPFRM
573 {
574 LCSCMDHDR bLCSCmdHdr; // LCS Command Frame header
575
576 HWORD hwNumIPPairs;
577 HWORD hwIPAssistsSupported;
578 HWORD hwIPAssistsEnabled;
579 HWORD hwIPVersion;
580 } ATTRIBUTE_PACKED;
581
582
583 #define LCS_ARP_PROCESSING 0x0001
584 #define LCS_INBOUND_CHECKSUM_SUPPORT 0x0002
585 #define LCS_OUTBOUND_CHECKSUM_SUPPORT 0x0004
586 #define LCS_IP_FRAG_REASSEMBLY 0x0008
587 #define LCS_IP_FILTERING 0x0010
588 #define LCS_IP_V6_SUPPORT 0x0020
589 #define LCS_MULTICAST_SUPPORT 0x0040
590
591
592 // --------------------------------------------------------------------
593 // LCS LAN Statistics Command Frame (network byte order)
594 // --------------------------------------------------------------------
595
596 struct _LCSLSTFRM
597 {
598 LCSCMDHDR bLCSCmdHdr; // LCS Command Frame header
599
600 BYTE _unused1[10];
601 MAC MAC_Address; // MAC Address of Adapter
602 FWORD fwPacketsDeblocked;
603 FWORD fwPacketsBlocked;
604 FWORD fwTX_Packets;
605 FWORD fwTX_Errors;
606 FWORD fwTX_PacketsDiscarded;
607 FWORD fwRX_Packets;
608 FWORD fwRX_Errors;
609 FWORD fwRX_DiscardedNoBuffs;
610 U32 fwRX_DiscardedTooLarge;
611 } ATTRIBUTE_PACKED;
612
613
614 // --------------------------------------------------------------------
615 // LCS Set IP Multicast Command Frame (network byte order)
616 // --------------------------------------------------------------------
617
618 struct _LCSIPMPAIR
619 {
620 U32 IP_Addr;
621 MAC MAC_Address; // MAC Address of Adapter
622 BYTE _reserved[2];
623 } ATTRIBUTE_PACKED;
624
625 #define MAX_IP_MAC_PAIRS 32
626
627 struct _LCSIPMFRM
628 {
629 LCSCMDHDR bLCSCmdHdr; // LCS Command Frame header
630
631 HWORD hwNumIPPairs;
632 U16 hwIPAssistsSupported;
633 U16 hwIPAssistsEnabled;
634 U16 hwIPVersion;
635 LCSIPMPAIR IP_MAC_Pair[MAX_IP_MAC_PAIRS];
636 U32 fwResponseData;
637 } ATTRIBUTE_PACKED;
638
639
640 // --------------------------------------------------------------------
641 // LCS Ethernet Passthru Frame (network byte order)
642 // --------------------------------------------------------------------
643
644 struct _LCSETHFRM
645 {
646 LCSHDR bLCSHdr; // LCS Frame header
647 BYTE bData[FLEXIBLE_ARRAY]; // Ethernet Frame
648 } ATTRIBUTE_PACKED;
649
650
651
652 /**********************************************************************\
653 **********************************************************************
654 ** **
655 ** INLINE FUNCTIONS **
656 ** **
657 **********************************************************************
658 \**********************************************************************/
659
660
661 // --------------------------------------------------------------------
662 // Set SenseID Information
663 // --------------------------------------------------------------------
664
SetSIDInfo(DEVBLK * pDEVBLK,U16 wCUType,BYTE bCUMod,U16 wDevType,BYTE bDevMod)665 static inline void SetSIDInfo( DEVBLK* pDEVBLK,
666 U16 wCUType,
667 BYTE bCUMod,
668 U16 wDevType,
669 BYTE bDevMod )
670 {
671 BYTE* pSIDInfo = pDEVBLK->devid;
672
673 memset( pSIDInfo, 0, 256 );
674
675 *pSIDInfo++ = 0x0FF;
676 *pSIDInfo++ = (BYTE)(( wCUType >> 8 ) & 0x00FF );
677 *pSIDInfo++ = (BYTE)( wCUType & 0x00FF );
678 *pSIDInfo++ = bCUMod;
679 *pSIDInfo++ = (BYTE)(( wDevType >> 8 ) & 0x00FF );
680 *pSIDInfo++ = (BYTE)( wDevType & 0x00FF );
681 *pSIDInfo++ = bDevMod;
682 *pSIDInfo++ = 0x00;
683
684 pDEVBLK->numdevid = 7;
685 }
686
687
688 // --------------------------------------------------------------------
689 // Set SenseID CIW Information
690 // --------------------------------------------------------------------
691
SetCIWInfo(DEVBLK * pDEVBLK,U16 bOffset,BYTE bCIWType,BYTE bCIWOp,U16 wCIWCount)692 static inline void SetCIWInfo( DEVBLK* pDEVBLK,
693 U16 bOffset,
694 BYTE bCIWType,
695 BYTE bCIWOp,
696 U16 wCIWCount )
697 {
698 BYTE* pSIDInfo = pDEVBLK->devid;
699
700 pSIDInfo += 8;
701 pSIDInfo += ( bOffset * 4 );
702
703 *pSIDInfo++ = bCIWType | 0x40;
704 *pSIDInfo++ = bCIWOp;
705 *pSIDInfo++ = (BYTE)(( wCIWCount >> 8 ) & 0x00FF );
706 *pSIDInfo++ = (BYTE)( wCIWCount & 0x00FF );
707
708 pDEVBLK->numdevid += pDEVBLK->numdevid == 7 ? 5 : 4;
709 }
710
711
712 // --------------------------------------------------------------------
713
714 #if defined(_MSVC_)
715 #pragma pack(pop)
716 #endif
717
718 #endif // __CTCADPT_H_
719