*
* srvx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
#include "log.h"
#include "timeq.h"
+#if defined(HAVE_NETINET_IN_H)
+# include <netinet/in.h> /* sockaddr_in6 on some BSDs */
+#endif
+
static const char hexdigits[] = "0123456789abcdef";
struct dns_rr;
sar_request_abort(req);
}
-static time_t next_sar_timeout;
+static unsigned long next_sar_timeout;
static void
sar_timeout_cb(void *data)
}
static void
-sar_check_timeout(time_t when)
+sar_check_timeout(unsigned long when)
{
if (!next_sar_timeout || when < next_sar_timeout) {
timeq_del(0, sar_timeout_cb, NULL, TIMEQ_IGNORE_WHEN | TIMEQ_IGNORE_DATA);
sprintf(id_text, "%d", hdr.id);
req = dict_find(sar_requests, id_text, NULL);
- log_module(sar_log, LOG_DEBUG, "sar_fd_readable(%p): hdr {id=%d, flags=0x%x, qdcount=%d, ancount=%d, nscount=%d, arcount=%d} -> req %p", fd, hdr.id, hdr.flags, hdr.qdcount, hdr.ancount, hdr.nscount, hdr.arcount, req);
+ log_module(sar_log, LOG_DEBUG, "sar_fd_readable(%p): hdr {id=%d, flags=0x%x, qdcount=%d, ancount=%d, nscount=%d, arcount=%d} -> req %p", (void*)fd, hdr.id, hdr.flags, hdr.qdcount, hdr.ancount, hdr.nscount, hdr.arcount, (void*)req);
if (!req || !req->retries || !(hdr.flags & REQ_FLAG_QR)) {
ns->resp_ignored++;
return;
/* Set up canonical name-indexed service entry. */
canon = sar_service_byname(name, 1);
if (canon->protos[proto].valid) {
- log_module(sar_log, LOG_ERROR, "Service %s/%s listed twice.", name, port);
+ /* log_module(sar_log, LOG_ERROR, "Service %s/%s listed twice.", name, port); who cares? */
continue;
}
canon->protos[proto].canon = NULL;
struct service_byname *byname;
unsigned int ii;
+ /* Forget old services dicts and allocate new ones. */
+ dict_delete(services_byname);
+ services_byname = dict_new();
+ dict_set_free_data(services_byname, free);
+
+ dict_delete(services_byport);
+ services_byport = dict_new();
+ dict_set_free_data(services_byport, free);
+
+ /* Load the list from the services file. */
sar_services_load_file(etc_services);
+ /* Mark well-known services as using DNS-SD SRV records. */
for (ii = 0; tcp_srvs[ii]; ++ii) {
byname = sar_service_byname(tcp_srvs[ii], 1);
byname->protos[SERVICE_TCP].srv = 1;
{
unsigned int count;
- log_module(sar_log, LOG_DEBUG, "sar_getaddr_append({full_name=%s}, ai=%p, copy=%d)", state->full_name, ai, copy);
+ log_module(sar_log, LOG_DEBUG, "sar_getaddr_append({full_name=%s}, ai=%p, copy=%d)", state->full_name, (void*)ai, copy);
/* Set the appropriate pointer to the new element(s). */
if (state->ai_tail)
if (flags & SNI_NUMERICHOST) {
const char *servname;
- unsigned int len;
char host[SAR_NTOP_MAX], servbuf[16];
/* If appropriate, try to look up service name. */
if (!pos)
return 0;
sa->sa_family = AF_INET;
+#if defined(HAVE_SOCKADDR_SA_LEN)
+ sa->sa_len = sizeof(struct sockaddr_in);
+#endif
return pos;
}
sin6->sin6_addr.s6_addr[cpos + jj] = 0;
}
sa->sa_family = AF_INET6;
+#if defined(HAVE_SOCKADDR_SA_LEN)
+ sa->sa_len = sizeof(struct sockaddr_in6);
+#endif
return pos;
}
dict_delete(services_byport);
dict_delete(sar_nameservers);
dict_delete(sar_requests);
+ free_string_list(conf.sar_search);
+ free_string_list(conf.sar_nslist);
}
static void
sar_nameservers = dict_new();
dict_set_free_data(sar_nameservers, free);
- services_byname = dict_new();
- dict_set_free_data(services_byname, free);
-
- services_byport = dict_new();
- dict_set_free_data(services_byport, free);
-
sar_register_helper(&sar_ipv4_helper);
#if defined(AF_INET6)
sar_register_helper(&sar_ipv6_helper);