From: Victor Julien Date: Fri, 29 Mar 2024 18:21:44 +0000 (+0100) Subject: decode/pppoe: localize pppoedh pointer X-Git-Tag: suricata-8.0.0-beta1~1372 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2f7d3604b3de2eb87f176a0456898534bde4544;p=thirdparty%2Fsuricata.git decode/pppoe: localize pppoedh pointer Remove from Packet struct as there were no users of it. Ticket: #6938. --- diff --git a/src/decode-pppoe.c b/src/decode-pppoe.c index 9d54d70e51..0886cad9a3 100644 --- a/src/decode-pppoe.c +++ b/src/decode-pppoe.c @@ -59,28 +59,27 @@ int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, return TM_ECODE_FAILED; } - p->pppoedh = (PPPOEDiscoveryHdr *)pkt; + PPPOEDiscoveryHdr *pppoedh = (PPPOEDiscoveryHdr *)pkt; /* parse the PPPOE code */ - switch (p->pppoedh->pppoe_code) - { - case PPPOE_CODE_PADI: + switch (pppoedh->pppoe_code) { + case PPPOE_CODE_PADI: break; - case PPPOE_CODE_PADO: + case PPPOE_CODE_PADO: break; - case PPPOE_CODE_PADR: + case PPPOE_CODE_PADR: break; case PPPOE_CODE_PADS: break; case PPPOE_CODE_PADT: break; default: - SCLogDebug("unknown PPPOE code: 0x%0"PRIX8"", p->pppoedh->pppoe_code); + SCLogDebug("unknown PPPOE code: 0x%0" PRIX8 "", pppoedh->pppoe_code); ENGINE_SET_INVALID_EVENT(p, PPPOE_WRONG_CODE); return TM_ECODE_OK; } - uint32_t pppoe_length = SCNtohs(p->pppoedh->pppoe_length); + uint32_t pppoe_length = SCNtohs(pppoedh->pppoe_length); uint32_t packet_length = len - PPPOE_DISCOVERY_HEADER_MIN_LEN ; SCLogDebug("pppoe_length %"PRIu32", packet_length %"PRIu32"", @@ -318,7 +317,6 @@ static int DecodePPPOEtest02 (void) */ static int DecodePPPOEtest03 (void) { - /* example PADO packet taken from RFC2516 */ uint8_t raw_pppoe[] = { 0x11, 0x07, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01, @@ -336,8 +334,8 @@ static int DecodePPPOEtest03 (void) memset(&tv, 0, sizeof(ThreadVars)); memset(&dtv, 0, sizeof(DecodeThreadVars)); - DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); - FAIL_IF_NULL(p->pppoedh); + int r = DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); + FAIL_IF_NOT(r == TM_ECODE_OK); SCFree(p); PASS; diff --git a/src/decode.h b/src/decode.h index 7b1f4bea36..439937fb52 100644 --- a/src/decode.h +++ b/src/decode.h @@ -87,7 +87,6 @@ enum PktSrcEnum { #include "decode-ethernet.h" #include "decode-gre.h" #include "decode-ppp.h" -#include "decode-pppoe.h" #include "decode-ipv4.h" #include "decode-ipv6.h" #include "decode-icmpv4.h" @@ -583,7 +582,6 @@ typedef struct Packet_ TCPHdr *tcph; UDPHdr *udph; - PPPOEDiscoveryHdr *pppoedh; /* ptr to the payload of the packet * with it's length. */ diff --git a/src/packet.c b/src/packet.c index 256cf78109..76c636f53f 100644 --- a/src/packet.c +++ b/src/packet.c @@ -121,7 +121,6 @@ void PacketReinit(Packet *p) if (p->udph != NULL) { CLEAR_UDP_PACKET(p); } - p->pppoedh = NULL; p->payload = NULL; p->payload_len = 0; p->BypassPacketsFlow = NULL; diff --git a/src/runmode-unittests.c b/src/runmode-unittests.c index c854e8ecf1..fb5b4f1bc0 100644 --- a/src/runmode-unittests.c +++ b/src/runmode-unittests.c @@ -108,6 +108,7 @@ #include "decode-chdlc.h" #include "decode-geneve.h" #include "decode-nsh.h" +#include "decode-pppoe.h" #include "decode-raw.h" #include "decode-vntag.h" #include "decode-vxlan.h"