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 
27 #ifdef UNITTESTS
28 static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
29 {
30  return PacketCheckAction(p, a);
31 }
32 #endif
33 
34 void PacketInit(Packet *p);
35 void PacketReleaseRefs(Packet *p);
36 void PacketReinit(Packet *p);
37 void PacketRecycle(Packet *p);
38 void PacketDestructor(Packet *p);
39 
40 /** \brief Set a packet release function.
41  *
42  * Set a custom release function for packet. This is required if extra
43  * non-standard packet was done that needs to be cleaned up when
44  * Suricata is done with a packet.
45  *
46  * Its also where IPS actions may be done.
47  */
49 
50 /** \brief Set a packets live device. */
51 void SCPacketSetLiveDevice(Packet *p, LiveDevice *device);
52 
53 /** \brief Set a packets data link type. */
54 void SCPacketSetDatalink(Packet *p, int datalink);
55 
56 /** \brief Set the timestamp for a packet.
57  *
58  * \param ts A timestamp in SCTime_t format. See SCTIME_FROM_TIMEVAL
59  * for conversion from struct timeval.
60  */
62 
63 /** \brief Set packet source.
64  */
65 void SCPacketSetSource(Packet *p, enum PktSrcEnum source);
66 
67 #endif
SCPacketSetDatalink
void SCPacketSetDatalink(Packet *p, int datalink)
Set a packets data link type.
Definition: packet.c:177
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:172
PacketCheckAction
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition: packet.c:49
PacketReleaseRefs
void PacketReleaseRefs(Packet *p)
Definition: packet.c:70
Packet_::action
uint8_t action
Definition: decode.h:592
LiveDevice_
Definition: util-device.h:41
PacketDropReason
PacketDropReason
Definition: decode.h:365
Packet_::datalink
int datalink
Definition: decode.h:622
decode.h
util-device.h
PacketInit
void PacketInit(Packet *p)
Initialize a packet structure for use.
Definition: packet.c:63
PacketReinit
void PacketReinit(Packet *p)
Recycle a packet structure for reuse.
Definition: packet.c:80
PktSrcEnum
PktSrcEnum
Definition: decode.h:51
Packet_
Definition: decode.h:484
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:154
Packet_::ReleasePacket
void(* ReleasePacket)(struct Packet_ *)
Definition: decode.h:574
PacketRecycle
void PacketRecycle(Packet *p)
Definition: packet.c:145
PacketDrop
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
Definition: packet.c:33
SCPacketSetReleasePacket
void SCPacketSetReleasePacket(Packet *p, void(*ReleasePacket)(Packet *p))
Set a packet release function.
Definition: packet.c:167
SCPacketSetSource
void SCPacketSetSource(Packet *p, enum PktSrcEnum source)
Set packet source.
Definition: packet.c:187
SCPacketSetTime
void SCPacketSetTime(Packet *p, SCTime_t ts)
Set the timestamp for a packet.
Definition: packet.c:182