The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ModuleZLib Class Reference

Inheritance diagram for ModuleZLib:

Inheritance graph
[legend]
Collaboration diagram for ModuleZLib:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleZLib (InspIRCd *Me)
virtual ~ModuleZLib ()
virtual Version GetVersion ()
 Returns the version number of a Module.
virtual const char * OnRequest (Request *request)
 Called whenever a Request class is sent to your module by another module.
virtual int OnStats (char symbol, User *user, string_list &results)
 Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.
virtual void OnRawSocketConnect (int fd)
 Called immediately upon connection of an outbound BufferedSocket which has been hooked by a module.
virtual void OnRawSocketAccept (int fd, const std::string &ip, int localport)
 Called immediately after any connection is accepted.
virtual void OnRawSocketClose (int fd)
 Called immediately before any socket is closed.
virtual int OnRawSocketRead (int fd, char *buffer, unsigned int count, int &readresult)
 Called immediately before any read() operation on a client socket in the core.
virtual int OnRawSocketWrite (int fd, const char *buffer, int count)
 Called immediately before any write() operation on a user's socket in the core.
void Error (izip_session *session, const std::string &text)
void CloseSession (izip_session *session)

Private Attributes

izip_sessionsessions
float total_out_compressed
float total_in_compressed
float total_out_uncompressed
float total_in_uncompressed
char * net_buffer
unsigned int net_buffer_size

Detailed Description

Definition at line 44 of file m_ziplink.cpp.


Constructor & Destructor Documentation

ModuleZLib::ModuleZLib InspIRCd Me  )  [inline]
 

Definition at line 59 of file m_ziplink.cpp.

References ModuleManager::Attach(), InspIRCd::Config, SocketEngine::GetMaxFds(), I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketConnect, I_OnRawSocketRead, I_OnRawSocketWrite, I_OnRequest, I_OnStats, IZIP_CLOSED, InspIRCd::Modules, net_buffer, net_buffer_size, ServerConfig::NetBufferSize, ModuleManager::PublishInterface(), InspIRCd::SE, Module::ServerInstance, sessions, izip_session::status, total_in_compressed, total_in_uncompressed, total_out_compressed, and total_out_uncompressed.

virtual ModuleZLib::~ModuleZLib  )  [inline, virtual]
 

Definition at line 78 of file m_ziplink.cpp.

References InspIRCd::Modules, net_buffer, Module::ServerInstance, sessions, and ModuleManager::UnpublishInterface().


Member Function Documentation

void ModuleZLib::CloseSession izip_session session  )  [inline]
 

Definition at line 422 of file m_ziplink.cpp.

References izip_session::c_stream, izip_session::d_stream, IZIP_CLOSED, IZIP_OPEN, izip_session::outbuf, and izip_session::status.

Referenced by OnRawSocketClose().

void ModuleZLib::Error izip_session session,
const std::string text
[inline]
 

Definition at line 417 of file m_ziplink.cpp.

References Module::ServerInstance, InspIRCd::SNO, and SnomaskManager::WriteToSnoMask().

Referenced by OnRawSocketRead(), and OnRawSocketWrite().

virtual Version ModuleZLib::GetVersion  )  [inline, virtual]
 

Returns the version number of a Module.

The method should return a Version object with its version information assigned via Version::Version

Reimplemented from Module.

Definition at line 85 of file m_ziplink.cpp.

References API_VERSION, and VF_VENDOR.

virtual void ModuleZLib::OnRawSocketAccept int  fd,
const std::string ip,
int  localport
[inline, virtual]
 

Called immediately after any connection is accepted.

This is intended for raw socket processing (e.g. modules which wrap the tcp connection within another library) and provides no information relating to a user record as the connection has not been assigned yet. There are no return values from this call as all modules get an opportunity if required to process the connection.

Parameters:
fd The file descriptor returned from accept()
ip The IP address of the connecting user
localport The local port number the user connected to

Reimplemented from Module.

Definition at line 214 of file m_ziplink.cpp.

References OnRawSocketConnect().

virtual void ModuleZLib::OnRawSocketClose int  fd  )  [inline, virtual]
 

Called immediately before any socket is closed.

When this event is called, shutdown() has not yet been called on the socket.

Parameters:
fd The file descriptor of the socket prior to close()

Reimplemented from Module.

Definition at line 220 of file m_ziplink.cpp.

References CloseSession(), and sessions.

virtual void ModuleZLib::OnRawSocketConnect int  fd  )  [inline, virtual]
 

Called immediately upon connection of an outbound BufferedSocket which has been hooked by a module.

Parameters:
fd The file descriptor of the socket immediately after connect()

Reimplemented from Module.

