+static struct addrinfo *smn_lookup(const char *name)
+{
+ struct addrinfo *ai, hint = {
+#if HAVE_DECL_AI_ADDRCONFIG
+ .ai_flags = AI_ADDRCONFIG,
+#endif /* HAVE_DECL_AI_ADDRCONFIG */
+ .ai_family = AF_INET,
+ .ai_protocol = IPPROTO_UDP,
+ };
+ int error;
+
+ error = getaddrinfo(name, NULL, &hint, &ai);
+ if (error) {
+ xlog(D_GENERAL, "getaddrinfo(3): %s", gai_strerror(error));
+ return NULL;
+ }
+
+ return ai;
+}
+
+__attribute_malloc__
+static struct nsm_host *
+smn_alloc_host(const char *hostname, const time_t timestamp)
+{
+ struct nsm_host *host;
+
+ host = calloc(1, sizeof(*host));
+ if (host == NULL)
+ goto out_nomem;
+
+ host->name = strdup(hostname);
+ if (host->name == NULL) {
+ free(host);
+ goto out_nomem;
+ }
+
+ host->last_used = timestamp;
+ host->timeout = NSM_TIMEOUT;
+ host->retries = 100; /* force address retry */
+
+ return host;
+
+out_nomem:
+ xlog_warn("Unable to allocate memory");
+ return NULL;
+}
+
+static void smn_forget_host(struct nsm_host *host)
+{
+ xlog(D_CALL, "Removing %s from notify list", host->name);
+
+ nsm_delete_notified_host(host->name);
+
+ free(host->name);
+ if (host->ai)
+ freeaddrinfo(host->ai);
+
+ free(host);
+}
+
+static unsigned int
+smn_get_host(const char *hostname,
+ __attribute__ ((unused)) const struct sockaddr *sap,
+ __attribute__ ((unused)) const struct mon *m,
+ const time_t timestamp)
+{
+ struct nsm_host *host;
+
+ host = smn_alloc_host(hostname, timestamp);
+ if (host == NULL)
+ return 0;
+
+ insert_host(host);
+ xlog(D_GENERAL, "Added host %s to notify list", hostname);
+ return 1;
+}
+