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