From 6067edfed371cae30d1e777252fad42f9407e714 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 28 Jun 2018 21:51:20 +0200 Subject: [PATCH] mdns: add defines for mdns_name_result_cb_t result parameter --- src/apps/mdns/mdns.c | 8 +++++--- src/include/lwip/apps/mdns.h | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 8597103b..c5b68791 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -103,7 +103,7 @@ static const ip_addr_t v6group = DNS_MQUERY_IPV6_GROUP_INIT; static u8_t mdns_netif_client_id; static struct udp_pcb *mdns_pcb; NETIF_DECLARE_EXT_CALLBACK(netif_callback) -static mdns_name_result_cb_t mdns_name_result_cb = NULL; +static mdns_name_result_cb_t mdns_name_result_cb; #define NETIF_TO_HOST(netif) (struct mdns_host*)(netif_get_client_data(netif, mdns_netif_client_id)) @@ -1830,7 +1830,7 @@ mdns_handle_response(struct mdns_packet *pkt) if (conflict != 0) { sys_untimeout(mdns_probe, pkt->netif); if (mdns_name_result_cb != NULL) { - mdns_name_result_cb(pkt->netif, 0); + mdns_name_result_cb(pkt->netif, MDNS_PROBING_CONFLICT); } } } @@ -2018,7 +2018,7 @@ mdns_probe(void* arg) mdns->probing_state = MDNS_PROBING_COMPLETE; mdns_resp_announce(netif); if (mdns_name_result_cb != NULL) { - mdns_name_result_cb(netif, 1); + mdns_name_result_cb(netif, MDNS_PROBING_SUCCESSFUL); } } else { #if LWIP_IPV4 @@ -2331,6 +2331,8 @@ mdns_resp_announce(struct netif *netif) } /* else: ip address changed while probing was ongoing? todo reset counter to restart? */ } +/** Register a callback function that is called if probing is completed successfully + * or with a conflict. */ void mdns_resp_register_name_result_cb(mdns_name_result_cb_t cb) { diff --git a/src/include/lwip/apps/mdns.h b/src/include/lwip/apps/mdns.h index b36b81f3..32df511a 100644 --- a/src/include/lwip/apps/mdns.h +++ b/src/include/lwip/apps/mdns.h @@ -48,6 +48,9 @@ enum mdns_sd_proto { DNSSD_PROTO_TCP = 1 }; +#define MDNS_PROBING_CONFLICT 0 +#define MDNS_PROBING_SUCCESSFUL 1 + #define MDNS_LABEL_MAXLEN 63 struct mdns_host; @@ -57,9 +60,9 @@ struct mdns_service; typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata); /** Callback function to let application know the result of probing network for name - * uniqueness, called with result 1 if no other node claimed use for the name for the - * netif or a service and is safe to use, or 0 if another node is already using it and - * mdns is disabled on this interface */ + * uniqueness, called with result MDNS_PROBING_SUCCESSFUL if no other node claimed + * use for the name for the netif or a service and is safe to use, or MDNS_PROBING_CONFLICT + * if another node is already using it and mdns is disabled on this interface */ typedef void (*mdns_name_result_cb_t)(struct netif* netif, u8_t result); void mdns_resp_init(void);