Add support for decoding the type of a cmsg.
This commit is contained in:
parent
c1f0d826d6
commit
a826eb5a41
@ -15,6 +15,7 @@ CFLAGS+= -I${SRCTOP}/libexec/rtld-elf
|
|||||||
MAN= sysdecode.3 \
|
MAN= sysdecode.3 \
|
||||||
sysdecode_abi_to_freebsd_errno.3 \
|
sysdecode_abi_to_freebsd_errno.3 \
|
||||||
sysdecode_cap_rights.3 \
|
sysdecode_cap_rights.3 \
|
||||||
|
sysdecode_cmsg_type.3 \
|
||||||
sysdecode_enum.3 \
|
sysdecode_enum.3 \
|
||||||
sysdecode_fcntl_arg.3 \
|
sysdecode_fcntl_arg.3 \
|
||||||
sysdecode_kevent.3 \
|
sysdecode_kevent.3 \
|
||||||
|
@ -1159,6 +1159,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 *
|
const char *
|
||||||
sysdecode_sctp_pr_policy(int policy)
|
sysdecode_sctp_pr_policy(int policy)
|
||||||
{
|
{
|
||||||
|
@ -158,6 +158,7 @@ gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/
|
|||||||
gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h"
|
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 "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 "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
|
if [ -e "${include_dir}/x86/sysarch.h" ]; then
|
||||||
gen_table "sysarchnum" "(AMD64|I386)_[A-Z86_]+[[:space:]]+[0-9]+" "x86/sysarch.h"
|
gen_table "sysarchnum" "(AMD64|I386)_[A-Z86_]+[[:space:]]+[0-9]+" "x86/sysarch.h"
|
||||||
else
|
else
|
||||||
|
@ -73,6 +73,7 @@ A placeholder for use when the ABI is not known.
|
|||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr sysdecode_abi_to_freebsd_errno 3 ,
|
.Xr sysdecode_abi_to_freebsd_errno 3 ,
|
||||||
.Xr sysdecode_cap_rights 3 ,
|
.Xr sysdecode_cap_rights 3 ,
|
||||||
|
.Xr sysdecode_cmsg_type 3 ,
|
||||||
.Xr sysdecode_enum 3 ,
|
.Xr sysdecode_enum 3 ,
|
||||||
.Xr sysdecode_fcntl_arg 3 ,
|
.Xr sysdecode_fcntl_arg 3 ,
|
||||||
.Xr sysdecode_ioctlname 3 ,
|
.Xr sysdecode_ioctlname 3 ,
|
||||||
|
@ -46,6 +46,7 @@ const char *sysdecode_atfd(int _fd);
|
|||||||
bool sysdecode_atflags(FILE *_fp, int _flags, int *_rem);
|
bool sysdecode_atflags(FILE *_fp, int _flags, int *_rem);
|
||||||
bool sysdecode_cap_fcntlrights(FILE *_fp, uint32_t _rights, uint32_t *_rem);
|
bool sysdecode_cap_fcntlrights(FILE *_fp, uint32_t _rights, uint32_t *_rem);
|
||||||
void sysdecode_cap_rights(FILE *_fp, cap_rights_t *_rightsp);
|
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_extattrnamespace(int _namespace);
|
||||||
const char *sysdecode_fadvice(int _advice);
|
const char *sysdecode_fadvice(int _advice);
|
||||||
void sysdecode_fcntl_arg(FILE *_fp, int _cmd, uintptr_t _arg, int _base);
|
void sysdecode_fcntl_arg(FILE *_fp, int _cmd, uintptr_t _arg, int _base);
|
||||||
|
54
lib/libsysdecode/sysdecode_cmsg_type.3
Normal file
54
lib/libsysdecode/sysdecode_cmsg_type.3
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
.\"
|
||||||
|
.\" Copyright (c) 2018 Michael Tuexen <tuexen@FreeBSD.org>
|
||||||
|
.\" 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
|
Loading…
Reference in New Issue
Block a user