Esempio n. 1
0
static void mdns_tinysvcmdns_unregister(void) {
    if (svr)
    {
        mdnsd_stop(svr);
        svr = NULL;
    }
}
Esempio n. 2
0
static int test_mdns_stop(void)
{
	if (mdnsd_stop() != 0) {
		fprintf(stderr, "ERROR: |%s| fail to execute mdnsd_stop() \n", __FUNCTION__);
		return -1;
	}
	printf("mdnsd_stop() OK. \n");

	return 0;
}
Esempio n. 3
0
int main(int argc, char *argv[]) {
	// create host entries
	char *hostname = "some-random-host.local";

	struct mdnsd *svr = mdnsd_start();
	if (svr == NULL) {
		printf("mdnsd_start() error\n");
		return 1;
	}

	printf("mdnsd_start OK. press ENTER to add hostname & service\n");
	getchar();

	mdnsd_set_hostname(svr, hostname, inet_addr("192.168.0.29"));

	struct rr_entry *a2_e = NULL;
	a2_e = rr_create_a(create_nlabel(hostname), inet_addr("192.168.0.31"));
	mdnsd_add_rr(svr, a2_e);

	struct rr_entry *aaaa_e = NULL;

	struct addrinfo hints;
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET6;
	hints.ai_flags = AI_NUMERICHOST;
	struct addrinfo* results;
	getaddrinfo(
		"fe80::e2f8:47ff:fe20:28e0",
		NULL,
		&hints,
		&results);
	struct sockaddr_in6* addr = (struct sockaddr_in6*)results->ai_addr;
	struct in6_addr v6addr = addr->sin6_addr;
	freeaddrinfo(results);

	aaaa_e = rr_create_aaaa(create_nlabel(hostname), &v6addr);

	mdnsd_add_rr(svr, aaaa_e);

	const char *txt[] = {
		"path=/mywebsite", 
		NULL
	};
	struct mdns_service *svc = mdnsd_register_svc(svr, "My Website", 
									"_http._tcp.local", 8080, NULL, txt);
	mdns_service_destroy(svc);

	printf("added service and hostname. press ENTER to exit\n");
	getchar();

	mdnsd_stop(svr);

	return 0;
}
Esempio n. 4
0
TinySVCMDNS::~TinySVCMDNS() {
  for (mdnsd* mdnsd : mdnsd_) {
    mdnsd_stop(mdnsd);
  }
}