mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-06 00:39:59 +00:00
netdb.c: add a LWIP_DNS_API_HOSTENT_STORAGE option to decide to use a static set of variables (=0) or a local one (=1). In this last case, your port should provide a function "struct hostent* sys_thread_hostent( struct hostent* h)" which have to do a copy of "h" and return a pointer ont the "per-thread" copy.
This commit is contained in:
parent
8d3d08e814
commit
ac10470643
@ -19,6 +19,12 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-12-05 Frédéric Bernon
|
||||||
|
* netdb.c: add a LWIP_DNS_API_HOSTENT_STORAGE option to decide to use a static
|
||||||
|
set of variables (=0) or a local one (=1). In this last case, your port should
|
||||||
|
provide a function "struct hostent* sys_thread_hostent( struct hostent* h)"
|
||||||
|
which have to do a copy of "h" and return a pointer ont the "per-thread" copy.
|
||||||
|
|
||||||
2007-12-03 Simon Goldschmidt
|
2007-12-03 Simon Goldschmidt
|
||||||
* ip.c: ip_input: check if a packet is for inp first before checking all other
|
* ip.c: ip_input: check if a packet is for inp first before checking all other
|
||||||
netifs on netif_list (speeds up packet receiving in most cases)
|
netifs on netif_list (speeds up packet receiving in most cases)
|
||||||
|
@ -54,11 +54,18 @@ struct gethostbyname_r_helper {
|
|||||||
int h_errno;
|
int h_errno;
|
||||||
#endif /* LWIP_DNS_API_DECLARE_H_ERRNO */
|
#endif /* LWIP_DNS_API_DECLARE_H_ERRNO */
|
||||||
|
|
||||||
/* static buffer variables for lwip_gethostbyname() */
|
/** define "hostent" variables storage: 0 if we use a static (but unprotected)
|
||||||
static struct hostent s_hostent;
|
* set of variables for lwip_gethostbyname, 1 if we use a local storage */
|
||||||
static char *s_aliases;
|
#ifndef LWIP_DNS_API_HOSTENT_STORAGE
|
||||||
static struct ip_addr s_hostent_addr;
|
#define LWIP_DNS_API_HOSTENT_STORAGE 0
|
||||||
static struct ip_addr *s_phostent_addr;
|
#endif
|
||||||
|
|
||||||
|
/** define "hostent" variables storage */
|
||||||
|
#if LWIP_DNS_API_HOSTENT_STORAGE
|
||||||
|
#define HOSTENT_STORAGE
|
||||||
|
#else
|
||||||
|
#define HOSTENT_STORAGE static
|
||||||
|
#endif /* LWIP_DNS_API_STATIC_HOSTENT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an entry containing addresses of address family AF_INET
|
* Returns an entry containing addresses of address family AF_INET
|
||||||
@ -75,6 +82,12 @@ lwip_gethostbyname(const char *name)
|
|||||||
err_t err;
|
err_t err;
|
||||||
struct ip_addr addr;
|
struct ip_addr addr;
|
||||||
|
|
||||||
|
/* buffer variables for lwip_gethostbyname() */
|
||||||
|
HOSTENT_STORAGE struct hostent s_hostent;
|
||||||
|
HOSTENT_STORAGE char *s_aliases;
|
||||||
|
HOSTENT_STORAGE struct ip_addr s_hostent_addr;
|
||||||
|
HOSTENT_STORAGE struct ip_addr *s_phostent_addr;
|
||||||
|
|
||||||
/* query host IP address */
|
/* query host IP address */
|
||||||
err = netconn_gethostbyname(name, &addr);
|
err = netconn_gethostbyname(name, &addr);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
@ -115,7 +128,12 @@ lwip_gethostbyname(const char *name)
|
|||||||
}
|
}
|
||||||
#endif /* DNS_DEBUG */
|
#endif /* DNS_DEBUG */
|
||||||
|
|
||||||
|
#if LWIP_DNS_API_HOSTENT_STORAGE
|
||||||
|
/* this function should return the "per-thread" hostent after copy from s_hostent */
|
||||||
|
return sys_thread_hostent(&s_hostent);
|
||||||
|
#else
|
||||||
return &s_hostent;
|
return &s_hostent;
|
||||||
|
#endif /* LWIP_DNS_API_HOSTENT_STORAGE */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user