m->xid[2] = xid & 0xff;
}
+#ifndef SMALL
static const struct if_sla *
dhcp6_findselfsla(struct interface *ifp, const uint8_t *iaid)
{
return sla->prefix_len;
}
+#endif
static int
dhcp6_makemessage(struct interface *ifp)
{
struct dhcp6_state *state;
struct dhcp6_message *m;
- struct dhcp6_option *o, *so, *eo;
+ struct dhcp6_option *o, *so;
const struct dhcp6_option *si, *unicast;
size_t l, n, len, ml;
- uint8_t u8, type;
+ uint8_t type;
uint16_t u16, n_options, auth_len;
struct if_options *ifo;
const struct dhcp_opt *opt, *opt2;
uint8_t IA, *p;
- const uint8_t *pp;
uint32_t u32;
const struct ipv6_addr *ap;
char hbuf[HOSTNAME_MAX_LEN + 1];
const char *hostname;
int fqdn;
struct dhcp6_ia_addr *iap;
+#ifndef SMALL
+ struct dhcp6_option *eo;
struct dhcp6_pd_addr *pdp;
+ uint8_t u8;
+ const uint8_t *pp;
+#endif
state = D6_STATE(ifp);
if (state->send) {
len += sizeof(u16);
}
}
+#ifndef SMALL
for (l = 0, opt = ifo->dhcp6_override;
l < ifo->dhcp6_override_len;
l++, opt++)
n_options++;
len += sizeof(u16);
}
+#endif
if (len)
len += sizeof(*o);
!(ap->flags & IPV6_AF_REQUEST))
continue;
if (ap->ia_type == D6_OPTION_IA_PD) {
+#ifndef SMALL
len += sizeof(*o) + sizeof(u8) +
sizeof(u32) + sizeof(u32) +
sizeof(ap->prefix);
len += sizeof(*o) + 1 +
(uint8_t)((ap->prefix_exclude_len -
ap->prefix_len - 1) / NBBY) + 1;
+#endif
} else
len += sizeof(*o) + sizeof(ap->addr) +
sizeof(u32) + sizeof(u32);
continue;
so = D6_NEXT_OPTION(o);
if (ap->ia_type == D6_OPTION_IA_PD) {
+#ifndef SMALL
so->code = htons(D6_OPTION_IAPREFIX);
so->len = htons(sizeof(ap->prefix) +
sizeof(u32) + sizeof(u32) + sizeof(u8));
u16 = (uint16_t)(ntohs(o->len) + sizeof(*so)
+ ntohs(so->len));
o->len = htons(u16);
+#endif
} else {
so->code = htons(D6_OPTION_IA_ADDR);
so->len = sizeof(ap->addr) +
l < ifp->ctx->dhcp6_opts_len;
l++, opt++)
{
+#ifndef SMALL
for (n = 0, opt2 = ifo->dhcp6_override;
n < ifo->dhcp6_override_len;
n++, opt2++)
}
if (n < ifo->dhcp6_override_len)
continue;
+#endif
if (!(opt->type & OT_NOREQ) &&
(opt->type & OT_REQUEST ||
has_option_mask(ifo->requestmask6,
o->len = (uint16_t)(o->len+sizeof(u16));
}
}
+#ifndef SMALL
for (l = 0, opt = ifo->dhcp6_override;
l < ifo->dhcp6_override_len;
l++, opt++)
memcpy(p, &u16, sizeof(u16));
o->len = (uint16_t)(o->len + sizeof(u16));
}
+#endif
o->len = htons(o->len);
}
}
}
}
+#ifndef SMALL
static void dhcp6_delete_delegates(struct interface *ifp)
{
struct interface *ifp0;
}
}
}
+#endif
static ssize_t
dhcp6_update_auth(struct interface *ifp, struct dhcp6_message *m, size_t len)
struct dhcp6_state *state;
ifp = arg;
+#ifndef SMALL
dhcp6_delete_delegates(ifp);
+#endif
logger(ifp->ctx, LOG_INFO, "%s: soliciting a DHCPv6 lease", ifp->name);
state = D6_STATE(ifp);
state->state = DH6S_DISCOVER;
dhcp6_startdiscover(ifp);
}
+#ifdef SMALL
+#define dhcp6_hasprefixdelegation(a) (0)
+#else
static void
dhcp6_failrebind(void *arg)
{
dhcp6_startdiscover(ifp);
}
-
static int
dhcp6_hasprefixdelegation(struct interface *ifp)
{
}
return t == D6_OPTION_IA_PD ? 1 : 0;
}
+#endif
static void
dhcp6_startrebind(void *arg)
{
struct interface *ifp;
struct dhcp6_state *state;
+#ifndef SMALL
int pd;
+#endif
ifp = arg;
eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrenew, ifp);
state->RTC = 0;
state->MRC = 0;
+#ifndef SMALL
/* RFC 3633 section 12.1 */
pd = dhcp6_hasprefixdelegation(ifp);
if (pd) {
state->IMD = CNF_MAX_DELAY;
state->IRT = CNF_TIMEOUT;
state->MRT = CNF_MAX_RT;
- } else {
+ } else
+#endif
+ {
state->IRT = REB_TIMEOUT;
state->MRT = REB_MAX_RT;
}
else
dhcp6_sendrebind(ifp);
+#ifndef SMALL
/* RFC 3633 section 12.1 */
if (pd)
eloop_timeout_add_sec(ifp->ctx->eloop,
CNF_MAX_RD, dhcp6_failrebind, ifp);
+#endif
}
logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 lease expired", ifp->name);
dhcp6_freedrop_addrs(ifp, 1, NULL);
+#ifndef SMALL
dhcp6_delete_delegates(ifp);
+#endif
script_runreason(ifp, "EXPIRE6");
if (ipv6nd_hasradhcp(ifp) || dhcp6_hasprefixdelegation(ifp))
dhcp6_startdiscover(ifp);
return i;
}
+#ifndef SMALL
static int
dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
const uint8_t *d, size_t l, const struct timespec *acquired)
}
return i;
}
+#endif
static int
dhcp6_findia(struct interface *ifp, const struct dhcp6_message *m, size_t l,
continue;
}
if (code == D6_OPTION_IA_PD) {
+#ifndef SMALL
if (dhcp6_findpd(ifp, iaid, p, ol, acquired) == 0) {
logger(ifp->ctx, LOG_WARNING,
"%s: %s: DHCPv6 REPLY missing Prefix",
ifp->name, sfrom);
continue;
}
+#endif
} else {
if (dhcp6_findna(ifp, code, iaid, p, ol, acquired) == 0)
{
ifp->name, state->leasefile);
} else if (r != 0) {
/* RFC 3633 section 12.1 */
+#ifndef SMALL
if (dhcp6_hasprefixdelegation(ifp))
dhcp6_startrebind(ifp);
else
+#endif
dhcp6_startconfirm(ifp);
return;
}
dhcp6_startdiscover(ifp);
}
+#ifndef SMALL
static struct ipv6_addr *
dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
const struct if_sla *sla, struct if_ia *if_ia)
return ia;
}
+#endif
static void
dhcp6_script_try_run(struct interface *ifp, int delegated)
"%s: waiting for DHCPv6 DAD to complete", ifp->name);
}
+#ifdef SMALL
+size_t
+dhcp6_find_delegates(__unused struct interface *ifp)
+{
+
+ return 0;
+}
+#else
static void
dhcp6_delegate_prefix(struct interface *ifp)
{
}
return k;
}
+#endif
/* ARGSUSED */
static void
if (dhcp6_validatelease(ifp, r, len,
ctx->sfrom, NULL) == -1)
{
+#ifndef SMALL
/* PD doesn't use CONFIRM, so REBIND could
* throw up an invalid prefix if we
* changed link */
if (dhcp6_hasprefixdelegation(ifp))
dhcp6_startdiscover(ifp);
+#endif
return;
}
break;
if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
dhcp6_writelease(ifp);
+#ifndef SMALL
dhcp6_delegate_prefix(ifp);
+#endif
dhcp6_script_try_run(ifp, 0);
}
return -1;
}
+#ifndef SMALL
static void
dhcp6_activateinterfaces(struct interface *ifp)
{
}
}
}
+#endif
static void
dhcp6_start1(void *arg)
add_option_mask(ifo->requestmask6, D6_OPTION_FQDN);
}
+#ifndef SMALL
/* Rapid commit won't work with Prefix Delegation Exclusion */
if (dhcp6_findselfsla(ifp, NULL))
del_option_mask(ifo->requestmask6, D6_OPTION_RAPID_COMMIT);
+#endif
if (state->state == DH6S_INFORM) {
add_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME);
dhcp6_startinit(ifp);
}
+#ifndef SMALL
dhcp6_activateinterfaces(ifp);
+#endif
}
int
}
/* We're already running DHCP6 */
/* XXX: What if the managed flag vanishes from all RA? */
+#ifndef SMALL
dhcp6_activateinterfaces(ifp);
+#endif
return 0;
}
struct dhcp6_state *state;
struct dhcpcd_ctx *ctx;
unsigned long long options;
+#ifndef SMALL
int dropdele;
+#endif
/*
* As the interface is going away from dhcpcd we need to
options = ifp->options->options;
else
options = ifp->ctx->options;
+#ifndef SMALL
dropdele = (options & (DHCPCD_STOPPING | DHCPCD_RELEASE) &&
(options & DHCPCD_NODROP) != DHCPCD_NODROP);
+#endif
if (ifp->ctx->eloop)
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
+#ifndef SMALL
if (dropdele)
dhcp6_delete_delegates(ifp);
+#endif
state = D6_STATE(ifp);
if (state) {
dhcp6_freedrop(ifp, 0, NULL);
}
-void dhcp6_dropnondelegates(struct interface *ifp)
+void
+dhcp6_dropnondelegates(struct interface *ifp)
{
+#ifndef SMALL
struct dhcp6_state *state;
struct ipv6_addr *ia;
if (ia->flags & (IPV6_AF_DELEGATED | IPV6_AF_DELEGATEDPFX))
return;
}
+#endif
dhcp6_drop(ifp, "EXPIRE6");
}
--- /dev/null
+# Copyright (c) 2006-2016 Roy Marples
+# All rights reserved
+
+# Bare essentials for automatic IP configuration
+
+##############################################################################
+# DHCP RFC2132 options unless otheriwse stated
+define 1 request ipaddress subnet_mask
+# RFC3442 states that the CSR has to come before all other routes
+# For completeness we also specify static routes then routers
+define 121 rfc3442 classless_static_routes
+# Option 249 is an IANA assigned private number used by Windows DHCP servers
+# to provide the exact same information as option 121, classless static routes
+define 249 rfc3442 ms_classless_static_routes
+define 33 request array ipaddress static_routes
+define 3 request array ipaddress routers
+define 6 array ipaddress domain_name_servers
+define 12 dname host_name
+define 15 array dname domain_name
+define 28 request ipaddress broadcast_address
+define 50 ipaddress dhcp_requested_address
+define 51 request uint32 dhcp_lease_time
+define 52 byte dhcp_option_overload
+define 53 byte dhcp_message_type
+define 54 ipaddress dhcp_server_identifier
+define 55 array byte dhcp_parameter_request_list
+define 56 string dhcp_message
+define 57 uint16 dhcp_max_message_size
+define 58 request uint32 dhcp_renewal_time
+define 59 request uint32 dhcp_rebinding_time
+define 60 string vendor_class_identifier
+define 61 binhex dhcp_client_identifier
+
+# DHCP Rapid Commit, RFC4039
+define 80 norequest flag rapid_commit
+
+# DHCP Fully Qualified Domain Name, RFC4702
+define 81 embed fqdn
+embed bitflags=0000NEOS flags
+embed byte rcode1
+embed byte rcode2
+# dhcpcd always sets the E bit which means the fqdn itself is always
+# RFC1035 encoded.
+# The server MUST use the encoding as specified by the client as noted
+# in RFC4702 Section 2.1.
+embed optional domain fqdn
+
+# DHCP Domain Search, RFC3397
+define 119 array domain domain_search
+
+##############################################################################
+# ND6 options, RFC4861
+definend 1 binhex source_address
+definend 2 binhex target_address
+
+definend 3 index embed prefix_information
+embed byte length
+embed bitflags=LA flags
+embed uint32 vltime
+embed uint32 pltime
+embed uint32 reserved
+embed array ip6address prefix
+
+# option 4 is only for Redirect messages
+
+definend 5 embed mtu
+embed uint16 reserved
+embed uint32 mtu
+
+# ND6 options, RFC6101
+definend 25 index embed rdnss
+embed uint16 reserved
+embed uint32 lifetime
+embed array ip6address servers
+
+definend 31 index embed dnssl
+embed uint16 reserved
+embed uint32 lifetime
+embed domain search
+
+##############################################################################
+# DHCPv6 options, RFC3315
+define6 1 binhex client_id
+define6 2 binhex server_id
+
+define6 3 norequest index embed ia_na
+embed binhex:4 iaid
+embed uint32 t1
+embed uint32 t2
+encap 5 option
+encap 13 option
+
+define6 4 norequest index embed ia_ta
+embed uint32 iaid
+encap 5 option
+encap 13 option
+
+define6 5 norequest index embed ia_addr
+embed ip6address ia_addr
+embed uint32 pltime
+embed uint32 vltime
+encap 13 option
+
+define6 12 ip6address unicast
+
+define6 13 norequest embed status_code
+embed uint16 status_code
+embed string message
+
+define6 18 binhex interface_id
+define6 19 byte reconfigure_msg
+define6 20 flag reconfigure_accept
+
+# DHCPv6 DNS Configuration Options, RFC3646
+define6 23 array ip6address name_servers
+define6 24 array domain domain_search
+
+# DHCPv6 Fully Qualified Domain Name, RFC4704
+define6 39 embed fqdn
+embed bitflags=00000NOS flags
+embed optional domain fqdn
+
+# DHCPv6 SOL_MAX_RT, RFC7083
+define6 82 request uint32 sol_max_rt
+define6 83 request uint32 inf_max_rt