Ejemplo n.º 1
0
/**
 * Runs the DNS-SD sequence to discover the sFlow server settings,
 * collector addresses and ports and sampling rates and polling interval
 * settings.
 * The DNS query is scoped to query for entries in the domain (zone)
 * configured as the domain override in the registry (if set), or the
 * primary domain name configured on the system if there is no domain
 * override.
 * Note that the DNS query could fail or return no results if we are
 * unable to discover the primary domain of the system.
 * HSP *sp used to update the min TTL for DNS entries so that the
 * next DNS request can be scheduled.
 * HSPSFlowSettings *settings in which sFlow collector addresses and ports
 * and sampling and polling settings will be populated.
 * Returns the number of sFlow collectors discovered or -1 on failure.
 */
int dnsSD(HSP *sp, HSPSFlowSettings *settings)
{
    char request[HSP_MAX_DNS_LEN];
	if (sp->DNSSD_domain) {
		sprintf_s(request, HSP_MAX_DNS_LEN, "%s%s", SFLOW_DNS_SD, sp->DNSSD_domain);
	} else {
		char domain[MAX_HOSTNAME_LEN];
		memset(domain, 0, MAX_HOSTNAME_LEN);
		DWORD len = MAX_HOSTNAME_LEN;
		char *dot = "";
		if (GetComputerNameEx(ComputerNameDnsDomain, domain, &len) == 0) {
			DWORD err = GetLastError();
			logErr(LOG_ERR, err, "dnsSD: cannot determined DNS domain for this computer error=%u", err);
		} else if (len == 0) {
			myLog(LOG_ERR, "dnsSD: DNS domain for this computer not set");
		} else {
			dot = ".";
		}
		sprintf_s(request, HSP_MAX_DNS_LEN, "%s%s%s", SFLOW_DNS_SD, dot, domain);
	}
	myLog(LOG_INFO, "dnsSD: request=%s", request);
    int num_servers = dnsSD_Request(sp, settings, request, DNS_TYPE_SRV);
    dnsSD_Request(sp, settings, request, DNS_TYPE_TEXT);
    // it's ok even if only the SRV request succeeded
    return num_servers; //  -1 on error
}
Ejemplo n.º 2
0
 int dnsSD(HSP *sp, HSPDnsCB callback)
 {
   int num_servers = dnsSD_Request(sp, SFLOW_DNS_SD, T_SRV, callback);
   dnsSD_Request(sp, SFLOW_DNS_SD, T_TXT, callback);
   // it's ok even if just the SRV request succeeded
   return num_servers; //  -1 on error
 }
Ejemplo n.º 3
0
 int dnsSD(HSP *sp, HSPDnsCB callback, HSPSFlowSettings *settings)
 {
   char request[HSP_MAX_DNS_LEN];
   char *domain_override = sp->DNSSD_domain ? sp->DNSSD_domain : "";
   snprintf(request, HSP_MAX_DNS_LEN, "%s%s", SFLOW_DNS_SD, domain_override);
   int num_servers = dnsSD_Request(sp, request, T_SRV, callback, settings);
   dnsSD_Request(sp, request, T_TXT, callback, settings);
   // it's ok even if only the SRV request succeeded
   return num_servers; //  -1 on error
 }