Lines Matching refs:ifi
85 struct ifi_info *ifi, *ifihead, **ifipnext, *ifipold, **ifiptr; in get_ifi_info_linuxv6() local
121 ifi = (struct ifi_info*)calloc(1, sizeof(struct ifi_info)); in get_ifi_info_linuxv6()
122 if (ifi == NULL) { in get_ifi_info_linuxv6()
128 *ifipnext = ifi; /* prev points to this new one */ in get_ifi_info_linuxv6()
129 ifipnext = &ifi->ifi_next; /* pointer to next one goes here */ in get_ifi_info_linuxv6()
143 ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in6)); in get_ifi_info_linuxv6()
144 if (ifi->ifi_addr == NULL) { in get_ifi_info_linuxv6()
147 memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6)); in get_ifi_info_linuxv6()
152 ifi->ifi_netmask = calloc(1, sizeof(struct sockaddr_in6)); in get_ifi_info_linuxv6()
153 if (ifi->ifi_addr == NULL) { in get_ifi_info_linuxv6()
162 memcpy(ifi->ifi_netmask, sin6, sizeof(struct sockaddr_in6)); in get_ifi_info_linuxv6()
167 strncpy(ifi->ifi_name, ifname, IFI_NAME); in get_ifi_info_linuxv6()
170 ifi->ifi_index = index; in get_ifi_info_linuxv6()
181 free(ifi->ifi_addr); in get_ifi_info_linuxv6()
182 free(ifi); in get_ifi_info_linuxv6()
190 ifi->ifi_flags = ifr.ifr_flags; in get_ifi_info_linuxv6()
224 struct ifi_info *ifi, *ifihead, **ifipnext, *ifipold, **ifiptr; in get_ifi_info() local
312 ifi = (struct ifi_info*)calloc(1, sizeof(struct ifi_info)); in get_ifi_info()
313 if (ifi == NULL) { in get_ifi_info()
318 *ifipnext = ifi; /* prev points to this new one */ in get_ifi_info()
319 ifipnext = &ifi->ifi_next; /* pointer to next one goes here */ in get_ifi_info()
321 ifi->ifi_flags = flags; /* IFF_xxx values */ in get_ifi_info()
322 ifi->ifi_myflags = myflags; /* IFI_xxx values */ in get_ifi_info()
324 ifi->ifi_index = if_nametoindex(ifr->ifr_name); in get_ifi_info()
329 ifi->ifi_index = ifrcopy.ifr_index; in get_ifi_info()
332 ifi->ifi_index = index++; /* SIOCGIFINDEX is broken on Solaris 2.5ish, so fake it */ in get_ifi_info()
334 memcpy(ifi->ifi_name, ifr->ifr_name, IFI_NAME); in get_ifi_info()
335 ifi->ifi_name[IFI_NAME-1] = '\0'; in get_ifi_info()
341 if (ifi->ifi_addr == NULL) { in get_ifi_info()
342 ifi->ifi_addr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in)); in get_ifi_info()
343 if (ifi->ifi_addr == NULL) { in get_ifi_info()
346 memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in)); in get_ifi_info()
356 free(ifi->ifi_addr); in get_ifi_info()
357 free(ifi); in get_ifi_info()
366 ifi->ifi_netmask = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in)); in get_ifi_info()
367 if (ifi->ifi_netmask == NULL) goto gotError; in get_ifi_info()
374 memcpy(ifi->ifi_netmask, sinptr, sizeof(struct sockaddr_in)); in get_ifi_info()
388 ifi->ifi_brdaddr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in)); in get_ifi_info()
389 if (ifi->ifi_brdaddr == NULL) { in get_ifi_info()
392 memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in)); in get_ifi_info()
407 ifi->ifi_dstaddr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in)); in get_ifi_info()
408 if (ifi->ifi_dstaddr == NULL) { in get_ifi_info()
411 memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in)); in get_ifi_info()
420 if (ifi->ifi_addr == NULL) { in get_ifi_info()
421 ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in6)); in get_ifi_info()
422 if (ifi->ifi_addr == NULL) { in get_ifi_info()
430 memcpy(ifi->ifi_addr, sinptr6, sizeof(struct sockaddr_in6)); in get_ifi_info()
447 free(ifi->ifi_addr); in get_ifi_info()
448 free(ifi); in get_ifi_info()
456 ifi->ifi_netmask = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in6)); in get_ifi_info()
457 if (ifi->ifi_netmask == NULL) goto gotError; in get_ifi_info()
459 memcpy(ifi->ifi_netmask, sinptr6, sizeof(struct sockaddr_in6)); in get_ifi_info()
498 struct ifi_info *ifi, *ifinext; in free_ifi_info() local
500 for (ifi = ifihead; ifi != NULL; ifi = ifinext) { in free_ifi_info()
501 if (ifi->ifi_addr != NULL) in free_ifi_info()
502 free(ifi->ifi_addr); in free_ifi_info()
503 if (ifi->ifi_netmask != NULL) in free_ifi_info()
504 free(ifi->ifi_netmask); in free_ifi_info()
505 if (ifi->ifi_brdaddr != NULL) in free_ifi_info()
506 free(ifi->ifi_brdaddr); in free_ifi_info()
507 if (ifi->ifi_dstaddr != NULL) in free_ifi_info()
508 free(ifi->ifi_dstaddr); in free_ifi_info()
509 ifinext = ifi->ifi_next; /* can't fetch ifi_next after free() */ in free_ifi_info()
510 free(ifi); /* the ifi_info{} itself */ in free_ifi_info()