1
/* Definitions for tcpsrv class.
3
* Copyright 2008 Rainer Gerhards and Adiscon GmbH.
5
* This file is part of rsyslog.
7
* Rsyslog is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU 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.
12
* Rsyslog 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 General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
20
* A copy of the GPL can be found in the file "COPYING" in this distribution.
22
#ifndef INCLUDED_TCPSRV_H
23
#define INCLUDED_TCPSRV_H
26
#include "tcps_sess.h"
28
/* the tcpsrv object */
29
typedef struct tcpsrv_s {
30
BEGINobjInstance; /**< Data to implement generic object - MUST be the first data element! */
31
int *pSocksLstn; /**< listen socket array for server [0] holds count */
32
int iSessMax; /**< max number of sessions supported */
33
char *TCPLstnPort; /**< the port the listener shall listen on */
34
tcps_sess_t **pSessions;/**< array of all of our sessions */
35
void *pUsr; /**< a user-settable pointer (provides extensibility for "derived classes")*/
37
int (*pIsPermittedHost)(struct sockaddr *addr, char *fromHostFQDN, void*pUsrSrv, void*pUsrSess);
38
int (*pRcvData)(tcps_sess_t*, char*, size_t);
39
int* (*OpenLstnSocks)(struct tcpsrv_s*);
40
rsRetVal (*pOnListenDeinit)(void*);
41
rsRetVal (*OnDestruct)(void*);
42
rsRetVal (*pOnRegularClose)(tcps_sess_t *pSess);
43
rsRetVal (*pOnErrClose)(tcps_sess_t *pSess);
44
/* session specific callbacks */
45
rsRetVal (*pOnSessAccept)(struct tcpsrv_s *, tcps_sess_t*);
46
rsRetVal (*OnSessConstructFinalize)(void*);
47
rsRetVal (*pOnSessDestruct)(void*);
52
BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */
53
INTERFACEObjDebugPrint(tcpsrv);
54
rsRetVal (*Construct)(tcpsrv_t **ppThis);
55
rsRetVal (*ConstructFinalize)(tcpsrv_t __attribute__((unused)) *pThis);
56
rsRetVal (*Destruct)(tcpsrv_t **ppThis);
57
void (*configureTCPListen)(tcpsrv_t*, char *cOptarg);
58
int (*SessAccept)(tcpsrv_t *pThis, tcps_sess_t**ppSess, int fd);
59
int* (*create_tcp_socket)(tcpsrv_t *pThis);
60
rsRetVal (*Run)(tcpsrv_t *pThis);
62
rsRetVal (*SetUsrP)(tcpsrv_t*, void*);
63
rsRetVal (*SetCBIsPermittedHost)(tcpsrv_t*, int (*) (struct sockaddr *addr, char*, void*, void*));
64
rsRetVal (*SetCBOpenLstnSocks)(tcpsrv_t *, int* (*)(tcpsrv_t*));
65
rsRetVal (*SetCBRcvData)(tcpsrv_t *, int (*)(tcps_sess_t*, char*, size_t));
66
rsRetVal (*SetCBOnListenDeinit)(tcpsrv_t*, rsRetVal (*)(void*));
67
rsRetVal (*SetCBOnDestruct)(tcpsrv_t*, rsRetVal (*) (void*));
68
rsRetVal (*SetCBOnRegularClose)(tcpsrv_t*, rsRetVal (*) (tcps_sess_t*));
69
rsRetVal (*SetCBOnErrClose)(tcpsrv_t*, rsRetVal (*) (tcps_sess_t*));
70
/* session specifics */
71
rsRetVal (*SetCBOnSessAccept)(tcpsrv_t*, rsRetVal (*) (tcpsrv_t*, tcps_sess_t*));
72
rsRetVal (*SetCBOnSessDestruct)(tcpsrv_t*, rsRetVal (*) (void*));
73
rsRetVal (*SetCBOnSessConstructFinalize)(tcpsrv_t*, rsRetVal (*) (void*));
75
#define tcpsrvCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */
81
/* the name of our library binary */
82
#define LM_TCPSRV_FILENAME "lmtcpsrv"
84
#endif /* #ifndef INCLUDED_TCPSRV_H */