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 +        struct sockaddr_storage buf;
     1802 +
     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[16] = "";
     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, (void*)&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 +                    sprintf(scope, "%%%u", ntohl(sin6->sin6_scope_id));
     1834 +                }
     1835 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1836 +                    " AF_INET6 to = [%s]%s:%u",
     1837 +                    inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
     1838 +                    sizeof (addrbuf)),
     1839 +                    scope, ntohs(sin6->sin6_port));
     1840 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1841 +                    " source id = 0x%x"
     1842 +                    " flow class = 0x%02x flow label = 0x%05x",
     1843 +                    ntohl(sin6->__sin6_src_id),
     1844 +                    ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
     1845 +                    ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
     1846 +                break;
     1847 +        case AF_INET:
     1848 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1849 +                    " AF_INET to = %s:%u",
     1850 +                    inet_ntop(AF_INET, &sin->sin_addr, addrbuf,
     1851 +                    sizeof (addrbuf)),
     1852 +                    ntohs(sin->sin_port));
     1853 +                break;
     1854 +        case AF_UNIX:
     1855 +                rlen -= sizeof (soun->sun_family);
     1856 +                if (rlen >= 0) {
     1857 +                        /* Null terminate */
     1858 +                        soun->sun_path[rlen] = NULL;
     1859 +                        pri->sys_leng += sprintf(
     1860 +                            pri->sys_string + pri->sys_leng,
     1861 +                            " AF_UNIX to = %s", soun->sun_path);
     1862 +                }
     1863 +                break;
     1864 +        }
     1865 +
     1866 +        /*
     1867 +         * print the third argument len
     1868 +         */
     1869 +        if (data_model == PR_MODEL_ILP32) {
     1870 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1871 +                    ", %d", (int)len);
     1872 +        } else {
     1873 +                pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
     1874 +                    ", %ld", len);
     1875 +        }
     1876 +
     1877 +}
     1878 +
     1879 +
     1880 +/*
1789 1881   * Print accept4() flags argument.
1790 1882   */
1791 1883  void
1792 1884  prt_acf(private_t *pri, int raw, long val)
1793 1885  {
1794 1886          int first = 1;
1795 1887          if (raw || !val ||
1796 1888              (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1797 1889                  prt_dex(pri, 0, val);
1798 1890                  return;
↓ open down ↓ 1009 lines elided ↑ open up ↑
2808 2900          prt_cpc,        /* CPC -- print cpc() subcode */
2809 2901          prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2810 2902          prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2811 2903          prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2812 2904          prt_pst,        /* PST -- print processor set id */
2813 2905          prt_mif,        /* MIF -- print meminfo() arguments */
2814 2906          prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2815 2907          prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2816 2908          prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2817 2909          prt_skv,        /* SKV -- print socket version arg */
     2910 +        prt_sad,        /* SAD -- print connect 2nd and 3rd arguments */
2818 2911          prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2819 2912          prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2820 2913          prt_utt,        /* UTT -- print utrap type */
2821 2914          prt_uth,        /* UTH -- print utrap handler */
2822 2915          prt_acc,        /* ACC -- print access() flags */
2823 2916          prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2824 2917          prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2825 2918          prt_prs,        /* PRS -- print privilege set */
2826 2919          prt_pro,        /* PRO -- print privilege set operation */
2827 2920          prt_prn,        /* PRN -- print privilege set name */
↓ open down ↓ 23 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX