45 const uint8_t *pkt, uint32_t
len, uint16_t proto_offset)
47 const uint32_t data_offset = proto_offset + 1;
48 switch (*(pkt + proto_offset)) {
55 uint16_t iplen = (uint16_t)
MIN((uint32_t)USHRT_MAX,
len - data_offset);
64 uint16_t iplen = (uint16_t)
MIN((uint32_t)USHRT_MAX,
len - data_offset);
91 const uint8_t *pkt, uint32_t
len,
const uint16_t
proto,
const uint32_t data_offset)
184 uint16_t proto_offset = 0;
195 uint8_t proto_byte = *(pkt + proto_offset);
197 if (proto_byte & 0x01) {
206 if (!PacketIncreaseCheckLayers(p)) {
210 const uint32_t data_offset = proto_offset +
proto_size;
211 if (data_offset != 4) {
213 return DecodePPPCompressedProto(
tv,
dtv, p, pkt,
len, proto_offset);
215 const uint16_t
proto =
SCNtohs(*(uint16_t *)(pkt + proto_offset));
216 return DecodePPPUncompressedProto(
tv,
dtv, p, pkt,
len,
proto, data_offset);
221 const PPPHdr *ppph = (PPPHdr *)pkt;
223 "p %p pkt %p PPP protocol %04x Len: %" PRIu32
"", p, pkt,
SCNtohs(ppph->protocol),
len);
224 return DecodePPPUncompressedProto(
tv,
dtv, p, pkt,
len,
SCNtohs(ppph->protocol), data_offset);
234static int DecodePPPtest01 (
void)
236 uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 };
263static int DecodePPPtest02 (
void)
265 uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0xff, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
266 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
267 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
268 0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
269 0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
298static int DecodePPPtest03 (
void)
300 uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
301 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
302 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
303 0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
304 0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
351static int DecodePPPtest04 (
void)
353 uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
354 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
355 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
356 0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
357 0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
#define IPV4_GET_RAW_VER(ip4h)
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
void DecodePPPRegisterTests(void)
#define ENGINE_SET_INVALID_EVENT(p, e)
#define ENGINE_ISSET_EVENT(p, e)
#define ENGINE_SET_EVENT(p, e)
void FlowInitConfig(bool quiet)
initialize the configuration
void FlowShutdown(void)
shutdown the flow engine
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Structure to hold thread specific data for all decode modules.
Per thread variable structure.
#define DEBUG_VALIDATE_BUG_ON(exp)