MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsdNetIFUpdate

Function cupsdNetIFUpdate

scheduler/network.c:84–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 */
83
84void
85cupsdNetIFUpdate(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

Callers 2

cupsdNetIFFindFunction · 0.85
cupsdCheckAuthFunction · 0.85

Calls 11

cupsdNetIFFreeFunction · 0.85
cupsArrayNewFunction · 0.85
cupsdLogMessageFunction · 0.85
httpAddrLookupFunction · 0.85
httpAddrLocalhostFunction · 0.85
httpAddrStringFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
httpAddrAnyFunction · 0.85
httpAddrPortFunction · 0.85
cupsArrayAddFunction · 0.85

Tested by

no test coverage detected