From owner-svn-src-stable@freebsd.org Sat Apr 7 21:03:48 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27A85F854A1; Sat, 7 Apr 2018 21:03:48 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C43CF7535B; Sat, 7 Apr 2018 21:03:47 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB9D22607F; Sat, 7 Apr 2018 21:03:47 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37L3lcX009240; Sat, 7 Apr 2018 21:03:47 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37L3l3N009233; Sat, 7 Apr 2018 21:03:47 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201804072103.w37L3l3N009233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sat, 7 Apr 2018 21:03:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332247 - stable/11/lib/libsysdecode X-SVN-Group: stable-11 X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: stable/11/lib/libsysdecode X-SVN-Commit-Revision: 332247 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 21:03:48 -0000 Author: tuexen Date: Sat Apr 7 21:03:46 2018 New Revision: 332247 URL: https://svnweb.freebsd.org/changeset/base/332247 Log: MFC r327995: Add support for decoding the type of a cmsg. Added: stable/11/lib/libsysdecode/sysdecode_cmsg_type.3 - copied unchanged from r327995, head/lib/libsysdecode/sysdecode_cmsg_type.3 Modified: stable/11/lib/libsysdecode/Makefile stable/11/lib/libsysdecode/flags.c stable/11/lib/libsysdecode/mktables stable/11/lib/libsysdecode/sysdecode.3 stable/11/lib/libsysdecode/sysdecode.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libsysdecode/Makefile ============================================================================== --- stable/11/lib/libsysdecode/Makefile Sat Apr 7 21:02:42 2018 (r332246) +++ stable/11/lib/libsysdecode/Makefile Sat Apr 7 21:03:46 2018 (r332247) @@ -15,6 +15,7 @@ CFLAGS+= -I${SRCTOP}/libexec/rtld-elf MAN= sysdecode.3 \ sysdecode_abi_to_freebsd_errno.3 \ sysdecode_cap_rights.3 \ + sysdecode_cmsg_type.3 \ sysdecode_enum.3 \ sysdecode_fcntl_arg.3 \ sysdecode_kevent.3 \ Modified: stable/11/lib/libsysdecode/flags.c ============================================================================== --- stable/11/lib/libsysdecode/flags.c Sat Apr 7 21:02:42 2018 (r332246) +++ stable/11/lib/libsysdecode/flags.c Sat Apr 7 21:03:46 2018 (r332247) @@ -1157,6 +1157,46 @@ sysdecode_cap_rights(FILE *fp, cap_rights_t *rightsp) } } +static struct name_table cmsgtypeip[] = { + X(IP_RECVDSTADDR) X(IP_RECVTTL) X(IP_RECVOPTS) X(IP_RECVRETOPTS) + X(IP_RECVIF) X(IP_RECVTOS) X(IP_FLOWID) X(IP_FLOWTYPE) + X(IP_RSSBUCKETID) XEND +}; + +static struct name_table cmsgtypeipv6[] = { +#if 0 + /* The RFC 2292 defines are kernel space only. */ + X(IPV6_2292PKTINFO) X(IPV6_2292HOPLIMIT) X(IPV6_2292HOPOPTS) + X(IPV6_2292DSTOPTS) X(IPV6_2292RTHDR) X(IPV6_2292NEXTHOP) +#endif + X(IPV6_PKTINFO) X(IPV6_HOPLIMIT) X(IPV6_HOPOPTS) + X(IPV6_DSTOPTS) X(IPV6_RTHDR) X(IPV6_NEXTHOP) + X(IPV6_TCLASS) X(IPV6_FLOWID) X(IPV6_FLOWTYPE) X(IPV6_RSSBUCKETID) + X(IPV6_PATHMTU) X(IPV6_RTHDRDSTOPTS) X(IPV6_USE_MIN_MTU) + X(IPV6_DONTFRAG) X(IPV6_PREFER_TEMPADDR) XEND +}; + +static struct name_table cmsgtypesctp[] = { + X(SCTP_INIT) X(SCTP_SNDRCV) X(SCTP_EXTRCV) X(SCTP_SNDINFO) + X(SCTP_RCVINFO) X(SCTP_NXTINFO) X(SCTP_PRINFO) X(SCTP_AUTHINFO) + X(SCTP_DSTADDRV4) X(SCTP_DSTADDRV6) XEND +}; + +const char * +sysdecode_cmsg_type(int cmsg_level, int cmsg_type) +{ + + if (cmsg_level == SOL_SOCKET) + return (lookup_value(cmsgtypesocket, cmsg_type)); + if (cmsg_level == IPPROTO_IP) + return (lookup_value(cmsgtypeip, cmsg_type)); + if (cmsg_level == IPPROTO_IPV6) + return (lookup_value(cmsgtypeipv6, cmsg_type)); + if (cmsg_level == IPPROTO_SCTP) + return (lookup_value(cmsgtypesctp, cmsg_type)); + return (NULL); +} + const char * sysdecode_sctp_pr_policy(int policy) { Modified: stable/11/lib/libsysdecode/mktables ============================================================================== --- stable/11/lib/libsysdecode/mktables Sat Apr 7 21:02:42 2018 (r332246) +++ stable/11/lib/libsysdecode/mktables Sat Apr 7 21:03:46 2018 (r332247) @@ -158,6 +158,7 @@ gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]] gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h" gen_table "caprights" "CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)" "sys/capsicum.h" gen_table "sctpprpolicy" "SCTP_PR_SCTP_[A-Z_]+[[:space:]]+0x[0-9]+" "netinet/sctp_uio.h" "SCTP_PR_SCTP_ALL" +gen_table "cmsgtypesocket" "SCM_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/socket.h" if [ -e "${include_dir}/x86/sysarch.h" ]; then gen_table "sysarchnum" "(AMD64|I386)_[A-Z86_]+[[:space:]]+[0-9]+" "x86/sysarch.h" else Modified: stable/11/lib/libsysdecode/sysdecode.3 ============================================================================== --- stable/11/lib/libsysdecode/sysdecode.3 Sat Apr 7 21:02:42 2018 (r332246) +++ stable/11/lib/libsysdecode/sysdecode.3 Sat Apr 7 21:03:46 2018 (r332247) @@ -70,6 +70,7 @@ A placeholder for use when the ABI is not known. .Sh SEE ALSO .Xr sysdecode_abi_to_freebsd_errno 3 , .Xr sysdecode_cap_rights 3 , +.Xr sysdecode_cmsg_type 3 , .Xr sysdecode_enum 3 , .Xr sysdecode_fcntl_arg 3 , .Xr sysdecode_ioctlname 3 , Modified: stable/11/lib/libsysdecode/sysdecode.h ============================================================================== --- stable/11/lib/libsysdecode/sysdecode.h Sat Apr 7 21:02:42 2018 (r332246) +++ stable/11/lib/libsysdecode/sysdecode.h Sat Apr 7 21:03:46 2018 (r332247) @@ -45,6 +45,7 @@ const char *sysdecode_atfd(int _fd); bool sysdecode_atflags(FILE *_fp, int _flags, int *_rem); bool sysdecode_cap_fcntlrights(FILE *_fp, uint32_t _rights, uint32_t *_rem); void sysdecode_cap_rights(FILE *_fp, cap_rights_t *_rightsp); +const char *sysdecode_cmsg_type(int _cmsg_level, int _cmsg_type); const char *sysdecode_extattrnamespace(int _namespace); const char *sysdecode_fadvice(int _advice); void sysdecode_fcntl_arg(FILE *_fp, int _cmd, uintptr_t _arg, int _base); Copied: stable/11/lib/libsysdecode/sysdecode_cmsg_type.3 (from r327995, head/lib/libsysdecode/sysdecode_cmsg_type.3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/lib/libsysdecode/sysdecode_cmsg_type.3 Sat Apr 7 21:03:46 2018 (r332247, copy of r327995, head/lib/libsysdecode/sysdecode_cmsg_type.3) @@ -0,0 +1,54 @@ +.\" +.\" Copyright (c) 2018 Michael Tuexen +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 15, 2018 +.Dt sysdecode_cmsg_type 3 +.Os +.Sh NAME +.Nm sysdecode_cmsg_type +.Nd lookup name of cmsg type +.Sh LIBRARY +.Lb libsysdecode +.Sh SYNOPSIS +.In sys/types.h +.In stdbool.h +.In sysdecode.h +.Ft const char * +.Fn sysdecode_cmsg_type "int cmsg_level" "int cmsg_type" +.Sh DESCRIPTION +The +.Fn sysdecode_cmsg_type +function returns a text description of the +.Fa cmsg_type +member of a +.Vt struct cmsghdr . +.Fn sysdecode_cmsg_type +also takes the +.Fa cmsg_level +to uniquely identify the type. +.Sh SEE ALSO +.Xr sysdecode 3