mdns: add defines for mdns_name_result_cb_t result parameter

This commit is contained in:
Simon Goldschmidt 2018-06-28 21:51:20 +02:00
parent 9f1196fb53
commit 6067edfed3
2 changed files with 11 additions and 6 deletions

View File

@ -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)
{

View File

@ -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);