+#endif
+
+void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m) {
+#ifndef HAVE_STRUCT_LIFCONF
+ size_t needed;
+ int mib[6];
+ char *buf, *lim, *next, count = 0;
+ struct rt_msghdr *rtm;
+
+ assert(m);
+
+ retry2:
+ mib[0] = CTL_NET;
+ mib[1] = PF_ROUTE;
+ mib[2] = 0; /* protocol */
+ mib[3] = 0; /* wildcard address family */
+ mib[4] = NET_RT_IFLIST;
+ mib[5] = 0; /* no flags */
+ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ {
+ avahi_log_error("sysctl failed: %s", strerror(errno));
+ avahi_log_error("route-sysctl-estimate");
+ return;
+ }
+ if ((buf = avahi_malloc(needed)) == NULL)
+ {
+ avahi_log_error("malloc failed in avahi_interface_monitor_sync");
+ return;
+ }
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
+ avahi_log_warn("sysctl failed: %s", strerror(errno));
+ if (errno == ENOMEM && count++ < 10) {
+ avahi_log_warn("Routing table grew, retrying");
+ sleep(1);
+ avahi_free(buf);
+ goto retry2;
+ }
+ }
+ lim = buf + needed;
+ for (next = buf; next < lim; next += rtm->rtm_msglen) {
+ rtm = (struct rt_msghdr *)next;
+ parse_rtmsg(rtm, m);
+ }
+
+ m->list_complete = 1;
+ avahi_interface_monitor_check_relevant(m);
+ avahi_interface_monitor_update_rrs(m, 0);
+ avahi_log_info("Network interface enumeration completed.");
+#elif defined (SIOCGLIFNUM) && defined(HAVE_STRUCT_LIFCONF) /* Solaris 8 and later; Sol 7? */
+ int sockfd;
+ int ret;
+ int n;
+ struct lifnum lifn;
+ struct lifconf lifc;
+ struct lifreq *lifreq;
+
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ avahi_log_error(__FILE__": socket(PFROUTE): %s", strerror(errno));
+ return;
+ }
+ lifc.lifc_buf = NULL;
+ lifn.lifn_family = AF_UNSPEC;
+ lifn.lifn_flags = 0;
+ if (ioctl(sockfd, SIOCGLIFNUM, &lifn) < 0) {
+ avahi_log_error(__FILE__": ioctl(SIOCGLIFNUM): %s", strerror(errno));
+ goto end;
+ }
+ lifc.lifc_len = lifn.lifn_count * sizeof (struct lifreq);
+ if ((lifc.lifc_buf = avahi_malloc(lifc.lifc_len)) == NULL) {
+ avahi_log_error("malloc failed in avahi_interface_monitor_sync");
+ goto end;
+ }
+ lifc.lifc_family = NULL;
+ lifc.lifc_flags = 0;
+ if(ioctl(sockfd, SIOCGLIFCONF, &lifc) < 0) {
+ avahi_log_error(__FILE__": ioctl(SIOCGLIFCONF): %s", strerror(errno));
+ goto end;
+ }
+ lifreq = lifc.lifc_req;