mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-17 05:36:46 +08:00
Let netdb use a memp pool for allocating memory when getaddrinfo() is called.
This commit is contained in:
@@ -66,6 +66,13 @@
|
||||
#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
|
||||
#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
|
||||
|
||||
/* The size used for the next line is rather a hack, but it prevents including socket.h in all files
|
||||
that include memp.h, and that would possibly break portability (since socket.h defines some types
|
||||
and constants possibly already define by the OS).
|
||||
Calculation rule:
|
||||
sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
|
||||
#define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
|
||||
|
||||
/** Callback which is invoked when a hostname is found.
|
||||
* A function of this type must be implemented by the application using the DNS resolver.
|
||||
* @param name pointer to the name that was looked up.
|
||||
@@ -75,15 +82,10 @@
|
||||
*/
|
||||
typedef void (*dns_found_callback)(const char *name, struct ip_addr *ipaddr, void *callback_arg);
|
||||
|
||||
|
||||
void dns_init(void);
|
||||
|
||||
void dns_tmr(void);
|
||||
|
||||
void dns_setserver(u8_t numdns, struct ip_addr *dnsserver);
|
||||
|
||||
struct ip_addr dns_getserver(u8_t numdns);
|
||||
|
||||
err_t dns_gethostbyname(const char *hostname, struct ip_addr *addr,
|
||||
dns_found_callback found, void *callback_arg);
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_no
|
||||
LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND")
|
||||
LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE")
|
||||
#endif /* LWIP_SNMP */
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
|
||||
/*
|
||||
* A list of pools of pbuf's used by LWIP.
|
||||
|
||||
@@ -362,6 +362,14 @@
|
||||
#define MEMP_NUM_SNMP_VALUE 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls
|
||||
* (before freeing the corresponding memory using lwip_freeaddrinfo()).
|
||||
*/
|
||||
#ifndef MEMP_NUM_NETDB
|
||||
#define MEMP_NUM_NETDB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user