update_resolv() {
local device="$1"
local dns="$2"
-
+
(
flock 9
grep -v "#odhcp6c:$device:" /etc/resolv.conf > /tmp/resolv.conf.tmp
done
local prefix="{\"address\": \"$addr\", \"preferred\": $preferred, \"valid\": $valid $class $excluded}"
-
+
if [ -z "$prefixpart" ]; then
prefixpart="$prefix"
else
entry="${entry#*,}"
local valid="${entry%%,*}"
- ip -6 address add "$addr" dev "$device" preferred_lft "$preferred" valid_lft "$valid"
+ ip -6 address add "$addr" dev "$device" preferred_lft "$preferred" valid_lft "$valid"
done
for entry in $RA_ROUTES; do
free(config_dhcp.auth_token);
config_dhcp.auth_token = strdup(token);
- return config_dhcp.auth_token != NULL;
+ return config_dhcp.auth_token != NULL;
}
static int config_parse_opt_u8(const char *src, uint8_t **dst)
} else if (otype == DHCPV6_OPT_AUTH) {
struct dhcpv6_auth *r = (void*)&odata[-4];
if (auth_present) {
- options_valid = false;
+ options_valid = false;
continue;
}
retx->delay_msec = 0;
}
}
-
+
retx->is_retransmit = true;
retx->rc = 0;
retx->timeout = UINT32_MAX;
dhcpv6_send(type, retx->tr_id, elapsed / 10);
retx->rc++;
}
-
+
if (dhcpv6_get_state() != DHCPV6_EXIT)
dhcpv6_next_state();
if (retx->round_start >= retx->round_end || ret >=0 ) {
if (retx->handler_finish)
ret = retx->handler_finish();
-
+
if (ret < 0 && ((retx->timeout == UINT32_MAX) || (elapsed / 1000 < retx->timeout)) &&
(!retx->max_rc || retx->rc < retx->max_rc)) {
retx->reply_ret = -1;
#define DHCPV6_FD_INDEX 0
#define UBUS_FD_INDEX 1
-
+
#ifndef IN6_IS_ADDR_UNIQUELOCAL
#define IN6_IS_ADDR_UNIQUELOCAL(a) \
((((__const uint32_t *) (a))[0] & htonl (0xfe000000)) \
while (!terminate) { // Main logic
int poll_res;
- bool signalled = odhcp6c_signal_process();
+ bool signalled = odhcp6c_signal_process();
switch (dhcpv6_get_state()) {
case DHCPV6_INIT:
}
msg_type = DHCPV6_MSG_SOLICIT;
- dhcpv6_send_request(msg_type);
+ dhcpv6_send_request(msg_type);
break;
case DHCPV6_ADVERT:
msg_type = DHCPV6_MSG_UNKNOWN;
dhcpv6_send_request(msg_type);
break;
-
+
case DHCPV6_BOUND_REPLY:
if (res == DHCPV6_MSG_RENEW || res == DHCPV6_MSG_REBIND ||
res == DHCPV6_MSG_INFO_REQ) {
msg_type = res;
- dhcpv6_set_state(DHCPV6_RECONF);
+ dhcpv6_set_state(DHCPV6_RECONF);
} else {
dhcpv6_set_state(DHCPV6_RECONF_REPLY);
}
break;
- case DHCPV6_RECONF:
+ case DHCPV6_RECONF:
dhcpv6_send_request(msg_type);
break;
dhcpv6_set_state(mode == DHCPV6_STATELESS ? DHCPV6_INFO : DHCPV6_RENEW);
}
break;
-
+
case DHCPV6_RENEW:
msg_type = DHCPV6_MSG_RENEW;
dhcpv6_send_request(msg_type);
break;
-
+
case DHCPV6_RENEW_REPLY:
if (res > 0 ) {
notify_state_change("updated", 0, false);
msg_type = DHCPV6_MSG_REBIND;
dhcpv6_send_request(msg_type);
break;
-
+
case DHCPV6_REBIND_REPLY:
if (res < 0) {
dhcpv6_set_state(DHCPV6_RESET);
msg_type = DHCPV6_MSG_INFO_REQ;
dhcpv6_send_request(msg_type);
break;
-
+
case DHCPV6_INFO_REPLY:
dhcpv6_set_state(res < 0 ? DHCPV6_RESET : DHCPV6_BOUND);
break;
if (signal_usr1)
dhcpv6_set_state(mode == DHCPV6_STATELESS ? DHCPV6_INFO : DHCPV6_RENEW);
break;
-
+
case DHCPV6_RENEW_PROCESSING:
case DHCPV6_INFO_PROCESSING:
res = dhcpv6_state_processing(msg_type);
if (signal_usr1)
signal_usr1 = false; // Acknowledged
break;
-
+
case DHCPV6_EXIT:
odhcp6c_expire(false);
DHCPV6_ADVERT,
DHCPV6_REQUEST,
DHCPV6_REQUEST_PROCESSING,
- DHCPV6_REPLY,
+ DHCPV6_REPLY,
DHCPV6_BOUND,
DHCPV6_BOUND_PROCESSING,
DHCPV6_BOUND_REPLY,
- DHCPV6_RECONF,
+ DHCPV6_RECONF,
DHCPV6_RECONF_PROCESSING,
- DHCPV6_RECONF_REPLY,
- DHCPV6_RENEW,
+ DHCPV6_RECONF_REPLY,
+ DHCPV6_RENEW,
DHCPV6_RENEW_PROCESSING,
DHCPV6_RENEW_REPLY,
DHCPV6_REBIND,
uint64_t discarded_packets;
uint64_t transmit_failures;
};
-
+
enum odhcp6c_state {
STATE_CLIENT_ID,
STATE_SERVER_ID,
UBUS_METHOD_NOARG("release", ubus_handle_release),
};
-static struct ubus_object_type odhcp6c_object_type =
+static struct ubus_object_type odhcp6c_object_type =
UBUS_OBJECT_TYPE("odhcp6c", odhcp6c_object_methods);
static struct ubus_object odhcp6c_object = {
}
}
-char *ubus_init(const char* interface)
+char *ubus_init(const char* interface)
{
int ret = 0;
snprintf(ubus_name, 24, "odhcp6c.%s", interface);
odhcp6c_object.name = ubus_name;
-
+
ret = ubus_add_object(ubus, &odhcp6c_object);
if (ret) {
ubus_destroy(ubus);
void ubus_destroy(struct ubus_context *ubus)
{
syslog(LOG_NOTICE, "Disconnecting from ubus");
-
+
if (ubus != NULL)
ubus_free(ubus);
ubus = NULL;
const struct in6_addr *addr, size_t cnt)
{
void *arr = blobmsg_open_array(&b, name);
-
+
for (size_t i = 0; i < cnt; ++i) {
char *buf = blobmsg_alloc_string_buffer(&b, NULL, INET6_ADDRSTRLEN);
CHECK_ALLOC(buf);
e = odhcp6c_next_entry(e)) {
if (!e->valid)
continue;
-
+
buf = blobmsg_alloc_string_buffer(&b, NULL, e->auxlen+1);
CHECK_ALLOC(buf);
buf = mempcpy(buf, e->auxtarget, e->auxlen);
blobmsg_add_u32(&b, "RA_MTU", ra_get_mtu());
blobmsg_add_u32(&b, "RA_REACHABLE", ra_get_reachable());
blobmsg_add_u32(&b, "RA_RETRANSMIT", ra_get_retransmit());
-
+
buf = blobmsg_alloc_string_buffer(&b, "PASSTHRU", passthru_len * 2);
CHECK_ALLOC(buf);
script_hexlify(buf, passthru, passthru_len);
char *ubus_init(const char* interface);
struct ubus_context *ubus_get_ctx(void);
-void ubus_destroy(struct ubus_context *ubus);
+void ubus_destroy(struct ubus_context *ubus);
int ubus_dhcp_event(const char *status);
#endif /* _UBUS_H_ */