| 1 |
/* Definitions for the stream-based netstrmworking class. |
| 2 |
* |
| 3 |
* Copyright 2007-2026 Rainer Gerhards and Adiscon GmbH. |
| 4 |
* |
| 5 |
* This file is part of the rsyslog runtime library. |
| 6 |
* |
| 7 |
* The rsyslog runtime library is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Lesser General Public License as published by |
| 9 |
* the Free Software Foundation, either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* The rsyslog runtime library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
* |
| 20 |
* A copy of the GPL can be found in the file "COPYING" in this distribution. |
| 21 |
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution. |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifndef INCLUDED_NETSTRM_H |
| 25 |
#define INCLUDED_NETSTRM_H |
| 26 |
|
| 27 |
#include "tcpsrv.h" |
| 28 |
#include "netstrms.h" |
| 29 |
|
| 30 |
/* the netstrm object */ |
| 31 |
struct netstrm_s { |
| 32 |
BEGINobjInstance |
| 33 |
; /* Data to implement generic object - MUST be the first data element! */ |
| 34 |
nsd_t *pDrvrData; /**< the driver's data elements (at most other places, this is called pNsd) */ |
| 35 |
nsd_if_t Drvr; /**< our stream driver */ |
| 36 |
uchar *pszDrvrAuthMode; /**< auth mode of the stream driver to use */ |
| 37 |
void *pUsr; /**< pointer to user-provided data structure */ |
| 38 |
netstrms_t *pNS; /**< pointer to our netstream subsystem object */ |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
/* interface */ |
| 43 |
BEGINinterface(netstrm) /* name must also be changed in ENDinterface macro! */ |
| 44 |
rsRetVal (*Construct)(netstrm_t **ppThis); |
| 45 |
rsRetVal (*ConstructFinalize)(netstrm_t *pThis); |
| 46 |
rsRetVal (*Destruct)(netstrm_t **ppThis); |
| 47 |
rsRetVal (*AbortDestruct)(netstrm_t **ppThis); |
| 48 |
rsRetVal (*AcceptConnReq)(netstrm_t *pThis, netstrm_t **ppNew, char *connInfo); |
| 49 |
rsRetVal (*Rcv)(netstrm_t *pThis, uchar *pRcvBuf, ssize_t *pLenBuf, int *oserr, unsigned *nextIODirection); |
| 50 |
rsRetVal (*Send)(netstrm_t *pThis, uchar *pBuf, ssize_t *pLenBuf); |
| 51 |
rsRetVal (*Connect)(netstrm_t *pThis, int family, unsigned char *port, unsigned char *host, char *device); |
| 52 |
rsRetVal (*GetRemoteHName)(netstrm_t *pThis, uchar **pszName); |
| 53 |
rsRetVal (*GetRemoteIP)(netstrm_t *pThis, prop_t **ip); |
| 54 |
rsRetVal (*SetDrvrMode)(netstrm_t *pThis, int iMode); |
| 55 |
rsRetVal (*SetDrvrAuthMode)(netstrm_t *pThis, uchar *); |
| 56 |
rsRetVal (*SetDrvrPermitExpiredCerts)(netstrm_t *pThis, uchar *); |
| 57 |
rsRetVal (*SetDrvrPermPeers)(netstrm_t *pThis, permittedPeers_t *); |
| 58 |
rsRetVal (*CheckConnection)(netstrm_t *pThis); /* This is a trick mostly for plain tcp syslog */ |
| 59 |
/* the GetSock() below is a hack to make imgssapi work. In the long term, |
| 60 |
* we should migrate imgssapi to a stream driver, which will relieve us of |
| 61 |
* this problem. Please note that nobody else should use GetSock(). Using it |
| 62 |
* will also tie the caller to nsd_ptcp, because other drivers may not support |
| 63 |
* it at all. Once the imgssapi problem is solved, GetSock should be removed from |
| 64 |
* this interface. -- rgerhards, 2008-05-05 |
| 65 |
*/ |
| 66 |
rsRetVal (*GetSock)(netstrm_t *pThis, int *pSock); |
| 67 |
rsRetVal (*GetRemAddr)(netstrm_t *pThis, struct sockaddr_storage **ppAddr); |
| 68 |
/* getRemAddr() is an aid needed by the legacy ACL system. It exposes the remote |
| 69 |
* peer's socket addr structure, so that the legacy matching functions can work on |
| 70 |
* it. Note that this ties netstream drivers to things that can be implemented over |
| 71 |
* sockets - not really desirable, but not the end of the world... |
| 72 |
*/ |
| 73 |
/* v4 */ |
| 74 |
rsRetVal (*EnableKeepAlive)(netstrm_t *pThis); |
| 75 |
/* v7 */ |
| 76 |
rsRetVal (*SetKeepAliveProbes)(netstrm_t *pThis, int keepAliveProbes); |
| 77 |
rsRetVal (*SetKeepAliveTime)(netstrm_t *pThis, int keepAliveTime); |
| 78 |
rsRetVal (*SetKeepAliveIntvl)(netstrm_t *pThis, int keepAliveIntvl); |
| 79 |
rsRetVal (*SetGnutlsPriorityString)(netstrm_t *pThis, uchar *priorityString); |
| 80 |
/* v11 -- Parameter pszLstnFileName added to LstnInit*/ |
| 81 |
rsRetVal(ATTR_NONNULL(1, 3, 5) * LstnInit)(netstrms_t * pNS, void *pUsr, rsRetVal (*)(void *, netstrm_t *), |
| 82 |
const int iSessMax, const tcpLstnParams_t *const cnf_params); |
| 83 |
/* v12 -- two new binary flags added to gtls driver enabling stricter operation */ |
| 84 |
rsRetVal (*SetDrvrCheckExtendedKeyUsage)(netstrm_t *pThis, int ChkExtendedKeyUsage); |
| 85 |
rsRetVal (*SetDrvrPrioritizeSAN)(netstrm_t *pThis, int prioritizeSan); |
| 86 |
|
| 87 |
/* v14 -- Tls functions */ |
| 88 |
rsRetVal (*SetDrvrTlsVerifyDepth)(netstrm_t *pThis, int verifyDepth); |
| 89 |
rsRetVal (*SetDrvrTlsRevocationCheck)(netstrm_t *pThis, int enabled); |
| 90 |
|
| 91 |
/* v15 -- Tls cert functions */ |
| 92 |
rsRetVal (*SetDrvrTlsCAFile)(netstrm_t *pThis, const uchar *file); |
| 93 |
rsRetVal (*SetDrvrTlsCRLFile)(netstrm_t *pThis, const uchar *file); |
| 94 |
rsRetVal (*SetDrvrTlsKeyFile)(netstrm_t *pThis, const uchar *file); |
| 95 |
rsRetVal (*SetDrvrTlsCertFile)(netstrm_t *pThis, const uchar *file); |
| 96 |
/* v18 -- allow remote server's TLS SNI to be set manually */ |
| 97 |
rsRetVal (*SetDrvrRemoteSNI)(netstrm_t *pThis, uchar *pszRemoteSNI); |
| 98 |
ENDinterface(netstrm) |
| 99 |
#define netstrmCURR_IF_VERSION 18 /* increment whenever you change the interface structure! */ |
| 100 |
/* interface version 3 added GetRemAddr() |
| 101 |
* interface version 4 added EnableKeepAlive() -- rgerhards, 2009-06-02 |
| 102 |
* interface version 5 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06 |
| 103 |
* interface version 6 changed signature of GetRemoteIP() -- rgerhards, 2013-01-21 |
| 104 |
* interface version 7 added KeepAlive parameter set functions |
| 105 |
* interface version 8 changed signature of Connect() -- dsa, 2016-11-14 |
| 106 |
* interface version 9 added SetGnutlsPriorityString -- PascalWithopf, 2017-08-08 |
| 107 |
* interface version 10 added oserr parameter to Rcv() -- rgerhards, 2017-09-04 |
| 108 |
* interface version 16 CRL file -- Oracle, 2022-01-16 |
| 109 |
* interface version 17 added nextIODirection parameter to Rcv() -- rgehards, 2025-04-17 |
| 110 |
* interface version 18 added SetDrvrRemoteSNI -- jfcantu, 2020-01-15 |
| 111 |
* */ |
| 112 |
|
| 113 |
/* prototypes */ |
| 114 |
PROTOTYPEObjFull(netstrm); |
| 115 |
|
| 116 |
/* the name of our library binary */ |
| 117 |
#define LM_NETSTRM_FILENAME LM_NETSTRMS_FILENAME |
| 118 |
|
| 119 |
#endif /* #ifndef INCLUDED_NETSTRM_H */ |