Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Protocol.h
Go to the documentation of this file.
1 /************************************
2 * Protocol.h
3 *************************************/
4 #ifndef __PROTOCOL_H__
5 #define __PROTOCOL_H__
6 
7 
8 #define IPV4 4
9 #define IPV6 6
10 
11 
12 struct ArpHeader {
13  struct arphdr arp;
14  unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
15  unsigned char ar_sip[4]; /* sender IP address */
16  unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
17  unsigned char ar_tip[4]; /* target IP address */
18 }/*__attribute__((packed))*/;
19 
20 
22 {
23  union
24  {
25  struct udphdr uhdr;
26  struct tcphdr thdr;
27  };
28 } __attribute__((packed));
29 typedef struct TransportHeaderT xporthdr;
30 
31 
33 {
38 
40 {
47 
48 typedef struct _S_ETHCS_PKT_INFO
49 {
55 
56 typedef struct _ETH_CS_802_Q_FRAME
57 {
63 } __attribute__((packed)) ETH_CS_802_Q_FRAME;
64 
66 {
68  unsigned char DSAP;
69  unsigned char SSAP;
70  unsigned char Control;
71 }__attribute__((packed)) ETH_CS_802_LLC_FRAME;
72 
74 {
76  unsigned char DSAP;
77  unsigned char SSAP;
78  unsigned char Control;
79  unsigned char OUI[3];
80  unsigned short usEtherType;
81 } __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME;
82 
84 {
86 } __attribute__((packed)) ETH_CS_ETH2_FRAME;
87 
88 #define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800)
89 #define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd)
90 #define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100)
91 
92 //Per SF CS Specification Encodings
94 {
106 
107 
108 #define IP6_HEADER_LEN 40
109 
110 #define IP_VERSION(byte) (((byte&0xF0)>>4))
111 
112 
113 
114 #define MAC_ADDRESS_SIZE 6
115 #define ETH_AND_IP_HEADER_LEN 14 + 20
116 #define L4_SRC_PORT_LEN 2
117 #define L4_DEST_PORT_LEN 2
118 
119 
120 
121 #define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN
122 
123 #define ETH_ARP_FRAME 0x806
124 #define ETH_IPV4_FRAME 0x800
125 #define ETH_IPV6_FRAME 0x86DD
126 #define UDP 0x11
127 #define TCP 0x06
128 
129 #define ARP_OP_REQUEST 0x01
130 #define ARP_OP_REPLY 0x02
131 #define ARP_PKT_SIZE 60
132 
133 // This is the format for the TCP packet header
134 typedef struct _TCP_HEADER
135 {
146 #define TCP_HEADER_LEN sizeof(TCP_HEADER)
147 #define TCP_ACK 0x10 //Bit 4 in tcpflags field.
148 #define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4)
149 
150 
151 #endif //__PROTOCOL_H__