Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/networking/vconfig.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/vconfig.c
r821 r1770 10 10 /* BB_AUDIT SUSv3 N/A */ 11 11 12 #include <stdlib.h> 13 #include <unistd.h> 14 #include <fcntl.h> 15 #include <sys/ioctl.h> 12 #include "libbb.h" 16 13 #include <net/if.h> 17 #include <string.h>18 #include <limits.h>19 #include "busybox.h"20 14 21 15 /* Stuff from linux/if_vlan.h, kernel version 2.4.23 */ … … 70 64 } 71 65 72 static const char cmds[] = {66 static const char cmds[] ALIGN1 = { 73 67 4, ADD_VLAN_CMD, 7, 74 68 'a', 'd', 'd', 0, … … 79 73 'n', 'a', 'm', 'e', '_', 80 74 't', 'y', 'p', 'e', 0, 81 4, SET_VLAN_FLAG_CMD, 12,75 5, SET_VLAN_FLAG_CMD, 12, 82 76 's', 'e', 't', '_', 83 77 'f', 'l', 'a', 'g', 0, … … 92 86 }; 93 87 94 static const char name_types[] = {88 static const char name_types[] ALIGN1 = { 95 89 VLAN_NAME_TYPE_PLUS_VID, 16, 96 90 'V', 'L', 'A', 'N', … … 111 105 }; 112 106 113 static const char conf_file_name[] = "/proc/net/vlan/config";107 static const char conf_file_name[] ALIGN1 = "/proc/net/vlan/config"; 114 108 109 int vconfig_main(int argc, char **argv); 115 110 int vconfig_main(int argc, char **argv) 116 111 { … … 125 120 /* Don't bother closing the filedes. It will be closed on cleanup. */ 126 121 /* Will die if 802.1q is not present */ 127 bb_xopen3(conf_file_name, O_RDONLY, 0);122 xopen(conf_file_name, O_RDONLY); 128 123 129 124 memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); … … 140 135 } else { 141 136 if (strlen(argv[1]) >= IF_NAMESIZE) { 142 bb_error_msg_and_die("if_name >= %d chars \n", IF_NAMESIZE);137 bb_error_msg_and_die("if_name >= %d chars", IF_NAMESIZE); 143 138 } 144 139 strcpy(ifr.device1, argv[1]); … … 151 146 * more of a pain. */ 152 147 if (ifr.cmd == SET_VLAN_FLAG_CMD) { /* set_flag */ 153 ifr.u.flag = bb_xgetularg10_bnd(p, 0, 1); 148 ifr.u.flag = xatoul_range(p, 0, 1); 149 /* DM: in order to set reorder header, qos must be set */ 150 ifr.vlan_qos = xatoul_range(argv[3], 0, 7); 154 151 } else if (ifr.cmd == ADD_VLAN_CMD) { /* add */ 155 ifr.u.VID = bb_xgetularg10_bnd(p, 0, VLAN_GROUP_ARRAY_LEN-1);152 ifr.u.VID = xatoul_range(p, 0, VLAN_GROUP_ARRAY_LEN-1); 156 153 } else if (ifr.cmd != DEL_VLAN_CMD) { /* set_{egress|ingress}_map */ 157 ifr.u.skb_priority = bb_xgetularg10_bnd(p, 0, ULONG_MAX);158 ifr.vlan_qos = bb_xgetularg10_bnd(argv[3], 0, 7);154 ifr.u.skb_priority = xatou(p); 155 ifr.vlan_qos = xatoul_range(argv[3], 0, 7); 159 156 } 160 157 } 161 158 162 fd = bb_xsocket(AF_INET, SOCK_STREAM, 0); 163 if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) { 164 bb_perror_msg_and_die("ioctl error for %s", *argv); 165 } 159 fd = xsocket(AF_INET, SOCK_STREAM, 0); 160 ioctl_or_perror_and_die(fd, SIOCSIFVLAN, &ifr, 161 "ioctl error for %s", *argv); 166 162 167 163 return 0; 168 164 } 169
Note:
See TracChangeset
for help on using the changeset viewer.