mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-26 16:12:55 +00:00
Reformat mdns.c using astylerc
This commit is contained in:
parent
014420bfa0
commit
914a20728e
@ -69,13 +69,13 @@
|
|||||||
#if LWIP_MDNS_RESPONDER
|
#if LWIP_MDNS_RESPONDER
|
||||||
|
|
||||||
#if (LWIP_IPV4 && !LWIP_IGMP)
|
#if (LWIP_IPV4 && !LWIP_IGMP)
|
||||||
#error "If you want to use MDNS with IPv4, you have to define LWIP_IGMP=1 in your lwipopts.h"
|
#error "If you want to use MDNS with IPv4, you have to define LWIP_IGMP=1 in your lwipopts.h"
|
||||||
#endif
|
#endif
|
||||||
#if (LWIP_IPV6 && !LWIP_IPV6_MLD)
|
#if (LWIP_IPV6 && !LWIP_IPV6_MLD)
|
||||||
#error "If you want to use MDNS with IPv6, you have to define LWIP_IPV6_MLD=1 in your lwipopts.h"
|
#error "If you want to use MDNS with IPv6, you have to define LWIP_IPV6_MLD=1 in your lwipopts.h"
|
||||||
#endif
|
#endif
|
||||||
#if (!LWIP_UDP)
|
#if (!LWIP_UDP)
|
||||||
#error "If you want to use MDNS, you have to define LWIP_UDP=1 in your lwipopts.h"
|
#error "If you want to use MDNS, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
@ -340,7 +340,7 @@ mdns_readname_loop(struct pbuf *p, u16_t offset, struct mdns_domain *domain, uns
|
|||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
/* is this a compressed label? */
|
/* is this a compressed label? */
|
||||||
if((c & 0xc0) == 0xc0) {
|
if ((c & 0xc0) == 0xc0) {
|
||||||
u16_t jumpaddr;
|
u16_t jumpaddr;
|
||||||
if (offset >= p->tot_len) {
|
if (offset >= p->tot_len) {
|
||||||
/* Make sure both jump bytes fit in the packet */
|
/* Make sure both jump bytes fit in the packet */
|
||||||
@ -498,9 +498,9 @@ mdns_build_reverse_v4_domain(struct mdns_domain *domain, const ip4_addr_t *addr)
|
|||||||
res = mdns_domain_add_label(domain, buf, (u8_t)strlen(buf));
|
res = mdns_domain_add_label(domain, buf, (u8_t)strlen(buf));
|
||||||
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
}
|
}
|
||||||
res = mdns_domain_add_label(domain, REVERSE_PTR_V4_DOMAIN, (u8_t)(sizeof(REVERSE_PTR_V4_DOMAIN)-1));
|
res = mdns_domain_add_label(domain, REVERSE_PTR_V4_DOMAIN, (u8_t)(sizeof(REVERSE_PTR_V4_DOMAIN) - 1));
|
||||||
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, REVERSE_PTR_TOPDOMAIN, (u8_t)(sizeof(REVERSE_PTR_TOPDOMAIN)-1));
|
res = mdns_domain_add_label(domain, REVERSE_PTR_TOPDOMAIN, (u8_t)(sizeof(REVERSE_PTR_TOPDOMAIN) - 1));
|
||||||
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, NULL, 0);
|
res = mdns_domain_add_label(domain, NULL, 0);
|
||||||
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
@ -543,9 +543,9 @@ mdns_build_reverse_v6_domain(struct mdns_domain *domain, const ip6_addr_t *addr)
|
|||||||
byte >>= 4;
|
byte >>= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = mdns_domain_add_label(domain, REVERSE_PTR_V6_DOMAIN, (u8_t)(sizeof(REVERSE_PTR_V6_DOMAIN)-1));
|
res = mdns_domain_add_label(domain, REVERSE_PTR_V6_DOMAIN, (u8_t)(sizeof(REVERSE_PTR_V6_DOMAIN) - 1));
|
||||||
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, REVERSE_PTR_TOPDOMAIN, (u8_t)(sizeof(REVERSE_PTR_TOPDOMAIN)-1));
|
res = mdns_domain_add_label(domain, REVERSE_PTR_TOPDOMAIN, (u8_t)(sizeof(REVERSE_PTR_TOPDOMAIN) - 1));
|
||||||
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, NULL, 0);
|
res = mdns_domain_add_label(domain, NULL, 0);
|
||||||
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_reverse_v6_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
@ -558,7 +558,7 @@ mdns_build_reverse_v6_domain(struct mdns_domain *domain, const ip6_addr_t *addr)
|
|||||||
static err_t
|
static err_t
|
||||||
mdns_add_dotlocal(struct mdns_domain *domain)
|
mdns_add_dotlocal(struct mdns_domain *domain)
|
||||||
{
|
{
|
||||||
err_t res = mdns_domain_add_label(domain, TOPDOMAIN_LOCAL, (u8_t)(sizeof(TOPDOMAIN_LOCAL)-1));
|
err_t res = mdns_domain_add_label(domain, TOPDOMAIN_LOCAL, (u8_t)(sizeof(TOPDOMAIN_LOCAL) - 1));
|
||||||
LWIP_ERROR("mdns_add_dotlocal: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_add_dotlocal: Failed to add label", (res == ERR_OK), return res);
|
||||||
return mdns_domain_add_label(domain, NULL, 0);
|
return mdns_domain_add_label(domain, NULL, 0);
|
||||||
}
|
}
|
||||||
@ -590,9 +590,9 @@ mdns_build_dnssd_domain(struct mdns_domain *domain)
|
|||||||
{
|
{
|
||||||
err_t res;
|
err_t res;
|
||||||
memset(domain, 0, sizeof(struct mdns_domain));
|
memset(domain, 0, sizeof(struct mdns_domain));
|
||||||
res = mdns_domain_add_label(domain, "_services", (u8_t)(sizeof("_services")-1));
|
res = mdns_domain_add_label(domain, "_services", (u8_t)(sizeof("_services") - 1));
|
||||||
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, "_dns-sd", (u8_t)(sizeof("_dns-sd")-1));
|
res = mdns_domain_add_label(domain, "_dns-sd", (u8_t)(sizeof("_dns-sd") - 1));
|
||||||
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
res = mdns_domain_add_label(domain, dnssd_protos[DNSSD_PROTO_UDP], (u8_t)strlen(dnssd_protos[DNSSD_PROTO_UDP]));
|
res = mdns_domain_add_label(domain, dnssd_protos[DNSSD_PROTO_UDP], (u8_t)strlen(dnssd_protos[DNSSD_PROTO_UDP]));
|
||||||
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
LWIP_ERROR("mdns_build_dnssd_domain: Failed to add label", (res == ERR_OK), return res);
|
||||||
@ -1278,7 +1278,7 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
|
|||||||
struct mdns_service *service;
|
struct mdns_service *service;
|
||||||
err_t res;
|
err_t res;
|
||||||
int i;
|
int i;
|
||||||
struct mdns_host* mdns = NETIF_TO_HOST(outpkt->netif);
|
struct mdns_host *mdns = NETIF_TO_HOST(outpkt->netif);
|
||||||
|
|
||||||
/* Write answers to host questions */
|
/* Write answers to host questions */
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
@ -1478,14 +1478,15 @@ mdns_announce(struct netif *netif, const ip_addr_t *destination)
|
|||||||
{
|
{
|
||||||
struct mdns_outpacket announce;
|
struct mdns_outpacket announce;
|
||||||
int i;
|
int i;
|
||||||
struct mdns_host* mdns = NETIF_TO_HOST(netif);
|
struct mdns_host *mdns = NETIF_TO_HOST(netif);
|
||||||
|
|
||||||
memset(&announce, 0, sizeof(announce));
|
memset(&announce, 0, sizeof(announce));
|
||||||
announce.netif = netif;
|
announce.netif = netif;
|
||||||
announce.cache_flush = 1;
|
announce.cache_flush = 1;
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
if (!ip4_addr_isany_val(*netif_ip4_addr(netif)))
|
if (!ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
||||||
announce.host_replies = REPLY_HOST_A | REPLY_HOST_PTR_V4;
|
announce.host_replies = REPLY_HOST_A | REPLY_HOST_PTR_V4;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) {
|
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) {
|
||||||
@ -1523,7 +1524,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
int replies = 0;
|
int replies = 0;
|
||||||
int i;
|
int i;
|
||||||
err_t res;
|
err_t res;
|
||||||
struct mdns_host* mdns = NETIF_TO_HOST(pkt->netif);
|
struct mdns_host *mdns = NETIF_TO_HOST(pkt->netif);
|
||||||
|
|
||||||
mdns_init_outpacket(&reply, pkt);
|
mdns_init_outpacket(&reply, pkt);
|
||||||
|
|
||||||
@ -1775,7 +1776,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
|||||||
LWIP_UNUSED_ARG(arg);
|
LWIP_UNUSED_ARG(arg);
|
||||||
LWIP_UNUSED_ARG(pcb);
|
LWIP_UNUSED_ARG(pcb);
|
||||||
|
|
||||||
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Received IPv%d MDNS packet, len %d\n", IP_IS_V6(addr)? 6 : 4, p->tot_len));
|
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Received IPv%d MDNS packet, len %d\n", IP_IS_V6(addr) ? 6 : 4, p->tot_len));
|
||||||
|
|
||||||
if (NETIF_TO_HOST(recv_netif) == NULL) {
|
if (NETIF_TO_HOST(recv_netif) == NULL) {
|
||||||
/* From netif not configured for MDNS */
|
/* From netif not configured for MDNS */
|
||||||
@ -1856,7 +1857,7 @@ mdns_resp_netif_settings_changed(struct netif *netif)
|
|||||||
|
|
||||||
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
#if LWIP_NETIF_EXT_STATUS_CALLBACK
|
||||||
static void
|
static void
|
||||||
mdns_netif_ext_status_callback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args)
|
mdns_netif_ext_status_callback(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
|
||||||
{
|
{
|
||||||
LWIP_UNUSED_ARG(args);
|
LWIP_UNUSED_ARG(args);
|
||||||
|
|
||||||
@ -1865,8 +1866,7 @@ mdns_netif_ext_status_callback(struct netif* netif, netif_nsc_reason_t reason, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (reason)
|
switch (reason) {
|
||||||
{
|
|
||||||
case LWIP_NSC_STATUS_CHANGED:
|
case LWIP_NSC_STATUS_CHANGED:
|
||||||
if (args->status_changed.state != 0) {
|
if (args->status_changed.state != 0) {
|
||||||
mdns_resp_netif_settings_changed(netif);
|
mdns_resp_netif_settings_changed(netif);
|
||||||
@ -1906,7 +1906,7 @@ err_t
|
|||||||
mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl)
|
mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl)
|
||||||
{
|
{
|
||||||
err_t res;
|
err_t res;
|
||||||
struct mdns_host* mdns;
|
struct mdns_host *mdns;
|
||||||
|
|
||||||
LWIP_ERROR("mdns_resp_add_netif: netif != NULL", (netif != NULL), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_netif: netif != NULL", (netif != NULL), return ERR_VAL);
|
||||||
LWIP_ERROR("mdns_resp_add_netif: Hostname too long", (strlen(hostname) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_netif: Hostname too long", (strlen(hostname) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
||||||
@ -1954,7 +1954,7 @@ err_t
|
|||||||
mdns_resp_remove_netif(struct netif *netif)
|
mdns_resp_remove_netif(struct netif *netif)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct mdns_host* mdns;
|
struct mdns_host *mdns;
|
||||||
|
|
||||||
LWIP_ASSERT("mdns_resp_remove_netif: Null pointer", netif);
|
LWIP_ASSERT("mdns_resp_remove_netif: Null pointer", netif);
|
||||||
mdns = NETIF_TO_HOST(netif);
|
mdns = NETIF_TO_HOST(netif);
|
||||||
@ -2001,7 +2001,7 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
s8_t i;
|
s8_t i;
|
||||||
s8_t slot = -1;
|
s8_t slot = -1;
|
||||||
struct mdns_service *srv;
|
struct mdns_service *srv;
|
||||||
struct mdns_host* mdns;
|
struct mdns_host *mdns;
|
||||||
|
|
||||||
LWIP_ASSERT("mdns_resp_add_service: netif != NULL", netif);
|
LWIP_ASSERT("mdns_resp_add_service: netif != NULL", netif);
|
||||||
mdns = NETIF_TO_HOST(netif);
|
mdns = NETIF_TO_HOST(netif);
|
||||||
@ -2019,7 +2019,7 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
}
|
}
|
||||||
LWIP_ERROR("mdns_resp_add_service: Service list full (increase MDNS_MAX_SERVICES)", (slot >= 0), return ERR_MEM);
|
LWIP_ERROR("mdns_resp_add_service: Service list full (increase MDNS_MAX_SERVICES)", (slot >= 0), return ERR_MEM);
|
||||||
|
|
||||||
srv = (struct mdns_service*)mem_calloc(1, sizeof(struct mdns_service));
|
srv = (struct mdns_service *)mem_calloc(1, sizeof(struct mdns_service));
|
||||||
LWIP_ERROR("mdns_resp_add_service: Alloc failed", (srv != NULL), return ERR_MEM);
|
LWIP_ERROR("mdns_resp_add_service: Alloc failed", (srv != NULL), return ERR_MEM);
|
||||||
|
|
||||||
MEMCPY(&srv->name, name, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(name)));
|
MEMCPY(&srv->name, name, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(name)));
|
||||||
@ -2052,7 +2052,7 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
err_t
|
err_t
|
||||||
mdns_resp_del_service(struct netif *netif, s8_t slot)
|
mdns_resp_del_service(struct netif *netif, s8_t slot)
|
||||||
{
|
{
|
||||||
struct mdns_host* mdns;
|
struct mdns_host *mdns;
|
||||||
struct mdns_service *srv;
|
struct mdns_service *srv;
|
||||||
LWIP_ASSERT("mdns_resp_del_service: netif != NULL", netif);
|
LWIP_ASSERT("mdns_resp_del_service: netif != NULL", netif);
|
||||||
mdns = NETIF_TO_HOST(netif);
|
mdns = NETIF_TO_HOST(netif);
|
||||||
|
Loading…
Reference in New Issue
Block a user