Added API and test to add additional RRs (lAAAA RRs i.e.)
This commit is contained in:
parent
501803d9d3
commit
3acbda1c5d
14
mdnsd.c
14
mdnsd.c
@ -46,6 +46,14 @@
|
||||
#include <pthread.h>
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* Define a proper IP socket level if not already done.
|
||||
* Required to compile on OS X
|
||||
*/
|
||||
#ifndef SOL_IP
|
||||
#define SOL_IP IPPROTO_IP
|
||||
#endif
|
||||
|
||||
#include "mdns.h"
|
||||
#include "mdnsd.h"
|
||||
|
||||
@ -446,6 +454,12 @@ void mdnsd_set_hostname(struct mdnsd *svr, const char *hostname, uint32_t ip) {
|
||||
pthread_mutex_unlock(&svr->data_lock);
|
||||
}
|
||||
|
||||
void mdnsd_add_rr(struct mdnsd *svr, struct rr_entry *rr) {
|
||||
pthread_mutex_lock(&svr->data_lock);
|
||||
rr_group_add(&svr->group, rr);
|
||||
pthread_mutex_unlock(&svr->data_lock);
|
||||
}
|
||||
|
||||
struct mdns_service *mdnsd_register_svc(struct mdnsd *svr, const char *instance_name,
|
||||
const char *type, uint16_t port, const char *hostname, const char *txt[]) {
|
||||
struct rr_entry *txt_e = NULL,
|
||||
|
3
mdnsd.h
3
mdnsd.h
@ -44,6 +44,9 @@ void mdnsd_stop(struct mdnsd *s);
|
||||
// sets the hostname for the given MDNS responder instance
|
||||
void mdnsd_set_hostname(struct mdnsd *svr, const char *hostname, uint32_t ip);
|
||||
|
||||
// adds an additional RR
|
||||
void mdnsd_add_rr(struct mdnsd *svr, struct rr_entry *rr);
|
||||
|
||||
// registers a service with the MDNS responder instance
|
||||
struct mdns_service *mdnsd_register_svc(struct mdnsd *svr, const char *instance_name,
|
||||
const char *type, uint16_t port, const char *hostname, const char *txt[]);
|
||||
|
11
testmdnsd.c
11
testmdnsd.c
@ -47,6 +47,17 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
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 in6_addr v6addr;
|
||||
inet_pton(AF_INET6, "fe80::e2f8:47ff:fe20:28e0", &v6addr);
|
||||
aaaa_e = rr_create_aaaa(create_nlabel(hostname), &v6addr);
|
||||
|
||||
mdnsd_add_rr(svr, aaaa_e);
|
||||
|
||||
const char *txt[] = {
|
||||
"path=/mywebsite",
|
||||
NULL
|
||||
|
Loading…
Reference in New Issue
Block a user