Import new (much simpler) resolver code from Hybrid.
[ircu2.10.12-pk.git] / ircd / s_bsd.c
index 5498a0c7154c96669fe58d6521faae9282ab8f15..0d460ba8e5fd4451cd01101cdcd69ae7891c9228 100644 (file)
 #include "version.h"
 
 #include <arpa/inet.h>
-#include <arpa/nameser.h>
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <netdb.h>
-#include <resolv.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -177,13 +175,14 @@ void report_error(const char* text, const char* who, int err)
  * a non-null pointer, otherwise reply will be null.
  * if successful start the connection, otherwise notify opers
  */
-static void connect_dns_callback(void* vptr, struct hostent* hp)
+static void connect_dns_callback(void* vptr, struct DNSReply* hp)
 {
   struct ConfItem* aconf = (struct ConfItem*) vptr;
   assert(aconf);
   aconf->dns_pending = 0;
   if (hp) {
-    memcpy(&aconf->ipnum, hp->h_addr, sizeof(struct in_addr));
+    struct sockaddr_in *sin = (struct sockaddr_in*)&hp->addr;
+    memcpy(&aconf->ipnum, &sin->sin_addr, sizeof(struct in_addr));
     MyFree(hp);
     connect_server(aconf, 0);
   }
@@ -290,7 +289,7 @@ static int connect_inet(struct ConfItem* aconf, struct Client* cptr)
   /*
    * we want a big buffer for server connections
    */
-  if (!os_set_sockbufs(cli_fd(cptr), SERVER_TCP_WINDOW)) {
+  if (!os_set_sockbufs(cli_fd(cptr), feature_int(FEAT_SOCKSENDBUF), feature_int(FEAT_SOCKRECVBUF))) {
     cli_error(cptr) = errno;
     report_error(SETBUFS_ERROR_MSG, cli_name(cptr), errno);
     close(cli_fd(cptr));
@@ -396,6 +395,7 @@ void release_dns_reply(struct Client* cptr)
   assert(MyConnect(cptr));
 
   if (cli_dns_reply(cptr)) {
+    MyFree(cli_dns_reply(cptr)->h_name);
     MyFree(cli_dns_reply(cptr));
     cli_dns_reply(cptr) = 0;
   }
@@ -983,7 +983,7 @@ static void client_sock_callback(struct Event* ev)
   assert(0 != ev_socket(ev));
   assert(0 != s_data(ev_socket(ev)));
 
-  con = s_data(ev_socket(ev));
+  con = (struct Connection*) s_data(ev_socket(ev));
 
   assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);
 
@@ -1071,7 +1071,7 @@ static void client_timer_callback(struct Event* ev)
   assert(0 != t_data(ev_timer(ev)));
   assert(ET_DESTROY == ev_type(ev) || ET_EXPIRE == ev_type(ev));
 
-  con = t_data(ev_timer(ev));
+  con = (struct Connection*) t_data(ev_timer(ev));
 
   assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);