1 /** 2 * Copyright (C) 2012 Steven Barth <steven@midlink.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License version 2 for more details. 12 * 13 */ 14 15 #ifndef _DHCPV6_H_ 16 #define _DHCPV6_H_ 17 18 #include "odhcpd.h" 19 20 #define ALL_DHCPV6_RELAYS "ff02::1:2" 21 22 #define ALL_DHCPV6_SERVERS "ff05::1:3" 23 24 #define DHCPV6_CLIENT_PORT 546 25 #define DHCPV6_SERVER_PORT 547 26 27 /* RFC8415 */ 28 #define DHCPV6_MSG_SOLICIT 1 29 #define DHCPV6_MSG_ADVERTISE 2 30 #define DHCPV6_MSG_REQUEST 3 31 #define DHCPV6_MSG_CONFIRM 4 32 #define DHCPV6_MSG_RENEW 5 33 #define DHCPV6_MSG_REBIND 6 34 #define DHCPV6_MSG_REPLY 7 35 #define DHCPV6_MSG_RELEASE 8 36 #define DHCPV6_MSG_DECLINE 9 37 #define DHCPV6_MSG_RECONFIGURE 10 38 #define DHCPV6_MSG_INFORMATION_REQUEST 11 39 #define DHCPV6_MSG_RELAY_FORW 12 40 #define DHCPV6_MSG_RELAY_REPL 13 41 /* RFC7341 */ 42 #define DHCPV6_MSG_DHCPV4_QUERY 20 43 #define DHCPV6_MSG_DHCPV4_RESPONSE 21 44 45 #define DHCPV6_OPT_CLIENTID 1 46 #define DHCPV6_OPT_SERVERID 2 47 #define DHCPV6_OPT_IA_NA 3 48 #define DHCPV6_OPT_IA_ADDR 5 49 #define DHCPV6_OPT_ORO 6 50 #define DHCPV6_OPT_STATUS 13 51 #define DHCPV6_OPT_RELAY_MSG 9 52 #define DHCPV6_OPT_AUTH 11 53 #define DHCPV6_OPT_RAPID_COMMIT 14 54 #define DHCPV6_OPT_USER_CLASS 15 55 #define DHCPV6_OPT_INTERFACE_ID 18 56 #define DHCPV6_OPT_RECONF_MSG 19 57 #define DHCPV6_OPT_RECONF_ACCEPT 20 58 #define DHCPV6_OPT_DNS_SERVERS 23 59 #define DHCPV6_OPT_DNS_DOMAIN 24 60 #define DHCPV6_OPT_IA_PD 25 61 #define DHCPV6_OPT_IA_PREFIX 26 62 #define DHCPV6_OPT_SNTP_SERVERS 31 63 #define DHCPV6_OPT_INFO_REFRESH 32 64 #define DHCPV6_OPT_FQDN 39 65 /* RFC 4833 */ 66 #define DHCPV6_OPT_NEW_POSIX_TIMEZONE 41 67 #define DHCPV6_OPT_NEW_TZDB_TIMEZONE 42 68 69 #define DHCPV6_OPT_NTP_SERVERS 56 70 #define DHCPV6_OPT_BOOTFILE_URL 59 71 #define DHCPV6_OPT_BOOTFILE_PARAM 60 72 #define DHCPV6_OPT_CLIENT_ARCH 61 73 #define DHCPV6_OPT_SOL_MAX_RT 82 74 #define DHCPV6_OPT_INF_MAX_RT 83 75 #define DHCPV6_OPT_DHCPV4_MSG 87 76 #define DHCPV6_OPT_4O6_SERVER 88 77 /* RFC8910 */ 78 #define DHCPV6_OPT_CAPTIVE_PORTAL 103 79 #define DHCPV6_OPT_DNR 144 80 81 #define DHCPV6_DUID_VENDOR 2 82 83 #define DHCPV6_STATUS_OK 0 84 #define DHCPV6_STATUS_NOADDRSAVAIL 2 85 #define DHCPV6_STATUS_NOBINDING 3 86 #define DHCPV6_STATUS_NOTONLINK 4 87 #define DHCPV6_STATUS_USEMULTICAST 5 88 #define DHCPV6_STATUS_NOPREFIXAVAIL 6 89 90 #define DHCPV6_HOP_COUNT_LIMIT 32 91 92 #define DHCPV6_REC_TIMEOUT 2000 /* msec */ 93 #define DHCPV6_REC_MAX_RC 8 94 95 struct dhcpv6_client_header { 96 uint8_t msg_type; 97 uint8_t transaction_id[3]; 98 } _o_packed; 99 100 struct dhcpv6_relay_header { 101 uint8_t msg_type; 102 uint8_t hop_count; 103 struct in6_addr link_address; 104 struct in6_addr peer_address; 105 uint8_t options[]; 106 } _o_packed; 107 108 struct dhcpv6_relay_forward_envelope { 109 uint8_t msg_type; 110 uint8_t hop_count; 111 struct in6_addr link_address; 112 struct in6_addr peer_address; 113 uint16_t interface_id_type; 114 uint16_t interface_id_len; 115 uint32_t interface_id_data; 116 uint16_t relay_message_type; 117 uint16_t relay_message_len; 118 } _o_packed; 119 120 struct dhcpv6_auth_reconfigure { 121 uint16_t type; 122 uint16_t len; 123 uint8_t protocol; 124 uint8_t algorithm; 125 uint8_t rdm; 126 uint32_t replay[2]; 127 uint8_t reconf_type; 128 uint8_t key[16]; 129 } _o_packed; 130 131 struct dhcpv6_ia_hdr { 132 uint16_t type; 133 uint16_t len; 134 uint32_t iaid; 135 uint32_t t1; 136 uint32_t t2; 137 } _o_packed; 138 139 struct dhcpv6_ia_prefix { 140 uint16_t type; 141 uint16_t len; 142 uint32_t preferred_lt; 143 uint32_t valid_lt; 144 uint8_t prefix_len; 145 struct in6_addr addr; 146 } _o_packed; 147 148 struct dhcpv6_ia_addr { 149 uint16_t type; 150 uint16_t len; 151 struct in6_addr addr; 152 uint32_t preferred_lt; 153 uint32_t valid_lt; 154 } _o_packed; 155 156 struct dhcpv6_cer_id { 157 uint16_t type; 158 uint16_t len; 159 uint16_t reserved; 160 uint16_t auth_type; 161 uint8_t auth[16]; 162 struct in6_addr addr; 163 }; 164 165 #define dhcpv6_for_each_option(start, end, otype, olen, odata) \ 166 for (uint8_t *_o = (uint8_t*)(start); _o + 4 <= (end) && \ 167 ((otype) = _o[0] << 8 | _o[1]) && ((odata) = (void*)&_o[4]) && \ 168 ((olen) = _o[2] << 8 | _o[3]) + (odata) <= (end); \ 169 _o += 4 + (_o[2] << 8 | _o[3])) 170 171 #define dhcpv6_for_each_sub_option(start, end, otype, olen, odata) \ 172 for (uint8_t *_so = (uint8_t*)(start); _so + 4 <= (end) && \ 173 ((otype) = _so[0] << 8 | _so[1]) && ((odata) = (void*)&_so[4]) && \ 174 ((olen) = _so[2] << 8 | _so[3]) + (odata) <= (end); \ 175 _so += 4 + (_so[2] << 8 | _so[3])) 176 177 #endif /* _DHCPV6_H_ */ 178
This page was automatically generated by LXR 0.3.1. • OpenWrt