13229Spst/************************************************************************ 23229Spst Copyright 1988, 1991 by Carnegie Mellon University 33229Spst 43229Spst All Rights Reserved 53229Spst 63229SpstPermission to use, copy, modify, and distribute this software and its 73229Spstdocumentation for any purpose and without fee is hereby granted, provided 83229Spstthat the above copyright notice appear in all copies and that both that 93229Spstcopyright notice and this permission notice appear in supporting 103229Spstdocumentation, and that the name of Carnegie Mellon University not be used 113229Spstin advertising or publicity pertaining to distribution of the software 123229Spstwithout specific, written prior permission. 133229Spst 143229SpstCARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 153229SpstSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 163229SpstIN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 173229SpstDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 183229SpstPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 193229SpstACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 203229SpstSOFTWARE. 213229Spst************************************************************************/ 223229Spst 233229Spst/* 243229Spst * Bootstrap Protocol (BOOTP). RFC951 and RFC1395. 253229Spst * 2650476Speter * $FreeBSD$ 273229Spst * 283229Spst * 293229Spst * This file specifies the "implementation-independent" BOOTP protocol 303229Spst * information which is common to both client and server. 313229Spst * 323229Spst */ 333229Spst 343229Spst#include "bptypes.h" /* for int32, u_int32 */ 353229Spst 363229Spst#define BP_CHADDR_LEN 16 373229Spst#define BP_SNAME_LEN 64 383229Spst#define BP_FILE_LEN 128 393229Spst#define BP_VEND_LEN 64 403229Spst#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */ 4183941Siedowse/* Overhead to fit a bootp message into an Ethernet packet. */ 4283941Siedowse#define BP_MSG_OVERHEAD (14 + 20 + 8) /* Ethernet + IP + UDP headers */ 433229Spst 443229Spststruct bootp { 453229Spst unsigned char bp_op; /* packet opcode type */ 463229Spst unsigned char bp_htype; /* hardware addr type */ 473229Spst unsigned char bp_hlen; /* hardware addr length */ 483229Spst unsigned char bp_hops; /* gateway hops */ 4953105Smarcel u_int32 bp_xid; /* transaction ID */ 503229Spst unsigned short bp_secs; /* seconds since boot began */ 513229Spst unsigned short bp_flags; /* RFC1532 broadcast, etc. */ 523229Spst struct in_addr bp_ciaddr; /* client IP address */ 533229Spst struct in_addr bp_yiaddr; /* 'your' IP address */ 543229Spst struct in_addr bp_siaddr; /* server IP address */ 553229Spst struct in_addr bp_giaddr; /* gateway IP address */ 563229Spst unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */ 573229Spst char bp_sname[BP_SNAME_LEN]; /* server host name */ 583229Spst char bp_file[BP_FILE_LEN]; /* boot file name */ 593229Spst unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */ 603229Spst /* note that bp_vend can be longer, extending to end of packet. */ 613229Spst}; 623229Spst 633229Spst/* 643229Spst * UDP port numbers, server and client. 653229Spst */ 663229Spst#define IPPORT_BOOTPS 67 673229Spst#define IPPORT_BOOTPC 68 683229Spst 693229Spst#define BOOTREPLY 2 703229Spst#define BOOTREQUEST 1 713229Spst 723229Spst/* 733229Spst * Hardware types from Assigned Numbers RFC. 743229Spst */ 753229Spst#define HTYPE_ETHERNET 1 763229Spst#define HTYPE_EXP_ETHERNET 2 773229Spst#define HTYPE_AX25 3 783229Spst#define HTYPE_PRONET 4 793229Spst#define HTYPE_CHAOS 5 803229Spst#define HTYPE_IEEE802 6 813229Spst#define HTYPE_ARCNET 7 823229Spst 833229Spst/* 843229Spst * Vendor magic cookie (v_magic) for CMU 853229Spst */ 863229Spst#define VM_CMU "CMU" 873229Spst 883229Spst/* 893229Spst * Vendor magic cookie (v_magic) for RFC1048 903229Spst */ 913229Spst#define VM_RFC1048 { 99, 130, 83, 99 } 923229Spst 933229Spst 943229Spst 953229Spst/* 963229Spst * Tag values used to specify what information is being supplied in 973229Spst * the vendor (options) data area of the packet. 983229Spst */ 993229Spst/* RFC 1048 */ 1003229Spst#define TAG_END ((unsigned char) 255) 1013229Spst#define TAG_PAD ((unsigned char) 0) 1023229Spst#define TAG_SUBNET_MASK ((unsigned char) 1) 1033229Spst#define TAG_TIME_OFFSET ((unsigned char) 2) 1043229Spst#define TAG_GATEWAY ((unsigned char) 3) 1053229Spst#define TAG_TIME_SERVER ((unsigned char) 4) 1063229Spst#define TAG_NAME_SERVER ((unsigned char) 5) 1073229Spst#define TAG_DOMAIN_SERVER ((unsigned char) 6) 1083229Spst#define TAG_LOG_SERVER ((unsigned char) 7) 1093229Spst#define TAG_COOKIE_SERVER ((unsigned char) 8) 1103229Spst#define TAG_LPR_SERVER ((unsigned char) 9) 1113229Spst#define TAG_IMPRESS_SERVER ((unsigned char) 10) 1123229Spst#define TAG_RLP_SERVER ((unsigned char) 11) 1133229Spst#define TAG_HOST_NAME ((unsigned char) 12) 1143229Spst#define TAG_BOOT_SIZE ((unsigned char) 13) 1153229Spst/* RFC 1395 */ 1163229Spst#define TAG_DUMP_FILE ((unsigned char) 14) 1173229Spst#define TAG_DOMAIN_NAME ((unsigned char) 15) 1183229Spst#define TAG_SWAP_SERVER ((unsigned char) 16) 1193229Spst#define TAG_ROOT_PATH ((unsigned char) 17) 1203229Spst/* RFC 1497 */ 1213229Spst#define TAG_EXTEN_FILE ((unsigned char) 18) 1223229Spst/* RFC 1533 */ 1233229Spst#define TAG_NIS_DOMAIN ((unsigned char) 40) 1243229Spst#define TAG_NIS_SERVER ((unsigned char) 41) 1253229Spst#define TAG_NTP_SERVER ((unsigned char) 42) 1263229Spst/* DHCP maximum message size. */ 1273229Spst#define TAG_MAX_MSGSZ ((unsigned char) 57) 1283229Spst 1293229Spst/* XXX - Add new tags here */ 1303229Spst 1313229Spst 1323229Spst/* 1333229Spst * "vendor" data permitted for CMU bootp clients. 1343229Spst */ 1353229Spst 1363229Spststruct cmu_vend { 1373229Spst char v_magic[4]; /* magic number */ 13853105Smarcel u_int32 v_flags; /* flags/opcodes, etc. */ 1393229Spst struct in_addr v_smask; /* Subnet mask */ 1403229Spst struct in_addr v_dgate; /* Default gateway */ 1413229Spst struct in_addr v_dns1, v_dns2; /* Domain name servers */ 1423229Spst struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ 1433229Spst struct in_addr v_ts1, v_ts2; /* Time servers */ 1443229Spst int32 v_unused[6]; /* currently unused */ 1453229Spst}; 1463229Spst 1473229Spst 1483229Spst/* v_flags values */ 1493229Spst#define VF_SMASK 1 /* Subnet mask field contains valid data */ 150