| 82 | */ |
| 83 | |
| 84 | void |
| 85 | cupsdNetIFUpdate(void) |
| 86 | { |
| 87 | int match; /* Matching address? */ |
| 88 | cupsd_listener_t *lis; /* Listen address */ |
| 89 | cupsd_netif_t *temp; /* New interface */ |
| 90 | struct ifaddrs *addrs, /* Interface address list */ |
| 91 | *addr; /* Current interface address */ |
| 92 | char hostname[1024]; /* Hostname for address */ |
| 93 | size_t hostlen; /* Length of hostname */ |
| 94 | |
| 95 | |
| 96 | /* |
| 97 | * Only update the list if we need to... |
| 98 | */ |
| 99 | |
| 100 | if (!NetIFUpdate) |
| 101 | return; |
| 102 | |
| 103 | NetIFUpdate = 0; |
| 104 | |
| 105 | /* |
| 106 | * Free the old interfaces... |
| 107 | */ |
| 108 | |
| 109 | cupsdNetIFFree(); |
| 110 | |
| 111 | /* |
| 112 | * Make sure we have an array... |
| 113 | */ |
| 114 | |
| 115 | if (!NetIFList) |
| 116 | NetIFList = cupsArrayNew((cups_array_func_t)compare_netif, NULL); |
| 117 | |
| 118 | if (!NetIFList) |
| 119 | return; |
| 120 | |
| 121 | /* |
| 122 | * Grab a new list of interfaces... |
| 123 | */ |
| 124 | |
| 125 | if (getifaddrs(&addrs) < 0) |
| 126 | { |
| 127 | cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdNetIFUpdate: Unable to get interface list - %s", strerror(errno)); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | for (addr = addrs; addr != NULL; addr = addr->ifa_next) |
| 132 | { |
| 133 | /* |
| 134 | * See if this interface address is IPv4 or IPv6... |
| 135 | */ |
| 136 | |
| 137 | if (addr->ifa_addr == NULL || |
| 138 | (addr->ifa_addr->sa_family != AF_INET |
| 139 | #ifdef AF_INET6 |
| 140 | && addr->ifa_addr->sa_family != AF_INET6 |
| 141 | #endif |
no test coverage detected