]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/bootp.h
e69f97c729e0ddb4fd3b366cf595c00d3ca6303d
[apple/xnu.git] / bsd / netinet / bootp.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Bootstrap Protocol (BOOTP). RFC 951.
32 */
33 /*
34 * HISTORY
35 *
36 * 14 May 1992 ? at NeXT
37 * Added correct padding to struct nextvend. This is
38 * needed for the i386 due to alignment differences wrt
39 * the m68k. Also adjusted the size of the array fields
40 * because the NeXT vendor area was overflowing the bootp
41 * packet.
42 */
43
44 #include <netinet/udp.h>
45
46 #define iaddr_t struct in_addr
47
48 struct bootp {
49 u_char bp_op; /* packet opcode type */
50 #define BOOTREQUEST 1
51 #define BOOTREPLY 2
52 u_char bp_htype; /* hardware addr type */
53 u_char bp_hlen; /* hardware addr length */
54 u_char bp_hops; /* gateway hops */
55 u_long bp_xid; /* transaction ID */
56 u_short bp_secs; /* seconds since boot began */
57 u_short bp_unused;
58 iaddr_t bp_ciaddr; /* client IP address */
59 iaddr_t bp_yiaddr; /* 'your' IP address */
60 iaddr_t bp_siaddr; /* server IP address */
61 iaddr_t bp_giaddr; /* gateway IP address */
62 u_char bp_chaddr[16]; /* client hardware address */
63 u_char bp_sname[64]; /* server host name */
64 u_char bp_file[128]; /* boot file name */
65 u_char bp_vend[64]; /* vendor-specific area */
66 };
67
68 /*
69 * UDP port numbers, server and client.
70 */
71 #define IPPORT_BOOTPS 67
72 #define IPPORT_BOOTPC 68
73
74 /*
75 * "vendor" data permitted for Stanford boot clients.
76 */
77 struct vend {
78 u_char v_magic[4]; /* magic number */
79 u_long v_flags; /* flags/opcodes, etc. */
80 u_char v_unused[56]; /* currently unused */
81 };
82 #define VM_STANFORD "STAN" /* v_magic for Stanford */
83
84 /* v_flags values */
85 #define VF_PCBOOT 1 /* an IBMPC or Mac wants environment info */
86 #define VF_HELP 2 /* help me, I'm not registered */
87
88 #define NVMAXTEXT 55 /* don't change this, it just fits RFC951 */
89 struct nextvend {
90 u_char nv_magic[4]; /* Magic number for vendor specificity */
91 u_char nv_version; /* NeXT protocol version */
92 /*
93 * Round the beginning
94 * of the union to a 16
95 * bit boundary due to
96 * struct/union alignment
97 * on the m68k.
98 */
99 unsigned short :0;
100 union {
101 u_char NV0[58];
102 struct {
103 u_char NV1_opcode; /* opcode - Version 1 */
104 u_char NV1_xid; /* transcation id */
105 u_char NV1_text[NVMAXTEXT]; /* text */
106 u_char NV1_null; /* null terminator */
107 } NV1;
108 } nv_U;
109 };
110 #define nv_unused nv_U.NV0
111 #define nv_opcode nv_U.NV1.NV1_opcode
112 #define nv_xid nv_U.NV1.NV1_xid
113 #define nv_text nv_U.NV1.NV1_text
114 #define nv_null nv_U.NV1.NV1_null
115
116 /* Magic number */
117 #define VM_NEXT "NeXT" /* v_magic for NeXT, Inc. */
118
119 /* Opcodes */
120 #define BPOP_OK 0
121 #define BPOP_QUERY 1
122 #define BPOP_QUERY_NE 2
123 #define BPOP_ERROR 3
124
125 struct bootp_packet {
126 struct ip bp_ip;
127 struct udphdr bp_udp;
128 struct bootp bp_bootp;
129 };
130
131 #define BOOTP_PKTSIZE (sizeof (struct bootp_packet))
132
133 /* backoffs must be masks */
134 #define BOOTP_MIN_BACKOFF 0x7ff /* 2.048 sec */
135 #define BOOTP_MAX_BACKOFF 0xffff /* 65.535 sec */
136 #define BOOTP_RETRY 6 /* # retries */
137