/**
- * Copyright (C) 2012-2013 Steven Barth <steven@midlink.org>
+ * Copyright (C) 2012-2014 Steven Barth <steven@midlink.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License v2 as published by
#define DHCPV6_REB_MAX_RT 600
#define DHCPV6_INF_MAX_RT 3600
+#define DEFAULT_MIN_UPDATE_INTERVAL 30
+
enum dhcvp6_opt {
DHCPV6_OPT_CLIENTID = 1,
DHCPV6_OPT_SERVERID = 2,
DHCPV6_OPT_IA_NA = 3,
+ DHCPV6_OPT_IA_TA = 4,
DHCPV6_OPT_IA_ADDR = 5,
DHCPV6_OPT_ORO = 6,
DHCPV6_OPT_PREF = 7,
DHCPV6_OPT_ELAPSED = 8,
DHCPV6_OPT_RELAY_MSG = 9,
DHCPV6_OPT_AUTH = 11,
+ DHCPV6_OPT_UNICAST = 12,
DHCPV6_OPT_STATUS = 13,
DHCPV6_OPT_RAPID_COMMIT = 14,
+ DHCPV6_OPT_USER_CLASS = 15,
+ DHCPV6_OPT_VENDOR_CLASS = 16,
DHCPV6_OPT_RECONF_MESSAGE = 19,
DHCPV6_OPT_RECONF_ACCEPT = 20,
DHCPV6_OPT_DNS_SERVERS = 23,
/* draft-bhandari-dhc-class-based-prefix, not yet standardized */
DHCPV6_OPT_PREFIX_CLASS = EXT_PREFIX_CLASS,
#endif
+#ifdef EXT_CER_ID
+ /* draft-donley-dhc-cer-id-option-03 */
+ DHCPV6_OPT_CER_ID = EXT_CER_ID,
+#endif
+ /* draft-ietf-softwire-map-dhcp-08 */
+ DHCPV6_OPT_S46_RULE = 89,
+ DHCPV6_OPT_S46_BR = 90,
+ DHCPV6_OPT_S46_DMR = 91,
+ DHCPV6_OPT_S46_V4V6BIND = 92,
+ DHCPV6_OPT_S46_PORTPARAMS = 93,
+ DHCPV6_OPT_S46_CONT_MAPE = 94,
+ DHCPV6_OPT_S46_CONT_MAPT = 95,
+ DHCPV6_OPT_S46_CONT_LW = 96,
};
enum dhcpv6_opt_npt {
_DHCPV6_Status_Max
};
+enum dhcpv6_config {
+ DHCPV6_STRICT_OPTIONS = 1,
+ DHCPV6_CLIENT_FQDN = 2,
+ DHCPV6_ACCEPT_RECONFIGURE = 4,
+};
+
typedef int(reply_handler)(enum dhcpv6_msg orig, const int rc,
- const void *opt, const void *end);
+ const void *opt, const void *end, const struct sockaddr_in6 *from);
// retransmission strategy
struct dhcpv6_retx {
uint8_t key[16];
} _packed;
+struct dhcpv6_cer_id {
+ uint16_t type;
+ uint16_t len;
+ struct in6_addr addr;
+} _packed;
+
+struct dhcpv6_s46_portparams {
+ uint8_t offset;
+ uint8_t psid_len;
+ uint16_t psid;
+} _packed;
+
+struct dhcpv6_s46_v4v6bind {
+ struct in_addr ipv4_address;
+ uint8_t bindprefix6_len;
+ uint8_t bind_ipv6_prefix[];
+} _packed;
+
+struct dhcpv6_s46_dmr {
+ uint8_t dmr_prefix6_len;
+ uint8_t dmr_ipv6_prefix[];
+} _packed;
+
+struct dhcpv6_s46_rule {
+ uint8_t flags;
+ uint8_t ea_len;
+ uint8_t prefix4_len;
+ struct in_addr ipv4_prefix;
+ uint8_t prefix6_len;
+ uint8_t ipv6_prefix[];
+} _packed;
#define dhcpv6_for_each_option(start, end, otype, olen, odata)\
for (uint8_t *_o = (uint8_t*)(start); _o + 4 <= (uint8_t*)(end) &&\
STATE_CLIENT_ID,
STATE_SERVER_ID,
STATE_SERVER_CAND,
+ STATE_SERVER_ADDR,
STATE_ORO,
STATE_DNS,
STATE_SEARCH,
STATE_RA_PREFIX,
STATE_RA_DNS,
STATE_AFTR_NAME,
+ STATE_VENDORCLASS,
+ STATE_USERCLASS,
+ STATE_CER,
+ STATE_S46_MAPT,
+ STATE_S46_MAPE,
+ STATE_S46_LW,
+ STATE_PASSTHRU,
_STATE_MAX
};
uint16_t length;
};
-int init_dhcpv6(const char *ifname, bool strict_options, int sol_timeout);
+int init_dhcpv6(const char *ifname, unsigned int client_options, int sol_timeout);
void dhcpv6_set_ia_mode(enum odhcp6c_ia_mode na, enum odhcp6c_ia_mode pd);
int dhcpv6_request(enum dhcpv6_msg type);
int dhcpv6_poll_reconfigure(void);
int script_init(const char *path, const char *ifname);
ssize_t script_unhexlify(uint8_t *dst, size_t len, const char *src);
void script_call(const char *status);
-void script_delay_call(const char *status, int timeout);
bool odhcp6c_signal_process(void);
uint64_t odhcp6c_get_milli_time(void);
// Entry manipulation
struct odhcp6c_entry* odhcp6c_find_entry(enum odhcp6c_state state, const struct odhcp6c_entry *new);
-bool odhcp6c_update_entry(enum odhcp6c_state state, struct odhcp6c_entry *new);
-bool odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *new, uint32_t safe);
+bool odhcp6c_update_entry(enum odhcp6c_state state, struct odhcp6c_entry *new, uint32_t safe, bool filterexcess);
void odhcp6c_expire(void);
uint32_t odhcp6c_elapsed(void);