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
199 #define IP_PROT_IGMP 2
\r
202 #include <complib/cl_packon.h>
\r
203 /****s* IB Network Drivers/ip_hdr_t
\r
208 * Defines the IP header for IP packets.
\r
212 typedef struct _ip_hdr
\r
225 } PACK_SUFFIX ip_hdr_t;
\r
229 * Header version and length.
\r
238 * Packet identification.
\r
253 * Source IP address
\r
256 * Destination IP address
\r
259 * IB Network Drivers, eth_hdr_t, arp_pkt_t, tcp_hdr_t, udp_hdr_t
\r
261 #include <complib/cl_packoff.h>
\r
264 #include <complib/cl_packon.h>
\r
265 /****s* IB Network Drivers/tcp_hdr_t
\r
270 * Defines the IP header for IP packets.
\r
274 typedef struct _tcp_hdr
\r
286 } PACK_SUFFIX tcp_hdr_t;
\r
293 * Destination port.
\r
299 * Acknowledge number.
\r
317 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
319 #include <complib/cl_packoff.h>
\r
322 #include <complib/cl_packon.h>
\r
323 /****s* IB Network Drivers/udp_hdr_t
\r
328 * Defines the IP header for IP packets.
\r
332 typedef struct _udp_hdr
\r
339 } PACK_SUFFIX udp_hdr_t;
\r
346 * Destination port.
\r
349 * Length of datagram.
\r
355 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t
\r
357 #include <complib/cl_packoff.h>
\r
359 #define IP_HEADER_LENGTH(pIpHdr) \
\r
360 ( (ULONG)((pIpHdr->ver_hl & 0x0F) << 2) )
\r
362 #define TCP_HEADER_LENGTH(pTcpHdr) \
\r
363 ((pTcpHdr->offset & 0xF0) >> 2)
\r
365 #define PROTOCOL_TCP 6
\r
368 #define IGMP_V2_MEMBERSHIP_QUERY 0x11
\r
369 #define IGMP_V2_MEMBERSHIP_REPORT 0x16
\r
370 #define IGMP_V1_MEMBERSHIP_REPORT 0x12 // for backward compatibility with IGMPv1
\r
371 #define IGMP_V2_LEAVE_GROUP 0x17
\r
372 #include <complib/cl_packon.h>
\r
373 /****s* IB Network Drivers/igmp__v2_hdr_t
\r
378 * Defines the IGMPv2 header for IP packets.
\r
382 typedef struct _igmp_v2_hdr
\r
385 uint8_t max_resp_time;
\r
387 net32_t group_address;
\r
388 } PACK_SUFFIX igmp_v2_hdr_t;
\r
392 * type of IGMPv2 message: query/report/leave
\r
395 * The Max Response Time field is meaningful only in Membership Query
\r
396 * messages, and specifies the maximum allowed time before sending a
\r
397 * responding report in units of 1/10 second. In all other messages, it
\r
398 * is set to zero by the sender and ignored by receivers.
\r
401 * The checksum is the 16-bit one's complement of the one's complement
\r
402 * sum of the whole IGMP message (the entire IP payload).
\r
405 * In a Membership Query message, the group address field is set to zero
\r
406 * when sending a General Query, and set to the group address being
\r
407 * queried when sending a Group-Specific Query.
\r
409 * In a Membership Report or Leave Group message, the group address
\r
410 * field holds the IP multicast group address of the group being
\r
411 * reported or left.
\r
414 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, tcp_hdr_t
\r
416 #include <complib/cl_packoff.h>
\r
418 #define DHCP_PORT_SERVER CL_HTON16(67)
\r
419 #define DHCP_PORT_CLIENT CL_HTON16(68)
\r
421 #define DHCP_REQUEST 1
\r
422 #define DHCP_REPLY 2
\r
423 #define DHCP_HW_TYPE_ETH 1
\r
424 #define DHCP_HW_TYPE_IB 32
\r
425 #define DHCP_OPT_PAD 0
\r
426 #define DHCP_OPT_END 255
\r
427 #define DHCP_OPT_MSG 53
\r
428 #define DHCP_OPT_CLIENT_ID 61
\r
430 #define DHCPDISCOVER 1
\r
431 #define DHCPOFFER 2
\r
432 #define DHCPREQUEST 3
\r
433 #define DHCPDECLINE 4
\r
436 #define DHCPRELEASE 7
\r
437 #define DHCPINFORM 8
\r
439 #define DHCP_FLAGS_BROADCAST CL_HTON16(0x8000)
\r
440 #define DHCP_COOKIE 0x63538263
\r
441 #define DHCP_OPTIONS_SIZE 312
\r
442 #define DHCP_COOKIE_SIZE 4
\r
445 /* Minimum DHCP size is without options (but with 4-byte magic cookie). */
\r
446 #define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE )
\r
448 #include <complib/cl_packon.h>
\r
449 /****s* IB Network Drivers/dhcp_pkt_t
\r
454 * Defines the DHCP packet format as documented in RFC 2131
\r
455 * http://www.zvon.org/tmRFC/RFC2131/Output/index.html
\r
459 typedef struct _dhcp_pkt
\r
472 uint8_t chaddr[16];
\r
475 uint8_t options[312];
\r
477 } PACK_SUFFIX dhcp_pkt_t;
\r
480 * IB Network Drivers, eth_hdr_t, arp_pkt_t, ip_hdr_t, udp_hdr_t
\r
482 #include <complib/cl_packoff.h>
\r
485 #include <complib/cl_packon.h>
\r
486 typedef struct _udp_pkt
\r
491 } PACK_SUFFIX udp_pkt_t;
\r
493 typedef struct _ip_pkt
\r
501 } PACK_SUFFIX prot;
\r
503 } PACK_SUFFIX ip_pkt_t;
\r
505 typedef struct _eth_pkt
\r
513 } PACK_SUFFIX type;
\r
515 } PACK_SUFFIX eth_pkt_t;
\r
516 #include <complib/cl_packoff.h>
\r
519 #endif /* _IP_PACKET_H_ */
\r