#include "packet.h"#include "../engine/hlbr.h"#include <string.h>#include <stdio.h>#include <stdlib.h>#include "../engine/bits.h"#include "packet_linux_raw.h"#include "packet_obsd_bpf.h"#include "packet_osx_bpf.h"#include "packet_tcpdump.h"#include "packet_solaris_dlpi.h"Go to the source code of this file.
Defines | |
| #define | DEBUGPATH ; |
Functions | |
| int | GetPacketTypeByName (char *Name) |
| int | GetPacketProtoByName (char *Name) |
| int | GetPacketRoleByName (char *Name) |
| int | OpenInterface (int InterfaceID) |
| int | OpenInterfaces () |
| int | ReadPacket (int InterfaceID) |
| int | WritePacket (int PacketSlot) |
| int | AddPacketToPending (int PacketSlot) |
| int | BlockPacket (int PacketSlot) |
| int | DropPacket (int PacketSlot) |
| int | PopFromPending () |
| int | GetEmptyPacket () |
| void | ReturnEmptyPacket (int PacketSlot) |
| int | StartInterfaceThread (int InterfaceID) |
| int | RuleIsActive (int PacketSlot, int RuleNum) |
| int | SetRuleInactive (int PacketSlot, int RuleNum) |
| int | GetInterfaceByName (char *Name) |
Variables | |
| GlobalVars | Globals |
| int | LastFreeSlot |
| int | LastPendingSlot |
| pthread_mutex_t | PacketMutex |
| int | PacketLockID = 0 |
| unsigned int | CurPacketNum = 0 |
| int AddPacketToPending | ( | int | PacketSlot | ) |
Marks a packet as 'pending' (thread safe, called from ReadPacket) Gets called every time a packet gets put on the pending list. Uses a mutex lock (to avoid problems with threads). This may be called more than once per ReadPacket request.
Definition at line 334 of file packet.c.
References ADD_PACKET_1, global_vars::AllocatedCount, DEBUGPATH, Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), LastPendingSlot, PACKET_STATUS_PENDING, PacketLockID, PacketMutex, global_vars::Packets, global_vars::PendingCount, packet_rec::Status, and TRUE.
Referenced by ReadPacketTCPDump(), and RebuildPacket().
| int BlockPacket | ( | int | PacketSlot | ) |
Marks a packet as 'blocked' (thread safe). Blocked packets can't be processed until are unblocked. Usually they're blocked by session handling functions
Definition at line 357 of file packet.c.
References Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), PACKET_STATUS_BLOCKED, PacketLockID, PacketMutex, global_vars::Packets, POP_PACKET_1, packet_rec::Status, and TRUE.
Referenced by AssignSessionTCP().
| int DropPacket | ( | int | PacketSlot | ) |
Definition at line 366 of file packet.c.
References FALSE, Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), PacketLockID, PacketMutex, global_vars::Packets, packet_rec::PassRawPacket, POP_PACKET_1, and TRUE.
| int GetEmptyPacket | ( | ) |
Definition at line 412 of file packet.c.
References DEBUG, DEBUGPATH, GET_PACKET_1, Globals, hlbr_mutex_lock(), LastFreeSlot, MAX_PACKETS, NULL, PACKET_STATUS_ALLOCATED, PACKET_STATUS_IDLE, PacketLockID, PacketMutex, global_vars::Packets, packet_rec::PacketSlot, packet_rec::SaveCount, and packet_rec::Status.
Referenced by ReadPacketTCPDump(), RebuildPacket(), and SendARP().
| int GetInterfaceByName | ( | char * | Name | ) |
Definition at line 595 of file packet.c.
References DEBUGPATH, Globals, global_vars::Interfaces, interface_rec::Name, and global_vars::NumInterfaces.
Referenced by RouteBNSAddNode().
| int GetPacketProtoByName | ( | char * | Name | ) |
Definition at line 64 of file packet.c.
References DEBUGPATH, PACKET_PROTO_ETHERNET, and PACKET_PROTO_NONE.
Referenced by ParseInterface().
| int GetPacketRoleByName | ( | char * | Name | ) |
Definition at line 79 of file packet.c.
References DEBUGPATH, PACKET_ROLE_EXTERNAL, PACKET_ROLE_HONEY, PACKET_ROLE_INTERNAL, and PACKET_ROLE_NORMAL.
Referenced by ParseInterface().
| int GetPacketTypeByName | ( | char * | Name | ) |
Definition at line 38 of file packet.c.
References DEBUGPATH, PACKET_TYPE_LINUX_RAW, PACKET_TYPE_NONE, PACKET_TYPE_OBSD_BPF, PACKET_TYPE_OSX_BPF, PACKET_TYPE_PCAP, PACKET_TYPE_SOLARIS_DLPI, and PACKET_TYPE_TCPDUMP.
Referenced by ParseInterface().
| int OpenInterface | ( | int | InterfaceID | ) |
Definition at line 99 of file packet.c.
References DEBUGPATH, FALSE, Globals, global_vars::Interfaces, interface_rec::Name, OpenInterfaceLinuxRaw(), OpenInterfaceOBSDBPF(), OpenInterfaceOSXBPF(), OpenInterfaceSolarisDLPI(), OpenInterfaceTCPDump(), PACKET_TYPE_LINUX_RAW, PACKET_TYPE_OBSD_BPF, PACKET_TYPE_OSX_BPF, PACKET_TYPE_SOLARIS_DLPI, PACKET_TYPE_TCPDUMP, and interface_rec::Type.
Referenced by OpenInterfaces().
| int OpenInterfaces | ( | ) |
Definition at line 140 of file packet.c.
References DEBUGPATH, FALSE, Globals, global_vars::NumInterfaces, OpenInterface(), and TRUE.
Referenced by main().
| int PopFromPending | ( | ) |
Pops a packet off the pending queue Give the caller a packet off the pending queue (marked as PACKET_STATUS_PENDING
Definition at line 384 of file packet.c.
References DEBUGPATH, Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), MAX_PACKETS, PACKET_NONE, PACKET_STATUS_PENDING, PACKET_STATUS_PROCESSING, PacketLockID, PacketMutex, global_vars::Packets, global_vars::PendingCount, POP_PACKET_1, global_vars::ProcessingCount, and packet_rec::Status.
Referenced by MainLoopPoll(), and ProcessPacketThread().
| int ReadPacket | ( | int | InterfaceID | ) |
Definition at line 156 of file packet.c.
References DEBUGPATH, FALSE, Globals, global_vars::Interfaces, PACKET_TYPE_LINUX_RAW, PACKET_TYPE_OBSD_BPF, PACKET_TYPE_OSX_BPF, PACKET_TYPE_SOLARIS_DLPI, PACKET_TYPE_TCPDUMP, ReadPacketLinuxRaw(), ReadPacketOBSDBPF(), ReadPacketOSXBPF(), ReadPacketSolarisDLPI(), ReadPacketTCPDump(), and interface_rec::Type.
Referenced by MainLoopPoll().
| void ReturnEmptyPacket | ( | int | PacketSlot | ) |
Definition at line 480 of file packet.c.
References global_vars::AllocatedCount, decoder_data::Data, DEBUGPATH, packet_rec::DecoderInfo, FALSE, Globals, hlbr_mutex_lock(), global_vars::IdleCount, packet_rec::LargePacket, NULL, packet_rec::NumDecoderData, PACKET_STATUS_ALLOCATED, PACKET_STATUS_IDLE, PACKET_STATUS_PROCESSING, PacketLockID, PacketMutex, global_vars::Packets, global_vars::ProcessingCount, packet_rec::RawPacket, RETURN_PACKET_1, packet_rec::SaveCount, packet_rec::Status, and packet_rec::TypicalPacket.
Referenced by DecodeIPDefrag(), FreeSaved(), ProcessPacket(), ReadPacketTCPDump(), and SendARP().
| int RuleIsActive | ( | int | PacketSlot, | |
| int | RuleNum | |||
| ) | [inline] |
Definition at line 575 of file packet.c.
References DEBUGPATH, GetBit(), Globals, global_vars::NumRules, global_vars::Packets, and packet_rec::RuleBits.
Referenced by PerformActions(), TestEthernetDst(), TestEthernetSrc(), TestEthernetType(), TestICMPCode(), TestICMPType(), TestIPCheck(), TestIPDst(), TestIPProto(), TestIPSrc(), TestIPTTL(), TestTCPContent(), TestTCPDst(), TestTCPDstOld(), TestTCPFlags(), TestTCPListContent(), TestTCPListNoCase(), TestTCPNoCase(), TestTCPPort(), TestTCPRegExp(), TestTCPSrc(), TestUDPContent(), TestUDPDst(), TestUDPNoCase(), TestUDPRegExp(), and TestUDPSrc().
| int SetRuleInactive | ( | int | PacketSlot, | |
| int | RuleNum | |||
| ) | [inline] |
Definition at line 584 of file packet.c.
References DEBUGPATH, Globals, global_vars::NumRules, global_vars::Packets, packet_rec::RuleBits, SetBit(), and TRUE.
Referenced by TestEthernetDst(), TestEthernetSrc(), TestEthernetType(), TestICMPCode(), TestICMPType(), TestIPCheck(), TestIPProto(), TestTCPDstOld(), TestTCPPort(), TestTCPRegExp(), TestTCPSrc(), TestUDPDst(), and TestUDPRegExp().
| int StartInterfaceThread | ( | int | InterfaceID | ) |
Definition at line 534 of file packet.c.
References DEBUGPATH, FALSE, Globals, global_vars::Interfaces, LoopThreadLinuxRaw(), LoopThreadOBSDBPF(), LoopThreadOSXBPF(), LoopThreadSolarisDLPI(), LoopThreadTCPDump(), PACKET_TYPE_LINUX_RAW, PACKET_TYPE_OBSD_BPF, PACKET_TYPE_OSX_BPF, PACKET_TYPE_SOLARIS_DLPI, PACKET_TYPE_TCPDUMP, TRUE, and interface_rec::Type.
Referenced by MainLoopThreaded().
| int WritePacket | ( | int | PacketSlot | ) |
Definition at line 194 of file packet.c.
References DEBUG, DEBUGPATH, FALSE, Globals, INTERFACE_BROADCAST, global_vars::Interfaces, interface_rec::Name, global_vars::NumInterfaces, PACKET_TYPE_LINUX_RAW, PACKET_TYPE_OBSD_BPF, PACKET_TYPE_OSX_BPF, PACKET_TYPE_SOLARIS_DLPI, PACKET_TYPE_TCPDUMP, packet_rec::PacketLen, global_vars::Packets, packet_rec::RawPacket, packet_rec::TargetInterface, interface_rec::Type, WritePacketLinuxRaw(), WritePacketOBSDBPF(), WritePacketOSXBPF(), WritePacketSolarisDLPI(), and WritePacketTCPDump().
Referenced by RouteAndSend(), and SendARP().
| unsigned int CurPacketNum = 0 |
| int LastFreeSlot |
| int LastPendingSlot |
| int PacketLockID = 0 |
Definition at line 27 of file packet.c.
Referenced by AddPacketToPending(), BlockPacket(), DropPacket(), GetEmptyPacket(), PopFromPending(), and ReturnEmptyPacket().
| pthread_mutex_t PacketMutex |
Definition at line 26 of file packet.c.
Referenced by AddPacketToPending(), BlockPacket(), DropPacket(), GetEmptyPacket(), PopFromPending(), and ReturnEmptyPacket().
1.5.2