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