Lines Matching refs:ifi
85 struct ifi_info *ifi, *ifihead, **ifipnext, *ifipold, **ifiptr;
121 ifi = (struct ifi_info*)calloc(1, sizeof(struct ifi_info));
122 if (ifi == NULL) {
128 *ifipnext = ifi; /* prev points to this new one */
129 ifipnext = &ifi->ifi_next; /* pointer to next one goes here */
143 ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in6));
144 if (ifi->ifi_addr == NULL) {
147 memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6));
152 ifi->ifi_netmask = calloc(1, sizeof(struct sockaddr_in6));
153 if (ifi->ifi_addr == NULL) {
162 memcpy(ifi->ifi_netmask, sin6, sizeof(struct sockaddr_in6));
167 strncpy(ifi->ifi_name, ifname, IFI_NAME);
170 ifi->ifi_index = index;
181 free(ifi->ifi_addr);
182 free(ifi);
190 ifi->ifi_flags = ifr.ifr_flags;
217 struct ifi_info *ifi, *ifihead, **ifipnext, *ifipold, **ifiptr;
305 ifi = (struct ifi_info*)calloc(1, sizeof(struct ifi_info));
306 if (ifi == NULL) {
311 *ifipnext = ifi; /* prev points to this new one */
312 ifipnext = &ifi->ifi_next; /* pointer to next one goes here */
314 ifi->ifi_flags = flags; /* IFF_xxx values */
315 ifi->ifi_myflags = myflags; /* IFI_xxx values */
317 ifi->ifi_index = if_nametoindex(ifr->ifr_name);
322 ifi->ifi_index = ifrcopy.ifr_index;
325 ifi->ifi_index = index++; /* SIOCGIFINDEX is broken on Solaris 2.5ish, so fake it */
327 memcpy(ifi->ifi_name, ifr->ifr_name, IFI_NAME);
328 ifi->ifi_name[IFI_NAME-1] = '\0';
334 if (ifi->ifi_addr == NULL) {
335 ifi->ifi_addr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in));
336 if (ifi->ifi_addr == NULL) {
339 memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in));
349 free(ifi->ifi_addr);
350 free(ifi);
359 ifi->ifi_netmask = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in));
360 if (ifi->ifi_netmask == NULL) goto gotError;
367 memcpy(ifi->ifi_netmask, sinptr, sizeof(struct sockaddr_in));
381 ifi->ifi_brdaddr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in));
382 if (ifi->ifi_brdaddr == NULL) {
385 memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in));
400 ifi->ifi_dstaddr = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in));
401 if (ifi->ifi_dstaddr == NULL) {
404 memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in));
413 if (ifi->ifi_addr == NULL) {
414 ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in6));
415 if (ifi->ifi_addr == NULL) {
423 memcpy(ifi->ifi_addr, sinptr6, sizeof(struct sockaddr_in6));
440 free(ifi->ifi_addr);
441 free(ifi);
449 ifi->ifi_netmask = (struct sockaddr*)calloc(1, sizeof(struct sockaddr_in6));
450 if (ifi->ifi_netmask == NULL) goto gotError;
452 memcpy(ifi->ifi_netmask, sinptr6, sizeof(struct sockaddr_in6));
491 struct ifi_info *ifi, *ifinext;
493 for (ifi = ifihead; ifi != NULL; ifi = ifinext) {
494 if (ifi->ifi_addr != NULL)
495 free(ifi->ifi_addr);
496 if (ifi->ifi_netmask != NULL)
497 free(ifi->ifi_netmask);
498 if (ifi->ifi_brdaddr != NULL)
499 free(ifi->ifi_brdaddr);
500 if (ifi->ifi_dstaddr != NULL)
501 free(ifi->ifi_dstaddr);
502 ifinext = ifi->ifi_next; /* can't fetch ifi_next after free() */
503 free(ifi); /* the ifi_info{} itself */