diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile index 300af94a51b1..a070307b4f11 100644 --- a/lib/libsysdecode/Makefile +++ b/lib/libsysdecode/Makefile @@ -21,6 +21,7 @@ MAN= sysdecode.3 \ sysdecode_ioctlname.3 \ sysdecode_mask.3 \ sysdecode_quotactl_cmd.3 \ + sysdecode_sctp_sinfo_flags.3 \ sysdecode_sigcode.3 \ sysdecode_sockopt_name.3 \ sysdecode_socket_protocol.3 \ diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c index b1a576ff6807..55589b55bd1f 100644 --- a/lib/libsysdecode/flags.c +++ b/lib/libsysdecode/flags.c @@ -1165,3 +1165,31 @@ sysdecode_sctp_pr_policy(int policy) return (lookup_value(sctpprpolicy, policy)); } + +static struct name_table sctpsinfoflags[] = { + X(SCTP_EOF) X(SCTP_ABORT) X(SCTP_UNORDERED) X(SCTP_ADDR_OVER) + X(SCTP_SENDALL) X(SCTP_EOR) X(SCTP_SACK_IMMEDIATELY) XEND +}; + +void +sysdecode_sctp_sinfo_flags(FILE *fp, int sinfo_flags) +{ + const char *temp; + int rem; + bool printed; + + printed = print_mask_0(fp, sctpsinfoflags, sinfo_flags, &rem); + if (rem & ~SCTP_PR_SCTP_ALL) { + fprintf(fp, "%s%#x", printed ? "|" : "", rem & ~SCTP_PR_SCTP_ALL); + printed = true; + rem &= ~SCTP_PR_SCTP_ALL; + } + if (rem != 0) { + temp = sysdecode_sctp_pr_policy(rem); + if (temp != NULL) { + fprintf(fp, "%s%s", printed ? "|" : "", temp); + } else { + fprintf(fp, "%s%#x", printed ? "|" : "", rem); + } + } +} diff --git a/lib/libsysdecode/sysdecode.3 b/lib/libsysdecode/sysdecode.3 index c0278137930c..8773b41dee43 100644 --- a/lib/libsysdecode/sysdecode.3 +++ b/lib/libsysdecode/sysdecode.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 16, 2017 +.Dd January 14, 2018 .Dt SYSDECODE 3 .Os .Sh NAME @@ -79,6 +79,7 @@ A placeholder for use when the ABI is not known. .Xr sysdecode_kevent 3 , .Xr sysdecode_mask 3 , .Xr sysdecode_quotactl_cmd 3 , +.Xr sysdecode_sctp_sinfo_flags 3 , .Xr sysdecode_sigcode 3 , .Xr sysdecode_socket_protocol 3 , .Xr sysdecode_sockopt_name 3 , diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h index 999c71893dcf..413b4f1afa41 100644 --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -91,6 +91,7 @@ const char *sysdecode_rlimit(int _resource); const char *sysdecode_rtprio_function(int _function); const char *sysdecode_scheduler_policy(int _policy); const char *sysdecode_sctp_pr_policy(int _policy); +void sysdecode_sctp_sinfo_flags(FILE *_fp, int _sinfo_flags); const char *sysdecode_semctl_cmd(int _cmd); bool sysdecode_semget_flags(FILE *_fp, int _flag, int *_rem); bool sysdecode_sendfile_flags(FILE *_fp, int _flags, int *_rem); diff --git a/lib/libsysdecode/sysdecode_enum.3 b/lib/libsysdecode/sysdecode_enum.3 index 1a337a715c2f..b52a387657b4 100644 --- a/lib/libsysdecode/sysdecode_enum.3 +++ b/lib/libsysdecode/sysdecode_enum.3 @@ -54,6 +54,7 @@ .Nm sysdecode_rtprio_function , .Nm sysdecode_scheduler_policy , .Nm sysdecode_sctp_pr_policy , +.Nm sysdecode_sctp_sinfo_flags , .Nm sysdecode_semctl_cmd , .Nm sysdecode_shmctl_cmd , .Nm sysdecode_shutdown_how , diff --git a/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3 b/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3 new file mode 100644 index 000000000000..121d85c0e056 --- /dev/null +++ b/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3 @@ -0,0 +1,55 @@ +.\" +.\" 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 14, 2018 +.Dt sysdecode_sctp_sinfo_flags 3 +.Os +.Sh NAME +.Nm sysdecode_sctp_sinfo_flags +.Nd output textual description of the sinfo_flags field of struct sctp_sndrcvinfo +.Sh LIBRARY +.Lb libsysdecode +.Sh SYNOPSIS +.In sys/types.h +.In stdbool.h +.In stdio.h +.In sysdecode.h +.Ft void +.Fn sysdecode_sctp_sinfo_flags "FILE *fp" "int sinfo_flags" +.Sh DESCRIPTION +The +.Fn sysdecode_sctp_sinfo_flags +function outputs a textual description of the +.Fa sinfo_flags +member of a +.Vt struct sctp_sndrcvinfo +to the stream +.Fa fp . +In particular, the embedded PR-SCTP policies are handled. +.Sh SEE ALSO +.Xr sysdecode 3 +.Xr sysdecode_sctp_pr_policy 3