Debian Codegraph @

runtime/tcps_sess.h

raw
1 /* Definitions for tcps_sess class. This implements a session of the
2 * plain TCP server.
3 *
4 * Copyright 2008-2026 Adiscon GmbH.
5 *
6 * This file is part of rsyslog.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 * -or-
14 * see COPYING.ASL20 in the source distribution
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22 #ifndef INCLUDED_TCPS_SESS_H
23 #define INCLUDED_TCPS_SESS_H
24
25 #include "rsyslog.h"
26 #include "obj.h"
27 #include "prop.h"
28
29 /* a forward-definition, we are somewhat cyclic */
30 struct tcpsrv_s;
31
32 /* the tcps_sess object */
33 struct tcps_sess_s {
34 BEGINobjInstance
35 ; /* Data to implement generic object - MUST be the first data element! */
36 tcpsrv_t *pSrv; /* pointer back to my server (e.g. for callbacks) */
37 tcpLstnPortList_t *pLstnInfo; /* pointer back to listener info */
38 netstrm_t *pStrm;
39 int iMsg; /* index of next char to store in msg */
40 sbool bSuppOctetFram; /**< copy from listener, to speed up access */
41 sbool bSPFramingFix;
42 enum {
43 eAtStrtFram,
44 eInOctetCnt,
45 eInMsg,
46 eInMsgTruncating,
47 eInMsgCheckMultiLine
48 } inputState; /* our current state */
49 int iOctetsRemain; /* Number of Octets remaining in message */
50 TCPFRAMINGMODE eFraming;
51 uchar *pMsg; /* message (fragment) received */
52 prop_t *fromHost; /* host name we received messages from */
53 prop_t *fromHostIP;
54 prop_t *fromHostPort;
55 int iCurrLine; /* 2nd char of current line in regex framing mode */
56 uchar *pMsg_save; /* message (fragment) save area in regex framing mode */
57 actWrkrIParams_t perSourceKeyParam; /**< reusable template buffer */
58 void *pUsr; /* a user-pointer */
59 rsRetVal (*DoSubmitMessage)(tcps_sess_t *, uchar *, int); /* submit message callback */
60 int iMaxLine; /* fast lookup buffer for config property */
61 pthread_mutex_t mut;
62 unsigned tlsProbeBytes; /**< number of bytes collected for TLS client detection */
63 uchar tlsProbeBuf[5]; /**< first bytes received for TLS client detection */
64 sbool tlsProbeDone; /**< indicates TLS client detection has been completed */
65 sbool tlsMismatchWarned; /**< avoids logging the same TLS mismatch twice */
66 };
67
68
69 /* interfaces */
70 BEGINinterface(tcps_sess) /* name must also be changed in ENDinterface macro! */
71 INTERFACEObjDebugPrint(tcps_sess);
72 rsRetVal (*Construct)(tcps_sess_t **ppThis);
73 rsRetVal (*ConstructFinalize)(tcps_sess_t __attribute__((unused)) * pThis);
74 rsRetVal (*Destruct)(tcps_sess_t **ppThis);
75 rsRetVal (*PrepareClose)(tcps_sess_t *pThis);
76 rsRetVal (*Close)(tcps_sess_t *pThis);
77 rsRetVal (*DataRcvd)(tcps_sess_t *pThis, char *pData, size_t iLen);
78 /* set methods */
79 rsRetVal (*SetTcpsrv)(tcps_sess_t *pThis, struct tcpsrv_s *pSrv);
80 rsRetVal (*SetLstnInfo)(tcps_sess_t *pThis, tcpLstnPortList_t *pLstnInfo);
81 rsRetVal (*SetUsrP)(tcps_sess_t *, void *);
82 rsRetVal (*SetHost)(tcps_sess_t *pThis, uchar *);
83 rsRetVal (*SetHostIP)(tcps_sess_t *pThis, prop_t *);
84 rsRetVal (*SetHostPort)(tcps_sess_t *pThis, prop_t *);
85 rsRetVal (*SetStrm)(tcps_sess_t *pThis, netstrm_t *);
86 rsRetVal (*SetMsgIdx)(tcps_sess_t *pThis, int);
87 rsRetVal (*SetOnMsgReceive)(tcps_sess_t *pThis, rsRetVal (*OnMsgReceive)(tcps_sess_t *, uchar *, int));
88 ENDinterface(tcps_sess)
89 #define tcps_sessCURR_IF_VERSION 4 /* increment whenever you change the interface structure! */
90 /* interface changes
91 * to version v2, rgerhards, 2009-05-22
92 * - Data structures changed
93 * - SetLstnInfo entry point added
94 * version 3, rgerhards, 2013-01-21:
95 * - signature of SetHostIP() changed
96 * version 4, 2025-01-??:
97 * - SetHostPort() entry point added
98 */
99
100
101 /* prototypes */
102 PROTOTYPEObjFull(tcps_sess);
103 PROTOTYPEObjDebugPrint(tcps_sess);
104
105
106 #endif /* #ifndef INCLUDED_TCPS_SESS_H */