]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - net-tools/patches/net-tools-1.60-ifconfig.patch
Move all packages to root.
[people/ms/ipfire-3.x.git] / net-tools / patches / net-tools-1.60-ifconfig.patch
CommitLineData
236898d6
MT
1--- net-tools-1.60/ifconfig.c.new 2005-07-20 12:47:29.000000000 +0200
2+++ net-tools-1.60/ifconfig.c 2005-07-20 12:54:57.000000000 +0200
3@@ -175,6 +175,32 @@
4 return (0);
5 }
6
7+/** test is a specified flag is set */
8+static int test_flag(char *ifname, short flags)
9+{
10+ struct ifreq ifr;
11+ int fd;
12+
13+ if (strchr(ifname, ':')) {
14+ /* This is a v4 alias interface. Downing it via a socket for
15+ another AF may have bad consequences. */
16+ fd = get_socket_for_af(AF_INET);
17+ if (fd < 0) {
18+ fprintf(stderr, _("No support for INET on this system.\n"));
19+ return -1;
20+ }
21+ } else
22+ fd = skfd;
23+
24+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
25+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
26+ fprintf(stderr, _("%s: ERROR while testing interface flags: %s\n"),
27+ ifname, strerror(errno));
28+ return -1;
29+ }
30+ return (ifr.ifr_flags & flags);
31+}
32+
33 static void usage(void)
34 {
35 fprintf(stderr, _("Usage:\n ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]\n"));
36@@ -249,7 +275,7 @@
37 err = 1;
38 }
39 }
40- return 0;
41+ return err;
42 }
43
44 int main(int argc, char **argv)
45@@ -415,6 +441,8 @@
46 }
47 if (!strcmp(*spp, "-promisc")) {
48 goterr |= clr_flag(ifr.ifr_name, IFF_PROMISC);
49+ if (test_flag(ifr.ifr_name, IFF_PROMISC) > 0)
50+ fprintf(stderr, _("Warning: Interface %s still in promisc mode... maybe other application is running?\n"), ifr.ifr_name);
51 spp++;
52 continue;
53 }
54@@ -425,6 +453,8 @@
55 }
56 if (!strcmp(*spp, "-multicast")) {
57 goterr |= clr_flag(ifr.ifr_name, IFF_MULTICAST);
58+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
59+ fprintf(stderr, _("Warning: Interface %s still in MULTICAST mode.\n"), ifr.ifr_name);
60 spp++;
61 continue;
62 }
63@@ -435,6 +465,8 @@
64 }
65 if (!strcmp(*spp, "-allmulti")) {
66 goterr |= clr_flag(ifr.ifr_name, IFF_ALLMULTI);
67+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
68+ fprintf(stderr, _("Warning: Interface %s still in ALLMULTI mode.\n"), ifr.ifr_name);
69 spp++;
70 continue;
71 }
72@@ -456,6 +488,8 @@
73 }
74 if (!strcmp(*spp, "-dynamic")) {
75 goterr |= clr_flag(ifr.ifr_name, IFF_DYNAMIC);
76+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
77+ fprintf(stderr, _("Warning: Interface %s still in DYNAMIC mode.\n"), ifr.ifr_name);
78 spp++;
79 continue;
80 }
81@@ -513,6 +547,8 @@
82
83 if (!strcmp(*spp, "-broadcast")) {
84 goterr |= clr_flag(ifr.ifr_name, IFF_BROADCAST);
85+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
86+ fprintf(stderr, _("Warning: Interface %s still in BROADCAST mode.\n"), ifr.ifr_name);
87 spp++;
88 continue;
89 }
90@@ -569,7 +605,7 @@
91 continue;
92 }
93 didnetmask++;
94- goterr = set_netmask(ap->fd, &ifr, &sa, dobcast);
95+ goterr |= set_netmask(ap->fd, &ifr, &sa, dobcast);
96 spp++;
97 continue;
98 }
99@@ -640,6 +676,8 @@
100 }
101 if (!strcmp(*spp, "-pointopoint")) {
102 goterr |= clr_flag(ifr.ifr_name, IFF_POINTOPOINT);
103+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
104+ fprintf(stderr, _("Warning: Interface %s still in POINTOPOINT mode.\n"), ifr.ifr_name);
105 spp++;
106 continue;
107 }