/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * This describes an implementation of the DHCP (RFC2131, RFC2132) protocol
 * for internet bootstrapping.
 *
 * There is only one UDP packet format, used by both client and server.
 * The client should zero all unused entries.
 */

#define DHCP_server     67
#define DHCP_client     68

#define CHADDR_MAX      16
#define SNAME_MAX       64
#define FILE_MAX        128
#define OPTIONS_MAX     312

typedef struct { /* C = Must be set by client,  c = may be set by client */
                 /* S = Must be set by server,  s = may be set by server */
                 /* G = Must be set by gateway, g = may be set by gateway*/
  u_char  op,                 /* C S - BOOTREQUEST or BOOTREPLY */
          htype,              /* C   - Hardware type */
          hlen,               /* C   - Length of hardware address */
          hops;               /*  g  - Hop count (used by gateways) */
  u_long  xid;                /* C   - Transaction id */
  u_short secs,               /* C   - Seconds elapsed since start of boot */
          flags;
  u_long  ciaddr,             /* c   - Client  IP address (if known by client) */
          yiaddr,             /*   S - Client  IP address */
          siaddr,             /*   S - Server  IP address */
          giaddr;             /*  gs - Gateway IP address */
  u_char  chaddr[CHADDR_MAX]; /* C   - Client hardware address */
  u_char  sname[SNAME_MAX];   /* c S - Server hostname name */
  u_char  file[FILE_MAX];     /* c S - File name to boot */
  u_char  options[OPTIONS_MAX]; /* c s - optional parameters */
} BOOTP;

/* This structure is the parameter for the SIOCGWHOIAMD ioctl */
typedef struct ifdhcpreq {
  struct ifreq ifr;
  BOOTP packet;
} ifdhcpreq;

#define BOOTREQUEST     1
#define BOOTREPLY       2

#define DHCPDISCOVER    1
#define DHCPOFFER       2
#define DHCPREQUEST     3
#define DHCPDECLINE     4
#define DHCPACK         5
#define DHCPNAK         6
#define DHCPRELEASE     7
#define DHCPINFORM      8

#define ETHERNET_TYPE   1       /* ethernet hardware type */
#define TOKENRING_TYPE  4       /* token ring hardware type */
#define IEEE802_TYPE    6       /* IEEE 802 hardware type */
#define SERIAL_TYPE     20      /* serial line hardware type */

#define ETHERNET_LEN    6       /* ethernet hardware byte length */

/* 19980821: sbrodie: The comment used to say "network byte order" but
 * this is wrong.  The value stated here is in HOST byte order.
 * This "confused" the Internet 5.0x modules' vendor block validation code.
 * See TCP/IP Illus. for docs.  Fake IP address is 99.130.83.99
 */
#define OPTIONS_COOKIE	0x63825363 /* host byte order */

/* RFC 1497 Vendor Extensions */
#define OPTION_PAD		0	/* Pad Option */
#define OPTION_NETMASK  	1       /* Subnet Mask */
#define OPTION_TIMEOFFSET	2       /* Time Offset */
#define OPTION_ROUTER		3       /* Router Option */
#define OPTION_TIMESERVER	4       /* Time Server Option */
#define OPTION_IEN116SERVER	5       /* Name Server Option */
#define OPTION_NAMESERVER	6       /* Domain Name Server Option */
#define OPTION_LOGSERVER	7       /* Log Server Option */
#define OPTION_COOKIESERVER	8       /* Cookie Server Option */
#define OPTION_LPRSERVER	9       /* LPR Server Option */
#define OPTION_IMPRESSSERVER	10      /* Impress Server Option */
#define OPTION_RESOURCESERVER	11      /* Resource Location Server Option */
#define OPTION_HOSTNAME		12      /* Host Name Option */
#define OPTION_BOOTFILESIZE	13      /* Boot File Size Option */
#define OPTION_MERITDUMPFILE    14      /* Merit Dump File */
#define OPTION_DOMAINNAME       15      /* Domain Name */
#define OPTION_SWAPSERVER       16      /* Swap Server */
#define OPTION_ROOTPATH         17      /* Root Path */
#define OPTION_EXTENSIONSPATH   18      /* Extensions Path */

/* IP Layer Parameters per Host */
#define OPTION_IPFORWARDING     19      /* IP Forwarding Enable/Disable Option */
#define OPTION_SOURCEROUTING    20      /* Non-Local Source Routing Enable/Disable Option */
#define OPTION_POLICYFILTER     21      /* Policy Filter Option */
#define OPTION_REASSEMBLYSIZE   22      /* Maximum Datagram Reassembly Size */
#define OPTION_IPTTL            23      /* Default IP Time-to-live */
#define OPTION_PATHMTUTIMEOUT   24      /* Path MTU Aging Timeout Option */
#define OPTION_PATHMTUTABLE     25      /* Path MTU Plateau Table Option */

/* IP Layer Parameters per Interface */
#define OPTION_INTERFACEMTU     26      /* Interface MTU Option */
#define OPTION_SUBNETSARELOCAL  27      /* All Subnets are Local Option */
#define OPTION_BROADCASTADDRESS 28      /* Broadcast Address Option */
#define OPTION_ICMPMASKDISCOVERY 29     /* Perform Mask Discovery Option */
#define OPTION_ICMPMASKSUPPLIER 30      /* Mask Supplier Option */
#define OPTION_ROUTERDISCOVERY  31      /* Perform Router Discovery Option */
#define OPTION_ROUTERSOLADDRESS 32      /* Router Solicitation Address Option */
#define OPTION_STATICROUTE      33      /* Static Route Option */

/* Link Layer Parameters per Interface */
#define OPTION_TRAILERENCAP     34      /* Trailer Encapsulation Option */
#define OPTION_ARPTIMEOUT       35      /* ARP Cache Timeout Option */
#define OPTION_ETHERNETENCAP    36      /* Ethernet Encapsulation Option */

/* TCP Parameters */
#define OPTION_TCPTTL           37      /* TCP Default TTL Option */
#define OPTION_TCPKEEPALIVE     38      /* TCP Keepalive Interval Option */
#define OPTION_TCPKEEPALIVEGRBG 39      /* TCP Keepalive Garbage Option */

/* Application and Service Parameters */
#define OPTION_NISDOMAIN        40      /* Network Information Service Domain Option */
#define OPTION_NISSERVERS       41      /* Network Information Servers Option */
#define OPTION_NTPSERVERS       42      /* Network Time Protocol Servers Option */
#define OPTION_VENDORSPECIFIC   43      /* Vendor Specific Information */
#define OPTION_NBNSSERVERS      44      /* NetBIOS over TCP/IP Name Server Option */
#define OPTION_NBDDSERVERS      45      /* NetBIOS over TCP/IP Datagram Distribution Server Option */
#define OPTION_NBNODETYPE       46      /* NetBIOS over TCP/IP Node Type Option */
#define OPTION_NBSCOPE          47      /* NetBIOS over TCP/IP Scope Option */
#define OPTION_XFONTSERVERS     48      /* X Window System Font Server Option */
#define OPTION_XDISPLAYMANAGERS 49      /* X Window System Display Manager Option */

/* DHCP Extensions */
#define OPTION_REQUESTEDIPADDR  50      /* Requested IP Address */
#define OPTION_IPADDRLEASETIME  51      /* IP Address Lease Time */
#define OPTION_OPTIONOVERLOAD   52      /* Option Overload */
#define OPTION_DHCPMESSAGETYPE  53      /* DHCP Message Type */
#define OPTION_SERVERIDENTIFIER 54      /* Server Identifier */
#define OPTION_PARAMETERREQLIST 55      /* Parameter Request List */
#define OPTION_MESSAGE          56      /* Message */
#define OPTION_MAXDHCPLENGTH    57      /* Maximum DHCP Message Size */
#define OPTION_RENEWALTIME      58      /* Renewal (T1) Time Value */
#define OPTION_REBINDINGTIME    59      /* Rebinding (T2) Time Value */
#define OPTION_CLASSIDENTIFIER  60      /* Vendor class identifier */
#define OPTION_CLIENTIDENTIFER  61      /* Client-identifier */

