]>
Commit | Line | Data |
---|---|---|
236898d6 MT |
1 | --- net-tools-1.60/ifconfig.c.netmask 2001-04-13 20:25:18.000000000 +0200 |
2 | +++ net-tools-1.60/ifconfig.c 2004-11-02 15:31:56.454594456 +0100 | |
3 | @@ -23,6 +23,7 @@ | |
4 | * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu | |
5 | * (default AF was wrong) | |
6 | * 20010404 - Arnaldo Carvalho de Melo, use setlocale | |
7 | + * 20040831 - Florin Malita <fmalita@glenayre.com> delayed CIDR netmask | |
8 | */ | |
9 | ||
10 | #define DFLT_AF "inet" | |
11 | @@ -227,13 +228,13 @@ | |
12 | ||
13 | int main(int argc, char **argv) | |
14 | { | |
15 | - struct sockaddr sa; | |
16 | + struct sockaddr sa, sa_netmask; | |
17 | struct sockaddr_in sin; | |
18 | char host[128]; | |
19 | struct aftype *ap; | |
20 | struct hwtype *hw; | |
21 | struct ifreq ifr; | |
22 | - int goterr = 0, didnetmask = 0; | |
23 | + int goterr = 0, didnetmask = 0, donetmask = 0; | |
24 | char **spp; | |
25 | int fd; | |
26 | #if HAVE_AFINET6 | |
27 | @@ -903,16 +904,16 @@ | |
28 | /* FIXME: sa is too small for INET6 addresses, inet6 should use that too, | |
29 | broadcast is unexpected */ | |
30 | if (ap->getmask) { | |
31 | - switch (ap->getmask(host, &sa, NULL)) { | |
32 | + switch (ap->getmask(host, &sa_netmask, NULL)) { | |
33 | case -1: | |
34 | usage(); | |
35 | break; | |
36 | case 1: | |
37 | if (didnetmask) | |
38 | usage(); | |
39 | - | |
40 | - goterr = set_netmask(skfd, &ifr, &sa); | |
41 | - didnetmask++; | |
42 | + | |
43 | + /* delay setting the CIDR netmask till after setting the addr */ | |
44 | + donetmask = 1; | |
45 | break; | |
46 | } | |
47 | } | |
48 | @@ -960,6 +961,13 @@ | |
49 | } | |
50 | } | |
51 | ||
52 | + /* set CIDR netmask */ | |
53 | + if (donetmask) { | |
54 | + donetmask = 0; | |
55 | + goterr = set_netmask(skfd, &ifr, &sa_netmask); | |
56 | + didnetmask++; | |
57 | + } | |
58 | + | |
59 | /* | |
60 | * Don't do the set_flag() if the address is an alias with a - at the | |
61 | * end, since it's deleted already! - Roman |