[1567] | 1 | //Struct representing raw Ethernet header + packet contents |
---|
| 2 | typedef struct { |
---|
| 3 | //Standard 14-byte Ethernet header (dest/src MAC addresses + EtherType) |
---|
| 4 | unsigned char dstAddr[6]; |
---|
| 5 | unsigned char srcAddr[6]; |
---|
| 6 | unsigned short ethType; |
---|
| 7 | //total number of bytes in pkt, including this header |
---|
| 8 | unsigned short pktLength; |
---|
| 9 | //number of warpnet structs that follow |
---|
| 10 | unsigned char numStructs; |
---|
| 11 | //Sequence number to match packets to ACKs |
---|
| 12 | unsigned char seqNum; |
---|
| 13 | } warpnetEthernetPktHeader; |
---|
| 14 | |
---|
| 15 | typedef struct { |
---|
| 16 | unsigned char controllerID; |
---|
| 17 | unsigned char controllerGrp; |
---|
| 18 | unsigned char access; |
---|
| 19 | unsigned char reserved0; |
---|
| 20 | } warpnetControllerGroup; |
---|
| 21 | |
---|
| 22 | ///Structure contains PHY header |
---|
| 23 | typedef struct { |
---|
| 24 | unsigned char fullRate; |
---|
| 25 | unsigned char codeRate; |
---|
| 26 | unsigned short int length; |
---|
| 27 | unsigned short int srcAddr; |
---|
| 28 | unsigned short int destAddr; |
---|
| 29 | unsigned short int relAddr; |
---|
| 30 | unsigned char pktType; |
---|
| 31 | unsigned char reserved1; |
---|
| 32 | unsigned short seqNum; |
---|
| 33 | unsigned char reserved2; |
---|
| 34 | unsigned char reserved4; |
---|
| 35 | unsigned char reserved5; |
---|
| 36 | unsigned char reserved6; |
---|
| 37 | unsigned char reserved7; |
---|
| 38 | unsigned char reserved8; |
---|
| 39 | unsigned char reserved9; |
---|
| 40 | unsigned short int checksum; |
---|
| 41 | unsigned char headerTail; |
---|
| 42 | } phyHeader; |
---|
| 43 | |
---|
| 44 | typedef struct { |
---|
| 45 | unsigned char structID; |
---|
| 46 | unsigned char nodeID; |
---|
| 47 | unsigned short sequenceNumber; |
---|
| 48 | unsigned char nodeID_tx; |
---|
| 49 | unsigned char nodeID_rx; |
---|
| 50 | unsigned short mac_seqNum; |
---|
| 51 | unsigned int bits_rx; |
---|
| 52 | unsigned int bits_errors; |
---|
| 53 | } warpnetObserveBER; |
---|
| 54 | |
---|
| 55 | #define STRUCTID_OBSERVE_BER 0x24 |
---|
| 56 | #define STRUCTID_OBSERVE_BER_REQ 0x25 |
---|
| 57 | |
---|
| 58 | #define WARPNET_ETHTYPE_NODE2SVR 0x9191 |
---|
[1572] | 59 | #define WARPNET_ETHTYPE_NODE2BER 0x9494 |
---|
[1567] | 60 | |
---|
| 61 | //Compile-time limits on numbers of nodes and controllers |
---|
| 62 | #define MAX_NUMWARPNODES 4 |
---|
| 63 | #define MAX_NODETXTRIES 32 |
---|
| 64 | #define NODETX_TRYDELAY 65000 |
---|
| 65 | |
---|
| 66 | //Maximum size of network buffers |
---|
| 67 | #define MAX_ETHPKTSIZE 1550 |
---|
| 68 | |
---|
| 69 | void ProcessWARPnodeMessage(u_char *args, const struct pcap_pkthdr *header, const u_char *packet); |
---|
| 70 | int CalculateBER(void *bufA, void *bufB, int length, warpnetObserveBER *berResult); |
---|
| 71 | void SendStructToServer(void *theStruct); |
---|
| 72 | int SetupPCAP(); |
---|