summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-04-17 12:41:10 +0000
committerEric Andersen <andersen@codepoet.org>2002-04-17 12:41:10 +0000
commit98832397c2155e6470119ce3e7e32ceaed4eb49f (patch)
tree11bd7ba4b668cf5ed8777643db3cf83a69a328ad /libc/inet/resolv.c
parent8c8fbab31d989ee42b7781d0720291d6443d70d3 (diff)
Patch from Axel Barnitzke <barney@xkontor.com> to add basic
support for struct _res. This is a minimalist implementation, but should work for most anything out there.
Diffstat (limited to 'libc/inet/resolv.c')
-rw-r--r--libc/inet/resolv.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index fa7ba37fe..3fd9b81cd 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1034,11 +1034,77 @@ struct netent * getnetbyname(const char * name)
#ifdef L_res_init
+struct __res_state * __res;
+
+#ifndef _res
+#define _res (*__res_state())
+#endif
int res_init(void)
{
+ struct __res_state *rp = __res;
+ if(!__res) {
+ rp = (struct __res_state *) malloc(sizeof(struct __res_state));
+ memset(rp, 0, sizeof(struct __res_state));
+ __res = rp;
+ }
+
+ (void) open_nameservers();
+ rp->retrans = RES_TIMEOUT;
+ rp->retry = 4;
+ rp->options = RES_INIT;
+ rp->id = (u_int) random();
+ rp->nsaddr.sin_addr.s_addr = INADDR_ANY;
+ rp->nsaddr.sin_family = AF_INET;
+ rp->nsaddr.sin_port = htons(NAMESERVER_PORT);
+ rp->ndots = 1;
+ /** rp->pfcode = 0; **/
+ rp->_vcsock = -1;
+ /** rp->_flags = 0; **/
+ /** rp->qhook = NULL; **/
+ /** rp->rhook = NULL; **/
+ /** rp->_u._ext.nsinit = 0; **/
+
+ if(searchdomains) {
+ int i;
+ for(i=0; i<searchdomains; i++) {
+ rp->dnsrch[i] = searchdomain[i];
+ }
+ }
+
+ if(nameservers) {
+ int i;
+ struct in_addr a;
+ for(i=0; i<nameservers; i++) {
+ if (inet_aton(nameserver[i], &a)) {
+ rp->nsaddr_list[i].sin_addr = a;
+ rp->nsaddr_list[i].sin_family = AF_INET;
+ rp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT);
+ }
+ }
+ }
+ rp->nscount = nameservers;
+
return(0);
}
+
+struct __res_state * __res_state (void)
+{
+ if(!__res) {
+ res_init();
+ }
+ return __res;
+}
+
+void res_close( void )
+{
+ if(__res) {
+ free(__res);
+ __res = NULL;
+ }
+ return;
+}
+
#endif