suricata
packet.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #ifndef SURICATA_PACKET_H
19 #define SURICATA_PACKET_H
20 
21 #include "decode.h"
22 #include "util-device.h"
23 
24 void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r);
25 bool PacketCheckAction(const Packet *p, const uint8_t a);
26 uint8_t PacketGetAction(const Packet *p);
27 
28 #ifdef UNITTESTS
29 static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
30 {
31  return PacketCheckAction(p, a);
32 }
33 #endif
34 
35 void PacketInit(Packet *p);
36 void PacketReleaseRefs(Packet *p);
37 void PacketReinit(Packet *p);
38 void PacketRecycle(Packet *p);
39 void PacketDestructor(Packet *p);
40 
41 /** \brief Set a packet release function.
42  *
43  * Set a custom release function for packet. This is required if extra
44  * non-standard packet was done that needs to be cleaned up when
45  * Suricata is done with a packet.
46  *
47  * Its also where IPS actions may be done.
48  */
50 
51 /** \brief Set a packets live device. */
52 void SCPacketSetLiveDevice(Packet *p, LiveDevice *device);
53 
54 /** \brief Set a packets data link type. */
55 void SCPacketSetDatalink(Packet *p, int datalink);
56 
57 /** \brief Set the timestamp for a packet.
58  *
59  * \param ts A timestamp in SCTime_t format. See SCTIME_FROM_TIMEVAL
60  * for conversion from struct timeval.
61  */
63 
64 /** \brief Set packet source.
65  */
66 void SCPacketSetSource(Packet *p, enum PktSrcEnum source);
67 
68 #endif
SCPacketSetDatalink
void SCPacketSetDatalink(Packet *p, int datalink)
Set a packets data link type.
Definition: packet.c:192
PacketGetAction
uint8_t PacketGetAction(const Packet *p)
Definition: packet.c:61
ts
uint64_t ts
Definition: source-erf-file.c:55
SCPacketSetLiveDevice
void SCPacketSetLiveDevice(Packet *p, LiveDevice *device)
Set a packets live device.
Definition: packet.c:187
PacketCheckAction
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition: packet.c:50
PacketReleaseRefs
void PacketReleaseRefs(Packet *p)
Definition: packet.c:80
Packet_::action
uint8_t action
Definition: decode.h:609
LiveDevice_
Definition: util-device-private.h:32
PacketDropReason
PacketDropReason
Definition: decode.h:380
Packet_::datalink
int datalink
Definition: decode.h:639
decode.h
util-device.h
PacketInit
void PacketInit(Packet *p)
Initialize a packet structure for use.
Definition: packet.c:73
PacketReinit
void PacketReinit(Packet *p)
Recycle a packet structure for reuse.
Definition: packet.c:90
PktSrcEnum
PktSrcEnum
Definition: decode.h:51
Packet_
Definition: decode.h:501
SCTime_t
Definition: util-time.h:40
PacketDestructor
void PacketDestructor(Packet *p)
Cleanup a packet so that we can free it. No memset needed..
Definition: packet.c:169
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:591
PacketRecycle
void PacketRecycle(Packet *p)
Definition: packet.c:160
PacketDrop
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
Definition: packet.c:34
SCPacketSetReleasePacket
void SCPacketSetReleasePacket(Packet *p, void(*ReleasePacket)(Packet *p))
Set a packet release function.
Definition: packet.c:182
SCPacketSetSource
void SCPacketSetSource(Packet *p, enum PktSrcEnum source)
Set packet source.
Definition: packet.c:202
SCPacketSetTime
void SCPacketSetTime(Packet *p, SCTime_t ts)
Set the timestamp for a packet.
Definition: packet.c:197