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