ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/s_bsd.c
(Generate patch)

Comparing:
ircd-hybrid-7.2/src/s_bsd.c (file contents), Revision 1013 by michael, Sun Oct 18 14:26:49 2009 UTC vs.
ircd-hybrid-8/src/s_bsd.c (file contents), Revision 1243 by michael, Fri Sep 30 10:47:53 2011 UTC

# Line 30 | Line 30
30   #include "fdlist.h"
31   #include "s_bsd.h"
32   #include "client.h"
33 #include "common.h"
33   #include "dbuf.h"
34   #include "event.h"
35   #include "irc_string.h"
37 #include "irc_getnameinfo.h"
38 #include "irc_getaddrinfo.h"
36   #include "ircd.h"
37   #include "listener.h"
38   #include "numeric.h"
39   #include "packet.h"
40   #include "irc_res.h"
44 #include "inet_misc.h"
41   #include "restart.h"
42   #include "s_auth.h"
43   #include "s_conf.h"
# Line 198 | Line 194 | close_connection(struct Client *client_p
194      send_queued_write(client_p);
195    }
196  
197 <  if (IsServer(client_p))
197 >  if (IsClient(client_p))
198 >  {
199 >    ++ServerStats.is_cl;
200 >    ServerStats.is_cbs += client_p->localClient->send.bytes;
201 >    ServerStats.is_cbr += client_p->localClient->recv.bytes;
202 >    ServerStats.is_cti += CurrentTime - client_p->localClient->firsttime;
203 >  }
204 >  else if (IsServer(client_p))
205    {
206      ++ServerStats.is_sv;
207      ServerStats.is_sbs += client_p->localClient->send.bytes;
208      ServerStats.is_sbr += client_p->localClient->recv.bytes;
209 <    ServerStats.is_sti += CurrentTime - client_p->firsttime;
209 >    ServerStats.is_sti += CurrentTime - client_p->localClient->firsttime;
210  
211      /* XXX Does this even make any sense at all anymore?
212       * scheduling a 'quick' reconnect could cause a pile of
# Line 225 | Line 228 | close_connection(struct Client *client_p
228        aconf  = map_to_conf(conf);
229        aclass = map_to_conf(aconf->class_ptr);
230        aconf->hold = time(NULL);
231 <      aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ?
231 >      aconf->hold += (aconf->hold - client_p->localClient->since > HANGONGOODLINK) ?
232          HANGONRETRYDELAY : ConFreq(aclass);
233      }
234    }
232  else if (IsClient(client_p))
233  {
234    ++ServerStats.is_cl;
235    ServerStats.is_cbs += client_p->localClient->send.bytes;
236    ServerStats.is_cbr += client_p->localClient->recv.bytes;
237    ServerStats.is_cti += CurrentTime - client_p->firsttime;
238  }
235    else
236      ++ServerStats.is_ni;
237  
# Line 307 | Line 303 | ssl_handshake(int fd, struct Client *cli
303   void
304   add_connection(struct Listener *listener, struct irc_ssaddr *irn, int fd)
305   {
306 <  struct Client *new_client;
311 <
312 <  assert(NULL != listener);
313 <
314 <  new_client = make_client(NULL);
306 >  struct Client *new_client = make_client(NULL);
307  
308    fd_open(&new_client->localClient->fd, fd, 1,
309            (listener->flags & LISTENER_SSL) ?
310            "Incoming SSL connection" : "Incoming connection");
311  
312 <  /*
312 >  /*
313     * copy address to 'sockhost' as a string, copy it to host too
314     * so we have something valid to put into error messages...
315     */
316    memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr));
317  
318 <  irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip,
319 <        new_client->localClient->ip.ss_len, new_client->sockhost,
320 <        sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
318 >  getnameinfo((struct sockaddr *)&new_client->localClient->ip,
319 >              new_client->localClient->ip.ss_len, new_client->sockhost,
320 >              sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST);
321    new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family;
330 #ifdef IPV6
331  if (new_client->sockhost[0] == ':')
332    strlcat(new_client->host, "0", HOSTLEN+1);
322  
323 <  if (new_client->localClient->aftype == AF_INET6 &&
335 <      ConfigFileEntry.dot_in_ip6_addr == 1)
323 >  if (new_client->sockhost[0] == ':' && new_client->sockhost[1] == ':')
324    {
325 <    strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
326 <    strlcat(new_client->host, ".", HOSTLEN+1);
325 >    strlcpy(new_client->host, "0", sizeof(new_client->host));
326 >    strlcpy(new_client->host+1, new_client->sockhost, sizeof(new_client->host)-1);
327 >    memmove(new_client->sockhost+1, new_client->sockhost, sizeof(new_client->sockhost)-1);
328 >    new_client->sockhost[0] = '0';
329    }
330    else
331 < #endif
342 <    strlcat(new_client->host, new_client->sockhost,HOSTLEN+1);
331 >    strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host));
332  
333    new_client->localClient->listener = listener;
334    ++listener->ref_count;
# Line 526 | Line 515 | comm_connect_tcp(fde_t *fd, const char *
515  
516    snprintf(portname, sizeof(portname), "%d", port);
517  
518 <  if (irc_getaddrinfo(host, portname, &hints, &res))
518 >  if (getaddrinfo(host, portname, &hints, &res))
519    {
520      /* Send the DNS request, for the next level */
521      if (aftype == AF_INET6)
# Line 542 | Line 531 | comm_connect_tcp(fde_t *fd, const char *
531      memcpy(&fd->connect.hostaddr, res->ai_addr, res->ai_addrlen);
532      fd->connect.hostaddr.ss_len = res->ai_addrlen;
533      fd->connect.hostaddr.ss.ss_family = res->ai_family;
534 <    irc_freeaddrinfo(res);
534 >    freeaddrinfo(res);
535      comm_settimeout(fd, timeout*1000, comm_connect_timeout, NULL);
536      comm_connect_tryconnect(fd, NULL);
537    }
# Line 752 | Line 741 | comm_accept(struct Listener *lptr, struc
741  
742   /*
743   * remove_ipv6_mapping() - Removes IPv4-In-IPv6 mapping from an address
744 < * This function should really inspect the struct itself rather than relying
756 < * on inet_pton and inet_ntop.  OSes with IPv6 mapping listening on both
744 > * OSes with IPv6 mapping listening on both
745   * AF_INET and AF_INET6 map AF_INET connections inside AF_INET6 structures
746   *
747   */
# Line 763 | Line 751 | remove_ipv6_mapping(struct irc_ssaddr *a
751   {
752    if (addr->ss.ss_family == AF_INET6)
753    {
754 <    struct sockaddr_in6 *v6;
767 <
768 <    v6 = (struct sockaddr_in6*)addr;
769 <    if (IN6_IS_ADDR_V4MAPPED(&v6->sin6_addr))
754 >    if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr)->sin6_addr))
755      {
756 <      char v4ip[HOSTIPLEN];
757 <      struct sockaddr_in *v4 = (struct sockaddr_in*)addr;
758 <      inetntop(AF_INET6, &v6->sin6_addr, v4ip, HOSTIPLEN);
759 <      inet_pton(AF_INET, v4ip, &v4->sin_addr);
756 >      struct sockaddr_in6 v6;
757 >      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
758 >
759 >      memcpy(&v6, addr, sizeof(v6));
760 >      memset(v4, 0, sizeof(struct sockaddr_in));
761 >      memcpy(&v4->sin_addr, &v6.sin6_addr.s6_addr[12], sizeof(v4->sin_addr));
762 >
763        addr->ss.ss_family = AF_INET;
764        addr->ss_len = sizeof(struct sockaddr_in);
765      }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)