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