]> git.pld-linux.org Git - packages/iproute2.git/blame - 001-net-dev-iface-descr-0.1.diff
- up to 3.4.0
[packages/iproute2.git] / 001-net-dev-iface-descr-0.1.diff
CommitLineData
91d521f5
PG
1diff -Nur iproute2-2.6.16-060323.orig/ip/ipaddress.c iproute2-2.6.16-060323/ip/ipaddress.c
2--- iproute2-2.6.16-060323.orig/ip/ipaddress.c 2005-09-21 21:33:18.000000000 +0200
3+++ iproute2-2.6.16-060323/ip/ipaddress.c 2006-07-07 12:09:50.000000000 +0200
4@@ -127,6 +127,28 @@
5 printf("qlen %d", ifr.ifr_qlen);
6 }
7
8+void print_description(char *name)
9+{
10+ struct ifreq ifr;
11+ int s;
12+
13+ s = socket(AF_INET, SOCK_STREAM, 0);
14+ if (s < 0)
15+ return;
16+
17+ memset(&ifr, 0, sizeof(ifr));
18+ strcpy(ifr.ifr_name, name);
19+ if (ioctl(s, SIOCGIFDESCR, &ifr) < 0) {
20+ perror("SIOCGIFDESCR");
21+ close(s);
22+ return;
23+ }
24+ close(s);
25+
26+ if (ifr.ifr_description[0])
27+ printf("\n descr %s", ifr.ifr_description);
28+}
29+
30 int print_linkinfo(const struct sockaddr_nl *who,
31 struct nlmsghdr *n, void *arg)
32 {
33@@ -192,6 +214,8 @@
34 if (filter.showqueue)
35 print_queuelen((char*)RTA_DATA(tb[IFLA_IFNAME]));
36
37+ print_description((char*)RTA_DATA(tb[IFLA_IFNAME]));
38+
39 if (!filter.family || filter.family == AF_PACKET) {
40 SPRINT_BUF(b1);
41 fprintf(fp, "%s", _SL_);
42diff -Nur iproute2-2.6.16-060323.orig/ip/iplink.c iproute2-2.6.16-060323/ip/iplink.c
43--- iproute2-2.6.16-060323.orig/ip/iplink.c 2006-03-22 00:57:50.000000000 +0100
44+++ iproute2-2.6.16-060323/ip/iplink.c 2006-07-07 11:46:17.000000000 +0200
45@@ -45,6 +45,7 @@
46 fprintf(stderr, " trailers { on | off } |\n");
47 fprintf(stderr, " txqueuelen PACKETS |\n");
48 fprintf(stderr, " name NEWNAME |\n");
49+ fprintf(stderr, " descr NEWDESCR |\n");
50 fprintf(stderr, " address LLADDR | broadcast LLADDR |\n");
51 fprintf(stderr, " mtu MTU }\n");
52 fprintf(stderr, " ip link show [ DEVICE ]\n");
53@@ -130,6 +131,27 @@
54 return err;
55 }
56
57+static int do_changedescr(const char *dev, const char *newdescr)
58+{
59+ struct ifreq ifr;
60+ int fd;
61+ int err;
62+
63+ strncpy(ifr.ifr_name, dev, IFNAMSIZ);
64+ strncpy(ifr.ifr_description, newdescr, NET_DEV_DESCR_LEN);
65+ fd = get_ctl_fd();
66+ if (fd < 0)
67+ return -1;
68+ err = ioctl(fd, SIOCSIFDESCR, &ifr);
69+ if (err) {
70+ perror("SIOCSIFDESCR");
71+ close(fd);
72+ return -1;
73+ }
74+ close(fd);
75+ return err;
76+}
77+
78 static int set_qlen(const char *dev, int qlen)
79 {
80 struct ifreq ifr;
81@@ -262,6 +284,7 @@
82 char *newbrd = NULL;
83 struct ifreq ifr0, ifr1;
84 char *newname = NULL;
85+ char *newdescr = NULL;
86 int htype, halen;
87
88 while (argc > 0) {
89@@ -274,6 +297,9 @@
90 } else if (strcmp(*argv, "name") == 0) {
91 NEXT_ARG();
92 newname = *argv;
93+ } else if (strcmp(*argv, "descr") == 0) {
94+ NEXT_ARG();
95+ newdescr = *argv;
96 } else if (matches(*argv, "address") == 0) {
97 NEXT_ARG();
98 newaddr = *argv;
99@@ -388,6 +414,10 @@
100 return -1;
101 dev = newname;
102 }
103+ if (newdescr) {
104+ if (do_changedescr(dev, newdescr) < 0)
105+ return -1;
106+ }
107 if (qlen != -1) {
108 if (set_qlen(dev, qlen) < 0)
109 return -1;
This page took 0.079371 seconds and 4 git commands to generate.