/*
- * "$Id: network.c 177 2006-06-21 00:20:03Z jlovell $"
+ * "$Id: network.c 7861 2008-08-26 03:15:14Z mike $"
*
* Network interface functions for the Common UNIX Printing System
* (CUPS) scheduler.
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
* "LICENSE" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
* Update the interface list as needed...
*/
- cupsdNetIFUpdate();
+ if (NetIFUpdate)
+ cupsdNetIFUpdate();
/*
* Search for the named interface...
/*
- * Update the network interface list no more often than once a
- * minute...
+ * Only update the list if we need to...
*/
- if ((time(NULL) - NetIFTime) < 60)
+ if (!NetIFUpdate)
return;
- NetIFTime = time(NULL);
+ NetIFUpdate = 0;
/*
* Free the old interfaces...
else if (addr->ifa_addr->sa_family == AF_INET &&
lis->address.addr.sa_family == AF_INET &&
(lis->address.ipv4.sin_addr.s_addr &
- temp->mask.ipv4.sin_addr.s_addr) ==
- temp->address.ipv4.sin_addr.s_addr)
+ temp->mask.ipv4.sin_addr.s_addr) ==
+ (temp->address.ipv4.sin_addr.s_addr &
+ temp->mask.ipv4.sin_addr.s_addr))
match = 1;
#ifdef AF_INET6
else if (addr->ifa_addr->sa_family == AF_INET6 &&
lis->address.addr.sa_family == AF_INET6 &&
(lis->address.ipv6.sin6_addr.s6_addr[0] &
- temp->mask.ipv6.sin6_addr.s6_addr[0]) ==
- temp->address.ipv6.sin6_addr.s6_addr[0] &&
+ temp->mask.ipv6.sin6_addr.s6_addr[0]) ==
+ (temp->address.ipv6.sin6_addr.s6_addr[0] &
+ temp->mask.ipv6.sin6_addr.s6_addr[0]) &&
(lis->address.ipv6.sin6_addr.s6_addr[1] &
- temp->mask.ipv6.sin6_addr.s6_addr[1]) ==
- temp->address.ipv6.sin6_addr.s6_addr[1] &&
+ temp->mask.ipv6.sin6_addr.s6_addr[1]) ==
+ (temp->address.ipv6.sin6_addr.s6_addr[1] &
+ temp->mask.ipv6.sin6_addr.s6_addr[1]) &&
(lis->address.ipv6.sin6_addr.s6_addr[2] &
- temp->mask.ipv6.sin6_addr.s6_addr[2]) ==
- temp->address.ipv6.sin6_addr.s6_addr[2] &&
+ temp->mask.ipv6.sin6_addr.s6_addr[2]) ==
+ (temp->address.ipv6.sin6_addr.s6_addr[2] &
+ temp->mask.ipv6.sin6_addr.s6_addr[2]) &&
(lis->address.ipv6.sin6_addr.s6_addr[3] &
- temp->mask.ipv6.sin6_addr.s6_addr[3]) ==
- temp->address.ipv6.sin6_addr.s6_addr[3])
+ temp->mask.ipv6.sin6_addr.s6_addr[3]) ==
+ (temp->address.ipv6.sin6_addr.s6_addr[3] &
+ temp->mask.ipv6.sin6_addr.s6_addr[3]))
match = 1;
#endif /* AF_INET6 */
cupsArrayAdd(NetIFList, temp);
- cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdNetIFUpdate: \"%s\" = %s...",
- temp->name, temp->hostname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdNetIFUpdate: \"%s\" = %s:%d",
+ temp->name, temp->hostname, temp->port);
}
freeifaddrs(addrs);
/*
- * End of "$Id: network.c 177 2006-06-21 00:20:03Z jlovell $".
+ * End of "$Id: network.c 7861 2008-08-26 03:15:14Z mike $".
*/