X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fifspec.c;h=6121615d131b4c04af7fb0a0733e12099c26db62;hb=a917f24ef7b003dcef54a3db2644cf9cb4bc2db2;hp=cebe4d07a5f94c8622f6156fead4b13ca36ad682;hpb=da691fd4bad5e187b307b7fd86bf5fd61e47c3fc;p=util-vserver.git diff --git a/util-vserver/src/ifspec.c b/util-vserver/src/ifspec.c index cebe4d0..6121615 100644 --- a/util-vserver/src/ifspec.c +++ b/util-vserver/src/ifspec.c @@ -24,6 +24,10 @@ NETMASK= BCAST= */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -104,7 +108,7 @@ int ifconfig_print ( struct { unsigned long addr; unsigned long mask; - } solved; + } solved = {0,0}; if (addrstr != NULL && addrstr[0] != '\0'){ printf ("ADDR=%s\n",addrstr); solved.addr = ip_cnv (addrstr); @@ -119,6 +123,10 @@ int ifconfig_print ( solved.addr = addr; ret = 0; } + else { + perror("ifspec: ioctl(SIOCGIFADDR)"); + } + if (maskstr != NULL && maskstr[0] != '\0'){ printf ("NETMASK=%s\n",maskstr); solved.mask = ip_cnv (maskstr); @@ -133,6 +141,10 @@ int ifconfig_print ( solved.mask = addr; ret = 0; } + else { + perror("ifspec: ioctl(SIOCGIFNETMASK)"); + } + if (bcaststr != NULL && bcaststr[0] != '\0'){ printf ("BCAST=%s\n",bcaststr); }else if (ifconfig_ioctl(skfd,ifname,SIOCGIFBRDADDR, &ifr) >= 0){ @@ -144,7 +156,7 @@ int ifconfig_print ( ,(addr>>8)&0xff ,addr&0xff); ret = 0; - }else{ + }else if (solved.addr!=0 && solved.mask!=0) { // Can't get it from the kernel, compute it from the IP // and the netmask unsigned long addr = (solved.addr & solved.mask)