Print this page
4142 truss should expand connect() arguments

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/truss/print.c
          +++ new/usr/src/cmd/truss/print.c
↓ open down ↓ 74 lines elided ↑ open up ↑
  75   75  #include <netinet/sctp.h>
  76   76  #include <net/route.h>
  77   77  #include <sys/utrap.h>
  78   78  #include <sys/lgrp_user.h>
  79   79  #include <sys/door.h>
  80   80  #include <sys/tsol/tndb.h>
  81   81  #include <sys/rctl.h>
  82   82  #include <sys/rctl_impl.h>
  83   83  #include <sys/fork.h>
  84   84  #include <sys/task.h>
       85 +#include <sys/socket.h>
       86 +#include <arpa/inet.h>
  85   87  #include "ramdata.h"
  86   88  #include "print.h"
  87   89  #include "proto.h"
  88   90  #include "systable.h"
  89   91  
  90   92  void grow(private_t *, int nbyte);
  91   93  
  92   94  #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
  93   95  
  94   96  
↓ open down ↓ 1684 lines elided ↑ open up ↑
1779 1781          case SOV_STREAM:        outstring(pri, "SOV_STREAM");   break;
1780 1782          case SOV_DEFAULT:       outstring(pri, "SOV_DEFAULT");  break;
1781 1783          case SOV_SOCKSTREAM:    outstring(pri, "SOV_SOCKSTREAM");       break;
1782 1784          case SOV_SOCKBSD:       outstring(pri, "SOV_SOCKBSD");  break;
1783 1785          case SOV_XPG4_2:        outstring(pri, "SOV_XPG4_2");   break;
1784 1786          default:                prt_dec(pri, 0, val);           break;
1785 1787          }
1786 1788  }
1787 1789  
1788 1790  /*
     1791 + * Print connect() 2nd and 3rd arguments.
     1792 + */
     1793 +/*ARGSUSED*/
     1794 +void
     1795 +prt_sad(private_t *pri, int raw, long addr, long len)
     1796 +{
     1797 +        /*
     1798 +         * A buffer large enough for PATH_MAX size AF_UNIX address, which is
     1799 +         * also large enough to store a sockaddr_in or a sockaddr_in6.
     1800 +         */
     1801 +        long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1) /
     1802 +            sizeof (long)];
     1803 +        struct sockaddr *sa = (struct sockaddr *)buf;
     1804 +        struct sockaddr_in *sin = (struct sockaddr_in *)buf;
     1805 +        struct sockaddr_un *soun = (struct sockaddr_un *)buf;
     1806 +        struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
     1807 +        char addrbuf[INET6_ADDRSTRLEN];
     1808 +        char scope[8];
     1809 +        long rlen = len;
     1810 +
     1811 +        GROW(20);
     1812 +        if (data_model == PR_MODEL_ILP32) {
     1813 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1814 +                    "0x%.8X", (int)addr);
     1815 +        } else {
     1816 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1817 +                    "0x%.8lX", addr);
     1818 +        }
     1819 +
     1820 +        if (raw != 0)
     1821 +                return;
     1822 +
     1823 +        if (rlen >= sizeof (buf))       /* protect against ridiculous length */
     1824 +                rlen = sizeof (buf) - 1;
     1825 +        if (Pread(Proc, buf, rlen, addr) != rlen)
     1826 +                return;
     1827 +
     1828 +        GROW(175);
     1829 +
     1830 +        switch (sa->sa_family) {
     1831 +        case AF_INET6:
     1832 +                if (ntohl(sin6->sin6_scope_id) == 0) {
     1833 +                    scope[0] = '\0';
     1834 +                } else {
     1835 +                    sprintf(scope, "%%%u", ntohl(sin6->sin6_scope_id));
     1836 +                }
     1837 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1838 +                    " AF_INET6 to = %s%s:%u",
     1839 +                    inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
     1840 +                    sizeof (addrbuf)),
     1841 +                    scope, ntohs(sin6->sin6_port));
     1842 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1843 +                    " source id = 0x%x"
     1844 +                    " flow class = 0x%02x flow label = 0x%05x",
     1845 +                    ntohl(sin6->__sin6_src_id),
     1846 +                    ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
     1847 +                    ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
     1848 +                break;
     1849 +        case AF_INET:
     1850 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1851 +                    " AF_INET to = %s:%u",
     1852 +                    inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
     1853 +                    sizeof (addrbuf)),
     1854 +                    ntohs(sin->sin_port));
     1855 +                break;
     1856 +        case AF_UNIX:
     1857 +                len -= sizeof (soun->sun_family);
     1858 +                if (len >= 0) {
     1859 +                        /* Null terminate */
     1860 +                        soun->sun_path[len] = NULL;
     1861 +                        pri->sys_leng += sprintf(
     1862 +                            pri->sys_string + pri->sys_leng,
     1863 +                            " AF_UNIX to = %s", soun->sun_path);
     1864 +                }
     1865 +                break;
     1866 +        }
     1867 +
     1868 +        /*
     1869 +         * print the third argument len
     1870 +         */
     1871 +        if (data_model == PR_MODEL_ILP32) {
     1872 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1873 +                    ", %d", (int)len);
     1874 +        } else {
     1875 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1876 +                    ", %ld", len);
     1877 +        }
     1878 +
     1879 +}
     1880 +
     1881 +
     1882 +/*
1789 1883   * Print accept4() flags argument.
1790 1884   */
1791 1885  void
1792 1886  prt_acf(private_t *pri, int raw, long val)
1793 1887  {
1794 1888          int first = 1;
1795 1889          if (raw || !val ||
1796 1890              (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1797 1891                  prt_dex(pri, 0, val);
1798 1892                  return;
↓ open down ↓ 1009 lines elided ↑ open up ↑
2808 2902          prt_cpc,        /* CPC -- print cpc() subcode */
2809 2903          prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2810 2904          prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2811 2905          prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2812 2906          prt_pst,        /* PST -- print processor set id */
2813 2907          prt_mif,        /* MIF -- print meminfo() arguments */
2814 2908          prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2815 2909          prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2816 2910          prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2817 2911          prt_skv,        /* SKV -- print socket version arg */
     2912 +        prt_sad,        /* SAD -- print connect 2nd and 3rd arguments */
2818 2913          prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2819 2914          prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2820 2915          prt_utt,        /* UTT -- print utrap type */
2821 2916          prt_uth,        /* UTH -- print utrap handler */
2822 2917          prt_acc,        /* ACC -- print access() flags */
2823 2918          prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2824 2919          prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2825 2920          prt_prs,        /* PRS -- print privilege set */
2826 2921          prt_pro,        /* PRO -- print privilege set operation */
2827 2922          prt_prn,        /* PRN -- print privilege set name */
↓ open down ↓ 23 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX