#include "hlbr.h"
#include "hlbrlib.h"
#include "parse_config.h"
#include "parse_rules.h"
#include "main_loop.h"
#include "session.h"
#include "../decoders/decode.h"
#include "../decoders/decode_ip.h"
#include "../decoders/decode_tcp.h"
#include "../tests/test.h"
#include "../packets/packet.h"
#include "../packets/packet_cache.h"
#include "../actions/action.h"
#include "../routes/route.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
Defines | |
#define | HOG_PARSEARGS_FLAGS "c:r:tn:l:dhvL:" |
Functions | |
int | CallShutdownHandlers () |
int | CreateTimer (char *Name, unsigned int Interval, int(*TimerFunc)(int TimerID, int Time, void *User), void *User) |
void | PrintVersion () |
void | PrintUsage (char op) |
int | hlbr_daemon (int nochdir, int noclose) |
int | ParseArgs (int argc, char **argv) |
int | hlbr_mutex_lock (pthread_mutex_t *mutex, int ID, int *LockID) |
int | hlbr_mutex_trylock (pthread_mutex_t *mutex, int ID, int *LockID) |
int | hlbr_mutex_unlock (pthread_mutex_t *mutex) |
void | HandleSignal (int signal) |
int | main (int argc, char **argv) |
int | GetListByName (char *Name) |
int | AddShutdownHandler (int(*func)(void *data), void *data) |
void | PrintPacketSummary (FILE *stream, int PacketSlot, IPData *IData, TCPData *TData, char newline) |
void | PrintSessionSummary (FILE *stream, PP *Port, char newline) |
void | PrintSessionBuffer (FILE *stream, PP *Port) |
Variables | |
GlobalVars | Globals |
#define HOG_PARSEARGS_FLAGS "c:r:tn:l:dhvL:" |
Referenced by ParseArgs().
int AddShutdownHandler | ( | int(*)(void *data) | func, | |
void * | data | |||
) |
Add a function to be called during shutdown. Defines a callback function.
Definition at line 458 of file hlbr.c.
References func_list::Data, DEBUGPATH, func_list::Func, Globals, global_vars::ShutdownFuncs, and TRUE.
Referenced by SyslogInit().
int CallShutdownHandlers | ( | ) |
int CreateTimer | ( | char * | Name, | |
unsigned int | Interval, | |||
int(*)(int TimerID, int Time, void *User) | TimerFunc, | |||
void * | User | |||
) |
Definition at line 48 of file hlbr.c.
References FALSE, Globals, timer_rec::Interval, timer_rec::InUse, timer_rec::LastTime, MAX_NAME_LEN, MAX_TIMERS, timer_rec::Name, TIMER_NONE, timer_rec::TimerFunc, global_vars::Timers, TRUE, and timer_rec::User.
Referenced by AlertListenSocketParseArgs().
int GetListByName | ( | char * | Name | ) |
Definition at line 441 of file hlbr.c.
References DEBUGPATH, Globals, LIST_NONE, global_vars::Lists, global_list::Name, and global_vars::NumLists.
Referenced by AddIPRanges(), and ParseList().
void HandleSignal | ( | int | signal | ) |
int hlbr_daemon | ( | int | nochdir, | |
int | noclose | |||
) |
int hlbr_mutex_lock | ( | pthread_mutex_t * | mutex, | |
int | ID, | |||
int * | LockID | |||
) |
Definition at line 281 of file hlbr.c.
References Globals, TRUE, and global_vars::UseThreads.
Referenced by AddPacketToPending(), BlockPacket(), DecodeIPDefrag(), DropPacket(), FreeSaveQuery(), GetAndLockSavedPackets(), GetEmptyPacket(), PopFromPending(), ReturnEmptyPacket(), SavePacket(), TimeoutSavedPackets(), and UnlockSavedQuery().
int hlbr_mutex_trylock | ( | pthread_mutex_t * | mutex, | |
int | ID, | |||
int * | LockID | |||
) |
int hlbr_mutex_unlock | ( | pthread_mutex_t * | mutex | ) |
Definition at line 319 of file hlbr.c.
References Globals, TRUE, and global_vars::UseThreads.
Referenced by AddPacketToPending(), BlockPacket(), DecodeIPDefrag(), DropPacket(), FreeSaved(), FreeSaveQuery(), GetAndLockSavedPackets(), PopFromPending(), SavePacket(), TimeoutSavedPackets(), and UnlockSavedQuery().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 348 of file hlbr.c.
References CallShutdownHandlers(), FALSE, Globals, HandleSignal(), global_vars::IdleCount, InitActions(), InitDecoders(), InitRoutes(), InitSession(), InitTests(), MainLoop(), MainLoopThreaded(), MAX_PACKETS, global_vars::NumRules, OpenInterfaces(), global_vars::PacketLimit, ParseArgs(), ParseConfig(), global_vars::ParseOnly, ParseRules(), PrintUsage(), global_vars::RulesFilename, TestsFinishSetup(), TRUE, and global_vars::UseThreads.
int ParseArgs | ( | int | argc, | |
char ** | argv | |||
) |
Make sense of the command line. Parse the parameters received by the main() function
Definition at line 170 of file hlbr.c.
References global_vars::ConfigFilename, DEBUGPATH, log_file_rec::fname, Globals, hlbr_daemon(), HOG_PARSEARGS_FLAGS, global_vars::LogDir, global_vars::logSession_All, global_vars::logSession_StartEnd, global_vars::logSessionFile, global_vars::PacketLimit, global_vars::ParseOnly, PRINT, PRINT1, PrintUsage(), PrintVersion(), global_vars::RulesFilename, and TRUE.
Referenced by main().
void PrintPacketSummary | ( | FILE * | stream, | |
int | PacketSlot, | |||
IPData * | IData, | |||
TCPData * | TData, | |||
char | newline | |||
) |
Prints a one-line summary of the packet. Inspects packet's IP and TCP structure (if any)
Definition at line 507 of file hlbr.c.
References tcp_header::ack_seq, ip_header::daddr, tcp_header::dest, tcp_header::fin, ip_data::Header, tcp_data::Header, IP_BYTES, tcp_header::rst, ip_header::saddr, tcp_header::seq, tcp_header::source, and tcp_header::syn.
Referenced by AssignSessionTCP().
void PrintSessionBuffer | ( | FILE * | stream, | |
PP * | Port | |||
) |
Prints the TCP buffer for the session. Non-printable characters are printed as dots
Definition at line 566 of file hlbr.c.
References ip_pair::IP1, ip_pair::IP2, IP_BYTES, tcp_stream::LastSeq, port_pair::Parent, tcp_stream::Payloads, port_pair::Port1, port_pair::Port2, port_pair::SessionID, port_pair::Stream0, port_pair::Stream1, and tcp_stream::TopSeq.
void PrintSessionSummary | ( | FILE * | stream, | |
PP * | Port, | |||
char | newline | |||
) |
Prints a one-line summary of the session. Can be called right after PrintPacketSummary, and continue printing in the same line (in this case PrintPacketSummary's newline parameter should be false, of course.).
Definition at line 554 of file hlbr.c.
References port_pair::SessionID, and port_pair::TCPCount.
void PrintUsage | ( | char | op | ) |
Tell the user about the command line.
Definition at line 86 of file hlbr.c.
References DEBUGPATH, and PrintVersion().
Referenced by main(), and ParseArgs().
void PrintVersion | ( | ) |
Print out the version number.
Definition at line 75 of file hlbr.c.
References MAJOR_VERSION, and MINOR_VERSION.
Referenced by ParseArgs(), and PrintUsage().