/* More application and Service Parameters (RFC2132) */
#define OPTION_NISPLUSDOMAIN    64      /* Client's NIS+ domain */
#define OPTION_NISPLUSSERVERS   65      /* Available NIS+ servers */
#define OPTION_TFTPSERVER       66      /* Used when sname field is overloaded */
#define OPTION_BOOTFILENAME     67      /* Used when file field is overloaded */
#define OPTION_MOBILEHOMEAGENT  68      /* Mobile IP Home Agent (list of IP addresses) */
#define OPTION_SMTPSERVERS      69      /* SMTP servers (list of IP addresses) */
#define OPTION_POP3SERVER       70      /* POP3 servers */
#define OPTION_NNTPSERVER       71      /* News servers */
#define OPTION_WWWSERVER        72      /* Web servers */
#define OPTION_FINGERSERVER     73      /* Finger servers */
#define OPTION_IRCSERVER        74      /* IRC server */
#define OPTION_STREETTALK       75      /* StreetTalk servers */
#define OPTION_STREETTALKDIR    76      /* StreetTalk directory assistance server */

/* More options added since RFC 2132 */
#define OPTION_USERCLASS	77	/* User Class Information */
#define OPTION_DIRECTORYAGENT	78	/* Directory Agent */
#define OPTION_SERVICESCOPE	79	/* Service Scope */
#define OPTION_NAMINGAUTHORITY	80	/* Naming Authority */
#define OPTION_CLIENTFQDN	81	/* Client FQDN (Fully Qualified Domain Name) */
#define OPTION_AGENTCIRCUITID	82	/* Agent Circuit ID */
#define OPTION_AGENTREMOTEID	83	/* Agent Remote ID */
#define OPTION_AGENTSUBNETMASK	84	/* Agent Subnet Mask */
#define OPTION_NDSSERVERS	85	/* NDS Servers (Novell Directory Services - RFC2241) */
#define OPTION_NDSTREENAME	86	/* NDS Tree Name */
#define OPTION_NDSCONTEXT	87	/* NDS Context */
#define OPTION_POSIXTIMEZONE	88	/* IEEE 1003.1 POSIX Timezone */
#define OPTION_FQDN		89	/* FQDNs instead of IP addresses in other options */
#define OPTION_AUTHENTICATION	90	/* DHCP authentication */
#define OPTION_VINESSERVERS	91	/* VINES TCP/IP servers */
#define OPTION_SERVERPRIORITY	92	/* DHCP Server Selection */
#define OPTION_SYSTEMARCH	93	/* Client System Architecture */
#define OPTION_NETWORKDEVICE	94	/* Client Network Device Interface */
#define OPTION_LDAPSERVERS	95	/* LDAP server URLs */
#define OPTION_IPV6ROUTERS	96	/* IPv6 Router 6over4 Address */
#define OPTION_GUID		97	/* Net PC 128-bit GUID */
#define OPTION_UAPSERVERS	98	/* User Authentication Protocol server URLs */
#define OPTION_PRINTERNAMES	100	/* Printer names */
#define OPTION_MDHCPSERVER	101	/* MDHCP Server Multicast Address */
#define OPTION_IPXCOMPATIBILITY	110	/* IPX Compatibility Sub-Options */
#define OPTION_NETINFOSERVER	112	/* NetInfo Parent Server Address */
#define OPTION_NETINFOSERVERTAG	113	/* NetInfo Parent Server Tag */
#define OPTION_URL		114	/* URL */
#define OPTION_FAILOVER		115	/* DHCP Failover protocol */
#define OPTION_AUTOCONFIGURE	116	/* Stateless Auto-Configuration (RFC 2563) */

/* Extended options */
#define OPTION_EXTENSIONREQLIST	126	/* Extended option code parameter request list */
#define OPTION_EXTENSION	127	/* Extended two-octet option code */

#define OPTION_END		255	/* End Option */

/* EOF dhcp.h */
