mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-19 14:46:58 +08:00
Apply patch #8755: Multicast DNS responder support from Erik Ekman
This commit is contained in:
committed by
Dirk Ziegelmeier
parent
4af297fc20
commit
4919932c49
78
src/include/lwip/apps/mdns.h
Normal file
78
src/include/lwip/apps/mdns.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Verisure Innovation AB
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Erik Ekman <erik.ekman@verisure.com>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_MDNS_H
|
||||
#define LWIP_HDR_MDNS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#if LWIP_MDNS
|
||||
|
||||
#define DNSSD_PROTO_UDP 0
|
||||
#define DNSSD_PROTO_TCP 1
|
||||
|
||||
#define MDNS_LABEL_MAXLEN 63
|
||||
|
||||
struct mdns_host;
|
||||
struct mdns_service;
|
||||
|
||||
void mdns_resp_init(void);
|
||||
|
||||
err_t mdns_resp_add_netif(struct netif *netif, char *hostname, u32_t dns_ttl);
|
||||
err_t mdns_resp_remove_netif(struct netif *netif);
|
||||
|
||||
typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata);
|
||||
err_t mdns_resp_add_service(struct netif *netif, char *name, char *service, u16_t proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata);
|
||||
err_t mdns_resp_add_service_txtitem(struct mdns_service *service, char *txt, int txt_len);
|
||||
|
||||
|
||||
/* Domain struct and methods - visible for unit tests */
|
||||
#define MDNS_DOMAIN_MAXLEN 256
|
||||
#define MDNS_READNAME_ERROR 0xFFFF
|
||||
|
||||
struct mdns_domain {
|
||||
/* Encoded domain name */
|
||||
u8_t name[MDNS_DOMAIN_MAXLEN];
|
||||
/* Total length of domain name, including zero */
|
||||
u16_t length;
|
||||
/* Set if compression of this domain is not allowed */
|
||||
u8_t skip_compression;
|
||||
};
|
||||
|
||||
err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, unsigned len);
|
||||
u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain);
|
||||
int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b);
|
||||
u8_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain);
|
||||
|
||||
#endif /* LWIP_MDNS */
|
||||
|
||||
#endif /* LWIP_HDR_MDNS_H */
|
||||
41
src/include/lwip/apps/mdns_opts.h
Normal file
41
src/include/lwip/apps/mdns_opts.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* File: mdns_opts.h
|
||||
* Author: dziegel
|
||||
*
|
||||
* Created on 13. August 2016, 09:17
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
#define LWIP_HDR_APPS_MDNS_OPTS_H
|
||||
/**
|
||||
* @defgroup mdns_opts Options
|
||||
* @ingroup mdns
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_MDNS==1: Turn on multicast DNS module. UDP must be available for MDNS
|
||||
* transport. IGMP is needed for IPv4 multicast.
|
||||
*/
|
||||
#ifndef LWIP_MDNS
|
||||
#define LWIP_MDNS 0
|
||||
#endif /* LWIP_MDNS */
|
||||
|
||||
/** The maximum number of services per netif */
|
||||
#ifndef MDNS_MAX_SERVICES
|
||||
#define MDNS_MAX_SERVICES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MDNS_DEBUG: Enable debugging for multicast DNS.
|
||||
*/
|
||||
#ifndef MDNS_DEBUG
|
||||
#define MDNS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#define LWIP_HDR_NETIF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/mdns_opts.h"
|
||||
|
||||
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
|
||||
|
||||
@@ -58,6 +59,9 @@ struct autoip;
|
||||
#if LWIP_IPV6_DHCP6
|
||||
struct dhcp6;
|
||||
#endif /* LWIP_IPV6_DHCP6 */
|
||||
#if LWIP_MDNS
|
||||
struct mdns_host;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -255,6 +259,10 @@ struct netif {
|
||||
/** the AutoIP client state information for this netif */
|
||||
struct autoip *autoip;
|
||||
#endif
|
||||
#if LWIP_MDNS
|
||||
/** Interface-specific info for multicast DNS */
|
||||
struct mdns_host *mdns;
|
||||
#endif /* LWIP_MDNS */
|
||||
#if LWIP_IPV6_AUTOCONFIG
|
||||
/** is this netif enabled for IPv6 autoconfiguration */
|
||||
u8_t ip6_autoconfig_enabled;
|
||||
|
||||
@@ -69,12 +69,15 @@ extern "C" {
|
||||
#define DNS_RRTYPE_MX 15 /* mail exchange */
|
||||
#define DNS_RRTYPE_TXT 16 /* text strings */
|
||||
#define DNS_RRTYPE_AAAA 28 /* IPv6 address */
|
||||
#define DNS_RRTYPE_SRV 33 /* service location */
|
||||
#define DNS_RRTYPE_ANY 255 /* any type */
|
||||
|
||||
/* DNS field CLASS used for "Resource Records" */
|
||||
#define DNS_RRCLASS_IN 1 /* the Internet */
|
||||
#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
|
||||
#define DNS_RRCLASS_CH 3 /* the CHAOS class */
|
||||
#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
|
||||
#define DNS_RRCLASS_ANY 255 /* any class */
|
||||
#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
|
||||
|
||||
/* DNS protocol flags */
|
||||
@@ -90,6 +93,8 @@ extern "C" {
|
||||
#define DNS_FLAG2_ERR_NONE 0x00
|
||||
#define DNS_FLAG2_ERR_NAME 0x03
|
||||
|
||||
#define DNS_HDR_GET_OPCODE(hdr) ((((hdr)->flags1) >> 3) & 0xF)
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
@@ -122,5 +127,5 @@ typedef enum {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DNS_H */
|
||||
#endif /* LWIP_HDR_PROT_DNS_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user