diff --git a/.gitignore b/.gitignore index f73526b6..4c954dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,57 +1,59 @@ *.o *.a *.la *.lo *.pc *.tar.* *.sha256* stamp-h1 Makefile.in Makefile .deps .libs .version .dirstamp # build-aux/release.mk related litter /.tarball-version /tag-* aclocal.m4 autoconf autoheader autom4te.cache automake compile config.* configure* debian/changelog debian/kronosnetd.postinst debian/patches depcomp install-sh libtoolize ltmain.sh m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 missing libtool autoscan.log init/kronosnetd init/kronosnetd.service kronosnetd/kronosnetd kronosnetd/knet-keygen kronosnetd/kronosnetd.logrotate kronosnet.spec *.swp *_test *_bench test-driver *.trs *.log -Doxyfile -doxyfile.stamp -xml/ +Doxyfile* +doxyfile*.stamp +xml-*/ +doxyxml +*.3 diff --git a/Makefile.am b/Makefile.am index 44b395bf..d5657687 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,196 +1,203 @@ # # Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \ config.guess config.sub missing install-sh \ ltmain.sh compile config.h.in config.h.in~ \ autoscan.log configure.scan test-driver \ m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 \ m4/ltsugar.m4 m4/ltversion.m4 include $(top_srcdir)/build-aux/check.mk AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 SPEC = $(PACKAGE_NAME).spec TARGZFILE = $(PACKAGE_NAME)-$(VERSION).tar.gz -EXTRA_DIST = build-aux autogen.sh .version \ +EXTRA_DIST = autogen.sh .version \ NOTES_TO_PACKAGE_MAINTAINERS \ - $(SPEC).in + $(SPEC).in build-aux SUBDIRS = init libtap libknet kronosnetd +if BUILD_MAN +SUBDIRS += man +endif + if BUILD_POC SUBDIRS += poc-code endif dist_doc_DATA = \ COPYING.applications \ COPYING.libraries \ COPYRIGHT \ README.licence \ README all-local: $(SPEC) clean-local: rm -f $(SPEC) distclean-local: rm -f $(PACKAGE_NAME)-*.tar.* $(PACKAGE_NAME)-*.sha256* tag-* ## make rpm/srpm section. $(SPEC): $(SPEC).in .version config.status rm -f $@-t $@ date="`LC_ALL=C date "+%a %b %d %Y"`" && \ if [ -f $(abs_srcdir)/.tarball-version ]; then \ gitver="`cat $(abs_srcdir)/.tarball-version`" && \ rpmver=$$gitver && \ alphatag="" && \ dirty="" && \ numcomm="0"; \ else \ gitver="`GIT_DIR=$(abs_srcdir)/.git git describe --abbrev=4 --match='v*' HEAD 2>/dev/null`" && \ rpmver=`echo $$gitver | sed -e "s/^v//" -e "s/-.*//g"` && \ alphatag=`echo $$gitver | sed -e "s/.*-//" -e "s/^g//"` && \ vtag=`echo $$gitver | sed -e "s/-.*//g"` && \ numcomm=`GIT_DIR=$(abs_srcdir)/.git git rev-list $$vtag..HEAD | wc -l` && \ cd $(abs_srcdir) && \ git update-index --refresh > /dev/null 2>&1 || true && \ dirty=`git diff-index --name-only HEAD 2>/dev/null` && cd - 2>/dev/null; \ fi && \ if [ -n "$$dirty" ]; then dirty="dirty"; else dirty=""; fi && \ if [ "$$numcomm" = "0" ]; then \ sed \ -e "s#@version@#$$rpmver#g" \ -e "s#%glo.*alpha.*##g" \ -e "s#%glo.*numcomm.*##g" \ -e "s#@dirty@#$$dirty#g" \ -e "s#@date@#$$date#g" \ $(abs_srcdir)/$@.in > $@-t; \ else \ sed \ -e "s#@version@#$$rpmver#g" \ -e "s#@alphatag@#$$alphatag#g" \ -e "s#@numcomm@#$$numcomm#g" \ -e "s#@dirty@#$$dirty#g" \ -e "s#@date@#$$date#g" \ $(abs_srcdir)/$@.in > $@-t; \ fi; \ if [ -z "$$dirty" ]; then sed -i -e "s#%glo.*dirty.*##g" $@-t; fi -if BUILDSCTP +if BUILD_SCTP sed -i -e "s#@sctp@#bcond_without#g" $@-t else sed -i -e "s#@sctp@#bcond_with#g" $@-t endif if BUILD_CRYPTO_NSS sed -i -e "s#@nss@#bcond_without#g" $@-t else sed -i -e "s#@nss@#bcond_with#g" $@-t endif if BUILD_CRYPTO_OPENSSL sed -i -e "s#@openssl@#bcond_without#g" $@-t else sed -i -e "s#@openssl@#bcond_with#g" $@-t endif if BUILD_COMPRESS_ZLIB sed -i -e "s#@zlib@#bcond_without#g" $@-t else sed -i -e "s#@zlib@#bcond_with#g" $@-t endif if BUILD_COMPRESS_LZ4 sed -i -e "s#@lz4@#bcond_without#g" $@-t else sed -i -e "s#@lz4@#bcond_with#g" $@-t endif if BUILD_COMPRESS_LZO2 sed -i -e "s#@lzo2@#bcond_without#g" $@-t else sed -i -e "s#@lzo2@#bcond_with#g" $@-t endif if BUILD_COMPRESS_LZMA sed -i -e "s#@lzma@#bcond_without#g" $@-t else sed -i -e "s#@lzma@#bcond_with#g" $@-t endif if BUILD_COMPRESS_BZIP2 sed -i -e "s#@bzip2@#bcond_without#g" $@-t else sed -i -e "s#@bzip2@#bcond_with#g" $@-t endif if BUILD_KRONOSNETD sed -i -e "s#@kronosnetd@#bcond_without#g" $@-t else sed -i -e "s#@kronosnetd@#bcond_with#g" $@-t endif if BUILD_LIBTAP sed -i -e "s#@libtap@#bcond_without#g" $@-t else sed -i -e "s#@libtap@#bcond_with#g" $@-t endif if BUILD_RUNAUTOGEN sed -i -e "s#@runautogen@#bcond_without#g" $@-t else sed -i -e "s#@runautogen@#bcond_with#g" $@-t endif - if OVERRIDE_RPM_DEBUGINFO sed -i -e "s#@overriderpmdebuginfo@#bcond_without#g" $@-t else sed -i -e "s#@overriderpmdebuginfo@#bcond_with#g" $@-t endif - if BUILD_RPM_DEBUGINFO sed -i -e "s#@rpmdebuginfo@#bcond_without#g" $@-t else sed -i -e "s#@rpmdebuginfo@#bcond_with#g" $@-t +endif +if BUILD_MAN + sed -i -e "s#@buildman@#bcond_without#g" $@-t +else + sed -i -e "s#@buildman@#bcond_with#g" $@-t endif sed -i -e "s#@defaultadmgroup@#$(DEFAULTADMGROUP)#g" $@-t chmod a-w $@-t mv $@-t $@ rm -f $@-t* $(TARGZFILE): $(MAKE) dist RPMBUILDOPTS = --define "_sourcedir $(abs_builddir)" \ --define "_specdir $(abs_builddir)" \ --define "_builddir $(abs_builddir)" \ --define "_srcrpmdir $(abs_builddir)" \ --define "_rpmdir $(abs_builddir)" srpm: clean $(MAKE) $(SPEC) $(TARGZFILE) rpmbuild $(RPMBUILDOPTS) --nodeps -bs $(SPEC) rpm: clean $(MAKE) $(SPEC) $(TARGZFILE) rpmbuild $(RPMBUILDOPTS) -ba $(SPEC) # release/versioning BUILT_SOURCES = .version .version: echo $(VERSION) > $@-t && mv $@-t $@ dist-hook: gen-ChangeLog echo $(VERSION) > $(distdir)/.tarball-version gen_start_date = 2000-01-01 .PHONY: gen-ChangeLog gen-ChangeLog: - if test -d $(abs_sourcedir)/.git; then \ + if test -d $(abs_srcdir)/.git; then \ LC_ALL=C $(top_srcdir)/build-aux/gitlog-to-changelog \ --since=$(gen_start_date) > $(distdir)/cl-t; \ rm -f $(distdir)/ChangeLog; \ mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi diff --git a/configure.ac b/configure.ac index 6b3d4cc5..bd122016 100644 --- a/configure.ac +++ b/configure.ac @@ -1,467 +1,474 @@ # # Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. # # Authors: Fabio M. Di Nitto # Federico Simoncelli # # This software licensed under GPL-2.0+, LGPL-2.0+ # # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # AC_PREREQ([2.63]) AC_INIT([kronosnet], m4_esyscmd([build-aux/git-version-gen .tarball-version]), [devel@lists.kronosnet.org]) +# Don't let AC_PROC_CC (invoked by AC_USE_SYSTEM_EXTENSIONS) replace +# undefined CFLAGS with -g -O2, overriding our special OPT_CFLAGS. +: ${CFLAGS=""} AC_USE_SYSTEM_EXTENSIONS AM_INIT_AUTOMAKE([1.13 dist-bzip2 dist-xz color-tests -Wno-portability subdir-objects]) + LT_PREREQ([2.2.6]) +# --enable-new-dtags: Use RUNPATH instead of RPATH. +# It is necessary to have this done before libtool does linker detection. +# See also: https://github.com/kronosnet/kronosnet/issues/107 +# --as-needed: Modern systems have builtin ceil() making -lm superfluous but +# AC_SEARCH_LIBS can't detect this because it tests with a false prototype +AX_CHECK_LINK_FLAG([-Wl,--enable-new-dtags], + [AM_LDFLAGS=-Wl,--enable-new-dtags], + [AC_MSG_ERROR(["Linker support for --enable-new-dtags is required"])]) +AX_CHECK_LINK_FLAG([-Wl,--as-needed], [AM_LDFLAGS="$AM_LDFLAGS -Wl,--as-needed"]) + +AC_SUBST([AM_LDFLAGS]) +saved_LDFLAGS="$LDFLAGS" +LDFLAGS="$AM_LDFLAGS $LDFLAGS" LT_INIT +LDFLAGS="$saved_LDFLAGS" AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([kronosnetd/main.c]) AC_CONFIG_HEADERS([config.h]) AC_CANONICAL_HOST -AC_PROG_LIBTOOL AC_LANG([C]) systemddir=${prefix}/lib/systemd/system if test "$prefix" = "NONE"; then prefix="/usr" if test "$localstatedir" = "\${prefix}/var"; then localstatedir="/var" fi if test "$sysconfdir" = "\${prefix}/etc"; then sysconfdir="/etc" fi if test "$systemddir" = "NONE/lib/systemd/system"; then systemddir=/lib/systemd/system fi if test "$libdir" = "\${exec_prefix}/lib"; then if test -e /usr/lib64; then libdir="/usr/lib64" else libdir="/usr/lib" fi fi fi AC_PROG_AWK AC_PROG_GREP AC_PROG_SED AC_PROG_CPP AC_PROG_CC AC_PROG_CC_C99 if test "x$ac_cv_prog_cc_c99" = "xno"; then AC_MSG_ERROR(["C99 support is required"]) fi AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_MAKE_SET PKG_PROG_PKG_CONFIG -AC_CHECK_PROGS([DOXYGEN], [doxygen]) -AC_CHECK_PROGS([DOXY2MAN], [doxy2man]) - -manpageupdates=1 -if test "x$DOXYGEN" = "x" || test "x$DOXY2MAN" = "x"; then - manpageupdates=0; -fi - -AM_CONDITIONAL([MANPAGEUPDATES], [test $manpageupdates -gt 0]) AC_CHECK_PROGS([VALGRIND_EXEC], [valgrind]) AM_CONDITIONAL([HAS_VALGRIND], [test x$VALGRIND_EXEC != "x"]) # KNET_OPTION_DEFINES(stem,type,detection code) # stem: enters name of option, Automake conditional and preprocessor define # type: compress or crypto, determines where the default comes from AC_DEFUN([KNET_OPTION_DEFINES],[ AC_ARG_ENABLE([$2-$1],[AS_HELP_STRING([--disable-$2-$1],[disable libknet $1 support])],, [enable_$2_$1="$enable_$2_all"]) AM_CONDITIONAL([BUILD_]m4_toupper([$2_$1]),[test "x$enable_$2_$1" = xyes]) if test "x$enable_$2_$1" = xyes; then $3 fi AC_DEFINE_UNQUOTED([WITH_]m4_toupper([$2_$1]), [`test "x$enable_$2_$1" != xyes; echo $?`], $1 $2 [built in]) ]) +AC_ARG_ENABLE([man], + [AS_HELP_STRING([--disable-man],[disable man page creation])],, + [ enable_man="yes" ]) +AM_CONDITIONAL([BUILD_MAN], [test x$enable_man = xyes]) + AC_ARG_ENABLE([libknet-sctp], [AS_HELP_STRING([--disable-libknet-sctp],[disable libknet SCTP support])],, [ enable_libknet_sctp="yes" ]) -AM_CONDITIONAL([BUILDSCTP], [test x$enable_libknet_sctp = xyes]) +AM_CONDITIONAL([BUILD_SCTP], [test x$enable_libknet_sctp = xyes]) AC_ARG_ENABLE([crypto-all], [AS_HELP_STRING([--disable-crypto-all],[disable libknet all crypto modules support])],, [ enable_crypto_all="yes" ]) KNET_OPTION_DEFINES([nss],[crypto],[PKG_CHECK_MODULES([nss], [nss])]) KNET_OPTION_DEFINES([openssl],[crypto],[ PKG_CHECK_MODULES([openssl],[libcrypto < 1.1], [AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL10], [1], [openssl 1.0 crypto])], [PKG_CHECK_MODULES([openssl],[libcrypto >= 1.1], [AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL11], [1], [openssl 1.1 crypto])])]) ]) AC_ARG_ENABLE([compress-all], [AS_HELP_STRING([--disable-compress-all],[disable libknet all compress modules support])],, [ enable_compress_all="yes" ]) KNET_OPTION_DEFINES([zlib],[compress],[PKG_CHECK_MODULES([zlib], [zlib])]) KNET_OPTION_DEFINES([lz4],[compress],[PKG_CHECK_MODULES([liblz4], [liblz4])]) KNET_OPTION_DEFINES([lzo2],[compress],[ PKG_CHECK_MODULES([lzo2], [lzo2], [# work around broken pkg-config file in v2.10 AC_SUBST([lzo2_CFLAGS],[`echo $lzo2_CFLAGS | sed 's,/lzo *, ,'`])], [AC_CHECK_HEADERS([lzo/lzo1x.h], [AC_CHECK_LIB([lzo2], [lzo1x_decompress_safe], [AC_SUBST([lzo2_LIBS], [-llzo2])])], [AC_MSG_ERROR(["missing required lzo/lzo1x.h header"])])]) ]) KNET_OPTION_DEFINES([lzma],[compress],[PKG_CHECK_MODULES([liblzma], [liblzma])]) KNET_OPTION_DEFINES([bzip2],[compress],[ PKG_CHECK_MODULES([bzip2], [bzip2],, [AC_CHECK_HEADERS([bzlib.h], [AC_CHECK_LIB([bz2], [BZ2_bzBuffToBuffCompress], [AC_SUBST([bzip2_LIBS], [-lbz2])])], [AC_MSG_ERROR(["missing required bzlib.h"])])]) ]) AC_ARG_ENABLE([poc], [AS_HELP_STRING([--enable-poc],[enable building poc code])],, [ enable_poc="no" ]) AM_CONDITIONAL([BUILD_POC], [test x$enable_poc = xyes]) AC_ARG_ENABLE([kronosnetd], [AS_HELP_STRING([--enable-kronosnetd],[Kronosnetd support])],, [ enable_kronosnetd="no" ]) AM_CONDITIONAL([BUILD_KRONOSNETD], [test x$enable_kronosnetd = xyes]) AC_ARG_ENABLE([runautogen], [AS_HELP_STRING([--enable-runautogen],[run autogen.sh])],, [ enable_runautogen="no" ]) AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes]) override_rpm_debuginfo_option="yes" AC_ARG_ENABLE([rpm-debuginfo], [AS_HELP_STRING([--enable-rpm-debuginfo],[build debuginfo packages])],, [ enable_rpm_debuginfo="no", override_rpm_debuginfo_option="no" ]) AM_CONDITIONAL([BUILD_RPM_DEBUGINFO], [test x$enable_rpm_debuginfo = xyes]) AM_CONDITIONAL([OVERRIDE_RPM_DEBUGINFO], [test x$override_rpm_debuginfo_option = xyes]) AC_ARG_ENABLE([libtap], [AS_HELP_STRING([--enable-libtap],[libtap support])],, [ enable_libtap="no" ]) if test "x$enable_kronosnetd" = xyes; then enable_libtap=yes fi AM_CONDITIONAL([BUILD_LIBTAP], [test x$enable_libtap = xyes]) ## local helper functions # this function checks if CC support options passed as -# args. Global CFLAGS are ignored during this test. +# args. Global CPPFLAGS are ignored during this test. cc_supports_flag() { saveCPPFLAGS="$CPPFLAGS" CPPFLAGS="$@" if echo $CC | grep -q clang; then CPPFLAGS="-Werror $CPPFLAGS" fi AC_MSG_CHECKING([whether $CC supports "$@"]) AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])], [RC=0; AC_MSG_RESULT([yes])], [RC=1; AC_MSG_RESULT([no])]) CPPFLAGS="$saveCPPFLAGS" return $RC } -# Checks for C features -AC_C_INLINE - # Checks for libraries. AX_PTHREAD(,[AC_MSG_ERROR([POSIX threads support is required])]) -AC_CHECK_LIB([m], [ceil], [AC_SUBST([m_LIBS], [-lm])], [AC_MSG_ERROR([kronosnet requires m library])]) saved_LIBS="$LIBS" LIBS= +AC_SEARCH_LIBS([ceil], [m], , [AC_MSG_ERROR([ceil not found])]) +AC_SUBST([m_LIBS], [$LIBS]) +LIBS= AC_SEARCH_LIBS([clock_gettime], [rt], , [AC_MSG_ERROR([clock_gettime not found])]) AC_SUBST([rt_LIBS], [$LIBS]) LIBS= AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])]) AC_SUBST([dl_LIBS], [$LIBS]) LIBS="$saved_LIBS" # OS detection AC_MSG_CHECKING([for os in ${host_os}]) case "$host_os" in *linux*) AC_DEFINE_UNQUOTED([KNET_LINUX], [1], [Compiling for Linux platform]) AC_MSG_RESULT([Linux]) ;; *bsd*) AC_DEFINE_UNQUOTED([KNET_BSD], [1], [Compiling for BSD platform]) AC_MSG_RESULT([BSD]) if test "x$enable_libtap" = xyes; then AC_MSG_ERROR([libtap is not currently supported on BSD platforms]) fi ;; *) AC_MSG_ERROR([Unsupported OS? hmmmm]) ;; esac # Checks for header files. -AC_CHECK_HEADERS([fcntl.h]) -AC_CHECK_HEADERS([stdlib.h]) -AC_CHECK_HEADERS([string.h]) -AC_CHECK_HEADERS([strings.h]) -AC_CHECK_HEADERS([sys/ioctl.h]) -AC_CHECK_HEADERS([syslog.h]) -AC_CHECK_HEADERS([unistd.h]) -AC_CHECK_HEADERS([netinet/in.h]) -AC_CHECK_HEADERS([sys/socket.h]) -AC_CHECK_HEADERS([arpa/inet.h]) -AC_CHECK_HEADERS([netdb.h]) -AC_CHECK_HEADERS([limits.h]) -AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([sys/epoll.h]) +AC_CHECK_FUNCS([kevent]) +# if neither sys/epoll.h nor kevent are present, we should fail. + +if test "x$ac_cv_header_sys_epoll_h" = xno && test "x$ac_cv_func_kevent" = xno; then + AC_MSG_ERROR([Both epoll and kevent unavailable on this OS]) +fi + +if test "x$ac_cv_header_sys_epoll_h" = xyes && test "x$ac_cv_func_kevent" = xyes; then + AC_MSG_ERROR([Both epoll and kevent available on this OS, please contact the maintainers to fix the code]) +fi if test "x$enable_libknet_sctp" = xyes; then AC_CHECK_HEADERS([netinet/sctp.h],, [AC_MSG_ERROR(["missing required SCTP headers"])]) fi # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE -AC_TYPE_SIZE_T AC_TYPE_PID_T +AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT8_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T +AC_TYPE_INT8_T +AC_TYPE_INT16_T AC_TYPE_INT32_T +AC_TYPE_INT64_T -# Checks for library functions. -AC_FUNC_ALLOCA -AC_FUNC_FORK -AC_FUNC_MALLOC -AC_FUNC_REALLOC -AC_CHECK_FUNCS([kevent]) -# if neither sys/epoll.h nor kevent are present, we should fail. - -if test "x$ac_cv_header_sys_epoll_h" = xno && test "x$ac_cv_func_kevent" = xno; then - AC_MSG_ERROR([Both epoll and kevent unavailable on this OS]) -fi - -if test "x$ac_cv_header_sys_epoll_h" = xyes && test "x$ac_cv_func_kevent" = xyes; then - AC_MSG_ERROR([Both epoll and kevent available on this OS, please contact the maintainers to fix the code]) +if test "x$enable_man" = "xyes"; then + AC_ARG_VAR([DOXYGEN], [override doxygen executable]) + AC_CHECK_PROGS([DOXYGEN], [doxygen], [no]) + if test "x$DOXYGEN" = xno; then + AC_MSG_ERROR(["Doxygen command not found"]) + fi + # required by doxyxml to build man pages dynamically + # Don't let AC_PROC_CC (invoked by AX_PROG_CC_FOR_BUILD) replace + # undefined CFLAGS_FOR_BUILD with -g -O2, overriding our special OPT_CFLAGS. + : ${CFLAGS_FOR_BUILD=""} + AX_PROG_CC_FOR_BUILD + saved_PKG_CONFIG="$PKG_CONFIG" + saved_ac_cv_path_PKG_CONFIG="$ac_cv_path_PKG_CONFIG" + unset PKG_CONFIG ac_cv_path_PKG_CONFIG + AC_PATH_PROG([PKG_CONFIG], [pkg-config]) + PKG_CHECK_MODULES([libqb_BUILD], [libqb]) + PKG_CHECK_MODULES([libxml_BUILD], [libxml-2.0]) + PKG_CONFIG="$saved_PKG_CONFIG" + ac_cv_path_PKG_CONFIG="$saved_ac_cv_path_PKG_CONFIG" fi # checks (for kronosnetd) if test "x$enable_kronosnetd" = xyes; then AC_CHECK_HEADERS([security/pam_appl.h], [AC_CHECK_LIB([pam], [pam_start], [AC_SUBST([pam_LIBS], [-lpam])], [AC_MSG_ERROR([Unable to find LinuxPAM devel files])])]) AC_CHECK_HEADERS([security/pam_misc.h], [AC_CHECK_LIB([pam_misc], [misc_conv], [AC_SUBST([pam_misc_LIBS], [-lpam_misc])], [AC_MSG_ERROR([Unable to find LinuxPAM MISC devel files])])]) PKG_CHECK_MODULES([libqb], [libqb]) AC_CHECK_LIB([qb], [qb_log_thread_priority_set], [have_qb_log_thread_priority_set="yes"], [have_qb_log_thread_priority_set="no"]) if test "x${have_qb_log_thread_priority_set}" = xyes; then AC_DEFINE_UNQUOTED([HAVE_QB_LOG_THREAD_PRIORITY_SET], [1], [have qb_log_thread_priority_set]) fi fi # local options AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[enable debug build])]) AC_ARG_WITH([initdefaultdir], [AS_HELP_STRING([--with-initdefaultdir=DIR],[path to /etc/sysconfig or /etc/default dir])], [ INITDEFAULTDIR="$withval" ], [ INITDEFAULTDIR="$sysconfdir/default" ]) AC_ARG_WITH([initddir], [AS_HELP_STRING([--with-initddir=DIR],[path to init script directory])], [ INITDDIR="$withval" ], [ INITDDIR="$sysconfdir/init.d" ]) AC_ARG_WITH([systemddir], [AS_HELP_STRING([--with-systemddir=DIR],[path to systemd unit files directory])], [ SYSTEMDDIR="$withval" ], [ SYSTEMDDIR="$systemddir" ]) AC_ARG_WITH([syslogfacility], [AS_HELP_STRING([--with-syslogfacility=FACILITY],[default syslog facility])], [ SYSLOGFACILITY="$withval" ], [ SYSLOGFACILITY="LOG_DAEMON" ]) AC_ARG_WITH([sysloglevel], [AS_HELP_STRING([--with-sysloglevel=LEVEL],[default syslog level])], [ SYSLOGLEVEL="$withval" ], [ SYSLOGLEVEL="LOG_INFO" ]) AC_ARG_WITH([defaultadmgroup], [AS_HELP_STRING([--with-defaultadmgroup=GROUP], [define PAM group. Users part of this group will be allowed to configure kronosnet. Others will only receive read-only rights.])], [ DEFAULTADMGROUP="$withval" ], [ DEFAULTADMGROUP="kronosnetadm" ]) ## random vars LOGDIR=${localstatedir}/log/ RUNDIR=${localstatedir}/run/ DEFAULT_CONFIG_DIR=${sysconfdir}/kronosnet ## do subst -AM_CONDITIONAL([DEBUG], [test "x${enable_debug}" = xyes]) - AC_SUBST([DEFAULT_CONFIG_DIR]) AC_SUBST([INITDEFAULTDIR]) AC_SUBST([INITDDIR]) AC_SUBST([SYSTEMDDIR]) AC_SUBST([LOGDIR]) AC_SUBST([DEFAULTADMGROUP]) AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_DIR], ["$(eval echo ${DEFAULT_CONFIG_DIR})"], [Default config directory]) AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_FILE], ["$(eval echo ${DEFAULT_CONFIG_DIR}/kronosnetd.conf)"], [Default config file]) AC_DEFINE_UNQUOTED([LOGDIR], ["$(eval echo ${LOGDIR})"], [Default logging directory]) AC_DEFINE_UNQUOTED([DEFAULT_LOG_FILE], ["$(eval echo ${LOGDIR}/kronosnetd.log)"], [Default log file]) AC_DEFINE_UNQUOTED([RUNDIR], ["$(eval echo ${RUNDIR})"], [Default run directory]) AC_DEFINE_UNQUOTED([SYSLOGFACILITY], [$(eval echo ${SYSLOGFACILITY})], [Default syslog facility]) AC_DEFINE_UNQUOTED([SYSLOGLEVEL], [$(eval echo ${SYSLOGLEVEL})], [Default syslog level]) AC_DEFINE_UNQUOTED([DEFAULTADMGROUP], ["$(eval echo ${DEFAULTADMGROUP})"], [Default admin group]) -## *FLAGS handling -ENV_CFLAGS="$CFLAGS" -ENV_CPPFLAGS="$CPPFLAGS" -ENV_LDFLAGS="$LDFLAGS" - # debug build stuff if test "x${enable_debug}" = xyes; then AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code]) OPT_CFLAGS="-O0" else OPT_CFLAGS="-O3" fi # gdb flags if test "x${GCC}" = xyes; then GDB_FLAGS="-ggdb3" else GDB_FLAGS="-g" fi # extra warnings EXTRA_WARNINGS="" WARNLIST=" all extra unused shadow missing-prototypes missing-declarations suggest-attribute=noreturn suggest-attribute=format strict-prototypes declaration-after-statement pointer-arith write-strings cast-align bad-function-cast missing-format-attribute float-equal format=2 format-signedness format-security format-nonliteral no-long-long unsigned-char gnu89-inline no-strict-aliasing error address cpp overflow parentheses sequence-point switch shift-overflow=2 overlength-strings retundent-decls init-self uninitialized unused-but-set-variable unused-function unused-result unused-value unused-variable unknown-pragmas no-unused-parameter " for j in $WARNLIST; do if cc_supports_flag -W$j; then EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j"; fi done -CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $OPT_CFLAGS $GDB_FLAGS \ - $EXTRA_WARNINGS $WERROR_CFLAGS" -CPPFLAGS="$ENV_CPPFLAGS" -LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic" +AC_SUBST([AM_CFLAGS],["$OPT_CFLAGS $GDB_FLAGS $EXTRA_WARNINGS"]) AC_CONFIG_FILES([ Makefile init/Makefile libtap/Makefile libtap/libtap.pc kronosnetd/Makefile kronosnetd/kronosnetd.logrotate libknet/Makefile libknet/libknet.pc libknet/tests/Makefile - libknet/man/Doxyfile - libknet/man/Makefile + man/Makefile + man/Doxyfile-knet poc-code/Makefile poc-code/iov-hash/Makefile poc-code/access-list/Makefile ]) AC_OUTPUT diff --git a/kronosnet.spec.in b/kronosnet.spec.in index 24f0e105..a9cb445e 100644 --- a/kronosnet.spec.in +++ b/kronosnet.spec.in @@ -1,522 +1,537 @@ ############################################################################### ############################################################################### ## ## Copyright (C) 2012-2018 Red Hat, Inc. All rights reserved. ## ## This copyrighted material is made available to anyone wishing to use, ## modify, copy, or redistribute it subject to the terms and conditions ## of the GNU General Public License v.2 or higher ## ############################################################################### ############################################################################### # keep around ready for later user %global alphatag @alphatag@ %global numcomm @numcomm@ %global dirty @dirty@ # set defaults from ./configure invokation %@sctp@ sctp %@nss@ nss %@openssl@ openssl %@zlib@ zlib %@lz4@ lz4 %@lzo2@ lzo2 %@lzma@ lzma %@bzip2@ bzip2 %@kronosnetd@ kronosnetd %@libtap@ libtap %@runautogen@ runautogen %@rpmdebuginfo@ rpmdebuginfo %@overriderpmdebuginfo@ overriderpmdebuginfo +%@buildman@ buildman %if %{with overriderpmdebuginfo} %undefine _enable_debug_packages %endif %if %{with sctp} %global buildsctp 1 %endif %if %{with nss} %global buildcryptonss 1 %endif %if %{with openssl} %global buildcryptoopenssl 1 %endif %if %{with zlib} %global buildcompresszlib 1 %endif %if %{with lz4} %global buildcompresslz4 1 %endif %if %{with lzo2} %global buildcompresslzo2 1 %endif %if %{with lzma} %global buildcompresslzma 1 %endif %if %{with bzip2} %global buildcompressbzip2 1 %endif %if %{with libtap} %global buildlibtap 1 %endif %if %{with kronosnetd} %global buildlibtap 1 %global buildkronosnetd 1 %endif %if %{with runautogen} %global buildautogen 1 %endif +%if %{with buildman} +%global buildmanpages 1 +%endif # main (empty) package # http://www.rpm.org/max-rpm/s1-rpm-subpack-spec-file-changes.html Name: kronosnet Summary: Multipoint-to-Multipoint VPN daemon Version: @version@ Release: 1%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist} License: GPLv2+ and LGPLv2+ Group: System Environment/Base -URL: https://github.com/fabbione/kronosnet/ -Source0: https://github.com/fabbione/kronosnet/archive/%{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}.tar.gz +URL: https://github.com/kronosnet/kronosnet/ +Source0: https://github.com/kronosnet/kronosnet/archive/%{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}.tar.gz ## Setup/build bits BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) # Build dependencies BuildRequires: gcc +# required to build man pages +%if %{defined buildmanpages} +BuildRequires: libqb-devel libxml2-devel doxygen +%endif %if %{defined buildsctp} BuildRequires: lksctp-tools-devel %endif %if %{defined buildcryptonss} BuildRequires: /usr/include/nss3/nss.h /usr/include/nspr4/nspr.h %endif %if %{defined buildcryptoopenssl} BuildRequires: /usr/include/openssl/conf.h %endif %if %{defined buildcompresszlib} BuildRequires: zlib-devel %endif %if %{defined buildcompresslz4} BuildRequires: /usr/include/lz4hc.h %endif %if %{defined buildcompresslzo2} BuildRequires: lzo-devel %endif %if %{defined buildcompresslzma} BuildRequires: xz-devel %endif %if %{defined buildcompressbzip2} BuildRequires: /usr/include/bzlib.h %endif %if %{defined buildkronosnetd} -BuildRequires: libqb-devel pam-devel +BuildRequires: pam-devel %endif %if %{defined buildautogen} -BuildRequires: autoconf -BuildRequires: automake -BuildRequires: libtool +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool %endif %prep %setup -q -n %{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}} %build %if %{with runautogen} ./autogen.sh %endif %{configure} \ +%if %{defined buildmanpages} + --enable-man \ +%else + --disable-man \ +%endif %if %{defined buildsctp} --enable-libknet-sctp \ %else --disable-libknet-sctp \ %endif %if %{defined buildcryptonss} --enable-crypto-nss \ %else --disable-crypto-nss \ %endif %if %{defined buildcryptoopenssl} --enable-crypto-openssl \ %else --disable-crypto-openssl \ %endif %if %{defined buildcompresszlib} --enable-compress-zlib \ %else --disable-compress-zlib \ %endif %if %{defined buildcompresslz4} --enable-compress-lz4 \ %else --disable-compress-lz4 \ %endif %if %{defined buildcompresslzo2} --enable-compress-lzo2 \ %else --disable-compress-lzo2 \ %endif %if %{defined buildcompresslzma} --enable-compress-lzma \ %else --disable-compress-lzma \ %endif %if %{defined buildcompressbzip2} --enable-compress-bzip2 \ %else --disable-compress-bzip2 \ %endif %if %{defined buildkronosnetd} --enable-kronosnetd \ %endif %if %{defined buildlibtap} --enable-libtap \ %endif --with-initdefaultdir=%{_sysconfdir}/sysconfig/ \ %if %{defined _unitdir} --with-systemddir=%{_unitdir} %else --with-initddir=%{_sysconfdir}/rc.d/init.d/ %endif make %{_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} # tree cleanup # remove static libraries find %{buildroot} -name "*.a" -exec rm {} \; # remove libtools leftovers find %{buildroot} -name "*.la" -exec rm {} \; # handle systemd vs init script %if %{defined _unitdir} # remove init scripts rm -rf %{buildroot}/etc/init.d %else # remove systemd specific bits find %{buildroot} -name "*.service" -exec rm {} \; %endif # remove docs rm -rf %{buildroot}/usr/share/doc/kronosnet %clean rm -rf %{buildroot} # main empty package %description kronosnet source %if %{defined buildkronosnetd} ## Runtime and subpackages section %package -n kronosnetd Group: System Environment/Base Summary: Multipoint-to-Multipoint VPN daemon %if %{defined _unitdir} # Needed for systemd unit Requires(post): systemd-sysv Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units %else Requires(post): chkconfig Requires(preun): chkconfig, initscripts %endif Requires(post): shadow-utils Requires(preun): shadow-utils Requires: pam, /etc/pam.d/passwd %description -n kronosnetd The kronosnet daemon is a bridge between kronosnet switching engine and kernel network tap devices, to create and administer a distributed LAN over multipoint-to-multipoint VPNs. The daemon does a poor attempt to provide a configure UI similar to other known network devices/tools (Cisco, quagga). Beside looking horrific, it allows runtime changes and reconfiguration of the kronosnet(s) without daemon reload or service disruption. %post -n kronosnetd %if %{defined _unitdir} %if 0%{?systemd_post:1} %systemd_post kronosnetd.service %else /bin/systemctl daemon-reload >/dev/null 2>&1 || : %endif %else /sbin/chkconfig --add kronosnetd %endif /usr/sbin/groupadd --force --system @defaultadmgroup@ %preun -n kronosnetd %if %{defined _unitdir} %if 0%{?systemd_preun:1} %systemd_preun kronosnetd.service %else if [ "$1" -eq 0 ]; then /bin/systemctl --no-reload disable kronosnetd.service /bin/systemctl stop kronosnetd.service >/dev/null 2>&1 fi %endif %else if [ "$1" = 0 ]; then /sbin/service kronosnetd stop >/dev/null 2>&1 /sbin/chkconfig --del kronosnetd fi %endif %files -n kronosnetd %defattr(-,root,root,-) %doc COPYING.* COPYRIGHT %dir %{_sysconfdir}/kronosnet %dir %{_sysconfdir}/kronosnet/* %config(noreplace) %{_sysconfdir}/sysconfig/kronosnetd %config(noreplace) %{_sysconfdir}/pam.d/kronosnetd %config(noreplace) %{_sysconfdir}/logrotate.d/kronosnetd %if %{defined _unitdir} %{_unitdir}/kronosnetd.service %else %config(noreplace) %{_sysconfdir}/rc.d/init.d/kronosnetd %endif %{_sbindir}/* %{_mandir}/man8/* %endif %if %{defined buildlibtap} %package -n libtap1 Group: System Environment/Libraries Summary: Simple userland wrapper around kernel tap devices %description -n libtap1 This is an over-engineered commodity library to manage a pool of tap devices and provides the basic pre-up.d/up.d/down.d/post-down.d infrastructure. %files -n libtap1 %defattr(-,root,root,-) %doc COPYING.* COPYRIGHT %{_libdir}/libtap.so.* %post -n libtap1 -p /sbin/ldconfig %postun -n libtap1 -p /sbin/ldconfig %package -n libtap1-devel Group: Development/Libraries Summary: Simple userland wrapper around kernel tap devices (developer files) Requires: libtap1 = %{version}-%{release} Requires: pkgconfig %description -n libtap1-devel This is an over-engineered commodity library to manage a pool of tap devices and provides the basic pre-up.d/up.d/down.d/post-down.d infrastructure. %files -n libtap1-devel %defattr(-,root,root,-) %doc COPYING.* COPYRIGHT %{_libdir}/libtap.so %{_includedir}/libtap.h %{_libdir}/pkgconfig/libtap.pc %endif %package -n libknet1 Group: System Environment/Libraries Summary: Kronosnet core switching implementation %description -n libknet1 The whole kronosnet core is implemented in this library. Please refer to the not-yet-existing documentation for further information. %files -n libknet1 %defattr(-,root,root,-) %doc COPYING.* COPYRIGHT %{_libdir}/libknet.so.* %dir %{_libdir}/kronosnet %post -n libknet1 -p /sbin/ldconfig %postun -n libknet1 -p /sbin/ldconfig %package -n libknet1-devel Group: Development/Libraries Summary: Kronosnet core switching implementation (developer files) Requires: libknet1 = %{version}-%{release} Requires: pkgconfig %description -n libknet1-devel The whole kronosnet core is implemented in this library. Please refer to the not-yet-existing documentation for further information. %files -n libknet1-devel %defattr(-,root,root,-) %doc COPYING.* COPYRIGHT %{_libdir}/libknet.so %{_includedir}/libknet.h %{_libdir}/pkgconfig/libknet.pc -%{_mandir}/man3/*.3.gz +%if %{defined buildmanpages} +%{_mandir}/man3/knet*.3.gz +%endif %if %{defined buildcryptonss} %package -n libknet1-crypto-nss-plugin Group: System Environment/Libraries Summary: libknet1 nss support Requires: libknet1 = %{version}-%{release} %description -n libknet1-crypto-nss-plugin NSS crypto support for libknet1. %files -n libknet1-crypto-nss-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/crypto_nss.so %endif %if %{defined buildcryptoopenssl} %package -n libknet1-crypto-openssl-plugin Group: System Environment/Libraries Summary: libknet1 openssl support Requires: libknet1 = %{version}-%{release} %description -n libknet1-crypto-openssl-plugin OpenSSL crypto support for libknet1. %files -n libknet1-crypto-openssl-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/crypto_openssl.so %endif %if %{defined buildcompresszlib} %package -n libknet1-compress-zlib-plugin Group: System Environment/Libraries Summary: libknet1 zlib support Requires: libknet1 = %{version}-%{release} %description -n libknet1-compress-zlib-plugin zlib compression support for libknet1. %files -n libknet1-compress-zlib-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/compress_zlib.so %endif %if %{defined buildcompresslz4} %package -n libknet1-compress-lz4-plugin Group: System Environment/Libraries Summary: libknet1 lz4 and lz4hc support Requires: libknet1 = %{version}-%{release} %description -n libknet1-compress-lz4-plugin lz4 and lz4hc compression support for libknet1. %files -n libknet1-compress-lz4-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/compress_lz4.so %{_libdir}/kronosnet/compress_lz4hc.so %endif %if %{defined buildcompresslzo2} %package -n libknet1-compress-lzo2-plugin Group: System Environment/Libraries Summary: libknet1 lzo2 support Requires: libknet1 = %{version}-%{release} %description -n libknet1-compress-lzo2-plugin lzo2 compression support for libknet1. %files -n libknet1-compress-lzo2-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/compress_lzo2.so %endif %if %{defined buildcompresslzma} %package -n libknet1-compress-lzma-plugin Group: System Environment/Libraries Summary: libknet1 lzma support Requires: libknet1 = %{version}-%{release} %description -n libknet1-compress-lzma-plugin lzma compression support for libknet1. %files -n libknet1-compress-lzma-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/compress_lzma.so %endif %if %{defined buildcompressbzip2} %package -n libknet1-compress-bzip2-plugin Group: System Environment/Libraries Summary: libknet1 bzip2 support Requires: libknet1 = %{version}-%{release} %description -n libknet1-compress-bzip2-plugin bzip2 compression support for libknet1. %files -n libknet1-compress-bzip2-plugin %defattr(-,root,root,-) %{_libdir}/kronosnet/compress_bzip2.so %endif %package -n libknet1-crypto-plugins-all Group: System Environment/Libraries Summary: libknet1 crypto plugins meta package %if %{defined buildcryptonss} Requires: libknet1-crypto-nss-plugin %endif %if %{defined buildcryptoopenssl} Requires: libknet1-crypto-openssl-plugin %endif %description -n libknet1-crypto-plugins-all meta package to install all of libknet1 crypto plugins %files -n libknet1-crypto-plugins-all %package -n libknet1-compress-plugins-all Group: System Environment/Libraries Summary: libknet1 compress plugins meta package %if %{defined buildcompresszlib} Requires: libknet1-compress-zlib-plugin %endif %if %{defined buildcompresslz4} Requires: libknet1-compress-lz4-plugin %endif %if %{defined buildcompresslzo2} Requires: libknet1-compress-lzo2-plugin %endif %if %{defined buildcompresslzma} Requires: libknet1-compress-lzma-plugin %endif %if %{defined buildcompressbzip2} Requires: libknet1-compress-bzip2-plugin %endif %description -n libknet1-compress-plugins-all meta package to install all of libknet1 compress plugins %files -n libknet1-compress-plugins-all %package -n libknet1-plugins-all Group: System Environment/Libraries Summary: libknet1 plugins meta package Requires: libknet1-compress-plugins-all Requires: libknet1-crypto-plugins-all %description -n libknet1-plugins-all meta package to install all of libknet1 plugins %files -n libknet1-plugins-all %if %{with rpmdebuginfo} %debug_package %endif %changelog * @date@ Autotools generated version - @version@-1-@numcomm@.@alphatag@.@dirty@ - These aren't the droids you're looking for. diff --git a/kronosnetd/Makefile.am b/kronosnetd/Makefile.am index 569fdcd7..8c233579 100644 --- a/kronosnetd/Makefile.am +++ b/kronosnetd/Makefile.am @@ -1,91 +1,89 @@ # # Copyright (C) 2012-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in kronostnetd.logrotate include $(top_srcdir)/build-aux/check.mk -EXTRA_DIST = kronosnetd.logrotate.in kronosnetd.8 knet-keygen.8 +EXTRA_DIST = kronosnetd.logrotate.in noinst_HEADERS = \ cfg.h \ etherfilter.h \ logging.h \ vty.h \ vty_auth.h \ vty_cli.h \ vty_cli_cmds.h \ vty_utils.h kronosnetd_SOURCES = \ cfg.c \ etherfilter.c \ main.c \ logging.c \ vty.c \ vty_auth.c \ vty_cli.c \ vty_cli_cmds.c \ vty_utils.c kronosnetd_CPPFLAGS = \ -I$(top_srcdir)/libtap \ -I$(top_srcdir)/libknet -kronosnetd_CFLAGS = $(libqb_CFLAGS) +kronosnetd_CFLAGS = $(AM_CFLAGS) $(libqb_CFLAGS) kronosnetd_LDADD = \ $(top_builddir)/libknet/libknet.la \ $(top_builddir)/libtap/libtap.la \ $(libqb_LIBS) \ $(pam_misc_LIBS) $(pam_LIBS) knet_keygen_SOURCES = keygen.c knet_keygen_CPPFLAGS = -I$(top_srcdir)/libknet if BUILD_KRONOSNETD sbin_PROGRAMS = kronosnetd \ knet-keygen -dist_man_MANS = kronosnetd.8 knet-keygen.8 - install-exec-local: $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR) $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/down.d $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/post-down.d $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/pre-up.d $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/up.d $(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/cryptokeys.d $(INSTALL) -d -m 0755 $(DESTDIR)/$(sysconfdir)/logrotate.d $(INSTALL) -m 644 kronosnetd.logrotate $(DESTDIR)/$(sysconfdir)/logrotate.d/kronosnetd $(INSTALL) -d -m 0755 $(DESTDIR)/$(sysconfdir)/pam.d if [ -a $(sysconfdir)/pam.d/password-auth ]; then \ cd $(DESTDIR)/$(sysconfdir)/pam.d && \ rm -f kronosnetd && \ $(LN_S) password-auth kronosnetd; \ else \ cd $(DESTDIR)/$(sysconfdir)/pam.d && \ rm -f kronosnetd && \ $(LN_S) passwd kronosnetd; \ fi uninstall-local: rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/cryptokeys.d || :; rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/down.d || :; rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/post-down.d || :; rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/pre-up.d || :; rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/up.d || :; rmdir $(DESTDIR)/$(DEFAULT_CONFIG_DIR) || :; rm -f $(DESTDIR)/$(sysconfdir)/logrotate.d/kronosnetd rmdir $(DESTDIR)/$(sysconfdir)/logrotate.d || :; rm -f $(DESTDIR)/$(sysconfdir)/pam.d/kronosnetd || :; rmdir $(DESTDIR)/$(sysconfdir)/pam.d || :; endif diff --git a/libknet/Makefile.am b/libknet/Makefile.am index 225d2c0c..b0a20569 100644 --- a/libknet/Makefile.am +++ b/libknet/Makefile.am @@ -1,162 +1,150 @@ # # Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. # # Authors: Fabio M. Di Nitto # Federico Simoncelli # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in include $(top_srcdir)/build-aux/check.mk SYMFILE = libknet_exported_syms EXTRA_DIST = $(SYMFILE) -SUBDIRS = . tests man +SUBDIRS = . tests -libversion = 1:0:0 +# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +libversion = 2:0:1 # override global LIBS that pulls in lots of craft we don't need here LIBS = sources = \ common.c \ compat.c \ compress.c \ crypto.c \ handle.c \ host.c \ links.c \ logging.c \ netutils.c \ threads_common.c \ threads_dsthandler.c \ threads_heartbeat.c \ threads_pmtud.c \ threads_rx.c \ threads_tx.c \ transports.c \ transport_common.c \ transport_loopback.c \ transport_udp.c \ transport_sctp.c include_HEADERS = libknet.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libknet.pc noinst_HEADERS = \ common.h \ compat.h \ compress.h \ compress_model.h \ crypto.h \ crypto_model.h \ host.h \ internals.h \ links.h \ logging.h \ netutils.h \ onwire.h \ threads_common.h \ threads_dsthandler.h \ threads_heartbeat.h \ threads_pmtud.h \ threads_rx.h \ threads_tx.h \ transports.h \ transport_common.h \ transport_loopback.h \ transport_udp.h \ transport_sctp.h lib_LTLIBRARIES = libknet.la libknet_la_SOURCES = $(sources) -libknet_la_CFLAGS = $(PTHREAD_CFLAGS) +libknet_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) EXTRA_libknet_la_DEPENDENCIES = $(SYMFILE) -libknet_la_LDFLAGS = -Wl,--version-script=$(srcdir)/$(SYMFILE) \ - --export-dynamic \ +libknet_la_LDFLAGS = $(AM_LDFLAGS) \ + -Wl,--version-script=$(srcdir)/$(SYMFILE) \ -Wl,-rpath=$(pkglibdir) \ - -version-number $(libversion) + -version-info $(libversion) libknet_la_LIBADD = $(PTHREAD_LIBS) $(dl_LIBS) $(rt_LIBS) $(m_LIBS) # Prepare empty value for appending pkglib_LTLIBRARIES = +# MODULE_LDFLAGS would mean a target-specific variable for Automake +MODULELDFLAGS = $(AM_LDFLAGS) -module -avoid-version -export-dynamic + if BUILD_COMPRESS_ZLIB pkglib_LTLIBRARIES += compress_zlib.la -compress_zlib_la_LDFLAGS = -module -avoid-version -compress_zlib_la_CFLAGS = $(zlib_CFLAGS) +compress_zlib_la_LDFLAGS = $(MODULELDFLAGS) +compress_zlib_la_CFLAGS = $(AM_CFLAGS) $(zlib_CFLAGS) compress_zlib_la_LIBADD = $(zlib_LIBS) endif if BUILD_COMPRESS_LZ4 pkglib_LTLIBRARIES += compress_lz4.la compress_lz4hc.la -compress_lz4_la_LDFLAGS = -module -avoid-version -compress_lz4_la_CFLAGS = $(liblz4_CFLAGS) +compress_lz4_la_LDFLAGS = $(MODULELDFLAGS) +compress_lz4_la_CFLAGS = $(AM_CFLAGS) $(liblz4_CFLAGS) compress_lz4_la_LIBADD = $(liblz4_LIBS) -compress_lz4hc_la_LDFLAGS = -module -avoid-version -compress_lz4hc_la_CFLAGS = $(liblz4_CFLAGS) +compress_lz4hc_la_LDFLAGS = $(MODULELDFLAGS) +compress_lz4hc_la_CFLAGS = $(AM_CFLAGS) $(liblz4_CFLAGS) compress_lz4hc_la_LIBADD = $(liblz4_LIBS) endif if BUILD_COMPRESS_LZO2 pkglib_LTLIBRARIES += compress_lzo2.la -compress_lzo2_la_LDFLAGS = -module -avoid-version -compress_lzo2_la_CFLAGS = $(lzo2_CFLAGS) +compress_lzo2_la_LDFLAGS = $(MODULELDFLAGS) +compress_lzo2_la_CFLAGS = $(AM_CFLAGS) $(lzo2_CFLAGS) compress_lzo2_la_LIBADD = $(lzo2_LIBS) endif if BUILD_COMPRESS_LZMA pkglib_LTLIBRARIES += compress_lzma.la -compress_lzma_la_LDFLAGS = -module -avoid-version -compress_lzma_la_CFLAGS = $(liblzma_CFLAGS) +compress_lzma_la_LDFLAGS = $(MODULELDFLAGS) +compress_lzma_la_CFLAGS = $(AM_CFLAGS) $(liblzma_CFLAGS) compress_lzma_la_LIBADD = $(liblzma_LIBS) endif if BUILD_COMPRESS_BZIP2 pkglib_LTLIBRARIES += compress_bzip2.la -compress_bzip2_la_LDFLAGS = -module -avoid-version -compress_bzip2_la_CFLAGS = $(bzip2_CFLAGS) +compress_bzip2_la_LDFLAGS = $(MODULELDFLAGS) +compress_bzip2_la_CFLAGS = $(AM_CFLAGS) $(bzip2_CFLAGS) compress_bzip2_la_LIBADD = $(bzip2_LIBS) endif if BUILD_CRYPTO_NSS pkglib_LTLIBRARIES += crypto_nss.la -crypto_nss_la_LDFLAGS = -module -avoid-version -crypto_nss_la_CFLAGS = $(nss_CFLAGS) +crypto_nss_la_LDFLAGS = $(MODULELDFLAGS) +crypto_nss_la_CFLAGS = $(AM_CFLAGS) $(nss_CFLAGS) crypto_nss_la_LIBADD = $(nss_LIBS) endif if BUILD_CRYPTO_OPENSSL pkglib_LTLIBRARIES += crypto_openssl.la -crypto_openssl_la_LDFLAGS = -module -avoid-version -crypto_openssl_la_CFLAGS = $(openssl_CFLAGS) +crypto_openssl_la_LDFLAGS = $(MODULELDFLAGS) +crypto_openssl_la_CFLAGS = $(AM_CFLAGS) $(openssl_CFLAGS) crypto_openssl_la_LIBADD = $(openssl_LIBS) endif - -dist_man_MANS = man - -update-man-pages: doxyfile.stamp - -doxyfile.stamp: Doxyfile -if MANPAGEUPDATES - $(DOXYGEN) Doxyfile - $(DOXY2MAN) -o $(abs_srcdir)/man -s 3 --short-pkg @PACKAGE_NAME@ --pkg "Kronosnet Programmer's Manual" $(builddir)/xml/libknet_8h.xml -else - @echo this system does not have doxy2man or doxygen installed. Unable to update man pages automatically. -endif - touch doxyfile.stamp - -clean-local: - rm -rf doxyfile.stamp xml diff --git a/libknet/common.c b/libknet/common.c index bfda7b93..957b8ab3 100644 --- a/libknet/common.c +++ b/libknet/common.c @@ -1,155 +1,155 @@ /* * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "logging.h" #include "common.h" int _fdset_cloexec(int fd) { int fdflags; fdflags = fcntl(fd, F_GETFD, 0); if (fdflags < 0) return -1; fdflags |= FD_CLOEXEC; if (fcntl(fd, F_SETFD, fdflags) < 0) return -1; return 0; } int _fdset_nonblock(int fd) { int fdflags; fdflags = fcntl(fd, F_GETFL, 0); if (fdflags < 0) return -1; fdflags |= O_NONBLOCK; if (fcntl(fd, F_SETFL, fdflags) < 0) return -1; return 0; } static void *open_lib(knet_handle_t knet_h, const char *libname, int extra_flags) { void *ret = NULL; char *error = NULL; - char dir[MAXPATHLEN], path[MAXPATHLEN], link[MAXPATHLEN]; + char dir[MAXPATHLEN], path[MAXPATHLEN * 2], link[MAXPATHLEN]; struct stat sb; /* * clear any pending error */ dlerror(); ret = dlopen(libname, RTLD_NOW | RTLD_GLOBAL | extra_flags); error = dlerror(); if (error != NULL) { log_err(knet_h, KNET_SUB_COMMON, "unable to dlopen %s: %s", libname, error); errno = EAGAIN; return NULL; } memset(dir, 0, sizeof(dir)); memset(link, 0, sizeof(link)); memset(path, 0, sizeof(path)); if (dlinfo(ret, RTLD_DI_ORIGIN, &dir) < 0) { /* * should we dlclose and return error? */ log_warn(knet_h, KNET_SUB_COMMON, "unable to dlinfo %s: %s", libname, error); } else { snprintf(path, sizeof(path), "%s/%s", dir, libname); log_info(knet_h, KNET_SUB_COMMON, "%s has been loaded from %s", libname, path); /* * try to resolve the library and check if it is a symlink and to where. * we can't prevent symlink attacks but at least we can log where the library * has been loaded from */ if (lstat(path, &sb) < 0) { log_debug(knet_h, KNET_SUB_COMMON, "Unable to stat %s: %s", path, strerror(errno)); goto out; } if (S_ISLNK(sb.st_mode)) { if (readlink(path, link, sizeof(link)) < 0) { log_debug(knet_h, KNET_SUB_COMMON, "Unable to readlink %s: %s", path, strerror(errno)); goto out; } /* * symlink is relative to the directory */ if (link[0] != '/') { snprintf(path, sizeof(path), "%s/%s", dir, link); log_info(knet_h, KNET_SUB_COMMON, "%s/%s is a symlink to %s", dir, libname, path); } else { log_info(knet_h, KNET_SUB_COMMON, "%s/%s is a symlink to %s", dir, libname, link); } } } out: return ret; } void *load_module(knet_handle_t knet_h, const char *type, const char *name) { void *module, *ops; log_msg_t **log_msg_sym; char soname[MAXPATHLEN], opsname[MAXPATHLEN]; snprintf (soname, sizeof soname, "%s_%s.so", type, name); module = open_lib(knet_h, soname, 0); if (!module) { return NULL; } log_msg_sym = dlsym (module, "log_msg"); if (!log_msg_sym) { log_err (knet_h, KNET_SUB_COMMON, "unable to map symbol 'log_msg' in module %s: %s", soname, dlerror ()); errno = EINVAL; return NULL; } *log_msg_sym = log_msg; snprintf (opsname, sizeof opsname, "%s_model", type); ops = dlsym (module, opsname); if (!ops) { log_err (knet_h, KNET_SUB_COMMON, "unable to map symbol 'model' in module %s: %s", soname, dlerror ()); errno = EINVAL; return NULL; } return ops; } diff --git a/libknet/compress_lz4.c b/libknet/compress_lz4.c index d89e6990..8f90a5a9 100644 --- a/libknet/compress_lz4.c +++ b/libknet/compress_lz4.c @@ -1,102 +1,102 @@ /* * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #define KNET_MODULE #include "config.h" #include -#include +#include #include "logging.h" #include "compress_model.h" static int lz4_val_level( knet_handle_t knet_h, int compress_level) { if (compress_level <= 0) { log_info(knet_h, KNET_SUB_LZ4COMP, "lz4 acceleration level 0 (or negatives) are automatically remapped to 1"); } return 0; } static int lz4_compress( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { int lzerr = 0, err = 0; int savederrno = 0; lzerr = LZ4_compress_fast((const char *)buf_in, (char *)buf_out, buf_in_len, KNET_DATABUFSIZE_COMPRESS, knet_h->compress_level); /* * data compressed */ if (lzerr > 0) { *buf_out_len = lzerr; } /* * unable to compress */ if (lzerr == 0) { *buf_out_len = buf_in_len; } /* * lz4 internal error */ if (lzerr < 0) { log_err(knet_h, KNET_SUB_LZ4COMP, "lz4 compression error: %d", lzerr); savederrno = EINVAL; err = -1; } errno = savederrno; return err; } static int lz4_decompress( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { int lzerr = 0, err = 0; int savederrno = 0; lzerr = LZ4_decompress_safe((const char *)buf_in, (char *)buf_out, buf_in_len, KNET_DATABUFSIZE); if (lzerr < 0) { log_err(knet_h, KNET_SUB_LZ4COMP, "lz4 decompression error: %d", lzerr); savederrno = EINVAL; err = -1; } if (lzerr > 0) { *buf_out_len = lzerr; } errno = savederrno; return err; } compress_ops_t compress_model = { KNET_COMPRESS_MODEL_ABI, NULL, NULL, NULL, lz4_val_level, lz4_compress, lz4_decompress }; diff --git a/libknet/compress_lz4hc.c b/libknet/compress_lz4hc.c index 3832cb59..aa832af6 100644 --- a/libknet/compress_lz4hc.c +++ b/libknet/compress_lz4hc.c @@ -1,117 +1,123 @@ /* * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #define KNET_MODULE #include "config.h" #include +#include #include #include "logging.h" #include "compress_model.h" #ifdef LZ4HC_CLEVEL_MAX #define KNET_LZ4HC_MAX LZ4HC_CLEVEL_MAX #endif #ifdef LZ4HC_MAX_CLEVEL #define KNET_LZ4HC_MAX LZ4HC_MAX_CLEVEL #endif #ifndef KNET_LZ4HC_MAX -#define KNET_LZ4HC_MAX 0 -#error Please check lz4hc.h for missing LZ4HC_CLEVEL_MAX or LZ4HC_MAX_CLEVEL variants +/* + * older releases of lz4 do not define LZ4HC_CLEVEL range. + * According to lz4hc.h, any value between 0 and 16 is valid. + * We defalt to 16 based on the comments in the include file + * from older versions. + */ +#define KNET_LZ4HC_MAX 16 #endif static int lz4hc_val_level( knet_handle_t knet_h, int compress_level) { if (compress_level < 1) { log_err(knet_h, KNET_SUB_LZ4HCCOMP, "lz4hc supports only 1+ values for compression level"); errno = EINVAL; return -1; } if (compress_level < 4) { log_info(knet_h, KNET_SUB_LZ4HCCOMP, "lz4hc recommends 4+ compression level for better results"); } if (compress_level > KNET_LZ4HC_MAX) { log_warn(knet_h, KNET_SUB_LZ4HCCOMP, "lz4hc installed on this system supports up to compression level %d. Higher values behaves as %d", KNET_LZ4HC_MAX, KNET_LZ4HC_MAX); } return 0; } static int lz4hc_compress( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { int lzerr = 0, err = 0; int savederrno = 0; lzerr = LZ4_compress_HC((const char *)buf_in, (char *)buf_out, buf_in_len, KNET_DATABUFSIZE_COMPRESS, knet_h->compress_level); /* * data compressed */ if (lzerr > 0) { *buf_out_len = lzerr; } /* * unable to compress */ if (lzerr <= 0) { log_err(knet_h, KNET_SUB_LZ4HCCOMP, "lz4hc compression error: %d", lzerr); savederrno = EINVAL; err = -1; } errno = savederrno; return err; } /* This is a straight copy from compress_lz4.c */ static int lz4_decompress( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { int lzerr = 0, err = 0; int savederrno = 0; lzerr = LZ4_decompress_safe((const char *)buf_in, (char *)buf_out, buf_in_len, KNET_DATABUFSIZE); if (lzerr < 0) { log_err(knet_h, KNET_SUB_LZ4COMP, "lz4 decompression error: %d", lzerr); savederrno = EINVAL; err = -1; } if (lzerr > 0) { *buf_out_len = lzerr; } errno = savederrno; return err; } compress_ops_t compress_model = { KNET_COMPRESS_MODEL_ABI, NULL, NULL, NULL, lz4hc_val_level, lz4hc_compress, lz4_decompress }; diff --git a/libknet/crypto.c b/libknet/crypto.c index accc5cd4..43c21994 100644 --- a/libknet/crypto.c +++ b/libknet/crypto.c @@ -1,207 +1,212 @@ /* * Copyright (C) 2012-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include "crypto.h" #include "crypto_model.h" #include "internals.h" #include "logging.h" #include "common.h" /* * internal module switch data */ crypto_model_t crypto_modules_cmds[] = { { "nss", WITH_CRYPTO_NSS, 0, NULL }, { "openssl", WITH_CRYPTO_OPENSSL, 0, NULL }, { NULL, 0, 0, NULL } }; static int crypto_get_model(const char *model) { int idx = 0; while (crypto_modules_cmds[idx].model_name != NULL) { if (!strcmp(crypto_modules_cmds[idx].model_name, model)) return idx; idx++; } return -1; } /* * exported API */ int crypto_encrypt_and_sign ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { return crypto_modules_cmds[knet_h->crypto_instance->model].ops->crypt(knet_h, buf_in, buf_in_len, buf_out, buf_out_len); } int crypto_encrypt_and_signv ( knet_handle_t knet_h, const struct iovec *iov_in, int iovcnt_in, unsigned char *buf_out, ssize_t *buf_out_len) { return crypto_modules_cmds[knet_h->crypto_instance->model].ops->cryptv(knet_h, iov_in, iovcnt_in, buf_out, buf_out_len); } int crypto_authenticate_and_decrypt ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { return crypto_modules_cmds[knet_h->crypto_instance->model].ops->decrypt(knet_h, buf_in, buf_in_len, buf_out, buf_out_len); } int crypto_init( knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg) { int savederrno = 0; int model = 0; model = crypto_get_model(knet_handle_crypto_cfg->crypto_model); if (model < 0) { log_err(knet_h, KNET_SUB_CRYPTO, "model %s not supported", knet_handle_crypto_cfg->crypto_model); return -1; } if (crypto_modules_cmds[model].built_in == 0) { log_err(knet_h, KNET_SUB_CRYPTO, "this version of libknet was built without %s support. Please contact your vendor or fix the build.", knet_handle_crypto_cfg->crypto_model); return -1; } savederrno = pthread_rwlock_wrlock(&shlib_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_CRYPTO, "Unable to get write lock: %s", strerror(savederrno)); return -1; } if (!crypto_modules_cmds[model].loaded) { crypto_modules_cmds[model].ops = load_module (knet_h, "crypto", crypto_modules_cmds[model].model_name); if (!crypto_modules_cmds[model].ops) { + savederrno = errno; log_err(knet_h, KNET_SUB_CRYPTO, "Unable to load %s lib", crypto_modules_cmds[model].model_name); goto out_err; } if (crypto_modules_cmds[model].ops->abi_ver != KNET_CRYPTO_MODEL_ABI) { log_err(knet_h, KNET_SUB_CRYPTO, "ABI mismatch loading module %s. knet ver: %d, module ver: %d", crypto_modules_cmds[model].model_name, KNET_CRYPTO_MODEL_ABI, crypto_modules_cmds[model].ops->abi_ver); - errno = EINVAL; + savederrno = EINVAL; goto out_err; } crypto_modules_cmds[model].loaded = 1; } log_debug(knet_h, KNET_SUB_CRYPTO, "Initizializing crypto module [%s/%s/%s]", knet_handle_crypto_cfg->crypto_model, knet_handle_crypto_cfg->crypto_cipher_type, knet_handle_crypto_cfg->crypto_hash_type); knet_h->crypto_instance = malloc(sizeof(struct crypto_instance)); if (!knet_h->crypto_instance) { log_err(knet_h, KNET_SUB_CRYPTO, "Unable to allocate memory for crypto instance"); pthread_rwlock_unlock(&shlib_rwlock); + savederrno = ENOMEM; goto out_err; } /* * if crypto_modules_cmds.ops->init fails, it is expected that * it will clean everything by itself. * crypto_modules_cmds.ops->fini is not invoked on error. */ knet_h->crypto_instance->model = model; - if (crypto_modules_cmds[knet_h->crypto_instance->model].ops->init(knet_h, knet_handle_crypto_cfg)) + if (crypto_modules_cmds[knet_h->crypto_instance->model].ops->init(knet_h, knet_handle_crypto_cfg)) { + savederrno = errno; goto out_err; + } log_debug(knet_h, KNET_SUB_CRYPTO, "security network overhead: %zu", knet_h->sec_header_size); pthread_rwlock_unlock(&shlib_rwlock); return 0; out_err: if (knet_h->crypto_instance) { free(knet_h->crypto_instance); knet_h->crypto_instance = NULL; } pthread_rwlock_unlock(&shlib_rwlock); + errno = savederrno; return -1; } void crypto_fini( knet_handle_t knet_h) { int savederrno = 0; int model = 0; savederrno = pthread_rwlock_wrlock(&shlib_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_CRYPTO, "Unable to get write lock: %s", strerror(savederrno)); return; } if (knet_h->crypto_instance) { model = knet_h->crypto_instance->model; if (crypto_modules_cmds[model].ops->fini != NULL) { crypto_modules_cmds[model].ops->fini(knet_h); } free(knet_h->crypto_instance); knet_h->crypto_instance = NULL; } pthread_rwlock_unlock(&shlib_rwlock); return; } int knet_get_crypto_list(struct knet_crypto_info *crypto_list, size_t *crypto_list_entries) { int err = 0; int idx = 0; int outidx = 0; if (!crypto_list_entries) { errno = EINVAL; return -1; } while (crypto_modules_cmds[idx].model_name != NULL) { if (crypto_modules_cmds[idx].built_in) { if (crypto_list) { crypto_list[outidx].name = crypto_modules_cmds[idx].model_name; } outidx++; } idx++; } *crypto_list_entries = outidx; return err; } diff --git a/libknet/crypto_nss.c b/libknet/crypto_nss.c index 6b5da122..b2eff193 100644 --- a/libknet/crypto_nss.c +++ b/libknet/crypto_nss.c @@ -1,810 +1,820 @@ /* * Copyright (C) 2012-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #define KNET_MODULE #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "crypto_model.h" #include "logging.h" static int nss_db_is_init = 0; static void nss_atexit_handler(void) { if (nss_db_is_init) { NSS_Shutdown(); if (PR_Initialized()) { PL_ArenaFinish(); PR_Cleanup(); } } return; } /* * crypto definitions and conversion tables */ #define SALT_SIZE 16 /* * This are defined in new NSS. For older one, we will define our own */ #ifndef AES_256_KEY_LENGTH #define AES_256_KEY_LENGTH 32 #endif #ifndef AES_192_KEY_LENGTH #define AES_192_KEY_LENGTH 24 #endif #ifndef AES_128_KEY_LENGTH #define AES_128_KEY_LENGTH 16 #endif enum nsscrypto_crypt_t { CRYPTO_CIPHER_TYPE_NONE = 0, CRYPTO_CIPHER_TYPE_AES256 = 1, CRYPTO_CIPHER_TYPE_AES192 = 2, CRYPTO_CIPHER_TYPE_AES128 = 3, CRYPTO_CIPHER_TYPE_3DES = 4 }; CK_MECHANISM_TYPE cipher_to_nss[] = { 0, /* CRYPTO_CIPHER_TYPE_NONE */ CKM_AES_CBC_PAD, /* CRYPTO_CIPHER_TYPE_AES256 */ CKM_AES_CBC_PAD, /* CRYPTO_CIPHER_TYPE_AES192 */ CKM_AES_CBC_PAD, /* CRYPTO_CIPHER_TYPE_AES128 */ CKM_DES3_CBC_PAD /* CRYPTO_CIPHER_TYPE_3DES */ }; size_t nsscipher_key_len[] = { 0, /* CRYPTO_CIPHER_TYPE_NONE */ AES_256_KEY_LENGTH, /* CRYPTO_CIPHER_TYPE_AES256 */ AES_192_KEY_LENGTH, /* CRYPTO_CIPHER_TYPE_AES192 */ AES_128_KEY_LENGTH, /* CRYPTO_CIPHER_TYPE_AES128 */ 24 /* CRYPTO_CIPHER_TYPE_3DES */ }; size_t nsscypher_block_len[] = { 0, /* CRYPTO_CIPHER_TYPE_NONE */ AES_BLOCK_SIZE, /* CRYPTO_CIPHER_TYPE_AES256 */ AES_BLOCK_SIZE, /* CRYPTO_CIPHER_TYPE_AES192 */ AES_BLOCK_SIZE, /* CRYPTO_CIPHER_TYPE_AES128 */ 0 /* CRYPTO_CIPHER_TYPE_3DES */ }; /* * hash definitions and conversion tables */ enum nsscrypto_hash_t { CRYPTO_HASH_TYPE_NONE = 0, CRYPTO_HASH_TYPE_MD5 = 1, CRYPTO_HASH_TYPE_SHA1 = 2, CRYPTO_HASH_TYPE_SHA256 = 3, CRYPTO_HASH_TYPE_SHA384 = 4, CRYPTO_HASH_TYPE_SHA512 = 5 }; CK_MECHANISM_TYPE hash_to_nss[] = { 0, /* CRYPTO_HASH_TYPE_NONE */ CKM_MD5_HMAC, /* CRYPTO_HASH_TYPE_MD5 */ CKM_SHA_1_HMAC, /* CRYPTO_HASH_TYPE_SHA1 */ CKM_SHA256_HMAC, /* CRYPTO_HASH_TYPE_SHA256 */ CKM_SHA384_HMAC, /* CRYPTO_HASH_TYPE_SHA384 */ CKM_SHA512_HMAC /* CRYPTO_HASH_TYPE_SHA512 */ }; size_t nsshash_len[] = { 0, /* CRYPTO_HASH_TYPE_NONE */ MD5_LENGTH, /* CRYPTO_HASH_TYPE_MD5 */ SHA1_LENGTH, /* CRYPTO_HASH_TYPE_SHA1 */ SHA256_LENGTH, /* CRYPTO_HASH_TYPE_SHA256 */ SHA384_LENGTH, /* CRYPTO_HASH_TYPE_SHA384 */ SHA512_LENGTH /* CRYPTO_HASH_TYPE_SHA512 */ }; enum sym_key_type { SYM_KEY_TYPE_CRYPT, SYM_KEY_TYPE_HASH }; struct nsscrypto_instance { PK11SymKey *nss_sym_key; PK11SymKey *nss_sym_key_sign; unsigned char *private_key; unsigned int private_key_len; int crypto_cipher_type; int crypto_hash_type; }; /* * crypt/decrypt functions */ static int nssstring_to_crypto_cipher_type(const char* crypto_cipher_type) { if (strcmp(crypto_cipher_type, "none") == 0) { return CRYPTO_CIPHER_TYPE_NONE; } else if (strcmp(crypto_cipher_type, "aes256") == 0) { return CRYPTO_CIPHER_TYPE_AES256; } else if (strcmp(crypto_cipher_type, "aes192") == 0) { return CRYPTO_CIPHER_TYPE_AES192; } else if (strcmp(crypto_cipher_type, "aes128") == 0) { return CRYPTO_CIPHER_TYPE_AES128; } else if (strcmp(crypto_cipher_type, "3des") == 0) { return CRYPTO_CIPHER_TYPE_3DES; } return -1; } static PK11SymKey *nssimport_symmetric_key(knet_handle_t knet_h, enum sym_key_type key_type) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; SECItem key_item; PK11SlotInfo *slot; PK11SymKey *res_key; CK_MECHANISM_TYPE cipher; CK_ATTRIBUTE_TYPE operation; CK_MECHANISM_TYPE wrap_mechanism; int wrap_key_len; PK11SymKey *wrap_key; PK11Context *wrap_key_crypt_context; SECItem tmp_sec_item; SECItem wrapped_key; int wrapped_key_len; unsigned char wrapped_key_data[KNET_MAX_KEY_LEN]; memset(&key_item, 0, sizeof(key_item)); slot = NULL; wrap_key = NULL; res_key = NULL; wrap_key_crypt_context = NULL; key_item.type = siBuffer; key_item.data = instance->private_key; switch (key_type) { case SYM_KEY_TYPE_CRYPT: key_item.len = nsscipher_key_len[instance->crypto_cipher_type]; cipher = cipher_to_nss[instance->crypto_cipher_type]; operation = CKA_ENCRYPT|CKA_DECRYPT; break; case SYM_KEY_TYPE_HASH: key_item.len = instance->private_key_len; cipher = hash_to_nss[instance->crypto_hash_type]; operation = CKA_SIGN; break; default: log_err(knet_h, KNET_SUB_NSSCRYPTO, "Import symmetric key failed. Unknown keyimport request"); goto exit_res_key; break; } slot = PK11_GetBestSlot(cipher, NULL); if (slot == NULL) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to find security slot (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto exit_res_key; } /* * Without FIPS it would be possible to just use * res_key = PK11_ImportSymKey(slot, cipher, PK11_OriginUnwrap, operation, &key_item, NULL); * with FIPS NSS Level 2 certification has to be "workarounded" (so it becomes Level 1) by using * following method: * 1. Generate wrap key * 2. Encrypt authkey with wrap key * 3. Unwrap encrypted authkey using wrap key */ /* * Generate wrapping key */ wrap_mechanism = PK11_GetBestWrapMechanism(slot); wrap_key_len = PK11_GetBestKeyLength(slot, wrap_mechanism); wrap_key = PK11_KeyGen(slot, wrap_mechanism, NULL, wrap_key_len, NULL); if (wrap_key == NULL) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to generate wrapping key (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto exit_res_key; } /* * Encrypt authkey with wrapping key */ /* * Initialization of IV is not needed because PK11_GetBestWrapMechanism should return ECB mode */ memset(&tmp_sec_item, 0, sizeof(tmp_sec_item)); wrap_key_crypt_context = PK11_CreateContextBySymKey(wrap_mechanism, CKA_ENCRYPT, wrap_key, &tmp_sec_item); if (wrap_key_crypt_context == NULL) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to create encrypt context (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto exit_res_key; } wrapped_key_len = (int)sizeof(wrapped_key_data); if (PK11_CipherOp(wrap_key_crypt_context, wrapped_key_data, &wrapped_key_len, sizeof(wrapped_key_data), key_item.data, key_item.len) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to encrypt authkey (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto exit_res_key; } if (PK11_Finalize(wrap_key_crypt_context) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to finalize encryption of authkey (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto exit_res_key; } /* * Finally unwrap sym key */ memset(&tmp_sec_item, 0, sizeof(tmp_sec_item)); wrapped_key.data = wrapped_key_data; wrapped_key.len = wrapped_key_len; res_key = PK11_UnwrapSymKey(wrap_key, wrap_mechanism, &tmp_sec_item, &wrapped_key, cipher, operation, key_item.len); if (res_key == NULL) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Failure to import key into NSS (%d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); if (PR_GetError() == SEC_ERROR_BAD_DATA) { /* * Maximum key length for FIPS enabled softtoken is limited to * MAX_KEY_LEN (pkcs11i.h - 256) and checked in NSC_UnwrapKey. Returned * error is CKR_TEMPLATE_INCONSISTENT which is mapped to SEC_ERROR_BAD_DATA. */ log_err(knet_h, KNET_SUB_NSSCRYPTO, "Secret key is probably too long. " "Try reduce it to 256 bytes"); } goto exit_res_key; } exit_res_key: if (wrap_key_crypt_context != NULL) { PK11_DestroyContext(wrap_key_crypt_context, PR_TRUE); } if (wrap_key != NULL) { PK11_FreeSymKey(wrap_key); } if (slot != NULL) { PK11_FreeSlot(slot); } return (res_key); } static int init_nss_crypto(knet_handle_t knet_h) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; if (!cipher_to_nss[instance->crypto_cipher_type]) { return 0; } instance->nss_sym_key = nssimport_symmetric_key(knet_h, SYM_KEY_TYPE_CRYPT); if (instance->nss_sym_key == NULL) { + errno = ENXIO; /* NSS reported error */ return -1; } return 0; } static int encrypt_nss( knet_handle_t knet_h, const struct iovec *iov, int iovcnt, unsigned char *buf_out, ssize_t *buf_out_len) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; PK11Context* crypt_context = NULL; SECItem crypt_param; SECItem *nss_sec_param = NULL; int tmp_outlen = 0, tmp1_outlen = 0; unsigned int tmp2_outlen = 0; unsigned char *salt = buf_out; unsigned char *data = buf_out + SALT_SIZE; int err = -1; int i; if (PK11_GenerateRandom(salt, SALT_SIZE) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Failure to generate a random number (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } crypt_param.type = siBuffer; crypt_param.data = salt; crypt_param.len = SALT_SIZE; nss_sec_param = PK11_ParamFromIV(cipher_to_nss[instance->crypto_cipher_type], &crypt_param); if (nss_sec_param == NULL) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Failure to set up PKCS11 param (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } /* * Create cipher context for encryption */ crypt_context = PK11_CreateContextBySymKey(cipher_to_nss[instance->crypto_cipher_type], CKA_ENCRYPT, instance->nss_sym_key, nss_sec_param); if (!crypt_context) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_CreateContext failed (encrypt) crypt_type=%d (err %d): %s", (int)cipher_to_nss[instance->crypto_cipher_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } for (i=0; icrypto_cipher_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } tmp1_outlen = tmp1_outlen + tmp_outlen; } if (PK11_DigestFinal(crypt_context, data + tmp1_outlen, &tmp2_outlen, KNET_DATABUFSIZE_CRYPT - tmp1_outlen) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_DigestFinal failed (encrypt) crypt_type=%d (err %d): %s", (int)cipher_to_nss[instance->crypto_cipher_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } *buf_out_len = tmp1_outlen + tmp2_outlen + SALT_SIZE; err = 0; out: if (crypt_context) { PK11_DestroyContext(crypt_context, PR_TRUE); } if (nss_sec_param) { SECITEM_FreeItem(nss_sec_param, PR_TRUE); } return err; } static int decrypt_nss ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; PK11Context* decrypt_context = NULL; SECItem decrypt_param; int tmp1_outlen = 0; unsigned int tmp2_outlen = 0; unsigned char *salt = (unsigned char *)buf_in; unsigned char *data = salt + SALT_SIZE; int datalen = buf_in_len - SALT_SIZE; int err = -1; /* Create cipher context for decryption */ decrypt_param.type = siBuffer; decrypt_param.data = salt; decrypt_param.len = SALT_SIZE; decrypt_context = PK11_CreateContextBySymKey(cipher_to_nss[instance->crypto_cipher_type], CKA_DECRYPT, instance->nss_sym_key, &decrypt_param); if (!decrypt_context) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_CreateContext (decrypt) failed (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } if (PK11_CipherOp(decrypt_context, buf_out, &tmp1_outlen, KNET_DATABUFSIZE_CRYPT, data, datalen) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_CipherOp (decrypt) failed (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } if (PK11_DigestFinal(decrypt_context, buf_out + tmp1_outlen, &tmp2_outlen, KNET_DATABUFSIZE_CRYPT - tmp1_outlen) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_DigestFinal (decrypt) failed (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } *buf_out_len = tmp1_outlen + tmp2_outlen; err = 0; out: if (decrypt_context) { PK11_DestroyContext(decrypt_context, PR_TRUE); } return err; } /* * hash/hmac/digest functions */ static int nssstring_to_crypto_hash_type(const char* crypto_hash_type) { if (strcmp(crypto_hash_type, "none") == 0) { return CRYPTO_HASH_TYPE_NONE; } else if (strcmp(crypto_hash_type, "md5") == 0) { return CRYPTO_HASH_TYPE_MD5; } else if (strcmp(crypto_hash_type, "sha1") == 0) { return CRYPTO_HASH_TYPE_SHA1; } else if (strcmp(crypto_hash_type, "sha256") == 0) { return CRYPTO_HASH_TYPE_SHA256; } else if (strcmp(crypto_hash_type, "sha384") == 0) { return CRYPTO_HASH_TYPE_SHA384; } else if (strcmp(crypto_hash_type, "sha512") == 0) { return CRYPTO_HASH_TYPE_SHA512; } return -1; } static int init_nss_hash(knet_handle_t knet_h) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; if (!hash_to_nss[instance->crypto_hash_type]) { return 0; } instance->nss_sym_key_sign = nssimport_symmetric_key(knet_h, SYM_KEY_TYPE_HASH); if (instance->nss_sym_key_sign == NULL) { + errno = ENXIO; /* NSS reported error */ return -1; } return 0; } static int calculate_nss_hash( knet_handle_t knet_h, const unsigned char *buf, const size_t buf_len, unsigned char *hash) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; PK11Context* hash_context = NULL; SECItem hash_param; unsigned int hash_tmp_outlen = 0; int err = -1; /* Now do the digest */ hash_param.type = siBuffer; hash_param.data = 0; hash_param.len = 0; hash_context = PK11_CreateContextBySymKey(hash_to_nss[instance->crypto_hash_type], CKA_SIGN, instance->nss_sym_key_sign, &hash_param); if (!hash_context) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_CreateContext failed (hash) hash_type=%d (err %d): %s", (int)hash_to_nss[instance->crypto_hash_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } if (PK11_DigestBegin(hash_context) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_DigestBegin failed (hash) hash_type=%d (err %d): %s", (int)hash_to_nss[instance->crypto_hash_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } if (PK11_DigestOp(hash_context, buf, buf_len) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_DigestOp failed (hash) hash_type=%d (err %d): %s", (int)hash_to_nss[instance->crypto_hash_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } if (PK11_DigestFinal(hash_context, hash, &hash_tmp_outlen, nsshash_len[instance->crypto_hash_type]) != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "PK11_DigestFinale failed (hash) hash_type=%d (err %d): %s", (int)hash_to_nss[instance->crypto_hash_type], PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); goto out; } err = 0; out: if (hash_context) { PK11_DestroyContext(hash_context, PR_TRUE); } return err; } /* * global/glue nss functions */ static int init_nss(knet_handle_t knet_h) { static int at_exit_registered = 0; if (!at_exit_registered) { if (atexit(nss_atexit_handler)) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to register NSS atexit handler"); errno = EAGAIN; return -1; } at_exit_registered = 1; } if (!nss_db_is_init) { if (NSS_NoDB_Init(".") != SECSuccess) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "NSS DB initialization failed (err %d): %s", PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT)); errno = EAGAIN; return -1; } nss_db_is_init = 1; } if (init_nss_crypto(knet_h) < 0) { return -1; } if (init_nss_hash(knet_h) < 0) { return -1; } return 0; } /* * exported API */ static int nsscrypto_encrypt_and_signv ( knet_handle_t knet_h, const struct iovec *iov_in, int iovcnt_in, unsigned char *buf_out, ssize_t *buf_out_len) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; int i; if (cipher_to_nss[instance->crypto_cipher_type]) { if (encrypt_nss(knet_h, iov_in, iovcnt_in, buf_out, buf_out_len) < 0) { return -1; } } else { *buf_out_len = 0; for (i=0; icrypto_hash_type]) { if (calculate_nss_hash(knet_h, buf_out, *buf_out_len, buf_out + *buf_out_len) < 0) { return -1; } *buf_out_len = *buf_out_len + nsshash_len[instance->crypto_hash_type]; } return 0; } static int nsscrypto_encrypt_and_sign ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { struct iovec iov_in; memset(&iov_in, 0, sizeof(iov_in)); iov_in.iov_base = (unsigned char *)buf_in; iov_in.iov_len = buf_in_len; return nsscrypto_encrypt_and_signv(knet_h, &iov_in, 1, buf_out, buf_out_len); } static int nsscrypto_authenticate_and_decrypt ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { struct nsscrypto_instance *instance = knet_h->crypto_instance->model_instance; ssize_t temp_len = buf_in_len; if (hash_to_nss[instance->crypto_hash_type]) { unsigned char tmp_hash[nsshash_len[instance->crypto_hash_type]]; ssize_t temp_buf_len = buf_in_len - nsshash_len[instance->crypto_hash_type]; if ((temp_buf_len < 0) || (temp_buf_len > KNET_MAX_PACKET_SIZE)) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Incorrect packet size."); return -1; } if (calculate_nss_hash(knet_h, buf_in, temp_buf_len, tmp_hash) < 0) { return -1; } if (memcmp(tmp_hash, buf_in + temp_buf_len, nsshash_len[instance->crypto_hash_type]) != 0) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Digest does not match"); return -1; } temp_len = temp_len - nsshash_len[instance->crypto_hash_type]; *buf_out_len = temp_len; } if (cipher_to_nss[instance->crypto_cipher_type]) { if (decrypt_nss(knet_h, buf_in, temp_len, buf_out, buf_out_len) < 0) { return -1; } } else { memmove(buf_out, buf_in, temp_len); *buf_out_len = temp_len; } return 0; } static void nsscrypto_fini( knet_handle_t knet_h) { struct nsscrypto_instance *nsscrypto_instance = knet_h->crypto_instance->model_instance; if (nsscrypto_instance) { if (nsscrypto_instance->nss_sym_key) { PK11_FreeSymKey(nsscrypto_instance->nss_sym_key); nsscrypto_instance->nss_sym_key = NULL; } if (nsscrypto_instance->nss_sym_key_sign) { PK11_FreeSymKey(nsscrypto_instance->nss_sym_key_sign); nsscrypto_instance->nss_sym_key_sign = NULL; } free(nsscrypto_instance); knet_h->crypto_instance->model_instance = NULL; knet_h->sec_header_size = 0; } return; } static int nsscrypto_init( knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg) { struct nsscrypto_instance *nsscrypto_instance = NULL; + int savederrno; log_debug(knet_h, KNET_SUB_NSSCRYPTO, "Initizializing nss crypto module [%s/%s]", knet_handle_crypto_cfg->crypto_cipher_type, knet_handle_crypto_cfg->crypto_hash_type); knet_h->crypto_instance->model_instance = malloc(sizeof(struct nsscrypto_instance)); if (!knet_h->crypto_instance->model_instance) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "Unable to allocate memory for nss model instance"); + savederrno = ENOMEM; return -1; } nsscrypto_instance = knet_h->crypto_instance->model_instance; memset(nsscrypto_instance, 0, sizeof(struct nsscrypto_instance)); nsscrypto_instance->crypto_cipher_type = nssstring_to_crypto_cipher_type(knet_handle_crypto_cfg->crypto_cipher_type); if (nsscrypto_instance->crypto_cipher_type < 0) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "unknown crypto cipher type requested"); + savederrno = ENXIO; goto out_err; } nsscrypto_instance->crypto_hash_type = nssstring_to_crypto_hash_type(knet_handle_crypto_cfg->crypto_hash_type); if (nsscrypto_instance->crypto_hash_type < 0) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "unknown crypto hash type requested"); + savederrno = ENXIO; goto out_err; } if ((nsscrypto_instance->crypto_cipher_type > 0) && (nsscrypto_instance->crypto_hash_type == 0)) { log_err(knet_h, KNET_SUB_NSSCRYPTO, "crypto communication requires hash specified"); + savederrno = EINVAL; goto out_err; } nsscrypto_instance->private_key = knet_handle_crypto_cfg->private_key; nsscrypto_instance->private_key_len = knet_handle_crypto_cfg->private_key_len; if (init_nss(knet_h) < 0) { + savederrno = errno; goto out_err; } knet_h->sec_header_size = 0; if (nsscrypto_instance->crypto_hash_type > 0) { knet_h->sec_header_size += nsshash_len[nsscrypto_instance->crypto_hash_type]; knet_h->sec_hash_size = nsshash_len[nsscrypto_instance->crypto_hash_type]; } if (nsscrypto_instance->crypto_cipher_type > 0) { int block_size; if (nsscypher_block_len[nsscrypto_instance->crypto_cipher_type]) { block_size = nsscypher_block_len[nsscrypto_instance->crypto_cipher_type]; } else { block_size = PK11_GetBlockSize(nsscrypto_instance->crypto_cipher_type, NULL); if (block_size < 0) { + savederrno = ENXIO; goto out_err; } } knet_h->sec_header_size += (block_size * 2); knet_h->sec_header_size += SALT_SIZE; knet_h->sec_salt_size = SALT_SIZE; knet_h->sec_block_size = block_size; } return 0; out_err: nsscrypto_fini(knet_h); + errno = savederrno; return -1; } crypto_ops_t crypto_model = { KNET_CRYPTO_MODEL_ABI, nsscrypto_init, nsscrypto_fini, nsscrypto_encrypt_and_sign, nsscrypto_encrypt_and_signv, nsscrypto_authenticate_and_decrypt }; diff --git a/libknet/crypto_openssl.c b/libknet/crypto_openssl.c index 60a6a385..13e2d8f4 100644 --- a/libknet/crypto_openssl.c +++ b/libknet/crypto_openssl.c @@ -1,602 +1,606 @@ /* * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #define KNET_MODULE #include "config.h" #include #include #include #include #include #include #include #include #include "logging.h" #include "crypto_model.h" /* * 1.0.2 requires at least 120 bytes * 1.1.0 requires at least 256 bytes */ #define SSLERR_BUF_SIZE 512 /* * crypto definitions and conversion tables */ #define SALT_SIZE 16 struct opensslcrypto_instance { void *private_key; int private_key_len; const EVP_CIPHER *crypto_cipher_type; const EVP_MD *crypto_hash_type; }; /* * crypt/decrypt functions openssl1.0 */ #ifdef BUILDCRYPTOOPENSSL10 static int encrypt_openssl( knet_handle_t knet_h, const struct iovec *iov, int iovcnt, unsigned char *buf_out, ssize_t *buf_out_len) { struct opensslcrypto_instance *instance = knet_h->crypto_instance->model_instance; EVP_CIPHER_CTX ctx; int tmplen = 0, offset = 0; unsigned char *salt = buf_out; unsigned char *data = buf_out + SALT_SIZE; int err = 0; int i; char sslerr[SSLERR_BUF_SIZE]; EVP_CIPHER_CTX_init(&ctx); /* * contribute to PRNG for each packet we send/receive */ RAND_seed((unsigned char *)iov[iovcnt - 1].iov_base, iov[iovcnt - 1].iov_len); if (!RAND_bytes(salt, SALT_SIZE)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to get random salt data: %s", sslerr); err = -1; goto out; } /* * add warning re keylength */ EVP_EncryptInit_ex(&ctx, instance->crypto_cipher_type, NULL, instance->private_key, salt); for (i=0; icrypto_instance->model_instance; EVP_CIPHER_CTX ctx; int tmplen1 = 0, tmplen2 = 0; unsigned char *salt = (unsigned char *)buf_in; unsigned char *data = salt + SALT_SIZE; int datalen = buf_in_len - SALT_SIZE; int err = 0; char sslerr[SSLERR_BUF_SIZE]; EVP_CIPHER_CTX_init(&ctx); /* * contribute to PRNG for each packet we send/receive */ RAND_seed(buf_in, buf_in_len); /* * add warning re keylength */ EVP_DecryptInit_ex(&ctx, instance->crypto_cipher_type, NULL, instance->private_key, salt); if (!EVP_DecryptUpdate(&ctx, buf_out, &tmplen1, data, datalen)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to decrypt: %s", sslerr); err = -1; goto out; } if (!EVP_DecryptFinal_ex(&ctx, buf_out + tmplen1, &tmplen2)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to finalize decrypt: %s", sslerr); err = -1; goto out; } *buf_out_len = tmplen1 + tmplen2; out: EVP_CIPHER_CTX_cleanup(&ctx); return err; } #endif #ifdef BUILDCRYPTOOPENSSL11 static int encrypt_openssl( knet_handle_t knet_h, const struct iovec *iov, int iovcnt, unsigned char *buf_out, ssize_t *buf_out_len) { struct opensslcrypto_instance *instance = knet_h->crypto_instance->model_instance; EVP_CIPHER_CTX *ctx; int tmplen = 0, offset = 0; unsigned char *salt = buf_out; unsigned char *data = buf_out + SALT_SIZE; int err = 0; int i; char sslerr[SSLERR_BUF_SIZE]; ctx = EVP_CIPHER_CTX_new(); /* * contribute to PRNG for each packet we send/receive */ RAND_seed((unsigned char *)iov[iovcnt - 1].iov_base, iov[iovcnt - 1].iov_len); if (!RAND_bytes(salt, SALT_SIZE)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to get random salt data: %s", sslerr); err = -1; goto out; } /* * add warning re keylength */ EVP_EncryptInit_ex(ctx, instance->crypto_cipher_type, NULL, instance->private_key, salt); for (i=0; icrypto_instance->model_instance; EVP_CIPHER_CTX *ctx; int tmplen1 = 0, tmplen2 = 0; unsigned char *salt = (unsigned char *)buf_in; unsigned char *data = salt + SALT_SIZE; int datalen = buf_in_len - SALT_SIZE; int err = 0; char sslerr[SSLERR_BUF_SIZE]; ctx = EVP_CIPHER_CTX_new(); /* * contribute to PRNG for each packet we send/receive */ RAND_seed(buf_in, buf_in_len); /* * add warning re keylength */ EVP_DecryptInit_ex(ctx, instance->crypto_cipher_type, NULL, instance->private_key, salt); if (!EVP_DecryptUpdate(ctx, buf_out, &tmplen1, data, datalen)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to decrypt: %s", sslerr); err = -1; goto out; } if (!EVP_DecryptFinal_ex(ctx, buf_out + tmplen1, &tmplen2)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to finalize decrypt: %s", sslerr); err = -1; goto out; } *buf_out_len = tmplen1 + tmplen2; out: EVP_CIPHER_CTX_free(ctx); return err; } #endif /* * hash/hmac/digest functions */ static int calculate_openssl_hash( knet_handle_t knet_h, const unsigned char *buf, const size_t buf_len, unsigned char *hash) { struct opensslcrypto_instance *instance = knet_h->crypto_instance->model_instance; unsigned int hash_len = 0; unsigned char *hash_out = NULL; char sslerr[SSLERR_BUF_SIZE]; hash_out = HMAC(instance->crypto_hash_type, instance->private_key, instance->private_key_len, buf, buf_len, hash, &hash_len); if ((!hash_out) || (hash_len != knet_h->sec_hash_size)) { ERR_error_string_n(ERR_get_error(), sslerr, sizeof(sslerr)); log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to calculate hash: %s", sslerr); return -1; } return 0; } /* * exported API */ static int opensslcrypto_encrypt_and_signv ( knet_handle_t knet_h, const struct iovec *iov_in, int iovcnt_in, unsigned char *buf_out, ssize_t *buf_out_len) { struct opensslcrypto_instance *instance = knet_h->crypto_instance->model_instance; int i; if (instance->crypto_cipher_type) { if (encrypt_openssl(knet_h, iov_in, iovcnt_in, buf_out, buf_out_len) < 0) { return -1; } } else { *buf_out_len = 0; for (i=0; icrypto_hash_type) { if (calculate_openssl_hash(knet_h, buf_out, *buf_out_len, buf_out + *buf_out_len) < 0) { return -1; } *buf_out_len = *buf_out_len + knet_h->sec_hash_size; } return 0; } static int opensslcrypto_encrypt_and_sign ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { struct iovec iov_in; memset(&iov_in, 0, sizeof(iov_in)); iov_in.iov_base = (unsigned char *)buf_in; iov_in.iov_len = buf_in_len; return opensslcrypto_encrypt_and_signv(knet_h, &iov_in, 1, buf_out, buf_out_len); } static int opensslcrypto_authenticate_and_decrypt ( knet_handle_t knet_h, const unsigned char *buf_in, const ssize_t buf_in_len, unsigned char *buf_out, ssize_t *buf_out_len) { struct opensslcrypto_instance *instance = knet_h->crypto_instance->model_instance; ssize_t temp_len = buf_in_len; if (instance->crypto_hash_type) { unsigned char tmp_hash[knet_h->sec_hash_size]; ssize_t temp_buf_len = buf_in_len - knet_h->sec_hash_size; if ((temp_buf_len < 0) || (temp_buf_len > KNET_MAX_PACKET_SIZE)) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Incorrect packet size."); return -1; } if (calculate_openssl_hash(knet_h, buf_in, temp_buf_len, tmp_hash) < 0) { return -1; } if (memcmp(tmp_hash, buf_in + temp_buf_len, knet_h->sec_hash_size) != 0) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Digest does not match"); return -1; } temp_len = temp_len - knet_h->sec_hash_size; *buf_out_len = temp_len; } if (instance->crypto_cipher_type) { if (decrypt_openssl(knet_h, buf_in, temp_len, buf_out, buf_out_len) < 0) { return -1; } } else { memmove(buf_out, buf_in, temp_len); *buf_out_len = temp_len; } return 0; } #ifdef BUILDCRYPTOOPENSSL10 static pthread_mutex_t *openssl_internal_lock; static void openssl_internal_locking_callback(int mode, int type, char *file, int line) { if (mode & CRYPTO_LOCK) { pthread_mutex_lock(&(openssl_internal_lock[type])); } else { pthread_mutex_unlock(&(openssl_internal_lock[type])); } } static unsigned long openssl_internal_thread_id(void) { return (unsigned long)pthread_self(); } static void openssl_internal_lock_cleanup(void) { int i; CRYPTO_set_locking_callback(NULL); CRYPTO_set_id_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_destroy(&(openssl_internal_lock[i])); } if (openssl_internal_lock) { free(openssl_internal_lock); } return; } static int openssl_internal_lock_setup(void) { int savederrno = 0, err = 0; int i; openssl_internal_lock = malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); if (!openssl_internal_lock) { savederrno = errno; err = -1; goto out; } for (i = 0; i < CRYPTO_num_locks(); i++) { savederrno = pthread_mutex_init(&(openssl_internal_lock[i]), NULL); if (savederrno) { err = -1; goto out; } } CRYPTO_set_id_callback((unsigned long (*)(void))openssl_internal_thread_id); CRYPTO_set_locking_callback((void *)&openssl_internal_locking_callback); out: if (err) { openssl_internal_lock_cleanup(); } errno = savederrno; return err; } #endif static void opensslcrypto_fini( knet_handle_t knet_h) { struct opensslcrypto_instance *opensslcrypto_instance = knet_h->crypto_instance->model_instance; if (opensslcrypto_instance) { #ifdef BUILDCRYPTOOPENSSL10 openssl_internal_lock_cleanup(); #endif if (opensslcrypto_instance->private_key) { free(opensslcrypto_instance->private_key); opensslcrypto_instance->private_key = NULL; } free(opensslcrypto_instance); knet_h->crypto_instance->model_instance = NULL; knet_h->sec_header_size = 0; } return; } static int opensslcrypto_init( knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg) { static int openssl_is_init = 0; struct opensslcrypto_instance *opensslcrypto_instance = NULL; + int savederrno; log_debug(knet_h, KNET_SUB_OPENSSLCRYPTO, "Initizializing openssl crypto module [%s/%s]", knet_handle_crypto_cfg->crypto_cipher_type, knet_handle_crypto_cfg->crypto_hash_type); if (!openssl_is_init) { #ifdef BUILDCRYPTOOPENSSL10 ERR_load_crypto_strings(); OPENSSL_add_all_algorithms_noconf(); #endif #ifdef BUILDCRYPTOOPENSSL11 if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to init openssl"); errno = EAGAIN; return -1; } #endif openssl_is_init = 1; } #ifdef BUILDCRYPTOOPENSSL10 if (openssl_internal_lock_setup() < 0) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to init openssl"); errno = EAGAIN; return -1; } #endif knet_h->crypto_instance->model_instance = malloc(sizeof(struct opensslcrypto_instance)); if (!knet_h->crypto_instance->model_instance) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to allocate memory for openssl model instance"); + errno = ENOMEM; return -1; } opensslcrypto_instance = knet_h->crypto_instance->model_instance; memset(opensslcrypto_instance, 0, sizeof(struct opensslcrypto_instance)); if (strcmp(knet_handle_crypto_cfg->crypto_cipher_type, "none") == 0) { opensslcrypto_instance->crypto_cipher_type = NULL; } else { opensslcrypto_instance->crypto_cipher_type = EVP_get_cipherbyname(knet_handle_crypto_cfg->crypto_cipher_type); if (!opensslcrypto_instance->crypto_cipher_type) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "unknown crypto cipher type requested"); + savederrno = ENXIO; goto out_err; } } if (strcmp(knet_handle_crypto_cfg->crypto_hash_type, "none") == 0) { opensslcrypto_instance->crypto_hash_type = NULL; } else { opensslcrypto_instance->crypto_hash_type = EVP_get_digestbyname(knet_handle_crypto_cfg->crypto_hash_type); if (!opensslcrypto_instance->crypto_hash_type) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "unknown crypto hash type requested"); + savederrno = ENXIO; goto out_err; } } if ((opensslcrypto_instance->crypto_cipher_type) && (!opensslcrypto_instance->crypto_hash_type)) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "crypto communication requires hash specified"); + savederrno = EINVAL; goto out_err; } opensslcrypto_instance->private_key = malloc(knet_handle_crypto_cfg->private_key_len); if (!opensslcrypto_instance->private_key) { log_err(knet_h, KNET_SUB_OPENSSLCRYPTO, "Unable to allocate memory for openssl private key"); + savederrno = ENOMEM; goto out_err; } memmove(opensslcrypto_instance->private_key, knet_handle_crypto_cfg->private_key, knet_handle_crypto_cfg->private_key_len); opensslcrypto_instance->private_key_len = knet_handle_crypto_cfg->private_key_len; knet_h->sec_header_size = 0; if (opensslcrypto_instance->crypto_hash_type) { knet_h->sec_hash_size = EVP_MD_size(opensslcrypto_instance->crypto_hash_type); knet_h->sec_header_size += knet_h->sec_hash_size; } if (opensslcrypto_instance->crypto_cipher_type) { - int block_size; + size_t block_size; block_size = EVP_CIPHER_block_size(opensslcrypto_instance->crypto_cipher_type); - if (block_size < 0) { - goto out_err; - } knet_h->sec_header_size += (block_size * 2); knet_h->sec_header_size += SALT_SIZE; knet_h->sec_salt_size = SALT_SIZE; knet_h->sec_block_size = block_size; } return 0; out_err: opensslcrypto_fini(knet_h); + errno = savederrno; return -1; } crypto_ops_t crypto_model = { KNET_CRYPTO_MODEL_ABI, opensslcrypto_init, opensslcrypto_fini, opensslcrypto_encrypt_and_sign, opensslcrypto_encrypt_and_signv, opensslcrypto_authenticate_and_decrypt }; diff --git a/libknet/handle.c b/libknet/handle.c index 8cf5bb7d..8e952558 100644 --- a/libknet/handle.c +++ b/libknet/handle.c @@ -1,1592 +1,1608 @@ /* * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * Federico Simoncelli * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include #include #include "internals.h" #include "crypto.h" #include "links.h" #include "compress.h" #include "compat.h" #include "common.h" #include "threads_common.h" #include "threads_heartbeat.h" #include "threads_pmtud.h" #include "threads_dsthandler.h" #include "threads_rx.h" #include "threads_tx.h" #include "transports.h" #include "transport_common.h" #include "logging.h" static pthread_mutex_t handle_config_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_rwlock_t shlib_rwlock; static uint8_t shlib_wrlock_init = 0; static uint32_t knet_ref = 0; static int _init_shlib_tracker(knet_handle_t knet_h) { int savederrno = 0; if (!shlib_wrlock_init) { savederrno = pthread_rwlock_init(&shlib_rwlock, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize shared lib rwlock: %s", strerror(savederrno)); errno = savederrno; return -1; } shlib_wrlock_init = 1; } return 0; } static void _fini_shlib_tracker(void) { if (knet_ref == 0) { pthread_rwlock_destroy(&shlib_rwlock); shlib_wrlock_init = 0; } return; } static int _init_locks(knet_handle_t knet_h) { int savederrno = 0; savederrno = pthread_rwlock_init(&knet_h->global_rwlock, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize list rwlock: %s", strerror(savederrno)); goto exit_fail; } knet_h->lock_init_done = 1; savederrno = pthread_mutex_init(&knet_h->pmtud_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize pmtud mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_mutex_init(&knet_h->kmtu_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize kernel_mtu mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_cond_init(&knet_h->pmtud_cond, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize pmtud conditional mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_mutex_init(&knet_h->hb_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize hb_thread mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_mutex_init(&knet_h->tx_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize tx_thread mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_mutex_init(&knet_h->backoff_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize pong timeout backoff mutex: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_mutex_init(&knet_h->tx_seq_num_mutex, NULL); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize tx_seq_num_mutex mutex: %s", strerror(savederrno)); goto exit_fail; } return 0; exit_fail: errno = savederrno; return -1; } static void _destroy_locks(knet_handle_t knet_h) { knet_h->lock_init_done = 0; pthread_rwlock_destroy(&knet_h->global_rwlock); pthread_mutex_destroy(&knet_h->pmtud_mutex); pthread_mutex_destroy(&knet_h->kmtu_mutex); pthread_cond_destroy(&knet_h->pmtud_cond); pthread_mutex_destroy(&knet_h->hb_mutex); pthread_mutex_destroy(&knet_h->tx_mutex); pthread_mutex_destroy(&knet_h->backoff_mutex); pthread_mutex_destroy(&knet_h->tx_seq_num_mutex); } static int _init_socks(knet_handle_t knet_h) { int savederrno = 0; if (_init_socketpair(knet_h, knet_h->hostsockfd)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize internal hostsockpair: %s", strerror(savederrno)); goto exit_fail; } if (_init_socketpair(knet_h, knet_h->dstsockfd)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize internal dstsockpair: %s", strerror(savederrno)); goto exit_fail; } return 0; exit_fail: errno = savederrno; return -1; } static void _close_socks(knet_handle_t knet_h) { _close_socketpair(knet_h, knet_h->dstsockfd); _close_socketpair(knet_h, knet_h->hostsockfd); } static int _init_buffers(knet_handle_t knet_h) { int savederrno = 0; int i; size_t bufsize; for (i = 0; i < PCKT_FRAG_MAX; i++) { bufsize = ceil((float)KNET_MAX_PACKET_SIZE / (i + 1)) + KNET_HEADER_ALL_SIZE; knet_h->send_to_links_buf[i] = malloc(bufsize); if (!knet_h->send_to_links_buf[i]) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory datafd to link buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->send_to_links_buf[i], 0, bufsize); } for (i = 0; i < PCKT_RX_BUFS; i++) { knet_h->recv_from_links_buf[i] = malloc(KNET_DATABUFSIZE); if (!knet_h->recv_from_links_buf[i]) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for link to datafd buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->recv_from_links_buf[i], 0, KNET_DATABUFSIZE); } knet_h->recv_from_sock_buf = malloc(KNET_DATABUFSIZE); if (!knet_h->recv_from_sock_buf) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for app to datafd buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->recv_from_sock_buf, 0, KNET_DATABUFSIZE); knet_h->pingbuf = malloc(KNET_HEADER_PING_SIZE); if (!knet_h->pingbuf) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for hearbeat buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->pingbuf, 0, KNET_HEADER_PING_SIZE); knet_h->pmtudbuf = malloc(KNET_PMTUD_SIZE_V6); if (!knet_h->pmtudbuf) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for pmtud buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->pmtudbuf, 0, KNET_PMTUD_SIZE_V6); for (i = 0; i < PCKT_FRAG_MAX; i++) { bufsize = ceil((float)KNET_MAX_PACKET_SIZE / (i + 1)) + KNET_HEADER_ALL_SIZE + KNET_DATABUFSIZE_CRYPT_PAD; knet_h->send_to_links_buf_crypt[i] = malloc(bufsize); if (!knet_h->send_to_links_buf_crypt[i]) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for crypto datafd to link buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->send_to_links_buf_crypt[i], 0, bufsize); } knet_h->recv_from_links_buf_decrypt = malloc(KNET_DATABUFSIZE_CRYPT); if (!knet_h->recv_from_links_buf_decrypt) { savederrno = errno; log_err(knet_h, KNET_SUB_CRYPTO, "Unable to allocate memory for crypto link to datafd buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->recv_from_links_buf_decrypt, 0, KNET_DATABUFSIZE_CRYPT); knet_h->recv_from_links_buf_crypt = malloc(KNET_DATABUFSIZE_CRYPT); if (!knet_h->recv_from_links_buf_crypt) { savederrno = errno; log_err(knet_h, KNET_SUB_CRYPTO, "Unable to allocate memory for crypto link to datafd buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->recv_from_links_buf_crypt, 0, KNET_DATABUFSIZE_CRYPT); knet_h->pingbuf_crypt = malloc(KNET_DATABUFSIZE_CRYPT); if (!knet_h->pingbuf_crypt) { savederrno = errno; log_err(knet_h, KNET_SUB_CRYPTO, "Unable to allocate memory for crypto hearbeat buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->pingbuf_crypt, 0, KNET_DATABUFSIZE_CRYPT); knet_h->pmtudbuf_crypt = malloc(KNET_DATABUFSIZE_CRYPT); if (!knet_h->pmtudbuf_crypt) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for crypto pmtud buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->pmtudbuf_crypt, 0, KNET_DATABUFSIZE_CRYPT); knet_h->recv_from_links_buf_decompress = malloc(KNET_DATABUFSIZE_COMPRESS); if (!knet_h->recv_from_links_buf_decompress) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for decompress buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->recv_from_links_buf_decompress, 0, KNET_DATABUFSIZE_COMPRESS); knet_h->send_to_links_buf_compress = malloc(KNET_DATABUFSIZE_COMPRESS); if (!knet_h->send_to_links_buf_compress) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for compress buffer: %s", strerror(savederrno)); goto exit_fail; } memset(knet_h->send_to_links_buf_compress, 0, KNET_DATABUFSIZE_COMPRESS); memset(knet_h->knet_transport_fd_tracker, KNET_MAX_TRANSPORTS, sizeof(knet_h->knet_transport_fd_tracker)); return 0; exit_fail: errno = savederrno; return -1; } static void _destroy_buffers(knet_handle_t knet_h) { int i; for (i = 0; i < PCKT_FRAG_MAX; i++) { free(knet_h->send_to_links_buf[i]); free(knet_h->send_to_links_buf_crypt[i]); } for (i = 0; i < PCKT_RX_BUFS; i++) { free(knet_h->recv_from_links_buf[i]); } free(knet_h->recv_from_links_buf_decompress); free(knet_h->send_to_links_buf_compress); free(knet_h->recv_from_sock_buf); free(knet_h->recv_from_links_buf_decrypt); free(knet_h->recv_from_links_buf_crypt); free(knet_h->pingbuf); free(knet_h->pingbuf_crypt); free(knet_h->pmtudbuf); free(knet_h->pmtudbuf_crypt); } static int _init_epolls(knet_handle_t knet_h) { struct epoll_event ev; int savederrno = 0; /* * even if the kernel does dynamic allocation with epoll_ctl * we need to reserve one extra for host to host communication */ knet_h->send_to_links_epollfd = epoll_create(KNET_EPOLL_MAX_EVENTS + 1); if (knet_h->send_to_links_epollfd < 0) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to create epoll datafd to link fd: %s", strerror(savederrno)); goto exit_fail; } knet_h->recv_from_links_epollfd = epoll_create(KNET_EPOLL_MAX_EVENTS); if (knet_h->recv_from_links_epollfd < 0) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to create epoll link to datafd fd: %s", strerror(savederrno)); goto exit_fail; } knet_h->dst_link_handler_epollfd = epoll_create(KNET_EPOLL_MAX_EVENTS); if (knet_h->dst_link_handler_epollfd < 0) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to create epoll dst cache fd: %s", strerror(savederrno)); goto exit_fail; } if (_fdset_cloexec(knet_h->send_to_links_epollfd)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to set CLOEXEC on datafd to link epoll fd: %s", strerror(savederrno)); goto exit_fail; } if (_fdset_cloexec(knet_h->recv_from_links_epollfd)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to set CLOEXEC on link to datafd epoll fd: %s", strerror(savederrno)); goto exit_fail; } if (_fdset_cloexec(knet_h->dst_link_handler_epollfd)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to set CLOEXEC on dst cache epoll fd: %s", strerror(savederrno)); goto exit_fail; } memset(&ev, 0, sizeof(struct epoll_event)); ev.events = EPOLLIN; ev.data.fd = knet_h->hostsockfd[0]; if (epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_ADD, knet_h->hostsockfd[0], &ev)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to add hostsockfd[0] to epoll pool: %s", strerror(savederrno)); goto exit_fail; } memset(&ev, 0, sizeof(struct epoll_event)); ev.events = EPOLLIN; ev.data.fd = knet_h->dstsockfd[0]; if (epoll_ctl(knet_h->dst_link_handler_epollfd, EPOLL_CTL_ADD, knet_h->dstsockfd[0], &ev)) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to add dstsockfd[0] to epoll pool: %s", strerror(savederrno)); goto exit_fail; } return 0; exit_fail: errno = savederrno; return -1; } static void _close_epolls(knet_handle_t knet_h) { struct epoll_event ev; int i; memset(&ev, 0, sizeof(struct epoll_event)); for (i = 0; i < KNET_DATAFD_MAX; i++) { if (knet_h->sockfd[i].in_use) { epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_DEL, knet_h->sockfd[i].sockfd[knet_h->sockfd[i].is_created], &ev); if (knet_h->sockfd[i].sockfd[knet_h->sockfd[i].is_created]) { _close_socketpair(knet_h, knet_h->sockfd[i].sockfd); } } } epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_DEL, knet_h->hostsockfd[0], &ev); epoll_ctl(knet_h->dst_link_handler_epollfd, EPOLL_CTL_DEL, knet_h->dstsockfd[0], &ev); close(knet_h->send_to_links_epollfd); close(knet_h->recv_from_links_epollfd); close(knet_h->dst_link_handler_epollfd); } static int _start_threads(knet_handle_t knet_h) { int savederrno = 0; savederrno = pthread_create(&knet_h->pmtud_link_handler_thread, 0, _handle_pmtud_link_thread, (void *) knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to start pmtud link thread: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_create(&knet_h->dst_link_handler_thread, 0, _handle_dst_link_handler_thread, (void *) knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to start dst cache thread: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_create(&knet_h->send_to_links_thread, 0, _handle_send_to_links_thread, (void *) knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to start datafd to link thread: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_create(&knet_h->recv_from_links_thread, 0, _handle_recv_from_links_thread, (void *) knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to start link to datafd thread: %s", strerror(savederrno)); goto exit_fail; } savederrno = pthread_create(&knet_h->heartbt_thread, 0, _handle_heartbt_thread, (void *) knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to start heartbeat thread: %s", strerror(savederrno)); goto exit_fail; } return 0; exit_fail: errno = savederrno; return -1; } static void _stop_threads(knet_handle_t knet_h) { void *retval; /* * allow threads to catch on shutdown request * and release locks before we stop them. * this isn't the most efficent way to handle it * but it works good enough for now */ sleep(1); if (knet_h->heartbt_thread) { pthread_cancel(knet_h->heartbt_thread); pthread_join(knet_h->heartbt_thread, &retval); } if (knet_h->send_to_links_thread) { pthread_cancel(knet_h->send_to_links_thread); pthread_join(knet_h->send_to_links_thread, &retval); } if (knet_h->recv_from_links_thread) { pthread_cancel(knet_h->recv_from_links_thread); pthread_join(knet_h->recv_from_links_thread, &retval); } if (knet_h->dst_link_handler_thread) { pthread_cancel(knet_h->dst_link_handler_thread); pthread_join(knet_h->dst_link_handler_thread, &retval); } if (knet_h->pmtud_link_handler_thread) { pthread_cancel(knet_h->pmtud_link_handler_thread); pthread_join(knet_h->pmtud_link_handler_thread, &retval); } } -knet_handle_t knet_handle_new(knet_node_id_t host_id, - int log_fd, - uint8_t default_log_level) +knet_handle_t knet_handle_new_ex(knet_node_id_t host_id, + int log_fd, + uint8_t default_log_level, + uint64_t flags) { knet_handle_t knet_h; int savederrno = 0; struct rlimit cur; if (getrlimit(RLIMIT_NOFILE, &cur) < 0) { return NULL; } if ((log_fd < 0) || ((unsigned int)log_fd >= cur.rlim_max)) { errno = EINVAL; return NULL; } /* * validate incoming request */ if ((log_fd) && (default_log_level > KNET_LOG_DEBUG)) { errno = EINVAL; return NULL; } + if (flags > KNET_HANDLE_FLAG_PRIVILEGED * 2 - 1) { + errno = EINVAL; + return NULL; + } + /* * allocate handle */ knet_h = malloc(sizeof(struct knet_handle)); if (!knet_h) { errno = ENOMEM; return NULL; } memset(knet_h, 0, sizeof(struct knet_handle)); + knet_h->flags = flags; + savederrno = pthread_mutex_lock(&handle_config_mutex); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get handle mutex lock: %s", strerror(savederrno)); errno = savederrno; goto exit_fail; } /* * copy config in place */ knet_h->host_id = host_id; knet_h->logfd = log_fd; if (knet_h->logfd > 0) { memset(&knet_h->log_levels, default_log_level, KNET_MAX_SUBSYSTEMS); } /* * set pmtud default timers */ knet_h->pmtud_interval = KNET_PMTUD_DEFAULT_INTERVAL; /* * set transports reconnect default timers */ knet_h->reconnect_int = KNET_TRANSPORT_DEFAULT_RECONNECT_INTERVAL; /* * Set 'min' stats to the maximum value so the * first value we get is always less */ knet_h->stats.tx_compress_time_min = UINT64_MAX; knet_h->stats.rx_compress_time_min = UINT64_MAX; knet_h->stats.tx_crypt_time_min = UINT64_MAX; knet_h->stats.rx_crypt_time_min = UINT64_MAX; /* * init global shlib tracker */ if (_init_shlib_tracker(knet_h) < 0) { savederrno = errno; log_err(knet_h, KNET_SUB_HANDLE, "Unable to init handles traceker: %s", strerror(savederrno)); errno = savederrno; goto exit_fail; } /* * init main locking structures */ if (_init_locks(knet_h)) { savederrno = errno; goto exit_fail; } /* * init sockets */ if (_init_socks(knet_h)) { savederrno = errno; goto exit_fail; } /* * allocate packet buffers */ if (_init_buffers(knet_h)) { savederrno = errno; goto exit_fail; } if (compress_init(knet_h)) { savederrno = errno; goto exit_fail; } /* * create epoll fds */ if (_init_epolls(knet_h)) { savederrno = errno; goto exit_fail; } /* * start transports */ if (start_all_transports(knet_h)) { savederrno = errno; goto exit_fail; } /* * start internal threads */ if (_start_threads(knet_h)) { savederrno = errno; goto exit_fail; } knet_ref++; pthread_mutex_unlock(&handle_config_mutex); return knet_h; exit_fail: pthread_mutex_unlock(&handle_config_mutex); knet_handle_free(knet_h); errno = savederrno; return NULL; } +knet_handle_t knet_handle_new(knet_node_id_t host_id, + int log_fd, + uint8_t default_log_level) +{ + return knet_handle_new_ex(host_id, log_fd, default_log_level, KNET_HANDLE_FLAG_PRIVILEGED); +} + int knet_handle_free(knet_handle_t knet_h) { int savederrno = 0; savederrno = pthread_mutex_lock(&handle_config_mutex); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get handle mutex lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (!knet_h) { pthread_mutex_unlock(&handle_config_mutex); errno = EINVAL; return -1; } if (!knet_h->lock_init_done) { goto exit_nolock; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); pthread_mutex_unlock(&handle_config_mutex); errno = savederrno; return -1; } if (knet_h->host_head != NULL) { savederrno = EBUSY; log_err(knet_h, KNET_SUB_HANDLE, "Unable to free handle: host(s) or listener(s) are still active: %s", strerror(savederrno)); pthread_rwlock_unlock(&knet_h->global_rwlock); pthread_mutex_unlock(&handle_config_mutex); errno = savederrno; return -1; } knet_h->fini_in_progress = 1; pthread_rwlock_unlock(&knet_h->global_rwlock); _stop_threads(knet_h); stop_all_transports(knet_h); _close_epolls(knet_h); _destroy_buffers(knet_h); _close_socks(knet_h); crypto_fini(knet_h); compress_fini(knet_h, 1); _destroy_locks(knet_h); exit_nolock: free(knet_h); knet_h = NULL; knet_ref--; _fini_shlib_tracker(); pthread_mutex_unlock(&handle_config_mutex); return 0; } int knet_handle_enable_sock_notify(knet_handle_t knet_h, void *sock_notify_fn_private_data, void (*sock_notify_fn) ( void *private_data, int datafd, int8_t channel, uint8_t tx_rx, int error, int errorno)) { int savederrno = 0, err = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!sock_notify_fn) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } knet_h->sock_notify_fn_private_data = sock_notify_fn_private_data; knet_h->sock_notify_fn = sock_notify_fn; log_debug(knet_h, KNET_SUB_HANDLE, "sock_notify_fn enabled"); pthread_rwlock_unlock(&knet_h->global_rwlock); return err; } int knet_handle_add_datafd(knet_handle_t knet_h, int *datafd, int8_t *channel) { int err = 0, savederrno = 0; int i; struct epoll_event ev; if (!knet_h) { errno = EINVAL; return -1; } if (datafd == NULL) { errno = EINVAL; return -1; } if (channel == NULL) { errno = EINVAL; return -1; } if (*channel >= KNET_DATAFD_MAX) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (!knet_h->sock_notify_fn) { log_err(knet_h, KNET_SUB_HANDLE, "Adding datafd requires sock notify callback enabled!"); savederrno = EINVAL; err = -1; goto out_unlock; } if (*datafd > 0) { for (i = 0; i < KNET_DATAFD_MAX; i++) { if ((knet_h->sockfd[i].in_use) && (knet_h->sockfd[i].sockfd[0] == *datafd)) { log_err(knet_h, KNET_SUB_HANDLE, "requested datafd: %d already exist in index: %d", *datafd, i); savederrno = EEXIST; err = -1; goto out_unlock; } } } /* * auto allocate a channel */ if (*channel < 0) { for (i = 0; i < KNET_DATAFD_MAX; i++) { if (!knet_h->sockfd[i].in_use) { *channel = i; break; } } if (*channel < 0) { savederrno = EBUSY; err = -1; goto out_unlock; } } else { if (knet_h->sockfd[*channel].in_use) { savederrno = EBUSY; err = -1; goto out_unlock; } } knet_h->sockfd[*channel].is_created = 0; knet_h->sockfd[*channel].is_socket = 0; knet_h->sockfd[*channel].has_error = 0; if (*datafd > 0) { int sockopt; socklen_t sockoptlen = sizeof(sockopt); if (_fdset_cloexec(*datafd)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_HANDLE, "Unable to set CLOEXEC on datafd: %s", strerror(savederrno)); goto out_unlock; } if (_fdset_nonblock(*datafd)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_HANDLE, "Unable to set NONBLOCK on datafd: %s", strerror(savederrno)); goto out_unlock; } knet_h->sockfd[*channel].sockfd[0] = *datafd; knet_h->sockfd[*channel].sockfd[1] = 0; if (!getsockopt(knet_h->sockfd[*channel].sockfd[0], SOL_SOCKET, SO_TYPE, &sockopt, &sockoptlen)) { knet_h->sockfd[*channel].is_socket = 1; } } else { if (_init_socketpair(knet_h, knet_h->sockfd[*channel].sockfd)) { savederrno = errno; err = -1; goto out_unlock; } knet_h->sockfd[*channel].is_created = 1; knet_h->sockfd[*channel].is_socket = 1; *datafd = knet_h->sockfd[*channel].sockfd[0]; } memset(&ev, 0, sizeof(struct epoll_event)); ev.events = EPOLLIN; ev.data.fd = knet_h->sockfd[*channel].sockfd[knet_h->sockfd[*channel].is_created]; if (epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_ADD, knet_h->sockfd[*channel].sockfd[knet_h->sockfd[*channel].is_created], &ev)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_HANDLE, "Unable to add datafd %d to linkfd epoll pool: %s", knet_h->sockfd[*channel].sockfd[knet_h->sockfd[*channel].is_created], strerror(savederrno)); if (knet_h->sockfd[*channel].is_created) { _close_socketpair(knet_h, knet_h->sockfd[*channel].sockfd); } goto out_unlock; } knet_h->sockfd[*channel].in_use = 1; out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_remove_datafd(knet_handle_t knet_h, int datafd) { int err = 0, savederrno = 0; int8_t channel = -1; int i; struct epoll_event ev; if (!knet_h) { errno = EINVAL; return -1; } if (datafd <= 0) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } for (i = 0; i < KNET_DATAFD_MAX; i++) { if ((knet_h->sockfd[i].in_use) && (knet_h->sockfd[i].sockfd[0] == datafd)) { channel = i; break; } } if (channel < 0) { savederrno = EINVAL; err = -1; goto out_unlock; } if (!knet_h->sockfd[channel].has_error) { memset(&ev, 0, sizeof(struct epoll_event)); if (epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_DEL, knet_h->sockfd[channel].sockfd[knet_h->sockfd[channel].is_created], &ev)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_HANDLE, "Unable to del datafd %d from linkfd epoll pool: %s", knet_h->sockfd[channel].sockfd[0], strerror(savederrno)); goto out_unlock; } } if (knet_h->sockfd[channel].is_created) { _close_socketpair(knet_h, knet_h->sockfd[channel].sockfd); } memset(&knet_h->sockfd[channel], 0, sizeof(struct knet_sock)); out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_get_datafd(knet_handle_t knet_h, const int8_t channel, int *datafd) { int err = 0, savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } if ((channel < 0) || (channel >= KNET_DATAFD_MAX)) { errno = EINVAL; return -1; } if (datafd == NULL) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (!knet_h->sockfd[channel].in_use) { savederrno = EINVAL; err = -1; goto out_unlock; } *datafd = knet_h->sockfd[channel].sockfd[0]; out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_get_channel(knet_handle_t knet_h, const int datafd, int8_t *channel) { int err = 0, savederrno = 0; int i; if (!knet_h) { errno = EINVAL; return -1; } if (datafd <= 0) { errno = EINVAL; return -1; } if (channel == NULL) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } *channel = -1; for (i = 0; i < KNET_DATAFD_MAX; i++) { if ((knet_h->sockfd[i].in_use) && (knet_h->sockfd[i].sockfd[0] == datafd)) { *channel = i; break; } } if (*channel < 0) { savederrno = EINVAL; err = -1; goto out_unlock; } out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_enable_filter(knet_handle_t knet_h, void *dst_host_filter_fn_private_data, int (*dst_host_filter_fn) ( void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_node_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries)) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } knet_h->dst_host_filter_fn_private_data = dst_host_filter_fn_private_data; knet_h->dst_host_filter_fn = dst_host_filter_fn; if (knet_h->dst_host_filter_fn) { log_debug(knet_h, KNET_SUB_HANDLE, "dst_host_filter_fn enabled"); } else { log_debug(knet_h, KNET_SUB_HANDLE, "dst_host_filter_fn disabled"); } pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_setfwd(knet_handle_t knet_h, unsigned int enabled) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } if (enabled > 1) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } knet_h->enabled = enabled; if (enabled) { log_debug(knet_h, KNET_SUB_HANDLE, "Data forwarding is enabled"); } else { log_debug(knet_h, KNET_SUB_HANDLE, "Data forwarding is disabled"); } pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_pmtud_getfreq(knet_handle_t knet_h, unsigned int *interval) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!interval) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } *interval = knet_h->pmtud_interval; pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_pmtud_setfreq(knet_handle_t knet_h, unsigned int interval) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } if ((!interval) || (interval > 86400)) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } knet_h->pmtud_interval = interval; log_debug(knet_h, KNET_SUB_HANDLE, "PMTUd interval set to: %u seconds", interval); pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_enable_pmtud_notify(knet_handle_t knet_h, void *pmtud_notify_fn_private_data, void (*pmtud_notify_fn) ( void *private_data, unsigned int data_mtu)) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } knet_h->pmtud_notify_fn_private_data = pmtud_notify_fn_private_data; knet_h->pmtud_notify_fn = pmtud_notify_fn; if (knet_h->pmtud_notify_fn) { log_debug(knet_h, KNET_SUB_HANDLE, "pmtud_notify_fn enabled"); } else { log_debug(knet_h, KNET_SUB_HANDLE, "pmtud_notify_fn disabled"); } pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_pmtud_get(knet_handle_t knet_h, unsigned int *data_mtu) { int savederrno = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!data_mtu) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } *data_mtu = knet_h->data_mtu; pthread_rwlock_unlock(&knet_h->global_rwlock); return 0; } int knet_handle_crypto(knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg) { int savederrno = 0; int err = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!knet_handle_crypto_cfg) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } crypto_fini(knet_h); if ((!strncmp("none", knet_handle_crypto_cfg->crypto_model, 4)) || ((!strncmp("none", knet_handle_crypto_cfg->crypto_cipher_type, 4)) && (!strncmp("none", knet_handle_crypto_cfg->crypto_hash_type, 4)))) { log_debug(knet_h, KNET_SUB_CRYPTO, "crypto is not enabled"); err = 0; goto exit_unlock; } if (knet_handle_crypto_cfg->private_key_len < KNET_MIN_KEY_LEN) { log_debug(knet_h, KNET_SUB_CRYPTO, "private key len too short (min %d): %u", KNET_MIN_KEY_LEN, knet_handle_crypto_cfg->private_key_len); savederrno = EINVAL; err = -1; goto exit_unlock; } if (knet_handle_crypto_cfg->private_key_len > KNET_MAX_KEY_LEN) { log_debug(knet_h, KNET_SUB_CRYPTO, "private key len too long (max %d): %u", KNET_MAX_KEY_LEN, knet_handle_crypto_cfg->private_key_len); savederrno = EINVAL; err = -1; goto exit_unlock; } err = crypto_init(knet_h, knet_handle_crypto_cfg); if (err) { err = -2; + savederrno = errno; } exit_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *knet_handle_compress_cfg) { int savederrno = 0; int err = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!knet_handle_compress_cfg) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } compress_fini(knet_h, 0); err = compress_cfg(knet_h, knet_handle_compress_cfg); savederrno = errno; pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } ssize_t knet_recv(knet_handle_t knet_h, char *buff, const size_t buff_len, const int8_t channel) { int savederrno = 0; ssize_t err = 0; struct iovec iov_in; if (!knet_h) { errno = EINVAL; return -1; } if (buff == NULL) { errno = EINVAL; return -1; } if (buff_len <= 0) { errno = EINVAL; return -1; } if (buff_len > KNET_MAX_PACKET_SIZE) { errno = EINVAL; return -1; } if (channel < 0) { errno = EINVAL; return -1; } if (channel >= KNET_DATAFD_MAX) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (!knet_h->sockfd[channel].in_use) { savederrno = EINVAL; err = -1; goto out_unlock; } memset(&iov_in, 0, sizeof(iov_in)); iov_in.iov_base = (void *)buff; iov_in.iov_len = buff_len; err = readv(knet_h->sockfd[channel].sockfd[0], &iov_in, 1); savederrno = errno; out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } ssize_t knet_send(knet_handle_t knet_h, const char *buff, const size_t buff_len, const int8_t channel) { int savederrno = 0; ssize_t err = 0; struct iovec iov_out[1]; if (!knet_h) { errno = EINVAL; return -1; } if (buff == NULL) { errno = EINVAL; return -1; } if (buff_len <= 0) { errno = EINVAL; return -1; } if (buff_len > KNET_MAX_PACKET_SIZE) { errno = EINVAL; return -1; } if (channel < 0) { errno = EINVAL; return -1; } if (channel >= KNET_DATAFD_MAX) { errno = EINVAL; return -1; } savederrno = pthread_rwlock_rdlock(&knet_h->global_rwlock); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get read lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (!knet_h->sockfd[channel].in_use) { savederrno = EINVAL; err = -1; goto out_unlock; } memset(iov_out, 0, sizeof(iov_out)); iov_out[0].iov_base = (void *)buff; iov_out[0].iov_len = buff_len; err = writev(knet_h->sockfd[channel].sockfd[0], iov_out, 1); savederrno = errno; out_unlock: pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_get_stats(knet_handle_t knet_h, struct knet_handle_stats *stats, size_t struct_size) { int savederrno = 0; int err = 0; if (!knet_h) { errno = EINVAL; return -1; } if (!stats) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } if (struct_size > sizeof(struct knet_handle_stats)) { struct_size = sizeof(struct knet_handle_stats); } memmove(stats, &knet_h->stats, struct_size); /* * TX crypt stats only count the data packets sent, so add in the ping/pong/pmtud figures * RX is OK as it counts them before they are sorted. */ stats->tx_crypt_packets += knet_h->stats_extra.tx_crypt_ping_packets + knet_h->stats_extra.tx_crypt_pong_packets + knet_h->stats_extra.tx_crypt_pmtu_packets + knet_h->stats_extra.tx_crypt_pmtu_reply_packets; /* Tell the caller our full size in case they have an old version */ stats->size = sizeof(struct knet_handle_stats); pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } int knet_handle_clear_stats(knet_handle_t knet_h, int clear_option) { int savederrno = 0; int err = 0; if (!knet_h) { errno = EINVAL; return -1; } if (clear_option != KNET_CLEARSTATS_HANDLE_ONLY && clear_option != KNET_CLEARSTATS_HANDLE_AND_LINK) { errno = EINVAL; return -1; } savederrno = get_global_wrlock(knet_h); if (savederrno) { log_err(knet_h, KNET_SUB_HANDLE, "Unable to get write lock: %s", strerror(savederrno)); errno = savederrno; return -1; } memset(&knet_h->stats, 0, sizeof(struct knet_handle_stats)); memset(&knet_h->stats_extra, 0, sizeof(struct knet_handle_stats_extra)); if (clear_option == KNET_CLEARSTATS_HANDLE_AND_LINK) { _link_clear_stats(knet_h); } pthread_rwlock_unlock(&knet_h->global_rwlock); errno = savederrno; return err; } diff --git a/libknet/internals.h b/libknet/internals.h index f0f8f528..a785cd72 100644 --- a/libknet/internals.h +++ b/libknet/internals.h @@ -1,506 +1,507 @@ /* * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * Federico Simoncelli * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #ifndef __KNET_INTERNALS_H__ #define __KNET_INTERNALS_H__ /* * NOTE: you shouldn't need to include this header normally */ #include #include "libknet.h" #include "onwire.h" #include "compat.h" #define KNET_DATABUFSIZE KNET_MAX_PACKET_SIZE + KNET_HEADER_ALL_SIZE #define KNET_DATABUFSIZE_CRYPT_PAD 1024 #define KNET_DATABUFSIZE_CRYPT KNET_DATABUFSIZE + KNET_DATABUFSIZE_CRYPT_PAD #define KNET_DATABUFSIZE_COMPRESS_PAD 1024 #define KNET_DATABUFSIZE_COMPRESS KNET_DATABUFSIZE + KNET_DATABUFSIZE_COMPRESS_PAD #define KNET_RING_RCVBUFF 8388608 #define PCKT_FRAG_MAX UINT8_MAX #define PCKT_RX_BUFS 512 #define KNET_EPOLL_MAX_EVENTS KNET_DATAFD_MAX typedef void *knet_transport_link_t; /* per link transport handle */ typedef void *knet_transport_t; /* per knet_h transport handle */ struct knet_transport_ops; /* Forward because of circular dependancy */ struct knet_mmsghdr { struct msghdr msg_hdr; /* Message header */ unsigned int msg_len; /* Number of bytes transmitted */ }; struct knet_link { /* required */ struct sockaddr_storage src_addr; struct sockaddr_storage dst_addr; /* configurable */ unsigned int dynamic; /* see KNET_LINK_DYN_ define above */ uint8_t priority; /* higher priority == preferred for A/P */ unsigned long long ping_interval; /* interval */ unsigned long long pong_timeout; /* timeout */ unsigned long long pong_timeout_adj; /* timeout adjusted for latency */ uint8_t pong_timeout_backoff; /* see link.h for definition */ unsigned int latency_fix; /* precision */ uint8_t pong_count; /* how many ping/pong to send/receive before link is up */ uint64_t flags; /* status */ struct knet_link_status status; /* internals */ uint8_t link_id; uint8_t transport_type; /* #defined constant from API */ knet_transport_link_t transport_link; /* link_info_t from transport */ int outsock; unsigned int configured:1; /* set to 1 if src/dst have been configured transport initialized on this link*/ unsigned int transport_connected:1; /* set to 1 if lower level transport is connected */ unsigned int latency_exp; uint8_t received_pong; struct timespec ping_last; /* used by PMTUD thread as temp per-link variables and should always contain the onwire_len value! */ uint32_t proto_overhead; struct timespec pmtud_last; uint32_t last_ping_size; uint32_t last_good_mtu; uint32_t last_bad_mtu; uint32_t last_sent_mtu; uint32_t last_recv_mtu; uint8_t has_valid_mtu; }; #define KNET_CBUFFER_SIZE 4096 struct knet_host_defrag_buf { char buf[KNET_DATABUFSIZE]; uint8_t in_use; /* 0 buffer is free, 1 is in use */ seq_num_t pckt_seq; /* identify the pckt we are receiving */ uint8_t frag_recv; /* how many frags did we receive */ uint8_t frag_map[PCKT_FRAG_MAX];/* bitmap of what we received? */ uint8_t last_first; /* special case if we receive the last fragment first */ uint16_t frag_size; /* normal frag size (not the last one) */ uint16_t last_frag_size; /* the last fragment might not be aligned with MTU size */ struct timespec last_update; /* keep time of the last pckt */ }; struct knet_host { /* required */ knet_node_id_t host_id; /* configurable */ uint8_t link_handler_policy; char name[KNET_MAX_HOST_LEN]; /* status */ struct knet_host_status status; /* internals */ char circular_buffer[KNET_CBUFFER_SIZE]; seq_num_t rx_seq_num; seq_num_t untimed_rx_seq_num; seq_num_t timed_rx_seq_num; uint8_t got_data; /* defrag/reassembly buffers */ struct knet_host_defrag_buf defrag_buf[KNET_MAX_LINK]; char circular_buffer_defrag[KNET_CBUFFER_SIZE]; /* link stuff */ struct knet_link link[KNET_MAX_LINK]; uint8_t active_link_entries; uint8_t active_links[KNET_MAX_LINK]; struct knet_host *next; }; struct knet_sock { int sockfd[2]; /* sockfd[0] will always be application facing * and sockfd[1] internal if sockpair has been created by knet */ int is_socket; /* check if it's a socket for recvmmsg usage */ int is_created; /* knet created this socket and has to clean up on exit/del */ int in_use; /* set to 1 if it's use, 0 if free */ int has_error; /* set to 1 if there were errors reading from the sock * and socket has been removed from epoll */ }; struct knet_fd_trackers { uint8_t transport; /* transport type (UDP/SCTP...) */ uint8_t data_type; /* internal use for transport to define what data are associated * to this fd */ void *data; /* pointer to the data */ }; #define KNET_MAX_FDS KNET_MAX_HOST * KNET_MAX_LINK * 4 #define KNET_MAX_COMPRESS_METHODS UINT8_MAX struct knet_handle_stats_extra { uint64_t tx_crypt_pmtu_packets; uint64_t tx_crypt_pmtu_reply_packets; uint64_t tx_crypt_ping_packets; uint64_t tx_crypt_pong_packets; }; struct knet_handle { knet_node_id_t host_id; unsigned int enabled:1; struct knet_sock sockfd[KNET_DATAFD_MAX]; int logfd; uint8_t log_levels[KNET_MAX_SUBSYSTEMS]; int hostsockfd[2]; int dstsockfd[2]; int send_to_links_epollfd; int recv_from_links_epollfd; int dst_link_handler_epollfd; unsigned int pmtud_interval; unsigned int data_mtu; /* contains the max data size that we can send onwire * without frags */ struct knet_host *host_head; struct knet_host *host_index[KNET_MAX_HOST]; knet_transport_t transports[KNET_MAX_TRANSPORTS+1]; struct knet_fd_trackers knet_transport_fd_tracker[KNET_MAX_FDS]; /* track status for each fd handled by transports */ struct knet_handle_stats stats; struct knet_handle_stats_extra stats_extra; uint32_t reconnect_int; knet_node_id_t host_ids[KNET_MAX_HOST]; size_t host_ids_entries; struct knet_header *recv_from_sock_buf; struct knet_header *send_to_links_buf[PCKT_FRAG_MAX]; struct knet_header *recv_from_links_buf[PCKT_RX_BUFS]; struct knet_header *pingbuf; struct knet_header *pmtudbuf; pthread_t send_to_links_thread; pthread_t recv_from_links_thread; pthread_t heartbt_thread; pthread_t dst_link_handler_thread; pthread_t pmtud_link_handler_thread; int lock_init_done; pthread_rwlock_t global_rwlock; /* global config lock */ pthread_mutex_t pmtud_mutex; /* pmtud mutex to handle conditional send/recv + timeout */ pthread_cond_t pmtud_cond; /* conditional for above */ pthread_mutex_t tx_mutex; /* used to protect knet_send_sync and TX thread */ pthread_mutex_t hb_mutex; /* used to protect heartbeat thread and seq_num broadcasting */ pthread_mutex_t backoff_mutex; /* used to protect dst_link->pong_timeout_adj */ pthread_mutex_t kmtu_mutex; /* used to protect kernel_mtu */ uint32_t kernel_mtu; /* contains the MTU detected by the kernel on a given link */ int pmtud_waiting; int pmtud_running; int pmtud_forcerun; int pmtud_abort; struct crypto_instance *crypto_instance; size_t sec_header_size; size_t sec_block_size; size_t sec_hash_size; size_t sec_salt_size; unsigned char *send_to_links_buf_crypt[PCKT_FRAG_MAX]; unsigned char *recv_from_links_buf_crypt; unsigned char *recv_from_links_buf_decrypt; unsigned char *pingbuf_crypt; unsigned char *pmtudbuf_crypt; int compress_model; int compress_level; size_t compress_threshold; void *compress_int_data[KNET_MAX_COMPRESS_METHODS]; /* for compress method private data */ unsigned char *recv_from_links_buf_decompress; unsigned char *send_to_links_buf_compress; seq_num_t tx_seq_num; pthread_mutex_t tx_seq_num_mutex; uint8_t has_loop_link; uint8_t loop_link; void *dst_host_filter_fn_private_data; int (*dst_host_filter_fn) ( void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_node_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries); void *pmtud_notify_fn_private_data; void (*pmtud_notify_fn) ( void *private_data, unsigned int data_mtu); void *host_status_change_notify_fn_private_data; void (*host_status_change_notify_fn) ( void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external); void *sock_notify_fn_private_data; void (*sock_notify_fn) ( void *private_data, int datafd, int8_t channel, uint8_t tx_rx, int error, int errorno); int fini_in_progress; + uint64_t flags; }; extern pthread_rwlock_t shlib_rwlock; /* global shared lib load lock */ /* * NOTE: every single operation must be implementend * for every protocol. */ typedef struct knet_transport_ops { /* * transport generic information */ const char *transport_name; const uint8_t transport_id; const uint8_t built_in; uint32_t transport_mtu_overhead; /* * transport init must allocate the new transport * and perform all internal initializations * (threads, lists, etc). */ int (*transport_init)(knet_handle_t knet_h); /* * transport free must releases _all_ resources * allocated by tranport_init */ int (*transport_free)(knet_handle_t knet_h); /* * link operations should take care of all the * sockets and epoll management for a given link/transport set * transport_link_disable should return err = -1 and errno = EBUSY * if listener is still in use, and any other errno in case * the link cannot be disabled. * * set_config/clear_config are invoked in global write lock context */ int (*transport_link_set_config)(knet_handle_t knet_h, struct knet_link *link); int (*transport_link_clear_config)(knet_handle_t knet_h, struct knet_link *link); /* * transport callback for incoming dynamic connections * this is called in global read lock context */ int (*transport_link_dyn_connect)(knet_handle_t knet_h, int sockfd, struct knet_link *link); /* * per transport error handling of recvmmsg * (see _handle_recv_from_links comments for details) */ /* * transport_rx_sock_error is invoked when recvmmsg returns <= 0 * * transport_rx_sock_error is invoked with both global_rdlock */ int (*transport_rx_sock_error)(knet_handle_t knet_h, int sockfd, int recv_err, int recv_errno); /* * transport_tx_sock_error is invoked with global_rwlock and * it's invoked when sendto or sendmmsg returns =< 0 * * it should return: * -1 on internal error * 0 ignore error and continue * 1 retry * any sleep or wait action should happen inside the transport code */ int (*transport_tx_sock_error)(knet_handle_t knet_h, int sockfd, int recv_err, int recv_errno); /* * this function is called on _every_ received packet * to verify if the packet is data or internal protocol error handling * * it should return: * -1 on error * 0 packet is not data and we should continue the packet process loop * 1 packet is not data and we should STOP the packet process loop * 2 packet is data and should be parsed as such * * transport_rx_is_data is invoked with both global_rwlock * and fd_tracker read lock (from RX thread) */ int (*transport_rx_is_data)(knet_handle_t knet_h, int sockfd, struct knet_mmsghdr *msg); } knet_transport_ops_t; socklen_t sockaddr_len(const struct sockaddr_storage *ss); /** * This is a kernel style list implementation. * * @author Steven Dake */ struct knet_list_head { struct knet_list_head *next; struct knet_list_head *prev; }; /** * @def KNET_LIST_DECLARE() * Declare and initialize a list head. */ #define KNET_LIST_DECLARE(name) \ struct knet_list_head name = { &(name), &(name) } #define KNET_INIT_LIST_HEAD(ptr) do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) /** * Initialize the list entry. * * Points next and prev pointers to head. * @param head pointer to the list head */ static inline void knet_list_init(struct knet_list_head *head) { head->next = head; head->prev = head; } /** * Add this element to the list. * * @param element the new element to insert. * @param head pointer to the list head */ static inline void knet_list_add(struct knet_list_head *element, struct knet_list_head *head) { head->next->prev = element; element->next = head->next; element->prev = head; head->next = element; } /** * Add to the list (but at the end of the list). * * @param element pointer to the element to add * @param head pointer to the list head * @see knet_list_add() */ static inline void knet_list_add_tail(struct knet_list_head *element, struct knet_list_head *head) { head->prev->next = element; element->next = head; element->prev = head->prev; head->prev = element; } /** * Delete an entry from the list. * * @param _remove the list item to remove */ static inline void knet_list_del(struct knet_list_head *_remove) { _remove->next->prev = _remove->prev; _remove->prev->next = _remove->next; } /** * Replace old entry by new one * @param old: the element to be replaced * @param new: the new element to insert */ static inline void knet_list_replace(struct knet_list_head *old, struct knet_list_head *new) { new->next = old->next; new->next->prev = new; new->prev = old->prev; new->prev->next = new; } /** * Tests whether list is the last entry in list head * @param list: the entry to test * @param head: the head of the list * @return boolean true/false */ static inline int knet_list_is_last(const struct knet_list_head *list, const struct knet_list_head *head) { return list->next == head; } /** * A quick test to see if the list is empty (pointing to it's self). * @param head pointer to the list head * @return boolean true/false */ static inline int32_t knet_list_empty(const struct knet_list_head *head) { return head->next == head; } /** * Get the struct for this entry * @param ptr: the &struct list_head pointer. * @param type: the type of the struct this is embedded in. * @param member: the name of the list_struct within the struct. */ #define knet_list_entry(ptr,type,member)\ ((type *)((char *)(ptr)-(char*)(&((type *)0)->member))) /** * Get the first element from a list * @param ptr: the &struct list_head pointer. * @param type: the type of the struct this is embedded in. * @param member: the name of the list_struct within the struct. */ #define knet_list_first_entry(ptr, type, member) \ knet_list_entry((ptr)->next, type, member) /** * Iterate over a list * @param pos: the &struct list_head to use as a loop counter. * @param head: the head for your list. */ #define knet_list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** * Iterate over a list backwards * @param pos: the &struct list_head to use as a loop counter. * @param head: the head for your list. */ #define knet_list_for_each_reverse(pos, head) \ for (pos = (head)->prev; pos != (head); pos = pos->prev) /** * Iterate over a list safe against removal of list entry * @param pos: the &struct list_head to use as a loop counter. * @param n: another &struct list_head to use as temporary storage * @param head: the head for your list. */ #define knet_list_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) /** * Iterate over list of given type * @param pos: the type * to use as a loop counter. * @param head: the head for your list. * @param member: the name of the list_struct within the struct. */ #define knet_list_for_each_entry(pos, head, member) \ for (pos = knet_list_entry((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = knet_list_entry(pos->member.next, typeof(*pos), member)) #endif diff --git a/libknet/libknet.h b/libknet/libknet.h index 73bc2702..976ca911 100644 --- a/libknet/libknet.h +++ b/libknet/libknet.h @@ -1,1948 +1,1969 @@ /* * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * Federico Simoncelli * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #ifndef __LIBKNET_H__ #define __LIBKNET_H__ #include #include #include #include /** * @file libknet.h * @brief kronosnet API include file * @copyright Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. * * Kronosnet is an advanced VPN system for High Availability applications. */ /* * libknet limits */ /* * Maximum number of hosts */ typedef uint16_t knet_node_id_t; #define KNET_MAX_HOST 65536 /* * Maximum number of links between 2 hosts */ #define KNET_MAX_LINK 8 /* * Maximum packet size that should be written to datafd * see knet_handle_new for details */ #define KNET_MAX_PACKET_SIZE 65536 /* * Buffers used for pretty logging * host is used to store both ip addresses and hostnames */ #define KNET_MAX_HOST_LEN 256 #define KNET_MAX_PORT_LEN 6 /* * Some notifications can be generated either on TX or RX */ #define KNET_NOTIFY_TX 0 #define KNET_NOTIFY_RX 1 /* * Link flags */ /* * Where possible, set traffic priority to high. * On Linux this sets the TOS to INTERACTIVE (6), * see tc-prio(8) for more infomation */ #define KNET_LINK_FLAG_TRAFFICHIPRIO (1ULL << 0) +/* + * Handle flags + */ + +/* + * Use privileged operations during socket setup. + */ + +#define KNET_HANDLE_FLAG_PRIVILEGED (1ULL << 0) + typedef struct knet_handle *knet_handle_t; /* * Handle structs/API calls */ /** - * knet_handle_new + * knet_handle_new_ex * * @brief create a new instance of a knet handle * * host_id - Each host in a knet is identified with a unique * ID. when creating a new handle local host_id * must be specified (0 to UINT16T_MAX are all valid). * It is the user's responsibility to check that the value * is unique, or bad things might happen. * * log_fd - Write file descriptor. If set to a value > 0, it will be used * to write log packets from libknet to the application. * Setting to 0 will disable logging from libknet. * It is possible to enable logging at any given time (see logging API). * Make sure to either read from this filedescriptor properly and/or * mark it O_NONBLOCK, otherwise if the fd becomes full, libknet could * block. * * default_log_level - * If logfd is specified, it will initialize all subsystems to log * at default_log_level value. (see logging API) * + * flags - bitwise OR of some of the following flags: + * KNET_HANDLE_FLAG_PRIVILEGED: use privileged operations setting up the + * communication sockets. If disabled, failure to acquire large + * enough socket buffers is ignored but logged. Inadequate buffers + * lead to poor performance. + * * @return * on success, a new knet_handle_t is returned. * on failure, NULL is returned and errno is set. * knet-specific errno values: - * ENAMETOOLONG - socket buffers couldn't be set big enough + * ENAMETOOLONG - socket buffers couldn't be set big enough and KNET_HANDLE_FLAG_PRIVILEGED was specified * ERANGE - buffer size readback returned unexpected type */ +knet_handle_t knet_handle_new_ex(knet_node_id_t host_id, + int log_fd, + uint8_t default_log_level, + uint64_t flags); + +/** + * knet_handle_new + * + * @brief knet_handle_new_ex with flags = KNET_HANDLE_FLAG_PRIVILEGED. + */ + knet_handle_t knet_handle_new(knet_node_id_t host_id, int log_fd, uint8_t default_log_level); /** * knet_handle_free * @brief Destroy a knet handle, free all resources * * knet_h - pointer to knet_handle_t * * @return * knet_handle_free returns * 0 on success * -1 on error and errno is set. */ int knet_handle_free(knet_handle_t knet_h); /** * knet_handle_enable_sock_notify * @brief Register a callback to receive socket events * * knet_h - pointer to knet_handle_t * * sock_notify_fn_private_data * void pointer to data that can be used to identify * the callback. * * sock_notify_fn * A callback function that is invoked every time * a socket in the datafd pool will report an error (-1) * or an end of read (0) (see socket.7). * This function MUST NEVER block or add substantial delays. * The callback is invoked in an internal unlocked area * to allow calls to knet_handle_add_datafd/knet_handle_remove_datafd * to swap/replace the bad fd. * if both err and errno are 0, it means that the socket * has received a 0 byte packet (EOF?). * The callback function must either remove the fd from knet * (by calling knet_handle_remove_fd()) or dup a new fd in its place. * Failure to do this can cause problems. * * @return * knet_handle_enable_sock_notify returns * 0 on success * -1 on error and errno is set. */ int knet_handle_enable_sock_notify(knet_handle_t knet_h, void *sock_notify_fn_private_data, void (*sock_notify_fn) ( void *private_data, int datafd, int8_t channel, uint8_t tx_rx, int error, int errorno)); /* sorry! can't call it errno ;) */ #define KNET_DATAFD_MAX 32 /** * knet_handle_add_datafd * * @brief Install a file descriptor for communication * * IMPORTANT: In order to add datafd to knet, knet_handle_enable_sock_notify * _MUST_ be set and be able to handle both errors (-1) and * 0 bytes read / write from the provided datafd. * On read error (< 0) from datafd, the socket is automatically * removed from polling to avoid spinning on dead sockets. * It is safe to call knet_handle_remove_datafd even on sockets * that have been removed. * * knet_h - pointer to knet_handle_t * * *datafd - read/write file descriptor. * knet will read data here to send to the other hosts * and will write data received from the network. * Each data packet can be of max size KNET_MAX_PACKET_SIZE! * Applications using knet_send/knet_recv will receive a * proper error if the packet size is not within boundaries. * Applications using their own functions to write to the * datafd should NOT write more than KNET_MAX_PACKET_SIZE. * * Please refer to handle.c on how to set up a socketpair. * * datafd can be 0, and knet_handle_add_datafd will create a properly * populated socket pair the same way as ping_test, or a value * higher than 0. A negative number will return an error. * On exit knet_handle_free will take care to cleanup the * socketpair only if they have been created by knet_handle_add_datafd. * * It is possible to pass either sockets or normal fds. * User provided datafd will be marked as non-blocking and close-on-exit. * * *channel - This value has the same effect of VLAN tagging. * A negative value will auto-allocate a channel. * Setting a value between 0 and 31 will try to allocate that * specific channel (unless already in use). * * It is possible to add up to 32 datafds but be aware that each * one of them must have a receiving end on the other host. * * Example: * hostA channel 0 will be delivered to datafd on hostB channel 0 * hostA channel 1 to hostB channel 1. * * Each channel must have a unique file descriptor. * * If your application could have 2 channels on one host and one * channel on another host, then you can use dst_host_filter * to manipulate channel values on TX and RX. * * @return * knet_handle_add_datafd returns * @retval 0 on success, * *datafd will be populated with a socket if the original value was 0 * or if a specific fd was set, the value is untouched. * *channel will be populated with a channel number if the original value * was negative or the value is untouched if a specific channel * was requested. * * @retval -1 on error and errno is set. * *datafd and *channel are untouched or empty. */ int knet_handle_add_datafd(knet_handle_t knet_h, int *datafd, int8_t *channel); /** * knet_handle_remove_datafd * @brief Remove a file descriptor from knet * * knet_h - pointer to knet_handle_t * * datafd - file descriptor to remove. * NOTE that if the socket/fd was created by knet_handle_add_datafd, * the socket will be closed by libknet. * * @return * knet_handle_remove_datafd returns * 0 on success * -1 on error and errno is set. */ int knet_handle_remove_datafd(knet_handle_t knet_h, int datafd); /** * knet_handle_get_channel * @brief Get the channel associated with a file descriptor * * knet_h - pointer to knet_handle_t * * datafd - get the channel associated to this datafd * * *channel - will contain the result * * @return * knet_handle_get_channel returns * @retval 0 on success * and *channel will contain the result * @retval -1 on error and errno is set. * and *channel content is meaningless */ int knet_handle_get_channel(knet_handle_t knet_h, const int datafd, int8_t *channel); /** * knet_handle_get_datafd * @brief Get the file descriptor associated with a channel * * knet_h - pointer to knet_handle_t * * channel - get the datafd associated to this channel * * *datafd - will contain the result * * @return * knet_handle_get_datafd returns * @retval 0 on success * and *datafd will contain the results * @retval -1 on error and errno is set. * and *datafd content is meaningless */ int knet_handle_get_datafd(knet_handle_t knet_h, const int8_t channel, int *datafd); /** * knet_recv * @brief Receive data from knet nodes * * knet_h - pointer to knet_handle_t * * buff - pointer to buffer to store the received data * * buff_len - buffer length * * channel - channel number * * @return * knet_recv is a commodity function to wrap iovec operations * around a socket. It returns a call to readv(2). */ ssize_t knet_recv(knet_handle_t knet_h, char *buff, const size_t buff_len, const int8_t channel); /** * knet_send * @brief Send data to knet nodes * * knet_h - pointer to knet_handle_t * * buff - pointer to the buffer of data to send * * buff_len - length of data to send * * channel - channel number * * @return * knet_send is a commodity function to wrap iovec operations * around a socket. It returns a call to writev(2). */ ssize_t knet_send(knet_handle_t knet_h, const char *buff, const size_t buff_len, const int8_t channel); /** * knet_send_sync * * @brief Synchronously send data to knet nodes * * knet_h - pointer to knet_handle_t * * buff - pointer to the buffer of data to send * * buff_len - length of data to send * * channel - data channel to use (see knet_handle_add_datafd(3)) * * All knet RX/TX operations are async for performance reasons. * There are applications that might need a sync version of data * transmission and receive errors in case of failure to deliver * to another host. * knet_send_sync bypasses the whole TX async layer and delivers * data directly to the link layer, and returns errors accordingly. * knet_send_sync sends only one packet to one host at a time. * It does NOT support multiple destinations or multicast packets. * Decision is still based on dst_host_filter_fn. * * @return * knet_send_sync returns 0 on success and -1 on error. * In addition to normal sendmmsg errors, knet_send_sync can fail * due to: * * @retval ECANCELED - data forward is disabled * @retval EFAULT - dst_host_filter fatal error * @retval EINVAL - dst_host_filter did not provide dst_host_ids_entries on unicast pckts * @retval E2BIG - dst_host_filter did return more than one dst_host_ids_entries on unicast pckts * @retval ENOMSG - received unknown message type * @retval EHOSTDOWN - unicast pckt cannot be delivered because dest host is not connected yet * @retval ECHILD - crypto failed * @retval EAGAIN - sendmmsg was unable to send all messages and there was no progress during retry */ int knet_send_sync(knet_handle_t knet_h, const char *buff, const size_t buff_len, const int8_t channel); /** * knet_handle_enable_filter * * @brief install a filter to route packets * * knet_h - pointer to knet_handle_t * * dst_host_filter_fn_private_data * void pointer to data that can be used to identify * the callback. * * dst_host_filter_fn - * is a callback function that is invoked every time * a packet hits datafd (see knet_handle_new(3)). * the function allows users to tell libknet where the * packet has to be delivered. * * const unsigned char *outdata - is a pointer to the * current packet * ssize_t outdata_len - length of the above data * uint8_t tx_rx - filter is called on tx or rx * (KNET_NOTIFY_TX, KNET_NOTIFY_RX) * knet_node_id_t this_host_id - host_id processing the packet * knet_node_id_t src_host_id - host_id that generated the * packet * knet_node_id_t *dst_host_ids - array of KNET_MAX_HOST knet_node_id_t * where to store the destinations * size_t *dst_host_ids_entries - number of hosts to send the message * * dst_host_filter_fn should return * -1 on error, packet is discarded. * 0 packet is unicast and should be sent to dst_host_ids and there are * dst_host_ids_entries in the buffer. * 1 packet is broadcast/multicast and is sent all hosts. * contents of dst_host_ids and dst_host_ids_entries are ignored. * (see also kronosnetd/etherfilter.* for an example that filters based * on ether protocol) * * @return * knet_handle_enable_filter returns * 0 on success * -1 on error and errno is set. */ int knet_handle_enable_filter(knet_handle_t knet_h, void *dst_host_filter_fn_private_data, int (*dst_host_filter_fn) ( void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_host_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries)); /** * knet_handle_setfwd * * @brief Start packet forwarding * * knet_h - pointer to knet_handle_t * * enable - set to 1 to allow data forwarding, 0 to disable data forwarding. * * @return * knet_handle_setfwd returns * 0 on success * -1 on error and errno is set. * * By default data forwarding is off and no traffic will pass through knet until * it is set on. */ int knet_handle_setfwd(knet_handle_t knet_h, unsigned int enabled); #define KNET_PMTUD_DEFAULT_INTERVAL 60 /** * knet_handle_pmtud_setfreq * * @brief Set the interval between PMTUd scans * * knet_h - pointer to knet_handle_t * * interval - define the interval in seconds between PMTUd scans * range from 1 to 86400 (24h) * * @return * knet_handle_pmtud_setfreq returns * 0 on success * -1 on error and errno is set. * * default interval is 60. */ int knet_handle_pmtud_setfreq(knet_handle_t knet_h, unsigned int interval); /** * knet_handle_pmtud_getfreq * * @brief Get the interval between PMTUd scans * * knet_h - pointer to knet_handle_t * * interval - pointer where to store the current interval value * * @return * knet_handle_pmtud_setfreq returns * 0 on success * -1 on error and errno is set. */ int knet_handle_pmtud_getfreq(knet_handle_t knet_h, unsigned int *interval); /** * knet_handle_enable_pmtud_notify * * @brief install a callback to receive PMTUd changes * * knet_h - pointer to knet_handle_t * * pmtud_notify_fn_private_data * void pointer to data that can be used to identify * the callback. * * pmtud_notify_fn * is a callback function that is invoked every time * a path MTU size change is detected. * The function allows libknet to notify the user * of data MTU, that's the max value that can be send * onwire without fragmentation. The data MTU will always * be lower than real link MTU because it accounts for * protocol overhead, knet packet header and (if configured) * crypto overhead, * This function MUST NEVER block or add substantial delays. * * @return * knet_handle_enable_pmtud_notify returns * 0 on success * -1 on error and errno is set. */ int knet_handle_enable_pmtud_notify(knet_handle_t knet_h, void *pmtud_notify_fn_private_data, void (*pmtud_notify_fn) ( void *private_data, unsigned int data_mtu)); /** * knet_handle_pmtud_get * * @brief Get the current data MTU * * knet_h - pointer to knet_handle_t * * data_mtu - pointer where to store data_mtu * * @return * knet_handle_pmtud_get returns * 0 on success * -1 on error and errno is set. */ int knet_handle_pmtud_get(knet_handle_t knet_h, unsigned int *data_mtu); #define KNET_MIN_KEY_LEN 256 #define KNET_MAX_KEY_LEN 4096 struct knet_handle_crypto_cfg { char crypto_model[16]; char crypto_cipher_type[16]; char crypto_hash_type[16]; unsigned char private_key[KNET_MAX_KEY_LEN]; unsigned int private_key_len; }; /** * knet_handle_crypto * * @brief set up packet cryptographic signing & encryption * * knet_h - pointer to knet_handle_t * * knet_handle_crypto_cfg - * pointer to a knet_handle_crypto_cfg structure * * crypto_model should contain the model name. * Currently only "openssl" and "nss" are supported. * Setting to "none" will disable crypto. * * crypto_cipher_type * should contain the cipher algo name. * It can be set to "none" to disable * encryption. * Currently supported by "nss" model: * "3des", "aes128", "aes192" and "aes256". * "openssl" model supports more modes and it strictly * depends on the openssl build. See: EVP_get_cipherbyname * openssl API call for details. * * crypto_hash_type * should contain the hashing algo name. * It can be set to "none" to disable * hashing. * Currently supported by "nss" model: * "md5", "sha1", "sha256", "sha384" and "sha512". * "openssl" model supports more modes and it strictly * depends on the openssl build. See: EVP_get_digestbyname * openssl API call for details. * * private_key will contain the private shared key. * It has to be at least KNET_MIN_KEY_LEN long. * * private_key_len * length of the provided private_key. * * Implementation notes/current limitations: * - enabling crypto, will increase latency as packets have * to processed. * - enabling crypto might reduce the overall throughtput * due to crypto data overhead. * - re-keying is not implemented yet. * - private/public key encryption/hashing is not currently * planned. * - crypto key must be the same for all hosts in the same * knet instance. * - it is safe to call knet_handle_crypto multiple times at runtime. * The last config will be used. * IMPORTANT: a call to knet_handle_crypto can fail due to: * 1) failure to obtain locking * 2) errors to initializing the crypto level. * This can happen even in subsequent calls to knet_handle_crypto. * A failure in crypto init, might leave your traffic unencrypted! * It's best to stop data forwarding (see knet_handle_setfwd(3)), change crypto config, * start forward again. * * @return * knet_handle_crypto returns: * @retval 0 on success * @retval -1 on error and errno is set. * @retval -2 on crypto subsystem initialization error. No errno is provided at the moment (yet). */ int knet_handle_crypto(knet_handle_t knet_h, struct knet_handle_crypto_cfg *knet_handle_crypto_cfg); #define KNET_COMPRESS_THRESHOLD 100 struct knet_handle_compress_cfg { char compress_model[16]; uint32_t compress_threshold; int compress_level; }; /** * knet_handle_compress * * @brief Set up packet compression * * knet_h - pointer to knet_handle_t * * knet_handle_compress_cfg - * pointer to a knet_handle_compress_cfg structure * - * compress_model should contain the mode name. - * Currently only "zlib" and "lz4" are supported. - * Setting to "none" will disable compression. + * compress_model contains the model name. + * See "compress_level" for the list of accepted values. + * Setting the value to "none" disables compression. * * compress_threshold * tells the transmission thread to NOT compress * any packets that are smaller than the value * indicated. Default 100 bytes. * Set to 0 to reset to the default. * Set to 1 to compress everything. * Max accepted value is KNET_MAX_PACKET_SIZE. * - * compress_level some compression libraries allow tuning of compression - * parameters. - * For example zlib value ranges from 0 to 9 where 0 is no - * compression and 9 is max compression. - * This value is passed pristine to the compression library. + * compress_level is the "level" parameter for most models: * zlib: 0 (no compression), 1 (minimal) .. 9 (max compression). * lz4: 1 (max compression)... 9 (fastest compression). * lz4hc: 1 (min compression) ... LZ4HC_MAX_CLEVEL (16) or LZ4HC_CLEVEL_MAX (12) - * depends on the installed version of lz4hc. libknet can detects the max - * value and will print an appropriate warning. - * lzo2: accepts only some specific values depending on the - * requested algorithm: + * depending on the version of lz4hc libknet was built with. + * lzma: 0 (minimal) .. 9 (max compression) + * bzip2: 1 (minimal) .. 9 (max compression) + * For lzo2 it selects the algorithm to use: * 1 : lzo1x_1_compress (default) * 11 : lzo1x_1_11_compress * 12 : lzo1x_1_12_compress * 15 : lzo1x_1_15_compress * 999: lzo1x_999_compress - * every other values will use default - * lzma: 0 (minimal) .. 9 (max compression) - * bzip2: 1 (minimal) .. 9 (max compression) - * Please refer to the library man pages - * on how to be set this value, as it is passed - * unmodified to the compression algorithm where supported. + * Other values select the default algorithm. + * Please refer to the documentation of the respective + * compression library for guidance about setting this + * value. * * Implementation notes: * - it is possible to enable/disable compression at any time. * - nodes can be using a different compression algorithm at any time. * - knet does NOT implement the compression algorithm directly. it relies * on external libraries for this functionality. Please read * the libraries man pages to figure out which algorithm/compression * level is best for the data you are planning to transmit. * * @return * knet_handle_compress returns * 0 on success * -1 on error and errno is set. EINVAL means that either the model or the * level are not supported. */ int knet_handle_compress(knet_handle_t knet_h, struct knet_handle_compress_cfg *knet_handle_compress_cfg); struct knet_handle_stats { size_t size; uint64_t tx_uncompressed_packets; uint64_t tx_compressed_packets; uint64_t tx_compressed_original_bytes; uint64_t tx_compressed_size_bytes; uint64_t tx_compress_time_ave; uint64_t tx_compress_time_min; uint64_t tx_compress_time_max; uint64_t rx_compressed_packets; uint64_t rx_compressed_original_bytes; uint64_t rx_compressed_size_bytes; uint64_t rx_compress_time_ave; uint64_t rx_compress_time_min; uint64_t rx_compress_time_max; /* Overhead times, measured in usecs */ uint64_t tx_crypt_packets; uint64_t tx_crypt_byte_overhead; uint64_t tx_crypt_time_ave; uint64_t tx_crypt_time_min; uint64_t tx_crypt_time_max; uint64_t rx_crypt_packets; uint64_t rx_crypt_time_ave; uint64_t rx_crypt_time_min; uint64_t rx_crypt_time_max; }; /** * knet_handle_get_stats * * @brief Get statistics for compression & crypto * * knet_h - pointer to knet_handle_t * * knet_handle_stats * pointer to a knet_handle_stats structure * * struct_size * size of knet_handle_stats structure to allow * for backwards compatibility. libknet will only * copy this much data into the stats structure * so that older callers will not get overflowed if * new fields are added. * * @return * 0 on success * -1 on error and errno is set. * */ int knet_handle_get_stats(knet_handle_t knet_h, struct knet_handle_stats *stats, size_t struct_size); /* * Tell knet_handle_clear_stats whether to clear just the handle stats * or all of them. */ #define KNET_CLEARSTATS_HANDLE_ONLY 1 #define KNET_CLEARSTATS_HANDLE_AND_LINK 2 /** * knet_handle_clear_stats * * @brief Clear knet stats, link and/or handle * * knet_h - pointer to knet_handle_t * * clear_option - Which stats to clear, must be one of * * KNET_CLEARSTATS_HANDLE_ONLY or * KNET_CLEARSTATS_HANDLE_AND_LINK * * @return * 0 on success * -1 on error and errno is set. * */ int knet_handle_clear_stats(knet_handle_t knet_h, int clear_option); struct knet_crypto_info { const char *name; /* openssl,nss,etc.. */ uint8_t properties; /* currently unused */ char pad[256]; /* currently unused */ }; /** * knet_get_crypto_list * * @brief Get a list of supported crypto libraries * * crypto_list - array of struct knet_crypto_info * * If NULL then only the number of structs is returned in crypto_list_entries * to allow the caller to allocate sufficient space. * libknet does not allow more than 256 crypto methods at the moment. * it is safe to allocate 256 structs to avoid calling * knet_get_crypto_list twice. * * crypto_list_entries - returns the number of structs in crypto_list * * @return * knet_get_crypto_list returns * 0 on success * -1 on error and errno is set. */ int knet_get_crypto_list(struct knet_crypto_info *crypto_list, size_t *crypto_list_entries); struct knet_compress_info { const char *name; /* bzip2, lz4, etc.. */ uint8_t properties; /* currently unused */ char pad[256]; /* currently unused */ }; /** * knet_get_compress_list * * @brief Get a list of support compression types * * compress_list - array of struct knet_compress_info * * If NULL then only the number of structs is returned in compress_list_entries * to allow the caller to allocate sufficient space. * libknet does not allow more than 256 compress methods at the moment. * it is safe to allocate 256 structs to avoid calling * knet_get_compress_list twice. * * compress_list_entries - returns the number of structs in compress_list * * @return * knet_get_compress_list returns * 0 on success * -1 on error and errno is set. */ int knet_get_compress_list(struct knet_compress_info *compress_list, size_t *compress_list_entries); /* * host structs/API calls */ /** * knet_host_add * * @brief Add a new host ID to knet * * knet_h - pointer to knet_handle_t * * host_id - each host in a knet is identified with a unique ID * (see also knet_handle_new(3)) * * @return * knet_host_add returns: * 0 on success * -1 on error and errno is set. */ int knet_host_add(knet_handle_t knet_h, knet_node_id_t host_id); /** * knet_host_remove * * @brief Remove a host ID from knet * * knet_h - pointer to knet_handle_t * * host_id - each host in a knet is identified with a unique ID * (see also knet_handle_new(3)) * * @return * knet_host_remove returns: * 0 on success * -1 on error and errno is set. */ int knet_host_remove(knet_handle_t knet_h, knet_node_id_t host_id); /** * knet_host_set_name * * @brief Set the name of a knet host * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * name - this name will be used for pretty logging and eventually * search for hosts (see also knet_handle_host_get_name(2) and knet_handle_host_get_id(3)). * Only up to KNET_MAX_HOST_LEN - 1 bytes will be accepted and * name has to be unique for each host. * * @return * knet_host_set_name returns: * 0 on success * -1 on error and errno is set. */ int knet_host_set_name(knet_handle_t knet_h, knet_node_id_t host_id, const char *name); /** * knet_host_get_name_by_host_id * * @brief Get the name of a host given its ID * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * name - pointer to a preallocated buffer of at least size KNET_MAX_HOST_LEN * where the current host name will be stored * (as set by knet_host_set_name or default by knet_host_add) * * @return * knet_host_get_name_by_host_id returns: * 0 on success * -1 on error and errno is set (name is left untouched) */ int knet_host_get_name_by_host_id(knet_handle_t knet_h, knet_node_id_t host_id, char *name); /** * knet_host_get_id_by_host_name * * @brief Get the ID of a host given its name * * knet_h - pointer to knet_handle_t * * name - name to lookup, max len KNET_MAX_HOST_LEN * * host_id - where to store the result * * @return * knet_host_get_id_by_host_name returns: * 0 on success * -1 on error and errno is set. */ int knet_host_get_id_by_host_name(knet_handle_t knet_h, const char *name, knet_node_id_t *host_id); /** * knet_host_get_host_list * * @brief Get a list of hosts known to knet * * knet_h - pointer to knet_handle_t * * host_ids - array of at lest KNET_MAX_HOST size * * host_ids_entries - * number of entries writted in host_ids * * @return * knet_host_get_host_list returns * 0 on success * -1 on error and errno is set. */ int knet_host_get_host_list(knet_handle_t knet_h, knet_node_id_t *host_ids, size_t *host_ids_entries); /* * define switching policies */ #define KNET_LINK_POLICY_PASSIVE 0 #define KNET_LINK_POLICY_ACTIVE 1 #define KNET_LINK_POLICY_RR 2 /** * knet_host_set_policy * * knet_h - pointer to knet_handle_t * * @brief Set the switching policy for a host's links * * host_id - see knet_host_add(3) * * policy - there are currently 3 kind of simple switching policies * based on link configuration. * KNET_LINK_POLICY_PASSIVE - the active link with the lowest * priority will be used. * if one or more active links share * the same priority, the one with * lowest link_id will be used. * * KNET_LINK_POLICY_ACTIVE - all active links will be used * simultaneously to send traffic. * link priority is ignored. * * KNET_LINK_POLICY_RR - round-robin policy, every packet * will be send on a different active * link. * * @return * knet_host_set_policy returns * 0 on success * -1 on error and errno is set. */ int knet_host_set_policy(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t policy); /** * knet_host_get_policy * * @brief Get the switching policy for a host's links * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * policy - will contain the current configured switching policy. * Default is passive when creating a new host. * * @return * knet_host_get_policy returns * 0 on success * -1 on error and errno is set. */ int knet_host_get_policy(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t *policy); /** * knet_host_enable_status_change_notify * * @brief Install a callback to get host status change events * * knet_h - pointer to knet_handle_t * * host_status_change_notify_fn_private_data - * void pointer to data that can be used to identify * the callback * * host_status_change_notify_fn - * is a callback function that is invoked every time * there is a change in the host status. * host status is identified by: * - reachable, this host can send/receive data to/from host_id * - remote, 0 if the host_id is connected locally or 1 if * the there is one or more knet host(s) in between. * NOTE: re-switching is NOT currently implemented, * but this is ready for future and can avoid * an API/ABI breakage later on. * - external, 0 if the host_id is configured locally or 1 if * it has been added from remote nodes config. * NOTE: dynamic topology is NOT currently implemented, * but this is ready for future and can avoid * an API/ABI breakage later on. * This function MUST NEVER block or add substantial delays. * * @return * knet_host_status_change_notify returns * 0 on success * -1 on error and errno is set. */ int knet_host_enable_status_change_notify(knet_handle_t knet_h, void *host_status_change_notify_fn_private_data, void (*host_status_change_notify_fn) ( void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external)); /* * define host status structure for quick lookup * struct is in flux as more stats will be added soon * * reachable host_id can be seen either directly connected * or via another host_id * * remote 0 = node is connected locally, 1 is visible via * via another host_id * * external 0 = node is configured/known locally, * 1 host_id has been received via another host_id */ struct knet_host_status { uint8_t reachable; uint8_t remote; uint8_t external; /* add host statistics */ }; /** * knet_host_status_get * * @brief Get the status of a host * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * status - pointer to knet_host_status struct * * @return * knet_handle_pmtud_get returns * 0 on success * -1 on error and errno is set. */ int knet_host_get_status(knet_handle_t knet_h, knet_node_id_t host_id, struct knet_host_status *status); /* * link structs/API calls * * every host allocated/managed by knet_host_* has * KNET_MAX_LINK structures to define the network * paths that connect 2 hosts. * * Each link is identified by a link_id that has a * values between 0 and KNET_MAX_LINK - 1. * * KNOWN LIMITATIONS: * * - let's assume the scenario where two hosts are connected * with any number of links. link_id must match on both sides. * If host_id 0 link_id 0 is configured to connect IP1 to IP2 and * host_id 0 link_id 1 is configured to connect IP3 to IP4, * host_id 1 link_id 0 _must_ connect IP2 to IP1 and likewise * host_id 1 link_id 1 _must_ connect IP4 to IP3. * We might be able to lift this restriction in future, by using * other data to determine src/dst link_id, but for now, deal with it. */ /* * commodity functions to convert strings to sockaddr and viceversa */ /** * knet_strtoaddr * * @brief Convert a hostname string to an address * * host - IPaddr/hostname to convert * be aware only the first IP address will be returned * in case a hostname resolves to multiple IP * * port - port to connect to * * ss - sockaddr_storage where to store the converted data * * sslen - len of the sockaddr_storage * * @return * knet_strtoaddr returns same error codes as getaddrinfo * */ int knet_strtoaddr(const char *host, const char *port, struct sockaddr_storage *ss, socklen_t sslen); /** * knet_addrtostr * * @brief Convert an address to a host name * * ss - sockaddr_storage to convert * * sslen - len of the sockaddr_storage * * host - IPaddr/hostname where to store data * (recommended size: KNET_MAX_HOST_LEN) * * port - port buffer where to store data * (recommended size: KNET_MAX_PORT_LEN) * * @return * knet_strtoaddr returns same error codes as getnameinfo */ int knet_addrtostr(const struct sockaddr_storage *ss, socklen_t sslen, char *addr_buf, size_t addr_buf_size, char *port_buf, size_t port_buf_size); #define KNET_TRANSPORT_LOOPBACK 0 #define KNET_TRANSPORT_UDP 1 #define KNET_TRANSPORT_SCTP 2 #define KNET_MAX_TRANSPORTS UINT8_MAX /* * The Loopback transport is only valid for connections to localhost, the host * with the same node_id specified in knet_handle_new(). Only one link of this * type is allowed. Data sent down a LOOPBACK link will be copied directly from * the knet send datafd to the knet receive datafd so the application must be set * up to take data from that socket at least as often as it is sent or deadlocks * could occur. If used, a LOOPBACK link must be the only link configured to the * local host. */ struct knet_transport_info { const char *name; /* UDP/SCTP/etc... */ uint8_t id; /* value that can be used for link_set_config */ uint8_t properties; /* currently unused */ char pad[256]; /* currently unused */ }; /** * knet_get_transport_list * * @brief Get a list of the transports support by this build of knet * * transport_list - an array of struct transport_info that must be * at least of size struct transport_info * KNET_MAX_TRANSPORTS * * transport_list_entries - pointer to a size_t where to store how many transports * are available in this build of libknet. * * @return * knet_get_transport_list returns * 0 on success * -1 on error and errno is set. */ int knet_get_transport_list(struct knet_transport_info *transport_list, size_t *transport_list_entries); /** * knet_get_transport_name_by_id * * @brief Get a transport name from its ID number * * transport - one of the KNET_TRANSPORT_xxx constants * * @return * knet_get_transport_name_by_id returns: * * @retval pointer to the name on success or * @retval NULL on error and errno is set. */ const char *knet_get_transport_name_by_id(uint8_t transport); /** * knet_get_transport_id_by_name * * @brief Get a transport ID from its name * * name - transport name (UDP/SCTP/etc) * * @return * knet_get_transport_name_by_id returns: * * @retval KNET_MAX_TRANSPORTS on error and errno is set accordingly * @retval KNET_TRANSPORT_xxx on success. */ uint8_t knet_get_transport_id_by_name(const char *name); #define KNET_TRANSPORT_DEFAULT_RECONNECT_INTERVAL 1000 /** * knet_handle_set_transport_reconnect_interval * * @brief Set the interval between transport attempts to reconnect a failed link * * knet_h - pointer to knet_handle_t * * msecs - milliseconds * * @return * knet_handle_set_transport_reconnect_interval returns * 0 on success * -1 on error and errno is set. */ int knet_handle_set_transport_reconnect_interval(knet_handle_t knet_h, uint32_t msecs); /** * knet_handle_get_transport_reconnect_interval * * @brief Get the interval between transport attempts to reconnect a failed link * * knet_h - pointer to knet_handle_t * * msecs - milliseconds * * @return * knet_handle_get_transport_reconnect_interval returns * 0 on success * -1 on error and errno is set. */ int knet_handle_get_transport_reconnect_interval(knet_handle_t knet_h, uint32_t *msecs); /** * knet_link_set_config * * @brief Configure the link to a host * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * transport - one of the KNET_TRANSPORT_xxx constants * * src_addr - sockaddr_storage that can be either IPv4 or IPv6 * * dst_addr - sockaddr_storage that can be either IPv4 or IPv6 * this can be null if we don't know the incoming * IP address/port and the link will remain quiet * till the node on the other end will initiate a * connection * * flags - KNET_LINK_FLAG_* * * @return * knet_link_set_config returns * 0 on success * -1 on error and errno is set. */ int knet_link_set_config(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t transport, struct sockaddr_storage *src_addr, struct sockaddr_storage *dst_addr, uint64_t flags); /** * knet_link_get_config * * @brief Get the link configutation information * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * transport - see knet_link_set_config(3) * * src_addr - sockaddr_storage that can be either IPv4 or IPv6 * * dst_addr - sockaddr_storage that can be either IPv4 or IPv6 * * dynamic - 0 if dst_addr is static or 1 if dst_addr is dynamic. * In case of 1, dst_addr can be NULL and it will be left * untouched. * * flags - KNET_LINK_FLAG_* * * @return * knet_link_get_config returns * 0 on success. * -1 on error and errno is set. */ int knet_link_get_config(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t *transport, struct sockaddr_storage *src_addr, struct sockaddr_storage *dst_addr, uint8_t *dynamic, uint64_t *flags); /** * knet_link_clear_config * * @brief Clear link information and disconnect the link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * @return * knet_link_clear_config returns * 0 on success. * -1 on error and errno is set. */ int knet_link_clear_config(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id); /** * knet_link_set_enable * * @brief Enable traffic on a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * enabled - 0 disable the link, 1 enable the link * * @return * knet_link_set_enable returns * 0 on success * -1 on error and errno is set. */ int knet_link_set_enable(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, unsigned int enabled); /** * knet_link_get_enable * * @brief Find out whether a link is enabled or not * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * enabled - 0 disable the link, 1 enable the link * * @return * knet_link_get_enable returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_enable(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, unsigned int *enabled); #define KNET_LINK_DEFAULT_PING_INTERVAL 1000 /* 1 second */ #define KNET_LINK_DEFAULT_PING_TIMEOUT 2000 /* 2 seconds */ #define KNET_LINK_DEFAULT_PING_PRECISION 2048 /* samples */ /** * knet_link_set_ping_timers * * @brief Set the ping timers for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * interval - specify the ping interval in milliseconds. * * timeout - if no pong is received within this time, * the link is declared dead, in milliseconds. * NOTE: in future it will be possible to set timeout to 0 * for an autocalculated timeout based on interval, pong_count * and latency. The API already accept 0 as value and it will * return ENOSYS / -1. Once the automatic calculation feature * will be implemented, this call will only return EINVAL * for incorrect values. * * precision - how many values of latency are used to calculate * the average link latency (see also knet_link_get_status(3)) * * @return * knet_link_set_ping_timers returns * 0 on success * -1 on error and errno is set. */ int knet_link_set_ping_timers(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, time_t interval, time_t timeout, unsigned int precision); /** * knet_link_get_ping_timers * * @brief Get the ping timers for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * interval - ping interval * * timeout - if no pong is received within this time, * the link is declared dead * * precision - how many values of latency are used to calculate * the average link latency (see also knet_link_get_status(3)) * * @return * knet_link_get_ping_timers returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_ping_timers(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, time_t *interval, time_t *timeout, unsigned int *precision); #define KNET_LINK_DEFAULT_PONG_COUNT 5 /** * knet_link_set_pong_count * * @brief Set the pong count for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * pong_count - how many valid ping/pongs before a link is marked UP. * default: 5, value should be > 0 * * @return * knet_link_set_pong_count returns * 0 on success * -1 on error and errno is set. */ int knet_link_set_pong_count(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t pong_count); /** * knet_link_get_pong_count * * @brief Get the pong count for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * pong_count - how many valid ping/pongs before a link is marked UP. * default: 5, value should be > 0 * * @return * knet_link_get_pong_count returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_pong_count(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t *pong_count); /** * knet_link_set_priority * * @brief Set the priority for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * priority - specify the switching priority for this link * see also knet_host_set_policy * * @return * knet_link_set_priority returns * 0 on success * -1 on error and errno is set. */ int knet_link_set_priority(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t priority); /** * knet_link_get_priority * * @brief Get the priority for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * priority - gather the switching priority for this link * see also knet_host_set_policy * * @return * knet_link_get_priority returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_priority(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, uint8_t *priority); /** * knet_link_get_link_list * * @brief Get a list of links connecting a host * * knet_h - pointer to knet_handle_t * * link_ids - array of at lest KNET_MAX_LINK size * with the list of configured links for a certain host. * * link_ids_entries - * number of entries contained in link_ids * * @return * knet_link_get_link_list returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_link_list(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t *link_ids, size_t *link_ids_entries); /* * define link status structure for quick lookup * * src/dst_{ipaddr,port} strings are filled by * getnameinfo(3) when configuring the link. * if the link is dynamic (see knet_link_set_config(3)) * dst_ipaddr/port will contain ipaddr/port of the currently * connected peer or "Unknown" if it was not possible * to determine the ipaddr/port at runtime. * * enabled see also knet_link_set/get_enable. * * connected the link is connected to a peer and ping/pong traffic * is flowing. * * dynconnected the link has dynamic ip on the other end, and * we can see the other host is sending pings to us. * * latency average latency of this link * see also knet_link_set/get_timeout. * * pong_last if the link is down, this value tells us how long * ago this link was active. A value of 0 means that the link * has never been active. * * knet_link_stats structure that contains details statistics for the link */ #define MAX_LINK_EVENTS 16 struct knet_link_stats { /* onwire values */ uint64_t tx_data_packets; uint64_t rx_data_packets; uint64_t tx_data_bytes; uint64_t rx_data_bytes; uint64_t rx_ping_packets; uint64_t tx_ping_packets; uint64_t rx_ping_bytes; uint64_t tx_ping_bytes; uint64_t rx_pong_packets; uint64_t tx_pong_packets; uint64_t rx_pong_bytes; uint64_t tx_pong_bytes; uint64_t rx_pmtu_packets; uint64_t tx_pmtu_packets; uint64_t rx_pmtu_bytes; uint64_t tx_pmtu_bytes; /* Only filled in when requested */ uint64_t tx_total_packets; uint64_t rx_total_packets; uint64_t tx_total_bytes; uint64_t rx_total_bytes; uint64_t tx_total_errors; uint64_t tx_total_retries; uint32_t tx_pmtu_errors; uint32_t tx_pmtu_retries; uint32_t tx_ping_errors; uint32_t tx_ping_retries; uint32_t tx_pong_errors; uint32_t tx_pong_retries; uint32_t tx_data_errors; uint32_t tx_data_retries; /* measured in usecs */ uint32_t latency_min; uint32_t latency_max; uint32_t latency_ave; uint32_t latency_samples; /* how many times the link has been going up/down */ uint32_t down_count; uint32_t up_count; /* * circular buffer of time_t structs collecting the history * of up/down events on this link. * the index indicates current/last event. * it is safe to walk back the history by decreasing the index */ time_t last_up_times[MAX_LINK_EVENTS]; time_t last_down_times[MAX_LINK_EVENTS]; int8_t last_up_time_index; int8_t last_down_time_index; /* Always add new stats at the end */ }; struct knet_link_status { size_t size; /* For ABI checking */ char src_ipaddr[KNET_MAX_HOST_LEN]; char src_port[KNET_MAX_PORT_LEN]; char dst_ipaddr[KNET_MAX_HOST_LEN]; char dst_port[KNET_MAX_PORT_LEN]; uint8_t enabled; /* link is configured and admin enabled for traffic */ uint8_t connected; /* link is connected for data (local view) */ uint8_t dynconnected; /* link has been activated by remote dynip */ unsigned long long latency; /* average latency computed by fix/exp */ struct timespec pong_last; unsigned int mtu; /* current detected MTU on this link */ unsigned int proto_overhead; /* contains the size of the IP protocol, knet headers and * crypto headers (if configured). This value is filled in * ONLY after the first PMTUd run on that given link, * and can change if link configuration or crypto configuration * changes at runtime. * WARNING: in general mtu + proto_overhead might or might * not match the output of ifconfig mtu due to crypto * requirements to pad packets to some specific boundaries. */ /* Link statistics */ struct knet_link_stats stats; }; /** * knet_link_get_status * * @brief Get the status (and statistics) for a link * * knet_h - pointer to knet_handle_t * * host_id - see knet_host_add(3) * * link_id - see knet_link_set_config(3) * * status - pointer to knet_link_status struct * * struct_size - max size of knet_link_status - allows library to * add fields without ABI change. Returned structure * will be truncated to this length and .size member * indicates the full size. * * @return * knet_link_get_status returns * 0 on success * -1 on error and errno is set. */ int knet_link_get_status(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id, struct knet_link_status *status, size_t struct_size); /* * logging structs/API calls */ /* * libknet is composed of several subsystems. In order * to easily distinguish log messages coming from different * places, each subsystem has its own ID. * * 0-19 config/management * 20-39 internal threads * 40-59 transports * 60-69 crypto implementations */ #define KNET_SUB_COMMON 0 /* common.c */ #define KNET_SUB_HANDLE 1 /* handle.c alloc/dealloc config changes */ #define KNET_SUB_HOST 2 /* host add/del/modify */ #define KNET_SUB_LISTENER 3 /* listeners add/del/modify... */ #define KNET_SUB_LINK 4 /* link add/del/modify */ #define KNET_SUB_TRANSPORT 5 /* Transport common */ #define KNET_SUB_CRYPTO 6 /* crypto.c config generic layer */ #define KNET_SUB_COMPRESS 7 /* compress.c config generic layer */ #define KNET_SUB_FILTER 19 /* allocated for users to log from dst_filter */ #define KNET_SUB_DSTCACHE 20 /* switching thread (destination cache handling) */ #define KNET_SUB_HEARTBEAT 21 /* heartbeat thread */ #define KNET_SUB_PMTUD 22 /* Path MTU Discovery thread */ #define KNET_SUB_TX 23 /* send to link thread */ #define KNET_SUB_RX 24 /* recv from link thread */ #define KNET_SUB_TRANSP_BASE 40 /* Base log level for transports */ #define KNET_SUB_TRANSP_LOOPBACK (KNET_SUB_TRANSP_BASE + KNET_TRANSPORT_LOOPBACK) #define KNET_SUB_TRANSP_UDP (KNET_SUB_TRANSP_BASE + KNET_TRANSPORT_UDP) #define KNET_SUB_TRANSP_SCTP (KNET_SUB_TRANSP_BASE + KNET_TRANSPORT_SCTP) #define KNET_SUB_NSSCRYPTO 60 /* nsscrypto.c */ #define KNET_SUB_OPENSSLCRYPTO 61 /* opensslcrypto.c */ #define KNET_SUB_ZLIBCOMP 70 /* compress_zlib.c */ #define KNET_SUB_LZ4COMP 71 /* compress_lz4.c */ #define KNET_SUB_LZ4HCCOMP 72 /* compress_lz4.c */ #define KNET_SUB_LZO2COMP 73 /* compress_lzo.c */ #define KNET_SUB_LZMACOMP 74 /* compress_lzma.c */ #define KNET_SUB_BZIP2COMP 75 /* compress_bzip2.c */ #define KNET_SUB_UNKNOWN UINT8_MAX - 1 #define KNET_MAX_SUBSYSTEMS UINT8_MAX /* * Convert between subsystem IDs and names */ /** * knet_log_get_subsystem_name * * @brief Get a logging system name from its numeric ID * * @return * returns internal name of the subsystem or "common" */ const char *knet_log_get_subsystem_name(uint8_t subsystem); /** * knet_log_get_subsystem_id * * @brief Get a logging system ID from its name * * @return * returns internal ID of the subsystem or KNET_SUB_COMMON */ uint8_t knet_log_get_subsystem_id(const char *name); /* * 4 log levels are enough for everybody */ #define KNET_LOG_ERR 0 /* unrecoverable errors/conditions */ #define KNET_LOG_WARN 1 /* recoverable errors/conditions */ #define KNET_LOG_INFO 2 /* info, link up/down, config changes.. */ #define KNET_LOG_DEBUG 3 /* * Convert between log level values and names */ /** * knet_log_get_loglevel_name * * @brief Get a logging level name from its numeric ID * * @return * returns internal name of the log level or "ERROR" for unknown values */ const char *knet_log_get_loglevel_name(uint8_t level); /** * knet_log_get_loglevel_id * * @brief Get a logging level ID from its name * * @return * returns internal log level ID or KNET_LOG_ERR for invalid names */ uint8_t knet_log_get_loglevel_id(const char *name); /* * every log message is composed by a text message (including a trailing \n) * and message level/subsystem IDs. * In order to make debugging easier it is possible to send those packets * straight to stdout/stderr (see knet_bench.c stdout option). */ #define KNET_MAX_LOG_MSG_SIZE 256 struct knet_log_msg { char msg[KNET_MAX_LOG_MSG_SIZE - (sizeof(uint8_t)*2)]; uint8_t subsystem; /* KNET_SUB_* */ uint8_t msglevel; /* KNET_LOG_* */ }; /** * knet_log_set_log_level * * @brief Set the logging level for a subsystem * * knet_h - same as above * * subsystem - same as above * * level - same as above * * knet_log_set_loglevel allows fine control of log levels by subsystem. * See also knet_handle_new for defaults. * * @return * knet_log_set_loglevel returns * 0 on success * -1 on error and errno is set. */ int knet_log_set_loglevel(knet_handle_t knet_h, uint8_t subsystem, uint8_t level); /** * knet_log_get_log_level * * @brief Get the logging level for a subsystem * * knet_h - same as above * * subsystem - same as above * * level - same as above * * @return * knet_log_get_loglevel returns * 0 on success * -1 on error and errno is set. */ int knet_log_get_loglevel(knet_handle_t knet_h, uint8_t subsystem, uint8_t *level); #endif diff --git a/libknet/man/knet_addrtostr.3 b/libknet/man/knet_addrtostr.3 deleted file mode 100644 index 2427d3b3..00000000 --- a/libknet/man/knet_addrtostr.3 +++ /dev/null @@ -1,42 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_addrtostr 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_addrtostr \- Convert an address to a host name. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_addrtostr\fP( - \fBconst struct sockaddr_storage *\fP\fIss\fP, - \fBsocklen_t \fP\fIsslen\fP, - \fBchar *\fP\fIaddr_buf\fP, - \fBsize_t \fP\fIaddr_buf_size\fP, - \fBchar *\fP\fIport_buf\fP, - \fBsize_t \fP\fIport_buf_size\fP -); -.fi -.SH DESCRIPTION -.PP -knet_addrtostr -.PP -ss - sockaddr_storage to convert -.PP -sslen - len of the sockaddr_storage -.PP -host - IPaddr/hostname where to store data (recommended size: KNET_MAX_HOST_LEN) -.PP -port - port buffer where to store data (recommended size: KNET_MAX_PORT_LEN) -.SH RETURN VALUE -.PP -knet_strtoaddr returns same error codes as getnameinfo -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_get_compress_list.3 b/libknet/man/knet_get_compress_list.3 deleted file mode 100644 index c393debd..00000000 --- a/libknet/man/knet_get_compress_list.3 +++ /dev/null @@ -1,50 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_get_compress_list 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_get_compress_list \- Get a list of support compression types. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_get_compress_list\fP( - \fBstruct knet_compress_info *\fP\fIcompress_list\fP, - \fBsize_t *\fP\fIcompress_list_entries\fP -); -.fi -.SH DESCRIPTION -.PP -knet_get_compress_list -.PP -compress_list - array of struct knet_compress_info * If NULL then only the number of structs is returned in compress_list_entries to allow the caller to allocate sufficient space. libknet does not allow more than 256 compress methods at the moment. it is safe to allocate 256 structs to avoid calling knet_get_compress_list twice. -.PP -compress_list_entries - returns the number of structs in compress_list -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_compress_info { - const char *\fIname\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_get_compress_list returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_get_crypto_list.3 b/libknet/man/knet_get_crypto_list.3 deleted file mode 100644 index bfa1065f..00000000 --- a/libknet/man/knet_get_crypto_list.3 +++ /dev/null @@ -1,50 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_get_crypto_list 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_get_crypto_list \- Get a list of supported crypto libraries. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_get_crypto_list\fP( - \fBstruct knet_crypto_info *\fP\fIcrypto_list\fP, - \fBsize_t *\fP\fIcrypto_list_entries\fP -); -.fi -.SH DESCRIPTION -.PP -knet_get_crypto_list -.PP -crypto_list - array of struct knet_crypto_info * If NULL then only the number of structs is returned in crypto_list_entries to allow the caller to allocate sufficient space. libknet does not allow more than 256 crypto methods at the moment. it is safe to allocate 256 structs to avoid calling knet_get_crypto_list twice. -.PP -crypto_list_entries - returns the number of structs in crypto_list -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_crypto_info { - const char *\fIname\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_get_crypto_list returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_get_transport_id_by_name.3 b/libknet/man/knet_get_transport_id_by_name.3 deleted file mode 100644 index 520c65e1..00000000 --- a/libknet/man/knet_get_transport_id_by_name.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_get_transport_id_by_name 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_get_transport_id_by_name \- Get a transport ID from its name. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBuint8_t knet_get_transport_id_by_name\fP( - \fBconst char *\fP\fIname\fP -); -.fi -.SH DESCRIPTION -.PP -knet_get_transport_id_by_name -.PP -name - transport name (UDP/SCTP/etc) -.SH RETURN VALUE -.PP -knet_get_transport_name_by_id returns: -.TP -.B KNET_MAX_TRANSPORTS -on error and errno is set accordingly - -.TP -.B KNET_TRANSPORT_xxx -on success. - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_get_transport_list.3 b/libknet/man/knet_get_transport_list.3 deleted file mode 100644 index 45d4a921..00000000 --- a/libknet/man/knet_get_transport_list.3 +++ /dev/null @@ -1,51 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_get_transport_list 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_get_transport_list \- Get a list of the transports support by this build of knet. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_get_transport_list\fP( - \fBstruct knet_transport_info *\fP\fItransport_list\fP, - \fBsize_t *\fP\fItransport_list_entries\fP -); -.fi -.SH DESCRIPTION -.PP -knet_get_transport_list -.PP -transport_list - an array of struct transport_info that must be at least of size struct transport_info * KNET_MAX_TRANSPORTS -.PP -transport_list_entries - pointer to a size_t where to store how many transports are available in this build of libknet. -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_transport_info { - const char *\fIname\fP; - uint8_t \fIid\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_get_transport_list returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_get_transport_name_by_id.3 b/libknet/man/knet_get_transport_name_by_id.3 deleted file mode 100644 index ba5f2b2c..00000000 --- a/libknet/man/knet_get_transport_name_by_id.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_get_transport_name_by_id 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_get_transport_name_by_id \- Get a transport name from its ID number. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBconst char * knet_get_transport_name_by_id\fP( - \fBuint8_t \fP\fItransport\fP -); -.fi -.SH DESCRIPTION -.PP -knet_get_transport_name_by_id -.PP -transport - one of the KNET_TRANSPORT_xxx constants -.SH RETURN VALUE -.PP -knet_get_transport_name_by_id returns: -.TP -.B pointer -to the name on success or - -.TP -.B NULL -on error and errno is set. - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_add_datafd.3 b/libknet/man/knet_handle_add_datafd.3 deleted file mode 100644 index 358d0561..00000000 --- a/libknet/man/knet_handle_add_datafd.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_add_datafd 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_add_datafd \- Install a file descriptor for communication. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_add_datafd\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBint *\fP\fIdatafd\fP, - \fBint8_t *\fP\fIchannel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_add_datafd -.PP -IMPORTANT: In order to add datafd to knet, knet_handle_enable_sock_notify MUST be set and be able to handle both errors (-1) and 0 bytes read / write from the provided datafd. On read error (< 0) from datafd, the socket is automatically removed from polling to avoid spinning on dead sockets. It is safe to call knet_handle_remove_datafd even on sockets that have been removed. -.PP -knet_h - pointer to knet_handle_t -.PP -*datafd - read/write file descriptor. knet will read data here to send to the other hosts and will write data received from the network. Each data packet can be of max size KNET_MAX_PACKET_SIZE! Applications using knet_send/knet_recv will receive a proper error if the packet size is not within boundaries. Applications using their own functions to write to the datafd should NOT write more than KNET_MAX_PACKET_SIZE. -.PP -Please refer to handle.c on how to set up a socketpair. -.PP -datafd can be 0, and knet_handle_add_datafd will create a properly populated socket pair the same way as ping_test, or a value higher than 0. A negative number will return an error. On exit knet_handle_free will take care to cleanup the socketpair only if they have been created by knet_handle_add_datafd. -.PP -It is possible to pass either sockets or normal fds. User provided datafd will be marked as non-blocking and close-on-exit. -.PP -*channel - This value has the same effect of VLAN tagging. A negative value will auto-allocate a channel. Setting a value between 0 and 31 will try to allocate that specific channel (unless already in use). -.PP -It is possible to add up to 32 datafds but be aware that each one of them must have a receiving end on the other host. -.PP -Example: hostA channel 0 will be delivered to datafd on hostB channel 0 hostA channel 1 to hostB channel 1. -.PP -Each channel must have a unique file descriptor. -.PP -If your application could have 2 channels on one host and one channel on another host, then you can use dst_host_filter to manipulate channel values on TX and RX. -.SH RETURN VALUE -.PP -knet_handle_add_datafd returns -.TP -.B 0 -on success, *datafd will be populated with a socket if the original value was 0 or if a specific fd was set, the value is untouched. *channel will be populated with a channel number if the original value was negative or the value is untouched if a specific channel was requested. - -.TP -.B -1 -on error and errno is set. *datafd and *channel are untouched or empty. - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_clear_stats.3 b/libknet/man/knet_handle_clear_stats.3 deleted file mode 100644 index c148a56b..00000000 --- a/libknet/man/knet_handle_clear_stats.3 +++ /dev/null @@ -1,36 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_clear_stats 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_clear_stats \- Clear knet stats, link and/or handle. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_clear_stats\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBint \fP\fIclear_option\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_clear_stats -.PP -knet_h - pointer to knet_handle_t -.PP -clear_option - Which stats to clear, must be one of -.PP -KNET_CLEARSTATS_HANDLE_ONLY or KNET_CLEARSTATS_HANDLE_AND_LINK -.SH RETURN VALUE -.PP -0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_compress.3 b/libknet/man/knet_handle_compress.3 deleted file mode 100644 index 179d95fd..00000000 --- a/libknet/man/knet_handle_compress.3 +++ /dev/null @@ -1,58 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_compress 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_compress \- Set up packet compression. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_compress\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBstruct knet_handle_compress_cfg *\fP\fIknet_handle_compress_cfg\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_compress -.PP -knet_h - pointer to knet_handle_t -.PP -knet_handle_compress_cfg - pointer to a knet_handle_compress_cfg structure -.PP -compress_model should contain the mode name. Currently only "zlib" and "lz4" are supported. Setting to "none" will disable compression. -.PP -compress_threshold tells the transmission thread to NOT compress any packets that are smaller than the value indicated. Default 100 bytes. Set to 0 to reset to the default. Set to 1 to compress everything. Max accepted value is KNET_MAX_PACKET_SIZE. -.PP -compress_level some compression libraries allow tuning of compression parameters. For example zlib value ranges from 0 to 9 where 0 is no compression and 9 is max compression. This value is passed pristine to the compression library. zlib: 0 (no compression), 1 (minimal) .. 9 (max compression). lz4: 1 (max compression)... 9 (fastest compression). lz4hc: 1 (min compression) ... LZ4HC_MAX_CLEVEL (16) or LZ4HC_CLEVEL_MAX (12) depends on the installed version of lz4hc. libknet can detects the max value and will print an appropriate warning. lzo2: accepts only some specific values depending on the requested algorithm: 1 : lzo1x_1_compress (default) 11 : lzo1x_1_11_compress 12 : lzo1x_1_12_compress 15 : lzo1x_1_15_compress 999: lzo1x_999_compress every other values will use default lzma: 0 (minimal) .. 9 (max compression) bzip2: 1 (minimal) .. 9 (max compression) Please refer to the library man pages on how to be set this value, as it is passed unmodified to the compression algorithm where supported. -.PP -knet does NOT implement the compression algorithm directly. it relies on external libraries for this functionality. Please read the libraries man pages to figure out which algorithm/compression level is best for the data you are planning to transmit. -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_compress_cfg { - char \fIcompress_model\fP; - uint32_t \fIcompress_threshold\fP; - int \fIcompress_level\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_handle_compress returns 0 on success -1 on error and errno is set. EINVAL means that either the model or the level are not supported. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_crypto.3 b/libknet/man/knet_handle_crypto.3 deleted file mode 100644 index 302a0d84..00000000 --- a/libknet/man/knet_handle_crypto.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_crypto 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_crypto \- set up packet cryptographic signing & encryption -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_crypto\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBstruct knet_handle_crypto_cfg *\fP\fIknet_handle_crypto_cfg\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_crypto -.PP -knet_h - pointer to knet_handle_t -.PP -knet_handle_crypto_cfg - pointer to a knet_handle_crypto_cfg structure -.PP -crypto_model should contain the model name. Currently only "openssl" and "nss" are supported. Setting to "none" will disable crypto. -.PP -crypto_cipher_type should contain the cipher algo name. It can be set to "none" to disable encryption. Currently supported by "nss" model: "3des", "aes128", "aes192" and "aes256". "openssl" model supports more modes and it strictly depends on the openssl build. See: EVP_get_cipherbyname openssl API call for details. -.PP -crypto_hash_type should contain the hashing algo name. It can be set to "none" to disable hashing. Currently supported by "nss" model: "md5", "sha1", "sha256", "sha384" and "sha512". "openssl" model supports more modes and it strictly depends on the openssl build. See: EVP_get_digestbyname openssl API call for details. -.PP -private_key will contain the private shared key. It has to be at least KNET_MIN_KEY_LEN long. -.PP -private_key_len length of the provided private_key. -.PP -it is safe to call knet_handle_crypto multiple times at runtime. The last config will be used. IMPORTANT: a call to knet_handle_crypto can fail due to: 1) failure to obtain locking 2) errors to initializing the crypto level. This can happen even in subsequent calls to knet_handle_crypto. A failure in crypto init, might leave your traffic unencrypted! It's best to stop data forwarding (see knet_handle_setfwd(3)), change crypto config, start forward again. -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_crypto_cfg { - char \fIcrypto_model\fP; - char \fIcrypto_cipher_type\fP; - char \fIcrypto_hash_type\fP; - unsigned char \fIprivate_key\fP; - unsigned int \fIprivate_key_len\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_handle_crypto returns: -.TP -.B 0 -on success - -.TP -.B -1 -on error and errno is set. - -.TP -.B -2 -on crypto subsystem initialization error. No errno is provided at the moment (yet). - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_enable_filter.3 b/libknet/man/knet_handle_enable_filter.3 deleted file mode 100644 index c0f8516f..00000000 --- a/libknet/man/knet_handle_enable_filter.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_enable_filter 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_enable_filter \- install a filter to route packets -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_enable_filter\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBvoid *\fP\fIdst_host_filter_fn_private_data\fP, - \fBint(*)(void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_host_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries) \fP\fIdst_host_filter_fn\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_enable_filter -.PP -knet_h - pointer to knet_handle_t -.PP -dst_host_filter_fn_private_data void pointer to data that can be used to identify the callback. -.PP -dst_host_filter_fn - is a callback function that is invoked every time a packet hits datafd (see knet_handle_new(3)). the function allows users to tell libknet where the packet has to be delivered. -.PP -const unsigned char *outdata - is a pointer to the current packet ssize_t outdata_len - length of the above data uint8_t tx_rx - filter is called on tx or rx (KNET_NOTIFY_TX, KNET_NOTIFY_RX) knet_node_id_t this_host_id - host_id processing the packet knet_node_id_t src_host_id - host_id that generated the packet knet_node_id_t *dst_host_ids - array of KNET_MAX_HOST knet_node_id_t where to store the destinations size_t *dst_host_ids_entries - number of hosts to send the message -.PP -dst_host_filter_fn should return -1 on error, packet is discarded. 0 packet is unicast and should be sent to dst_host_ids and there are dst_host_ids_entries in the buffer. 1 packet is broadcast/multicast and is sent all hosts. contents of dst_host_ids and dst_host_ids_entries are ignored. (see also kronosnetd/etherfilter.* for an example that filters based on ether protocol) -.SH RETURN VALUE -.PP -knet_handle_enable_filter returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_enable_pmtud_notify.3 b/libknet/man/knet_handle_enable_pmtud_notify.3 deleted file mode 100644 index 11f1082b..00000000 --- a/libknet/man/knet_handle_enable_pmtud_notify.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_enable_pmtud_notify 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_enable_pmtud_notify \- install a callback to receive PMTUd changes -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_enable_pmtud_notify\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBvoid *\fP\fIpmtud_notify_fn_private_data\fP, - \fBvoid(*)(void *private_data, unsigned int data_mtu) \fP\fIpmtud_notify_fn\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_enable_pmtud_notify -.PP -knet_h - pointer to knet_handle_t -.PP -pmtud_notify_fn_private_data void pointer to data that can be used to identify the callback. -.PP -pmtud_notify_fn is a callback function that is invoked every time a path MTU size change is detected. The function allows libknet to notify the user of data MTU, that's the max value that can be send onwire without fragmentation. The data MTU will always be lower than real link MTU because it accounts for protocol overhead, knet packet header and (if configured) crypto overhead, This function MUST NEVER block or add substantial delays. -.SH RETURN VALUE -.PP -knet_handle_enable_pmtud_notify returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_enable_sock_notify.3 b/libknet/man/knet_handle_enable_sock_notify.3 deleted file mode 100644 index 74a829a1..00000000 --- a/libknet/man/knet_handle_enable_sock_notify.3 +++ /dev/null @@ -1,35 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_enable_sock_notify 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_enable_sock_notify \- Register a callback to receive socket events. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_enable_sock_notify\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBvoid *\fP\fIsock_notify_fn_private_data\fP, - \fBvoid(*)(void *private_data, int datafd, int8_t channel, uint8_t tx_rx, int error, int errorno) \fP\fIsock_notify_fn\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_enable_sock_notify knet_h - pointer to knet_handle_t -.PP -sock_notify_fn_private_data void pointer to data that can be used to identify the callback. -.PP -sock_notify_fn A callback function that is invoked every time a socket in the datafd pool will report an error (-1) or an end of read (0) (see socket.7). This function MUST NEVER block or add substantial delays. The callback is invoked in an internal unlocked area to allow calls to knet_handle_add_datafd/knet_handle_remove_datafd to swap/replace the bad fd. if both err and errno are 0, it means that the socket has received a 0 byte packet (EOF?). The callback function must either remove the fd from knet (by calling knet_handle_remove_fd()) or dup a new fd in its place. Failure to do this can cause problems. -.SH RETURN VALUE -.PP -knet_handle_enable_sock_notify returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_free.3 b/libknet/man/knet_handle_free.3 deleted file mode 100644 index b2b27ce1..00000000 --- a/libknet/man/knet_handle_free.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_free 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_free \- Destroy a knet handle, free all resources. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_free\fP( - \fBknet_handle_t \fP\fIknet_h\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_free knet_h - pointer to knet_handle_t -.SH RETURN VALUE -.PP -knet_handle_free returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_get_channel.3 b/libknet/man/knet_handle_get_channel.3 deleted file mode 100644 index 28ad7a87..00000000 --- a/libknet/man/knet_handle_get_channel.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_get_channel 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_get_channel \- Get the channel associated with a file descriptor. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_get_channel\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBconst int \fP\fIdatafd\fP, - \fBint8_t *\fP\fIchannel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_get_channel knet_h - pointer to knet_handle_t -.PP -datafd - get the channel associated to this datafd -.PP -*channel - will contain the result -.SH RETURN VALUE -.PP -knet_handle_get_channel returns -.TP -.B 0 -on success and *channel will contain the result - -.TP -.B -1 -on error and errno is set. and *channel content is meaningless - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_get_datafd.3 b/libknet/man/knet_handle_get_datafd.3 deleted file mode 100644 index dbda74e3..00000000 --- a/libknet/man/knet_handle_get_datafd.3 +++ /dev/null @@ -1,43 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_get_datafd 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_get_datafd \- Get the file descriptor associated with a channel. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_get_datafd\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBconst int8_t \fP\fIchannel\fP, - \fBint *\fP\fIdatafd\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_get_datafd knet_h - pointer to knet_handle_t -.PP -channel - get the datafd associated to this channel -.PP -*datafd - will contain the result -.SH RETURN VALUE -.PP -knet_handle_get_datafd returns -.TP -.B 0 -on success and *datafd will contain the results - -.TP -.B -1 -on error and errno is set. and *datafd content is meaningless - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_get_stats.3 b/libknet/man/knet_handle_get_stats.3 deleted file mode 100644 index e329c7dd..00000000 --- a/libknet/man/knet_handle_get_stats.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_get_stats 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_get_stats \- Get statistics for compression & crypto. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_get_stats\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBstruct knet_handle_stats *\fP\fIstats\fP, - \fBsize_t \fP\fIstruct_size\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_get_stats -.PP -knet_h - pointer to knet_handle_t -.PP -knet_handle_stats pointer to a knet_handle_stats structure -.PP -struct_size size of knet_handle_stats structure to allow for backwards compatibility. libknet will only copy this much data into the stats structure so that older callers will not get overflowed if new fields are added. -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_stats { - size_t \fIsize\fP; - uint64_t \fItx_uncompressed_packets\fP; - uint64_t \fItx_compressed_packets\fP; - uint64_t \fItx_compressed_original_bytes\fP; - uint64_t \fItx_compressed_size_bytes\fP; - uint64_t \fItx_compress_time_ave\fP; - uint64_t \fItx_compress_time_min\fP; - uint64_t \fItx_compress_time_max\fP; - uint64_t \fIrx_compressed_packets\fP; - uint64_t \fIrx_compressed_original_bytes\fP; - uint64_t \fIrx_compressed_size_bytes\fP; - uint64_t \fIrx_compress_time_ave\fP; - uint64_t \fIrx_compress_time_min\fP; - uint64_t \fIrx_compress_time_max\fP; - uint64_t \fItx_crypt_packets\fP; - uint64_t \fItx_crypt_byte_overhead\fP; - uint64_t \fItx_crypt_time_ave\fP; - uint64_t \fItx_crypt_time_min\fP; - uint64_t \fItx_crypt_time_max\fP; - uint64_t \fIrx_crypt_packets\fP; - uint64_t \fIrx_crypt_time_ave\fP; - uint64_t \fIrx_crypt_time_min\fP; - uint64_t \fIrx_crypt_time_max\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_get_transport_reconnect_interval.3 b/libknet/man/knet_handle_get_transport_reconnect_interval.3 deleted file mode 100644 index 44f4fc13..00000000 --- a/libknet/man/knet_handle_get_transport_reconnect_interval.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_get_transport_reconnect_interval 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_get_transport_reconnect_interval \- Get the interval between transport attempts to reconnect a failed link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_get_transport_reconnect_interval\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBuint32_t *\fP\fImsecs\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_get_transport_reconnect_interval -.PP -knet_h - pointer to knet_handle_t -.PP -msecs - milliseconds -.SH RETURN VALUE -.PP -knet_handle_get_transport_reconnect_interval returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_new.3 b/libknet/man/knet_handle_new.3 deleted file mode 100644 index 89fdc9f9..00000000 --- a/libknet/man/knet_handle_new.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_new 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_new \- create a new instance of a knet handle -.SH SYNOPSIS -.nf -.B #include -.sp -\fBknet_handle_t knet_handle_new\fP( - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBint \fP\fIlog_fd\fP, - \fBuint8_t \fP\fIdefault_log_level\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_new -.PP -host_id - Each host in a knet is identified with a unique ID. when creating a new handle local host_id must be specified (0 to UINT16T_MAX are all valid). It is the user's responsibility to check that the value is unique, or bad things might happen. -.PP -log_fd - Write file descriptor. If set to a value > 0, it will be used to write log packets from libknet to the application. Setting to 0 will disable logging from libknet. It is possible to enable logging at any given time (see logging API). Make sure to either read from this filedescriptor properly and/or mark it O_NONBLOCK, otherwise if the fd becomes full, libknet could block. -.PP -default_log_level - If logfd is specified, it will initialize all subsystems to log at default_log_level value. (see logging API) -.SH RETURN VALUE -.PP -on success, a new knet_handle_t is returned. on failure, NULL is returned and errno is set. knet-specific errno values: ENAMETOOLONG - socket buffers couldn't be set big enough ERANGE - buffer size readback returned unexpected type -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_pmtud_get.3 b/libknet/man/knet_handle_pmtud_get.3 deleted file mode 100644 index 99a70c73..00000000 --- a/libknet/man/knet_handle_pmtud_get.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_pmtud_get 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_pmtud_get \- Get the current data MTU. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_pmtud_get\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBunsigned int *\fP\fIdata_mtu\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_pmtud_get -.PP -knet_h - pointer to knet_handle_t -.PP -data_mtu - pointer where to store data_mtu -.SH RETURN VALUE -.PP -knet_handle_pmtud_get returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_pmtud_getfreq.3 b/libknet/man/knet_handle_pmtud_getfreq.3 deleted file mode 100644 index 2682512c..00000000 --- a/libknet/man/knet_handle_pmtud_getfreq.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_pmtud_getfreq 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_pmtud_getfreq \- Get the interval between PMTUd scans. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_pmtud_getfreq\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBunsigned int *\fP\fIinterval\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_pmtud_getfreq -.PP -knet_h - pointer to knet_handle_t -.PP -interval - pointer where to store the current interval value -.SH RETURN VALUE -.PP -knet_handle_pmtud_setfreq returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_pmtud_setfreq.3 b/libknet/man/knet_handle_pmtud_setfreq.3 deleted file mode 100644 index f34fe92e..00000000 --- a/libknet/man/knet_handle_pmtud_setfreq.3 +++ /dev/null @@ -1,36 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_pmtud_setfreq 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_pmtud_setfreq \- Set the interval between PMTUd scans. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_pmtud_setfreq\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBunsigned int \fP\fIinterval\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_pmtud_setfreq -.PP -knet_h - pointer to knet_handle_t -.PP -interval - define the interval in seconds between PMTUd scans range from 1 to 86400 (24h) -.PP -default interval is 60. -.SH RETURN VALUE -.PP -knet_handle_pmtud_setfreq returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_remove_datafd.3 b/libknet/man/knet_handle_remove_datafd.3 deleted file mode 100644 index f5be2a6a..00000000 --- a/libknet/man/knet_handle_remove_datafd.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_remove_datafd 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_remove_datafd \- Remove a file descriptor from knet. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_remove_datafd\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBint \fP\fIdatafd\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_remove_datafd knet_h - pointer to knet_handle_t -.PP -datafd - file descriptor to remove. NOTE that if the socket/fd was created by knet_handle_add_datafd, the socket will be closed by libknet. -.SH RETURN VALUE -.PP -knet_handle_remove_datafd returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_set_transport_reconnect_interval.3 b/libknet/man/knet_handle_set_transport_reconnect_interval.3 deleted file mode 100644 index a9e62007..00000000 --- a/libknet/man/knet_handle_set_transport_reconnect_interval.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_set_transport_reconnect_interval 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_set_transport_reconnect_interval \- Set the interval between transport attempts to reconnect a failed link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_set_transport_reconnect_interval\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBuint32_t \fP\fImsecs\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_set_transport_reconnect_interval -.PP -knet_h - pointer to knet_handle_t -.PP -msecs - milliseconds -.SH RETURN VALUE -.PP -knet_handle_set_transport_reconnect_interval returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_handle_setfwd.3 b/libknet/man/knet_handle_setfwd.3 deleted file mode 100644 index d3037b24..00000000 --- a/libknet/man/knet_handle_setfwd.3 +++ /dev/null @@ -1,36 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_handle_setfwd 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_handle_setfwd \- Start packet forwarding. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_handle_setfwd\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBunsigned int \fP\fIenabled\fP -); -.fi -.SH DESCRIPTION -.PP -knet_handle_setfwd -.PP -knet_h - pointer to knet_handle_t -.PP -enable - set to 1 to allow data forwarding, 0 to disable data forwarding. -.PP -By default data forwarding is off and no traffic will pass through knet until it is set on. -.SH RETURN VALUE -.PP -knet_handle_setfwd returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_add.3 b/libknet/man/knet_host_add.3 deleted file mode 100644 index 159dcf13..00000000 --- a/libknet/man/knet_host_add.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_add 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_add \- Add a new host ID to knet. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_add\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_add -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - each host in a knet is identified with a unique ID (see also knet_handle_new(3)) -.SH RETURN VALUE -.PP -knet_host_add returns: 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_enable_status_change_notify.3 b/libknet/man/knet_host_enable_status_change_notify.3 deleted file mode 100644 index 5a1fa56a..00000000 --- a/libknet/man/knet_host_enable_status_change_notify.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_enable_status_change_notify 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_enable_status_change_notify \- Install a callback to get host status change events. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_enable_status_change_notify\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBvoid *\fP\fIhost_status_change_notify_fn_private_data\fP, - \fBvoid(*)(void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external) \fP\fIhost_status_change_notify_fn\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_enable_status_change_notify -.PP -knet_h - pointer to knet_handle_t -.PP -host_status_change_notify_fn_private_data - void pointer to data that can be used to identify the callback -.PP -external, 0 if the host_id is configured locally or 1 if it has been added from remote nodes config. NOTE: dynamic topology is NOT currently implemented, but this is ready for future and can avoid an API/ABI breakage later on. This function MUST NEVER block or add substantial delays. -.SH RETURN VALUE -.PP -knet_host_status_change_notify returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_get_host_list.3 b/libknet/man/knet_host_get_host_list.3 deleted file mode 100644 index 7bf6c3b1..00000000 --- a/libknet/man/knet_host_get_host_list.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_get_host_list 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_get_host_list \- Get a list of hosts known to knet. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_get_host_list\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t *\fP\fIhost_ids\fP, - \fBsize_t *\fP\fIhost_ids_entries\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_get_host_list -.PP -knet_h - pointer to knet_handle_t -.PP -host_ids - array of at lest KNET_MAX_HOST size -.PP -host_ids_entries - number of entries writted in host_ids -.SH RETURN VALUE -.PP -knet_host_get_host_list returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_get_id_by_host_name.3 b/libknet/man/knet_host_get_id_by_host_name.3 deleted file mode 100644 index e4cbe0f9..00000000 --- a/libknet/man/knet_host_get_id_by_host_name.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_get_id_by_host_name 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_get_id_by_host_name \- Get the ID of a host given its name. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_get_id_by_host_name\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBconst char *\fP\fIname\fP, - \fBknet_node_id_t *\fP\fIhost_id\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_get_id_by_host_name -.PP -knet_h - pointer to knet_handle_t -.PP -name - name to lookup, max len KNET_MAX_HOST_LEN -.PP -host_id - where to store the result -.SH RETURN VALUE -.PP -knet_host_get_id_by_host_name returns: 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_get_name_by_host_id.3 b/libknet/man/knet_host_get_name_by_host_id.3 deleted file mode 100644 index cb373536..00000000 --- a/libknet/man/knet_host_get_name_by_host_id.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_get_name_by_host_id 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_get_name_by_host_id \- Get the name of a host given its ID. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_get_name_by_host_id\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBchar *\fP\fIname\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_get_name_by_host_id -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -name - pointer to a preallocated buffer of at least size KNET_MAX_HOST_LEN where the current host name will be stored (as set by knet_host_set_name or default by knet_host_add) -.SH RETURN VALUE -.PP -knet_host_get_name_by_host_id returns: 0 on success -1 on error and errno is set (name is left untouched) -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_get_policy.3 b/libknet/man/knet_host_get_policy.3 deleted file mode 100644 index 859d1e38..00000000 --- a/libknet/man/knet_host_get_policy.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_get_policy 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_get_policy \- Get the switching policy for a host's links. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_get_policy\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t *\fP\fIpolicy\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_get_policy -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -policy - will contain the current configured switching policy. Default is passive when creating a new host. -.SH RETURN VALUE -.PP -knet_host_get_policy returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_get_status.3 b/libknet/man/knet_host_get_status.3 deleted file mode 100644 index 40e78830..00000000 --- a/libknet/man/knet_host_get_status.3 +++ /dev/null @@ -1,53 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_get_status 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_get_status \- Get the status of a host. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_get_status\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBstruct knet_host_status *\fP\fIstatus\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_status_get -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -status - pointer to knet_host_status struct -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_host_status { - uint8_t \fIreachable\fP; - uint8_t \fIremote\fP; - uint8_t \fIexternal\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_handle_pmtud_get returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_remove.3 b/libknet/man/knet_host_remove.3 deleted file mode 100644 index d5cc8686..00000000 --- a/libknet/man/knet_host_remove.3 +++ /dev/null @@ -1,34 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_remove 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_remove \- Remove a host ID from knet. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_remove\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_remove -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - each host in a knet is identified with a unique ID (see also knet_handle_new(3)) -.SH RETURN VALUE -.PP -knet_host_remove returns: 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_set_name.3 b/libknet/man/knet_host_set_name.3 deleted file mode 100644 index 374a3eef..00000000 --- a/libknet/man/knet_host_set_name.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_set_name 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_set_name \- Set the name of a knet host. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_set_name\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBconst char *\fP\fIname\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_set_name -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -name - this name will be used for pretty logging and eventually search for hosts (see also knet_handle_host_get_name(2) and knet_handle_host_get_id(3)). Only up to KNET_MAX_HOST_LEN - 1 bytes will be accepted and name has to be unique for each host. -.SH RETURN VALUE -.PP -knet_host_set_name returns: 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_host_set_policy.3 b/libknet/man/knet_host_set_policy.3 deleted file mode 100644 index c6be0838..00000000 --- a/libknet/man/knet_host_set_policy.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_host_set_policy 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_host_set_policy \- Set the switching policy for a host's links. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_host_set_policy\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIpolicy\fP -); -.fi -.SH DESCRIPTION -.PP -knet_host_set_policy -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -policy - there are currently 3 kind of simple switching policies based on link configuration. KNET_LINK_POLICY_PASSIVE - the active link with the lowest priority will be used. if one or more active links share the same priority, the one with lowest link_id will be used. -.PP -KNET_LINK_POLICY_ACTIVE - all active links will be used simultaneously to send traffic. link priority is ignored. -.PP -KNET_LINK_POLICY_RR - round-robin policy, every packet will be send on a different active link. -.SH RETURN VALUE -.PP -knet_host_set_policy returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_clear_config.3 b/libknet/man/knet_link_clear_config.3 deleted file mode 100644 index 095138cc..00000000 --- a/libknet/man/knet_link_clear_config.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_clear_config 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_clear_config \- Clear link information and disconnect the link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_clear_config\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_clear_config -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.SH RETURN VALUE -.PP -knet_link_clear_config returns 0 on success. -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_config.3 b/libknet/man/knet_link_get_config.3 deleted file mode 100644 index 03f6c75c..00000000 --- a/libknet/man/knet_link_get_config.3 +++ /dev/null @@ -1,52 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_config 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_config \- Get the link configutation information. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_config\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t *\fP\fItransport\fP, - \fBstruct sockaddr_storage *\fP\fIsrc_addr\fP, - \fBstruct sockaddr_storage *\fP\fIdst_addr\fP, - \fBuint8_t *\fP\fIdynamic\fP, - \fBuint64_t *\fP\fIflags\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_config -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -transport - see knet_link_set_config(3) -.PP -src_addr - sockaddr_storage that can be either IPv4 or IPv6 -.PP -dst_addr - sockaddr_storage that can be either IPv4 or IPv6 -.PP -dynamic - 0 if dst_addr is static or 1 if dst_addr is dynamic. In case of 1, dst_addr can be NULL and it will be left untouched. -.PP -flags - KNET_LINK_FLAG_* -.SH RETURN VALUE -.PP -knet_link_get_config returns 0 on success. -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_enable.3 b/libknet/man/knet_link_get_enable.3 deleted file mode 100644 index aa85587b..00000000 --- a/libknet/man/knet_link_get_enable.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_enable 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_enable \- Find out whether a link is enabled or not. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_enable\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBunsigned int *\fP\fIenabled\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_enable -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -enabled - 0 disable the link, 1 enable the link -.SH RETURN VALUE -.PP -knet_link_get_enable returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_link_list.3 b/libknet/man/knet_link_get_link_list.3 deleted file mode 100644 index d4945a90..00000000 --- a/libknet/man/knet_link_get_link_list.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_link_list 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_link_list \- Get a list of links connecting a host. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_link_list\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t *\fP\fIlink_ids\fP, - \fBsize_t *\fP\fIlink_ids_entries\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_link_list -.PP -knet_h - pointer to knet_handle_t -.PP -link_ids - array of at lest KNET_MAX_LINK size with the list of configured links for a certain host. -.PP -link_ids_entries - number of entries contained in link_ids -.SH RETURN VALUE -.PP -knet_link_get_link_list returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_ping_timers.3 b/libknet/man/knet_link_get_ping_timers.3 deleted file mode 100644 index 8526adca..00000000 --- a/libknet/man/knet_link_get_ping_timers.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_ping_timers 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_ping_timers \- Get the ping timers for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_ping_timers\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBtime_t *\fP\fIinterval\fP, - \fBtime_t *\fP\fItimeout\fP, - \fBunsigned int *\fP\fIprecision\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_ping_timers -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -interval - ping interval -.PP -timeout - if no pong is received within this time, the link is declared dead -.PP -precision - how many values of latency are used to calculate the average link latency (see also knet_link_get_status(3)) -.SH RETURN VALUE -.PP -knet_link_get_ping_timers returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_pong_count.3 b/libknet/man/knet_link_get_pong_count.3 deleted file mode 100644 index 98a0d473..00000000 --- a/libknet/man/knet_link_get_pong_count.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_pong_count 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_pong_count \- Get the pong count for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_pong_count\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t *\fP\fIpong_count\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_pong_count -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -pong_count - how many valid ping/pongs before a link is marked UP. default: 5, value should be > 0 -.SH RETURN VALUE -.PP -knet_link_get_pong_count returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_priority.3 b/libknet/man/knet_link_get_priority.3 deleted file mode 100644 index b58f46b3..00000000 --- a/libknet/man/knet_link_get_priority.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_priority 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_priority \- Get the priority for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_priority\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t *\fP\fIpriority\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_priority -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -priority - gather the switching priority for this link see also knet_host_set_policy -.SH RETURN VALUE -.PP -knet_link_get_priority returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_get_status.3 b/libknet/man/knet_link_get_status.3 deleted file mode 100644 index 31c85409..00000000 --- a/libknet/man/knet_link_get_status.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_get_status 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_get_status \- Get the status (and statistics) for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_get_status\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBstruct knet_link_status *\fP\fIstatus\fP, - \fBsize_t \fP\fIstruct_size\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_get_status -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -status - pointer to knet_link_status struct -.PP -struct_size - max size of knet_link_status - allows library to add fields without ABI change. Returned structure will be truncated to this length and .size member indicates the full size. -.SH STRUCTURES -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_link_status { - size_t \fIsize\fP; - char \fIsrc_ipaddr\fP; - char \fIsrc_port\fP; - char \fIdst_ipaddr\fP; - char \fIdst_port\fP; - uint8_t \fIenabled\fP; - uint8_t \fIconnected\fP; - uint8_t \fIdynconnected\fP; - unsigned long long \fIlatency\fP; - struct timespec \fIpong_last\fP; - unsigned int \fImtu\fP; - unsigned int \fIproto_overhead\fP; - struct knet_link_stats \fIstats\fP; -}; -\fP -.fi -.RE -.SH RETURN VALUE -.PP -knet_link_get_status returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_set_config.3 b/libknet/man/knet_link_set_config.3 deleted file mode 100644 index d32cacb2..00000000 --- a/libknet/man/knet_link_set_config.3 +++ /dev/null @@ -1,49 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_set_config 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_set_config \- Configure the link to a host. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_set_config\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t \fP\fItransport\fP, - \fBstruct sockaddr_storage *\fP\fIsrc_addr\fP, - \fBstruct sockaddr_storage *\fP\fIdst_addr\fP, - \fBuint64_t \fP\fIflags\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_set_config -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -transport - one of the KNET_TRANSPORT_xxx constants -.PP -src_addr - sockaddr_storage that can be either IPv4 or IPv6 -.PP -dst_addr - sockaddr_storage that can be either IPv4 or IPv6 this can be null if we don't know the incoming IP address/port and the link will remain quiet till the node on the other end will initiate a connection -.PP -flags - KNET_LINK_FLAG_* -.SH RETURN VALUE -.PP -knet_link_set_config returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_set_enable.3 b/libknet/man/knet_link_set_enable.3 deleted file mode 100644 index ce1442cd..00000000 --- a/libknet/man/knet_link_set_enable.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_set_enable 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_set_enable \- Enable traffic on a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_set_enable\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBunsigned int \fP\fIenabled\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_set_enable -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -enabled - 0 disable the link, 1 enable the link -.SH RETURN VALUE -.PP -knet_link_set_enable returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_set_ping_timers.3 b/libknet/man/knet_link_set_ping_timers.3 deleted file mode 100644 index 4ddb1d10..00000000 --- a/libknet/man/knet_link_set_ping_timers.3 +++ /dev/null @@ -1,46 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_set_ping_timers 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_set_ping_timers \- Set the ping timers for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_set_ping_timers\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBtime_t \fP\fIinterval\fP, - \fBtime_t \fP\fItimeout\fP, - \fBunsigned int \fP\fIprecision\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_set_ping_timers -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -interval - specify the ping interval in milliseconds. -.PP -timeout - if no pong is received within this time, the link is declared dead, in milliseconds. NOTE: in future it will be possible to set timeout to 0 for an autocalculated timeout based on interval, pong_count and latency. The API already accept 0 as value and it will return ENOSYS / -1. Once the automatic calculation feature will be implemented, this call will only return EINVAL for incorrect values. -.PP -precision - how many values of latency are used to calculate the average link latency (see also knet_link_get_status(3)) -.SH RETURN VALUE -.PP -knet_link_set_ping_timers returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_set_pong_count.3 b/libknet/man/knet_link_set_pong_count.3 deleted file mode 100644 index 97ff90c8..00000000 --- a/libknet/man/knet_link_set_pong_count.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_set_pong_count 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_set_pong_count \- Set the pong count for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_set_pong_count\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t \fP\fIpong_count\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_set_pong_count -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -pong_count - how many valid ping/pongs before a link is marked UP. default: 5, value should be > 0 -.SH RETURN VALUE -.PP -knet_link_set_pong_count returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_link_set_priority.3 b/libknet/man/knet_link_set_priority.3 deleted file mode 100644 index 8e014e74..00000000 --- a/libknet/man/knet_link_set_priority.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_link_set_priority 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_link_set_priority \- Set the priority for a link. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_link_set_priority\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBknet_node_id_t \fP\fIhost_id\fP, - \fBuint8_t \fP\fIlink_id\fP, - \fBuint8_t \fP\fIpriority\fP -); -.fi -.SH DESCRIPTION -.PP -knet_link_set_priority -.PP -knet_h - pointer to knet_handle_t -.PP -host_id - see knet_host_add(3) -.PP -link_id - see knet_link_set_config(3) -.PP -priority - specify the switching priority for this link see also knet_host_set_policy -.SH RETURN VALUE -.PP -knet_link_set_priority returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_get_loglevel.3 b/libknet/man/knet_log_get_loglevel.3 deleted file mode 100644 index d23bdbb7..00000000 --- a/libknet/man/knet_log_get_loglevel.3 +++ /dev/null @@ -1,37 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_get_loglevel 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_get_loglevel \- Get the logging level for a subsystem. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_log_get_loglevel\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBuint8_t \fP\fIsubsystem\fP, - \fBuint8_t *\fP\fIlevel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_get_log_level -.PP -knet_h - same as above -.PP -subsystem - same as above -.PP -level - same as above -.SH RETURN VALUE -.PP -knet_log_get_loglevel returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_get_loglevel_id.3 b/libknet/man/knet_log_get_loglevel_id.3 deleted file mode 100644 index 8b01bbfb..00000000 --- a/libknet/man/knet_log_get_loglevel_id.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_get_loglevel_id 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_get_loglevel_id \- Get a logging level ID from its name. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBuint8_t knet_log_get_loglevel_id\fP( - \fBconst char *\fP\fIname\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_get_loglevel_id -.SH RETURN VALUE -.PP -returns internal log level ID or KNET_LOG_ERR for invalid names -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_get_loglevel_name.3 b/libknet/man/knet_log_get_loglevel_name.3 deleted file mode 100644 index 4ec4a05a..00000000 --- a/libknet/man/knet_log_get_loglevel_name.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_get_loglevel_name 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_get_loglevel_name \- Get a logging level name from its numeric ID. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBconst char * knet_log_get_loglevel_name\fP( - \fBuint8_t \fP\fIlevel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_get_loglevel_name -.SH RETURN VALUE -.PP -returns internal name of the log level or "ERROR" for unknown values -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_get_subsystem_id.3 b/libknet/man/knet_log_get_subsystem_id.3 deleted file mode 100644 index 7427a2f8..00000000 --- a/libknet/man/knet_log_get_subsystem_id.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_get_subsystem_id 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_get_subsystem_id \- Get a logging system ID from its name. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBuint8_t knet_log_get_subsystem_id\fP( - \fBconst char *\fP\fIname\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_get_subsystem_id -.SH RETURN VALUE -.PP -returns internal ID of the subsystem or KNET_SUB_COMMON -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_get_subsystem_name.3 b/libknet/man/knet_log_get_subsystem_name.3 deleted file mode 100644 index 7f12e496..00000000 --- a/libknet/man/knet_log_get_subsystem_name.3 +++ /dev/null @@ -1,29 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_get_subsystem_name 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_get_subsystem_name \- Get a logging system name from its numeric ID. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBconst char * knet_log_get_subsystem_name\fP( - \fBuint8_t \fP\fIsubsystem\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_get_subsystem_name -.SH RETURN VALUE -.PP -returns internal name of the subsystem or "common" -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_log_set_loglevel.3 b/libknet/man/knet_log_set_loglevel.3 deleted file mode 100644 index d235c771..00000000 --- a/libknet/man/knet_log_set_loglevel.3 +++ /dev/null @@ -1,39 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_log_set_loglevel 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_log_set_loglevel \- Set the logging level for a subsystem. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_log_set_loglevel\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBuint8_t \fP\fIsubsystem\fP, - \fBuint8_t \fP\fIlevel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_log_set_log_level -.PP -knet_h - same as above -.PP -subsystem - same as above -.PP -level - same as above -.PP -knet_log_set_loglevel allows fine control of log levels by subsystem. See also knet_handle_new for defaults. -.SH RETURN VALUE -.PP -knet_log_set_loglevel returns 0 on success -1 on error and errno is set. -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_recv.3 b/libknet/man/knet_recv.3 deleted file mode 100644 index 09e2fb74..00000000 --- a/libknet/man/knet_recv.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_recv 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_recv \- Receive data from knet nodes. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBssize_t knet_recv\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBchar *\fP\fIbuff\fP, - \fBconst size_t \fP\fIbuff_len\fP, - \fBconst int8_t \fP\fIchannel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_recv knet_h - pointer to knet_handle_t -.PP -buff - pointer to buffer to store the received data -.PP -buff_len - buffer length -.PP -channel - channel number -.SH RETURN VALUE -.PP -knet_recv is a commodity function to wrap iovec operations around a socket. It returns a call to readv(2). -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_send.3 b/libknet/man/knet_send.3 deleted file mode 100644 index 72b37039..00000000 --- a/libknet/man/knet_send.3 +++ /dev/null @@ -1,38 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_send 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_send \- Send data to knet nodes. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBssize_t knet_send\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBconst char *\fP\fIbuff\fP, - \fBconst size_t \fP\fIbuff_len\fP, - \fBconst int8_t \fP\fIchannel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_send knet_h - pointer to knet_handle_t -.PP -buff - pointer to the buffer of data to send -.PP -buff_len - length of data to send -.PP -channel - channel number -.SH RETURN VALUE -.PP -knet_send is a commodity function to wrap iovec operations around a socket. It returns a call to writev(2). -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_send_sync.3 b/libknet/man/knet_send_sync.3 deleted file mode 100644 index da3da8e1..00000000 --- a/libknet/man/knet_send_sync.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_send_sync 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_send_sync \- Synchronously send data to knet nodes. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_send_sync\fP( - \fBknet_handle_t \fP\fIknet_h\fP, - \fBconst char *\fP\fIbuff\fP, - \fBconst size_t \fP\fIbuff_len\fP, - \fBconst int8_t \fP\fIchannel\fP -); -.fi -.SH DESCRIPTION -.PP -knet_send_sync -.PP -knet_h - pointer to knet_handle_t -.PP -buff - pointer to the buffer of data to send -.PP -buff_len - length of data to send -.PP -channel - data channel to use (see knet_handle_add_datafd(3)) -.PP -All knet RX/TX operations are async for performance reasons. There are applications that might need a sync version of data transmission and receive errors in case of failure to deliver to another host. knet_send_sync bypasses the whole TX async layer and delivers data directly to the link layer, and returns errors accordingly. knet_send_sync sends only one packet to one host at a time. It does NOT support multiple destinations or multicast packets. Decision is still based on dst_host_filter_fn. -.SH RETURN VALUE -.PP -knet_send_sync returns 0 on success and -1 on error. In addition to normal sendmmsg errors, knet_send_sync can fail due to: -.TP -.B ECANCELED -- data forward is disabled - -.TP -.B EFAULT -- dst_host_filter fatal error - -.TP -.B EINVAL -- dst_host_filter did not provide dst_host_ids_entries on unicast pckts - -.TP -.B E2BIG -- dst_host_filter did return more than one dst_host_ids_entries on unicast pckts - -.TP -.B ENOMSG -- received unknown message type - -.TP -.B EHOSTDOWN -- unicast pckt cannot be delivered because dest host is not connected yet - -.TP -.B ECHILD -- crypto failed - -.TP -.B EAGAIN -- sendmmsg was unable to send all messages and there was no progress during retry - -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/knet_strtoaddr.3 b/libknet/man/knet_strtoaddr.3 deleted file mode 100644 index e4a75347..00000000 --- a/libknet/man/knet_strtoaddr.3 +++ /dev/null @@ -1,40 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH knet_strtoaddr 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -knet_strtoaddr \- Convert a hostname string to an address. -.SH SYNOPSIS -.nf -.B #include -.sp -\fBint knet_strtoaddr\fP( - \fBconst char *\fP\fIhost\fP, - \fBconst char *\fP\fIport\fP, - \fBstruct sockaddr_storage *\fP\fIss\fP, - \fBsocklen_t \fP\fIsslen\fP -); -.fi -.SH DESCRIPTION -.PP -knet_strtoaddr -.PP -host - IPaddr/hostname to convert be aware only the first IP address will be returned in case a hostname resolves to multiple IP -.PP -port - port to connect to -.PP -ss - sockaddr_storage where to store the converted data -.PP -sslen - len of the sockaddr_storage -.SH RETURN VALUE -.PP -knet_strtoaddr returns same error codes as getaddrinfo -.SH SEE ALSO -.PP -.nh -.ad l -\fIlibknet.h\fP(3), \fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/man/libknet.h.3 b/libknet/man/libknet.h.3 deleted file mode 100644 index 7691ae72..00000000 --- a/libknet/man/libknet.h.3 +++ /dev/null @@ -1,241 +0,0 @@ -.\" File automatically generated by doxy2man0.2 -.\" Generation date: Mon Jan 8 2018 -.TH libknet.h 3 2018-01-08 "kronosnet" "Kronosnet Programmer's Manual" -.SH "NAME" -libknet.h \- kronosnet API include file -.SH SYNOPSIS -.nf -.B #include -.fi -.SH DESCRIPTION -.PP -Kronosnet is an advanced VPN system for High Availability applications. -.PP -.sp -.RS -.nf -\fB -int knet_addrtostr(const struct sockaddr_storage *, socklen_t, char *, size_t, char *, size_t); -int knet_get_compress_list(struct knet_compress_info *, size_t *); -int knet_get_crypto_list(struct knet_crypto_info *, size_t *); -uint8_t knet_get_transport_id_by_name(const char *); -int knet_get_transport_list(struct knet_transport_info *, size_t *); -const char *knet_get_transport_name_by_id(uint8_t); -int knet_handle_add_datafd(knet_handle_t, int *, int8_t *); -int knet_handle_clear_stats(knet_handle_t, int); -int knet_handle_compress(knet_handle_t, struct knet_handle_compress_cfg *); -int knet_handle_crypto(knet_handle_t, struct knet_handle_crypto_cfg *); -int knet_handle_enable_filter(knet_handle_t, void *, int(*)(void *private_data, const unsigned char *outdata, ssize_t outdata_len, uint8_t tx_rx, knet_node_id_t this_host_id, knet_node_id_t src_host_id, int8_t *channel, knet_node_id_t *dst_host_ids, size_t *dst_host_ids_entries)); -int knet_handle_enable_pmtud_notify(knet_handle_t, void *, void(*)(void *private_data, unsigned int data_mtu)); -int knet_handle_enable_sock_notify(knet_handle_t, void *, void(*)(void *private_data, int datafd, int8_t channel, uint8_t tx_rx, int error, int errorno)); -int knet_handle_free(knet_handle_t); -int knet_handle_get_channel(knet_handle_t, const int, int8_t *); -int knet_handle_get_datafd(knet_handle_t, const int8_t, int *); -int knet_handle_get_stats(knet_handle_t, struct knet_handle_stats *, size_t); -int knet_handle_get_transport_reconnect_interval(knet_handle_t, uint32_t *); -knet_handle_t knet_handle_new(knet_node_id_t, int, uint8_t); -int knet_handle_pmtud_get(knet_handle_t, unsigned int *); -int knet_handle_pmtud_getfreq(knet_handle_t, unsigned int *); -int knet_handle_pmtud_setfreq(knet_handle_t, unsigned int); -int knet_handle_remove_datafd(knet_handle_t, int); -int knet_handle_set_transport_reconnect_interval(knet_handle_t, uint32_t); -int knet_handle_setfwd(knet_handle_t, unsigned int); -int knet_host_add(knet_handle_t, knet_node_id_t); -int knet_host_enable_status_change_notify(knet_handle_t, void *, void(*)(void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external)); -int knet_host_get_host_list(knet_handle_t, knet_node_id_t *, size_t *); -int knet_host_get_id_by_host_name(knet_handle_t, const char *, knet_node_id_t *); -int knet_host_get_name_by_host_id(knet_handle_t, knet_node_id_t, char *); -int knet_host_get_policy(knet_handle_t, knet_node_id_t, uint8_t *); -int knet_host_get_status(knet_handle_t, knet_node_id_t, struct knet_host_status *); -int knet_host_remove(knet_handle_t, knet_node_id_t); -int knet_host_set_name(knet_handle_t, knet_node_id_t, const char *); -int knet_host_set_policy(knet_handle_t, knet_node_id_t, uint8_t); -int knet_link_clear_config(knet_handle_t, knet_node_id_t, uint8_t); -int knet_link_get_config(knet_handle_t, knet_node_id_t, uint8_t, uint8_t *, struct sockaddr_storage *, struct sockaddr_storage *, uint8_t *, uint64_t *); -int knet_link_get_enable(knet_handle_t, knet_node_id_t, uint8_t, unsigned int *); -int knet_link_get_link_list(knet_handle_t, knet_node_id_t, uint8_t *, size_t *); -int knet_link_get_ping_timers(knet_handle_t, knet_node_id_t, uint8_t, time_t *, time_t *, unsigned int *); -int knet_link_get_pong_count(knet_handle_t, knet_node_id_t, uint8_t, uint8_t *); -int knet_link_get_priority(knet_handle_t, knet_node_id_t, uint8_t, uint8_t *); -int knet_link_get_status(knet_handle_t, knet_node_id_t, uint8_t, struct knet_link_status *, size_t); -int knet_link_set_config(knet_handle_t, knet_node_id_t, uint8_t, uint8_t, struct sockaddr_storage *, struct sockaddr_storage *, uint64_t); -int knet_link_set_enable(knet_handle_t, knet_node_id_t, uint8_t, unsigned int); -int knet_link_set_ping_timers(knet_handle_t, knet_node_id_t, uint8_t, time_t, time_t, unsigned int); -int knet_link_set_pong_count(knet_handle_t, knet_node_id_t, uint8_t, uint8_t); -int knet_link_set_priority(knet_handle_t, knet_node_id_t, uint8_t, uint8_t); -int knet_log_get_loglevel(knet_handle_t, uint8_t, uint8_t *); -uint8_t knet_log_get_loglevel_id(const char *); -const char *knet_log_get_loglevel_name(uint8_t); -uint8_t knet_log_get_subsystem_id(const char *); -const char *knet_log_get_subsystem_name(uint8_t); -int knet_log_set_loglevel(knet_handle_t, uint8_t, uint8_t); -ssize_t knet_recv(knet_handle_t, char *, const size_t, const int8_t); -ssize_t knet_send(knet_handle_t, const char *, const size_t, const int8_t); -int knet_send_sync(knet_handle_t, const char *, const size_t, const int8_t); -int knet_strtoaddr(const char *, const char *, struct sockaddr_storage *, socklen_t); -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_compress_cfg { - char \fIcompress_model\fP; - uint32_t \fIcompress_threshold\fP; - int \fIcompress_level\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_stats { - size_t \fIsize\fP; - uint64_t \fItx_uncompressed_packets\fP; - uint64_t \fItx_compressed_packets\fP; - uint64_t \fItx_compressed_original_bytes\fP; - uint64_t \fItx_compressed_size_bytes\fP; - uint64_t \fItx_compress_time_ave\fP; - uint64_t \fItx_compress_time_min\fP; - uint64_t \fItx_compress_time_max\fP; - uint64_t \fIrx_compressed_packets\fP; - uint64_t \fIrx_compressed_original_bytes\fP; - uint64_t \fIrx_compressed_size_bytes\fP; - uint64_t \fIrx_compress_time_ave\fP; - uint64_t \fIrx_compress_time_min\fP; - uint64_t \fIrx_compress_time_max\fP; - uint64_t \fItx_crypt_packets\fP; - uint64_t \fItx_crypt_byte_overhead\fP; - uint64_t \fItx_crypt_time_ave\fP; - uint64_t \fItx_crypt_time_min\fP; - uint64_t \fItx_crypt_time_max\fP; - uint64_t \fIrx_crypt_packets\fP; - uint64_t \fIrx_crypt_time_ave\fP; - uint64_t \fIrx_crypt_time_min\fP; - uint64_t \fIrx_crypt_time_max\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_crypto_info { - const char *\fIname\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_compress_info { - const char *\fIname\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_handle_crypto_cfg { - char \fIcrypto_model\fP; - char \fIcrypto_cipher_type\fP; - char \fIcrypto_hash_type\fP; - unsigned char \fIprivate_key\fP; - unsigned int \fIprivate_key_len\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_host_status { - uint8_t \fIreachable\fP; - uint8_t \fIremote\fP; - uint8_t \fIexternal\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_transport_info { - const char *\fIname\fP; - uint8_t \fIid\fP; - uint8_t \fIproperties\fP; - char \fIpad\fP; -}; -\fP -.fi -.RE -.SS "" -.PP -.sp -.sp -.RS -.nf -\fB -struct knet_link_status { - size_t \fIsize\fP; - char \fIsrc_ipaddr\fP; - char \fIsrc_port\fP; - char \fIdst_ipaddr\fP; - char \fIdst_port\fP; - uint8_t \fIenabled\fP; - uint8_t \fIconnected\fP; - uint8_t \fIdynconnected\fP; - unsigned long long \fIlatency\fP; - struct timespec \fIpong_last\fP; - unsigned int \fImtu\fP; - unsigned int \fIproto_overhead\fP; - struct knet_link_stats \fIstats\fP; -}; -\fP -.fi -.RE -.SH SEE ALSO -.PP -.nh -.ad l -\fIknet_addrtostr\fP(3), \fIknet_get_compress_list\fP(3), \fIknet_get_crypto_list\fP(3), \fIknet_get_transport_id_by_name\fP(3), \fIknet_get_transport_list\fP(3), \fIknet_get_transport_name_by_id\fP(3), \fIknet_handle_add_datafd\fP(3), \fIknet_handle_clear_stats\fP(3), \fIknet_handle_compress\fP(3), \fIknet_handle_crypto\fP(3), \fIknet_handle_enable_filter\fP(3), \fIknet_handle_enable_pmtud_notify\fP(3), \fIknet_handle_enable_sock_notify\fP(3), \fIknet_handle_free\fP(3), \fIknet_handle_get_channel\fP(3), \fIknet_handle_get_datafd\fP(3), \fIknet_handle_get_stats\fP(3), \fIknet_handle_get_transport_reconnect_interval\fP(3), \fIknet_handle_new\fP(3), \fIknet_handle_pmtud_get\fP(3), \fIknet_handle_pmtud_getfreq\fP(3), \fIknet_handle_pmtud_setfreq\fP(3), \fIknet_handle_remove_datafd\fP(3), \fIknet_handle_set_transport_reconnect_interval\fP(3), \fIknet_handle_setfwd\fP(3), \fIknet_host_add\fP(3), \fIknet_host_enable_status_change_notify\fP(3), \fIknet_host_get_host_list\fP(3), \fIknet_host_get_id_by_host_name\fP(3), \fIknet_host_get_name_by_host_id\fP(3), \fIknet_host_get_policy\fP(3), \fIknet_host_get_status\fP(3), \fIknet_host_remove\fP(3), \fIknet_host_set_name\fP(3), \fIknet_host_set_policy\fP(3), \fIknet_link_clear_config\fP(3), \fIknet_link_get_config\fP(3), \fIknet_link_get_enable\fP(3), \fIknet_link_get_link_list\fP(3), \fIknet_link_get_ping_timers\fP(3), \fIknet_link_get_pong_count\fP(3), \fIknet_link_get_priority\fP(3), \fIknet_link_get_status\fP(3), \fIknet_link_set_config\fP(3), \fIknet_link_set_enable\fP(3), \fIknet_link_set_ping_timers\fP(3), \fIknet_link_set_pong_count\fP(3), \fIknet_link_set_priority\fP(3), \fIknet_log_get_loglevel\fP(3), \fIknet_log_get_loglevel_id\fP(3), \fIknet_log_get_loglevel_name\fP(3), \fIknet_log_get_subsystem_id\fP(3), \fIknet_log_get_subsystem_name\fP(3), \fIknet_log_set_loglevel\fP(3), \fIknet_recv\fP(3), \fIknet_send\fP(3), \fIknet_send_sync\fP(3), \fIknet_strtoaddr\fP(3) -.ad -.hy -.SH COPYRIGHT -.PP -Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. diff --git a/libknet/tests/Makefile.am b/libknet/tests/Makefile.am index 13b6aecb..02eef6c1 100644 --- a/libknet/tests/Makefile.am +++ b/libknet/tests/Makefile.am @@ -1,70 +1,70 @@ # # Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. # # Authors: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in include $(top_srcdir)/build-aux/check.mk include $(top_srcdir)/libknet/tests/api-check.mk EXTRA_DIST = \ api-test-coverage \ api-check.mk AM_CPPFLAGS = -I$(top_srcdir)/libknet -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS += $(PTHREAD_CFLAGS) LIBS = $(top_builddir)/libknet/libknet.la \ $(PTHREAD_LIBS) $(dl_LIBS) noinst_HEADERS = \ test-common.h # the order of those tests is NOT random. # some functions can only be tested properly after some dependents # API have been validated upfront. check_PROGRAMS = \ $(api_checks) \ $(int_checks) \ $(fun_checks) int_checks = \ int_timediff_test fun_checks = benchmarks = \ knet_bench_test noinst_PROGRAMS = \ api_knet_handle_new_limit_test \ pckt_test \ $(benchmarks) \ $(check_PROGRAMS) noinst_SCRIPTS = \ api-test-coverage TESTS = $(check_PROGRAMS) check-local: check-api-test-coverage check-api-test-coverage: chmod u+x $(top_srcdir)/libknet/tests/api-test-coverage $(top_srcdir)/libknet/tests/api-test-coverage $(top_srcdir) $(top_builddir) pckt_test_SOURCES = pckt_test.c int_timediff_test_SOURCES = int_timediff.c knet_bench_test_SOURCES = knet_bench.c \ test-common.c \ ../common.c \ ../logging.c \ ../compat.c \ ../transport_common.c \ ../threads_common.c diff --git a/libknet/tests/api-test-coverage b/libknet/tests/api-test-coverage index 1810c043..52cfb0e1 100755 --- a/libknet/tests/api-test-coverage +++ b/libknet/tests/api-test-coverage @@ -1,86 +1,90 @@ #!/bin/sh # # Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # srcdir="$1"/libknet/tests builddir="$2"/libknet/tests headerapicalls="$(grep knet_ "$srcdir"/../libknet.h | grep -v "^ \*" | grep -v ^struct | grep -v "^[[:space:]]" | grep -v typedef | sed -e 's/(.*//g' -e 's/^const //g' -e 's/\*//g' | awk '{print $2}')" -exportedapicalls="$(nm -B -D "$builddir"/../.libs/libknet.so | grep ' T ' | awk '{print $3}')" +# The PowerPC64 ELFv1 ABI defines the address of a function as that of a +# function descriptor defined in .opd, a data (D) section. Other ABIs +# use the entry address of the function itself in the text (T) section. +exportedapicalls="$(nm -B -D "$builddir"/../.libs/libknet.so | grep ' [DT] ' | awk '{print $3}')" echo "Checking for exported symbols NOT available in header file" for i in $exportedapicalls; do found=0 for x in $headerapicalls; do if [ "$x" = "$i" ]; then found=1 break; fi done if [ "$found" = 0 ]; then echo "Symbol $i not found in header file" exit 1 fi done echo "Checking for symbols in header file NOT exported by binary lib" for i in $headerapicalls; do found=0 for x in $exportedapicalls; do if [ "$x" = "$i" ]; then found=1 break; fi done if [ "$found" = 0 ]; then echo "Symbol $i not found in binary lib" exit 1 fi done echo "Checking for tests with memcheck exceptions" for i in $(grep -l is_memcheck "$srcdir"/*.c | grep -v test-common); do echo "WARNING: $(basename $i) - has memcheck exception enabled" done echo "Checking for tests with helgrind exceptions" for i in $(grep -l is_helgrind "$srcdir"/*.c | grep -v test-common); do echo "WARNING: $(basename $i) has helgrind exception enabled" done echo "Checking for api test coverage" numapicalls=0 found=0 missing=0 for i in $headerapicalls; do + [ "$i" = knet_handle_new_ex ] && i=knet_handle_new # tested together numapicalls=$((numapicalls + 1)) if [ -f $srcdir/api_${i}.c ]; then found=$((found + 1)) else missing=$((missing + 1)) echo "MISSING: $i" fi done echo "Summary" echo "-------" echo "Found : $found" echo "Missing : $missing" echo "Total : $numapicalls" which bc > /dev/null 2>&1 && { coverage=$(echo "scale=3; $found / $numapicalls * 100" | bc -l) echo "Coverage: $coverage%" } exit 0 diff --git a/libknet/tests/api_knet_handle_new.c b/libknet/tests/api_knet_handle_new.c index bd1e9514..f3c546f4 100644 --- a/libknet/tests/api_knet_handle_new.c +++ b/libknet/tests/api_knet_handle_new.c @@ -1,135 +1,130 @@ /* * Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include "libknet.h" #include "internals.h" #include "test-common.h" static void test(void) { knet_handle_t knet_h; struct rlimit cur; int logfds[2]; printf("Test knet_handle_new hostid 1, no logging\n"); - knet_h = knet_handle_new(1, 0, 0); + knet_h = knet_handle_new_ex(1, 0, 0, 0); if (!knet_h) { - if (errno == ENAMETOOLONG) { - printf("Socket buffers too small (at least %d bytes needed)\n", - KNET_RING_RCVBUFF); - exit(SKIP); - } printf("Unable to init knet_handle! err: %s\n", strerror(errno)); exit(FAIL); } if (knet_handle_free(knet_h) != 0) { printf("Unable to free knet_handle\n"); exit(FAIL); } printf("Test knet_handle_new hostid -1, no logging\n"); - knet_h = knet_handle_new(-1, 0, 0); + knet_h = knet_handle_new_ex(-1, 0, 0, 0); if (!knet_h) { printf("Unable to init knet_handle! err: %s\n", strerror(errno)); exit(FAIL); } /* * -1 == knet_node_id_t 65535 */ if (knet_h->host_id != 65535) { printf("host_id size might have changed!\n"); knet_handle_free(knet_h); exit(FAIL); } if (knet_handle_free(knet_h) != 0) { printf("Unable to free knet_handle\n"); exit(FAIL); } if (getrlimit(RLIMIT_NOFILE, &cur) < 0) { printf("Unable to get current fd limit: %s\n", strerror(errno)); exit(SKIP); } /* * passing a bad fd and it should fail */ printf("Test knet_handle_new hostid 1, incorrect log_fd (-1)\n"); knet_h = knet_handle_new(1, -1, 0); if ((!knet_h) && (errno != EINVAL)) { printf("knet_handle_new returned incorrect errno on incorrect log_fd\n"); exit(FAIL); } if (knet_h) { printf("knet_handle_new accepted an incorrect (-1) log_fd\n"); knet_handle_free(knet_h); exit(FAIL); } /* * passing a bad fd and it should fail */ printf("Test knet_handle_new hostid 1, incorrect log_fd (max_fd + 1)\n"); knet_h = knet_handle_new(1, (int) cur.rlim_max, 0); if ((knet_h) || (errno != EINVAL)) { printf("knet_handle_new accepted an incorrect (max_fd + 1) log_fd or returned incorrect errno on incorrect log_fd: %s\n", strerror(errno)); knet_handle_free(knet_h); exit(FAIL); } setup_logpipes(logfds); printf("Test knet_handle_new hostid 1, proper log_fd, invalid log level (DEBUG + 1)\n"); knet_h = knet_handle_new(1, logfds[1], KNET_LOG_DEBUG + 1); if ((knet_h) || (errno != EINVAL)) { printf("knet_handle_new accepted an incorrect log level or returned incorrect errno on incorrect log level: %s\n", strerror(errno)); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } printf("Test knet_handle_new hostid 1, proper log_fd, proper log level (DEBUG)\n"); knet_h = knet_handle_start(logfds, KNET_LOG_DEBUG); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); } int main(int argc, char *argv[]) { test(); return PASS; } diff --git a/libknet/tests/api_knet_link_set_enable.c b/libknet/tests/api_knet_link_set_enable.c index 0f386eec..45e45053 100644 --- a/libknet/tests/api_knet_link_set_enable.c +++ b/libknet/tests/api_knet_link_set_enable.c @@ -1,344 +1,345 @@ /* * Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. * * Authors: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include "libknet.h" #include "internals.h" #include "link.h" #include "netutils.h" #include "test-common.h" static void test_udp(void) { knet_handle_t knet_h; int logfds[2]; struct sockaddr_storage src, dst; if (make_local_sockaddr(&src, 0) < 0) { printf("Unable to convert src to sockaddr: %s\n", strerror(errno)); exit(FAIL); } if (make_local_sockaddr(&dst, 1) < 0) { printf("Unable to convert dst to sockaddr: %s\n", strerror(errno)); exit(FAIL); } printf("Test knet_link_set_enable incorrect knet_h\n"); if ((!knet_link_set_enable(NULL, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid knet_h or returned incorrect error: %s\n", strerror(errno)); exit(FAIL); } setup_logpipes(logfds); knet_h = knet_handle_start(logfds, KNET_LOG_DEBUG); printf("Test knet_link_set_enable with unconfigured host_id\n"); if ((!knet_link_set_enable(knet_h, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid host_id or returned incorrect error: %s\n", strerror(errno)); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with incorrect linkid\n"); if (knet_host_add(knet_h, 1) < 0) { printf("Unable to add host_id 1: %s\n", strerror(errno)); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if ((!knet_link_set_enable(knet_h, 1, KNET_MAX_LINK, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid linkid or returned incorrect error: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with unconfigured link\n"); if ((!knet_link_set_enable(knet_h, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted unconfigured link or returned incorrect error: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with incorrect values\n"); if (knet_link_set_config(knet_h, 1, 0, KNET_TRANSPORT_UDP, &src, &dst, 0) < 0) { printf("Unable to configure link: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if ((!knet_link_set_enable(knet_h, 1, 0, 2)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted incorrect value for enabled or returned incorrect error: %s\n", strerror(errno)); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with correct values (1)\n"); if (knet_link_set_enable(knet_h, 1, 0, 1) < 0) { printf("knet_link_set_enable failed: %s\n", strerror(errno)); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if (knet_h->host_index[1]->link[0].status.enabled != 1) { printf("knet_link_set_enable failed to set correct values\n"); knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } printf("Test knet_link_set_enable with correct values (0)\n"); if (knet_link_set_enable(knet_h, 1, 0, 0) < 0) { printf("knet_link_set_enable failed: %s\n", strerror(errno)); knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if (knet_h->host_index[1]->link[0].status.enabled != 0) { printf("knet_link_set_enable failed to set correct values\n"); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); } #ifdef HAVE_NETINET_SCTP_H static void test_sctp(void) { knet_handle_t knet_h; int logfds[2]; struct sockaddr_storage src, dst; if (make_local_sockaddr(&src, 0) < 0) { printf("Unable to convert src to sockaddr: %s\n", strerror(errno)); exit(FAIL); } if (make_local_sockaddr(&dst, 1) < 0) { printf("Unable to convert dst to sockaddr: %s\n", strerror(errno)); exit(FAIL); } printf("Test knet_link_set_enable incorrect knet_h\n"); if ((!knet_link_set_enable(NULL, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid knet_h or returned incorrect error: %s\n", strerror(errno)); exit(FAIL); } setup_logpipes(logfds); knet_h = knet_handle_start(logfds, KNET_LOG_DEBUG); printf("Test knet_link_set_enable with unconfigured host_id\n"); if ((!knet_link_set_enable(knet_h, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid host_id or returned incorrect error: %s\n", strerror(errno)); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with incorrect linkid\n"); if (knet_host_add(knet_h, 1) < 0) { printf("Unable to add host_id 1: %s\n", strerror(errno)); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if ((!knet_link_set_enable(knet_h, 1, KNET_MAX_LINK, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted invalid linkid or returned incorrect error: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with unconfigured link\n"); if ((!knet_link_set_enable(knet_h, 1, 0, 1)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted unconfigured link or returned incorrect error: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with incorrect values\n"); if (knet_link_set_config(knet_h, 1, 0, KNET_TRANSPORT_SCTP, &src, &dst, 0) < 0) { + int exit_status = errno == EPROTONOSUPPORT ? SKIP : FAIL; printf("Unable to configure link: %s\n", strerror(errno)); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); - exit(FAIL); + exit(exit_status); } if ((!knet_link_set_enable(knet_h, 1, 0, 2)) || (errno != EINVAL)) { printf("knet_link_set_enable accepted incorrect value for enabled or returned incorrect error: %s\n", strerror(errno)); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } flush_logs(logfds[0], stdout); printf("Test knet_link_set_enable with correct values (1)\n"); if (knet_link_set_enable(knet_h, 1, 0, 1) < 0) { printf("knet_link_set_enable failed: %s\n", strerror(errno)); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if (knet_h->host_index[1]->link[0].status.enabled != 1) { printf("knet_link_set_enable failed to set correct values\n"); knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } printf("Wait 2 seconds for sockets to connect\n"); sleep(2); printf("Test knet_link_set_enable with correct values (0)\n"); if (knet_link_set_enable(knet_h, 1, 0, 0) < 0) { printf("knet_link_set_enable failed: %s\n", strerror(errno)); knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } if (knet_h->host_index[1]->link[0].status.enabled != 0) { printf("knet_link_set_enable failed to set correct values\n"); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); exit(FAIL); } knet_link_set_enable(knet_h, 1, 0, 0); knet_link_clear_config(knet_h, 1, 0); knet_host_remove(knet_h, 1); knet_handle_free(knet_h); flush_logs(logfds[0], stdout); close_logpipes(logfds); } #endif int main(int argc, char *argv[]) { printf("Testing with UDP\n"); test_udp(); #ifdef HAVE_NETINET_SCTP_H printf("Testing with SCTP\n"); test_sctp(); #else printf("Skipping SCTP test. Protocol not supported in this build\n"); #endif return PASS; } diff --git a/libknet/tests/test-common.c b/libknet/tests/test-common.c index a8537426..e32b47ed 100644 --- a/libknet/tests/test-common.c +++ b/libknet/tests/test-common.c @@ -1,513 +1,506 @@ /* * Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "libknet.h" #include "test-common.h" static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; static int log_init = 0; static pthread_mutex_t log_thread_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t log_thread; static int log_thread_init = 0; static int log_fds[2]; struct log_thread_data { int logfd; FILE *std; }; static struct log_thread_data data; static pthread_mutex_t shutdown_mutex = PTHREAD_MUTEX_INITIALIZER; static int shutdown_in_progress = 0; static int _read_pipe(int fd, char **file, size_t *length) { char buf[4096]; int n; int done = 0; *file = NULL; *length = 0; memset(buf, 0, sizeof(buf)); while (!done) { n = read(fd, buf, sizeof(buf)); if (n < 0) { if (errno == EINTR) continue; if (*file) free(*file); return n; } if (n == 0 && (!*length)) return 0; if (n == 0) done = 1; if (*file) *file = realloc(*file, (*length) + n + done); else *file = malloc(n + done); if (!*file) return -1; memmove((*file) + (*length), buf, n); *length += (done + n); } /* Null terminator */ (*file)[(*length) - 1] = 0; return 0; } int execute_shell(const char *command, char **error_string) { pid_t pid; int status, err = 0; int fd[2]; size_t size = 0; if ((command == NULL) || (!error_string)) { errno = EINVAL; return FAIL; } *error_string = NULL; err = pipe(fd); if (err) goto out_clean; pid = fork(); if (pid < 0) { err = pid; goto out_clean; } if (pid) { /* parent */ close(fd[1]); err = _read_pipe(fd[0], error_string, &size); if (err) goto out_clean0; waitpid(pid, &status, 0); if (!WIFEXITED(status)) { err = -1; goto out_clean0; } if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { err = WEXITSTATUS(status); goto out_clean0; } goto out_clean0; } else { /* child */ close(0); close(1); close(2); close(fd[0]); dup2(fd[1], 1); dup2(fd[1], 2); close(fd[1]); execlp("/bin/sh", "/bin/sh", "-c", command, NULL); exit(FAIL); } out_clean: close(fd[1]); out_clean0: close(fd[0]); return err; } int is_memcheck(void) { char *val; val = getenv("KNETMEMCHECK"); if (val) { if (!strncmp(val, "yes", 3)) { return 1; } } return 0; } int is_helgrind(void) { char *val; val = getenv("KNETHELGRIND"); if (val) { if (!strncmp(val, "yes", 3)) { return 1; } } return 0; } void set_scheduler(int policy) { struct sched_param sched_param; int err; err = sched_get_priority_max(policy); if (err < 0) { printf("Could not get maximum scheduler priority\n"); exit(FAIL); } sched_param.sched_priority = err; err = sched_setscheduler(0, policy, &sched_param); if (err < 0) { printf("Could not set priority\n"); exit(FAIL); } return; } int setup_logpipes(int *logfds) { if (pipe2(logfds, O_CLOEXEC | O_NONBLOCK) < 0) { printf("Unable to setup logging pipe\n"); exit(FAIL); } return PASS; } void close_logpipes(int *logfds) { close(logfds[0]); logfds[0] = 0; close(logfds[1]); logfds[1] = 0; } void flush_logs(int logfd, FILE *std) { struct knet_log_msg msg; size_t bytes_read; int len; next: len = 0; bytes_read = 0; memset(&msg, 0, sizeof(struct knet_log_msg)); while (bytes_read < sizeof(struct knet_log_msg)) { len = read(logfd, &msg + bytes_read, sizeof(struct knet_log_msg) - bytes_read); if (len <= 0) { return; } bytes_read += len; } if (len > 0) { fprintf(std, "[knet]: [%s] %s: %s\n", knet_log_get_loglevel_name(msg.msglevel), knet_log_get_subsystem_name(msg.subsystem), msg.msg); goto next; } } static void *_logthread(void *args) { fd_set rfds; ssize_t len; struct timeval tv; select_loop: tv.tv_sec = 60; tv.tv_usec = 0; FD_ZERO(&rfds); FD_SET(data.logfd, &rfds); len = select(FD_SETSIZE, &rfds, NULL, NULL, &tv); if (len < 0) { fprintf(data.std, "Unable select over logfd!\nHALTING LOGTHREAD!\n"); return NULL; } if (!len) { fprintf(data.std, "[knet]: No logs in the last 60 seconds\n"); } if (FD_ISSET(data.logfd, &rfds)) { flush_logs(data.logfd, data.std); } goto select_loop; return NULL; } int start_logthread(int logfd, FILE *std) { int savederrno = 0; savederrno = pthread_mutex_lock(&log_thread_mutex); if (savederrno) { printf("Unable to get log_thread mutex lock\n"); return -1; } if (!log_thread_init) { data.logfd = logfd; data.std = std; savederrno = pthread_create(&log_thread, 0, _logthread, NULL); if (savederrno) { printf("Unable to start logging thread: %s\n", strerror(savederrno)); pthread_mutex_unlock(&log_thread_mutex); return -1; } log_thread_init = 1; } pthread_mutex_unlock(&log_thread_mutex); return 0; } int stop_logthread(void) { int savederrno = 0; void *retval; savederrno = pthread_mutex_lock(&log_thread_mutex); if (savederrno) { printf("Unable to get log_thread mutex lock\n"); return -1; } if (log_thread_init) { pthread_cancel(log_thread); pthread_join(log_thread, &retval); log_thread_init = 0; } pthread_mutex_unlock(&log_thread_mutex); return 0; } static void stop_logging(void) { stop_logthread(); flush_logs(log_fds[0], stdout); close_logpipes(log_fds); } int start_logging(FILE *std) { int savederrno = 0; savederrno = pthread_mutex_lock(&log_mutex); if (savederrno) { printf("Unable to get log_mutex lock\n"); return -1; } if (!log_init) { setup_logpipes(log_fds); if (atexit(&stop_logging) != 0) { printf("Unable to register atexit handler to stop logging: %s\n", strerror(errno)); exit(FAIL); } if (start_logthread(log_fds[0], std) < 0) { exit(FAIL); } log_init = 1; } pthread_mutex_unlock(&log_mutex); return log_fds[1]; } knet_handle_t knet_handle_start(int logfds[2], uint8_t log_level) { - knet_handle_t knet_h = knet_handle_new(1, logfds[1], log_level); + knet_handle_t knet_h = knet_handle_new_ex(1, logfds[1], log_level, 0); if (knet_h) { return knet_h; } else { - int exit_status; - - if (errno == ENAMETOOLONG) { - exit_status = SKIP; - } else { - exit_status = FAIL; - } printf("knet_handle_new failed: %s\n", strerror(errno)); flush_logs(logfds[0], stdout); close_logpipes(logfds); - exit(exit_status); + exit(FAIL); } } int knet_handle_stop(knet_handle_t knet_h) { int savederrno; size_t i, j; knet_node_id_t host_ids[KNET_MAX_HOST]; uint8_t link_ids[KNET_MAX_LINK]; size_t host_ids_entries = 0, link_ids_entries = 0; struct knet_link_status status; savederrno = pthread_mutex_lock(&shutdown_mutex); if (savederrno) { printf("Unable to get shutdown mutex lock\n"); return -1; } if (shutdown_in_progress) { pthread_mutex_unlock(&shutdown_mutex); errno = EINVAL; return -1; } shutdown_in_progress = 1; pthread_mutex_unlock(&shutdown_mutex); if (!knet_h) { errno = EINVAL; return -1; } if (knet_host_get_host_list(knet_h, host_ids, &host_ids_entries) < 0) { printf("knet_host_get_host_list failed: %s\n", strerror(errno)); return -1; } for (i = 0; i < host_ids_entries; i++) { if (knet_link_get_link_list(knet_h, host_ids[i], link_ids, &link_ids_entries)) { printf("knet_link_get_link_list failed: %s\n", strerror(errno)); return -1; } for (j = 0; j < link_ids_entries; j++) { if (knet_link_get_status(knet_h, host_ids[i], link_ids[j], &status, sizeof(struct knet_link_status))) { printf("knet_link_get_status failed: %s\n", strerror(errno)); return -1; } if (status.enabled) { if (knet_link_set_enable(knet_h, host_ids[i], j, 0)) { printf("knet_link_set_enable failed: %s\n", strerror(errno)); return -1; } } knet_link_clear_config(knet_h, host_ids[i], j); } if (knet_host_remove(knet_h, host_ids[i]) < 0) { printf("knet_host_remove failed: %s\n", strerror(errno)); return -1; } } if (knet_handle_free(knet_h)) { printf("knet_handle_free failed: %s\n", strerror(errno)); return -1; } return 0; } int make_local_sockaddr(struct sockaddr_storage *lo, uint16_t offset) { uint32_t port; char portstr[32]; /* Use the pid if we can. but makes sure its in a sensible range */ port = (uint32_t)getpid() + offset; if (port < 1024) { port += 1024; } if (port > 65536) { port = port & 0xFFFF; } sprintf(portstr, "%u", port); memset(lo, 0, sizeof(struct sockaddr_storage)); printf("Using port %u\n", port); return knet_strtoaddr("127.0.0.1", portstr, lo, sizeof(struct sockaddr_storage)); } int wait_for_host(knet_handle_t knet_h, uint16_t host_id, int seconds, int logfd, FILE *std) { int i = 0; if (is_memcheck() || is_helgrind()) { printf("Test suite is running under valgrind, adjusting wait_for_host timeout\n"); seconds = seconds * 16; } while (i < seconds) { flush_logs(logfd, std); if (knet_h->host_index[host_id]->status.reachable == 1) { return 0; } printf("waiting host %u to be reachable for %d more seconds\n", host_id, seconds - i); sleep(1); i++; } return -1; } int wait_for_packet(knet_handle_t knet_h, int seconds, int datafd) { fd_set rfds; struct timeval tv; int err = 0; if (is_memcheck() || is_helgrind()) { printf("Test suite is running under valgrind, adjusting wait_for_packet timeout\n"); seconds = seconds * 16; } FD_ZERO(&rfds); FD_SET(datafd, &rfds); tv.tv_sec = seconds; tv.tv_usec = 0; err = select(datafd+1, &rfds, NULL, NULL, &tv); if ((err > 0) && (FD_ISSET(datafd, &rfds))) { return 0; } return -1; } diff --git a/libknet/transport_common.c b/libknet/transport_common.c index 7f8c2f06..ffae0a5c 100644 --- a/libknet/transport_common.c +++ b/libknet/transport_common.c @@ -1,432 +1,439 @@ /* * Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. * * Author: Fabio M. Di Nitto * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include #include "libknet.h" #include "compat.h" #include "host.h" #include "link.h" #include "logging.h" #include "common.h" #include "transport_common.h" /* * reuse Jan Friesse's compat layer as wrapper to drop usage of sendmmsg * * TODO: kill those wrappers once we work on packet delivery guaranteed */ int _recvmmsg(int sockfd, struct knet_mmsghdr *msgvec, unsigned int vlen, unsigned int flags) { int savederrno = 0, err = 0; unsigned int i; for (i = 0; i < vlen; i++) { err = recvmsg(sockfd, &msgvec[i].msg_hdr, flags); savederrno = errno; if (err >= 0) { msgvec[i].msg_len = err; } else { if ((i > 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { savederrno = 0; } break; } } errno = savederrno; return ((i > 0) ? (int)i : err); } int _sendmmsg(int sockfd, struct knet_mmsghdr *msgvec, unsigned int vlen, unsigned int flags) { int savederrno = 0, err = 0; unsigned int i; for (i = 0; i < vlen; i++) { err = sendmsg(sockfd, &msgvec[i].msg_hdr, flags); savederrno = errno; if (err < 0) { break; } } errno = savederrno; return ((i > 0) ? (int)i : err); } /* Assume neither of these constants can ever be zero */ #ifndef SO_RCVBUFFORCE #define SO_RCVBUFFORCE 0 #endif #ifndef SO_SNDBUFFORCE #define SO_SNDBUFFORCE 0 #endif static int _configure_sockbuf(knet_handle_t knet_h, int sock, int option, int force, int target) { int savederrno = 0; int new_value; socklen_t value_len = sizeof new_value; if (setsockopt(sock, SOL_SOCKET, option, &target, sizeof target) != 0) { savederrno = errno; log_err(knet_h, KNET_SUB_TRANSPORT, "Error setting socket buffer via option %d to value %d: %s\n", option, target, strerror(savederrno)); errno = savederrno; return -1; } if (getsockopt(sock, SOL_SOCKET, option, &new_value, &value_len) != 0) { savederrno = errno; log_err(knet_h, KNET_SUB_TRANSPORT, "Error getting socket buffer via option %d: %s\n", option, strerror(savederrno)); errno = savederrno; return -1; } if (value_len != sizeof new_value) { log_err(knet_h, KNET_SUB_TRANSPORT, "Socket option %d returned unexpected size %u\n", option, value_len); errno = ERANGE; return -1; } if (target <= new_value) { return 0; } - if (!force) { + if (!force || !(knet_h->flags & KNET_HANDLE_FLAG_PRIVILEGED)) { log_err(knet_h, KNET_SUB_TRANSPORT, "Failed to set socket buffer via option %d to value %d: capped at %d", option, target, new_value); - errno = ENAMETOOLONG; - return -1; + if (!(knet_h->flags & KNET_HANDLE_FLAG_PRIVILEGED)) { + log_err(knet_h, KNET_SUB_TRANSPORT, + "Continuing regardless, as the handle is not privileged." + " Expect poor performance!"); + return 0; + } else { + errno = ENAMETOOLONG; + return -1; + } } if (setsockopt(sock, SOL_SOCKET, force, &target, sizeof target) < 0) { savederrno = errno; log_err(knet_h, KNET_SUB_TRANSPORT, "Failed to set socket buffer via force option %d: %s", force, strerror(savederrno)); if (savederrno == EPERM) { errno = ENAMETOOLONG; } else { errno = savederrno; } return -1; } return 0; } int _configure_common_socket(knet_handle_t knet_h, int sock, uint64_t flags, const char *type) { int err = 0, savederrno = 0; int value; if (_fdset_cloexec(sock)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s CLOEXEC socket opts: %s", type, strerror(savederrno)); goto exit_error; } if (_fdset_nonblock(sock)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s NONBLOCK socket opts: %s", type, strerror(savederrno)); goto exit_error; } if (_configure_sockbuf(knet_h, sock, SO_RCVBUF, SO_RCVBUFFORCE, KNET_RING_RCVBUFF)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s receive buffer: %s", type, strerror(savederrno)); goto exit_error; } if (_configure_sockbuf(knet_h, sock, SO_SNDBUF, SO_SNDBUFFORCE, KNET_RING_RCVBUFF)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s send buffer: %s", type, strerror(savederrno)); goto exit_error; } if (flags & KNET_LINK_FLAG_TRAFFICHIPRIO) { #ifdef KNET_LINUX #ifdef SO_PRIORITY value = 6; /* TC_PRIO_INTERACTIVE */ if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &value, sizeof(value)) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s priority: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "TC_PRIO_INTERACTIVE enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "TC_PRIO_INTERACTIVE not available in this build/platform"); #endif #endif #if defined(IP_TOS) && defined(IPTOS_LOWDELAY) value = IPTOS_LOWDELAY; if (setsockopt(sock, IPPROTO_IP, IP_TOS, &value, sizeof(value)) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s priority: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "IPTOS_LOWDELAY enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "IPTOS_LOWDELAY not available in this build/platform"); #endif } exit_error: errno = savederrno; return err; } int _configure_transport_socket(knet_handle_t knet_h, int sock, struct sockaddr_storage *address, uint64_t flags, const char *type) { int err = 0, savederrno = 0; int value; if (_configure_common_socket(knet_h, sock, flags, type) < 0) { savederrno = errno; err = -1; goto exit_error; } #ifdef KNET_LINUX #ifdef IP_FREEBIND value = 1; if (setsockopt(sock, SOL_IP, IP_FREEBIND, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set FREEBIND on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "FREEBIND enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "FREEBIND not available in this build/platform"); #endif #endif #ifdef KNET_BSD #ifdef IP_BINDANY /* BSD */ value = 1; if (setsockopt(sock, IPPROTO_IP, IP_BINDANY, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set BINDANY on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "BINDANY enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "BINDANY not available in this build/platform"); #endif #endif if (address->ss_family == AF_INET6) { value = 1; if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &value, sizeof(value)) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s IPv6 only: %s", type, strerror(savederrno)); goto exit_error; } #ifdef KNET_LINUX #ifdef IPV6_MTU_DISCOVER value = IPV6_PMTUDISC_PROBE; if (setsockopt(sock, SOL_IPV6, IPV6_MTU_DISCOVER, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set PMTUDISC on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "IPV6_MTU_DISCOVER enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "IPV6_MTU_DISCOVER not available in this build/platform"); #endif #endif #ifdef IPV6_DONTFRAG value = 1; if (setsockopt(sock, IPPROTO_IPV6, IPV6_DONTFRAG, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set DONTFRAG on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "IPV6_DONTFRAG enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "IPV6_DONTFRAG not available in this build/platform"); #endif } else { #ifdef KNET_LINUX #ifdef IP_MTU_DISCOVER value = IP_PMTUDISC_PROBE; if (setsockopt(sock, SOL_IP, IP_MTU_DISCOVER, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set PMTUDISC on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "PMTUDISC enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "PMTUDISC not available in this build/platform"); #endif #endif #ifdef KNET_BSD #ifdef IP_DONTFRAG value = 1; if (setsockopt(sock, IPPROTO_IP, IP_DONTFRAG, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set DONTFRAG on %s socket: %s", type, strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSPORT, "DONTFRAG enabled on socket: %i", sock); #else log_debug(knet_h, KNET_SUB_TRANSPORT, "DONTFRAG not available in this build/platform"); #endif #endif } value = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSPORT, "Unable to set %s reuseaddr: %s", type, strerror(savederrno)); goto exit_error; } exit_error: errno = savederrno; return err; } int _init_socketpair(knet_handle_t knet_h, int *sock) { int err = 0, savederrno = 0; int i; if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sock) != 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize socketpair: %s", strerror(savederrno)); goto exit_fail; } for (i = 0; i < 2; i++) { if (_configure_common_socket(knet_h, sock[i], 0, "local socketpair") < 0) { savederrno = errno; err = -1; goto exit_fail; } } exit_fail: errno = savederrno; return err; } void _close_socketpair(knet_handle_t knet_h, int *sock) { int i; for (i = 0; i < 2; i++) { if (sock[i]) { close(sock[i]); sock[i] = 0; } } } /* * must be called with global read lock * * return -1 on error * return 0 if fd is invalid * return 1 if fd is valid */ int _is_valid_fd(knet_handle_t knet_h, int sockfd) { int ret = 0; if (sockfd < 0) { errno = EINVAL; return -1; } if (sockfd > KNET_MAX_FDS) { errno = EINVAL; return -1; } if (knet_h->knet_transport_fd_tracker[sockfd].transport >= KNET_MAX_TRANSPORTS) { ret = 0; } else { ret = 1; } return ret; } /* * must be called with global write lock */ int _set_fd_tracker(knet_handle_t knet_h, int sockfd, uint8_t transport, uint8_t data_type, void *data) { if (sockfd < 0) { errno = EINVAL; return -1; } if (sockfd > KNET_MAX_FDS) { errno = EINVAL; return -1; } knet_h->knet_transport_fd_tracker[sockfd].transport = transport; knet_h->knet_transport_fd_tracker[sockfd].data_type = data_type; knet_h->knet_transport_fd_tracker[sockfd].data = data; return 0; } diff --git a/libknet/transport_udp.c b/libknet/transport_udp.c index e4e61648..25e1ae64 100644 --- a/libknet/transport_udp.c +++ b/libknet/transport_udp.c @@ -1,430 +1,433 @@ /* * Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. * * Author: Christine Caulfield * * This software licensed under GPL-2.0+, LGPL-2.0+ */ #include "config.h" #include #include #include #include #include #include #include #include #include #if defined (IP_RECVERR) || defined (IPV6_RECVERR) #include #endif #include "libknet.h" #include "compat.h" #include "host.h" #include "link.h" #include "logging.h" #include "common.h" #include "transport_common.h" #include "transport_udp.h" #include "threads_common.h" typedef struct udp_handle_info { struct knet_list_head links_list; } udp_handle_info_t; typedef struct udp_link_info { struct knet_list_head list; struct sockaddr_storage local_address; int socket_fd; int on_epoll; } udp_link_info_t; int udp_transport_link_set_config(knet_handle_t knet_h, struct knet_link *kn_link) { int err = 0, savederrno = 0; int sock = -1; struct epoll_event ev; udp_link_info_t *info; udp_handle_info_t *handle_info = knet_h->transports[KNET_TRANSPORT_UDP]; #if defined (IP_RECVERR) || defined (IPV6_RECVERR) int value; #endif /* * Only allocate a new link if the local address is different */ knet_list_for_each_entry(info, &handle_info->links_list, list) { if (memcmp(&info->local_address, &kn_link->src_addr, sizeof(struct sockaddr_storage)) == 0) { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Re-using existing UDP socket for new link"); kn_link->outsock = info->socket_fd; kn_link->transport_link = info; kn_link->transport_connected = 1; return 0; } } info = malloc(sizeof(udp_link_info_t)); if (!info) { err = -1; goto exit_error; } sock = socket(kn_link->src_addr.ss_family, SOCK_DGRAM, 0); if (sock < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to create listener socket: %s", strerror(savederrno)); goto exit_error; } if (_configure_transport_socket(knet_h, sock, &kn_link->src_addr, kn_link->flags, "UDP") < 0) { savederrno = errno; err = -1; goto exit_error; } #ifdef IP_RECVERR if (kn_link->src_addr.ss_family == AF_INET) { value = 1; if (setsockopt(sock, SOL_IP, IP_RECVERR, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to set RECVERR on socket: %s", strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSP_UDP, "IP_RECVERR enabled on socket: %i", sock); } #else log_debug(knet_h, KNET_SUB_TRANSP_UDP, "IP_RECVERR not available in this build/platform"); #endif #ifdef IPV6_RECVERR if (kn_link->src_addr.ss_family == AF_INET6) { value = 1; if (setsockopt(sock, SOL_IPV6, IPV6_RECVERR, &value, sizeof(value)) <0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to set RECVERR on socket: %s", strerror(savederrno)); goto exit_error; } log_debug(knet_h, KNET_SUB_TRANSP_UDP, "IPV6_RECVERR enabled on socket: %i", sock); } #else log_debug(knet_h, KNET_SUB_TRANSP_UDP, "IPV6_RECVERR not available in this build/platform"); #endif if (bind(sock, (struct sockaddr *)&kn_link->src_addr, sockaddr_len(&kn_link->src_addr))) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to bind listener socket: %s", strerror(savederrno)); goto exit_error; } memset(&ev, 0, sizeof(struct epoll_event)); ev.events = EPOLLIN; ev.data.fd = sock; if (epoll_ctl(knet_h->recv_from_links_epollfd, EPOLL_CTL_ADD, sock, &ev)) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to add listener to epoll pool: %s", strerror(savederrno)); goto exit_error; } info->on_epoll = 1; if (_set_fd_tracker(knet_h, sock, KNET_TRANSPORT_UDP, 0, info) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to set fd tracker: %s", strerror(savederrno)); goto exit_error; } memmove(&info->local_address, &kn_link->src_addr, sizeof(struct sockaddr_storage)); info->socket_fd = sock; knet_list_add(&info->list, &handle_info->links_list); kn_link->outsock = sock; kn_link->transport_link = info; kn_link->transport_connected = 1; exit_error: if (err) { if (info) { if (info->on_epoll) { epoll_ctl(knet_h->recv_from_links_epollfd, EPOLL_CTL_DEL, sock, &ev); } free(info); } if (sock >= 0) { close(sock); } } errno = savederrno; return err; } int udp_transport_link_clear_config(knet_handle_t knet_h, struct knet_link *kn_link) { int err = 0, savederrno = 0; int found = 0; struct knet_host *host; int link_idx; udp_link_info_t *info = kn_link->transport_link; struct epoll_event ev; for (host = knet_h->host_head; host != NULL; host = host->next) { for (link_idx = 0; link_idx < KNET_MAX_LINK; link_idx++) { if (&host->link[link_idx] == kn_link) continue; if ((host->link[link_idx].transport_link == info) && (host->link[link_idx].status.enabled == 1)) { found = 1; break; } } } if (found) { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "UDP socket %d still in use", info->socket_fd); savederrno = EBUSY; err = -1; goto exit_error; } if (info->on_epoll) { memset(&ev, 0, sizeof(struct epoll_event)); ev.events = EPOLLIN; ev.data.fd = info->socket_fd; if (epoll_ctl(knet_h->recv_from_links_epollfd, EPOLL_CTL_DEL, info->socket_fd, &ev) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to remove UDP socket from epoll poll: %s", strerror(errno)); goto exit_error; } info->on_epoll = 0; } if (_set_fd_tracker(knet_h, info->socket_fd, KNET_MAX_TRANSPORTS, 0, NULL) < 0) { savederrno = errno; err = -1; log_err(knet_h, KNET_SUB_TRANSP_UDP, "Unable to set fd tracker: %s", strerror(savederrno)); goto exit_error; } close(info->socket_fd); knet_list_del(&info->list); free(kn_link->transport_link); exit_error: errno = savederrno; return err; } int udp_transport_free(knet_handle_t knet_h) { udp_handle_info_t *handle_info; if (!knet_h->transports[KNET_TRANSPORT_UDP]) { errno = EINVAL; return -1; } handle_info = knet_h->transports[KNET_TRANSPORT_UDP]; /* * keep it here while we debug list usage and such */ if (!knet_list_empty(&handle_info->links_list)) { log_err(knet_h, KNET_SUB_TRANSP_UDP, "Internal error. handle list is not empty"); return -1; } free(handle_info); knet_h->transports[KNET_TRANSPORT_UDP] = NULL; return 0; } int udp_transport_init(knet_handle_t knet_h) { udp_handle_info_t *handle_info; if (knet_h->transports[KNET_TRANSPORT_UDP]) { errno = EEXIST; return -1; } handle_info = malloc(sizeof(udp_handle_info_t)); if (!handle_info) { return -1; } memset(handle_info, 0, sizeof(udp_handle_info_t)); knet_h->transports[KNET_TRANSPORT_UDP] = handle_info; knet_list_init(&handle_info->links_list); return 0; } #if defined (IP_RECVERR) || defined (IPV6_RECVERR) static int read_errs_from_sock(knet_handle_t knet_h, int sockfd) { int err = 0, savederrno = 0; int got_err = 0; char buffer[1024]; struct iovec iov; struct msghdr msg; struct cmsghdr *cmsg; struct sock_extended_err *sock_err; struct icmphdr icmph; struct sockaddr_storage remote; struct sockaddr_storage *origin; char addr_str[KNET_MAX_HOST_LEN]; char port_str[KNET_MAX_PORT_LEN]; iov.iov_base = &icmph; iov.iov_len = sizeof(icmph); msg.msg_name = (void*)&remote; msg.msg_namelen = sizeof(remote); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_flags = 0; msg.msg_control = buffer; msg.msg_controllen = sizeof(buffer); for (;;) { err = recvmsg(sockfd, &msg, MSG_ERRQUEUE); savederrno = errno; if (err < 0) { if (!got_err) { errno = savederrno; return -1; } else { return 0; } } got_err = 1; for (cmsg = CMSG_FIRSTHDR(&msg);cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_RECVERR)) || ((cmsg->cmsg_level == SOL_IPV6 && (cmsg->cmsg_type == IPV6_RECVERR)))) { sock_err = (struct sock_extended_err*)(void *)CMSG_DATA(cmsg); if (sock_err) { switch (sock_err->ee_origin) { case 0: /* no origin */ case 1: /* local source (EMSGSIZE) */ if (sock_err->ee_errno == EMSGSIZE) { if (pthread_mutex_lock(&knet_h->kmtu_mutex) != 0) { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Unable to get mutex lock"); knet_h->kernel_mtu = 0; break; } else { knet_h->kernel_mtu = sock_err->ee_info; pthread_mutex_unlock(&knet_h->kmtu_mutex); } /* * we can only try to take a lock here. This part of the code * can be invoked by any thread, including PMTUd that is already * holding a lock at that stage. * If PMTUd is holding the lock, most likely it is already running * and we don't need to notify it back. */ if (!pthread_mutex_trylock(&knet_h->pmtud_mutex)) { if (!knet_h->pmtud_running) { if (!knet_h->pmtud_forcerun) { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Notifying PMTUd to rerun"); knet_h->pmtud_forcerun = 1; } } pthread_mutex_unlock(&knet_h->pmtud_mutex); } } /* * those errors are way too noisy */ break; case 2: /* ICMP */ case 3: /* ICMP6 */ origin = (struct sockaddr_storage *)(void *)SO_EE_OFFENDER(sock_err); if (knet_addrtostr(origin, sizeof(origin), addr_str, KNET_MAX_HOST_LEN, port_str, KNET_MAX_PORT_LEN) < 0) { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Received ICMP error from unknown source: %s", strerror(sock_err->ee_errno)); } else { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Received ICMP error from %s: %s", addr_str, strerror(sock_err->ee_errno)); } break; } } else { log_debug(knet_h, KNET_SUB_TRANSP_UDP, "No data in MSG_ERRQUEUE"); } } } } } #else static int read_errs_from_sock(knet_handle_t knet_h, int sockfd) { return 0; } #endif int udp_transport_rx_sock_error(knet_handle_t knet_h, int sockfd, int recv_err, int recv_errno) { if (recv_errno == EAGAIN) { read_errs_from_sock(knet_h, sockfd); } return 0; } int udp_transport_tx_sock_error(knet_handle_t knet_h, int sockfd, int recv_err, int recv_errno) { if (recv_err < 0) { if (recv_errno == EMSGSIZE) { read_errs_from_sock(knet_h, sockfd); return 0; } + if (recv_errno == EINVAL) { + return -1; + } if ((recv_errno == ENOBUFS) || (recv_errno == EAGAIN)) { #ifdef DEBUG log_debug(knet_h, KNET_SUB_TRANSP_UDP, "Sock: %d is overloaded. Slowing TX down", sockfd); #endif usleep(KNET_THREADS_TIMERES / 16); } else { read_errs_from_sock(knet_h, sockfd); } return 1; } return 0; } int udp_transport_rx_is_data(knet_handle_t knet_h, int sockfd, struct knet_mmsghdr *msg) { if (msg->msg_len == 0) return 0; return 2; } int udp_transport_link_dyn_connect(knet_handle_t knet_h, int sockfd, struct knet_link *kn_link) { kn_link->status.dynconnected = 1; return 0; } diff --git a/libtap/Makefile.am b/libtap/Makefile.am index 4262364a..0690daea 100644 --- a/libtap/Makefile.am +++ b/libtap/Makefile.am @@ -1,60 +1,60 @@ # # Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in include $(top_srcdir)/build-aux/check.mk SYMFILE = libtap_exported_syms EXTRA_DIST = $(SYMFILE) tap_updown_bad tap_updown_good api-test-coverage sources = libtap.c libversion = 1:0:0 -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS += $(PTHREAD_CFLAGS) LIBS = $(PTHREAD_LIBS) if BUILD_LIBTAP include_HEADERS = libtap.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libtap.pc lib_LTLIBRARIES = libtap.la libtap_la_SOURCES = $(sources) EXTRA_libtap_la_DEPENDENCIES = $(SYMFILE) -libtap_la_LDFLAGS = -Wl,-version-script,$(srcdir)/$(SYMFILE) \ - --export-dynamic \ - -version-number $(libversion) +libtap_la_LDFLAGS = $(AM_LDFLAGS) \ + -Wl,-version-script,$(srcdir)/$(SYMFILE) \ + -version-info $(libversion) TESTS = $(check_PROGRAMS) noinst_PROGRAMS = $(check_PROGRAMS) check_PROGRAMS = tap_test check-local: check-api-test-coverage check-api-test-coverage: chmod u+x $(top_srcdir)/libtap/api-test-coverage $(top_srcdir)/libtap/api-test-coverage $(top_srcdir) $(top_builddir) tap_test_SOURCES = $(sources) tap_test_CPPFLAGS = -DTEST \ -DABSBUILDDIR=\"$(abs_builddir)\" endif diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4 new file mode 100644 index 00000000..819409a2 --- /dev/null +++ b/m4/ax_check_link_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the linker or gives an error. +# (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_LINK_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AC_DEFUN([AX_CHECK_LINK_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl +AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS $4 $1" + AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + LDFLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_LINK_FLAGS diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4 new file mode 100644 index 00000000..12cb005a --- /dev/null +++ b/m4/ax_prog_cc_for_build.m4 @@ -0,0 +1,125 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_CC_FOR_BUILD +# +# DESCRIPTION +# +# This macro searches for a C compiler that generates native executables, +# that is a C compiler that surely is not a cross-compiler. This can be +# useful if you have to generate source code at compile-time like for +# example GCC does. +# +# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything +# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). +# The value of these variables can be overridden by the user by specifying +# a compiler with an environment variable (like you do for standard CC). +# +# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object +# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if +# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are +# substituted in the Makefile. +# +# LICENSE +# +# Copyright (c) 2008 Paolo Bonzini +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 9 + +AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) +AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_EXEEXT])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl + +dnl Use the standard macros, but make them use other variable names +dnl +pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl +pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl +pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl +pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl +pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl +pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl +pushdef([ac_cv_objext], ac_cv_build_objext)dnl +pushdef([ac_exeext], ac_build_exeext)dnl +pushdef([ac_objext], ac_build_objext)dnl +pushdef([CC], CC_FOR_BUILD)dnl +pushdef([CPP], CPP_FOR_BUILD)dnl +pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl +pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl +pushdef([host], build)dnl +pushdef([host_alias], build_alias)dnl +pushdef([host_cpu], build_cpu)dnl +pushdef([host_vendor], build_vendor)dnl +pushdef([host_os], build_os)dnl +pushdef([ac_cv_host], ac_cv_build)dnl +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl +pushdef([ac_cv_host_os], ac_cv_build_os)dnl +pushdef([ac_cpp], ac_build_cpp)dnl +pushdef([ac_compile], ac_build_compile)dnl +pushdef([ac_link], ac_build_link)dnl + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +AC_PROG_CC +AC_PROG_CPP +AC_EXEEXT + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + +dnl Restore the old definitions +dnl +popdef([ac_link])dnl +popdef([ac_compile])dnl +popdef([ac_cpp])dnl +popdef([ac_cv_host_os])dnl +popdef([ac_cv_host_vendor])dnl +popdef([ac_cv_host_cpu])dnl +popdef([ac_cv_host_alias])dnl +popdef([ac_cv_host])dnl +popdef([host_os])dnl +popdef([host_vendor])dnl +popdef([host_cpu])dnl +popdef([host_alias])dnl +popdef([host])dnl +popdef([LDFLAGS])dnl +popdef([CPPFLAGS])dnl +popdef([CFLAGS])dnl +popdef([CPP])dnl +popdef([CC])dnl +popdef([ac_objext])dnl +popdef([ac_exeext])dnl +popdef([ac_cv_objext])dnl +popdef([ac_cv_exeext])dnl +popdef([ac_cv_prog_cc_g])dnl +popdef([ac_cv_prog_cc_cross])dnl +popdef([ac_cv_prog_cc_works])dnl +popdef([ac_cv_prog_gcc])dnl +popdef([ac_cv_prog_CPP])dnl + +dnl Finally, set Makefile variables +dnl +BUILD_EXEEXT=$ac_build_exeext +BUILD_OBJEXT=$ac_build_objext +AC_SUBST(BUILD_EXEEXT)dnl +AC_SUBST(BUILD_OBJEXT)dnl +AC_SUBST([CFLAGS_FOR_BUILD])dnl +AC_SUBST([CPPFLAGS_FOR_BUILD])dnl +AC_SUBST([LDFLAGS_FOR_BUILD])dnl +]) diff --git a/libknet/man/Doxyfile.in b/man/Doxyfile-knet.in similarity index 80% rename from libknet/man/Doxyfile.in rename to man/Doxyfile-knet.in index 034ba8af..50d78bd5 100644 --- a/libknet/man/Doxyfile.in +++ b/man/Doxyfile-knet.in @@ -1,17 +1,17 @@ # # Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # Christine Caulfield # # This software licensed under GPL-2.0+, LGPL-2.0+ # PROJECT_NAME = @PACKAGE_NAME@ PROJECT_NUMBER = @PACKAGE_VERSION@ -INPUT = @srcdir@/../libknet.h -XML_OUTPUT = @abs_builddir@/xml +INPUT = @abs_top_srcdir@/libknet/libknet.h +XML_OUTPUT = @abs_builddir@/xml-knet GENERATE_XML = YES XML_PROGRAMLISTING = NO AUTOLINK_SUPPORT = NO GENERATE_HTML = NO GENERATE_LATEX = NO diff --git a/libknet/man/Makefile.am b/man/Makefile.am similarity index 66% rename from libknet/man/Makefile.am rename to man/Makefile.am index 50c7350d..ec53439e 100644 --- a/libknet/man/Makefile.am +++ b/man/Makefile.am @@ -1,87 +1,110 @@ # # Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. # # Authors: Fabio M. Di Nitto # Federico Simoncelli # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in include $(top_srcdir)/build-aux/check.mk -dist_man_MANS = \ +EXTRA_DIST = kronosnetd.8 knet-keygen.8 + +# Avoid Automake warnings about overriding these user variables. +# Programs in this directory are used during the build only. +AUTOMAKE_OPTIONS = -Wno-gnu +EXEEXT=$(BUILD_EXEEXT) +CC=$(CC_FOR_BUILD) +CFLAGS=$(CFLAGS_FOR_BUILD) +CPPFLAGS=$(CPPFLAGS_FOR_BUILD) +LDFLAGS=$(LDFLAGS_FOR_BUILD) + +if BUILD_MAN + +if BUILD_KRONOSNETD +man8_MANS = kronosnetd.8 knet-keygen.8 +endif + +noinst_PROGRAMS = doxyxml + +doxyxml_SOURCES = doxyxml.c +doxyxml_CFLAGS = $(AM_CFLAGS) $(libqb_BUILD_CFLAGS) $(libxml_BUILD_CFLAGS) +doxyxml_LDADD = $(libqb_BUILD_LIBS) $(libxml_BUILD_LIBS) + +knet_man3_MANS = \ knet_addrtostr.3 \ knet_handle_add_datafd.3 \ knet_handle_clear_stats.3 \ knet_handle_compress.3 \ knet_handle_crypto.3 \ knet_handle_enable_filter.3 \ knet_handle_enable_pmtud_notify.3 \ knet_handle_enable_sock_notify.3 \ knet_handle_free.3 \ knet_handle_get_channel.3 \ knet_get_compress_list.3 \ knet_get_crypto_list.3 \ knet_handle_get_datafd.3 \ knet_handle_get_stats.3 \ knet_get_transport_id_by_name.3 \ knet_get_transport_list.3 \ knet_get_transport_name_by_id.3 \ knet_handle_get_transport_reconnect_interval.3 \ knet_handle_new.3 \ + knet_handle_new_ex.3 \ knet_handle_pmtud_get.3 \ knet_handle_pmtud_getfreq.3 \ knet_handle_pmtud_setfreq.3 \ knet_handle_remove_datafd.3 \ knet_handle_setfwd.3 \ knet_handle_set_transport_reconnect_interval.3 \ knet_host_add.3 \ knet_host_enable_status_change_notify.3 \ knet_host_get_host_list.3 \ knet_host_get_id_by_host_name.3 \ knet_host_get_name_by_host_id.3 \ knet_host_get_policy.3 \ knet_host_get_status.3 \ knet_host_remove.3 \ knet_host_set_name.3 \ knet_host_set_policy.3 \ knet_link_clear_config.3 \ knet_link_get_config.3 \ knet_link_get_enable.3 \ knet_link_get_link_list.3 \ knet_link_get_ping_timers.3 \ knet_link_get_pong_count.3 \ knet_link_get_priority.3 \ knet_link_get_status.3 \ knet_link_set_config.3 \ knet_link_set_enable.3 \ knet_link_set_ping_timers.3 \ knet_link_set_pong_count.3 \ knet_link_set_priority.3 \ knet_log_get_loglevel.3 \ knet_log_get_loglevel_id.3 \ knet_log_get_loglevel_name.3 \ knet_log_get_subsystem_id.3 \ knet_log_get_subsystem_name.3 \ knet_log_set_loglevel.3 \ knet_recv.3 \ knet_send.3 \ knet_send_sync.3 \ - knet_strtoaddr.3 \ - libknet.h.3 + knet_strtoaddr.3 + +man3_MANS = $(knet_man3_MANS) + +$(MANS): doxyfile-knet.stamp -update-man-pages: doxyfile.stamp +doxyfile-knet.stamp: $(builddir)/doxyxml Doxyfile-knet $(top_srcdir)/libknet/libknet.h + $(DOXYGEN) Doxyfile-knet + $(builddir)/doxyxml -m -P -o $(builddir) -s 3 -p @PACKAGE_NAME@ -H "Kronosnet Programmer's Manual" -d $(builddir)/xml-knet/ libknet_8h.xml + touch doxyfile-knet.stamp -doxyfile.stamp: Doxyfile -if MANPAGEUPDATES - $(DOXYGEN) Doxyfile - $(DOXY2MAN) -o $(abs_srcdir) -s 3 --short-pkg @PACKAGE_NAME@ --pkg "Kronosnet Programmer's Manual" $(builddir)/xml/libknet_8h.xml -else - @echo this system does not have doxy2man or doxygen installed. Unable to update man pages automatically. endif - touch doxyfile.stamp clean-local: - rm -rf doxyfile.stamp xml + rm -rf doxyfile*.stamp xml* *.3 diff --git a/man/doxyxml.c b/man/doxyxml.c new file mode 100644 index 00000000..ebdda868 --- /dev/null +++ b/man/doxyxml.c @@ -0,0 +1,829 @@ +/* + * Copyright (C) 2018 Red Hat, Inc. All rights reserved. + * + * Author: Christine Caulfield + * + * This software licensed under GPL-2.0+, LGPL-2.0+ + */ + + +/* + * NOTE: this code is very rough, it does the bare minimum to parse the + * XML out from doxygen and is probably very fragile to changes in that XML + * schema. It probably leaks memory all over the place too. + * + * In its favour, it *does* generate man pages and should only be run very ocasionally + */ + +#define _DEFAULT_SOURCE +#define _BSD_SOURCE +#define _XOPEN_SOURCE +#define _XOPEN_SOURCE_EXTENDED +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define XML_DIR "../../libknet/man/xml" +#define XML_FILE "libknet_8h.xml" + +static int print_ascii = 1; +static int print_man = 0; +static int print_params = 0; +static int num_functions = 0; +static const char *man_section="3"; +static const char *package_name="Kronosnet"; +static const char *header="Kronosnet Programmer's Manual"; +static const char *output_dir="./"; +static const char *xml_dir = XML_DIR; +static const char *xml_file = XML_FILE; +static struct qb_list_head params_list; +static struct qb_list_head retval_list; +static qb_map_t *function_map; +static qb_map_t *structures_map; +static qb_map_t *used_structures_map; + +struct param_info { + char *paramname; + char *paramtype; + char *paramdesc; + struct param_info *next; + struct qb_list_head list; +}; + +struct struct_info { + char *structname; + struct qb_list_head params_list; /* our params */ + struct qb_list_head list; +}; + +static char *get_texttree(int *type, xmlNode *cur_node, char **returntext); +static void traverse_node(xmlNode *parentnode, const char *leafname, void (do_members(xmlNode*, void*)), void *arg); + +static void free_paraminfo(struct param_info *pi) +{ + free(pi->paramname); + free(pi->paramtype); + free(pi->paramdesc); + free(pi); +} + +static char *get_attr(xmlNode *node, const char *tag) +{ + xmlAttr *this_attr; + + for (this_attr = node->properties; this_attr; this_attr = this_attr->next) { + if (this_attr->type == XML_ATTRIBUTE_NODE && strcmp((char *)this_attr->name, tag) == 0) { + return strdup((char *)this_attr->children->content); + } + } + return NULL; +} + +static char *get_child(xmlNode *node, const char *tag) +{ + xmlNode *this_node; + xmlNode *child; + char buffer[1024] = {'\0'}; + char *refid = NULL; + char *declname = NULL; + + for (this_node = node->children; this_node; this_node = this_node->next) { + if ((strcmp( (char*)this_node->name, "declname") == 0)) { + declname = strdup((char*)this_node->children->content); + } + + if ((this_node->type == XML_ELEMENT_NODE && this_node->children) && ((strcmp((char *)this_node->name, tag) == 0))) { + refid = NULL; + for (child = this_node->children; child; child = child->next) { + if (child->content) { + strcat(buffer, (char *)child->content); + } + + if ((strcmp( (char*)child->name, "ref") == 0)) { + if (child->children->content) { + strcat(buffer,(char *)child->children->content); + } + refid = get_attr(child, "refid"); + } + } + } + if (declname && refid) { + qb_map_put(used_structures_map, refid, declname); + } + } + return strdup(buffer); +} + +static struct param_info *find_param_by_name(struct qb_list_head *list, const char *name) +{ + struct qb_list_head *iter; + struct param_info *pi; + + qb_list_for_each(iter, list) { + pi = qb_list_entry(iter, struct param_info, list); + if (strcmp(pi->paramname, name) == 0) { + return pi; + } + } + return NULL; +} + +static int not_all_whitespace(char *string) +{ + unsigned int i; + + for (i=0; ichildren; this_tag; this_tag = this_tag->next) { + for (sub_tag = this_tag->children; sub_tag; sub_tag = sub_tag->next) { + if (sub_tag->type == XML_ELEMENT_NODE && strcmp((char *)sub_tag->name, "parameternamelist") == 0) { + paramname = (char*)sub_tag->children->next->children->content; + } + if (sub_tag->type == XML_ELEMENT_NODE && strcmp((char *)sub_tag->name, "parameterdescription") == 0) { + paramdesc = (char*)sub_tag->children->next->children->content; + + /* Add text to the param_map */ + pi = find_param_by_name(list, paramname); + if (pi) { + pi->paramdesc = paramdesc; + } + else { + pi = malloc(sizeof(struct param_info)); + if (pi) { + pi->paramname = paramname; + pi->paramdesc = paramdesc; + pi->paramtype = NULL; /* retval */ + qb_list_add_tail(&pi->list, list); + } + } + } + } + } +} + +static char *get_text(xmlNode *cur_node, char **returntext) +{ + xmlNode *this_tag; + xmlNode *sub_tag; + char *kind; + char buffer[4096] = {'\0'}; + + for (this_tag = cur_node->children; this_tag; this_tag = this_tag->next) { + if (this_tag->type == XML_TEXT_NODE && strcmp((char *)this_tag->name, "text") == 0) { + if (not_all_whitespace((char*)this_tag->content)) { + strcat(buffer, (char*)this_tag->content); + strcat(buffer, "\n"); + } + } + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "emphasis") == 0) { + if (print_man) { + strcat(buffer, "\\fB"); + } + strcat(buffer, (char*)this_tag->children->content); + if (print_man) { + strcat(buffer, "\\fR"); + } + } + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "itemizedlist") == 0) { + for (sub_tag = this_tag->children; sub_tag; sub_tag = sub_tag->next) { + if (sub_tag->type == XML_ELEMENT_NODE && strcmp((char *)sub_tag->name, "listitem") == 0) { + strcat(buffer, (char*)sub_tag->children->children->content); + strcat(buffer, "\n"); + } + } + } + + /* Look for subsections - return value & params */ + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "simplesect") == 0) { + char *tmp; + + kind = get_attr(this_tag, "kind"); + tmp = get_text(this_tag->children, NULL); + + if (returntext && strcmp(kind, "return") == 0) { + *returntext = tmp; + } + } + + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "parameterlist") == 0) { + kind = get_attr(this_tag, "kind"); + if (strcmp(kind, "param") == 0) { + get_param_info(this_tag, ¶ms_list); + } + if (strcmp(kind, "retval") == 0) { + get_param_info(this_tag, &retval_list); + } + } + } + return strdup(buffer); +} + +/* Called from traverse_node() */ +static void read_struct(xmlNode *cur_node, void *arg) +{ + xmlNode *this_tag; + struct struct_info *si=arg; + struct param_info *pi; + char fullname[1024]; + char *type = NULL; + char *name = NULL; + const char *args=""; + + for (this_tag = cur_node->children; this_tag; this_tag = this_tag->next) { + if (strcmp((char*)this_tag->name, "type") == 0) { + type = (char*)this_tag->children->content ; + } + if (strcmp((char*)this_tag->name, "name") == 0) { + name = (char*)this_tag->children->content ; + } + if (this_tag->children && strcmp((char*)this_tag->name, "argsstring") == 0) { + args = (char*)this_tag->children->content; + } + } + + if (name) { + pi = malloc(sizeof(struct param_info)); + if (pi) { + snprintf(fullname, sizeof(fullname), "%s%s", name, args); + pi->paramtype = strdup(type); + pi->paramname = strdup(fullname); + pi->paramdesc = NULL; + qb_list_add_tail(&pi->list, &si->params_list); + } + } +} + +static int read_structure_from_xml(char *refid, char *name) +{ + char fname[PATH_MAX]; + xmlNode *rootdoc; + xmlDocPtr doc; + struct struct_info *si; + int ret = -1; + + snprintf(fname, sizeof(fname), "%s/%s.xml", xml_dir, refid); + + doc = xmlParseFile(fname); + if (doc == NULL) { + fprintf(stderr, "Error: unable to open xml file for %s\n", refid); + return -1; + } + + rootdoc = xmlDocGetRootElement(doc); + if (!rootdoc) { + fprintf(stderr, "Can't find \"document root\"\n"); + return -1; + } + + si = malloc(sizeof(struct struct_info)); + if (si) { + qb_list_init(&si->params_list); + si->structname = strdup(name); + traverse_node(rootdoc, "memberdef", read_struct, si); + ret = 0; + qb_map_put(structures_map, refid, si); + } + xmlFreeDoc(doc); + + return ret; +} + +/* Reformat pointer params so they look nicer */ +static void print_param(FILE *manfile, struct param_info *pi, int field_width, int bold, const char *delimiter) +{ + char asterisk = ' '; + char *type = pi->paramtype; + + if (pi->paramtype[strlen(pi->paramtype)-1] == '*') { + asterisk='*'; + type = strdup(pi->paramtype); + type[strlen(type)-1] = '\0'; + } + + fprintf(manfile, " %s%-*s%c%s\\fI%s\\fP%s\n", + bold?"\\fB":"", field_width, type, + asterisk, bold?"\\fP":"", pi->paramname, delimiter); + + if (type != pi->paramtype) { + free(type); + } +} + +static void print_structure(FILE *manfile, char *refid, char *name) +{ + struct struct_info *si; + struct param_info *pi; + struct qb_list_head *iter; + unsigned int max_param_length=0; + + /* If it's not been read in - go and look for it */ + si = qb_map_get(structures_map, refid); + if (!si) { + if (!read_structure_from_xml(refid, name)) { + si = qb_map_get(structures_map, refid); + } + } + + if (si) { + qb_list_for_each(iter, &si->params_list) { + pi = qb_list_entry(iter, struct param_info, list); + if (strlen(pi->paramtype) > max_param_length) { + max_param_length = strlen(pi->paramtype); + } + } + + fprintf(manfile, "struct %s {\n", si->structname); + + qb_list_for_each(iter, &si->params_list) { + pi = qb_list_entry(iter, struct param_info, list); + print_param(manfile, pi, max_param_length, 0,";"); + } + fprintf(manfile, "};\n"); + } +} + +char *get_texttree(int *type, xmlNode *cur_node, char **returntext) +{ + xmlNode *this_tag; + char *tmp = NULL; + char buffer[4096] = {'\0'}; + + for (this_tag = cur_node->children; this_tag; this_tag = this_tag->next) { + + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "para") == 0) { + tmp = get_text(this_tag, returntext); + strcat(buffer, tmp); + strcat(buffer, "\n"); + free(tmp); + } + } + + if (buffer[0]) { + tmp = strdup(buffer); + } + + return tmp; +} + +/* The text output is VERY basic and just a check that it's working really */ +static void print_text(char *name, char *def, char *brief, char *args, char *detailed, struct qb_list_head *param_list, char *returntext) +{ + printf(" ------------------ %s --------------------\n", name); + printf("NAME\n"); + printf(" %s - %s\n", name, brief); + + printf("SYNOPSIS\n"); + printf(" %s %s\n\n", name, args); + + printf("DESCRIPTION\n"); + printf(" %s\n", detailed); + + if (returntext) { + printf("RETURN VALUE\n"); + printf(" %s\n", returntext); + } +} + +/* Print a long string with para marks in it. */ +static void man_print_long_string(FILE *manfile, char *text) +{ + char *next_nl; + char *current = text; + + next_nl = strchr(text, '\n'); + while (next_nl && *next_nl != '\0') { + *next_nl = '\0'; + if (strlen(current)) { + fprintf(manfile, ".PP\n%s\n", current); + } + + *next_nl = '\n'; + current = next_nl+1; + next_nl = strchr(current, '\n'); + } +} + +static void print_manpage(char *name, char *def, char *brief, char *args, char *detailed, struct qb_list_head *param_map, char *returntext) +{ + char manfilename[PATH_MAX]; + char gendate[64]; + FILE *manfile; + time_t t; + struct tm *tm; + qb_map_iter_t *map_iter; + struct qb_list_head *iter; + struct qb_list_head *tmp; + const char *p; + void *data; + unsigned int max_param_type_len; + unsigned int max_param_name_len; + unsigned int num_param_descs; + int param_count = 0; + int param_num = 0; + struct param_info *pi; + + t = time(NULL); + tm = localtime(&t); + if (!tm) { + perror("unable to get localtime"); + exit(1); + } + strftime(gendate, sizeof(gendate), "%Y-%m-%d", tm); + + snprintf(manfilename, sizeof(manfilename), "%s/%s.%s", output_dir, name, man_section); + manfile = fopen(manfilename, "w+"); + if (!manfile) { + perror("unable to open output file"); + printf("%s", manfilename); + exit(1); + } + + /* Work out the length of the parameters, so we can line them up */ + max_param_type_len = 0; + max_param_name_len = 0; + num_param_descs = 0; + + qb_list_for_each(iter, ¶ms_list) { + pi = qb_list_entry(iter, struct param_info, list); + + if (strlen(pi->paramtype) > max_param_type_len) { + max_param_type_len = strlen(pi->paramtype); + } + if (strlen(pi->paramname) > max_param_name_len) { + max_param_name_len = strlen(pi->paramname); + } + if (pi->paramdesc) { + num_param_descs++; + } + param_count++; + } + + /* Off we go */ + + fprintf(manfile, ".\\\" Automatically generated man page, do not edit\n"); + fprintf(manfile, ".TH %s %s %s \"%s\" \"%s\"\n", name, man_section, gendate, package_name, header); + + fprintf(manfile, ".SH NAME\n"); + fprintf(manfile, "%s \\- %s\n", name, brief); + + fprintf(manfile, ".SH SYNOPSIS\n"); + fprintf(manfile, ".nf\n"); + fprintf(manfile, ".B #include \n"); + fprintf(manfile, ".sp\n"); + fprintf(manfile, "\\fB%s\\fP(\n", def); + + + qb_list_for_each(iter, ¶ms_list) { + pi = qb_list_entry(iter, struct param_info, list); + + print_param(manfile, pi, max_param_type_len, 1, ++param_num < param_count?",":""); + } + + fprintf(manfile, ");\n"); + fprintf(manfile, ".fi\n"); + + if (print_params && num_param_descs) { + fprintf(manfile, ".SH PARAMS\n"); + + qb_list_for_each(iter, ¶ms_list) { + pi = qb_list_entry(iter, struct param_info, list); + fprintf(manfile, "\\fB%-*s \\fP\\fI%s\\fP\n", (int)max_param_name_len, pi->paramname, + pi->paramdesc); + fprintf(manfile, ".PP\n"); + } + } + + fprintf(manfile, ".SH DESCRIPTION\n"); + man_print_long_string(manfile, detailed); + + if (qb_map_count_get(used_structures_map)) { + fprintf(manfile, ".SH STRUCTURES\n"); + + map_iter = qb_map_iter_create(used_structures_map); + for (p = qb_map_iter_next(map_iter, &data); p; p = qb_map_iter_next(map_iter, &data)) { + fprintf(manfile, ".SS \"\"\n"); + fprintf(manfile, ".PP\n"); + fprintf(manfile, ".sp\n"); + fprintf(manfile, ".sp\n"); + fprintf(manfile, ".RS\n"); + fprintf(manfile, ".nf\n"); + fprintf(manfile, "\\fB\n"); + + print_structure(manfile, (char*)p, (char *)data); + + fprintf(manfile, "\\fP\n"); + fprintf(manfile, ".fi\n"); + } + qb_map_iter_free(map_iter); + + fprintf(manfile, ".RE\n"); + } + + if (returntext) { + fprintf(manfile, ".SH RETURN VALUE\n"); + man_print_long_string(manfile, returntext); + } + + qb_list_for_each(iter, &retval_list) { + pi = qb_list_entry(iter, struct param_info, list); + + fprintf(manfile, "\\fB%-*s \\fP\\fI%s\\fP\n", 10, pi->paramname, + pi->paramdesc); + fprintf(manfile, ".PP\n"); + } + + fprintf(manfile, ".SH SEE ALSO\n"); + fprintf(manfile, ".PP\n"); + fprintf(manfile, ".nh\n"); + fprintf(manfile, ".ad l\n"); + + param_num = 0; + map_iter = qb_map_iter_create(function_map); + for (p = qb_map_iter_next(map_iter, &data); p; p = qb_map_iter_next(map_iter, &data)) { + + /* Exclude us! */ + if (strcmp(data, name)) { + fprintf(manfile, "\\fI%s(%s)%s", (char *)data, man_section, + param_num < (num_functions - 1)?", ":""); + } + param_num++; + } + qb_map_iter_free(map_iter); + + fprintf(manfile, "\n"); + fprintf(manfile, ".ad\n"); + fprintf(manfile, ".hy\n"); + fprintf(manfile, ".SH \"COPYRIGHT\"\n"); + fprintf(manfile, ".PP\n"); + fprintf(manfile, "Copyright (C) 2010-%4d Red Hat, Inc. All rights reserved.\n", tm->tm_year+1900); + fclose(manfile); + + /* Free the params & retval info */ + qb_list_for_each_safe(iter, tmp, ¶ms_list) { + pi = qb_list_entry(iter, struct param_info, list); + qb_list_del(&pi->list); + free_paraminfo(pi); + } + + qb_list_for_each_safe(iter, tmp, &retval_list) { + pi = qb_list_entry(iter, struct param_info, list); + qb_list_del(&pi->list); + free_paraminfo(pi); + } + + /* Free used-structures map */ + map_iter = qb_map_iter_create(used_structures_map); + for (p = qb_map_iter_next(map_iter, &data); p; p = qb_map_iter_next(map_iter, &data)) { + qb_map_rm(used_structures_map, p); + free(data); + } +} + +/* Same as traverse_members, but to collect function names */ +static void collect_functions(xmlNode *cur_node, void *arg) +{ + xmlNode *this_tag; + char *kind; + char *name = NULL; + + if (cur_node->name && strcmp((char *)cur_node->name, "memberdef") == 0) { + + kind = get_attr(cur_node, "kind"); + if (kind && strcmp(kind, "function") == 0) { + + for (this_tag = cur_node->children; this_tag; this_tag = this_tag->next) { + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "name") == 0) { + name = strdup((char *)this_tag->children->content); + } + } + + if (name) { + qb_map_put(function_map, name, name); + num_functions++; + } + } + } +} + + +static void traverse_members(xmlNode *cur_node, void *arg) +{ + xmlNode *this_tag; + + if (cur_node->name && strcmp((char *)cur_node->name, "memberdef") == 0) { + char *kind = NULL; + char *def = NULL; + char *args = NULL; + char *name = NULL; + char *brief = NULL; + char *detailed = NULL; + char *returntext = NULL; + int type; + + kind=def=args=name=NULL; + + kind = get_attr(cur_node, "kind"); + + for (this_tag = cur_node->children; this_tag; this_tag = this_tag->next) + { + if (!this_tag->children || !this_tag->children->content) + continue; + + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "definition") == 0) + def = strdup((char *)this_tag->children->content); + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "argsstring") == 0) + args = strdup((char *)this_tag->children->content); + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "name") == 0) + name = strdup((char *)this_tag->children->content); + + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "briefdescription") == 0) { + brief = get_texttree(&type, this_tag, &returntext); + if (brief) { + /* + * apparently brief text contains extra trailing space and 2 \n. + * remove them. + */ + brief[strlen(brief) - 3] = '\0'; + } + } + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "detaileddescription") == 0) { + detailed = get_texttree(&type, this_tag, &returntext); + } + /* Get all the params */ + if (this_tag->type == XML_ELEMENT_NODE && strcmp((char *)this_tag->name, "param") == 0) { + char *param_type = get_child(this_tag, "type"); + char *param_name = get_child(this_tag, "declname"); + struct param_info *pi = malloc(sizeof(struct param_info)); + if (pi) { + pi->paramname = param_name; + pi->paramtype = param_type; + pi->paramdesc = NULL; + qb_list_add_tail(&pi->list, ¶ms_list); + } + } + } + + if (kind && strcmp(kind, "typedef") == 0) { + /* Collect typedefs? */ + } + + if (kind && strcmp(kind, "function") == 0) { + if (print_man) { + print_manpage(name, def, brief, args, detailed, ¶ms_list, returntext); + } + else { + print_text(name, def, brief, args, detailed, ¶ms_list, returntext); + } + + } + + free(kind); + free(def); + free(args); +// free(name); /* don't free, it's in the map */ + } +} + + +static void traverse_node(xmlNode *parentnode, const char *leafname, void (do_members(xmlNode*, void*)), void *arg) +{ + xmlNode *cur_node; + + for (cur_node = parentnode->children; cur_node; cur_node = cur_node->next) { + + if (cur_node->type == XML_ELEMENT_NODE && cur_node->name + && strcmp((char*)cur_node->name, leafname)==0) { + do_members(cur_node, arg); + continue; + } + if (cur_node->type == XML_ELEMENT_NODE) { + traverse_node(cur_node, leafname, do_members, arg); + } + } +} + + +static void usage(char *name) +{ + printf("Usage:\n"); + printf(" %s -[am] [-s
] [-p] [-H
] [-o ] []\n", name); + printf("\n"); + printf(" defaults to %s\n", XML_FILE); + printf("\n"); + printf(" -a Print ASCII dump of man pages to stdout\n"); + printf(" -m Write man page files to \n"); + printf(" -P Print PARAMS section\n"); + printf(" -s Write man pages into section Use name. default \n"); + printf(" -H
Set header (default \"Kronosnet Programmer's Manual\"\n"); + printf(" -o Write all man pages to (default .)\n"); + printf(" -d Directory for XML files (default %s)\n", XML_DIR); + printf(" -h Print this usage text\n"); +} + +int main(int argc, char *argv[]) +{ + xmlNode *rootdoc; + xmlDocPtr doc; + int quiet=0; + int opt; + char xml_filename[PATH_MAX]; + + while ( (opt = getopt_long(argc, argv, "H:amPs:d:o:p:f:h?", NULL, NULL)) != EOF) + { + switch(opt) + { + case 'a': + print_ascii = 1; + print_man = 0; + break; + case 'm': + print_man = 1; + print_ascii = 0; + break; + case 'P': + print_params = 1; + break; + case 's': + man_section = optarg; + break; + case 'd': + xml_dir = optarg; + break; + case 'p': + package_name = optarg; + break; + case 'H': + header = optarg; + break; + case 'o': + output_dir = optarg; + break; + case '?': + case 'h': + usage(argv[0]); + return 0; + } + } + + if (argv[optind]) { + xml_file = argv[optind]; + } + if (!quiet) { + fprintf(stderr, "reading xml ... "); + } + + snprintf(xml_filename, sizeof(xml_filename), "%s/%s", xml_dir, xml_file); + doc = xmlParseFile(xml_filename); + if (doc == NULL) { + fprintf(stderr, "Error: unable to read xml file %s\n", xml_filename); + exit(1); + } + + rootdoc = xmlDocGetRootElement(doc); + if (!rootdoc) { + fprintf(stderr, "Can't find \"document root\"\n"); + exit(1); + } + if (!quiet) + fprintf(stderr, "done.\n"); + + qb_list_init(¶ms_list); + qb_list_init(&retval_list); + structures_map = qb_hashtable_create(10); + function_map = qb_hashtable_create(10); + used_structures_map = qb_hashtable_create(10); + + /* Collect functions */ + traverse_node(rootdoc, "memberdef", collect_functions, NULL); + + /* print pages */ + traverse_node(rootdoc, "memberdef", traverse_members, NULL); + + return 0; +} diff --git a/kronosnetd/knet-keygen.8 b/man/knet-keygen.8 similarity index 100% rename from kronosnetd/knet-keygen.8 rename to man/knet-keygen.8 diff --git a/kronosnetd/kronosnetd.8 b/man/kronosnetd.8 similarity index 100% rename from kronosnetd/kronosnetd.8 rename to man/kronosnetd.8 diff --git a/poc-code/iov-hash/Makefile.am b/poc-code/iov-hash/Makefile.am index 21c3a73f..493719f2 100644 --- a/poc-code/iov-hash/Makefile.am +++ b/poc-code/iov-hash/Makefile.am @@ -1,22 +1,22 @@ # # Copyright (C) 2016-2018 Red Hat, Inc. All rights reserved. # # Author: Fabio M. Di Nitto # # This software licensed under GPL-2.0+, LGPL-2.0+ # MAINTAINERCLEANFILES = Makefile.in include $(top_srcdir)/build-aux/check.mk # override global LIBS that pulls in lots of craft we don't need here LIBS = noinst_PROGRAMS = nss_hash nss_hash_SOURCES = main.c -nss_hash_CFLAGS = $(nss_CFLAGS) +nss_hash_CFLAGS = $(AM_CFLAGS) $(nss_CFLAGS) -nss_hash_LDFLAGS = $(nss_LIBS) +nss_hash_LDADD = $(nss_LIBS)