• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/odhcpd/src/dhcpv6.h

  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 #define DHCPV6_OPT_DNR 144
 78 
 79 #define DHCPV6_DUID_VENDOR 2
 80 
 81 #define DHCPV6_STATUS_OK 0
 82 #define DHCPV6_STATUS_NOADDRSAVAIL 2
 83 #define DHCPV6_STATUS_NOBINDING 3
 84 #define DHCPV6_STATUS_NOTONLINK 4
 85 #define DHCPV6_STATUS_USEMULTICAST 5
 86 #define DHCPV6_STATUS_NOPREFIXAVAIL 6
 87 
 88 // I just remembered I have an old one lying around...
 89 #define DHCPV6_ENT_NO 30462
 90 #define DHCPV6_ENT_TYPE 1
 91 
 92 
 93 #define DHCPV6_HOP_COUNT_LIMIT 32
 94 
 95 #define DHCPV6_REC_TIMEOUT      2000 /* msec */
 96 #define DHCPV6_REC_MAX_RC       8
 97 
 98 struct dhcpv6_client_header {
 99         uint8_t msg_type;
100         uint8_t transaction_id[3];
101 } __attribute__((packed));
102 
103 struct dhcpv6_relay_header {
104         uint8_t msg_type;
105         uint8_t hop_count;
106         struct in6_addr link_address;
107         struct in6_addr peer_address;
108         uint8_t options[];
109 } __attribute__((packed));
110 
111 struct dhcpv6_relay_forward_envelope {
112         uint8_t msg_type;
113         uint8_t hop_count;
114         struct in6_addr link_address;
115         struct in6_addr peer_address;
116         uint16_t interface_id_type;
117         uint16_t interface_id_len;
118         uint32_t interface_id_data;
119         uint16_t relay_message_type;
120         uint16_t relay_message_len;
121 } __attribute__((packed));
122 
123 struct dhcpv6_auth_reconfigure {
124         uint16_t type;
125         uint16_t len;
126         uint8_t protocol;
127         uint8_t algorithm;
128         uint8_t rdm;
129         uint32_t replay[2];
130         uint8_t reconf_type;
131         uint8_t key[16];
132 } _packed;
133 
134 struct dhcpv6_ia_hdr {
135         uint16_t type;
136         uint16_t len;
137         uint32_t iaid;
138         uint32_t t1;
139         uint32_t t2;
140 } _packed;
141 
142 struct dhcpv6_ia_prefix {
143         uint16_t type;
144         uint16_t len;
145         uint32_t preferred_lt;
146         uint32_t valid_lt;
147         uint8_t prefix;
148         struct in6_addr addr;
149 } _packed;
150 
151 struct dhcpv6_ia_addr {
152         uint16_t type;
153         uint16_t len;
154         struct in6_addr addr;
155         uint32_t preferred_lt;
156         uint32_t valid_lt;
157 } _packed;
158 
159 struct dhcpv6_cer_id {
160         uint16_t type;
161         uint16_t len;
162         uint16_t reserved;
163         uint16_t auth_type;
164         uint8_t auth[16];
165         struct in6_addr addr;
166 };
167 
168 #define dhcpv6_for_each_option(start, end, otype, olen, odata)\
169         for (uint8_t *_o = (uint8_t*)(start); _o + 4 <= (end) &&\
170                 ((otype) = _o[0] << 8 | _o[1]) && ((odata) = (void*)&_o[4]) &&\
171                 ((olen) = _o[2] << 8 | _o[3]) + (odata) <= (end); \
172                 _o += 4 + (_o[2] << 8 | _o[3]))
173 
174 #endif /* _DHCPV6_H_ */
175 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt