4 *Copyright (C) 2010 Beceem Communications, Inc.
6 *This program is free software: you can redistribute it and/or modify
7 *it under the terms of the GNU General Public License version 2 as
8 *published by the Free Software Foundation.
10 *This program is distributed in the hope that it will be useful,but
11 *WITHOUT ANY WARRANTY; without even the implied warranty of
12 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *See the GNU General Public License for more details.
15 *You should have received a copy of the GNU General Public License
16 *along with this program. If not, write to the Free Software Foundation, Inc.,
17 *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __PROTOCOL_H__
23 #define __PROTOCOL_H__
32 unsigned char ar_sha
[ETH_ALEN
]; /* sender hardware address */
33 unsigned char ar_sip
[4]; /* sender IP address */
34 unsigned char ar_tha
[ETH_ALEN
]; /* target hardware address */
35 unsigned char ar_tip
[4]; /* target IP address */
36 }/*__attribute__((packed))*/;
39 struct TransportHeaderT
46 } __attribute__((packed
));
47 typedef struct TransportHeaderT xporthdr
;
50 typedef enum _E_NWPKT_IPFRAME_TYPE
55 }E_NWPKT_IPFRAME_TYPE
;
57 typedef enum _E_NWPKT_ETHFRAME_TYPE
64 } E_NWPKT_ETHFRAME_TYPE
;
66 typedef struct _S_ETHCS_PKT_INFO
68 E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType
;
69 E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType
;
72 }S_ETHCS_PKT_INFO
,*PS_ETHCS_PKT_INFO
;
74 typedef struct _ETH_CS_802_Q_FRAME
76 ETH_HEADER_STRUC EThHdr
;
77 USHORT UserPriority
:3;
81 } __attribute__((packed
)) ETH_CS_802_Q_FRAME
;
83 typedef struct _ETH_CS_802_LLC_FRAME
85 ETH_HEADER_STRUC EThHdr
;
88 unsigned char Control
;
89 }__attribute__((packed
)) ETH_CS_802_LLC_FRAME
;
91 typedef struct _ETH_CS_802_LLC_SNAP_FRAME
93 ETH_HEADER_STRUC EThHdr
;
96 unsigned char Control
;
98 unsigned short usEtherType
;
99 } __attribute__((packed
)) ETH_CS_802_LLC_SNAP_FRAME
;
101 typedef struct _ETH_CS_ETH2_FRAME
103 ETH_HEADER_STRUC EThHdr
;
104 } __attribute__((packed
)) ETH_CS_ETH2_FRAME
;
107 #define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800)
108 #define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd)
109 #define ETHERNET_FRAMETYPE_802QVLAN 0x8100
110 //Per SF CS Specification Encodings
111 typedef enum _E_SERVICEFLOW_CS_SPEC_
113 eCSSpecUnspecified
=0,
116 eCS802_3PacketEthernet
,
118 eCSPacketIPV4Over802_3Ethernet
,
119 eCSPacketIPV6Over802_3Ethernet
,
120 eCSPacketIPV4Over802_1QVLAN
,
121 eCSPacketIPV6Over802_1QVLAN
,
123 }E_SERVICEFLOW_CS_SPEC
;
126 #define IP6_HEADER_LEN 40
128 #define IP_VERSION(byte) (((byte&0xF0)>>4))
132 #define MAC_ADDRESS_SIZE 6
133 #define ETH_AND_IP_HEADER_LEN 14 + 20
134 #define L4_SRC_PORT_LEN 2
135 #define L4_DEST_PORT_LEN 2
139 #define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN
141 #define ETH_ARP_FRAME 0x806
142 #define ETH_IPV4_FRAME 0x800
143 #define ETH_IPV6_FRAME 0x86DD
147 #define ARP_OP_REQUEST 0x01
148 #define ARP_OP_REPLY 0x02
149 #define ARP_PKT_SIZE 60
151 // This is the format for the TCP packet header
152 typedef struct _TCP_HEADER
160 USHORT usWindowsSize
;
163 } TCP_HEADER
,*PTCP_HEADER
;
164 #define TCP_HEADER_LEN sizeof(TCP_HEADER)
165 #define TCP_ACK 0x10 //Bit 4 in tcpflags field.
166 #define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4)
169 #endif //__PROTOCOL_H__