Print this page
4142 truss should expand connect() arguments


  65 #include <sys/iapriocntl.h>
  66 #include <sys/rtpriocntl.h>
  67 #include <sys/fsspriocntl.h>
  68 #include <sys/fxpriocntl.h>
  69 #include <netdb.h>
  70 #include <nss_dbdefs.h>
  71 #include <sys/socketvar.h>
  72 #include <netinet/in.h>
  73 #include <netinet/tcp.h>
  74 #include <netinet/udp.h>
  75 #include <netinet/sctp.h>
  76 #include <net/route.h>
  77 #include <sys/utrap.h>
  78 #include <sys/lgrp_user.h>
  79 #include <sys/door.h>
  80 #include <sys/tsol/tndb.h>
  81 #include <sys/rctl.h>
  82 #include <sys/rctl_impl.h>
  83 #include <sys/fork.h>
  84 #include <sys/task.h>


  85 #include "ramdata.h"
  86 #include "print.h"
  87 #include "proto.h"
  88 #include "systable.h"
  89 
  90 void grow(private_t *, int nbyte);
  91 
  92 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
  93 
  94 
  95 /*ARGSUSED*/
  96 void
  97 prt_nov(private_t *pri, int raw, long val)      /* print nothing */
  98 {
  99 }
 100 
 101 /*ARGSUSED*/
 102 void
 103 prt_dec(private_t *pri, int raw, long val)      /* print as decimal */
 104 {


1769 
1770 
1771 /*
1772  * Print so_socket() 5th argument.
1773  */
1774 /*ARGSUSED*/
1775 void
1776 prt_skv(private_t *pri, int raw, long val)
1777 {
1778         switch (val) {
1779         case SOV_STREAM:        outstring(pri, "SOV_STREAM");   break;
1780         case SOV_DEFAULT:       outstring(pri, "SOV_DEFAULT");  break;
1781         case SOV_SOCKSTREAM:    outstring(pri, "SOV_SOCKSTREAM");       break;
1782         case SOV_SOCKBSD:       outstring(pri, "SOV_SOCKBSD");  break;
1783         case SOV_XPG4_2:        outstring(pri, "SOV_XPG4_2");   break;
1784         default:                prt_dec(pri, 0, val);           break;
1785         }
1786 }
1787 
1788 /*




























































































1789  * Print accept4() flags argument.
1790  */
1791 void
1792 prt_acf(private_t *pri, int raw, long val)
1793 {
1794         int first = 1;
1795         if (raw || !val ||
1796             (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1797                 prt_dex(pri, 0, val);
1798                 return;
1799         }
1800 
1801         if (val & SOCK_CLOEXEC) {
1802                 outstring(pri, "|SOCK_CLOEXEC" + first);
1803                 first = 0;
1804         }
1805         if (val & SOCK_NDELAY) {
1806                 outstring(pri, "|SOCK_NDELAY" + first);
1807                 first = 0;
1808         }


2798         prt_acl,        /* ACL -- print acl() code */
2799         prt_aio,        /* AIO -- print kaio() code */
2800         prt_aud,        /* AUD -- print auditsys() code */
2801         prt_uns,        /* DEC -- print value in unsigned decimal */
2802         prt_clc,        /* CLC -- print cladm command argument */
2803         prt_clf,        /* CLF -- print cladm flag argument */
2804         prt_cor,        /* COR -- print corectl() subcode */
2805         prt_cco,        /* CCO -- print corectl() options */
2806         prt_ccc,        /* CCC -- print corectl() content */
2807         prt_rcc,        /* RCC -- print corectl() returned content */
2808         prt_cpc,        /* CPC -- print cpc() subcode */
2809         prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2810         prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2811         prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2812         prt_pst,        /* PST -- print processor set id */
2813         prt_mif,        /* MIF -- print meminfo() arguments */
2814         prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2815         prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2816         prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2817         prt_skv,        /* SKV -- print socket version arg */

2818         prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2819         prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2820         prt_utt,        /* UTT -- print utrap type */
2821         prt_uth,        /* UTH -- print utrap handler */
2822         prt_acc,        /* ACC -- print access() flags */
2823         prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2824         prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2825         prt_prs,        /* PRS -- print privilege set */
2826         prt_pro,        /* PRO -- print privilege set operation */
2827         prt_prn,        /* PRN -- print privilege set name */
2828         prt_pfl,        /* PFL -- print privilege/process flag name */
2829         prt_laf,        /* LAF -- print lgrp_affinity arguments */
2830         prt_key,        /* KEY -- print key_t 0 as IPC_PRIVATE */
2831         prt_zga,        /* ZGA -- print zone_getattr attribute types */
2832         prt_atc,        /* ATC -- print AT_FDCWD or file descriptor */
2833         prt_lio,        /* LIO -- print LIO_XX flags */
2834         prt_dfl,        /* DFL -- print door_create() flags */
2835         prt_dpm,        /* DPM -- print DOOR_PARAM_XX flags */
2836         prt_tnd,        /* TND -- print trusted network data base opcode */
2837         prt_rsc,        /* RSC -- print rctlsys() subcodes */


  65 #include <sys/iapriocntl.h>
  66 #include <sys/rtpriocntl.h>
  67 #include <sys/fsspriocntl.h>
  68 #include <sys/fxpriocntl.h>
  69 #include <netdb.h>
  70 #include <nss_dbdefs.h>
  71 #include <sys/socketvar.h>
  72 #include <netinet/in.h>
  73 #include <netinet/tcp.h>
  74 #include <netinet/udp.h>
  75 #include <netinet/sctp.h>
  76 #include <net/route.h>
  77 #include <sys/utrap.h>
  78 #include <sys/lgrp_user.h>
  79 #include <sys/door.h>
  80 #include <sys/tsol/tndb.h>
  81 #include <sys/rctl.h>
  82 #include <sys/rctl_impl.h>
  83 #include <sys/fork.h>
  84 #include <sys/task.h>
  85 #include <sys/socket.h>
  86 #include <arpa/inet.h>
  87 #include "ramdata.h"
  88 #include "print.h"
  89 #include "proto.h"
  90 #include "systable.h"
  91 
  92 void grow(private_t *, int nbyte);
  93 
  94 #define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
  95 
  96 
  97 /*ARGSUSED*/
  98 void
  99 prt_nov(private_t *pri, int raw, long val)      /* print nothing */
 100 {
 101 }
 102 
 103 /*ARGSUSED*/
 104 void
 105 prt_dec(private_t *pri, int raw, long val)      /* print as decimal */
 106 {


1771 
1772 
1773 /*
1774  * Print so_socket() 5th argument.
1775  */
1776 /*ARGSUSED*/
1777 void
1778 prt_skv(private_t *pri, int raw, long val)
1779 {
1780         switch (val) {
1781         case SOV_STREAM:        outstring(pri, "SOV_STREAM");   break;
1782         case SOV_DEFAULT:       outstring(pri, "SOV_DEFAULT");  break;
1783         case SOV_SOCKSTREAM:    outstring(pri, "SOV_SOCKSTREAM");       break;
1784         case SOV_SOCKBSD:       outstring(pri, "SOV_SOCKBSD");  break;
1785         case SOV_XPG4_2:        outstring(pri, "SOV_XPG4_2");   break;
1786         default:                prt_dec(pri, 0, val);           break;
1787         }
1788 }
1789 
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 /*
1883  * Print accept4() flags argument.
1884  */
1885 void
1886 prt_acf(private_t *pri, int raw, long val)
1887 {
1888         int first = 1;
1889         if (raw || !val ||
1890             (val & ~(SOCK_CLOEXEC|SOCK_NDELAY|SOCK_NONBLOCK))) {
1891                 prt_dex(pri, 0, val);
1892                 return;
1893         }
1894 
1895         if (val & SOCK_CLOEXEC) {
1896                 outstring(pri, "|SOCK_CLOEXEC" + first);
1897                 first = 0;
1898         }
1899         if (val & SOCK_NDELAY) {
1900                 outstring(pri, "|SOCK_NDELAY" + first);
1901                 first = 0;
1902         }


2892         prt_acl,        /* ACL -- print acl() code */
2893         prt_aio,        /* AIO -- print kaio() code */
2894         prt_aud,        /* AUD -- print auditsys() code */
2895         prt_uns,        /* DEC -- print value in unsigned decimal */
2896         prt_clc,        /* CLC -- print cladm command argument */
2897         prt_clf,        /* CLF -- print cladm flag argument */
2898         prt_cor,        /* COR -- print corectl() subcode */
2899         prt_cco,        /* CCO -- print corectl() options */
2900         prt_ccc,        /* CCC -- print corectl() content */
2901         prt_rcc,        /* RCC -- print corectl() returned content */
2902         prt_cpc,        /* CPC -- print cpc() subcode */
2903         prt_sqc,        /* SQC -- print sigqueue() si_code argument */
2904         prt_pc4,        /* PC4 -- print priocntlsys() (fourth) argument */
2905         prt_pc5,        /* PC5 -- print priocntlsys() (key, value) pairs */
2906         prt_pst,        /* PST -- print processor set id */
2907         prt_mif,        /* MIF -- print meminfo() arguments */
2908         prt_pfm,        /* PFM -- print so_socket() proto-family (1st) arg */
2909         prt_skt,        /* SKT -- print so_socket() socket-type (2nd) arg */
2910         prt_skp,        /* SKP -- print so_socket() protocol (3rd) arg */
2911         prt_skv,        /* SKV -- print socket version arg */
2912         prt_sad,        /* SAD -- print connect 2nd and 3rd arguments */
2913         prt_sol,        /* SOL -- print [sg]etsockopt() level (2nd) arg */
2914         prt_son,        /* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2915         prt_utt,        /* UTT -- print utrap type */
2916         prt_uth,        /* UTH -- print utrap handler */
2917         prt_acc,        /* ACC -- print access() flags */
2918         prt_sht,        /* SHT -- print shutdown() how (2nd) argument */
2919         prt_ffg,        /* FFG -- print fcntl() flags (3rd) argument */
2920         prt_prs,        /* PRS -- print privilege set */
2921         prt_pro,        /* PRO -- print privilege set operation */
2922         prt_prn,        /* PRN -- print privilege set name */
2923         prt_pfl,        /* PFL -- print privilege/process flag name */
2924         prt_laf,        /* LAF -- print lgrp_affinity arguments */
2925         prt_key,        /* KEY -- print key_t 0 as IPC_PRIVATE */
2926         prt_zga,        /* ZGA -- print zone_getattr attribute types */
2927         prt_atc,        /* ATC -- print AT_FDCWD or file descriptor */
2928         prt_lio,        /* LIO -- print LIO_XX flags */
2929         prt_dfl,        /* DFL -- print door_create() flags */
2930         prt_dpm,        /* DPM -- print DOOR_PARAM_XX flags */
2931         prt_tnd,        /* TND -- print trusted network data base opcode */
2932         prt_rsc,        /* RSC -- print rctlsys() subcodes */