Mercurial > hg > toybox
annotate toys/other/vconfig.c @ 1104:e11684e3bbc5 draft
Merge toynet.h into toys.h: musl supports it and micromanaging uClibc config options isn't very interesting anymore.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 02 Nov 2013 14:24:33 -0500 |
parents | bc09fa708d94 |
children | 30a210bae3e9 |
rev | line source |
---|---|
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
1 /* vconfig.c - Creates virtual ethernet devices. |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
2 * |
1103 | 3 * Copyright 2012 Sandeep Sharma <sandeep.jack2756@gmail.com> |
4 * Copyright 2012 Kyungwan Han <asura321@gmail.com> | |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
5 * |
1103 | 6 * No standard |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
7 |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
8 USE_VCONFIG(NEWTOY(vconfig, "<2>4", TOYFLAG_NEEDROOT|TOYFLAG_SBIN)) |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
9 |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
10 config VCONFIG |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
11 bool "vconfig" |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
12 default y |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
13 help |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
14 usage: vconfig COMMAND [OPTIONS] |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
15 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
16 add [interface-name] [vlan_id] |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
17 rem [vlan-name] |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
18 set_flag [interface-name] [flag-num] [0 | 1] |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
19 set_egress_map [vlan-name] [skb_priority] [vlan_qos] |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
20 set_ingress_map [vlan-name] [skb_priority] [vlan_qos] |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
21 set_name_type [name-type] |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
22 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
23 Create and remove virtual ethernet devices |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
24 */ |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
25 |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
26 #include "toys.h" |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
27 #include <linux/if_vlan.h> |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
28 #include <linux/sockios.h> |
1103 | 29 |
30 static int strtorange(char *str, int min, int max) | |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
31 { |
1103 | 32 char *end = 0; |
33 long val = strtol(str, &end, 10); | |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
34 |
1103 | 35 if (end && *end && end != str && val >= min && val <= max) return val; |
36 | |
37 perror_exit("%s not %d-%d\n", str, min, max); | |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
38 } |
1103 | 39 |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
40 void vconfig_main(void) |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
41 { |
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
42 #define MAX_VLAN_ID 4094 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
43 struct vlan_ioctl_args request; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
44 char *interface_name = NULL; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
45 unsigned int name_type = VLAN_NAME_TYPE_PLUS_VID; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
46 char *cmd; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
47 int fd = 0; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
48 int vlan_id = 0; |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
49 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
50 if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) perror_exit("Can't open socket"); //Use socket instead of open |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
51 memset(&request, 0, sizeof(struct vlan_ioctl_args)); // Null set all the VLAN info's. |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
52 cmd = toys.optargs[0]; // Fetch cmd and proceed. |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
53 if(strcmp(cmd, "set_name_type") == 0) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
54 if(strcmp(toys.optargs[1], "VLAN_PLUS_VID") == 0) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
55 name_type = VLAN_NAME_TYPE_PLUS_VID; |
1103 | 56 } else if(strcmp(toys.optargs[1], "VLAN_PLUS_VID_NO_PAD") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
57 name_type = VLAN_NAME_TYPE_PLUS_VID_NO_PAD; |
1103 | 58 } else if(strcmp(toys.optargs[1], "DEV_PLUS_VID") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
59 name_type = VLAN_NAME_TYPE_RAW_PLUS_VID; |
1103 | 60 } else if(strcmp(toys.optargs[1], "DEV_PLUS_VID_NO_PAD") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
61 name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; |
1103 | 62 } else perror_exit("ERROR: Invalid name type"); |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
63 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
64 request.u.name_type = name_type; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
65 request.cmd = SET_VLAN_NAME_TYPE_CMD; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
66 if(ioctl(fd, SIOCSIFVLAN, &request) == 0) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
67 xprintf("Successful set_name_type for VLAN subsystem\n"); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
68 exit(EXIT_SUCCESS); |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
69 } |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
70 else perror_exit("Failed to set set_name_type:"); |
1103 | 71 } else { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
72 interface_name = toys.optargs[1]; // Store interface name. |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
73 if(strlen(interface_name) > 15) perror_exit("ERROR:if_name length can not be greater than 15"); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
74 strcpy(request.device1, interface_name); //we had exited if interface_name length greater than 15, so here it never overflows. |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
75 } |
683
8d7fbb4c2205
Add vconfig.c - Creates virtual ethernet devices.
Kyungwan Han <asura321@gmail.com>
parents:
diff
changeset
|
76 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
77 if(strcmp(cmd, "add") == 0) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
78 request.cmd = ADD_VLAN_CMD; |
1103 | 79 if(toys.optargs[2]) vlan_id = strtorange(toys.optargs[2], 0, MAX_VLAN_ID); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
80 else vlan_id = 0; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
81 request.u.VID = vlan_id; |
1103 | 82 } else if(strcmp(cmd, "rem") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
83 request.cmd = DEL_VLAN_CMD; |
1103 | 84 } else if(strcmp(cmd, "set_flag") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
85 request.cmd = SET_VLAN_FLAG_CMD; |
1103 | 86 if(toys.optargs[2]) request.u.flag = strtorange(toys.optargs[2], 0, 1); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
87 else request.u.flag = 0; |
1103 | 88 if(toys.optargs[3]) request.vlan_qos = strtorange(toys.optargs[3], 0, 7); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
89 else request.vlan_qos = 0; |
1103 | 90 } else if(strcmp(cmd, "set_egress_map") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
91 request.cmd = SET_VLAN_EGRESS_PRIORITY_CMD; |
1103 | 92 if(toys.optargs[2]) request.u.skb_priority = strtorange(toys.optargs[2], 0, INT_MAX); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
93 else request.u.skb_priority = 0; |
1103 | 94 if(toys.optargs[3]) request.vlan_qos = strtorange(toys.optargs[3], 0, 7); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
95 else request.vlan_qos = 0; |
1103 | 96 } else if(strcmp(cmd, "set_ingress_map") == 0) { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
97 request.cmd = SET_VLAN_INGRESS_PRIORITY_CMD; |
1103 | 98 if(toys.optargs[2]) request.u.skb_priority = strtorange(toys.optargs[2], 0, INT_MAX); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
99 else request.u.skb_priority = 0; |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
100 //To set flag we must have to set vlan_qos |
1103 | 101 if(toys.optargs[3]) request.vlan_qos = strtorange(toys.optargs[3], 0, 7); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
102 else request.vlan_qos = 0; |
1103 | 103 } else { |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
104 xclose(fd); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
105 perror_exit("Unknown command %s", cmd); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
106 } |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
107 if(ioctl(fd, SIOCSIFVLAN, &request) == 0) { |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
108 if(strcmp(cmd, "add") == 0 && vlan_id == 1) |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
109 xprintf("WARNING: VLAN 1 does not work with many switches,consider another number if you have problems.\n"); |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
110 xprintf("Successful %s on device %s\n", cmd, interface_name); |
1103 | 111 } else perror_exit("Failed to %s, on vlan subsystem %s.", cmd, interface_name); |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
683
diff
changeset
|
112 } |