From: aestrin Date: Mon, 30 Oct 2006 15:43:54 +0000 (+0000) Subject: [IPoIB] share ip_packet.h X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=102a65484f446b9918e9c27285a04681fe14e4d1;p=~shefty%2Frdma-win.git [IPoIB] share ip_packet.h git-svn-id: svn://openib.tc.cornell.edu/gen1@532 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/inc/kernel/ip_packet.h b/trunk/inc/kernel/ip_packet.h new file mode 100644 index 00000000..60421edb --- /dev/null +++ b/trunk/inc/kernel/ip_packet.h @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2005 SilverStorm Technologies. All rights reserved. + * + * This software is available to you under the OpenIB.org BSD license + * below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * $Id$ + */ + + +#ifndef _IP_PACKET_H_ +#define _IP_PACKET_H_ + + +#include +#include + + +#ifndef HW_ADDR_LEN +#define HW_ADDR_LEN 6 +#endif /* HW_ADDR_LEN */ + + +#define ETH_PROT_TYPE_IP CL_HTON16(0x800) +#define ETH_PROT_TYPE_ARP CL_HTON16(0x806) + + +#define ETH_IS_LOCALLY_ADMINISTERED(addr) \ + (BOOLEAN)(((PUCHAR)(addr))[0] & ((UCHAR)0x02)) + + +#include +/****s* IB Network Drivers/mac_addr_t +* NAME +* mac_addr_t +* +* DESCRIPTION +* Defines the ehternet MAC address. +* +* SYNOPSIS +*/ +typedef struct _mac_addr +{ + uint8_t addr[HW_ADDR_LEN]; + +} PACK_SUFFIX mac_addr_t; +/* +* FIELDS +* addr +* Byte array representing the MAC address. +* +* NOTES +* The HW_ADDR_LEN value must be defined before including this header in order +* to support various address lengths. If not defined, the default length for +* ethernet (6 bytes) is used. +* +* addr[0] & 0x1 indicates multicast +* addr[0] & 0x2 indicates LAA if not multicast +* +* SEE ALSO +* IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t +*********/ +#include + + +#include +/****s* IB Network Drivers/eth_hdr_t +* NAME +* eth_hdr_t +* +* DESCRIPTION +* Defines the ehternet header for IP packets. +* +* SYNOPSIS +*/ +typedef struct _eth_hdr +{ + mac_addr_t dst; + mac_addr_t src; + net16_t type; + +} PACK_SUFFIX eth_hdr_t; +/* +* FIELDS +* dst +* Destination address +* +* src +* Source address +* +* type +* Ethernet protocol type +* +* NOTES +* The HW_ADDR_LEN value must be defined before including this header in order +* to support various address lengths. +* +* SEE ALSO +* IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t +*********/ +#include + + +#define ARP_HW_TYPE_ETH CL_HTON16(1) +#define ARP_HW_TYPE_IB CL_HTON16(32) + +#define ARP_OP_REQ CL_HTON16(1) +#define ARP_OP_REP CL_HTON16(2) + + +#include +/****s* IB Network Drivers/arp_pkt_t +* NAME +* arp_pkt_t +* +* DESCRIPTION +* Defines the ARP packet for IP packets. +* +* SYNOPSIS +*/ +typedef struct _arp_pkt +{ + net16_t hw_type; + net16_t prot_type; + uint8_t hw_size; + uint8_t prot_size; + net16_t op; + mac_addr_t src_hw; + net32_t src_ip; + mac_addr_t dst_hw; + net32_t dst_ip; + +} PACK_SUFFIX arp_pkt_t; +/* +* FIELDS +* hw_type +* Hardware type +* +* prot_type +* Protocol type. See ETH_PROT_TYPE_XXX definitions. +* +* hw_size +* Size of the hardware address +* +* prot_size +* Size of the protocol address +* +* op +* ARP operation +* +* src_hw +* Source HW (MAC) address +* +* src_ip +* Source IP address +* +* dst_hw +* Destination HW (MAC) address +* +* dst_ip +* Destination IP address +* +* NOTES +* The HW_ADDR_LEN value must be defined before including this header in order +* to support various MAC address lengths. +* +* SEE ALSO +* IB Network Drivers, eth_hdr_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t +*********/ +#include + + +#define IP_PROT_IP 4 +#define IP_PROT_TCP 6 +#define IP_PROT_UDP 17 + + +#include +/****s* IB Network Drivers/ip_hdr_t +* NAME +* ip_hdr_t +* +* DESCRIPTION +* Defines the IP header for IP packets. +* +* SYNOPSIS +*/ +typedef struct _ip_hdr +{ + uint8_t ver_hl; + uint8_t svc_type; + net16_t length; + net16_t id; + net16_t offset; + uint8_t ttl; + uint8_t prot; + net16_t chksum; + net32_t src_ip; + net32_t dst_ip; + +} PACK_SUFFIX ip_hdr_t; +/* +* FIELDS +* ver_hl +* Header version and length. +* +* svc_type +* Service type. +* +* length +* Total length. +* +* id +* Packet identification. +* +* offset +* Fragment offset. +* +* ttl +* Time to live. +* +* prot +* Protocol. +* +* chksum +* Checksum. +* +* src_ip +* Source IP address +* +* dst_ip +* Destination IP address +* +* SEE ALSO +* IB Network Drivers, eth_hdr_t, arp_pkt_t, tcp_hdr_t, udp_hdr_t +*********/ +#include + + +#include +/****s* IB Network Drivers/tcp_hdr_t +* NAME +* tcp_hdr_t +* +* DESCRIPTION +* Defines the IP header for IP packets. +* +* SYNOPSIS +*/ +typedef struct _tcp_hdr +{ + net16_t src_port; + net16_t dst_port; + net32_t seq_num; + net32_t ack_num; + uint8_t offset; + uint8_t flags; + net16_t window; + net16_t chksum; + net16_t urp; + +} PACK_SUFFIX tcp_hdr_t; +/* +* FIELDS +* src_port +* Source port. +* +* dst_port +* Destination port. +* +* seq_num +* Sequence number. +* +* ack_num +* Acknowledge number. +* +* offset +* data offset. +* +* flags +* TCP flags. +* +* window +* Window number. +* +* chksum +* Checksum. +* +* urp +* Urgent pointer. +* +* SEE ALSO +* IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t +*********/ +#include + + +#include +/****s* IB Network Drivers/udp_hdr_t +* NAME +* udp_hdr_t +* +* DESCRIPTION +* Defines the IP header for IP packets. +* +* SYNOPSIS +*/ +typedef struct _udp_hdr +{ + net16_t src_port; + net16_t dst_port; + net16_t length; + net16_t chksum; + +} PACK_SUFFIX udp_hdr_t; +/* +* FIELDS +* src_port +* Source port. +* +* dst_port +* Destination port. +* +* length +* Length of datagram. +* +* chksum +* Checksum. +* +* SEE ALSO +* IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t +*********/ +#include + + +#define DHCP_PORT_SERVER CL_HTON16(67) +#define DHCP_PORT_CLIENT CL_HTON16(68) + +#define DHCP_REQUEST 1 +#define DHCP_REPLY 2 +#define DHCP_HW_TYPE_ETH 1 +#define DHCP_HW_TYPE_IB 32 +#define DHCP_OPT_PAD 0 +#define DHCP_OPT_END 255 +#define DHCP_OPT_MSG 53 +#define DHCP_OPT_CLIENT_ID 61 + +#define DHCPDISCOVER 1 +#define DHCPOFFER 2 +#define DHCPREQUEST 3 +#define DHCPDECLINE 4 +#define DHCPACK 5 +#define DHCPNAK 6 +#define DHCPRELEASE 7 +#define DHCPINFORM 8 + +#define DHCP_FLAGS_BROADCAST CL_HTON16(0x8000) +#define DHCP_COOKIE 0x63538263 +#define DHCP_OPTIONS_SIZE 312 +#define DHCP_COOKIE_SIZE 4 + + +/* Minimum DHCP size is without options (but with 4-byte magic cookie). */ +#define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE ) + +#include +/****s* IB Network Drivers/dhcp_pkt_t +* NAME +* dhcp_pkt_t +* +* DESCRIPTION +* Defines the DHCP packet format as documented in RFC 2131 +* http://www.zvon.org/tmRFC/RFC2131/Output/index.html +* +* SYNOPSIS +*/ +typedef struct _dhcp_pkt +{ + uint8_t op; + uint8_t htype; + uint8_t hlen; + uint8_t hops; + net32_t xid; + net16_t secs; + net16_t flags; + net32_t ciaddr; + net32_t yiaddr; + net32_t siaddr; + net32_t giaddr; + uint8_t chaddr[16]; + uint8_t sname[64]; + uint8_t file[128]; + uint8_t options[312]; + +} PACK_SUFFIX dhcp_pkt_t; +/* +* SEE ALSO +* IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t +*********/ +#include + + +#include +typedef struct _udp_pkt +{ + udp_hdr_t hdr; + dhcp_pkt_t dhcp; + +} PACK_SUFFIX udp_pkt_t; + +typedef struct _ip_pkt +{ + ip_hdr_t hdr; + union _ip_payload + { + tcp_hdr_t tcp; + udp_pkt_t udp; + + } PACK_SUFFIX prot; + +} PACK_SUFFIX ip_pkt_t; + +typedef struct _eth_pkt +{ + eth_hdr_t hdr; + union _eth_payload + { + arp_pkt_t arp; + ip_pkt_t ip; + + } PACK_SUFFIX type; + +} PACK_SUFFIX eth_pkt_t; +#include + + +#endif /* _IP_PACKET_H_ */ diff --git a/trunk/ulp/ipoib/kernel/ipoib_adapter.h b/trunk/ulp/ipoib/kernel/ipoib_adapter.h index 23e54af6..074f1b56 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_adapter.h +++ b/trunk/ulp/ipoib/kernel/ipoib_adapter.h @@ -42,7 +42,7 @@ #include #include #include -#include "ip_packet.h" +#include #include "ip_stats.h" diff --git a/trunk/ulp/ipoib/kernel/ipoib_endpoint.h b/trunk/ulp/ipoib/kernel/ipoib_endpoint.h index fdf76bf3..e4a36a47 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_endpoint.h +++ b/trunk/ulp/ipoib/kernel/ipoib_endpoint.h @@ -40,7 +40,7 @@ #include #include #include "iba/ipoib_ifc.h" -#include "ip_packet.h" +#include #include "ipoib_debug.h" diff --git a/trunk/ulp/ipoib/kernel/ipoib_port.h b/trunk/ulp/ipoib/kernel/ipoib_port.h index 31ee612f..6b6d6aaf 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_port.h +++ b/trunk/ulp/ipoib/kernel/ipoib_port.h @@ -39,7 +39,7 @@ #include #include #include -#include "ip_packet.h" +#include #include "ipoib_endpoint.h" #include "ipoib_xfr_mgr.h" diff --git a/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h b/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h index 230238f5..8e5ca00c 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h +++ b/trunk/ulp/ipoib/kernel/ipoib_xfr_mgr.h @@ -45,7 +45,7 @@ #include "ipoib_driver.h" #include "ip_stats.h" -#include "ip_packet.h" +#include #include