2013-05-15 18:27:36 +08:00
|
|
|
/*
|
2012-10-12 18:31:51 +08:00
|
|
|
* dhcpcd - DHCP client daemon
|
2014-01-30 02:33:43 +08:00
|
|
|
* Copyright (c) 2006-2014 Roy Marples <roy@marples.name>
|
2012-10-12 18:31:51 +08:00
|
|
|
* All rights reserved
|
|
|
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DHCP6_H
|
|
|
|
#define DHCP6_H
|
|
|
|
|
|
|
|
#include "dhcpcd.h"
|
|
|
|
|
2013-06-05 18:37:45 +08:00
|
|
|
#define IN6ADDR_LINKLOCAL_ALLDHCP_INIT \
|
|
|
|
{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02 }}}
|
2012-11-13 23:16:27 +08:00
|
|
|
|
2012-10-12 18:31:51 +08:00
|
|
|
/* UDP port numbers for DHCP */
|
|
|
|
#define DHCP6_CLIENT_PORT 546
|
|
|
|
#define DHCP6_SERVER_PORT 547
|
|
|
|
|
|
|
|
/* DHCP message type */
|
|
|
|
#define DHCP6_SOLICIT 1
|
|
|
|
#define DHCP6_ADVERTISE 2
|
|
|
|
#define DHCP6_REQUEST 3
|
|
|
|
#define DHCP6_CONFIRM 4
|
|
|
|
#define DHCP6_RENEW 5
|
|
|
|
#define DHCP6_REBIND 6
|
|
|
|
#define DHCP6_REPLY 7
|
|
|
|
#define DHCP6_RELEASE 8
|
|
|
|
#define DHCP6_DECLINE 9
|
|
|
|
#define DHCP6_RECONFIGURE 10
|
|
|
|
#define DHCP6_INFORMATION_REQ 11
|
|
|
|
#define DHCP6_RELAY_FLOW 12
|
|
|
|
#define DHCP6_RELAY_REPL 13
|
Add support for the following RFCs:
DHCP SLP Directory Agent, RFC2610
DHCP Name Service Search, RFC2937
DHCP PANA Authentication Agent, RFC5192
DHCP Lost Server, RFC5223
DHCP CAPWAP, RFC5417
DHCP Mobility Services, RFC5678
DHCP SIP UA, RFC6011
DHCP ANDSF, RFC6153
DHCP RDNSS Selection for MIF Nodes, RFC6731
DHCP TFTP Server Address, RFC5859
DHCP PXELINUX, RFC5071
DHCP Access Network Domain Name, RFC5986
DHCP Virtual Subnet Selection, RFC6607
DHCP Relay Agent Remote-ID, RFC4649
DHCP Relay Agent Subscriber-ID, RFC4580
DHCPv6 Relay-ID, RFC5460
DHCPv6 LIS Discovery, RFC5986
DHCPv6 SIP UA, RFC6011
DHCPv6 Network Boot, RFC5970
DHCPv6 Home Info Discovery in MIPv6, RFC6610
DHCPv6 RDNSS Selection for MIF Nodes, RFC6731
DHCPv6 Kerberos, RFC6784
DHCPv6 Relay-Triggered Reconfiguraion, RFC6977
DHCPv6 SOL_MAX_RT, RFC7083
2014-02-03 18:28:30 +08:00
|
|
|
#define DHCP6_RECONFIGURE_REQ 18
|
|
|
|
#define DHCP6_RECONFIGURE_REPLY 19
|
2012-10-12 18:31:51 +08:00
|
|
|
|
|
|
|
#define D6_OPTION_CLIENTID 1
|
|
|
|
#define D6_OPTION_SERVERID 2
|
2012-11-07 07:40:15 +08:00
|
|
|
#define D6_OPTION_IA_NA 3
|
2013-04-01 20:15:47 +08:00
|
|
|
#define D6_OPTION_IA_TA 4
|
2012-10-12 18:31:51 +08:00
|
|
|
#define D6_OPTION_ORO 6
|
|
|
|
#define D6_OPTION_IA_ADDR 5
|
|
|
|
#define D6_OPTION_PREFERENCE 7
|
|
|
|
#define D6_OPTION_ELAPSED 8
|
2014-01-25 09:35:53 +08:00
|
|
|
#define D6_OPTION_AUTH 11
|
2012-10-12 18:31:51 +08:00
|
|
|
#define D6_OPTION_UNICAST 12
|
|
|
|
#define D6_OPTION_STATUS_CODE 13
|
2013-06-06 07:57:03 +08:00
|
|
|
#define D6_OPTION_RAPID_COMMIT 14
|
2013-12-07 01:47:53 +08:00
|
|
|
#define D6_OPTION_VENDOR_CLASS 16
|
|
|
|
#define D6_OPTION_VENDOR_OPTS 17
|
2014-01-31 22:25:18 +08:00
|
|
|
#define D6_OPTION_INTERFACE_ID 18
|
|
|
|
#define D6_OPTION_RECONF_MSG 19
|
|
|
|
#define D6_OPTION_RECONF_ACCEPT 20
|
2012-10-12 18:31:51 +08:00
|
|
|
#define D6_OPTION_SIP_SERVERS_NAME 21
|
|
|
|
#define D6_OPTION_SIP_SERVERS_ADDRESS 22
|
|
|
|
#define D6_OPTION_DNS_SERVERS 23
|
|
|
|
#define D6_OPTION_DOMAIN_LIST 24
|
2013-04-01 20:15:47 +08:00
|
|
|
#define D6_OPTION_IA_PD 25
|
|
|
|
#define D6_OPTION_IAPREFIX 26
|
2012-10-12 18:31:51 +08:00
|
|
|
#define D6_OPTION_NIS_SERVERS 27
|
|
|
|
#define D6_OPTION_NISP_SERVERS 28
|
|
|
|
#define D6_OPTION_NIS_DOMAIN_NAME 29
|
|
|
|
#define D6_OPTION_NISP_DOMAIN_NAME 30
|
|
|
|
#define D6_OPTION_SNTP_SERVERS 31
|
|
|
|
#define D6_OPTION_INFO_REFRESH_TIME 32
|
|
|
|
#define D6_OPTION_BCMS_SERVER_D 33
|
|
|
|
#define D6_OPTION_BCMS_SERVER_A 34
|
2013-06-06 00:23:24 +08:00
|
|
|
#define D6_OPTION_FQDN 39
|
2013-05-03 21:38:54 +08:00
|
|
|
#define D6_OPTION_POSIX_TIMEZONE 41
|
|
|
|
#define D6_OPTION_TZDB_TIMEZONE 42
|
2014-07-05 03:44:15 +08:00
|
|
|
#define D6_OPTION_PD_EXCLUDE 67
|
Add support for the following RFCs:
DHCP SLP Directory Agent, RFC2610
DHCP Name Service Search, RFC2937
DHCP PANA Authentication Agent, RFC5192
DHCP Lost Server, RFC5223
DHCP CAPWAP, RFC5417
DHCP Mobility Services, RFC5678
DHCP SIP UA, RFC6011
DHCP ANDSF, RFC6153
DHCP RDNSS Selection for MIF Nodes, RFC6731
DHCP TFTP Server Address, RFC5859
DHCP PXELINUX, RFC5071
DHCP Access Network Domain Name, RFC5986
DHCP Virtual Subnet Selection, RFC6607
DHCP Relay Agent Remote-ID, RFC4649
DHCP Relay Agent Subscriber-ID, RFC4580
DHCPv6 Relay-ID, RFC5460
DHCPv6 LIS Discovery, RFC5986
DHCPv6 SIP UA, RFC6011
DHCPv6 Network Boot, RFC5970
DHCPv6 Home Info Discovery in MIPv6, RFC6610
DHCPv6 RDNSS Selection for MIF Nodes, RFC6731
DHCPv6 Kerberos, RFC6784
DHCPv6 Relay-Triggered Reconfiguraion, RFC6977
DHCPv6 SOL_MAX_RT, RFC7083
2014-02-03 18:28:30 +08:00
|
|
|
#define D6_OPTION_SOL_MAX_RT 82
|
|
|
|
#define D6_OPTION_INF_MAX_RT 83
|
2012-10-12 18:31:51 +08:00
|
|
|
|
2013-06-22 17:15:35 +08:00
|
|
|
#define D6_FQDN_PTR 0x00
|
|
|
|
#define D6_FQDN_BOTH 0x01
|
|
|
|
#define D6_FQDN_NONE 0x04
|
|
|
|
|
2012-10-12 18:31:51 +08:00
|
|
|
#include "dhcp.h"
|
2012-11-07 07:40:15 +08:00
|
|
|
#include "ipv6.h"
|
2012-10-12 18:31:51 +08:00
|
|
|
|
|
|
|
struct dhcp6_message {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t xid[3];
|
|
|
|
/* followed by options */
|
2013-04-24 17:38:18 +08:00
|
|
|
} __packed;
|
2012-10-12 18:31:51 +08:00
|
|
|
|
|
|
|
struct dhcp6_option {
|
|
|
|
uint16_t code;
|
|
|
|
uint16_t len;
|
|
|
|
/* followed by data */
|
2013-04-24 17:38:18 +08:00
|
|
|
} __packed;
|
2012-10-12 18:31:51 +08:00
|
|
|
|
2012-11-07 07:40:15 +08:00
|
|
|
#define D6_STATUS_OK 0
|
|
|
|
#define D6_STATUS_FAIL 1
|
|
|
|
#define D6_STATUS_NOADDR 2
|
|
|
|
#define D6_STATUS_NOBINDING 3
|
|
|
|
#define D6_STATUS_NOTONLINK 4
|
|
|
|
#define D6_STATUS_USEMULTICAST 5
|
|
|
|
|
|
|
|
#define SOL_MAX_DELAY 1
|
|
|
|
#define SOL_TIMEOUT 1
|
2014-02-03 19:02:17 +08:00
|
|
|
#define SOL_MAX_RT 3600 /* RFC7083 */
|
2012-11-07 07:40:15 +08:00
|
|
|
#define REQ_TIMEOUT 1
|
|
|
|
#define REQ_MAX_RT 30
|
|
|
|
#define REQ_MAX_RC 10
|
|
|
|
#define CNF_MAX_DELAY 1
|
|
|
|
#define CNF_TIMEOUT 1
|
|
|
|
#define CNF_MAX_RT 4
|
|
|
|
#define CNF_MAX_RD 10
|
|
|
|
#define REN_TIMEOUT 10
|
|
|
|
#define REN_MAX_RT 600
|
|
|
|
#define REB_TIMEOUT 10
|
|
|
|
#define REB_MAX_RT 600
|
|
|
|
#define INF_MAX_DELAY 1
|
|
|
|
#define INF_TIMEOUT 1
|
2014-02-03 19:02:17 +08:00
|
|
|
#define INF_MAX_RT 3600 /* RFC7083 */
|
2012-11-07 07:40:15 +08:00
|
|
|
#define REL_TIMEOUT 1
|
|
|
|
#define REL_MAX_RC 5
|
|
|
|
#define DEC_TIMEOUT 1
|
|
|
|
#define DEC_MAX_RC 5
|
|
|
|
#define REC_TIMEOUT 2
|
|
|
|
#define REC_MAX_RC 8
|
|
|
|
#define HOP_COUNT_LIMIT 32
|
|
|
|
|
2013-11-13 01:30:43 +08:00
|
|
|
/* RFC4242 3.1 */
|
|
|
|
#define IRT_DEFAULT 86400
|
|
|
|
#define IRT_MINIMUM 600
|
|
|
|
|
2012-11-07 07:40:15 +08:00
|
|
|
#define DHCP6_RAND_MIN -100
|
|
|
|
#define DHCP6_RAND_MAX 100
|
2013-04-05 05:59:02 +08:00
|
|
|
|
2012-10-12 18:31:51 +08:00
|
|
|
enum DH6S {
|
|
|
|
DH6S_INIT,
|
|
|
|
DH6S_DISCOVER,
|
|
|
|
DH6S_REQUEST,
|
|
|
|
DH6S_BOUND,
|
|
|
|
DH6S_RENEW,
|
|
|
|
DH6S_REBIND,
|
2013-04-01 20:15:47 +08:00
|
|
|
DH6S_CONFIRM,
|
2012-10-12 18:31:51 +08:00
|
|
|
DH6S_INFORM,
|
2013-06-12 23:01:59 +08:00
|
|
|
DH6S_INFORMED,
|
2012-10-12 18:31:51 +08:00
|
|
|
DH6S_RENEW_REQUESTED,
|
2013-04-01 20:15:47 +08:00
|
|
|
DH6S_PROBE,
|
2013-04-05 05:59:02 +08:00
|
|
|
DH6S_DELEGATED,
|
|
|
|
DH6S_RELEASE
|
2012-10-12 18:31:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dhcp6_state {
|
|
|
|
enum DH6S state;
|
|
|
|
time_t start_uptime;
|
2012-11-07 07:40:15 +08:00
|
|
|
|
|
|
|
/* Message retransmission timings */
|
|
|
|
struct timeval RT;
|
2014-03-28 06:14:52 +08:00
|
|
|
unsigned int IMD;
|
|
|
|
unsigned int RTC;
|
2014-04-25 21:05:15 +08:00
|
|
|
time_t IRT;
|
2014-03-28 06:14:52 +08:00
|
|
|
unsigned int MRC;
|
2014-04-25 21:05:15 +08:00
|
|
|
time_t MRT;
|
2012-11-07 07:40:15 +08:00
|
|
|
void (*MRCcallback)(void *);
|
2014-04-25 21:05:15 +08:00
|
|
|
time_t sol_max_rt;
|
|
|
|
time_t inf_max_rt;
|
2012-11-07 07:40:15 +08:00
|
|
|
|
2012-10-12 18:31:51 +08:00
|
|
|
struct dhcp6_message *send;
|
|
|
|
size_t send_len;
|
2012-11-07 07:40:15 +08:00
|
|
|
struct dhcp6_message *recv;
|
|
|
|
size_t recv_len;
|
2012-10-12 18:31:51 +08:00
|
|
|
struct dhcp6_message *new;
|
|
|
|
size_t new_len;
|
|
|
|
struct dhcp6_message *old;
|
|
|
|
size_t old_len;
|
2012-11-07 07:40:15 +08:00
|
|
|
|
|
|
|
uint32_t renew;
|
|
|
|
uint32_t rebind;
|
|
|
|
uint32_t expire;
|
2013-06-05 18:37:45 +08:00
|
|
|
struct in6_addr unicast;
|
2012-11-07 07:40:15 +08:00
|
|
|
struct ipv6_addrhead addrs;
|
|
|
|
uint32_t lowpl;
|
2014-02-12 19:16:22 +08:00
|
|
|
char leasefile[sizeof(LEASEFILE6) + IF_NAMESIZE];
|
2013-05-15 18:27:36 +08:00
|
|
|
const char *reason;
|
2014-01-25 09:35:53 +08:00
|
|
|
|
|
|
|
struct authstate auth;
|
2012-10-12 18:31:51 +08:00
|
|
|
};
|
|
|
|
|
2012-11-07 07:40:15 +08:00
|
|
|
#define D6_STATE(ifp) \
|
|
|
|
((struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6])
|
|
|
|
#define D6_CSTATE(ifp) \
|
|
|
|
((const struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6])
|
2014-09-03 07:41:52 +08:00
|
|
|
#define D6_STATE_RUNNING(ifp) \
|
2014-09-05 03:55:37 +08:00
|
|
|
(D6_CSTATE((ifp)) && D6_CSTATE((ifp))->new && \
|
|
|
|
D6_CSTATE((ifp))->reason && dhcp6_dadcompleted((ifp)))
|
2014-09-03 07:41:52 +08:00
|
|
|
|
2012-10-12 18:31:51 +08:00
|
|
|
#define D6_FIRST_OPTION(m) \
|
|
|
|
((struct dhcp6_option *) \
|
|
|
|
((uint8_t *)(m) + sizeof(struct dhcp6_message)))
|
|
|
|
#define D6_NEXT_OPTION(o) \
|
|
|
|
((struct dhcp6_option *) \
|
|
|
|
(((uint8_t *)o) + sizeof(struct dhcp6_option) + ntohs((o)->len)))
|
|
|
|
#define D6_OPTION_DATA(o) \
|
|
|
|
((uint8_t *)(o) + sizeof(struct dhcp6_option))
|
|
|
|
#define D6_CFIRST_OPTION(m) \
|
|
|
|
((const struct dhcp6_option *) \
|
|
|
|
((const uint8_t *)(m) + sizeof(struct dhcp6_message)))
|
|
|
|
#define D6_CNEXT_OPTION(o) \
|
|
|
|
((const struct dhcp6_option *) \
|
|
|
|
(((const uint8_t *)o) + sizeof(struct dhcp6_option) + ntohs((o)->len)))
|
|
|
|
#define D6_COPTION_DATA(o) \
|
|
|
|
((const uint8_t *)(o) + sizeof(struct dhcp6_option))
|
|
|
|
|
2013-02-04 21:30:35 +08:00
|
|
|
#ifdef INET6
|
2014-07-04 07:11:00 +08:00
|
|
|
void dhcp6_printoptions(const struct dhcpcd_ctx *,
|
|
|
|
const struct dhcp_opt *, size_t);
|
2014-02-12 08:39:46 +08:00
|
|
|
int dhcp6_addrexists(struct dhcpcd_ctx *, const struct ipv6_addr *);
|
2014-03-28 06:14:52 +08:00
|
|
|
size_t dhcp6_find_delegates(struct interface *);
|
2013-05-31 23:01:27 +08:00
|
|
|
int dhcp6_start(struct interface *, enum DH6S);
|
2013-06-07 20:44:19 +08:00
|
|
|
void dhcp6_reboot(struct interface *);
|
2012-10-12 18:31:51 +08:00
|
|
|
ssize_t dhcp6_env(char **, const char *, const struct interface *,
|
2014-03-28 06:14:52 +08:00
|
|
|
const struct dhcp6_message *, size_t);
|
2012-10-12 18:31:51 +08:00
|
|
|
void dhcp6_free(struct interface *);
|
2014-02-12 08:39:46 +08:00
|
|
|
void dhcp6_handleifa(struct dhcpcd_ctx *, int, const char *,
|
|
|
|
const struct in6_addr *addr, int);
|
2014-09-05 03:55:37 +08:00
|
|
|
int dhcp6_dadcompleted(const struct interface *);
|
2012-11-12 03:56:01 +08:00
|
|
|
void dhcp6_drop(struct interface *, const char *);
|
2014-06-22 21:05:05 +08:00
|
|
|
int dhcp6_dump(struct interface *);
|
2013-02-04 21:30:35 +08:00
|
|
|
#else
|
2014-02-13 16:15:05 +08:00
|
|
|
#define dhcp6_addrexists(a, b) (0)
|
2014-06-29 10:58:19 +08:00
|
|
|
#define dhcp6_find_delegates(a)
|
2014-02-13 16:15:05 +08:00
|
|
|
#define dhcp6_start(a, b) (0)
|
2013-06-07 20:44:19 +08:00
|
|
|
#define dhcp6_reboot(a)
|
2013-02-04 21:30:35 +08:00
|
|
|
#define dhcp6_env(a, b, c, d, e)
|
|
|
|
#define dhcp6_free(a)
|
|
|
|
#define dhcp6_drop(a, b)
|
2014-06-22 21:05:05 +08:00
|
|
|
#define dhcp6_dump(a) -1
|
2013-02-04 21:30:35 +08:00
|
|
|
#endif
|
2012-10-12 18:31:51 +08:00
|
|
|
|
|
|
|
#endif
|