Print this page
4142 truss should expand connect() arguments


3468                     ubuf.version,
3469                     ubuf.machine);
3470         }
3471 }
3472 
3473 void
3474 show_adjtime(private_t *pri, long off1, long off2)
3475 {
3476         show_timeval(pri, off1, "   delta");
3477         show_timeval(pri, off2, "olddelta");
3478 }
3479 
3480 void
3481 show_sockaddr(private_t *pri,
3482         const char *str, long addroff, long lenoff, long len)
3483 {
3484         /*
3485          * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3486          * also large enough to store a sockaddr_in or a sockaddr_in6.
3487          */
3488         long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
3489             / sizeof (long)];
3490         struct sockaddr *sa = (struct sockaddr *)buf;
3491         struct sockaddr_in *sin = (struct sockaddr_in *)buf;
3492         struct sockaddr_un *soun = (struct sockaddr_un *)buf;
3493         struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)buf;
3494         char addrbuf[INET6_ADDRSTRLEN];
3495 
3496         if (lenoff != 0) {
3497                 uint_t ilen;
3498                 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3499                         return;
3500                 len = ilen;
3501         }
3502 
3503         if (len >= sizeof (buf))     /* protect against ridiculous length */
3504                 len = sizeof (buf) - 1;
3505         if (Pread(Proc, buf, len, addroff) != len)
3506                 return;
3507 
3508         switch (sa->sa_family) {
3509         case AF_INET6:
3510                 (void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
3511                     pri->pname, str,
3512                     inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3513                     sizeof (addrbuf)),
3514                     ntohs(sin6->sin6_port));
3515                 (void) printf("%s\tscope id = %u  source id = 0x%x\n"
3516                     "%s\tflow class = 0x%02x  flow label = 0x%05x\n",
3517                     pri->pname, ntohl(sin6->sin6_scope_id),
3518                     ntohl(sin6->__sin6_src_id),
3519                     pri->pname,
3520                     ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3521                     ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3522                 break;
3523         case AF_INET:
3524                 (void) printf("%s\tAF_%s  %s = %s  port = %u\n",
3525                     pri->pname, "INET",




3468                     ubuf.version,
3469                     ubuf.machine);
3470         }
3471 }
3472 
3473 void
3474 show_adjtime(private_t *pri, long off1, long off2)
3475 {
3476         show_timeval(pri, off1, "   delta");
3477         show_timeval(pri, off2, "olddelta");
3478 }
3479 
3480 void
3481 show_sockaddr(private_t *pri,
3482         const char *str, long addroff, long lenoff, long len)
3483 {
3484         /*
3485          * A buffer large enough for PATH_MAX size AF_UNIX address, which is
3486          * also large enough to store a sockaddr_in or a sockaddr_in6.
3487          */
3488         struct sockaddr_storage buf;
3489 
3490         struct sockaddr *sa = (struct sockaddr *)&buf;
3491         struct sockaddr_in *sin = (struct sockaddr_in *)&buf;
3492         struct sockaddr_un *soun = (struct sockaddr_un *)&buf;
3493         struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&buf;
3494         char addrbuf[INET6_ADDRSTRLEN];
3495 
3496         if (lenoff != 0) {
3497                 uint_t ilen;
3498                 if (Pread(Proc, &ilen, sizeof (ilen), lenoff) != sizeof (ilen))
3499                         return;
3500                 len = ilen;
3501         }
3502 
3503         if (len >= sizeof (buf))     /* protect against ridiculous length */
3504                 len = sizeof (buf) - 1;
3505         if (Pread(Proc, (void*)&buf, len, addroff) != len)
3506                 return;
3507 
3508         switch (sa->sa_family) {
3509         case AF_INET6:
3510                 (void) printf("%s\tAF_INET6  %s = %s  port = %u\n",
3511                     pri->pname, str,
3512                     inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf,
3513                     sizeof (addrbuf)),
3514                     ntohs(sin6->sin6_port));
3515                 (void) printf("%s\tscope id = %u  source id = 0x%x\n"
3516                     "%s\tflow class = 0x%02x  flow label = 0x%05x\n",
3517                     pri->pname, ntohl(sin6->sin6_scope_id),
3518                     ntohl(sin6->__sin6_src_id),
3519                     pri->pname,
3520                     ntohl((sin6->sin6_flowinfo & IPV6_FLOWINFO_TCLASS) >> 20),
3521                     ntohl(sin6->sin6_flowinfo & IPV6_FLOWINFO_FLOWLABEL));
3522                 break;
3523         case AF_INET:
3524                 (void) printf("%s\tAF_%s  %s = %s  port = %u\n",
3525                     pri->pname, "INET",