xref: /freebsd/libexec/bootpd/bootp.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1 /************************************************************************
2           Copyright 1988, 1991 by Carnegie Mellon University
3 
4                           All Rights Reserved
5 
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted, provided
8 that the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation, and that the name of Carnegie Mellon University not be used
11 in advertising or publicity pertaining to distribution of the software
12 without specific, written prior permission.
13 
14 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
15 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
16 IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
17 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 SOFTWARE.
21 ************************************************************************/
22 
23 /*
24  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1395.
25  *
26  * $FreeBSD$
27  *
28  *
29  * This file specifies the "implementation-independent" BOOTP protocol
30  * information which is common to both client and server.
31  *
32  */
33 
34 #include "bptypes.h"	/* for int32, u_int32 */
35 
36 #define BP_CHADDR_LEN	 16
37 #define BP_SNAME_LEN	 64
38 #define BP_FILE_LEN	128
39 #define BP_VEND_LEN	 64
40 #define BP_MINPKTSZ	300	/* to check sizeof(struct bootp) */
41 /* Overhead to fit a bootp message into an Ethernet packet. */
42 #define BP_MSG_OVERHEAD	(14 + 20 + 8)	/* Ethernet + IP + UDP headers */
43 
44 struct bootp {
45     unsigned char    bp_op;			/* packet opcode type */
46     unsigned char    bp_htype;			/* hardware addr type */
47     unsigned char    bp_hlen;			/* hardware addr length */
48     unsigned char    bp_hops;			/* gateway hops */
49     u_int32	     bp_xid;			/* transaction ID */
50     unsigned short   bp_secs;			/* seconds since boot began */
51     unsigned short   bp_flags;			/* RFC1532 broadcast, etc. */
52     struct in_addr   bp_ciaddr;			/* client IP address */
53     struct in_addr   bp_yiaddr;			/* 'your' IP address */
54     struct in_addr   bp_siaddr;			/* server IP address */
55     struct in_addr   bp_giaddr;			/* gateway IP address */
56     unsigned char    bp_chaddr[BP_CHADDR_LEN];	/* client hardware address */
57     char	     bp_sname[BP_SNAME_LEN];	/* server host name */
58     char	     bp_file[BP_FILE_LEN];	/* boot file name */
59     unsigned char    bp_vend[BP_VEND_LEN];	/* vendor-specific area */
60     /* note that bp_vend can be longer, extending to end of packet. */
61 };
62 
63 /*
64  * UDP port numbers, server and client.
65  */
66 #define	IPPORT_BOOTPS		67
67 #define	IPPORT_BOOTPC		68
68 
69 #define BOOTREPLY		2
70 #define BOOTREQUEST		1
71 
72 /*
73  * Hardware types from Assigned Numbers RFC.
74  */
75 #define HTYPE_ETHERNET		  1
76 #define HTYPE_EXP_ETHERNET	  2
77 #define HTYPE_AX25		  3
78 #define HTYPE_PRONET		  4
79 #define HTYPE_CHAOS		  5
80 #define HTYPE_IEEE802		  6
81 #define HTYPE_ARCNET		  7
82 
83 /*
84  * Vendor magic cookie (v_magic) for CMU
85  */
86 #define VM_CMU		"CMU"
87 
88 /*
89  * Vendor magic cookie (v_magic) for RFC1048
90  */
91 #define VM_RFC1048	{ 99, 130, 83, 99 }
92 
93 
94 
95 /*
96  * Tag values used to specify what information is being supplied in
97  * the vendor (options) data area of the packet.
98  */
99 /* RFC 1048 */
100 #define TAG_END			((unsigned char) 255)
101 #define TAG_PAD			((unsigned char)   0)
102 #define TAG_SUBNET_MASK		((unsigned char)   1)
103 #define TAG_TIME_OFFSET		((unsigned char)   2)
104 #define TAG_GATEWAY		((unsigned char)   3)
105 #define TAG_TIME_SERVER		((unsigned char)   4)
106 #define TAG_NAME_SERVER		((unsigned char)   5)
107 #define TAG_DOMAIN_SERVER	((unsigned char)   6)
108 #define TAG_LOG_SERVER		((unsigned char)   7)
109 #define TAG_COOKIE_SERVER	((unsigned char)   8)
110 #define TAG_LPR_SERVER		((unsigned char)   9)
111 #define TAG_IMPRESS_SERVER	((unsigned char)  10)
112 #define TAG_RLP_SERVER		((unsigned char)  11)
113 #define TAG_HOST_NAME		((unsigned char)  12)
114 #define TAG_BOOT_SIZE		((unsigned char)  13)
115 /* RFC 1395 */
116 #define TAG_DUMP_FILE		((unsigned char)  14)
117 #define TAG_DOMAIN_NAME		((unsigned char)  15)
118 #define TAG_SWAP_SERVER		((unsigned char)  16)
119 #define TAG_ROOT_PATH		((unsigned char)  17)
120 /* RFC 1497 */
121 #define TAG_EXTEN_FILE		((unsigned char)  18)
122 /* RFC 1533 */
123 #define TAG_NIS_DOMAIN		((unsigned char)  40)
124 #define TAG_NIS_SERVER		((unsigned char)  41)
125 #define TAG_NTP_SERVER		((unsigned char)  42)
126 /* DHCP maximum message size. */
127 #define TAG_MAX_MSGSZ		((unsigned char)  57)
128 
129 /* XXX - Add new tags here */
130 
131 
132 /*
133  * "vendor" data permitted for CMU bootp clients.
134  */
135 
136 struct cmu_vend {
137 	char		v_magic[4];	/* magic number */
138 	u_int32		v_flags;	/* flags/opcodes, etc. */
139 	struct in_addr 	v_smask;	/* Subnet mask */
140 	struct in_addr 	v_dgate;	/* Default gateway */
141 	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
142 	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
143 	struct in_addr	v_ts1, v_ts2;	/* Time servers */
144 	int32		v_unused[6];	/* currently unused */
145 };
146 
147 
148 /* v_flags values */
149 #define VF_SMASK	1	/* Subnet mask field contains valid data */
150