]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lib: remove TmModuleLibHandlePacket
authorJason Ish <jason.ish@oisf.net>
Mon, 7 Oct 2024 22:08:59 +0000 (16:08 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 1 Apr 2025 08:17:05 +0000 (10:17 +0200)
This is better handled directly in the library user program so the
user has more control of the Packet structure, before and after
handling.

Ticket: #7240

src/source-lib.c
src/source-lib.h

index 822d7668f3f1ac62be47d4a372ef162d4944325f..a9d3e9007f1d89683e6ed22f6fc976e9447dae22 100644 (file)
@@ -101,62 +101,6 @@ static TmEcode DecodeLib(ThreadVars *tv, Packet *p, void *data)
     SCReturnInt(TM_ECODE_OK);
 }
 
-/** \brief process a single packet.
- *
- * \param tv                    Pointer to the per-thread structure.
- * \param device                Pionter to LiveDevice instance
- * \param data                  Pointer to the raw packet.
- * \param datalink              Datalink type.
- * \param ts                    Timeval structure.
- * \param len                   Packet length.
- * \param tenant_id             Tenant id of the detection engine to use.
- * \param flags                 Packet flags (packet checksum, rule profiling...).
- * \return                      Error code.
- */
-int TmModuleLibHandlePacket(ThreadVars *tv, LiveDevice *device, const uint8_t *data, int datalink,
-        struct timeval ts, uint32_t len, uint32_t tenant_id, uint32_t flags)
-{
-
-    /* If the packet is NULL, consider it as a read timeout. */
-    if (data == NULL) {
-        TmThreadsSetFlag(tv, THV_CAPTURE_INJECT_PKT);
-        TmThreadsCaptureHandleTimeout(tv, NULL);
-        SCReturnInt(TM_ECODE_OK);
-    }
-
-    Packet *p = PacketGetFromQueueOrAlloc();
-    if (unlikely(p == NULL)) {
-        SCReturnInt(TM_ECODE_FAILED);
-    }
-
-    /* If we are processing a PCAP and it is the first packet we need to set the timestamp. */
-    SCTime_t timestamp = SCTIME_FROM_TIMEVAL(&ts);
-    if (!time_set && !TimeModeIsLive()) {
-        TmThreadsInitThreadsTimestamp(timestamp);
-        time_set = true;
-    }
-
-    PKT_SET_SRC(p, PKT_SRC_WIRE);
-    p->ts = timestamp;
-    p->datalink = datalink;
-    p->tenant_id = tenant_id;
-    p->flags |= flags;
-    p->livedev = device;
-
-    if (PacketSetData(p, data, len) == -1) {
-        TmqhOutputPacketpool(tv, p);
-        SCReturnInt(TM_ECODE_FAILED);
-    }
-
-    SCLogDebug("pktlen: %" PRIu32 " (pkt %p, pkt data %p)", GET_PKT_LEN(p), p, GET_PKT_DATA(p));
-
-    if (TmThreadsSlotProcessPkt(tv, tv->tm_slots, p) != TM_ECODE_OK) {
-        SCReturnInt(TM_ECODE_FAILED);
-    }
-
-    SCReturnInt(TM_ECODE_OK);
-}
-
 /** \brief register a "Decode" module for suricata as a library.
  *
  *  The "Decode" module is the first module invoked when processing a packet */
index 432f12aa505b931b88a155b210c0ba1172bbb5ea..76cad144e295e4579dc1252eae4694f33fcc9167 100644 (file)
  *  The "Decode" module is the first module invoked when processing a packet */
 void TmModuleDecodeLibRegister(void);
 
-/** \brief process a single packet.
- *
- * \param tv                    Pointer to the per-thread structure.
- * \param data                  Pointer to the raw packet.
- * \param datalink              Datalink type.
- * \param ts                    Timeval structure.
- * \param len                   Packet length.
- * \param tenant_id             Tenant id of the detection engine to use.
- * \param flags                 Packet flags (packet checksum, rule profiling...).
- * \param iface                 Sniffing interface this packet comes from (can be NULL).
- * \return                      Error code.
- */
-int TmModuleLibHandlePacket(ThreadVars *tv, LiveDevice *device, const uint8_t *data, int datalink,
-        struct timeval ts, uint32_t len, uint32_t tenant_id, uint32_t flags);
-
 #endif /* SURICATA_SOURCE_LIB_H */