|
suricata
|
#include "packet.h"#include "packet-bindgen.h"#include "pkt-var.h"#include "flow.h"#include "host.h"#include "util-profiling.h"#include "util-validate.h"#include "action-globals.h"#include "rust.h"#include "app-layer-events.h"
Go to the source code of this file.
Macros | |
| #define | CLEAR_ADDR(a) |
| #define | PACKET_RESET_ACTION(p) (p)->action = 0 |
| #define | RESET_PKT_LEN(p) ((p)->pktlen = 0) |
Functions | |
| void | PacketDrop (Packet *p, const uint8_t action, enum PacketDropReason r) |
| issue drop action More... | |
| bool | PacketCheckAction (const Packet *p, const uint8_t a) |
| uint8_t | PacketGetAction (const Packet *p) |
| bool | PacketInit (Packet *p) |
| Initialize a packet structure for use. More... | |
| void | PacketReleaseRefs (Packet *p) |
| void | PacketReinit (Packet *p) |
| Recycle a packet structure for reuse. More... | |
| void | PacketRecycle (Packet *p) |
| void | PacketDestructor (Packet *p) |
| Cleanup a packet so that we can free it. No memset needed.. More... | |
| void | SCPacketSetReleasePacket (Packet *p, void(*ReleasePacket)(Packet *p)) |
| Set a packet release function. More... | |
| void | SCPacketSetLiveDevice (Packet *p, LiveDevice *device) |
| Set a packets live device. More... | |
| void | SCPacketSetDatalink (Packet *p, int datalink) |
| Set a packets data link type. More... | |
| void | SCPacketSetTime (Packet *p, SCTime_t ts) |
| Set the timestamp for a packet. More... | |
| void | SCPacketSetSource (Packet *p, enum PktSrcEnum source) |
| Set packet source. More... | |
| uint8_t | SCPacketGetIPProto (const Packet *p) |
| Get IP proto regardless of IP version. More... | |
| bool | SCPacketIsToServer (const Packet *p) |
| Test whether the packet is marked as flowing to the server. More... | |
| bool | SCPacketIsToClient (const Packet *p) |
| Test whether the packet is marked as flowing to the client. More... | |
| enum PacketL3Types | SCPacketGetL3Type (const Packet *p) |
| Get the type of the packet's L3 layer. More... | |
| const uint8_t * | SCPacketGetL3 (const Packet *p, uint32_t *len) |
| Get the L3 packet data, starting at the L3 header. More... | |
| Flow * | SCPacketGetFlow (const Packet *p) |
| Get the flow associated with the packet. More... | |
| void | SCPacketGetTimeAsParts (const Packet *p, uint64_t *secs, uint64_t *usecs) |
| Get packet timestamp as individual values. More... | |
| #define CLEAR_ADDR | ( | a | ) |
| bool PacketCheckAction | ( | const Packet * | p, |
| const uint8_t | a | ||
| ) |
Definition at line 51 of file packet.c.
References Packet_::action, likely, p, and Packet_::root.
Referenced by AlertJsonHeader(), CaptureStatsUpdate(), RejectSendIPv4ICMP(), RejectSendIPv4TCP(), RejectSendIPv6ICMP(), and RejectSendIPv6TCP().

| void PacketDestructor | ( | Packet * | p | ) |
Cleanup a packet so that we can free it. No memset needed..
Definition at line 179 of file packet.c.
References PacketAlerts_::alerts, Packet_::alerts, Packet_::app_layer_events, PacketAlerts_::drop, p, PACKET_FREE_EXTDATA, PACKET_PROFILING_RESET, PacketAlertFree(), PacketAlertRecycle(), PacketReleaseRefs(), Packet_::persistent, Packet_::pktvar, PktVarFree(), SCAppLayerDecoderEventsFreeEvents(), SCSpinDestroy, and Packet_::tunnel_lock.
Referenced by PacketFree().


