ifr.ifr_addr.sa_family = AF_INET;
int if_fetch(struct interface *ife){    struct ifreq ifr;    int fd;    char *ifname = ife->name;     strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)	return (-1);    ife->flags = ifr.ifr_flags;    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)	memset(ife->hwaddr, 0, 32);    else	memcpy(ife->hwaddr, ifr.ifr_hwaddr.sa_data, 8);    ife->type = ifr.ifr_hwaddr.sa_family;    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0)	ife->metric = 0;    else	ife->metric = ifr.ifr_metric;    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0)	ife->mtu = 0;    else	ife->mtu = ifr.ifr_mtu;    if (ife->type == ARPHRD_SLIP || ife->type == ARPHRD_CSLIP ||	ife->type == ARPHRD_SLIP6 || ife->type == ARPHRD_CSLIP6 ||	ife->type == ARPHRD_ADAPT) {#ifdef SIOCGOUTFILL	strcpy(ifr.ifr_name, ifname);	if (ioctl(skfd, SIOCGOUTFILL, &ifr) < 0)	    ife->outfill = 0;	else	    ife->outfill = (unsigned int) ifr.ifr_data;#endif#ifdef SIOCGKEEPALIVE	strcpy(ifr.ifr_name, ifname);	if (ioctl(skfd, SIOCGKEEPALIVE, &ifr) < 0)	    ife->keepalive = 0;	else	    ife->keepalive = (unsigned int) ifr.ifr_data;#endif    }    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)	memset(&ife->map, 0, sizeof(struct ifmap));    else	memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap));    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)	memset(&ife->map, 0, sizeof(struct ifmap));    else	ife->map = ifr.ifr_map;#ifdef HAVE_TXQUEUELEN    strcpy(ifr.ifr_name, ifname);    if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) < 0)	ife->tx_queue_len = -1;	/* unknown value */    else	ife->tx_queue_len = ifr.ifr_qlen;#else    ife->tx_queue_len = -1;	/* unknown value */#endif#if HAVE_AFINET    /* IPv4 address? */    fd = get_socket_for_af(AF_INET);    if (fd >= 0) {	strcpy(ifr.ifr_name, ifname);	if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {	    ife->has_ip = 1;	    ife->addr = ifr.ifr_addr;	    strcpy(ifr.ifr_name, ifname);	    if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0)	        memset(&ife->dstaddr, 0, sizeof(struct sockaddr));	    else	        ife->dstaddr = ifr.ifr_dstaddr;	    strcpy(ifr.ifr_name, ifname);	    if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0)	        memset(&ife->broadaddr, 0, sizeof(struct sockaddr));	    else		ife->broadaddr = ifr.ifr_broadaddr;	    strcpy(ifr.ifr_name, ifname);	    if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0)		memset(&ife->netmask, 0, sizeof(struct sockaddr));	    else		ife->netmask = ifr.ifr_netmask;	} else	    memset(&ife->addr, 0, sizeof(struct sockaddr));    }#endif#if HAVE_AFATALK    /* DDP address maybe ? */    fd = get_socket_for_af(AF_APPLETALK);    if (fd >= 0) {	strcpy(ifr.ifr_name, ifname);	if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {	    ife->ddpaddr = ifr.ifr_addr;	    ife->has_ddp = 1;	}    }#endif#if HAVE_AFIPX    /* Look for IPX addresses with all framing types */    fd = get_socket_for_af(AF_IPX);    if (fd >= 0) {	strcpy(ifr.ifr_name, ifname);	if (!ipx_getaddr(fd, IPX_FRAME_ETHERII, &ifr)) {	    ife->has_ipx_bb = 1;	    ife->ipxaddr_bb = ifr.ifr_addr;	}	strcpy(ifr.ifr_name, ifname);	if (!ipx_getaddr(fd, IPX_FRAME_SNAP, &ifr)) {	    ife->has_ipx_sn = 1;	    ife->ipxaddr_sn = ifr.ifr_addr;	}	strcpy(ifr.ifr_name, ifname);	if (!ipx_getaddr(fd, IPX_FRAME_8023, &ifr)) {	    ife->has_ipx_e3 = 1;	    ife->ipxaddr_e3 = ifr.ifr_addr;	}	strcpy(ifr.ifr_name, ifname);	if (!ipx_getaddr(fd, IPX_FRAME_8022, &ifr)) {	    ife->has_ipx_e2 = 1;	    ife->ipxaddr_e2 = ifr.ifr_addr;	}    }#endif#if HAVE_AFECONET    /* Econet address maybe? */    fd = get_socket_for_af(AF_ECONET);    if (fd >= 0) {	strcpy(ifr.ifr_name, ifname);	if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {	    ife->ecaddr = ifr.ifr_addr;	    ife->has_econet = 1;	}    }#endif    return 0;}