2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class IOHook : public ServiceProvider
27 IOHook(Module* mod, const std::string& Name)
28 : ServiceProvider(mod, Name, SERVICE_IOHOOK) { }
30 /** Called immediately after any connection is accepted. This is intended for raw socket
31 * processing (e.g. modules which wrap the tcp connection within another library) and provides
32 * no information relating to a user record as the connection has not been assigned yet.
33 * There are no return values from this call as all modules get an opportunity if required to
34 * process the connection.
35 * @param sock The socket in question
36 * @param client The client IP address and port
37 * @param server The server IP address and port
39 virtual void OnStreamSocketAccept(StreamSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) = 0;
42 * Called when a hooked stream has data to write, or when the socket
43 * engine returns it as writable
44 * @param sock The socket in question
45 * @param sendq Data to send to the socket
46 * @return 1 if the sendq has been completely emptied, 0 if there is
47 * still data to send, and -1 if there was an error
49 virtual int OnStreamSocketWrite(StreamSocket* sock, std::string& sendq) = 0;
51 /** Called immediately before any socket is closed. When this event is called, shutdown()
52 * has not yet been called on the socket.
53 * @param sock The socket in question
55 virtual void OnStreamSocketClose(StreamSocket* sock) = 0;
57 /** Called immediately upon connection of an outbound BufferedSocket which has been hooked
59 * @param sock The socket in question
61 virtual void OnStreamSocketConnect(StreamSocket* sock) = 0;
64 * Called when the stream socket has data to read
65 * @param sock The socket that is ready
66 * @param recvq The receive queue that new data should be appended to
67 * @return 1 if new data has been read, 0 if no new data is ready (but the
68 * socket is still connected), -1 if there was an error or close
70 virtual int OnStreamSocketRead(StreamSocket* sock, std::string& recvq) = 0;