Changeset 361 for trunk/src/sh_calls.c


Ignore:
Timestamp:
Oct 19, 2011, 12:14:06 AM (13 years ago)
Author:
katerina
Message:

Fix for ticket #268 (Insufficient server-side debugging information for IPv6).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_calls.c

    r317 r361  
    3434#include <signal.h>
    3535#include <sys/socket.h>
     36#include <netdb.h>
    3637#include <netinet/in.h>
    3738
     
    5758#undef  FIL__
    5859#define FIL__  _("sh_calls.c")
     60
     61extern int flag_err_debug;
    5962
    6063char aud_err_message[64];
     
    236239  errno = error;
    237240
     241  if (flag_err_debug == SL_TRUE)
     242    {
     243      char ipbuf[SH_IP_BUF];
     244      char buf[SH_BUFSIZE];
     245#if defined(USE_IPVX)
     246      sl_strlcpy(errbuf, _("Address family: "), sizeof(errbuf));
     247      sl_strlcat(errbuf,
     248                 (ss.ss_family == AF_INET6) ? _("AF_INET6") : _("AF_INET"),
     249                 sizeof(errbuf));
     250      getnameinfo((struct sockaddr *)&ss, my_addrlen,
     251                  ipbuf, sizeof(ipbuf), NULL, 0, NI_NUMERICHOST);
     252#else
     253      struct sockaddr_in sa;
     254      char * p;
     255      memcpy(&(sa), (struct sockaddr_in*)&ss, sizeof(struct sockaddr_in));
     256      p = inet_ntoa(sa.sin_addr);
     257      sl_strlcpy(ipbuf, p, sizeof(ipbuf));
     258      sl_strlcpy(errbuf, _("Address family: AF_INET"), sizeof(errbuf));
     259#endif
     260      sl_strlcpy(buf, _("Address: "), sizeof(buf));
     261      sl_strlcat(buf, ipbuf, sizeof(buf));
     262      sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     263                       errbuf, _("retry_accept"));
     264      sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     265                       buf, _("retry_accept"));
     266    }
     267
    238268  sh_ipvx_save(serv_addr, ss.ss_family, (struct sockaddr *) &ss);
     269
     270  if (flag_err_debug == SL_TRUE)
     271    {
     272      char ipbuf[SH_IP_BUF];
     273      char ipbuf2[SH_IP_BUF];
     274      char buf[SH_BUFSIZE];
     275#if defined(USE_IPVX)
     276      int len = (serv_addr->ss_family == AF_INET) ?
     277        sizeof(struct sockaddr_in) :
     278        sizeof(struct sockaddr_in6);
     279      getnameinfo(sh_ipvx_sockaddr_cast(serv_addr), len,
     280                  ipbuf2, sizeof(ipbuf2), NULL, 0, NI_NUMERICHOST);
     281#else
     282      char * p = inet_ntoa((serv_addr->sin).sin_addr);
     283      sl_strlcpy(ipbuf2, p, sizeof(ipbuf2));
     284#endif
     285      sh_ipvx_ntoa (ipbuf, sizeof(ipbuf), serv_addr);
     286      sl_snprintf(buf, sizeof(buf), _("Address: %s / %s"),
     287                  ipbuf, ipbuf2);
     288      sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     289                       buf, _("retry_accept"));
     290    }
    239291
    240292  *addrlen = (int) my_addrlen;
Note: See TracChangeset for help on using the changeset viewer.