mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
Introduce an API to store arbitrary data pointers in struct netif
Let MDNS to use the new API TODO: AutoIP, DHCP
This commit is contained in:
parent
93b286e508
commit
c28fb298b7
@ -103,6 +103,7 @@ static const ip_addr_t v6group = IPADDR6_INIT(PP_HTONL(0xFF020000UL), PP_HTONL(0
|
|||||||
#define DOMAIN_JUMP_SIZE 2
|
#define DOMAIN_JUMP_SIZE 2
|
||||||
#define DOMAIN_JUMP 0xc000
|
#define DOMAIN_JUMP 0xc000
|
||||||
|
|
||||||
|
static u8_t mdns_netif_client_id;
|
||||||
static struct udp_pcb *mdns_pcb;
|
static struct udp_pcb *mdns_pcb;
|
||||||
|
|
||||||
#define TOPDOMAIN_LOCAL "local"
|
#define TOPDOMAIN_LOCAL "local"
|
||||||
@ -682,7 +683,7 @@ check_host(struct netif *netif, struct mdns_rr_info *rr, u8_t *reverse_v6_reply)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
res = mdns_build_host_domain(&mydomain, netif->mdns);
|
res = mdns_build_host_domain(&mydomain, (struct mdns_host*)netif->client_data[mdns_netif_client_id]);
|
||||||
/* Handle requests for our hostname */
|
/* Handle requests for our hostname */
|
||||||
if (res == ERR_OK && mdns_domain_eq(&rr->domain, &mydomain)) {
|
if (res == ERR_OK && mdns_domain_eq(&rr->domain, &mydomain)) {
|
||||||
/* TODO return NSEC if unsupported protocol requested */
|
/* TODO return NSEC if unsupported protocol requested */
|
||||||
@ -1146,9 +1147,9 @@ static err_t
|
|||||||
mdns_add_a_answer(struct mdns_outpacket *reply, u16_t cache_flush, struct netif *netif)
|
mdns_add_a_answer(struct mdns_outpacket *reply, u16_t cache_flush, struct netif *netif)
|
||||||
{
|
{
|
||||||
struct mdns_domain host;
|
struct mdns_domain host;
|
||||||
mdns_build_host_domain(&host, netif->mdns);
|
mdns_build_host_domain(&host, (struct mdns_host*)netif->client_data[mdns_netif_client_id]);
|
||||||
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Responding with A record\n"));
|
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Responding with A record\n"));
|
||||||
return mdns_add_answer(reply, &host, DNS_RRTYPE_A, DNS_RRCLASS_IN, cache_flush, netif->mdns->dns_ttl, (const u8_t *) netif_ip4_addr(netif), sizeof(ip4_addr_t), NULL);
|
return mdns_add_answer(reply, &host, DNS_RRTYPE_A, DNS_RRCLASS_IN, cache_flush, ((struct mdns_host*)netif->client_data[mdns_netif_client_id])->dns_ttl, (const u8_t *) netif_ip4_addr(netif), sizeof(ip4_addr_t), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write a 4.3.2.1.in-addr.arpa -> hostname.local PTR RR to outpacket */
|
/** Write a 4.3.2.1.in-addr.arpa -> hostname.local PTR RR to outpacket */
|
||||||
@ -1156,10 +1157,10 @@ static err_t
|
|||||||
mdns_add_hostv4_ptr_answer(struct mdns_outpacket *reply, u16_t cache_flush, struct netif *netif)
|
mdns_add_hostv4_ptr_answer(struct mdns_outpacket *reply, u16_t cache_flush, struct netif *netif)
|
||||||
{
|
{
|
||||||
struct mdns_domain host, revhost;
|
struct mdns_domain host, revhost;
|
||||||
mdns_build_host_domain(&host, netif->mdns);
|
mdns_build_host_domain(&host, (struct mdns_host*)netif->client_data[mdns_netif_client_id]);
|
||||||
mdns_build_reverse_v4_domain(&revhost, netif_ip4_addr(netif));
|
mdns_build_reverse_v4_domain(&revhost, netif_ip4_addr(netif));
|
||||||
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Responding with v4 PTR record\n"));
|
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: Responding with v4 PTR record\n"));
|
||||||
return mdns_add_answer(reply, &revhost, DNS_RRTYPE_PTR, DNS_RRCLASS_IN, cache_flush, netif->mdns->dns_ttl, NULL, 0, &host);
|
return mdns_add_answer(reply, &revhost, DNS_RRTYPE_PTR, DNS_RRCLASS_IN, cache_flush, ((struct mdns_host*)netif->client_data[mdns_netif_client_id])->dns_ttl, NULL, 0, &host);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1286,6 +1287,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 = (struct mdns_host*)outpkt->netif->client_data[mdns_netif_client_id];
|
||||||
|
|
||||||
/* Write answers to host questions */
|
/* Write answers to host questions */
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
@ -1336,7 +1338,7 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
|
|||||||
|
|
||||||
/* Write answers to service questions */
|
/* Write answers to service questions */
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
||||||
service = outpkt->netif->mdns->services[i];
|
service = mdns->services[i];
|
||||||
if (!service) {
|
if (!service) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1358,7 +1360,7 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (outpkt->serv_replies[i] & REPLY_SERVICE_SRV) {
|
if (outpkt->serv_replies[i] & REPLY_SERVICE_SRV) {
|
||||||
res = mdns_add_srv_answer(outpkt, outpkt->cache_flush, outpkt->netif->mdns, service);
|
res = mdns_add_srv_answer(outpkt, outpkt->cache_flush, mdns, service);
|
||||||
if (res != ERR_OK) {
|
if (res != ERR_OK) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1376,7 +1378,7 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
|
|||||||
|
|
||||||
/* All answers written, add additional RRs */
|
/* All answers written, add additional RRs */
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
||||||
service = outpkt->netif->mdns->services[i];
|
service = mdns->services[i];
|
||||||
if (!service) {
|
if (!service) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1385,7 +1387,7 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
|
|||||||
/* Our service instance requested, include SRV & TXT
|
/* Our service instance requested, include SRV & TXT
|
||||||
* if they are already not requested. */
|
* if they are already not requested. */
|
||||||
if (!(outpkt->serv_replies[i] & REPLY_SERVICE_SRV)) {
|
if (!(outpkt->serv_replies[i] & REPLY_SERVICE_SRV)) {
|
||||||
res = mdns_add_srv_answer(outpkt, outpkt->cache_flush, outpkt->netif->mdns, service);
|
res = mdns_add_srv_answer(outpkt, outpkt->cache_flush, mdns, service);
|
||||||
if (res != ERR_OK) {
|
if (res != ERR_OK) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1485,6 +1487,7 @@ 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 = (struct mdns_host*)netif->client_data[mdns_netif_client_id];
|
||||||
|
|
||||||
memset(&announce, 0, sizeof(announce));
|
memset(&announce, 0, sizeof(announce));
|
||||||
announce.netif = netif;
|
announce.netif = netif;
|
||||||
@ -1499,7 +1502,7 @@ mdns_announce(struct netif *netif, const ip_addr_t *destination)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
||||||
struct mdns_service *serv = netif->mdns->services[i];
|
struct mdns_service *serv = mdns->services[i];
|
||||||
if (serv) {
|
if (serv) {
|
||||||
announce.serv_replies[i] = REPLY_SERVICE_TYPE_PTR | REPLY_SERVICE_NAME_PTR |
|
announce.serv_replies[i] = REPLY_SERVICE_TYPE_PTR | REPLY_SERVICE_NAME_PTR |
|
||||||
REPLY_SERVICE_SRV | REPLY_SERVICE_TXT;
|
REPLY_SERVICE_SRV | REPLY_SERVICE_TXT;
|
||||||
@ -1525,6 +1528,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 = (struct mdns_host*)pkt->netif->client_data[mdns_netif_client_id];
|
||||||
|
|
||||||
mdns_init_outpacket(&reply, pkt);
|
mdns_init_outpacket(&reply, pkt);
|
||||||
|
|
||||||
@ -1550,7 +1554,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
replies |= reply.host_replies;
|
replies |= reply.host_replies;
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
||||||
service = pkt->netif->mdns->services[i];
|
service = mdns->services[i];
|
||||||
if (!service) {
|
if (!service) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1591,7 +1595,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
|
|
||||||
rev_v6 = 0;
|
rev_v6 = 0;
|
||||||
match = reply.host_replies & check_host(pkt->netif, &ans.info, &rev_v6);
|
match = reply.host_replies & check_host(pkt->netif, &ans.info, &rev_v6);
|
||||||
if (match && (ans.ttl > (pkt->netif->mdns->dns_ttl / 2))) {
|
if (match && (ans.ttl > (mdns->dns_ttl / 2))) {
|
||||||
/* The RR in the known answer matches an RR we are planning to send,
|
/* The RR in the known answer matches an RR we are planning to send,
|
||||||
* and the TTL is less than half gone.
|
* and the TTL is less than half gone.
|
||||||
* If the payload matches we should not send that answer.
|
* If the payload matches we should not send that answer.
|
||||||
@ -1601,7 +1605,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
struct mdns_domain known_ans, my_ans;
|
struct mdns_domain known_ans, my_ans;
|
||||||
u16_t len;
|
u16_t len;
|
||||||
len = mdns_readname(pkt->pbuf, ans.rd_offset, &known_ans);
|
len = mdns_readname(pkt->pbuf, ans.rd_offset, &known_ans);
|
||||||
res = mdns_build_host_domain(&my_ans, pkt->netif->mdns);
|
res = mdns_build_host_domain(&my_ans, mdns);
|
||||||
if (len != MDNS_READNAME_ERROR && res == ERR_OK && mdns_domain_eq(&known_ans, &my_ans)) {
|
if (len != MDNS_READNAME_ERROR && res == ERR_OK && mdns_domain_eq(&known_ans, &my_ans)) {
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
if (match & REPLY_HOST_PTR_V4) {
|
if (match & REPLY_HOST_PTR_V4) {
|
||||||
@ -1640,7 +1644,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
for (i = 0; i < MDNS_MAX_SERVICES; ++i) {
|
||||||
service = pkt->netif->mdns->services[i];
|
service = mdns->services[i];
|
||||||
if (!service) {
|
if (!service) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1697,7 +1701,7 @@ mdns_handle_question(struct mdns_packet *pkt)
|
|||||||
read_pos += len;
|
read_pos += len;
|
||||||
/* Check host field */
|
/* Check host field */
|
||||||
len = mdns_readname(pkt->pbuf, read_pos, &known_ans);
|
len = mdns_readname(pkt->pbuf, read_pos, &known_ans);
|
||||||
mdns_build_host_domain(&my_ans, pkt->netif->mdns);
|
mdns_build_host_domain(&my_ans, mdns);
|
||||||
if (len == MDNS_READNAME_ERROR || !mdns_domain_eq(&known_ans, &my_ans)) {
|
if (len == MDNS_READNAME_ERROR || !mdns_domain_eq(&known_ans, &my_ans)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1780,7 +1784,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
|||||||
|
|
||||||
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 (!recv_netif->mdns) {
|
if (recv_netif->client_data[mdns_netif_client_id] == NULL) {
|
||||||
/* From netif not configured for MDNS */
|
/* From netif not configured for MDNS */
|
||||||
goto dealloc;
|
goto dealloc;
|
||||||
}
|
}
|
||||||
@ -1850,6 +1854,8 @@ mdns_resp_init(void)
|
|||||||
res = udp_bind(mdns_pcb, IP_ANY_TYPE, MDNS_PORT);
|
res = udp_bind(mdns_pcb, IP_ANY_TYPE, MDNS_PORT);
|
||||||
LWIP_ASSERT("Failed to bind pcb", res == ERR_OK);
|
LWIP_ASSERT("Failed to bind pcb", res == ERR_OK);
|
||||||
udp_recv(mdns_pcb, mdns_recv, NULL);
|
udp_recv(mdns_pcb, mdns_recv, NULL);
|
||||||
|
|
||||||
|
mdns_netif_client_id = netif_alloc_client_data_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1866,17 +1872,20 @@ 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;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
LWIP_ASSERT("mdns_resp_add_netif: Double add", netif->mdns == NULL);
|
LWIP_ASSERT("mdns_resp_add_netif: Double add", netif->client_data[mdns_netif_client_id] == NULL);
|
||||||
netif->mdns = (struct mdns_host *) mem_malloc(sizeof(struct mdns_host));
|
mdns = (struct mdns_host *) mem_malloc(sizeof(struct mdns_host));
|
||||||
LWIP_ERROR("mdns_resp_add_netif: Alloc failed", (netif->mdns != NULL), return ERR_MEM);
|
LWIP_ERROR("mdns_resp_add_netif: Alloc failed", (mdns != NULL), return ERR_MEM);
|
||||||
|
|
||||||
memset(netif->mdns, 0, sizeof(struct mdns_host));
|
netif->client_data[mdns_netif_client_id] = mdns;
|
||||||
memcpy(&netif->mdns->name, hostname, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(hostname)));
|
|
||||||
netif->mdns->dns_ttl = dns_ttl;
|
memset(mdns, 0, sizeof(struct mdns_host));
|
||||||
|
memcpy(&mdns->name, hostname, LWIP_MIN(MDNS_LABEL_MAXLEN, strlen(hostname)));
|
||||||
|
mdns->dns_ttl = dns_ttl;
|
||||||
|
|
||||||
/* Join multicast groups */
|
/* Join multicast groups */
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
@ -1903,8 +1912,8 @@ mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl)
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mem_free(netif->mdns);
|
mem_free(mdns);
|
||||||
netif->mdns = NULL;
|
netif->client_data[mdns_netif_client_id] = NULL;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1919,11 +1928,13 @@ 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*)netif->client_data[mdns_netif_client_id];
|
||||||
|
|
||||||
LWIP_ASSERT("mdns_resp_remove_netif: Null pointer", netif);
|
LWIP_ASSERT("mdns_resp_remove_netif: Null pointer", netif);
|
||||||
LWIP_ERROR("mdns_resp_remove_netif: Not an active netif", (netif->mdns != NULL), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_remove_netif: Not an active netif", (mdns != NULL), return ERR_VAL);
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
||||||
struct mdns_service *service = netif->mdns->services[i];
|
struct mdns_service *service = mdns->services[i];
|
||||||
if (service) {
|
if (service) {
|
||||||
mem_free(service);
|
mem_free(service);
|
||||||
}
|
}
|
||||||
@ -1937,8 +1948,8 @@ mdns_resp_remove_netif(struct netif *netif)
|
|||||||
mld6_leavegroup_netif(netif, ip_2_ip6(&v6group));
|
mld6_leavegroup_netif(netif, ip_2_ip6(&v6group));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mem_free(netif->mdns);
|
mem_free(mdns);
|
||||||
netif->mdns = NULL;
|
netif->client_data[mdns_netif_client_id] = NULL;
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1963,16 +1974,17 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
int i;
|
int i;
|
||||||
int slot = -1;
|
int slot = -1;
|
||||||
struct mdns_service *srv;
|
struct mdns_service *srv;
|
||||||
|
struct mdns_host* mdns = (struct mdns_host*)netif->client_data[mdns_netif_client_id];
|
||||||
|
|
||||||
LWIP_ASSERT("mdns_resp_add_service: netif != NULL", netif);
|
LWIP_ASSERT("mdns_resp_add_service: netif != NULL", netif);
|
||||||
LWIP_ERROR("mdns_resp_add_service: Not an mdns netif", (netif->mdns != NULL), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Not an mdns netif", (mdns != NULL), return ERR_VAL);
|
||||||
|
|
||||||
LWIP_ERROR("mdns_resp_add_service: Name too long", (strlen(name) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Name too long", (strlen(name) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
||||||
LWIP_ERROR("mdns_resp_add_service: Service too long", (strlen(service) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Service too long", (strlen(service) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
||||||
LWIP_ERROR("mdns_resp_add_service: Bad proto (need TCP or UDP)", (proto == DNSSD_PROTO_TCP || proto == DNSSD_PROTO_UDP), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Bad proto (need TCP or UDP)", (proto == DNSSD_PROTO_TCP || proto == DNSSD_PROTO_UDP), return ERR_VAL);
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
||||||
if (netif->mdns->services[i] == NULL) {
|
if (mdns->services[i] == NULL) {
|
||||||
slot = i;
|
slot = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1992,7 +2004,7 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
srv->port = port;
|
srv->port = port;
|
||||||
srv->dns_ttl = dns_ttl;
|
srv->dns_ttl = dns_ttl;
|
||||||
|
|
||||||
netif->mdns->services[slot] = srv;
|
mdns->services[slot] = srv;
|
||||||
|
|
||||||
/* Announce on IPv6 and IPv4 */
|
/* Announce on IPv6 and IPv4 */
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "lwip/def.h"
|
#include "lwip/def.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
#include "lwip/ip6_addr.h"
|
#include "lwip/ip6_addr.h"
|
||||||
@ -247,10 +249,9 @@ netif_add(struct netif *netif,
|
|||||||
/* netif not under AutoIP control by default */
|
/* netif not under AutoIP control by default */
|
||||||
netif->autoip = NULL;
|
netif->autoip = NULL;
|
||||||
#endif /* LWIP_AUTOIP */
|
#endif /* LWIP_AUTOIP */
|
||||||
#if LWIP_MDNS_RESPONDER
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
||||||
/* netif not using MDNS by default */
|
memset(netif->client_data, 0, sizeof(netif->client_data));
|
||||||
netif->mdns = NULL;
|
#endif /* LWIP_NUM_NETIF_CLIENT_DATA */
|
||||||
#endif /* LWIP_MDNS_RESPONDER */
|
|
||||||
#if LWIP_IPV6_AUTOCONFIG
|
#if LWIP_IPV6_AUTOCONFIG
|
||||||
/* IPv6 address autoconfiguration not enabled by default */
|
/* IPv6 address autoconfiguration not enabled by default */
|
||||||
netif->ip6_autoconfig_enabled = 0;
|
netif->ip6_autoconfig_enabled = 0;
|
||||||
@ -947,6 +948,24 @@ netif_poll_all(void)
|
|||||||
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
|
||||||
#endif /* ENABLE_LOOPBACK */
|
#endif /* ENABLE_LOOPBACK */
|
||||||
|
|
||||||
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
||||||
|
static u8_t netif_client_id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup netif
|
||||||
|
* Allocate an index to store data in client_data member of struct netif.
|
||||||
|
* Returned value is an index in mentioned array.
|
||||||
|
* @see LWIP_NUM_NETIF_CLIENT_DATA
|
||||||
|
*/
|
||||||
|
u8_t netif_alloc_client_data_id(void)
|
||||||
|
{
|
||||||
|
u8_t result = netif_client_id;
|
||||||
|
netif_client_id++;
|
||||||
|
LWIP_ASSERT("Increase LWIP_NUM_NETIF_CLIENT_DATA in lwipopts.h", netif_client_id<LWIP_NUM_NETIF_CLIENT_DATA);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
/**
|
/**
|
||||||
* Checks if a specific address is assigned to the netif and returns its
|
* Checks if a specific address is assigned to the netif and returns its
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#define LWIP_HDR_NETIF_H
|
#define LWIP_HDR_NETIF_H
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/apps/mdns_opts.h"
|
|
||||||
|
|
||||||
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
|
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
|
||||||
|
|
||||||
@ -59,9 +58,6 @@ struct autoip;
|
|||||||
#if LWIP_IPV6_DHCP6
|
#if LWIP_IPV6_DHCP6
|
||||||
struct dhcp6;
|
struct dhcp6;
|
||||||
#endif /* LWIP_IPV6_DHCP6 */
|
#endif /* LWIP_IPV6_DHCP6 */
|
||||||
#if LWIP_MDNS_RESPONDER
|
|
||||||
struct mdns_host;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -259,10 +255,9 @@ struct netif {
|
|||||||
/** the AutoIP client state information for this netif */
|
/** the AutoIP client state information for this netif */
|
||||||
struct autoip *autoip;
|
struct autoip *autoip;
|
||||||
#endif
|
#endif
|
||||||
#if LWIP_MDNS_RESPONDER
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
||||||
/** Interface-specific info for multicast DNS */
|
void* client_data[LWIP_NUM_NETIF_CLIENT_DATA];
|
||||||
struct mdns_host *mdns;
|
#endif
|
||||||
#endif /* LWIP_MDNS_RESPONDER */
|
|
||||||
#if LWIP_IPV6_AUTOCONFIG
|
#if LWIP_IPV6_AUTOCONFIG
|
||||||
/** is this netif enabled for IPv6 autoconfiguration */
|
/** is this netif enabled for IPv6 autoconfiguration */
|
||||||
u8_t ip6_autoconfig_enabled;
|
u8_t ip6_autoconfig_enabled;
|
||||||
@ -431,6 +426,10 @@ void netif_poll_all(void);
|
|||||||
|
|
||||||
err_t netif_input(struct pbuf *p, struct netif *inp);
|
err_t netif_input(struct pbuf *p, struct netif *inp);
|
||||||
|
|
||||||
|
#if LWIP_NUM_NETIF_CLIENT_DATA > 0
|
||||||
|
u8_t netif_alloc_client_data_id(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
/** @ingroup netif */
|
/** @ingroup netif */
|
||||||
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
|
||||||
|
@ -1465,6 +1465,14 @@
|
|||||||
#if !defined LWIP_NETIF_TX_SINGLE_PBUF || defined __DOXYGEN__
|
#if !defined LWIP_NETIF_TX_SINGLE_PBUF || defined __DOXYGEN__
|
||||||
#define LWIP_NETIF_TX_SINGLE_PBUF 0
|
#define LWIP_NETIF_TX_SINGLE_PBUF 0
|
||||||
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
|
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store
|
||||||
|
* per data in client_data member array of struct netif.
|
||||||
|
*/
|
||||||
|
#if !defined LWIP_NUM_NETIF_CLIENT_DATA || defined __DOXYGEN__
|
||||||
|
#define LWIP_NUM_NETIF_CLIENT_DATA (LWIP_DHCP + LWIP_AUTOIP)
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user