2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
36 #ifndef _IP_PACKET_H_
\r
37 #define _IP_PACKET_H_
\r
40 #include <complib/cl_types.h>
\r
41 #include <complib/cl_byteswap.h>
\r
45 #define HW_ADDR_LEN 6
\r
46 #endif /* HW_ADDR_LEN */
\r
49 #define ETH_PROT_TYPE_IP CL_HTON16(0x800)
\r
50 #define ETH_PROT_TYPE_ARP CL_HTON16(0x806)
\r
53 #include <complib/cl_packon.h>
\r
54 /****s* IB Network Drivers/mac_addr_t
\r
59 * Defines the ehternet MAC address.
\r
63 typedef struct _mac_addr
\r
65 uint8_t addr[HW_ADDR_LEN];
\r
67 } PACK_SUFFIX mac_addr_t;
\r
71 * Byte array representing the MAC address.
\r
74 * The HW_ADDR_LEN value must be defined before including this header in order
\r
75 * to support various address lengths. If not defined, the default length for
\r
76 * ethernet (6 bytes) is used.
\r
79 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
81 #include <complib/cl_packoff.h>
\r
84 #include <complib/cl_packon.h>
\r
85 /****s* IB Network Drivers/eth_hdr_t
\r
90 * Defines the ehternet header for IP packets.
\r
94 typedef struct _eth_hdr
\r
100 } PACK_SUFFIX eth_hdr_t;
\r
104 * Destination address
\r
110 * Ethernet protocol type
\r
113 * The HW_ADDR_LEN value must be defined before including this header in order
\r
114 * to support various address lengths.
\r
117 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
119 #include <complib/cl_packoff.h>
\r
122 #define ARP_HW_TYPE_ETH CL_HTON16(1)
\r
123 #define ARP_HW_TYPE_IB CL_HTON16(32)
\r
125 #define ARP_OP_REQ CL_HTON16(1)
\r
126 #define ARP_OP_REP CL_HTON16(2)
\r
129 #include <complib/cl_packon.h>
\r
130 /****s* IB Network Drivers/arp_pkt_t
\r
135 * Defines the ARP packet for IP packets.
\r
139 typedef struct _arp_pkt
\r
151 } PACK_SUFFIX arp_pkt_t;
\r
158 * Protocol type. See ETH_PROT_TYPE_XXX definitions.
\r
161 * Size of the hardware address
\r
164 * Size of the protocol address
\r
170 * Source HW (MAC) address
\r
173 * Source IP address
\r
176 * Destination HW (MAC) address
\r
179 * Destination IP address
\r
182 * The HW_ADDR_LEN value must be defined before including this header in order
\r
183 * to support various MAC address lengths.
\r
186 * IB Network Drivers, eth_hdr_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
188 #include <complib/cl_packoff.h>
\r
191 #define IP_PROT_IP 4
\r
192 #define IP_PROT_TCP 6
\r
193 #define IP_PROT_UDP 17
\r
196 #include <complib/cl_packon.h>
\r
197 /****s* IB Network Drivers/ip_hdr_t
\r
202 * Defines the IP header for IP packets.
\r
206 typedef struct _ip_hdr
\r
219 } PACK_SUFFIX ip_hdr_t;
\r
223 * Header version and length.
\r
232 * Packet identification.
\r
247 * Source IP address
\r
250 * Destination IP address
\r
253 * IB Network Drivers, eth_hdr_t, arp_pkt_t, tcp_hdr_t, udp_hdr_t
\r
255 #include <complib/cl_packoff.h>
\r
258 #include <complib/cl_packon.h>
\r
259 /****s* IB Network Drivers/tcp_hdr_t
\r
264 * Defines the IP header for IP packets.
\r
268 typedef struct _tcp_hdr
\r
280 } PACK_SUFFIX tcp_hdr_t;
\r
287 * Destination port.
\r
293 * Acknowledge number.
\r
311 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
313 #include <complib/cl_packoff.h>
\r
316 #include <complib/cl_packon.h>
\r
317 /****s* IB Network Drivers/udp_hdr_t
\r
322 * Defines the IP header for IP packets.
\r
326 typedef struct _udp_hdr
\r
333 } PACK_SUFFIX udp_hdr_t;
\r
340 * Destination port.
\r
343 * Length of datagram.
\r
349 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t
\r
351 #include <complib/cl_packoff.h>
\r
354 #define DHCP_PORT_SERVER CL_HTON16(67)
\r
355 #define DHCP_PORT_CLIENT CL_HTON16(68)
\r
357 #define DHCP_REQUEST 1
\r
358 #define DHCP_REPLY 2
\r
359 #define DHCP_HW_TYPE_ETH 1
\r
360 #define DHCP_HW_TYPE_IB 32
\r
361 #define DHCP_OPT_PAD 0
\r
362 #define DHCP_OPT_END 255
\r
363 #define DHCP_OPT_MSG 53
\r
364 #define DHCP_OPT_CLIENT_ID 61
\r
366 #define DHCPDISCOVER 1
\r
367 #define DHCPOFFER 2
\r
368 #define DHCPREQUEST 3
\r
369 #define DHCPDECLINE 4
\r
372 #define DHCPRELEASE 7
\r
373 #define DHCPINFORM 8
\r
375 #define DHCP_FLAGS_BROADCAST CL_HTON16(0x8000)
\r
376 #define DHCP_COOKIE 0x63538263
\r
377 #define DHCP_OPTIONS_SIZE 312
\r
378 #define DHCP_COOKIE_SIZE 4
\r
381 /* Minimum DHCP size is without options (but with 4-byte magic cookie). */
\r
382 #define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE )
\r
384 #include <complib/cl_packon.h>
\r
385 /****s* IB Network Drivers/dhcp_pkt_t
\r
390 * Defines the DHCP packet format as documented in RFC 2131
\r
391 * http://www.zvon.org/tmRFC/RFC2131/Output/index.html
\r
395 typedef struct _dhcp_pkt
\r
408 uint8_t chaddr[16];
\r
411 uint8_t options[312];
\r
413 } PACK_SUFFIX dhcp_pkt_t;
\r
416 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
418 #include <complib/cl_packoff.h>
\r
421 #include <complib/cl_packon.h>
\r
422 typedef struct _udp_pkt
\r
427 } PACK_SUFFIX udp_pkt_t;
\r
429 typedef struct _ip_pkt
\r
437 } PACK_SUFFIX prot;
\r
439 } PACK_SUFFIX ip_pkt_t;
\r
441 typedef struct _eth_pkt
\r
449 } PACK_SUFFIX type;
\r
451 } PACK_SUFFIX eth_pkt_t;
\r
452 #include <complib/cl_packoff.h>
\r
455 #endif /* _IP_PACKET_H_ */
\r