1.1.2
by Michael Biebl
Import upstream version 3.14.2 |
1 |
/* Definitions for tcps_sess class. This implements a session of the
|
2 |
* plain TCP server.
|
|
3 |
*
|
|
4 |
* Copyright 2008 Rainer Gerhards and Adiscon GmbH.
|
|
5 |
*
|
|
6 |
* This file is part of rsyslog.
|
|
7 |
*
|
|
8 |
* Rsyslog is free software: you can redistribute it and/or modify
|
|
9 |
* it under the terms of the GNU General Public License as published by
|
|
10 |
* the Free Software Foundation, either version 3 of the License, or
|
|
11 |
* (at your option) any later version.
|
|
12 |
*
|
|
13 |
* Rsyslog is distributed in the hope that it will be useful,
|
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
* GNU General Public License for more details.
|
|
17 |
*
|
|
18 |
* You should have received a copy of the GNU General Public License
|
|
19 |
* along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
|
|
20 |
*
|
|
21 |
* A copy of the GPL can be found in the file "COPYING" in this distribution.
|
|
22 |
*/
|
|
23 |
#ifndef INCLUDED_TCPS_SESS_H
|
|
24 |
#define INCLUDED_TCPS_SESS_H
|
|
25 |
||
26 |
#include "obj.h" |
|
27 |
||
28 |
/* a forward-definition, we are somewhat cyclic */
|
|
29 |
struct tcpsrv_s; |
|
30 |
||
31 |
/* framing modes for TCP */
|
|
32 |
typedef enum _TCPFRAMINGMODE { |
|
33 |
TCP_FRAMING_OCTET_STUFFING = 0, /* traditional LF-delimited */ |
|
34 |
TCP_FRAMING_OCTET_COUNTING = 1 /* -transport-tls like octet count */ |
|
35 |
} TCPFRAMINGMODE; |
|
36 |
||
37 |
/* the tcps_sess object */
|
|
38 |
typedef struct tcps_sess_s { |
|
39 |
BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ |
|
40 |
struct tcpsrv_s *pSrv; /* pointer back to my server (e.g. for callbacks) */ |
|
41 |
int sock; |
|
42 |
int iMsg; /* index of next char to store in msg */ |
|
43 |
int bAtStrtOfFram; /* are we at the very beginning of a new frame? */ |
|
44 |
enum { |
|
45 |
eAtStrtFram, |
|
46 |
eInOctetCnt, |
|
47 |
eInMsg
|
|
48 |
} inputState; /* our current state */ |
|
49 |
int iOctetsRemain; /* Number of Octets remaining in message */ |
|
50 |
TCPFRAMINGMODE eFraming; |
|
51 |
char msg[MAXLINE+1]; |
|
52 |
char *fromHost; |
|
53 |
void *pUsr; /* a user-pointer */ |
|
54 |
} tcps_sess_t; |
|
55 |
||
56 |
||
57 |
/* interfaces */
|
|
58 |
BEGINinterface(tcps_sess) /* name must also be changed in ENDinterface macro! */ |
|
59 |
INTERFACEObjDebugPrint(tcps_sess); |
|
60 |
rsRetVal (*Construct)(tcps_sess_t **ppThis); |
|
61 |
rsRetVal (*ConstructFinalize)(tcps_sess_t __attribute__((unused)) *pThis); |
|
62 |
rsRetVal (*Destruct)(tcps_sess_t **ppThis); |
|
63 |
rsRetVal (*PrepareClose)(tcps_sess_t *pThis); |
|
64 |
rsRetVal (*Close)(tcps_sess_t *pThis); |
|
65 |
rsRetVal (*DataRcvd)(tcps_sess_t *pThis, char *pData, size_t iLen); |
|
66 |
/* set methods */
|
|
67 |
rsRetVal (*SetTcpsrv)(tcps_sess_t *pThis, struct tcpsrv_s *pSrv); |
|
68 |
rsRetVal (*SetUsrP)(tcps_sess_t*, void*); |
|
69 |
rsRetVal (*SetHost)(tcps_sess_t *pThis, uchar*); |
|
70 |
rsRetVal (*SetSock)(tcps_sess_t *pThis, int); |
|
71 |
rsRetVal (*SetMsgIdx)(tcps_sess_t *pThis, int); |
|
72 |
ENDinterface(tcps_sess) |
|
73 |
#define tcps_sessCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */ |
|
74 |
||
75 |
||
76 |
/* prototypes */
|
|
77 |
PROTOTYPEObj(tcps_sess); |
|
78 |
||
79 |
||
80 |
#endif /* #ifndef INCLUDED_TCPS_SESS_H */ |