projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
network "default" --> bb_INET_default. Reduce 2 exported from find applet
[oweals/busybox.git]
/
networking
/
libiproute
/
iplink.c
diff --git
a/networking/libiproute/iplink.c
b/networking/libiproute/iplink.c
index 33f38918a8b76874accec76d0f7e883ac9138ddf..2550c196e493ef2cae628fefe7e80d77f158f0c3 100644
(file)
--- a/
networking/libiproute/iplink.c
+++ b/
networking/libiproute/iplink.c
@@
-10,34
+10,40
@@
*
*/
*
*/
-#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <linux/version.h>
+
+#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <unistd.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_packet.h>
+
+#include <net/if.h>
+#include <net/if_packet.h>
+#include <netpacket/packet.h>
+
+#if __GLIBC__ >=2 && __GLIBC_MINOR >= 1
+#include <net/ethernet.h>
+#else
#include <linux/if_ether.h>
#include <linux/if_ether.h>
-#include <linux/sockios.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <linux/sockios.h>
+#endif
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
-#include "busybox.h"
+#include "libbb.h"
+
+
+/* take from linux/sockios.h */
+#define SIOCSIFNAME 0x8923 /* set interface name */
static int do_link;
static int on_off(char *msg)
{
static int do_link;
static int on_off(char *msg)
{
- error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg);
+
bb_
error_msg("Error: argument of \"%s\" must be \"on\" or \"off\"", msg);
return -1;
}
return -1;
}
@@
-90,6
+96,7
@@
static int do_chflags(char *dev, __u32 flags, __u32 mask)
static int do_changename(char *dev, char *newdev)
{
static int do_changename(char *dev, char *newdev)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
struct ifreq ifr;
int fd;
int err;
struct ifreq ifr;
int fd;
int err;
@@
-107,6
+114,8
@@
static int do_changename(char *dev, char *newdev)
}
close(fd);
return err;
}
close(fd);
return err;
+#endif
+ return 0;
}
static int set_qlen(char *dev, int qlen)
}
static int set_qlen(char *dev, int qlen)
@@
-119,8
+128,8
@@
static int set_qlen(char *dev, int qlen)
return -1;
memset(&ifr, 0, sizeof(ifr));
return -1;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, dev);
- ifr.ifr_qlen = qlen;
+ strcpy(ifr.ifr_name, dev);
+ ifr.ifr_qlen = qlen;
if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) {
perror("SIOCSIFXQLEN");
close(s);
if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) {
perror("SIOCSIFXQLEN");
close(s);
@@
-128,7
+137,7
@@
static int set_qlen(char *dev, int qlen)
}
close(s);
}
close(s);
- return 0;
+ return 0;
}
static int set_mtu(char *dev, int mtu)
}
static int set_mtu(char *dev, int mtu)
@@
-141,8
+150,8
@@
static int set_mtu(char *dev, int mtu)
return -1;
memset(&ifr, 0, sizeof(ifr));
return -1;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, dev);
- ifr.ifr_mtu = mtu;
+ strcpy(ifr.ifr_name, dev);
+ ifr.ifr_mtu = mtu;
if (ioctl(s, SIOCSIFMTU, &ifr) < 0) {
perror("SIOCSIFMTU");
close(s);
if (ioctl(s, SIOCSIFMTU, &ifr) < 0) {
perror("SIOCSIFMTU");
close(s);
@@
-150,7
+159,7
@@
static int set_mtu(char *dev, int mtu)
}
close(s);
}
close(s);
- return 0;
+ return 0;
}
static int get_address(char *dev, int *htype)
}
static int get_address(char *dev, int *htype)
@@
-161,7
+170,7
@@
static int get_address(char *dev, int *htype)
int s;
s = socket(PF_PACKET, SOCK_DGRAM, 0);
int s;
s = socket(PF_PACKET, SOCK_DGRAM, 0);
- if (s < 0) {
+ if (s < 0) {
perror("socket(PF_PACKET)");
return -1;
}
perror("socket(PF_PACKET)");
return -1;
}
@@
-206,10
+215,10
@@
static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr
if (alen < 0)
return -1;
if (alen != halen) {
if (alen < 0)
return -1;
if (alen != halen) {
- error_msg("Wrong address (%s) length: expected %d bytes", lla, halen);
+
bb_
error_msg("Wrong address (%s) length: expected %d bytes", lla, halen);
return -1;
}
return -1;
}
- return 0;
+ return 0;
}
static int set_address(struct ifreq *ifr, int brd)
}
static int set_address(struct ifreq *ifr, int brd)
@@
-225,7
+234,7
@@
static int set_address(struct ifreq *ifr, int brd)
return -1;
}
close(s);
return -1;
}
close(s);
- return 0;
+ return 0;
}
}
@@
-288,7
+297,7
@@
static int do_set(int argc, char **argv)
}
if (!dev) {
}
if (!dev) {
- error_msg("Not enough of information: \"dev\" argument is required.");
+
bb_
error_msg("Not enough of information: \"dev\" argument is required.");
exit(-1);
}
exit(-1);
}
@@
-302,7
+311,7
@@
static int do_set(int argc, char **argv)
}
if (newbrd) {
if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0)
}
if (newbrd) {
if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0)
- return -1;
+ return -1;
}
}
}
}
@@
-311,18
+320,18
@@
static int do_set(int argc, char **argv)
return -1;
dev = newname;
}
return -1;
dev = newname;
}
- if (qlen != -1) {
+ if (qlen != -1) {
if (set_qlen(dev, qlen) < 0)
if (set_qlen(dev, qlen) < 0)
- return -1;
+ return -1;
}
}
- if (mtu != -1) {
+ if (mtu != -1) {
if (set_mtu(dev, mtu) < 0)
if (set_mtu(dev, mtu) < 0)
- return -1;
+ return -1;
}
if (newaddr || newbrd) {
if (newbrd) {
if (set_address(&ifr1, 1) < 0)
}
if (newaddr || newbrd) {
if (newbrd) {
if (set_address(&ifr1, 1) < 0)
- return -1;
+ return -1;
}
if (newaddr) {
if (set_address(&ifr0, 0) < 0)
}
if (newaddr) {
if (set_address(&ifr0, 0) < 0)
@@
-338,7
+347,7
@@
static int ipaddr_list_link(int argc, char **argv)
{
preferred_family = AF_PACKET;
do_link = 1;
{
preferred_family = AF_PACKET;
do_link = 1;
- return ipaddr_list
(argc, argv
);
+ return ipaddr_list
_or_flush(argc, argv, 0
);
}
int do_iplink(int argc, char **argv)
}
int do_iplink(int argc, char **argv)
@@
-353,6
+362,6
@@
int do_iplink(int argc, char **argv)
} else
return ipaddr_list_link(0, NULL);
} else
return ipaddr_list_link(0, NULL);
-
error_msg("Command \"%s\" is unknown, try \"ip link help\"
.", *argv);
+
bb_error_msg("Command \"%s\" is unknown
.", *argv);
exit(-1);
}
exit(-1);
}