Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jan 2018 14:27:42 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r327966 - head/lib/libsysdecode
Message-ID:  <201801141427.w0EERgv2081668@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sun Jan 14 14:27:42 2018
New Revision: 327966
URL: https://svnweb.freebsd.org/changeset/base/327966

Log:
  Add a function is decode the sinfo_flags of struct sctp_sndrcvinfo.

Added:
  head/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3   (contents, props changed)
Modified:
  head/lib/libsysdecode/Makefile
  head/lib/libsysdecode/flags.c
  head/lib/libsysdecode/sysdecode.3
  head/lib/libsysdecode/sysdecode.h
  head/lib/libsysdecode/sysdecode_enum.3

Modified: head/lib/libsysdecode/Makefile
==============================================================================
--- head/lib/libsysdecode/Makefile	Sun Jan 14 12:39:50 2018	(r327965)
+++ head/lib/libsysdecode/Makefile	Sun Jan 14 14:27:42 2018	(r327966)
@@ -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 \

Modified: head/lib/libsysdecode/flags.c
==============================================================================
--- head/lib/libsysdecode/flags.c	Sun Jan 14 12:39:50 2018	(r327965)
+++ head/lib/libsysdecode/flags.c	Sun Jan 14 14:27:42 2018	(r327966)
@@ -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);
+		}
+	}
+}

Modified: head/lib/libsysdecode/sysdecode.3
==============================================================================
--- head/lib/libsysdecode/sysdecode.3	Sun Jan 14 12:39:50 2018	(r327965)
+++ head/lib/libsysdecode/sysdecode.3	Sun Jan 14 14:27:42 2018	(r327966)
@@ -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 ,

Modified: head/lib/libsysdecode/sysdecode.h
==============================================================================
--- head/lib/libsysdecode/sysdecode.h	Sun Jan 14 12:39:50 2018	(r327965)
+++ head/lib/libsysdecode/sysdecode.h	Sun Jan 14 14:27:42 2018	(r327966)
@@ -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);

Modified: head/lib/libsysdecode/sysdecode_enum.3
==============================================================================
--- head/lib/libsysdecode/sysdecode_enum.3	Sun Jan 14 12:39:50 2018	(r327965)
+++ head/lib/libsysdecode/sysdecode_enum.3	Sun Jan 14 14:27:42 2018	(r327966)
@@ -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 ,

Added: head/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3	Sun Jan 14 14:27:42 2018	(r327966)
@@ -0,0 +1,55 @@
+.\"
+.\" 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 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801141427.w0EERgv2081668>