| void PacketDrop | ( | Packet * | p, |
| const uint8_t | action, | ||
| enum PacketDropReason | r | ||
| ) |
issue drop action
Set drop (+reject) flags in both current and root packet.
| action | action bit flags. Must be limited to ACTION_DROP_REJECT|ACTION_ALERT |
Definition at line 35 of file packet.c.
References Packet_::action, ACTION_ALERT, ACTION_DROP_REJECT, DEBUG_VALIDATE_BUG_ON, Packet_::drop_reason, p, PKT_DROP_REASON_INNER_PACKET, PKT_DROP_REASON_NOT_SET, and Packet_::root.
| uint8_t PacketGetAction | ( | const Packet * | p | ) |
Definition at line 62 of file packet.c.
References Packet_::action, likely, p, and Packet_::root.
Referenced by EveAddVerdict().

| bool PacketInit | ( | Packet * | p | ) |
Initialize a packet structure for use.
Definition at line 74 of file packet.c.
References PacketAlerts_::alerts, Packet_::alerts, Packet_::livedev_dst_id, Packet_::livedev_id, p, PacketAlertCreate(), Packet_::persistent, SCSpinInit, Packet_::tunnel_lock, and unlikely.
Referenced by PacketGetFromAlloc().


| void PacketRecycle | ( | Packet * | p | ) |
Definition at line 170 of file packet.c.
References p, PacketReinit(), and PacketReleaseRefs().

| void PacketReinit | ( | Packet * | p | ) |
Recycle a packet structure for reuse.
Definition at line 96 of file packet.c.
References Packet_::app_update_direction, CLEAR_ADDR, Packet_::datalink, Packet_::dp, Packet_::drop_reason, Packet_::dst, Packet_::flags, Packet_::flowflags, p, PACKET_FREE_EXTDATA, PACKET_RESET_ACTION, PacketTunnelNone, Packet_::pkt_hooks, Packet_::pkt_src, Packet_::pktvar, PktVarFree(), Packet_::proto, Packet_::recursion_level, SCTIME_INIT, Packet_::sig_mask, Packet_::sp, Packet_::src, Packet_::ts, Packet_::ttype, Packet_::tunnel_id, Packet_::vlan_id, Packet_::vlan_idx, and VLAN_MAX_LAYERS.
Referenced by PacketRecycle().


| void PacketReleaseRefs | ( | Packet * | p | ) |
Definition at line 86 of file packet.c.
Referenced by PacketDestructor(), and PacketRecycle().

Get the flow associated with the packet.
Definition at line 300 of file packet.c.
References Packet_::flow, and p.
| uint8_t SCPacketGetIPProto | ( | const Packet * | p | ) |
| const uint8_t* SCPacketGetL3 | ( | const Packet * | p, |
| uint32_t * | len | ||
| ) |
Get the L3 packet data, starting at the L3 header.
The returned data is borrowed from p and is valid only while its packet buffer remains valid and unchanged. For IPv4 and IPv6 the length comes from the IP header and includes the IPv6 base header. For ARP it is the fixed ARP header length. Trailing padding is excluded. The decoder has already validated the length against the captured packet length.
| p | Packet to inspect, or NULL. |
| len | Non-NULL output pointer, set to zero when no data is returned. |
| NULL | The packet is NULL or has no decoded L3 layer. |
Definition at line 271 of file packet.c.
References Packet_::l3, len, p, PACKET_L3_IPV4, and PacketL3::type.
| enum PacketL3Types SCPacketGetL3Type | ( | const Packet * | p | ) |
| void SCPacketGetTimeAsParts | ( | const Packet * | p, |
| uint64_t * | secs, | ||
| uint64_t * | usecs | ||
| ) |
Get packet timestamp as individual values.
Definition at line 308 of file packet.c.
References p, SCTIME_SECS, SCTIME_USECS, and Packet_::ts.
| bool SCPacketIsToClient | ( | const Packet * | p | ) |
Test whether the packet is marked as flowing to the client.
Requires a valid packet. Returns false when the direction flag is not set.
Definition at line 243 of file packet.c.
References p, and PKT_IS_TOCLIENT.
| bool SCPacketIsToServer | ( | const Packet * | p | ) |
Test whether the packet is marked as flowing to the server.
Requires a valid packet. Returns false when the direction flag is not set.
Definition at line 233 of file packet.c.
References p, and PKT_IS_TOSERVER.
|
inline |
Set a packets data link type.
Definition at line 203 of file packet.c.
References Packet_::datalink, and p.
|
inline |
Set a packets live device.
Definition at line 198 of file packet.c.
References Packet_::livedev_id, LiveDeviceGetId(), and p.

|
inline |