xref: /illumos-gate/usr/src/boot/lib/libstand/bootp.h (revision 734b3a42)
1199767f8SToomas Soome /*
2199767f8SToomas Soome  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
3199767f8SToomas Soome  *
4199767f8SToomas Soome  * This file specifies the "implementation-independent" BOOTP protocol
5199767f8SToomas Soome  * information which is common to both client and server.
6199767f8SToomas Soome  *
7199767f8SToomas Soome  * Copyright 1988 by Carnegie Mellon.
8199767f8SToomas Soome  *
9199767f8SToomas Soome  * Permission to use, copy, modify, and distribute this program for any
10199767f8SToomas Soome  * purpose and without fee is hereby granted, provided that this copyright
11199767f8SToomas Soome  * and permission notice appear on all copies and supporting documentation,
12199767f8SToomas Soome  * the name of Carnegie Mellon not be used in advertising or publicity
13199767f8SToomas Soome  * pertaining to distribution of the program without specific prior
14199767f8SToomas Soome  * permission, and notice be given in supporting documentation that copying
15199767f8SToomas Soome  * and distribution is by permission of Carnegie Mellon and Stanford
16199767f8SToomas Soome  * University.  Carnegie Mellon makes no representations about the
17199767f8SToomas Soome  * suitability of this software for any purpose.  It is provided "as is"
18199767f8SToomas Soome  * without express or implied warranty.
19199767f8SToomas Soome  */
20199767f8SToomas Soome 
217ee17e4eSToomas Soome #ifndef _BOOTP_H_
227ee17e4eSToomas Soome #define	_BOOTP_H_
23199767f8SToomas Soome 
24*734b3a42SToomas Soome #include <netinet/in.h>
25*734b3a42SToomas Soome 
26199767f8SToomas Soome struct bootp {
27199767f8SToomas Soome 	unsigned char	bp_op;		/* packet opcode type */
28199767f8SToomas Soome 	unsigned char	bp_htype;	/* hardware addr type */
29199767f8SToomas Soome 	unsigned char	bp_hlen;	/* hardware addr length */
30199767f8SToomas Soome 	unsigned char	bp_hops;	/* gateway hops */
31199767f8SToomas Soome 	unsigned int	bp_xid;		/* transaction ID */
32199767f8SToomas Soome 	unsigned short	bp_secs;	/* seconds since boot began */
33199767f8SToomas Soome 	unsigned short	bp_flags;
34199767f8SToomas Soome 	struct in_addr	bp_ciaddr;	/* client IP address */
35199767f8SToomas Soome 	struct in_addr	bp_yiaddr;	/* 'your' IP address */
36199767f8SToomas Soome 	struct in_addr	bp_siaddr;	/* server IP address */
37199767f8SToomas Soome 	struct in_addr	bp_giaddr;	/* gateway IP address */
38199767f8SToomas Soome 	unsigned char	bp_chaddr[16];	/* client hardware address */
39199767f8SToomas Soome 	unsigned char	bp_sname[64];	/* server host name */
4038005992SToomas Soome 	char	bp_file[128];		/* boot file name */
41199767f8SToomas Soome #ifdef SUPPORT_DHCP
42*734b3a42SToomas Soome #define	BOOTP_VENDSIZE 312
43199767f8SToomas Soome #else
44*734b3a42SToomas Soome #define	BOOTP_VENDSIZE 64
45199767f8SToomas Soome #endif
46*734b3a42SToomas Soome 	unsigned char	bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */
47199767f8SToomas Soome };
48199767f8SToomas Soome 
49199767f8SToomas Soome /*
50199767f8SToomas Soome  * UDP port numbers, server and client.
51199767f8SToomas Soome  */
52199767f8SToomas Soome #define	IPPORT_BOOTPS		67
53199767f8SToomas Soome #define	IPPORT_BOOTPC		68
54199767f8SToomas Soome 
55*734b3a42SToomas Soome #define	BOOTREPLY		2
56*734b3a42SToomas Soome #define	BOOTREQUEST		1
57199767f8SToomas Soome 
58199767f8SToomas Soome 
59199767f8SToomas Soome /*
60199767f8SToomas Soome  * Vendor magic cookie (v_magic) for CMU
61199767f8SToomas Soome  */
62*734b3a42SToomas Soome #define	VM_CMU		"CMU"
63199767f8SToomas Soome 
64199767f8SToomas Soome /*
65199767f8SToomas Soome  * Vendor magic cookie (v_magic) for RFC1048
66199767f8SToomas Soome  */
67*734b3a42SToomas Soome #define	VM_RFC1048	{ 99, 130, 83, 99 }
68199767f8SToomas Soome 
69199767f8SToomas Soome /*
70199767f8SToomas Soome  * RFC1048 tag values used to specify what information is being supplied in
71199767f8SToomas Soome  * the vendor field of the packet.
72199767f8SToomas Soome  */
73199767f8SToomas Soome 
74*734b3a42SToomas Soome #define	TAG_PAD			((unsigned char)   0)
75*734b3a42SToomas Soome #define	TAG_SUBNET_MASK		((unsigned char)   1)
76*734b3a42SToomas Soome #define	TAG_TIME_OFFSET		((unsigned char)   2)
77*734b3a42SToomas Soome #define	TAG_GATEWAY		((unsigned char)   3)
78*734b3a42SToomas Soome #define	TAG_TIME_SERVER		((unsigned char)   4)
79*734b3a42SToomas Soome #define	TAG_NAME_SERVER		((unsigned char)   5)
80*734b3a42SToomas Soome #define	TAG_DOMAIN_SERVER	((unsigned char)   6)
81*734b3a42SToomas Soome #define	TAG_LOG_SERVER		((unsigned char)   7)
82*734b3a42SToomas Soome #define	TAG_COOKIE_SERVER	((unsigned char)   8)
83*734b3a42SToomas Soome #define	TAG_LPR_SERVER		((unsigned char)   9)
84*734b3a42SToomas Soome #define	TAG_IMPRESS_SERVER	((unsigned char)  10)
85*734b3a42SToomas Soome #define	TAG_RLP_SERVER		((unsigned char)  11)
86*734b3a42SToomas Soome #define	TAG_HOSTNAME		((unsigned char)  12)
87*734b3a42SToomas Soome #define	TAG_BOOTSIZE		((unsigned char)  13)
88*734b3a42SToomas Soome #define	TAG_DUMPFILE		((unsigned char)  14)
89*734b3a42SToomas Soome #define	TAG_DOMAINNAME		((unsigned char)  15)
90*734b3a42SToomas Soome #define	TAG_SWAPSERVER		((unsigned char)  16)
91*734b3a42SToomas Soome #define	TAG_ROOTPATH		((unsigned char)  17)
92c21cf554SToomas Soome #define	TAG_INTF_MTU		((unsigned char)  26)
93199767f8SToomas Soome 
94199767f8SToomas Soome #ifdef SUPPORT_DHCP
95*734b3a42SToomas Soome #define	TAG_REQ_ADDR		((unsigned char)  50)
96*734b3a42SToomas Soome #define	TAG_LEASETIME		((unsigned char)  51)
97*734b3a42SToomas Soome #define	TAG_OVERLOAD		((unsigned char)  52)
98*734b3a42SToomas Soome #define	TAG_DHCP_MSGTYPE	((unsigned char)  53)
99*734b3a42SToomas Soome #define	TAG_SERVERID		((unsigned char)  54)
100*734b3a42SToomas Soome #define	TAG_PARAM_REQ		((unsigned char)  55)
101*734b3a42SToomas Soome #define	TAG_MSG			((unsigned char)  56)
102*734b3a42SToomas Soome #define	TAG_MAXSIZE		((unsigned char)  57)
103*734b3a42SToomas Soome #define	TAG_T1			((unsigned char)  58)
104*734b3a42SToomas Soome #define	TAG_T2			((unsigned char)  59)
105*734b3a42SToomas Soome #define	TAG_CLASSID		((unsigned char)  60)
106*734b3a42SToomas Soome #define	TAG_CLIENTID		((unsigned char)  61)
107*734b3a42SToomas Soome #define	TAG_USER_CLASS		((unsigned char)  77)
108199767f8SToomas Soome #endif
109199767f8SToomas Soome 
110*734b3a42SToomas Soome #define	TAG_END			((unsigned char) 255)
111199767f8SToomas Soome 
112199767f8SToomas Soome #ifdef SUPPORT_DHCP
113*734b3a42SToomas Soome #define	DHCPDISCOVER 1
114*734b3a42SToomas Soome #define	DHCPOFFER 2
115*734b3a42SToomas Soome #define	DHCPREQUEST 3
116*734b3a42SToomas Soome #define	DHCPDECLINE 4
117*734b3a42SToomas Soome #define	DHCPACK 5
118*734b3a42SToomas Soome #define	DHCPNAK 6
119*734b3a42SToomas Soome #define	DHCPRELEASE 7
120199767f8SToomas Soome #endif
121199767f8SToomas Soome 
122199767f8SToomas Soome /*
123199767f8SToomas Soome  * "vendor" data permitted for CMU bootp clients.
124199767f8SToomas Soome  */
125199767f8SToomas Soome 
126199767f8SToomas Soome struct cmu_vend {
127199767f8SToomas Soome 	unsigned char	v_magic[4];	/* magic number */
128199767f8SToomas Soome 	unsigned int	v_flags;	/* flags/opcodes, etc. */
129199767f8SToomas Soome 	struct in_addr	v_smask;	/* Subnet mask */
130199767f8SToomas Soome 	struct in_addr	v_dgate;	/* Default gateway */
131199767f8SToomas Soome 	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
132199767f8SToomas Soome 	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
133199767f8SToomas Soome 	struct in_addr	v_ts1, v_ts2;	/* Time servers */
134199767f8SToomas Soome 	unsigned char	v_unused[25];	/* currently unused */
135199767f8SToomas Soome };
136199767f8SToomas Soome 
137199767f8SToomas Soome 
138199767f8SToomas Soome /* v_flags values */
139*734b3a42SToomas Soome #define	VF_SMASK	1	/* Subnet mask field contains valid data */
1407ee17e4eSToomas Soome 
141f9feecc1SToomas Soome /* cached bootp response/dhcp ack */
142f9feecc1SToomas Soome extern struct bootp *bootp_response;
143859472daSToomas Soome extern size_t bootp_response_size;
144f9feecc1SToomas Soome 
1457ee17e4eSToomas Soome #endif /* _BOOTP_H_ */