Definition at line 177 of file m_ziplink.cpp.

References izip_session::c_stream, izip_session::d_stream, SocketEngine::GetMaxFds(), IZIP_CLOSED, IZIP_OPEN, izip_session::outbuf, InspIRCd::SE, Module::ServerInstance, sessions, and izip_session::status.

Referenced by OnRawSocketAccept().

virtual int ModuleZLib::OnRawSocketRead int  fd,
char *  buffer,
unsigned int  count,
int &  readresult
[inline, virtual]
 

Called immediately before any read() operation on a client socket in the core.

This occurs AFTER the select() or poll() so there is always data waiting to be read when this event occurs. Your event should return 1 if it has handled the reading itself, which prevents the core just using read(). You should place any data read into buffer, up to but NOT GREATER THAN the value of count. The value of readresult must be identical to an actual result that might be returned from the read() system call, for example, number of bytes read upon success, 0 upon EOF or closed socket, and -1 for error. If your function returns a nonzero value, you MUST set readresult.

Parameters:
fd The file descriptor of the socket
buffer A char* buffer being read to
count The size of the buffer
readresult The amount of characters read, or 0
Returns:
nonzero if the event was handled, in which case readresult must be valid on exit

Reimplemented from Module.

Definition at line 225 of file m_ziplink.cpp.

References izip_session::d_stream, Error(), izip_session::inbuf, IZIP_CLOSED, net_buffer, net_buffer_size, sessions, izip_session::status, total_in_compressed, and total_in_uncompressed.

virtual int ModuleZLib::OnRawSocketWrite int  fd,
const char *  buffer,
int  count
[inline, virtual]
 

Called immediately before any write() operation on a user's socket in the core.

Because this event is a low level event no user information is associated with it. It is intended for use by modules which may wrap connections within another API such as SSL for example. return a non-zero result if you have handled the write operation, in which case the core will not call write().

Parameters:
fd The file descriptor of the socket
buffer A char* buffer being written
Number of characters to write
Returns:
Number of characters actually written or 0 if you didn't handle the operation

Reimplemented from Module.

Definition at line 326 of file m_ziplink.cpp.

References izip_session::c_stream, Error(), IZIP_OPEN, net_buffer, net_buffer_size, izip_session::outbuf, sessions, izip_session::status, total_out_compressed, and total_out_uncompressed.

virtual const char* ModuleZLib::OnRequest Request request  )  [inline, virtual]
 

Called whenever a Request class is sent to your module by another module.

Please see the documentation of Request::Send() for further information. The Request sent can always be assumed to be non-NULL, you should not change the request object or its data. Your method may return arbitary data in the char* result which the requesting module may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).

Parameters:
request The Request class being received

Reimplemented from Module.

Definition at line 92 of file m_ziplink.cpp.

References EventHandler::AddIOHook(), EventHandler::DelIOHook(), Request::GetId(), and ISHRequest::Sock.

virtual int ModuleZLib::OnStats char  symbol,
User user,
string_list results
[inline, virtual]
 

Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.

Parameters:
symbol the symbol provided to /STATS
user the user issuing the /STATS command
results A string_list to append results into. You should put all your results into this string_list, rather than displaying them directly, so that your handler will work when remote STATS queries are received.
Returns:
1 to block the /STATS from being processed by the core, 0 to allow it

Reimplemented from Module.

Definition at line 137 of file m_ziplink.cpp.

References InspIRCd::Config, ConvToStr(), MAXBUF, User::nick, Module::ServerInstance, ServerConfig::ServerName, total_in_compressed, total_in_uncompressed, total_out_compressed, and total_out_uncompressed.


Member Data Documentation

char* ModuleZLib::net_buffer [private]
 

Definition at line 55 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketRead(), OnRawSocketWrite(), and ~ModuleZLib().

unsigned int ModuleZLib::net_buffer_size [private]
 

Definition at line 56 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketRead(), and OnRawSocketWrite().

izip_session* ModuleZLib::sessions [private]
 

Definition at line 46 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketClose(), OnRawSocketConnect(), OnRawSocketRead(), OnRawSocketWrite(), and ~ModuleZLib().

float ModuleZLib::total_in_compressed [private]
 

Definition at line 50 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketRead(), and OnStats().

float ModuleZLib::total_in_uncompressed [private]
 

Definition at line 52 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketRead(), and OnStats().

float ModuleZLib::total_out_compressed [private]
 

Definition at line 49 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketWrite(), and OnStats().

float ModuleZLib::total_out_uncompressed [private]
 

Definition at line 51 of file m_ziplink.cpp.

Referenced by ModuleZLib(), OnRawSocketWrite(), and OnStats().


The documentation for this class was generated from the following file: