diff -Nru librelp-1.2.0/ChangeLog librelp-1.2.2/ChangeLog --- librelp-1.2.0/ChangeLog 2013-07-14 14:53:38.000000000 +0000 +++ librelp-1.2.2/ChangeLog 2014-01-07 12:07:36.000000000 +0000 @@ -1,4 +1,12 @@ ---------------------------------------------------------------------- +Version 1.2.2 - 2014-01-07 +- add capability to enable tcp KEEPALIVE +- introduced new API relpSrvSetKeepAlive() to support KEEPALIVE +---------------------------------------------------------------------- +Version 1.2.1 - 2013-09-26 +- errors binding listener port are now reported via error message + callback +---------------------------------------------------------------------- Version 1.2.0 - 2013-07-15 - support for epoll() added platforms that do not support it fall back to select() diff -Nru librelp-1.2.0/configure librelp-1.2.2/configure --- librelp-1.2.0/configure 2013-07-08 16:25:51.000000000 +0000 +++ librelp-1.2.2/configure 2013-12-10 14:36:55.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for librelp 1.2.0. +# Generated by GNU Autoconf 2.68 for librelp 1.2.2. # # Report bugs to . # @@ -570,8 +570,8 @@ # Identity of this package. PACKAGE_NAME='librelp' PACKAGE_TARNAME='librelp' -PACKAGE_VERSION='1.2.0' -PACKAGE_STRING='librelp 1.2.0' +PACKAGE_VERSION='1.2.2' +PACKAGE_STRING='librelp 1.2.2' PACKAGE_BUGREPORT='rgerhards@adiscon.com' PACKAGE_URL='' @@ -1304,7 +1304,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures librelp 1.2.0 to adapt to many kinds of systems. +\`configure' configures librelp 1.2.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1374,7 +1374,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of librelp 1.2.0:";; + short | recursive ) echo "Configuration of librelp 1.2.2:";; esac cat <<\_ACEOF @@ -1486,7 +1486,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -librelp configure 1.2.0 +librelp configure 1.2.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2012,7 +2012,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by librelp $as_me 1.2.0, which was +It was created by librelp $as_me 1.2.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2827,7 +2827,7 @@ # Define the identity of the package. PACKAGE='librelp' - VERSION='1.2.0' + VERSION='1.2.2' cat >>confdefs.h <<_ACEOF @@ -2889,7 +2889,7 @@ # Define the identity of the package. PACKAGE='librelp' - VERSION='1.2.0' + VERSION='1.2.2' cat >>confdefs.h <<_ACEOF @@ -13171,7 +13171,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by librelp $as_me 1.2.0, which was +This file was extended by librelp $as_me 1.2.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13237,7 +13237,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -librelp config.status 1.2.0 +librelp config.status 1.2.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -Nru librelp-1.2.0/configure.ac librelp-1.2.2/configure.ac --- librelp-1.2.0/configure.ac 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/configure.ac 2013-12-10 14:36:48.000000000 +0000 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([librelp], [1.2.0], [rgerhards@adiscon.com]) +AC_INIT([librelp], [1.2.2], [rgerhards@adiscon.com]) AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff -Nru librelp-1.2.0/debian/changelog librelp-1.2.2/debian/changelog --- librelp-1.2.0/debian/changelog 2013-12-18 15:23:59.000000000 +0000 +++ librelp-1.2.2/debian/changelog 2014-02-22 23:49:54.000000000 +0000 @@ -1,8 +1,23 @@ -librelp (1.2.0-1ubuntu1) trusty; urgency=medium +librelp (1.2.2-2ubuntu1) trusty; urgency=medium - * Build using dh-autoreconf. + * debian/{rules,control}: switch from autotools-dev to autoreconf. - -- Matthias Klose Wed, 18 Dec 2013 16:23:40 +0100 + -- Adam Conrad Sat, 22 Feb 2014 16:49:30 -0700 + +librelp (1.2.2-2) unstable; urgency=medium + + * Run autotools_dev dh addon for up-to-date config.{guess,sub}. + * Convert debian/copyright using the machine-readable copyright format 1.0. + + -- Michael Biebl Sat, 15 Feb 2014 17:16:45 +0100 + +librelp (1.2.2-1) unstable; urgency=medium + + * New upstream release. + * Update symbols file. + * Bump Standards-Version to 3.9.5. No further changes. + + -- Michael Biebl Thu, 13 Feb 2014 06:02:25 +0100 librelp (1.2.0-1) unstable; urgency=low diff -Nru librelp-1.2.0/debian/control librelp-1.2.2/debian/control --- librelp-1.2.0/debian/control 2013-12-18 15:23:38.000000000 +0000 +++ librelp-1.2.2/debian/control 2014-02-22 23:50:05.000000000 +0000 @@ -1,12 +1,13 @@ Source: librelp Section: libs Priority: optional -Maintainer: Michael Biebl +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Michael Biebl Build-Depends: debhelper (>= 9), - autotools-dev, dh-autoreconf, + dh-autoreconf, libgnutls-dev (>= 1.4.0), pkg-config -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Vcs-Git: git://git.debian.org/git/collab-maint/librelp.git Vcs-Browser: http://git.debian.org/?p=collab-maint/librelp.git;a=summary Homepage: http://www.librelp.com/ diff -Nru librelp-1.2.0/debian/copyright librelp-1.2.2/debian/copyright --- librelp-1.2.0/debian/copyright 2013-07-26 05:41:43.000000000 +0000 +++ librelp-1.2.2/debian/copyright 2014-02-15 16:16:58.000000000 +0000 @@ -1,47 +1,34 @@ -This package was debianized by Michael Biebl on -Tue, 01 Apr 2008 21:48:30 +0200. - -It was downloaded from http://www.librelp.com/. - -Upstream Author: - - Rainer Gerhards - -Copyright: - - Copyright 2008 by Rainer Gerhards and Adiscon GmbH - -License: - - This package 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 package 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 package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. - - -The documentation in the doc/ subdirectory is licensed under the GFDL. - - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.3 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - -On Debian systems, the complete text of the GNU Free Documentation -License can be found in `/usr/share/common-licenses/GFDL'. - - -The Debian packaging is (C) 2008, Michael Biebl and -is licensed under the GPL, see above. - +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: librelp +Source: http://www.librelp.com/ + +Files: * +Copyright: 2008-2013 Rainer Gerhards and Adiscon GmbH +License: GPL-3.0+ + +Files: doc/* +Copyright: 2008 Rainer Gerhards and Adiscon GmbH +License: GFDL-NIV-1.3 + +License: GPL-3.0+ + 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 package 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 . + . + On Debian systems, the complete text of the GNU General Public + License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +License: GFDL-NIV-1.3 + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. diff -Nru librelp-1.2.0/debian/librelp0.symbols librelp-1.2.2/debian/librelp0.symbols --- librelp-1.2.0/debian/librelp0.symbols 2013-07-26 05:41:43.000000000 +0000 +++ librelp-1.2.2/debian/librelp0.symbols 2014-02-15 16:16:58.000000000 +0000 @@ -113,6 +113,7 @@ relpSrvSetEnableCmd@Base 0.1.1 relpSrvSetFamily@Base 1.0.2 relpSrvSetGnuTLSPriString@Base 1.1.3 + relpSrvSetKeepAlive@Base 1.2.2 relpSrvSetLstnPort@Base 0.1.1 relpSrvSetOwnCert@Base 1.1.3 relpSrvSetPrivKey@Base 1.1.3 diff -Nru librelp-1.2.0/src/librelp.h librelp-1.2.2/src/librelp.h --- librelp-1.2.0/src/librelp.h 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/src/librelp.h 2013-12-10 14:23:52.000000000 +0000 @@ -151,6 +151,7 @@ #define RELP_RET_ERR_INVAL RELPERR_BASE + 41 /**< some parameter is invalid (like EINVAL) */ #define RELP_RET_ERR_EPOLL_CTL RELPERR_BASE + 42 /**< epoll_ctl() failed */ #define RELP_RET_ERR_INTERNAL RELPERR_BASE + 43 /**< internal error in librelp (bug) */ +#define RELP_RET_WRN_NO_KEEPALIVE RELPERR_BASE + 44/**< KEEPALIVE cannot be enabled */ /* some macros to work with librelp error codes */ #define CHKRet(code) if((iRet = code) != RELP_RET_OK) goto finalize_it @@ -191,6 +192,7 @@ void relpSrvEnableTLS(relpSrv_t *pThis); void relpSrvEnableTLSZip(relpSrv_t *pThis); void relpSrvSetDHBits(relpSrv_t *pThis, int bits); +void relpSrvSetKeepAlive(relpSrv_t *pThis, const int bEnabled, const int iKeepAliveIntvl, const int iKeepAliveProbes, const int iKeepAliveTime); relpRetVal relpSrvSetGnuTLSPriString(relpSrv_t *pThis, char *pristr); relpRetVal relpSrvSetCACert(relpSrv_t *pThis, char *cert); relpRetVal relpSrvSetOwnCert(relpSrv_t *pThis, char *cert); diff -Nru librelp-1.2.0/src/relpsess.c librelp-1.2.2/src/relpsess.c --- librelp-1.2.0/src/relpsess.c 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/src/relpsess.c 2013-09-13 10:56:24.000000000 +0000 @@ -223,8 +223,6 @@ lenBuf = RELP_RCV_BUF_SIZE; CHKRet(relpTcpRcv(pThis->pTcp, rcvBuf, &lenBuf)); - rcvBuf[lenBuf] = '\0'; - pThis->pEngine->dbgprint("relp session read %d octets, buf '%s'\n", (int) lenBuf, rcvBuf); if(lenBuf == 0) { pThis->pEngine->dbgprint("server closed relp session %p, session broken\n", pThis); /* even though we had a "normal" close, it is unexpected at this @@ -240,6 +238,10 @@ ABORT_FINALIZE(RELP_RET_SESSION_BROKEN); } } else { + /* Terminate buffer and output received data to debug*/ + rcvBuf[lenBuf] = '\0'; + pThis->pEngine->dbgprint("relp session read %d octets, buf '%s'\n", (int) lenBuf, rcvBuf); + /* we have regular data, which we now can process */ for(i = 0 ; i < lenBuf ; ++i) { CHKRet(relpFrameProcessOctetRcvd(&pThis->pCurrRcvFrame, rcvBuf[i], pThis)); diff -Nru librelp-1.2.0/src/relpsrv.c librelp-1.2.2/src/relpsrv.c --- librelp-1.2.0/src/relpsrv.c 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/src/relpsrv.c 2013-12-10 14:32:45.000000000 +0000 @@ -295,6 +295,18 @@ pThis->bEnableTLSZip = 1; } +void +relpSrvSetKeepAlive(relpSrv_t *pThis, + const int bEnabled, + const int iKeepAliveIntvl, + const int iKeepAliveProbes, + const int iKeepAliveTime) +{ + pThis->bKeepAlive = bEnabled; + pThis->iKeepAliveIntvl = iKeepAliveIntvl; + pThis->iKeepAliveProbes = iKeepAliveProbes; + pThis->iKeepAliveTime = iKeepAliveTime; +} /* start a relp server - the server object must have all properties set * rgerhards, 2008-03-17 diff -Nru librelp-1.2.0/src/relpsrv.h librelp-1.2.2/src/relpsrv.h --- librelp-1.2.0/src/relpsrv.h 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/src/relpsrv.h 2013-12-10 11:10:23.000000000 +0000 @@ -1,6 +1,6 @@ /* The RELPSRV object. * - * Copyright 2008 by Rainer Gerhards and Adiscon GmbH. + * Copyright 2008-2013 by Rainer Gerhards and Adiscon GmbH. * * This file is part of librelp. * @@ -47,7 +47,11 @@ relpTcp_t *pTcp; /**< our tcp support object */ size_t maxDataSize; /**< maximum size of a DATA element */ void *pUsr; /**< user pointer (passed back in to callback) */ - int bEnableTLS; + int bKeepAlive; /* support keep-alive packets */ + int iKeepAliveIntvl; + int iKeepAliveProbes; + int iKeepAliveTime; + int bEnableTLS; /* support for TLS */ int bEnableTLSZip; int dhBits; /**< number of bits for Diffie-Hellman key */ char *pristring; /**< priority string for GnuTLS */ diff -Nru librelp-1.2.0/src/tcp.c librelp-1.2.2/src/tcp.c --- librelp-1.2.0/src/tcp.c 2013-07-08 10:03:48.000000000 +0000 +++ librelp-1.2.2/src/tcp.c 2013-12-10 11:45:17.000000000 +0000 @@ -170,7 +170,9 @@ /* helper to call onErr if set */ static void -callOnErr(relpTcp_t *pThis, char *emsg, relpRetVal ecode) +callOnErr(const relpTcp_t *__restrict__ const pThis, + char *__restrict__ const emsg, + const relpRetVal ecode) { char objinfo[1024]; pThis->pEngine->dbgprint("librelp: generic error: ecode %d, " @@ -586,6 +588,79 @@ LEAVE_RELPFUNC; } +/* Enable KEEPALIVE handling on the socket. */ +static void +EnableKeepAlive(const relpTcp_t *__restrict__ const pThis, + const relpSrv_t *__restrict__ const pSrv, + const int sock) +{ + int ret; + int optval; + socklen_t optlen; + + optval = 1; + optlen = sizeof(optval); + ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen); + if(ret < 0) { + pThis->pEngine->dbgprint("librelp: EnableKeepAlive socket call " + "returns error %d\n", ret); + goto done; + } + +# if defined(TCP_KEEPCNT) + if(pSrv->iKeepAliveProbes > 0) { + optval = pSrv->iKeepAliveProbes; + optlen = sizeof(optval); + ret = setsockopt(sock, SOL_TCP, TCP_KEEPCNT, &optval, optlen); + } else { + ret = 0; + } +# else + ret = -1; +# endif + if(ret < 0) { + callOnErr(pThis, "librelp cannot set keepalive probes - ignored", + RELP_RET_WRN_NO_KEEPALIVE); + } + +# if defined(TCP_KEEPCNT) + if(pSrv->iKeepAliveTime > 0) { + optval = pSrv->iKeepAliveTime; + optlen = sizeof(optval); + ret = setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &optval, optlen); + } else { + ret = 0; + } +# else + ret = -1; +# endif + if(ret < 0) { + callOnErr(pThis, "librelp cannot set keepalive time - ignored", + RELP_RET_WRN_NO_KEEPALIVE); + } + +# if defined(TCP_KEEPCNT) + if(pSrv->iKeepAliveIntvl > 0) { + optval = pSrv->iKeepAliveIntvl; + optlen = sizeof(optval); + ret = setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &optval, optlen); + } else { + ret = 0; + } +# else + ret = -1; +# endif + if(ret < 0) { + callOnErr(pThis, "librelp cannot set keepalive intvl - ignored", + RELP_RET_WRN_NO_KEEPALIVE); + } + + pThis->pEngine->dbgprint("KEEPALIVE enabled for socket %d\n", sock); + +done: + return; +} + /* accept an incoming connection request, sock provides the socket on which we can * accept the new session. * rgerhards, 2008-03-17 @@ -608,6 +683,9 @@ ABORT_FINALIZE(RELP_RET_ACCEPT_ERR); } + if(pSrv->bKeepAlive) + EnableKeepAlive(pThis, pSrv, iNewSock); + /* construct our object so that we can use it... */ CHKRet(relpTcpConstruct(&pThis, pEngine, RELP_SRV_CONN, pSrv)); @@ -1293,7 +1371,11 @@ && (errno != EADDRINUSE) #endif ) { - pThis->pEngine->dbgprint("error %d while binding relp tcp socket", errno); + char msgbuf[4096]; + snprintf(msgbuf, sizeof(msgbuf), "error while binding relp tcp socket " + "on port '%s'", pLstnPort); + msgbuf[sizeof(msgbuf)-1] = '\0'; + callOnErr(pThis, msgbuf, errno); close(*s); *s = -1; continue;