2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <libkern/OSByteOrder.h> /* OSSwap functions */
26 #define ETHERHDRSIZE 14
28 #define KDP_MAXPACKET (ETHERHDRSIZE + ETHERMTU + ETHERCRC)
35 u_char ether_addr_octet
[6];
38 typedef struct ether_addr enet_addr_t
;
41 caddr_t ih_next
, ih_prev
; /* for protocol sequence q's */
42 u_char ih_x1
; /* (unused) */
43 u_char ih_pr
; /* protocol */
44 short ih_len
; /* protocol length */
45 struct in_addr ih_src
; /* source internet address */
46 struct in_addr ih_dst
; /* destination internet address */
50 u_short uh_sport
; /* source port */
51 u_short uh_dport
; /* destination port */
52 short uh_ulen
; /* udp length */
53 u_short uh_sum
; /* udp checksum */
57 struct ipovly ui_i
; /* overlaid ip structure */
58 struct udphdr ui_u
; /* udp header */
60 #define ui_next ui_i.ih_next
61 #define ui_prev ui_i.ih_prev
62 #define ui_x1 ui_i.ih_x1
63 #define ui_pr ui_i.ih_pr
64 #define ui_len ui_i.ih_len
65 #define ui_src ui_i.ih_src
66 #define ui_dst ui_i.ih_dst
67 #define ui_sport ui_u.uh_sport
68 #define ui_dport ui_u.uh_dport
69 #define ui_ulen ui_u.uh_ulen
70 #define ui_sum ui_u.uh_sum
77 #if _BIG_ENDIAN == __LITTLE_ENDIAN__
78 ip_xhl
:4, /* header length */
79 ip_xv
:4, /* version */
80 ip_xtos
:8, /* type of service */
81 ip_xlen
:16; /* total length */
83 #if _BIG_ENDIAN == __BIG_ENDIAN__
84 ip_xv
:4, /* version */
85 ip_xhl
:4, /* header length */
86 ip_xtos
:8, /* type of service */
87 ip_xlen
:16; /* total length */
91 u_short ip_id
; /* identification */
92 short ip_off
; /* fragment offset field */
93 #define IP_DF 0x4000 /* dont fragment flag */
94 #define IP_MF 0x2000 /* more fragments flag */
95 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
96 u_char ip_ttl
; /* time to live */
97 u_char ip_p
; /* protocol */
98 u_short ip_sum
; /* checksum */
99 struct in_addr ip_src
,ip_dst
; /* source and dest address */
101 #define ip_v ip_vhltl.ip_x.ip_xv
102 #define ip_hl ip_vhltl.ip_x.ip_xhl
103 #define ip_tos ip_vhltl.ip_x.ip_xtos
104 #define ip_len ip_vhltl.ip_x.ip_xlen
106 #define IPPROTO_UDP 17
109 struct ether_header
{
110 u_char ether_dhost
[6];
111 u_char ether_shost
[6];
115 typedef struct ether_header ether_header_t
;
117 #define ETHERTYPE_IP 0x0800 /* IP protocol */
119 #define ntohs(x) OSSwapBigToHostInt16(x)
120 #define htons(x) OSSwapHostToBigInt16(x)