summaryrefslogtreecommitdiff
path: root/networking/libiproute/libnetlink.c
diff options
context:
space:
mode:
authorEric Andersen2006-03-03 18:37:39 +0000
committerEric Andersen2006-03-03 18:37:39 +0000
commitcbd1c857440347df90810fe93569db959096b9c5 (patch)
tree916d39cb3c7028f4320a56723bc08862520b36a3 /networking/libiproute/libnetlink.c
parentc05dda4b2dfe8893c751c39469ef14d690c354ac (diff)
downloadbusybox-cbd1c857440347df90810fe93569db959096b9c5.zip
busybox-cbd1c857440347df90810fe93569db959096b9c5.tar.gz
Kill off some unused code that was wasting several k, as noticed by
Denis Vlasenko when building with -ffunction-sections -fdata-sections
Diffstat (limited to 'networking/libiproute/libnetlink.c')
-rw-r--r--networking/libiproute/libnetlink.c128
1 files changed, 0 insertions, 128 deletions
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c
index efbb6f1..ad5bcd7 100644
--- a/networking/libiproute/libnetlink.c
+++ b/networking/libiproute/libnetlink.c
@@ -319,134 +319,6 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
}
}
-int rtnl_listen(struct rtnl_handle *rtnl,
- int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
- void *jarg)
-{
- int status;
- struct nlmsghdr *h;
- struct sockaddr_nl nladdr;
- struct iovec iov;
- char buf[8192];
- struct msghdr msg = {
- (void*)&nladdr, sizeof(nladdr),
- &iov, 1,
- NULL, 0,
- 0
- };
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
- nladdr.nl_pid = 0;
- nladdr.nl_groups = 0;
-
-
- iov.iov_base = buf;
-
- while (1) {
- iov.iov_len = sizeof(buf);
- status = recvmsg(rtnl->fd, &msg, 0);
-
- if (status < 0) {
- if (errno == EINTR)
- continue;
- bb_perror_msg("OVERRUN");
- continue;
- }
- if (status == 0) {
- bb_error_msg("EOF on netlink");
- return -1;
- }
- if (msg.msg_namelen != sizeof(nladdr)) {
- bb_error_msg_and_die("Sender address length == %d", msg.msg_namelen);
- }
- for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) {
- int err;
- int len = h->nlmsg_len;
- int l = len - sizeof(*h);
-
- if (l<0 || len>status) {
- if (msg.msg_flags & MSG_TRUNC) {
- bb_error_msg("Truncated message");
- return -1;
- }
- bb_error_msg_and_die("!!!malformed message: len=%d", len);
- }
-
- err = handler(&nladdr, h, jarg);
- if (err < 0) {
- return err;
- }
-
- status -= NLMSG_ALIGN(len);
- h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len));
- }
- if (msg.msg_flags & MSG_TRUNC) {
- bb_error_msg("Message truncated");
- continue;
- }
- if (status) {
- bb_error_msg_and_die("!!!Remnant of size %d", status);
- }
- }
-}
-
-int rtnl_from_file(FILE *rtnl,
- int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
- void *jarg)
-{
- int status;
- struct sockaddr_nl nladdr;
- char buf[8192];
- struct nlmsghdr *h = (void*)buf;
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
- nladdr.nl_pid = 0;
- nladdr.nl_groups = 0;
-
- while (1) {
- int err, len, type;
- int l;
-
- status = fread(&buf, 1, sizeof(*h), rtnl);
-
- if (status < 0) {
- if (errno == EINTR)
- continue;
- bb_perror_msg("rtnl_from_file: fread");
- return -1;
- }
- if (status == 0)
- return 0;
-
- len = h->nlmsg_len;
- type= h->nlmsg_type;
- l = len - sizeof(*h);
-
- if (l<0 || len>sizeof(buf)) {
- bb_error_msg("!!!malformed message: len=%d @%lu",
- len, ftell(rtnl));
- return -1;
- }
-
- status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl);
-
- if (status < 0) {
- bb_perror_msg("rtnl_from_file: fread");
- return -1;
- }
- if (status < l) {
- bb_error_msg("rtnl-from_file: truncated message");
- return -1;
- }
-
- err = handler(&nladdr, h, jarg);
- if (err < 0)
- return err;
- }
-}
-
int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
{
int len = RTA_LENGTH(4);