++ New features:
2007-11-16 Simon Goldschmidt
- * api.h, api_msg.h, api_lib.c, api_msg.c: Added sequential dns resolver
- function for netconn api (netconn_gethostbyname).
+ * api.h, api_msg.h, api_lib.c, api_msg.c, socket.h, socket.c: Added sequential
+ dns resolver function for netconn api (netconn_gethostbyname) and socket api
+ (gethostbyname).
2007-11-15 Jim Pettinato, Frédéric Bernon
* opt.h, init.c, tcpip.c, dhcp.c, dns.h, dns.c: add DNS client for simple name
static void lwip_getsockopt_internal(void *arg);
static void lwip_setsockopt_internal(void *arg);
+#if LWIP_DNS
+static struct hostent s_hostent;
+static char *s_aliases;
+static struct ip_addr s_hostent_addr;
+static struct ip_addr *s_phostent_addr;
+#endif /* LWIP_DNS */
+
static const int err_to_errno_table[] = {
0, /* ERR_OK 0 No error, everything OK. */
ENOMEM, /* ERR_MEM -1 Out of memory error. */
} /* switch (cmd) */
}
+#if LWIP_DNS
+static void
+lwip_fill_hostent(struct hostent *he, char *name, struct ip_addr **addr, char **aliases)
+{
+ he->h_name = name;
+ he->h_aliases = aliases;
+ he->h_addrtype = AF_INET;
+ he->h_length = sizeof(struct ip_addr);
+ he->h_addr_list = (char**)addr;
+}
+
+
+struct hostent*
+gethostbyname(const char *name)
+{
+ err_t err;
+ struct ip_addr addr;
+
+ err = netconn_gethostbyname(name, &addr);
+ if (err != ERR_OK) {
+ return NULL;
+ }
+
+ s_hostent_addr = addr;
+ s_phostent_addr = &s_hostent_addr;
+ s_hostent.h_name = (char*)name;
+ s_hostent.h_aliases = &s_aliases;
+ s_hostent.h_addrtype = AF_INET;
+ s_hostent.h_length = sizeof(struct ip_addr);
+ s_hostent.h_addr_list = (char**)&s_phostent_addr;
+
+ return &s_hostent;
+}
+#endif /* LWIP_DNS*/
+
#endif /* LWIP_SOCKET */
char sa_data[14];
};
+#if LWIP_DNS
+struct hostent {
+ char *h_name; /* Official name of the host. */
+ char **h_aliases; /* A pointer to an array of pointers to alternative host names,
+ terminated by a null pointer. */
+ int h_addrtype; /* Address type. */
+ int h_length; /* The length, in bytes, of the address. */
+ char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
+ network byte order) for the host, terminated by a null pointer. */
+#define h_addr h_addr_list[0] /* for backward compatibility */
+};
+#endif /* LWIP_DNS */
+
#ifndef socklen_t
# define socklen_t u32_t
#endif
struct timeval *timeout);
int lwip_ioctl(int s, long cmd, void *argp);
+#if LWIP_DNS
+struct hostent *gethostbyname(const char *name);
+#endif /* LWIP_DNS */
+
#if LWIP_COMPAT_SOCKETS
#define accept(a,b,c) lwip_accept(a,b,c)
#define bind(a,b,c) lwip_bind(a,b,c)