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
50 #define ETH_IS_LOCALLY_ADMINISTERED(addr) \
\r
51 (BOOLEAN)(((PUCHAR)(addr))[0] & ((UCHAR)0x02))
\r
54 #include <complib/cl_packon.h>
\r
55 /****s* IB Network Drivers/mac_addr_t
\r
60 * Defines the ehternet MAC address.
\r
64 typedef struct _mac_addr
\r
66 uint8_t addr[HW_ADDR_LEN];
\r
68 } PACK_SUFFIX mac_addr_t;
\r
72 * Byte array representing the MAC address.
\r
75 * The HW_ADDR_LEN value must be defined before including this header in order
\r
76 * to support various address lengths. If not defined, the default length for
\r
77 * ethernet (6 bytes) is used.
\r
79 * addr[0] & 0x1 indicates multicast
\r
80 * addr[0] & 0x2 indicates LAA if not multicast
\r
83 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
85 #include <complib/cl_packoff.h>
\r
88 #include <complib/cl_packon.h>
\r
89 /****s* IB Network Drivers/eth_hdr_t
\r
94 * Defines the ehternet header for IP packets.
\r
98 typedef struct _eth_hdr
\r
104 } PACK_SUFFIX eth_hdr_t;
\r
108 * Destination address
\r
114 * Ethernet protocol type
\r
117 * The HW_ADDR_LEN value must be defined before including this header in order
\r
118 * to support various address lengths.
\r
121 * IB Network Drivers, arp_pkt_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
123 #include <complib/cl_packoff.h>
\r
126 #define ARP_HW_TYPE_ETH CL_HTON16(1)
\r
127 #define ARP_HW_TYPE_IB CL_HTON16(32)
\r
129 #define ARP_OP_REQ CL_HTON16(1)
\r
130 #define ARP_OP_REP CL_HTON16(2)
\r
133 #include <complib/cl_packon.h>
\r
134 /****s* IB Network Drivers/arp_pkt_t
\r
139 * Defines the ARP packet for IP packets.
\r
143 typedef struct _arp_pkt
\r
155 } PACK_SUFFIX arp_pkt_t;
\r
162 * Protocol type. See ETH_PROT_TYPE_XXX definitions.
\r
165 * Size of the hardware address
\r
168 * Size of the protocol address
\r
174 * Source HW (MAC) address
\r
177 * Source IP address
\r
180 * Destination HW (MAC) address
\r
183 * Destination IP address
\r
186 * The HW_ADDR_LEN value must be defined before including this header in order
\r
187 * to support various MAC address lengths.
\r
190 * IB Network Drivers, eth_hdr_t, ip_hdr_t, tcp_hdr_t, udp_hdr_t
\r
192 #include <complib/cl_packoff.h>
\r
195 #define IP_PROT_IP 4
\r
196 #define IP_PROT_TCP 6
\r
197 #define IP_PROT_UDP 17
\r
200 #include <complib/cl_packon.h>
\r
201 /****s* IB Network Drivers/ip_hdr_t
\r
206 * Defines the IP header for IP packets.
\r
210 typedef struct _ip_hdr
\r
223 } PACK_SUFFIX ip_hdr_t;
\r
227 * Header version and length.
\r
236 * Packet identification.
\r
251 * Source IP address
\r
254 * Destination IP address
\r
257 * IB Network Drivers, eth_hdr_t, arp_pkt_t, tcp_hdr_t, udp_hdr_t
\r
259 #include <complib/cl_packoff.h>
\r
262 #include <complib/cl_packon.h>
\r
263 /****s* IB Network Drivers/tcp_hdr_t
\r
268 * Defines the IP header for IP packets.
\r
272 typedef struct _tcp_hdr
\r
284 } PACK_SUFFIX tcp_hdr_t;
\r
291 * Destination port.
\r
297 * Acknowledge number.
\r
315 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
317 #include <complib/cl_packoff.h>
\r
320 #include <complib/cl_packon.h>
\r
321 /****s* IB Network Drivers/udp_hdr_t
\r
326 * Defines the IP header for IP packets.
\r
330 typedef struct _udp_hdr
\r
337 } PACK_SUFFIX udp_hdr_t;
\r
344 * Destination port.
\r
347 * Length of datagram.
\r
353 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t
\r
355 #include <complib/cl_packoff.h>
\r
358 #define DHCP_PORT_SERVER CL_HTON16(67)
\r
359 #define DHCP_PORT_CLIENT CL_HTON16(68)
\r
361 #define DHCP_REQUEST 1
\r
362 #define DHCP_REPLY 2
\r
363 #define DHCP_HW_TYPE_ETH 1
\r
364 #define DHCP_HW_TYPE_IB 32
\r
365 #define DHCP_OPT_PAD 0
\r
366 #define DHCP_OPT_END 255
\r
367 #define DHCP_OPT_MSG 53
\r
368 #define DHCP_OPT_CLIENT_ID 61
\r
370 #define DHCPDISCOVER 1
\r
371 #define DHCPOFFER 2
\r
372 #define DHCPREQUEST 3
\r
373 #define DHCPDECLINE 4
\r
376 #define DHCPRELEASE 7
\r
377 #define DHCPINFORM 8
\r
379 #define DHCP_FLAGS_BROADCAST CL_HTON16(0x8000)
\r
380 #define DHCP_COOKIE 0x63538263
\r
381 #define DHCP_OPTIONS_SIZE 312
\r
382 #define DHCP_COOKIE_SIZE 4
\r
385 /* Minimum DHCP size is without options (but with 4-byte magic cookie). */
\r
386 #define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE )
\r
388 #include <complib/cl_packon.h>
\r
389 /****s* IB Network Drivers/dhcp_pkt_t
\r
394 * Defines the DHCP packet format as documented in RFC 2131
\r
395 * http://www.zvon.org/tmRFC/RFC2131/Output/index.html
\r
399 typedef struct _dhcp_pkt
\r
412 uint8_t chaddr[16];
\r
415 uint8_t options[312];
\r
417 } PACK_SUFFIX dhcp_pkt_t;
\r
420 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
422 #include <complib/cl_packoff.h>
\r
425 #include <complib/cl_packon.h>
\r
426 typedef struct _udp_pkt
\r
431 } PACK_SUFFIX udp_pkt_t;
\r
433 typedef struct _ip_pkt
\r
441 } PACK_SUFFIX prot;
\r
443 } PACK_SUFFIX ip_pkt_t;
\r
445 typedef struct _eth_pkt
\r
453 } PACK_SUFFIX type;
\r
455 } PACK_SUFFIX eth_pkt_t;
\r
456 #include <complib/cl_packoff.h>
\r
459 #endif /* _IP_PACKET_H_ */
\r