]> git.pld-linux.org Git - packages/libdnet.git/blame - libdnet-vlan.patch
- release 4 (by relup.sh)
[packages/libdnet.git] / libdnet-vlan.patch
CommitLineData
30804fcb
AO
1diff -ruN libdnet-1.11.orig/test/dnet/aton.c libdnet-1.11/test/dnet/aton.c
2--- libdnet-1.11.orig/test/dnet/aton.c 2002-10-14 17:42:10.000000000 +0200
3+++ libdnet-1.11/test/dnet/aton.c 2011-12-03 23:15:33.472366712 +0100
4@@ -222,3 +222,15 @@
5 }
6 return (u - buf);
7 }
8+
9+int
10+vid_aton(char *string, uint16_t *vid)
11+{
12+ u_int i;
13+
14+ /* XXX */
15+ if (sscanf(string, "%i", &i) != 1 || i > 0xffff)
16+ return (-1);
17+ *vid = htons(i & 0xffff);
18+ return (0);
19+}
20diff -ruN libdnet-1.11.orig/test/dnet/dnet.8 libdnet-1.11/test/dnet/dnet.8
21--- libdnet-1.11.orig/test/dnet/dnet.8 2002-04-01 09:11:34.000000000 +0200
22+++ libdnet-1.11/test/dnet/dnet.8 2011-12-03 23:10:04.055399746 +0100
23@@ -42,6 +42,7 @@
24 .Op Nm type Ar type
25 .Op Nm src Ar mac
26 .Op Nm dst Ar mac
27+.Op Nm vid Ar vlan_id
28 .Xc
29 Prepend the data read from standard input with an Ethernet header on
30 standard output. The Ethernet
31diff -ruN libdnet-1.11.orig/test/dnet/eth.c libdnet-1.11/test/dnet/eth.c
32--- libdnet-1.11.orig/test/dnet/eth.c 2002-02-08 08:43:53.000000000 +0100
33+++ libdnet-1.11/test/dnet/eth.c 2011-12-03 23:16:31.263588754 +0100
34@@ -23,7 +23,7 @@
35 void
36 eth_usage(void)
37 {
38- fprintf(stderr, "Usage: dnet eth [type|src|dst <value>] ... \n");
39+ fprintf(stderr, "Usage: dnet eth [type|src|dst|vid <value>] ... \n");
40 exit(1);
41 }
42
43@@ -31,10 +31,11 @@
44 eth_main(int argc, char *argv[])
45 {
46 struct eth_hdr *eth;
47+ uint16_t type, vid;
48 struct addr addr;
49- u_char *p, buf[ETH_LEN_MAX]; /* XXX */
50+ u_char *p, buf[ETH_LEN_MAX + 4]; /* XXX */
51 char *name, *value;
52- int c, len;
53+ int c, len, is_tagged = 0;
54
55 eth = (struct eth_hdr *)buf;
56 memset(eth, 0, sizeof(*eth));
57@@ -45,8 +46,13 @@
58 value = argv[c + 1];
59
60 if (strcmp(name, "type") == 0) {
61- if (type_aton(value, &eth->eth_type) < 0)
62+ if (type_aton(value, &type) < 0)
63 eth_usage();
64+
65+ if (is_tagged)
66+ memmove(((uint8_t *)&eth->eth_type) + 4, &type, sizeof(uint16_t));
67+ else
68+ eth->eth_type = type;
69 } else if (strcmp(name, "src") == 0) {
70 if (addr_aton(value, &addr) < 0)
71 eth_usage();
72@@ -55,6 +61,14 @@
73 if (addr_aton(value, &addr) < 0)
74 eth_usage();
75 memcpy(&eth->eth_dst, &addr.addr_eth, ETH_ADDR_LEN);
76+ } else if (strcmp(name, "vid") == 0) {
77+ if (is_tagged)
78+ eth_usage();
79+ memmove(buf + ETH_HDR_LEN - ETH_TYPE_LEN + 4, buf + ETH_HDR_LEN - ETH_TYPE_LEN, ETH_LEN_MAX - ETH_HDR_LEN + ETH_TYPE_LEN);
80+ eth->eth_type = htons(ETH_TYPE_8021Q);
81+ vid_aton(value, &vid);
82+ memmove(buf + ETH_HDR_LEN, &vid, sizeof(uint16_t));
83+ is_tagged = 1;
84 } else
85 eth_usage();
86 }
87@@ -67,8 +81,8 @@
88 if (isatty(STDIN_FILENO))
89 errx(1, "can't read Ethernet payload from tty");
90
91- p = buf + ETH_HDR_LEN;
92- len = sizeof(buf) - (p - buf);
93+ p = buf + ETH_HDR_LEN + (is_tagged ? 4 : 0);
94+ len = sizeof(buf) - (p - buf) - (is_tagged ? 0 : 4);
95
96 while ((c = read(STDIN_FILENO, p, len)) > 0) {
97 p += c;
This page took 0.068832 seconds and 4 git commands to generate.