1/************************************ 2* Protocol.h 3*************************************/ 4#ifndef __PROTOCOL_H__ 5#define __PROTOCOL_H__ 6 7#define IPV4 4 8#define IPV6 6 9 10struct ArpHeader { 11 struct arphdr arp; 12 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ 13 unsigned char ar_sip[4]; /* sender IP address */ 14 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ 15 unsigned char ar_tip[4]; /* target IP address */ 16}; 17 18struct bcm_transport_header { 19 union { 20 struct udphdr uhdr; 21 struct tcphdr thdr; 22 }; 23} __packed; 24 25enum bcm_ip_frame_type { 26 eNonIPPacket, 27 eIPv4Packet, 28 eIPv6Packet 29}; 30 31enum bcm_eth_frame_type { 32 eEthUnsupportedFrame, 33 eEth802LLCFrame, 34 eEth802LLCSNAPFrame, 35 eEth802QVLANFrame, 36 eEthOtherFrame 37}; 38 39struct bcm_eth_packet_info { 40 enum bcm_ip_frame_type eNwpktIPFrameType; 41 enum bcm_eth_frame_type eNwpktEthFrameType; 42 unsigned short usEtherType; 43 unsigned char ucDSAP; 44}; 45 46struct bcm_eth_q_frame { 47 struct bcm_eth_header EThHdr; 48 unsigned short UserPriority:3; 49 unsigned short CFI:1; 50 unsigned short VLANID:12; 51 unsigned short EthType; 52} __packed; 53 54struct bcm_eth_llc_frame { 55 struct bcm_eth_header EThHdr; 56 unsigned char DSAP; 57 unsigned char SSAP; 58 unsigned char Control; 59} __packed; 60 61struct bcm_eth_llc_snap_frame { 62 struct bcm_eth_header EThHdr; 63 unsigned char DSAP; 64 unsigned char SSAP; 65 unsigned char Control; 66 unsigned char OUI[3]; 67 unsigned short usEtherType; 68} __packed; 69 70struct bcm_ethernet2_frame { 71 struct bcm_eth_header EThHdr; 72} __packed; 73 74#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800) 75#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd) 76#define ETHERNET_FRAMETYPE_802QVLAN ntohs(0x8100) 77 78/* Per SF CS Specification Encodings */ 79enum bcm_spec_encoding { 80 eCSSpecUnspecified = 0, 81 eCSPacketIPV4, 82 eCSPacketIPV6, 83 eCS802_3PacketEthernet, 84 eCS802_1QPacketVLAN, 85 eCSPacketIPV4Over802_3Ethernet, 86 eCSPacketIPV6Over802_3Ethernet, 87 eCSPacketIPV4Over802_1QVLAN, 88 eCSPacketIPV6Over802_1QVLAN, 89 eCSPacketUnsupported 90}; 91 92#define IP6_HEADER_LEN 40 93#define IP_VERSION(byte) (((byte&0xF0)>>4)) 94 95#define MAC_ADDRESS_SIZE 6 96#define ETH_AND_IP_HEADER_LEN (14 + 20) 97#define L4_SRC_PORT_LEN 2 98#define L4_DEST_PORT_LEN 2 99#define CTRL_PKT_LEN (8 + ETH_AND_IP_HEADER_LEN) 100 101#define ETH_ARP_FRAME 0x806 102#define ETH_IPV4_FRAME 0x800 103#define ETH_IPV6_FRAME 0x86DD 104#define UDP 0x11 105#define TCP 0x06 106 107#define ARP_OP_REQUEST 0x01 108#define ARP_OP_REPLY 0x02 109#define ARP_PKT_SIZE 60 110 111/* This is the format for the TCP packet header */ 112struct bcm_tcp_header { 113 unsigned short usSrcPort; 114 unsigned short usDestPort; 115 unsigned long ulSeqNumber; 116 unsigned long ulAckNumber; 117 unsigned char HeaderLength; 118 unsigned char ucFlags; 119 unsigned short usWindowsSize; 120 unsigned short usChkSum; 121 unsigned short usUrgetPtr; 122}; 123 124#define TCP_HEADER_LEN sizeof(struct bcm_tcp_header) 125#define TCP_ACK 0x10 /* Bit 4 in tcpflags field. */ 126#define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4) 127 128#endif /* __PROTOCOL_H__ */ 129