1 diff -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
10 +vid_aton(char *string, uint16_t *vid)
15 + if (sscanf(string, "%i", &i) != 1 || i > 0xffff)
17 + *vid = htons(i & 0xffff);
20 diff -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
27 +.Op Nm vid Ar vlan_id
29 Prepend the data read from standard input with an Ethernet header on
30 standard output. The Ethernet
31 diff -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
38 - fprintf(stderr, "Usage: dnet eth [type|src|dst <value>] ... \n");
39 + fprintf(stderr, "Usage: dnet eth [type|src|dst|vid <value>] ... \n");
44 eth_main(int argc, char *argv[])
49 - u_char *p, buf[ETH_LEN_MAX]; /* XXX */
50 + u_char *p, buf[ETH_LEN_MAX + 4]; /* XXX */
53 + int c, len, is_tagged = 0;
55 eth = (struct eth_hdr *)buf;
56 memset(eth, 0, sizeof(*eth));
60 if (strcmp(name, "type") == 0) {
61 - if (type_aton(value, ð->eth_type) < 0)
62 + if (type_aton(value, &type) < 0)
66 + memmove(((uint8_t *)ð->eth_type) + 4, &type, sizeof(uint16_t));
68 + eth->eth_type = type;
69 } else if (strcmp(name, "src") == 0) {
70 if (addr_aton(value, &addr) < 0)
73 if (addr_aton(value, &addr) < 0)
75 memcpy(ð->eth_dst, &addr.addr_eth, ETH_ADDR_LEN);
76 + } else if (strcmp(name, "vid") == 0) {
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));
88 if (isatty(STDIN_FILENO))
89 errx(1, "can't read Ethernet payload from tty");
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);
96 while ((c = read(STDIN_FILENO, p, len)) > 0) {