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);
solved.addr = addr;
ret = 0;
}
+ else {
+ perror("ioctl(SIOCGIFADDR)");
+ }
+
if (maskstr != NULL && maskstr[0] != '\0'){
printf ("NETMASK=%s\n",maskstr);
solved.mask = ip_cnv (maskstr);
solved.mask = addr;
ret = 0;
}
+ else {
+ perror("ioctl(SIOCGIFNETMASK)");
+ }
+
if (bcaststr != NULL && bcaststr[0] != '\0'){
printf ("BCAST=%s\n",bcaststr);
}else if (ifconfig_ioctl(skfd,ifname,SIOCGIFBRDADDR, &ifr) >= 0){
,(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)