1 /* $OpenBSD: dhcp.h,v 1.1 2017/03/17 14:45:16 rzalamena Exp $ */ 2 3 /* 4 * Copyright (c) 2017 Rafael Zalamena <rzalamena@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _DHCP_H_ 20 #define _DHCP_H_ 21 22 /* Maximum DHCP packet size. */ 23 #define DHCP_MTU_MAX 1500 24 25 /* 26 * Enterprise numbers can be found at: 27 * http://www.iana.org/assignments/enterprise-numbers 28 */ 29 #define OPENBSD_ENTERPRISENO 30155 30 #define ENTERPRISENO_LEN sizeof(uint32_t) 31 32 /* 33 * DHCPv6 definitions and structures defined by the protocol 34 * specification (RFC 3315). 35 * 36 * The relay part of DHCPv6 is specified in section 20 of RFC 3315 and 37 * in the RFC 6221. 38 */ 39 40 /* 41 * RFC 3315 Section 5.1 Multicast Addresses: 42 * All_DHCP_Relay_Agents_and_Servers: FF02::1:2 43 * All_DHCP_Servers: FF05::1:3 44 */ 45 #define DHCP6_ADDR_RELAYSERVER "FF02::1:2" 46 #define DHCP6_ADDR_SERVER "FF05::1:3" 47 48 /* DHCPv6 client/server ports */ 49 #define DHCP6_CLIENT_PORT 546 50 #define DHCP6_CLIENT_PORT_STR "546" 51 #define DHCP6_SERVER_PORT 547 52 #define DHCP6_SERVER_PORT_STR "547" 53 54 /* DHCPv6 message types. */ 55 #define DHCP6_MT_SOLICIT 1 56 #define DHCP6_MT_ADVERTISE 2 57 #define DHCP6_MT_REQUEST 3 58 #define DHCP6_MT_CONFIRM 4 59 #define DHCP6_MT_RENEW 5 60 #define DHCP6_MT_REBIND 6 61 #define DHCP6_MT_REPLY 7 62 #define DHCP6_MT_RELEASE 8 63 #define DHCP6_MT_DECLINE 9 64 #define DHCP6_MT_RECONFIGURE 10 65 #define DHCP6_MT_INFORMATIONREQUEST 11 66 #define DHCP6_MT_RELAYFORW 12 67 #define DHCP6_MT_RELAYREPL 13 68 69 /* Maximum amount of hops limit by default. */ 70 #define DHCP6_HOP_LIMIT 32 71 72 /* DHCPv6 option definitions. */ 73 #define DHCP6_OPT_CLIENTID 1 74 #define DHCP6_OPT_SERVERID 2 75 /* IANA - Identity Association for Non-temporary Address */ 76 #define DHCP6_OPT_IANA 3 77 /* IATA - Identity Association for Temporary Address */ 78 #define DHCP6_OPT_IATA 4 79 /* IA Addr - Identity Association Address */ 80 #define DHCP6_OPT_IAADDR 5 81 /* ORO - Option Request Option */ 82 #define DHCP6_OPT_ORO 6 83 #define DHCP6_OPT_PREFERENCE 7 84 #define DHCP6_OPT_ELAPSED_TIME 8 85 #define DHCP6_OPT_RELAY_MSG 9 86 #define DHCP6_OPT_AUTH 11 87 #define DHCP6_OPT_UNICAST 12 88 #define DHCP6_OPT_STATUSCODE 13 89 #define DHCP6_OPT_RAPIDCOMMIT 14 90 #define DHCP6_OPT_USERCLASS 15 91 #define DHCP6_OPT_VENDORCLASS 16 92 #define DHCP6_OPT_VENDOROPTS 17 93 #define DHCP6_OPT_INTERFACEID 18 94 #define DHCP6_OPT_RECONFMSG 19 95 #define DHCP6_OPT_RECONFACCEPT 20 96 /* Remote-ID is defined at RFC 4649. */ 97 #define DHCP6_OPT_REMOTEID 37 98 99 /* DHCP option used in DHCP request/reply/relay packets. */ 100 struct dhcp6_option { 101 /* DHCP option code. */ 102 uint16_t dso_code; 103 /* DHCP option payload length. */ 104 uint16_t dso_length; 105 /* DHCP option data. */ 106 uint8_t dso_data[]; 107 } __packed; 108 109 /* Client / Server message format. */ 110 struct dhcp6_packet { 111 uint8_t ds_msgtype; /* message type */ 112 uint8_t ds_transactionid[3]; /* transaction id */ 113 struct dhcp6_option ds_options[]; 114 } __packed; 115 116 /* Relay Agent/Server message format. */ 117 struct dhcp6_relay_packet { 118 /* Message type: DHCP6_MT_RELAYFORW or DHCP6_MT_RELAYREPL */ 119 uint8_t dsr_msgtype; 120 121 /* Number of relay agents that relayed this message. */ 122 uint8_t dsr_hopcount; 123 124 /* 125 * A global or site local address used by the server to Identify 126 * the client link. 127 */ 128 struct in6_addr dsr_linkaddr; 129 130 /* 131 * The address of the client or relay agent from which the relayed 132 * message was received. 133 */ 134 struct in6_addr dsr_peer; 135 136 /* Must include a relay message option. */ 137 struct dhcp6_option dsr_options[]; 138 } __packed; 139 140 #endif /* _DHCP_H_ */ 141