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 *TCPLstnNode; /**< the node the listener shall listen on */
34 char *TCPLstnPort; /**< the port the listener shall listen on */
35 tcps_sess_t **pSessions;/**< array of all of our sessions */
36 void *pUsr; /**< a user-settable pointer (provides extensibility for "derived classes")*/
38 int (*pIsPermittedHost)(struct sockaddr *addr, char *fromHostFQDN, void*pUsrSrv, void*pUsrSess);
39 int (*pRcvData)(tcps_sess_t*, char*, size_t);
40 int* (*OpenLstnSocks)(struct tcpsrv_s*);
41 rsRetVal (*pOnListenDeinit)(void*);
42 rsRetVal (*OnDestruct)(void*);
43 rsRetVal (*pOnRegularClose)(tcps_sess_t *pSess);
44 rsRetVal (*pOnErrClose)(tcps_sess_t *pSess);
45 /* session specific callbacks */
46 rsRetVal (*pOnSessAccept)(struct tcpsrv_s *, tcps_sess_t*);
47 rsRetVal (*OnSessConstructFinalize)(void*);
48 rsRetVal (*pOnSessDestruct)(void*);
53 BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */
54 INTERFACEObjDebugPrint(tcpsrv);
55 rsRetVal (*Construct)(tcpsrv_t **ppThis);
56 rsRetVal (*ConstructFinalize)(tcpsrv_t __attribute__((unused)) *pThis);
57 rsRetVal (*Destruct)(tcpsrv_t **ppThis);
58 void (*configureTCPListen)(tcpsrv_t*, char *cOptarg);
59 int (*SessAccept)(tcpsrv_t *pThis, tcps_sess_t**ppSess, int fd);
60 int* (*create_tcp_socket)(tcpsrv_t *pThis);
61 rsRetVal (*Run)(tcpsrv_t *pThis);
63 rsRetVal (*SetUsrP)(tcpsrv_t*, void*);
64 rsRetVal (*SetCBIsPermittedHost)(tcpsrv_t*, int (*) (struct sockaddr *addr, char*, void*, void*));
65 rsRetVal (*SetCBOpenLstnSocks)(tcpsrv_t *, int* (*)(tcpsrv_t*));
66 rsRetVal (*SetCBRcvData)(tcpsrv_t *, int (*)(tcps_sess_t*, char*, size_t));
67 rsRetVal (*SetCBOnListenDeinit)(tcpsrv_t*, rsRetVal (*)(void*));
68 rsRetVal (*SetCBOnDestruct)(tcpsrv_t*, rsRetVal (*) (void*));
69 rsRetVal (*SetCBOnRegularClose)(tcpsrv_t*, rsRetVal (*) (tcps_sess_t*));
70 rsRetVal (*SetCBOnErrClose)(tcpsrv_t*, rsRetVal (*) (tcps_sess_t*));
71 /* session specifics */
72 rsRetVal (*SetCBOnSessAccept)(tcpsrv_t*, rsRetVal (*) (tcpsrv_t*, tcps_sess_t*));
73 rsRetVal (*SetCBOnSessDestruct)(tcpsrv_t*, rsRetVal (*) (void*));
74 rsRetVal (*SetCBOnSessConstructFinalize)(tcpsrv_t*, rsRetVal (*) (void*));
76 #define tcpsrvCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */
82 /* the name of our library binary */
83 #define LM_TCPSRV_FILENAME "lmtcpsrv"
85 #endif /* #ifndef INCLUDED_TCPSRV_H */