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
24void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r);
25bool PacketCheckAction(const Packet *p, const uint8_t a);
26
27#ifdef UNITTESTS
28static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
29{
30 return PacketCheckAction(p, a);
31}
32#endif
33
34void PacketInit(Packet *p);
36void PacketReinit(Packet *p);
37void PacketRecycle(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 */
48void SCPacketSetReleasePacket(Packet *p, void (*ReleasePacket)(Packet *p));
49
50/** \brief Set a packets live device. */
52
53/** \brief Set a packets data link type. */
54void 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 */
65void SCPacketSetSource(Packet *p, enum PktSrcEnum source);
66
67#endif
PacketDropReason
Definition decode.h:380
PktSrcEnum
Definition decode.h:51
void PacketReleaseRefs(Packet *p)
Definition packet.c:70
void SCPacketSetLiveDevice(Packet *p, LiveDevice *device)
Set a packets live device.
Definition packet.c:177
void SCPacketSetTime(Packet *p, SCTime_t ts)
Set the timestamp for a packet.
Definition packet.c:187
void SCPacketSetReleasePacket(Packet *p, void(*ReleasePacket)(Packet *p))
Set a packet release function.
Definition packet.c:172
void PacketReinit(Packet *p)
Recycle a packet structure for reuse.
Definition packet.c:80
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
Definition packet.c:33
void SCPacketSetSource(Packet *p, enum PktSrcEnum source)
Set packet source.
Definition packet.c:192
void SCPacketSetDatalink(Packet *p, int datalink)
Set a packets data link type.
Definition packet.c:182
void PacketDestructor(Packet *p)
Cleanup a packet so that we can free it. No memset needed..
Definition packet.c:159
void PacketInit(Packet *p)
Initialize a packet structure for use.
Definition packet.c:63
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition packet.c:49
void PacketRecycle(Packet *p)
Definition packet.c:150
uint64_t ts