summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2019-02-11 15:46:29 +0100
committerHans Dedecker <dedeckeh@gmail.com>2019-02-11 15:50:56 +0100
commit671ccaabc893b53be8a1891aaf2236b657d6ce06 (patch)
tree69283ce5503f16fffed26beb599148478d4f06a3
parent0db69b0b85c83fedd74ac77e850669a17c4e6617 (diff)
dhcpv6-ia: move function definitions to odhcpd.h
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--src/dhcpv6-ia.c16
-rw-r--r--src/dhcpv6.c4
-rw-r--r--src/dhcpv6.h13
-rw-r--r--src/odhcpd.h12
-rw-r--r--src/ubus.c2
5 files changed, 23 insertions, 24 deletions
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 95f4307..2820946 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -61,7 +61,7 @@ int dhcpv6_ia_init(void)
return 0;
}
-int dhcpv6_setup_ia_interface(struct interface *iface, bool enable)
+int dhcpv6_ia_setup_interface(struct interface *iface, bool enable)
{
if (!enable && iface->ia_assignments.next) {
struct dhcp_assignment *c;
@@ -272,7 +272,7 @@ static int send_reconf(struct dhcp_assignment *assign)
return odhcpd_send(iface->dhcpv6_event.uloop.fd, &assign->peer, &iov, 1, iface);
}
-void dhcpv6_enum_ia_addrs(struct interface *iface, struct dhcp_assignment *c,
+void dhcpv6_ia_enum_addrs(struct interface *iface, struct dhcp_assignment *c,
time_t now, dhcpv6_binding_cb_handler_t func, void *arg)
{
struct odhcpd_ipaddr *addrs = (c->managed) ? c->managed : iface->addr6;
@@ -349,7 +349,7 @@ void dhcpv6_write_ia_addr(struct in6_addr *addr, int prefix, _unused uint32_t pr
"%s/%d ", ipbuf, prefix);
}
-void dhcpv6_write_statefile(void)
+void dhcpv6_ia_write_statefile(void)
{
struct write_ctxt ctxt;
@@ -405,7 +405,7 @@ void dhcpv6_write_statefile(void)
ctxt.c->assigned, (unsigned)ctxt.c->length);
if (INFINITE_VALID(ctxt.c->valid_until) || ctxt.c->valid_until > now)
- dhcpv6_enum_ia_addrs(ctxt.iface, ctxt.c, now,
+ dhcpv6_ia_enum_addrs(ctxt.iface, ctxt.c, now,
dhcpv6_write_ia_addr, &ctxt);
ctxt.buf[ctxt.buf_idx - 1] = '\n';
@@ -770,7 +770,7 @@ static void handle_addrlist_change(struct netevent_handler_info *info)
}
}
- dhcpv6_write_statefile();
+ dhcpv6_ia_write_statefile();
}
static void reconf_timeout_cb(struct uloop_timeout *event)
@@ -1109,7 +1109,7 @@ static void dhcpv6_log(uint8_t msgtype, struct interface *iface, time_t now,
.buf_len = sizeof(leasebuf),
.buf_idx = 0 };
- dhcpv6_enum_ia_addrs(iface, a, now, dhcpv6_log_ia_addr, &ctxt);
+ dhcpv6_ia_enum_addrs(iface, a, now, dhcpv6_log_ia_addr, &ctxt);
}
syslog(LOG_WARNING, "DHCPV6 %s %s from %s on %s: %s %s", type, (is_pd) ? "IA_PD" : "IA_NA",
@@ -1157,7 +1157,7 @@ static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcp_assign
return onlink;
}
-ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
+ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *iface,
const struct sockaddr_in6 *addr, const void *data, const uint8_t *end)
{
time_t now = odhcpd_time();
@@ -1446,7 +1446,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
break;
}
- dhcpv6_write_statefile();
+ dhcpv6_ia_write_statefile();
out:
return response_len;
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index e88c007..400e988 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -147,7 +147,7 @@ int dhcpv6_setup_interface(struct interface *iface, bool enable)
odhcpd_register(&iface->dhcpv6_event);
}
- ret = dhcpv6_setup_ia_interface(iface, enable);
+ ret = dhcpv6_ia_setup_interface(iface, enable);
out:
if (ret < 0 && iface->dhcpv6_event.uloop.fd > 0) {
@@ -421,7 +421,7 @@ static void handle_client_request(void *addr, void *data, size_t len,
}
if (hdr->msg_type != DHCPV6_MSG_INFORMATION_REQUEST) {
- ssize_t ialen = dhcpv6_handle_ia(pdbuf, sizeof(pdbuf), iface, addr, data, opts_end);
+ ssize_t ialen = dhcpv6_ia_handle_IAs(pdbuf, sizeof(pdbuf), iface, addr, data, opts_end);
iov[IOV_PDBUF].iov_len = ialen;
if (ialen < 0 ||
diff --git a/src/dhcpv6.h b/src/dhcpv6.h
index 1ed7d6d..7abc8af 100644
--- a/src/dhcpv6.h
+++ b/src/dhcpv6.h
@@ -146,21 +146,8 @@ struct dhcpv6_cer_id {
struct in6_addr addr;
};
-typedef void (*dhcpv6_binding_cb_handler_t)(struct in6_addr *addr, int prefix,
- uint32_t pref, uint32_t valid,
- void *arg);
-
#define dhcpv6_for_each_option(start, end, otype, olen, odata)\
for (uint8_t *_o = (uint8_t*)(start); _o + 4 <= (end) &&\
((otype) = _o[0] << 8 | _o[1]) && ((odata) = (void*)&_o[4]) &&\
((olen) = _o[2] << 8 | _o[3]) + (odata) <= (end); \
_o += 4 + (_o[2] << 8 | _o[3]))
-
-int dhcpv6_init_ia(struct interface *iface, int socket);
-ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
- const struct sockaddr_in6 *addr, const void *data, const uint8_t *end);
-int dhcpv6_ia_init(void);
-int dhcpv6_setup_ia_interface(struct interface *iface, bool enable);
-void dhcpv6_enum_ia_addrs(struct interface *iface, struct dhcp_assignment *c, time_t now,
- dhcpv6_binding_cb_handler_t func, void *arg);
-void dhcpv6_write_statefile(void);
diff --git a/src/odhcpd.h b/src/odhcpd.h
index e7fcd82..8165f76 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -52,6 +52,10 @@ struct odhcpd_event {
void (*recv_msgs)(struct odhcpd_event *e);
};
+typedef void (*dhcpv6_binding_cb_handler_t)(struct in6_addr *addr, int prefix,
+ uint32_t pref, uint32_t valid,
+ void *arg);
+
union if_addr {
struct in_addr in;
struct in6_addr in6;
@@ -332,6 +336,14 @@ void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac, const size_t ma
const struct in_addr *addr, const char *name, const char *interface);
#endif
+ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *iface,
+ const struct sockaddr_in6 *addr, const void *data, const uint8_t *end);
+int dhcpv6_ia_init(void);
+int dhcpv6_ia_setup_interface(struct interface *iface, bool enable);
+void dhcpv6_ia_enum_addrs(struct interface *iface, struct dhcp_assignment *c, time_t now,
+ dhcpv6_binding_cb_handler_t func, void *arg);
+void dhcpv6_ia_write_statefile(void);
+
int netlink_add_netevent_handler(struct netevent_handler *hdlr);
ssize_t netlink_get_interface_addrs(const int ifindex, bool v6,
struct odhcpd_ipaddr **addrs);
diff --git a/src/ubus.c b/src/ubus.c
index e1fb30e..b263da6 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -146,7 +146,7 @@ static int handle_dhcpv6_leases(_unused struct ubus_context *ctx, _unused struct
blobmsg_close_array(&b, m);
m = blobmsg_open_array(&b, a->length == 128 ? "ipv6-addr": "ipv6-prefix");
- dhcpv6_enum_ia_addrs(iface, a, now, dhcpv6_blobmsg_ia_addr, NULL);
+ dhcpv6_ia_enum_addrs(iface, a, now, dhcpv6_blobmsg_ia_addr, NULL);
blobmsg_close_table(&b, m);
blobmsg_add_u32(&b, "valid", INFINITE_VALID(a->valid_until) ?