Changeset 250


Ignore:
Timestamp:
Sep 22, 2009, 9:22:14 PM (15 years ago)
Author:
katerina
Message:

Proper reporting for udp6 sockets (ticket #168).

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r248 r250  
    22        * remove stale file record when creating handle, and raise diagnostic
    33          error to find origin of stale record
     4        * sh_port2proc.c: check /proc/net/upd6 for IPv6-only UDP sockets
    45
    562.5.9a:
  • trunk/src/sh_port2proc.c

    r244 r250  
    320320/* returns the command and fills the 'user' array
    321321 */
    322 char * sh_port2proc_query(int proto, struct in_addr * saddr, int sport, unsigned long * pid,
    323                           char * user, size_t userlen)
     322static char * port2proc_query(char * file, int proto, struct in_addr * saddr, int sport,
     323                              unsigned long * pid, char * user, size_t userlen)
    324324{
    325325  FILE * fd;
    326326
    327   if (proto == IPPROTO_TCP)
    328     fd = fopen("/proc/net/tcp", "r");
    329   else
    330     fd = fopen("/proc/net/udp", "r");
     327  fd = fopen(file, "r");
    331328
    332329  *pid = 0;
     
    377374  sl_strlcpy(user, "-", userlen);
    378375  return sh_util_strdup("-");
     376}
     377
     378/* returns the command and fills the 'user' array
     379 */
     380char * sh_port2proc_query(int proto, struct in_addr * saddr, int sport,
     381                          unsigned long * pid, char * user, size_t userlen)
     382{
     383  char file[32];
     384
     385  if (proto == IPPROTO_TCP)
     386    {
     387      sl_strlcpy(file, _("/proc/net/tcp"), sizeof(file));
     388      return port2proc_query(file, proto, saddr, sport, pid, user, userlen);
     389    }
     390  else
     391    {
     392      char * ret;
     393      sl_strlcpy(file, _("/proc/net/udp"), sizeof(file));
     394      ret = port2proc_query(file, proto, saddr, sport, pid, user, userlen);
     395      if (ret[0] == '-' && ret[1] == '\0')
     396        {
     397          SH_FREE(ret);
     398          sl_strlcpy(file, _("/proc/net/udp6"), sizeof(file));
     399          ret = port2proc_query(file, proto, saddr, sport, pid, user, userlen);
     400        }
     401      return ret;
     402    }
    379403}
    380404
Note: See TracChangeset for help on using the changeset viewer.