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
33 #ifndef _IP_PACKET_H_
\r
34 #define _IP_PACKET_H_
\r
37 #include <complib/cl_types.h>
\r
38 #include <complib/cl_byteswap.h>
\r
42 #define HW_ADDR_LEN 6
\r
43 #endif /* HW_ADDR_LEN */
\r
46 #define ETH_PROT_TYPE_IP CL_HTON16(0x800)
\r
47 #define ETH_PROT_TYPE_ARP CL_HTON16(0x806)
\r
48 #define ETH_PROT_VLAN_TAG CL_HTON16(0x8100)
\r
51 #define ETH_IS_LOCALLY_ADMINISTERED(addr) \
\r
52 (BOOLEAN)(((PUCHAR)(addr))[0] & ((UCHAR)0x02))
\r
55 #include <complib/cl_packon.h>
\r
56 /****s* IB Network Drivers/mac_addr_t
\r
61 * Defines the ehternet MAC address.
\r
65 typedef struct _mac_addr
\r
67 uint8_t addr[HW_ADDR_LEN];
\r
69 } PACK_SUFFIX mac_addr_t;
\r
73 * Byte array representing the MAC address.
\r
76 * The HW_ADDR_LEN value must be defined before including this header in order
\r
77 * to support various address lengths. If not defined, the default length for
\r
78 * ethernet (6 bytes) is used.
\r
80 * addr[0] & 0x1 indicates multicast
\r
81 * addr[0] & 0x2 indicates LAA if not multicast
\r
84 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
86 #include <complib/cl_packoff.h>
\r
89 #include <complib/cl_packon.h>
\r
90 /****s* IB Network Drivers/eth_hdr_t
\r
95 * Defines the ehternet header for IP packets.
\r
99 typedef struct _eth_hdr
\r
105 } PACK_SUFFIX eth_hdr_t;
\r
109 * Destination address
\r
115 * Ethernet protocol type
\r
118 * The HW_ADDR_LEN value must be defined before including this header in order
\r
119 * to support various address lengths.
\r
122 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
124 #include <complib/cl_packoff.h>
\r
127 #define ARP_HW_TYPE_ETH CL_HTON16(1)
\r
128 #define ARP_HW_TYPE_IB CL_HTON16(32)
\r
130 #define ARP_OP_REQ CL_HTON16(1)
\r
131 #define ARP_OP_REP CL_HTON16(2)
\r
134 #include <complib/cl_packon.h>
\r
135 /****s* IB Network Drivers/arp_pkt_t
\r
140 * Defines the ARP packet for IP packets.
\r
144 typedef struct _arp_pkt
\r
156 } PACK_SUFFIX arp_pkt_t;
\r
163 * Protocol type. See ETH_PROT_TYPE_XXX definitions.
\r
166 * Size of the hardware address
\r
169 * Size of the protocol address
\r
175 * Source HW (MAC) address
\r
178 * Source IP address
\r
181 * Destination HW (MAC) address
\r
184 * Destination IP address
\r
187 * The HW_ADDR_LEN value must be defined before including this header in order
\r
188 * to support various MAC address lengths.
\r
191 * IB Network Drivers, eth_hdr_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
193 #include <complib/cl_packoff.h>
\r
196 #define IP_PROT_IP 4
\r
197 #define IP_PROT_TCP 6
\r
198 #define IP_PROT_UDP 17
\r
201 #include <complib/cl_packon.h>
\r
202 /****s* IB Network Drivers/ip_hdr_t
\r
207 * Defines the IP header for IP packets.
\r
211 typedef struct _ip_hdr
\r
224 } PACK_SUFFIX ip_hdr_t;
\r
228 * Header version and length.
\r
237 * Packet identification.
\r
252 * Source IP address
\r
255 * Destination IP address
\r
258 * IB Network Drivers, eth_hdr_t, arp_pkt_t, tcp_hdr_t, udp_hdr_t
\r
260 #include <complib/cl_packoff.h>
\r
263 #include <complib/cl_packon.h>
\r
264 /****s* IB Network Drivers/tcp_hdr_t
\r
269 * Defines the IP header for IP packets.
\r
273 typedef struct _tcp_hdr
\r
285 } PACK_SUFFIX tcp_hdr_t;
\r
292 * Destination port.
\r
298 * Acknowledge number.
\r
316 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
318 #include <complib/cl_packoff.h>
\r
321 #include <complib/cl_packon.h>
\r
322 /****s* IB Network Drivers/udp_hdr_t
\r
327 * Defines the IP header for IP packets.
\r
331 typedef struct _udp_hdr
\r
338 } PACK_SUFFIX udp_hdr_t;
\r
345 * Destination port.
\r
348 * Length of datagram.
\r
354 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t
\r
356 #include <complib/cl_packoff.h>
\r
359 #define DHCP_PORT_SERVER CL_HTON16(67)
\r
360 #define DHCP_PORT_CLIENT CL_HTON16(68)
\r
362 #define DHCP_REQUEST 1
\r
363 #define DHCP_REPLY 2
\r
364 #define DHCP_HW_TYPE_ETH 1
\r
365 #define DHCP_HW_TYPE_IB 32
\r
366 #define DHCP_OPT_PAD 0
\r
367 #define DHCP_OPT_END 255
\r
368 #define DHCP_OPT_MSG 53
\r
369 #define DHCP_OPT_CLIENT_ID 61
\r
371 #define DHCPDISCOVER 1
\r
372 #define DHCPOFFER 2
\r
373 #define DHCPREQUEST 3
\r
374 #define DHCPDECLINE 4
\r
377 #define DHCPRELEASE 7
\r
378 #define DHCPINFORM 8
\r
380 #define DHCP_FLAGS_BROADCAST CL_HTON16(0x8000)
\r
381 #define DHCP_COOKIE 0x63538263
\r
382 #define DHCP_OPTIONS_SIZE 312
\r
383 #define DHCP_COOKIE_SIZE 4
\r
386 /* Minimum DHCP size is without options (but with 4-byte magic cookie). */
\r
387 #define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE )
\r
389 #include <complib/cl_packon.h>
\r
390 /****s* IB Network Drivers/dhcp_pkt_t
\r
395 * Defines the DHCP packet format as documented in RFC 2131
\r
396 * http://www.zvon.org/tmRFC/RFC2131/Output/index.html
\r
400 typedef struct _dhcp_pkt
\r
413 uint8_t chaddr[16];
\r
416 uint8_t options[312];
\r
418 } PACK_SUFFIX dhcp_pkt_t;
\r
421 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
423 #include <complib/cl_packoff.h>
\r
426 #include <complib/cl_packon.h>
\r
427 typedef struct _udp_pkt
\r
432 } PACK_SUFFIX udp_pkt_t;
\r
434 typedef struct _ip_pkt
\r
442 } PACK_SUFFIX prot;
\r
444 } PACK_SUFFIX ip_pkt_t;
\r
446 typedef struct _eth_pkt
\r
454 } PACK_SUFFIX type;
\r
456 } PACK_SUFFIX eth_pkt_t;
\r
457 #include <complib/cl_packoff.h>
\r
460 #endif /* _IP_PACKET_H_ */
\r