xref: /titanic_51/usr/src/boot/lib/libstand/bootp.h (revision 59dfa57d51ab43df898b757f7913486cd6da89cb)
14a5d661aSToomas Soome /*	$NetBSD: bootp.h,v 1.4 1997/09/06 13:55:57 drochner Exp $	*/
24a5d661aSToomas Soome 
34a5d661aSToomas Soome /*
44a5d661aSToomas Soome  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
54a5d661aSToomas Soome  *
64a5d661aSToomas Soome  * This file specifies the "implementation-independent" BOOTP protocol
74a5d661aSToomas Soome  * information which is common to both client and server.
84a5d661aSToomas Soome  *
94a5d661aSToomas Soome  * Copyright 1988 by Carnegie Mellon.
104a5d661aSToomas Soome  *
114a5d661aSToomas Soome  * Permission to use, copy, modify, and distribute this program for any
124a5d661aSToomas Soome  * purpose and without fee is hereby granted, provided that this copyright
134a5d661aSToomas Soome  * and permission notice appear on all copies and supporting documentation,
144a5d661aSToomas Soome  * the name of Carnegie Mellon not be used in advertising or publicity
154a5d661aSToomas Soome  * pertaining to distribution of the program without specific prior
164a5d661aSToomas Soome  * permission, and notice be given in supporting documentation that copying
174a5d661aSToomas Soome  * and distribution is by permission of Carnegie Mellon and Stanford
184a5d661aSToomas Soome  * University.  Carnegie Mellon makes no representations about the
194a5d661aSToomas Soome  * suitability of this software for any purpose.  It is provided "as is"
204a5d661aSToomas Soome  * without express or implied warranty.
214a5d661aSToomas Soome  */
224a5d661aSToomas Soome 
23*59dfa57dSToomas Soome #include <netinet/in.h>
24*59dfa57dSToomas Soome 
257b0ff4b9SToomas Soome #ifndef _BOOTP_H_
267b0ff4b9SToomas Soome #define	_BOOTP_H_
274a5d661aSToomas Soome 
284a5d661aSToomas Soome struct bootp {
294a5d661aSToomas Soome 	unsigned char	bp_op;		/* packet opcode type */
304a5d661aSToomas Soome 	unsigned char	bp_htype;	/* hardware addr type */
314a5d661aSToomas Soome 	unsigned char	bp_hlen;	/* hardware addr length */
324a5d661aSToomas Soome 	unsigned char	bp_hops;	/* gateway hops */
334a5d661aSToomas Soome 	unsigned int	bp_xid;		/* transaction ID */
344a5d661aSToomas Soome 	unsigned short	bp_secs;	/* seconds since boot began */
354a5d661aSToomas Soome 	unsigned short	bp_flags;
364a5d661aSToomas Soome 	struct in_addr	bp_ciaddr;	/* client IP address */
374a5d661aSToomas Soome 	struct in_addr	bp_yiaddr;	/* 'your' IP address */
384a5d661aSToomas Soome 	struct in_addr	bp_siaddr;	/* server IP address */
394a5d661aSToomas Soome 	struct in_addr	bp_giaddr;	/* gateway IP address */
404a5d661aSToomas Soome 	unsigned char	bp_chaddr[16];	/* client hardware address */
414a5d661aSToomas Soome 	unsigned char	bp_sname[64];	/* server host name */
424a5d661aSToomas Soome 	unsigned char	bp_file[128];	/* boot file name */
434a5d661aSToomas Soome #ifdef SUPPORT_DHCP
444a5d661aSToomas Soome #define BOOTP_VENDSIZE 312
454a5d661aSToomas Soome #else
464a5d661aSToomas Soome #define BOOTP_VENDSIZE 64
474a5d661aSToomas Soome #endif
484a5d661aSToomas Soome 	unsigned char	bp_vend[BOOTP_VENDSIZE];	/* vendor-specific area */
494a5d661aSToomas Soome };
504a5d661aSToomas Soome 
514a5d661aSToomas Soome /*
524a5d661aSToomas Soome  * UDP port numbers, server and client.
534a5d661aSToomas Soome  */
544a5d661aSToomas Soome #define	IPPORT_BOOTPS		67
554a5d661aSToomas Soome #define	IPPORT_BOOTPC		68
564a5d661aSToomas Soome 
574a5d661aSToomas Soome #define BOOTREPLY		2
584a5d661aSToomas Soome #define BOOTREQUEST		1
594a5d661aSToomas Soome 
604a5d661aSToomas Soome 
614a5d661aSToomas Soome /*
624a5d661aSToomas Soome  * Vendor magic cookie (v_magic) for CMU
634a5d661aSToomas Soome  */
644a5d661aSToomas Soome #define VM_CMU		"CMU"
654a5d661aSToomas Soome 
664a5d661aSToomas Soome /*
674a5d661aSToomas Soome  * Vendor magic cookie (v_magic) for RFC1048
684a5d661aSToomas Soome  */
694a5d661aSToomas Soome #define VM_RFC1048	{ 99, 130, 83, 99 }
704a5d661aSToomas Soome 
714a5d661aSToomas Soome 
724a5d661aSToomas Soome 
734a5d661aSToomas Soome /*
744a5d661aSToomas Soome  * RFC1048 tag values used to specify what information is being supplied in
754a5d661aSToomas Soome  * the vendor field of the packet.
764a5d661aSToomas Soome  */
774a5d661aSToomas Soome 
784a5d661aSToomas Soome #define TAG_PAD			((unsigned char)   0)
794a5d661aSToomas Soome #define TAG_SUBNET_MASK		((unsigned char)   1)
804a5d661aSToomas Soome #define TAG_TIME_OFFSET		((unsigned char)   2)
814a5d661aSToomas Soome #define TAG_GATEWAY		((unsigned char)   3)
824a5d661aSToomas Soome #define TAG_TIME_SERVER		((unsigned char)   4)
834a5d661aSToomas Soome #define TAG_NAME_SERVER		((unsigned char)   5)
844a5d661aSToomas Soome #define TAG_DOMAIN_SERVER	((unsigned char)   6)
854a5d661aSToomas Soome #define TAG_LOG_SERVER		((unsigned char)   7)
864a5d661aSToomas Soome #define TAG_COOKIE_SERVER	((unsigned char)   8)
874a5d661aSToomas Soome #define TAG_LPR_SERVER		((unsigned char)   9)
884a5d661aSToomas Soome #define TAG_IMPRESS_SERVER	((unsigned char)  10)
894a5d661aSToomas Soome #define TAG_RLP_SERVER		((unsigned char)  11)
904a5d661aSToomas Soome #define TAG_HOSTNAME		((unsigned char)  12)
914a5d661aSToomas Soome #define TAG_BOOTSIZE		((unsigned char)  13)
924a5d661aSToomas Soome #define TAG_DUMPFILE		((unsigned char)  14)
934a5d661aSToomas Soome #define TAG_DOMAINNAME		((unsigned char)  15)
944a5d661aSToomas Soome #define TAG_SWAPSERVER		((unsigned char)  16)
954a5d661aSToomas Soome #define TAG_ROOTPATH		((unsigned char)  17)
96e1bd2803SToomas Soome #define	TAG_INTF_MTU		((unsigned char)  26)
974a5d661aSToomas Soome 
984a5d661aSToomas Soome #ifdef SUPPORT_DHCP
994a5d661aSToomas Soome #define TAG_REQ_ADDR		((unsigned char)  50)
1004a5d661aSToomas Soome #define TAG_LEASETIME		((unsigned char)  51)
1014a5d661aSToomas Soome #define TAG_OVERLOAD		((unsigned char)  52)
1024a5d661aSToomas Soome #define TAG_DHCP_MSGTYPE	((unsigned char)  53)
1034a5d661aSToomas Soome #define TAG_SERVERID		((unsigned char)  54)
1044a5d661aSToomas Soome #define TAG_PARAM_REQ		((unsigned char)  55)
1054a5d661aSToomas Soome #define TAG_MSG			((unsigned char)  56)
1064a5d661aSToomas Soome #define TAG_MAXSIZE		((unsigned char)  57)
1074a5d661aSToomas Soome #define TAG_T1			((unsigned char)  58)
1084a5d661aSToomas Soome #define TAG_T2			((unsigned char)  59)
1094a5d661aSToomas Soome #define TAG_CLASSID		((unsigned char)  60)
1104a5d661aSToomas Soome #define TAG_CLIENTID		((unsigned char)  61)
1114a5d661aSToomas Soome #endif
1124a5d661aSToomas Soome 
1134a5d661aSToomas Soome #define TAG_END			((unsigned char) 255)
1144a5d661aSToomas Soome 
1154a5d661aSToomas Soome #ifdef SUPPORT_DHCP
1164a5d661aSToomas Soome #define DHCPDISCOVER 1
1174a5d661aSToomas Soome #define DHCPOFFER 2
1184a5d661aSToomas Soome #define DHCPREQUEST 3
1194a5d661aSToomas Soome #define DHCPDECLINE 4
1204a5d661aSToomas Soome #define DHCPACK 5
1214a5d661aSToomas Soome #define DHCPNAK 6
1224a5d661aSToomas Soome #define DHCPRELEASE 7
1234a5d661aSToomas Soome #endif
1244a5d661aSToomas Soome 
1254a5d661aSToomas Soome /*
1264a5d661aSToomas Soome  * bootp flags
1274a5d661aSToomas Soome  */
1284a5d661aSToomas Soome #define	BOOTP_NONE		0x0000		/* No flags */
1294a5d661aSToomas Soome #define	BOOTP_PXE		0x0001		/* Booting from PXE. */
1304a5d661aSToomas Soome 
1314a5d661aSToomas Soome /*
1324a5d661aSToomas Soome  * "vendor" data permitted for CMU bootp clients.
1334a5d661aSToomas Soome  */
1344a5d661aSToomas Soome 
1354a5d661aSToomas Soome struct cmu_vend {
1364a5d661aSToomas Soome 	unsigned char	v_magic[4];	/* magic number */
1374a5d661aSToomas Soome 	unsigned int	v_flags;	/* flags/opcodes, etc. */
1384a5d661aSToomas Soome 	struct in_addr	v_smask;	/* Subnet mask */
1394a5d661aSToomas Soome 	struct in_addr	v_dgate;	/* Default gateway */
1404a5d661aSToomas Soome 	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
1414a5d661aSToomas Soome 	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
1424a5d661aSToomas Soome 	struct in_addr	v_ts1, v_ts2;	/* Time servers */
1434a5d661aSToomas Soome 	unsigned char	v_unused[25];	/* currently unused */
1444a5d661aSToomas Soome };
1454a5d661aSToomas Soome 
1464a5d661aSToomas Soome 
1474a5d661aSToomas Soome /* v_flags values */
1484a5d661aSToomas Soome #define VF_SMASK	1	/* Subnet mask field contains valid data */
1497b0ff4b9SToomas Soome 
150*59dfa57dSToomas Soome /* cached bootp response/dhcp ack */
151*59dfa57dSToomas Soome extern struct bootp *bootp_response;
152*59dfa57dSToomas Soome 
1537b0ff4b9SToomas Soome int	dhcp_try_rfc1048(uint8_t *cp, size_t len);
1547b0ff4b9SToomas Soome 
1557b0ff4b9SToomas Soome #endif /* _BOOTP_H_ */
156