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