static int
get_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, int fd, int flags,
- int (*callback)(struct dhcpcd_ctx *, struct interface *,
- struct nlmsghdr *, void *), void *data)
+ int (*callback)(struct dhcpcd_ctx *, struct interface *, struct nlmsghdr *))
{
char *buf = NULL, *nbuf;
ssize_t bytes;
if (r)
continue;
if (callback) {
- r = callback(ctx, ifp, nlm, data);
+ r = callback(ctx, ifp, nlm);
if (r != 0)
goto eexit;
}
static int
link_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
- struct nlmsghdr *nlm, __unused void *data)
+ struct nlmsghdr *nlm)
{
int r;
size_t len;
{
return get_netlink(ctx, NULL,
- ctx->link_fd, MSG_DONTWAIT, &link_netlink, NULL);
+ ctx->link_fd, MSG_DONTWAIT, &link_netlink);
}
static int
send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
int protocol, struct nlmsghdr *hdr,
- int (*callback)(struct dhcpcd_ctx *, struct interface *,
- struct nlmsghdr *, void *), void *data)
+ int (*callback)(struct dhcpcd_ctx *, struct interface *, struct nlmsghdr *))
{
int s, r;
struct sockaddr_nl snl;
hdr->nlmsg_seq = ++seq;
if (sendmsg(s, &msg, 0) != -1)
- r = get_netlink(ctx, ifp, s, 0, callback, data);
+ r = get_netlink(ctx, ifp, s, 0, callback);
else
r = -1;
close(s);
static int
_gnl_getfamily(__unused struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
- struct nlmsghdr *nlm, __unused void *data)
+ struct nlmsghdr *nlm)
{
struct nlattr *tb[CTRL_ATTR_FAMILY_ID + 1];
uint16_t family;
CTRL_ATTR_FAMILY_NAME, name) == -1)
return -1;
return send_netlink(ctx, NULL, NETLINK_GENERIC, &nlm.hdr,
- &_gnl_getfamily, NULL);
+ &_gnl_getfamily);
}
static int
_if_getssid(__unused struct dhcpcd_ctx *ctx, struct interface *ifp,
- struct nlmsghdr *nlm, __unused void *data)
+ struct nlmsghdr *nlm)
{
struct nlattr *tb[NL80211_ATTR_SSID + 1];
nla_put_32(&nlm.hdr, sizeof(nlm), NL80211_ATTR_IFINDEX, ifp->index);
return send_netlink(ifp->ctx, ifp,
- NETLINK_GENERIC, &nlm.hdr, &_if_getssid, NULL);
+ NETLINK_GENERIC, &nlm.hdr, &_if_getssid);
}
#endif
add_attr_l(&nlm.hdr, sizeof(nlm), IFA_BROADCAST,
&broadcast->s_addr, sizeof(broadcast->s_addr));
- if (send_netlink(iface->ctx, NULL, NETLINK_ROUTE, &nlm.hdr,
- NULL, NULL) == -1)
+ if (send_netlink(iface->ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL) == -1)
retval = -1;
return retval;
}
-static int
-_if_copyrt(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
- struct nlmsghdr *nlm, void *data)
-{
-
- return if_copyrt(ctx, (struct rt *)data, nlm);
-}
-
int
-if_route(unsigned char cmd, const struct rt *rt, struct rt *srt)
+if_route(unsigned char cmd, const struct rt *rt)
{
struct nlmr nlm;
int retval = 0;
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
switch (cmd) {
- case RTM_GET:
- nlm.hdr.nlmsg_type = RTM_GETROUTE;
- break;
case RTM_CHANGE:
nlm.hdr.nlmsg_type = RTM_NEWROUTE;
nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE;
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY, rt->metric);
if (send_netlink(rt->iface->ctx, NULL,
- NETLINK_ROUTE, &nlm.hdr, &_if_copyrt, srt) == -1)
+ NETLINK_ROUTE, &nlm.hdr, NULL) == -1)
retval = -1;
return retval;
}
static int
_if_initrt(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
- struct nlmsghdr *nlm, __unused void *data)
+ struct nlmsghdr *nlm)
{
struct rt rt;
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
return send_netlink(ifp->ctx, ifp,
- NETLINK_ROUTE, &nlm.hdr, &_if_initrt, NULL);
+ NETLINK_ROUTE, &nlm.hdr, &_if_initrt);
}
#endif
add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
#endif
- if (send_netlink(ap->iface->ctx, NULL,
- NETLINK_ROUTE, &nlm.hdr, NULL, NULL) == -1)
+ if (send_netlink(ap->iface->ctx, NULL, NETLINK_ROUTE, &nlm.hdr,
+ NULL) == -1)
retval = -1;
return retval;
}
return 0;
}
-static int
-_if_copyrt6(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
- struct nlmsghdr *nlm, void *data)
-{
-
- return if_copyrt6(ctx, (struct rt6 *)data, nlm);
-}
-
int
-if_route6(unsigned char cmd, const struct rt6 *rt, struct rt6 *srt)
+if_route6(unsigned char cmd, const struct rt6 *rt)
{
struct nlmr nlm;
int retval = 0;
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
switch (cmd) {
- case RTM_GET:
- nlm.hdr.nlmsg_type = RTM_GETROUTE;
- break;
case RTM_CHANGE:
nlm.hdr.nlmsg_type = RTM_NEWROUTE;
nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE;
}
if (send_netlink(rt->iface->ctx, NULL,
- NETLINK_ROUTE, &nlm.hdr, &_if_copyrt6, srt) == -1)
+ NETLINK_ROUTE, &nlm.hdr, NULL) == -1)
retval = -1;
return retval;
}
static int
_if_initrt6(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
- struct nlmsghdr *nlm, __unused void *data)
+ struct nlmsghdr *nlm)
{
struct rt6 rt;
add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
return send_netlink(ifp->ctx, ifp,
- NETLINK_ROUTE, &nlm.hdr, &_if_initrt6, NULL);
+ NETLINK_ROUTE, &nlm.hdr, &_if_initrt6);
}
int
add_attr_nest_end(&nlm.hdr, afs6);
add_attr_nest_end(&nlm.hdr, afs);
- return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL, NULL);
+ return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL);
}
static const char *prefix = "/proc/sys/net/ipv6/conf";