Skip to content

Allow compiling with DNS_SD=1 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions modules/pico_dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ pico_dns_sd_kv_vector_strlen( kv_vector *vector )
* @return Pointer to newly created record on success, NULL on failure.
* ****************************************************************************/
static struct pico_mdns_record *
pico_dns_sd_srv_record_create( const char *url,
pico_dns_sd_srv_record_create( struct pico_stack *S,
const char *url,
uint16_t priority,
uint16_t weight,
uint16_t port,
Expand Down Expand Up @@ -140,7 +141,7 @@ pico_dns_sd_srv_record_create( const char *url,
PICO_FREE(target_rname);

/* Create and return new mDNS record */
record = pico_mdns_record_create(url, srv_data, srv_length,
record = pico_mdns_record_create(S, url, srv_data, srv_length,
PICO_DNS_TYPE_SRV,
ttl, flags);
PICO_FREE(srv_data);
Expand All @@ -157,7 +158,8 @@ pico_dns_sd_srv_record_create( const char *url,
* @return Pointer to newly created record on success, NULL on failure.
* ****************************************************************************/
static struct pico_mdns_record *
pico_dns_sd_txt_record_create( const char *url,
pico_dns_sd_txt_record_create( struct pico_stack *S,
const char *url,
kv_vector key_value_pairs,
uint32_t ttl,
uint8_t flags )
Expand Down Expand Up @@ -210,7 +212,7 @@ pico_dns_sd_txt_record_create( const char *url,
txt_i = (uint16_t) (txt_i + 1u + key_len);
}
}
record = pico_mdns_record_create(url, txt, (uint16_t)(len - 1u), PICO_DNS_TYPE_TXT, ttl, flags);
record = pico_mdns_record_create(S, url, txt, (uint16_t)(len - 1u), PICO_DNS_TYPE_TXT, ttl, flags);
PICO_FREE(txt);

return record;
Expand Down Expand Up @@ -391,22 +393,24 @@ pico_dns_sd_create_service_url( const char *name,
* This function actually does exactly the same as pico_mdns_init();
* ****************************************************************************/
int
pico_dns_sd_init( const char *_hostname,
pico_dns_sd_init( struct pico_stack *S,
const char *_hostname,
struct pico_ip4 address,
void (*callback)(pico_mdns_rtree *,
char *,
void *),
void *arg )
{
return pico_mdns_init(_hostname, address, callback, arg);
return pico_mdns_init(S, _hostname, address, callback, arg);
}

/* ****************************************************************************
* Just calls pico_mdns_init in its turn to initialise the mDNS-module.
* See pico_mdns.h for description.
* ****************************************************************************/
int
pico_dns_sd_register_service( const char *name,
pico_dns_sd_register_service( struct pico_stack *S,
const char *name,
const char *type,
uint16_t port,
kv_vector *txt_data,
Expand All @@ -419,7 +423,7 @@ pico_dns_sd_register_service( const char *name,
PICO_MDNS_RTREE_DECLARE(rtree);
struct pico_mdns_record *srv_record = NULL;
struct pico_mdns_record *txt_record = NULL;
const char *hostname = pico_mdns_get_hostname();
const char *hostname = pico_mdns_get_hostname(S);
char *url = NULL;

/* Try to create a service URL to create records with */
Expand All @@ -435,14 +439,14 @@ pico_dns_sd_register_service( const char *name,
dns_sd_dbg("\n>>>>>>>>>> Target: %s <<<<<<<<<<\n\n", hostname);

/* Create the SRV record */
srv_record = pico_dns_sd_srv_record_create(url, 0, 0, port, hostname, ttl, PICO_MDNS_RECORD_UNIQUE);
srv_record = pico_dns_sd_srv_record_create(S, url, 0, 0, port, hostname, ttl, PICO_MDNS_RECORD_UNIQUE);
if (!srv_record) {
PICO_FREE(url);
return -1;
}

/* Create the TXT record */
txt_record = pico_dns_sd_txt_record_create(url, *txt_data, ttl, PICO_MDNS_RECORD_UNIQUE);
txt_record = pico_dns_sd_txt_record_create(S, url, *txt_data, ttl, PICO_MDNS_RECORD_UNIQUE);
PICO_FREE(url);

/* Erase the key-value pair vector, it's no longer needed */
Expand All @@ -463,7 +467,7 @@ pico_dns_sd_register_service( const char *name,
return -1;
}

if (pico_mdns_claim(rtree, callback, arg)) {
if (pico_mdns_claim(S, rtree, callback, arg)) {
PICO_MDNS_RTREE_DESTROY(&rtree);
return -1;
}
Expand Down
6 changes: 4 additions & 2 deletions modules/pico_dns_sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ typedef struct
* See pico_mdns.h for description.
* ****************************************************************************/
int
pico_dns_sd_init( const char *_hostname,
pico_dns_sd_init( struct pico_stack *S,
const char *_hostname,
struct pico_ip4 address,
void (*callback)(pico_mdns_rtree *,
char *,
Expand All @@ -70,7 +71,8 @@ pico_dns_sd_init( const char *_hostname,
* @return
* ****************************************************************************/
int
pico_dns_sd_register_service( const char *name,
pico_dns_sd_register_service( struct pico_stack *S,
const char *name,
const char *type,
uint16_t port,
kv_vector *txt_data,
Expand Down
Loading