svn commit: r317732 - head/usr.bin/truss

John Baldwin jhb at freebsd.org
Tue May 16 18:29:16 UTC 2017


On Wednesday, May 03, 2017 09:23:14 AM Michael Tuexen wrote:
> Author: tuexen
> Date: Wed May  3 09:23:13 2017
> New Revision: 317732
> URL: https://svnweb.freebsd.org/changeset/base/317732
> 
> Log:
>   Decode the third argument of socket().

This is not quite right for sockets that aren't PF_INET.  Probably this
warrants a const char *sysdecode_socket_protocol(int domain, int protocol)
that honors the domain in deciding what protocol value to output.  For now
this could just handle PF_INET:

const char *
sysdecode_socket_protocol(int domain, int protocol)
{

    switch (domain) {
        case PF_INET:
            return (lookup_value(sockipproto, protocol));
        default:
            return (NULL));
}

Then use this in truss.

The socket option stuff currently hardcodes IP protocols and levels only
because we don't have a good way of obtaining the domain of an existing
socket in a target process.  For socket()'s protocol argument though we
readily have the domain available.

At some point in the future we might address the socket option issue by
caching the domain argument when sockets are created in a table, and for
truss when attaching to an existing process using the kinfo_file interface to
learn about existing sockets, but that's not entirely trivial.

-- 
John Baldwin


More information about the svn-src-head mailing list