mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 13:02:21 +02:00
mdns: add more mdns result attributes
* Original commit: espressif/esp-idf@76ec76c12c
This commit is contained in:
committed by
suren-gabrielyan-espressif
parent
05dcd8f0ee
commit
d37ab6dd25
@ -75,10 +75,13 @@ typedef struct mdns_result_s {
|
|||||||
struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */
|
struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */
|
||||||
|
|
||||||
mdns_if_t tcpip_if; /*!< interface index */
|
mdns_if_t tcpip_if; /*!< interface index */
|
||||||
|
uint32_t ttl; /*!< time to live */
|
||||||
|
|
||||||
mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */
|
mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */
|
||||||
// PTR
|
// PTR
|
||||||
char * instance_name; /*!< instance name */
|
char * instance_name; /*!< instance name */
|
||||||
|
char * service_type; /*!< service type */
|
||||||
|
char * proto; /*!< srevice protocol */
|
||||||
// SRV
|
// SRV
|
||||||
char * hostname; /*!< hostname */
|
char * hostname; /*!< hostname */
|
||||||
uint16_t port; /*!< service port */
|
uint16_t port; /*!< service port */
|
||||||
|
@ -41,10 +41,16 @@ static SemaphoreHandle_t _mdns_service_semaphore = NULL;
|
|||||||
|
|
||||||
static void _mdns_search_finish_done(void);
|
static void _mdns_search_finish_done(void);
|
||||||
static mdns_search_once_t * _mdns_search_find_from(mdns_search_once_t * search, mdns_name_t * name, uint16_t type, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
static mdns_search_once_t * _mdns_search_find_from(mdns_search_once_t * search, mdns_name_t * name, uint16_t type, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
||||||
static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char * hostname, esp_ip_addr_t * ip, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char * hostname, esp_ip_addr_t * ip,
|
||||||
static void _mdns_search_result_add_srv(mdns_search_once_t * search, const char * hostname, uint16_t port, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, uint32_t ttl);
|
||||||
static void _mdns_search_result_add_txt(mdns_search_once_t * search, mdns_txt_item_t * txt, uint8_t *txt_value_len, size_t txt_count, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
static void _mdns_search_result_add_srv(mdns_search_once_t *search, const char *hostname, uint16_t port,
|
||||||
static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search, const char * instance, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol);
|
mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, uint32_t ttl);
|
||||||
|
static void _mdns_search_result_add_txt(mdns_search_once_t *search, mdns_txt_item_t *txt, uint8_t *txt_value_len,
|
||||||
|
size_t txt_count, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol,
|
||||||
|
uint32_t ttl);
|
||||||
|
static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search, const char * instance,
|
||||||
|
const char * service_type, const char * proto, mdns_if_t tcpip_if,
|
||||||
|
mdns_ip_protocol_t ip_protocol, uint32_t ttl);
|
||||||
static bool _mdns_append_host_list_in_services(mdns_out_answer_t ** destination, mdns_srv_item_t * services[], size_t services_len, bool flush, bool bye);
|
static bool _mdns_append_host_list_in_services(mdns_out_answer_t ** destination, mdns_srv_item_t * services[], size_t services_len, bool flush, bool bye);
|
||||||
static bool _mdns_append_host_list(mdns_out_answer_t ** destination, bool flush, bool bye);
|
static bool _mdns_append_host_list(mdns_out_answer_t ** destination, bool flush, bool bye);
|
||||||
static void _mdns_remap_self_service_hostname(const char *old_hostname, const char *new_hostname);
|
static void _mdns_remap_self_service_hostname(const char *old_hostname, const char *new_hostname);
|
||||||
@ -3162,7 +3168,8 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
continue;//error
|
continue;//error
|
||||||
}
|
}
|
||||||
if (search_result) {
|
if (search_result) {
|
||||||
_mdns_search_result_add_ptr(search_result, name->host, packet->tcpip_if, packet->ip_protocol);
|
_mdns_search_result_add_ptr(search_result, name->host, name->service, name->proto,
|
||||||
|
packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
} else if ((discovery || ours) && !name->sub && _mdns_name_is_ours(name)) {
|
} else if ((discovery || ours) && !name->sub && _mdns_name_is_ours(name)) {
|
||||||
if (discovery) {
|
if (discovery) {
|
||||||
service = _mdns_get_service_item(name->service, name->proto, NULL);
|
service = _mdns_get_service_item(name->service, name->proto, NULL);
|
||||||
@ -3189,7 +3196,8 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
result = result->next;
|
result = result->next;
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = _mdns_search_result_add_ptr(search_result, name->host, packet->tcpip_if, packet->ip_protocol);
|
result = _mdns_search_result_add_ptr(search_result, name->host, name->service, name->proto,
|
||||||
|
packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;//error
|
continue;//error
|
||||||
}
|
}
|
||||||
@ -3210,7 +3218,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
result->hostname = strdup(name->host);
|
result->hostname = strdup(name->host);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_mdns_search_result_add_srv(search_result, name->host, port, packet->tcpip_if, packet->ip_protocol);
|
_mdns_search_result_add_srv(search_result, name->host, port, packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
}
|
}
|
||||||
} else if (ours) {
|
} else if (ours) {
|
||||||
if (parsed_packet->questions && !parsed_packet->probe) {
|
if (parsed_packet->questions && !parsed_packet->probe) {
|
||||||
@ -3285,7 +3293,8 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
result = result->next;
|
result = result->next;
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = _mdns_search_result_add_ptr(search_result, name->host, packet->tcpip_if, packet->ip_protocol);
|
result = _mdns_search_result_add_ptr(search_result, name->host, name->service, name->proto,
|
||||||
|
packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;//error
|
continue;//error
|
||||||
}
|
}
|
||||||
@ -3301,7 +3310,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
} else {
|
} else {
|
||||||
_mdns_result_txt_create(data_ptr, data_len, &txt, &txt_value_len, &txt_count);
|
_mdns_result_txt_create(data_ptr, data_len, &txt, &txt_value_len, &txt_count);
|
||||||
if (txt_count) {
|
if (txt_count) {
|
||||||
_mdns_search_result_add_txt(search_result, txt, txt_value_len, txt_count, packet->tcpip_if, packet->ip_protocol);
|
_mdns_search_result_add_txt(search_result, txt, txt_value_len, txt_count, packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ours) {
|
} else if (ours) {
|
||||||
@ -3335,7 +3344,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
if (search_result) {
|
if (search_result) {
|
||||||
//check for more applicable searches (PTR & A/AAAA at the same time)
|
//check for more applicable searches (PTR & A/AAAA at the same time)
|
||||||
while (search_result) {
|
while (search_result) {
|
||||||
_mdns_search_result_add_ip(search_result, name->host, &ip6, packet->tcpip_if, packet->ip_protocol);
|
_mdns_search_result_add_ip(search_result, name->host, &ip6, packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
search_result = _mdns_search_find_from(search_result->next, name, type, packet->tcpip_if, packet->ip_protocol);
|
search_result = _mdns_search_find_from(search_result->next, name, type, packet->tcpip_if, packet->ip_protocol);
|
||||||
}
|
}
|
||||||
} else if (ours) {
|
} else if (ours) {
|
||||||
@ -3385,7 +3394,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
|
|||||||
if (search_result) {
|
if (search_result) {
|
||||||
//check for more applicable searches (PTR & A/AAAA at the same time)
|
//check for more applicable searches (PTR & A/AAAA at the same time)
|
||||||
while (search_result) {
|
while (search_result) {
|
||||||
_mdns_search_result_add_ip(search_result, name->host, &ip, packet->tcpip_if, packet->ip_protocol);
|
_mdns_search_result_add_ip(search_result, name->host, &ip, packet->tcpip_if, packet->ip_protocol, ttl);
|
||||||
search_result = _mdns_search_find_from(search_result->next, name, type, packet->tcpip_if, packet->ip_protocol);
|
search_result = _mdns_search_find_from(search_result->next, name, type, packet->tcpip_if, packet->ip_protocol);
|
||||||
}
|
}
|
||||||
} else if (ours) {
|
} else if (ours) {
|
||||||
@ -3699,6 +3708,11 @@ static mdns_ip_addr_t * _mdns_result_addr_create_ip(esp_ip_addr_t * ip)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void _mdns_result_update_ttl(mdns_result_t * r, uint32_t ttl)
|
||||||
|
{
|
||||||
|
r->ttl = r->ttl < ttl ? r->ttl : ttl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Chain new IP to search result
|
* @brief Chain new IP to search result
|
||||||
*/
|
*/
|
||||||
@ -3727,7 +3741,8 @@ static void _mdns_result_add_ip(mdns_result_t * r, esp_ip_addr_t * ip)
|
|||||||
/**
|
/**
|
||||||
* @brief Called from parser to add A/AAAA data to search result
|
* @brief Called from parser to add A/AAAA data to search result
|
||||||
*/
|
*/
|
||||||
static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char * hostname, esp_ip_addr_t * ip, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
|
static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char * hostname, esp_ip_addr_t * ip,
|
||||||
|
mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, uint32_t ttl)
|
||||||
{
|
{
|
||||||
mdns_result_t * r = NULL;
|
mdns_result_t * r = NULL;
|
||||||
mdns_ip_addr_t * a = NULL;
|
mdns_ip_addr_t * a = NULL;
|
||||||
@ -3739,6 +3754,7 @@ static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char *
|
|||||||
while (r) {
|
while (r) {
|
||||||
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol) {
|
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol) {
|
||||||
_mdns_result_add_ip(r, ip);
|
_mdns_result_add_ip(r, ip);
|
||||||
|
_mdns_result_update_ttl(r, ttl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
@ -3758,18 +3774,21 @@ static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char *
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a->next = r->addr;
|
a->next = r->addr;
|
||||||
|
r->hostname = strdup(hostname);
|
||||||
r->addr = a;
|
r->addr = a;
|
||||||
r->tcpip_if = tcpip_if;
|
r->tcpip_if = tcpip_if;
|
||||||
r->ip_protocol = ip_protocol;
|
r->ip_protocol = ip_protocol;
|
||||||
r->next = search->result;
|
r->next = search->result;
|
||||||
|
r->ttl = ttl;
|
||||||
search->result = r;
|
search->result = r;
|
||||||
search->num_results++;
|
search->num_results++;
|
||||||
}
|
}
|
||||||
} else if (search->type == MDNS_TYPE_PTR) {
|
} else if (search->type == MDNS_TYPE_PTR || search->type == MDNS_TYPE_SRV) {
|
||||||
r = search->result;
|
r = search->result;
|
||||||
while (r) {
|
while (r) {
|
||||||
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->hostname) && !strcasecmp(hostname, r->hostname)) {
|
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->hostname) && !strcasecmp(hostname, r->hostname)) {
|
||||||
_mdns_result_add_ip(r, ip);
|
_mdns_result_add_ip(r, ip);
|
||||||
|
_mdns_result_update_ttl(r, ttl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
@ -3780,11 +3799,14 @@ static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char *
|
|||||||
/**
|
/**
|
||||||
* @brief Called from parser to add PTR data to search result
|
* @brief Called from parser to add PTR data to search result
|
||||||
*/
|
*/
|
||||||
static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search, const char * instance, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
|
static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search, const char * instance,
|
||||||
|
const char * service_type, const char * proto, mdns_if_t tcpip_if,
|
||||||
|
mdns_ip_protocol_t ip_protocol, uint32_t ttl)
|
||||||
{
|
{
|
||||||
mdns_result_t * r = search->result;
|
mdns_result_t * r = search->result;
|
||||||
while (r) {
|
while (r) {
|
||||||
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->instance_name) && !strcasecmp(instance, r->instance_name)) {
|
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->instance_name) && !strcasecmp(instance, r->instance_name)) {
|
||||||
|
_mdns_result_update_ttl(r, ttl);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
@ -3798,6 +3820,8 @@ static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search,
|
|||||||
|
|
||||||
memset(r, 0 , sizeof(mdns_result_t));
|
memset(r, 0 , sizeof(mdns_result_t));
|
||||||
r->instance_name = strdup(instance);
|
r->instance_name = strdup(instance);
|
||||||
|
r->service_type = strdup(service_type);
|
||||||
|
r->proto = strdup(proto);
|
||||||
if (!r->instance_name) {
|
if (!r->instance_name) {
|
||||||
free(r);
|
free(r);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3805,6 +3829,7 @@ static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search,
|
|||||||
|
|
||||||
r->tcpip_if = tcpip_if;
|
r->tcpip_if = tcpip_if;
|
||||||
r->ip_protocol = ip_protocol;
|
r->ip_protocol = ip_protocol;
|
||||||
|
r->ttl = ttl;
|
||||||
r->next = search->result;
|
r->next = search->result;
|
||||||
search->result = r;
|
search->result = r;
|
||||||
search->num_results++;
|
search->num_results++;
|
||||||
@ -3816,11 +3841,13 @@ static mdns_result_t * _mdns_search_result_add_ptr(mdns_search_once_t * search,
|
|||||||
/**
|
/**
|
||||||
* @brief Called from parser to add SRV data to search result
|
* @brief Called from parser to add SRV data to search result
|
||||||
*/
|
*/
|
||||||
static void _mdns_search_result_add_srv(mdns_search_once_t * search, const char * hostname, uint16_t port, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
|
static void _mdns_search_result_add_srv(mdns_search_once_t *search, const char *hostname, uint16_t port,
|
||||||
|
mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, uint32_t ttl)
|
||||||
{
|
{
|
||||||
mdns_result_t * r = search->result;
|
mdns_result_t * r = search->result;
|
||||||
while (r) {
|
while (r) {
|
||||||
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->hostname) && !strcasecmp(hostname, r->hostname)) {
|
if (r->tcpip_if == tcpip_if && r->ip_protocol == ip_protocol && !_str_null_or_empty(r->hostname) && !strcasecmp(hostname, r->hostname)) {
|
||||||
|
_mdns_result_update_ttl(r, ttl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
@ -3838,9 +3865,15 @@ static void _mdns_search_result_add_srv(mdns_search_once_t * search, const char
|
|||||||
free(r);
|
free(r);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (search->instance) {
|
||||||
|
r->instance_name = strdup(search->instance);
|
||||||
|
}
|
||||||
|
r->service_type = strdup(search->service);
|
||||||
|
r->proto = strdup(search->proto);
|
||||||
r->port = port;
|
r->port = port;
|
||||||
r->tcpip_if = tcpip_if;
|
r->tcpip_if = tcpip_if;
|
||||||
r->ip_protocol = ip_protocol;
|
r->ip_protocol = ip_protocol;
|
||||||
|
r->ttl = ttl;
|
||||||
r->next = search->result;
|
r->next = search->result;
|
||||||
search->result = r;
|
search->result = r;
|
||||||
search->num_results++;
|
search->num_results++;
|
||||||
@ -3850,7 +3883,9 @@ static void _mdns_search_result_add_srv(mdns_search_once_t * search, const char
|
|||||||
/**
|
/**
|
||||||
* @brief Called from parser to add TXT data to search result
|
* @brief Called from parser to add TXT data to search result
|
||||||
*/
|
*/
|
||||||
static void _mdns_search_result_add_txt(mdns_search_once_t * search, mdns_txt_item_t * txt, uint8_t *txt_value_len, size_t txt_count, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
|
static void _mdns_search_result_add_txt(mdns_search_once_t *search, mdns_txt_item_t *txt, uint8_t *txt_value_len,
|
||||||
|
size_t txt_count, mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol,
|
||||||
|
uint32_t ttl)
|
||||||
{
|
{
|
||||||
mdns_result_t * r = search->result;
|
mdns_result_t * r = search->result;
|
||||||
while (r) {
|
while (r) {
|
||||||
@ -3861,6 +3896,7 @@ static void _mdns_search_result_add_txt(mdns_search_once_t * search, mdns_txt_it
|
|||||||
r->txt = txt;
|
r->txt = txt;
|
||||||
r->txt_value_len = txt_value_len;
|
r->txt_value_len = txt_value_len;
|
||||||
r->txt_count = txt_count;
|
r->txt_count = txt_count;
|
||||||
|
_mdns_result_update_ttl(r, ttl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
@ -3878,6 +3914,7 @@ static void _mdns_search_result_add_txt(mdns_search_once_t * search, mdns_txt_it
|
|||||||
r->txt_count = txt_count;
|
r->txt_count = txt_count;
|
||||||
r->tcpip_if = tcpip_if;
|
r->tcpip_if = tcpip_if;
|
||||||
r->ip_protocol = ip_protocol;
|
r->ip_protocol = ip_protocol;
|
||||||
|
r->ttl = ttl;
|
||||||
r->next = search->result;
|
r->next = search->result;
|
||||||
search->result = r;
|
search->result = r;
|
||||||
search->num_results++;
|
search->num_results++;
|
||||||
@ -3906,12 +3943,12 @@ static mdns_search_once_t * _mdns_search_find_from(mdns_search_once_t * s, mdns_
|
|||||||
|
|
||||||
if (type == MDNS_TYPE_A || type == MDNS_TYPE_AAAA) {
|
if (type == MDNS_TYPE_A || type == MDNS_TYPE_AAAA) {
|
||||||
if ((s->type == MDNS_TYPE_ANY && s->service != NULL)
|
if ((s->type == MDNS_TYPE_ANY && s->service != NULL)
|
||||||
|| (s->type != MDNS_TYPE_ANY && s->type != type && s->type != MDNS_TYPE_PTR))
|
|| (s->type != MDNS_TYPE_ANY && s->type != type && s->type != MDNS_TYPE_PTR && s->type != MDNS_TYPE_SRV))
|
||||||
{
|
{
|
||||||
s = s->next;
|
s = s->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (s->type != MDNS_TYPE_PTR) {
|
if (s->type != MDNS_TYPE_PTR && s->type != MDNS_TYPE_SRV) {
|
||||||
if (!strcasecmp(name->host, s->instance)) {
|
if (!strcasecmp(name->host, s->instance)) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -5266,6 +5303,8 @@ void mdns_query_results_free(mdns_result_t * results)
|
|||||||
|
|
||||||
free((char *)(r->hostname));
|
free((char *)(r->hostname));
|
||||||
free((char *)(r->instance_name));
|
free((char *)(r->instance_name));
|
||||||
|
free((char *)(r->service_type));
|
||||||
|
free((char *)(r->proto));
|
||||||
|
|
||||||
for (size_t i=0; i<r->txt_count; i++) {
|
for (size_t i=0; i<r->txt_count; i++) {
|
||||||
free((char *)(r->txt[i].key));
|
free((char *)(r->txt[i].key));
|
||||||
|
@ -85,14 +85,16 @@ static const char * if_str[] = {"STA", "AP", "ETH", "MAX"};
|
|||||||
/* these strings match mdns_ip_protocol_t enumeration */
|
/* these strings match mdns_ip_protocol_t enumeration */
|
||||||
static const char * ip_protocol_str[] = {"V4", "V6", "MAX"};
|
static const char * ip_protocol_str[] = {"V4", "V6", "MAX"};
|
||||||
|
|
||||||
static void mdns_print_results(mdns_result_t * results){
|
static void mdns_print_results(mdns_result_t *results)
|
||||||
|
{
|
||||||
mdns_result_t *r = results;
|
mdns_result_t *r = results;
|
||||||
mdns_ip_addr_t *a = NULL;
|
mdns_ip_addr_t *a = NULL;
|
||||||
int i = 1, t;
|
int i = 1, t;
|
||||||
while (r) {
|
while (r) {
|
||||||
printf("%d: Interface: %s, Type: %s\n", i++, if_str[r->tcpip_if], ip_protocol_str[r->ip_protocol]);
|
printf("%d: Interface: %s, Type: %s, TTL: %u\n", i++, if_str[r->tcpip_if], ip_protocol_str[r->ip_protocol],
|
||||||
|
r->ttl);
|
||||||
if (r->instance_name) {
|
if (r->instance_name) {
|
||||||
printf(" PTR : %s\n", r->instance_name);
|
printf(" PTR : %s.%s.%s\n", r->instance_name, r->service_type, r->proto);
|
||||||
}
|
}
|
||||||
if (r->hostname) {
|
if (r->hostname) {
|
||||||
printf(" SRV : %s.local:%u\n", r->hostname, r->port);
|
printf(" SRV : %s.local:%u\n", r->hostname, r->port);
|
||||||
@ -100,8 +102,7 @@ static void mdns_print_results(mdns_result_t * results){
|
|||||||
if (r->txt_count) {
|
if (r->txt_count) {
|
||||||
printf(" TXT : [%zu] ", r->txt_count);
|
printf(" TXT : [%zu] ", r->txt_count);
|
||||||
for (t = 0; t < r->txt_count; t++) {
|
for (t = 0; t < r->txt_count; t++) {
|
||||||
printf("%s=%s(%d); ", r->txt[t].key, r->txt[t].value?r->txt[t].value:"NULL",
|
printf("%s=%s(%d); ", r->txt[t].key, r->txt[t].value ? r->txt[t].value : "NULL", r->txt_value_len[t]);
|
||||||
r->txt_value_len[t]);
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
@ -116,7 +117,6 @@ static void mdns_print_results(mdns_result_t * results){
|
|||||||
}
|
}
|
||||||
r = r->next;
|
r = r->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void query_mdns_service(const char * service_name, const char * proto)
|
static void query_mdns_service(const char * service_name, const char * proto)
|
||||||
|
Reference in New Issue
Block a user