Debian Codegraph @

runtime/nsd.h

raw
1 /* The interface definition for "NetStream Drivers" (nsd).
2 *
3 * This is just an abstract driver interface, which needs to be
4 * implemented by concrete classes. As such, no nsd data type itself
5 * is defined.
6 *
7 * Copyright 2008-2025 Adiscon GmbH.
8 *
9 * This file is part of the rsyslog runtime library.
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 * -or-
17 * see COPYING.ASL20 in the source distribution
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 */
25 #ifndef INCLUDED_NSD_H
26 #define INCLUDED_NSD_H
27
28 #include <sys/socket.h>
29
30 enum nsdsel_waitOp_e { NSDSEL_RD = 1, NSDSEL_WR = 2, NSDSEL_RDWR = 3 }; /**< the operation we wait for */
31
32 /* nsd_t is actually obj_t (which is somewhat better than void* but in essence
33 * much the same).
34 */
35
36 /* interface */
37 BEGINinterface(nsd) /* name must also be changed in ENDinterface macro! */
38 rsRetVal (*Construct)(nsd_t **ppThis);
39 rsRetVal (*Destruct)(nsd_t **ppThis);
40 rsRetVal (*Abort)(nsd_t *pThis);
41 rsRetVal (*Rcv)(nsd_t *pThis, uchar *pRcvBuf, ssize_t *pLenBuf, int *oserr, unsigned *nextIODirection);
42 rsRetVal (*Send)(nsd_t *pThis, uchar *pBuf, ssize_t *pLenBuf);
43 rsRetVal (*Connect)(nsd_t *pThis, int family, unsigned char *port, unsigned char *host, char *device);
44 rsRetVal (*AcceptConnReq)(nsd_t *pThis, nsd_t **ppThis, char *connInfo);
45 rsRetVal (*GetRemoteHName)(nsd_t *pThis, uchar **pszName);
46 rsRetVal (*GetRemoteIP)(nsd_t *pThis, prop_t **ip);
47 rsRetVal (*SetMode)(nsd_t *pThis, int mode); /* sets a driver specific mode - see driver doc for details */
48 rsRetVal (*SetAuthMode)(nsd_t *pThis, uchar *); /* sets a driver specific mode - see driver doc for details */
49 rsRetVal (*SetPermitExpiredCerts)(nsd_t *pThis, uchar *); /* sets a driver specific permitexpiredcerts mode */
50 rsRetVal (*SetPermPeers)(nsd_t *pThis, permittedPeers_t *); /* sets driver permitted peers for auth needs */
51 rsRetVal (*CheckConnection)(nsd_t *pThis); /* This is a trick mostly for plain tcp syslog */
52 rsRetVal (*GetSock)(nsd_t *pThis, int *pSock);
53 rsRetVal (*SetSock)(nsd_t *pThis, int sock);
54 /* GetSock() and SetSock() return an error if the driver does not use plain
55 * OS sockets. This interface is primarily meant as an internal aid for
56 * those drivers that utilize the nsd_ptcp to do some of their work.
57 */
58 rsRetVal (*GetRemAddr)(nsd_t *pThis, struct sockaddr_storage **ppAddr);
59 /* getRemAddr() is an aid needed by the legacy ACL system. It exposes the remote
60 * peer's socket addr structure, so that the legacy matching functions can work on
61 * it. Note that this ties netstream drivers to things that can be implemented over
62 * sockets - not really desirable, but not the end of the world...
63 */
64 /* v5 */
65 rsRetVal (*EnableKeepAlive)(nsd_t *pThis);
66 /* v8 */
67 rsRetVal (*SetKeepAliveIntvl)(nsd_t *pThis, int keepAliveIntvl);
68 rsRetVal (*SetKeepAliveProbes)(nsd_t *pThis, int keepAliveProbes);
69 rsRetVal (*SetKeepAliveTime)(nsd_t *pThis, int keepAliveTime);
70 rsRetVal (*SetGnutlsPriorityString)(nsd_t *pThis, uchar *gnutlsPriorityString);
71 /* v12 -- parameter pszLstnPortFileName added to LstnInit()*/
72 rsRetVal(ATTR_NONNULL(1, 3, 5) * LstnInit)(netstrms_t * pNS, void *pUsr, rsRetVal (*)(void *, netstrm_t *),
73 const int iSessMax, const tcpLstnParams_t *const cnf_params);
74 /* v13 -- two new binary flags added to gtls driver enabling stricter operation */
75 rsRetVal (*SetCheckExtendedKeyUsage)(nsd_t *pThis, int ChkExtendedKeyUsage);
76 rsRetVal (*SetPrioritizeSAN)(nsd_t *pThis, int prioritizeSan);
77
78 /* v14 -- Tls functions */
79 rsRetVal (*SetTlsVerifyDepth)(nsd_t *pThis, int verifyDepth);
80
81 /* v15 -- Tls functions */
82 rsRetVal (*SetTlsCAFile)(nsd_t *pThis, const uchar *);
83 rsRetVal (*SetTlsKeyFile)(nsd_t *pThis, const uchar *);
84 rsRetVal (*SetTlsCertFile)(nsd_t *pThis, const uchar *);
85
86 /* v16 - Tls CRL */
87 rsRetVal (*SetTlsCRLFile)(nsd_t *pThis, const uchar *);
88
89 /* v17 - Remote Port */
90 rsRetVal (*GetRemotePort)(nsd_t *pThis, int *);
91 rsRetVal (*FmtRemotePortStr)(const int port, uchar *const buf, const size_t len);
92
93 /* v18 -- allow remote server's TLS SNI to be set manually */
94 rsRetVal (*SetRemoteSNI)(nsd_t *pThis, uchar *pszRemoteSNI);
95
96 /* v19 -- TLS revocation checking (OCSP/CRL) */
97 rsRetVal (*SetTlsRevocationCheck)(nsd_t *pThis, int enabled);
98
99 ENDinterface(nsd)
100 #define nsdCURR_IF_VERSION 19 /* increment whenever you change the interface structure! */
101 /* interface version 4 added GetRemAddr()
102 * interface version 5 added EnableKeepAlive() -- rgerhards, 2009-06-02
103 * interface version 6 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06
104 * interface version 7 changed signature ofGetRempoteIP() -- rgerhards, 2013-01-21
105 * interface version 8 added keep alive parameter set functions
106 * interface version 9 changed signature of Connect() -- dsa, 2016-11-14
107 * interface version 10 added SetGnutlsPriorityString() -- PascalWithopf, 2017-08-08
108 * interface version 11 added oserr to Rcv() signature -- rgerhards, 2017-09-04
109 * interface version 18 added SetRemoteSNI -- jfcantu, 2020-01-15
110 */
111
112 #endif /* #ifndef INCLUDED_NSD_H */