projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
runsvd: shrink by Vladimir
[oweals/busybox.git]
/
networking
/
vconfig.c
diff --git
a/networking/vconfig.c
b/networking/vconfig.c
index b90f41085d1220de8b26c9e0641ccb23d3b34a7c..3f12e7609c6af6d33d4912c08cdf05b68ac6280f 100644
(file)
--- a/
networking/vconfig.c
+++ b/
networking/vconfig.c
@@
-9,7
+9,7
@@
/* BB_AUDIT SUSv3 N/A */
/* BB_AUDIT SUSv3 N/A */
-#include "
busybox
.h"
+#include "
libbb
.h"
#include <net/if.h>
/* Stuff from linux/if_vlan.h, kernel version 2.4.23 */
#include <net/if.h>
/* Stuff from linux/if_vlan.h, kernel version 2.4.23 */
@@
-63,7
+63,7
@@
static const char *xfind_str(const char *table, const char *str)
return table - 1;
}
return table - 1;
}
-static const char cmds[] = {
+static const char cmds[]
ALIGN1
= {
4, ADD_VLAN_CMD, 7,
'a', 'd', 'd', 0,
3, DEL_VLAN_CMD, 7,
4, ADD_VLAN_CMD, 7,
'a', 'd', 'd', 0,
3, DEL_VLAN_CMD, 7,
@@
-72,7
+72,7
@@
static const char cmds[] = {
's', 'e', 't', '_',
'n', 'a', 'm', 'e', '_',
't', 'y', 'p', 'e', 0,
's', 'e', 't', '_',
'n', 'a', 'm', 'e', '_',
't', 'y', 'p', 'e', 0,
-
4
, SET_VLAN_FLAG_CMD, 12,
+
5
, SET_VLAN_FLAG_CMD, 12,
's', 'e', 't', '_',
'f', 'l', 'a', 'g', 0,
5, SET_VLAN_EGRESS_PRIORITY_CMD, 18,
's', 'e', 't', '_',
'f', 'l', 'a', 'g', 0,
5, SET_VLAN_EGRESS_PRIORITY_CMD, 18,
@@
-85,7
+85,7
@@
static const char cmds[] = {
'm', 'a', 'p', 0,
};
'm', 'a', 'p', 0,
};
-static const char name_types[] = {
+static const char name_types[]
ALIGN1
= {
VLAN_NAME_TYPE_PLUS_VID, 16,
'V', 'L', 'A', 'N',
'_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D',
VLAN_NAME_TYPE_PLUS_VID, 16,
'V', 'L', 'A', 'N',
'_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D',
@@
-104,8
+104,9
@@
static const char name_types[] = {
'_', 'N', 'O', '_', 'P', 'A', 'D', 0,
};
'_', 'N', 'O', '_', 'P', 'A', 'D', 0,
};
-static const char conf_file_name[] = "/proc/net/vlan/config";
+static const char conf_file_name[]
ALIGN1
= "/proc/net/vlan/config";
+int vconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int vconfig_main(int argc, char **argv)
{
struct vlan_ioctl_args ifr;
int vconfig_main(int argc, char **argv)
{
struct vlan_ioctl_args ifr;
@@
-118,7
+119,7
@@
int vconfig_main(int argc, char **argv)
/* Don't bother closing the filedes. It will be closed on cleanup. */
/* Will die if 802.1q is not present */
/* Don't bother closing the filedes. It will be closed on cleanup. */
/* Will die if 802.1q is not present */
- xopen
3(conf_file_name, O_RDONLY, 0
);
+ xopen
(conf_file_name, O_RDONLY
);
memset(&ifr, 0, sizeof(struct vlan_ioctl_args));
memset(&ifr, 0, sizeof(struct vlan_ioctl_args));
@@
-132,10
+133,7
@@
int vconfig_main(int argc, char **argv)
if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */
ifr.u.name_type = *xfind_str(name_types+1, argv[1]);
} else {
if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */
ifr.u.name_type = *xfind_str(name_types+1, argv[1]);
} else {
- if (strlen(argv[1]) >= IF_NAMESIZE) {
- bb_error_msg_and_die("if_name >= %d chars\n", IF_NAMESIZE);
- }
- strcpy(ifr.device1, argv[1]);
+ strncpy(ifr.device1, argv[1], IFNAMSIZ);
p = argv[2];
/* I suppose one could try to combine some of the function calls below,
p = argv[2];
/* I suppose one could try to combine some of the function calls below,
@@
-144,20
+142,20
@@
int vconfig_main(int argc, char **argv)
* doing so wouldn't save that much space and would also make maintainence
* more of a pain. */
if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */
* doing so wouldn't save that much space and would also make maintainence
* more of a pain. */
if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */
- ifr.u.flag = bb_xgetularg10_bnd(p, 0, 1);
+ ifr.u.flag = xatoul_range(p, 0, 1);
+ /* DM: in order to set reorder header, qos must be set */
+ ifr.vlan_qos = xatoul_range(argv[3], 0, 7);
} else if (ifr.cmd == ADD_VLAN_CMD) { /* add */
} else if (ifr.cmd == ADD_VLAN_CMD) { /* add */
- ifr.u.VID =
bb_xgetularg10_bnd
(p, 0, VLAN_GROUP_ARRAY_LEN-1);
+ ifr.u.VID =
xatoul_range
(p, 0, VLAN_GROUP_ARRAY_LEN-1);
} else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */
} else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */
- ifr.u.skb_priority =
bb_xgetularg10_bnd(p, 0, ULONG_MAX
);
- ifr.vlan_qos =
bb_xgetularg10_bnd
(argv[3], 0, 7);
+ ifr.u.skb_priority =
xatou(p
);
+ ifr.vlan_qos =
xatoul_range
(argv[3], 0, 7);
}
}
fd = xsocket(AF_INET, SOCK_STREAM, 0);
}
}
fd = xsocket(AF_INET, SOCK_STREAM, 0);
- if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) {
- bb_perror_msg_and_die("ioctl error for %s", *argv);
- }
+ ioctl_or_perror_and_die(fd, SIOCSIFVLAN, &ifr,
+ "ioctl error for %s", *argv);
return 0;
}
return 0;
}
-