51 const uint8_t *pkt, uint32_t
len)
62 PPPOEDiscoveryHdr *pppoedh = (PPPOEDiscoveryHdr *)pkt;
65 switch (pppoedh->pppoe_code) {
77 SCLogDebug(
"unknown PPPOE code: 0x%0" PRIX8
"", pppoedh->pppoe_code);
85 SCLogDebug(
"pppoe_length %"PRIu32
", packet_length %"PRIu32
"",
97 uint32_t tag_length = 0;
102 PPPOEDiscoveryTag *pppoedt = (PPPOEDiscoveryTag *)pkt_pppoedt;
103 uint16_t tag_type =
SCNtohs(pppoedt->pppoe_tag_type);
105 tag_length =
SCNtohs(pppoedt->pppoe_tag_length);
107 SCLogDebug (
"PPPoE Tag type %x, length %"PRIu32, tag_type, tag_length);
111 pkt_pppoedt = pkt_pppoedt + (4 + tag_length);
125 const uint8_t *pkt, uint32_t
len)
138 SCLogDebug(
"PPPOE VERSION %" PRIu32
" TYPE %" PRIu32
" CODE %" PRIu32
" SESSIONID %" PRIu32
139 " LENGTH %" PRIu32
"",
152 if (ppp_protocol & 0x0100) {
160 if (
len < pppoesh_len) {
166 SCLogDebug(
"Protocol %" PRIu16
" len %" PRIu8
"", ppp_protocol, pppoesh_len);
168 switch (ppp_protocol) {
240 SCLogDebug(
"unknown PPP protocol: %" PRIx32
"", ppp_protocol);
253static int DecodePPPOEtest01 (
void)
256 uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 };
277static int DecodePPPOEtest02 (
void)
280 uint8_t raw_pppoe[] = {
281 0x11, 0x00, 0x00, 0x01, 0x00, 0x40, 0x00, 0x21,
282 0x45, 0x00, 0x00, 0x3c, 0x05, 0x5c, 0x00, 0x00,
283 0x20, 0x01, 0xff, 0x30, 0xc0, 0xa8, 0x0a, 0x7f,
284 0xc0, 0xa8, 0x0a, 0x65, 0xab, 0xcd, 0x16, 0x5e,
285 0x02, 0x00, 0x37, 0x00, 0x41, 0x42, 0x43, 0x44,
286 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
287 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54,
288 0x55, 0x56, 0x57, 0x41, 0x42, 0x43, 0x44, 0x45,
289 0x46, 0x47, 0x48, 0x49 };
318static int DecodePPPOEtest03 (
void)
321 uint8_t raw_pppoe[] = {
322 0x11, 0x07, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01,
323 0x00, 0x00, 0x01, 0x02, 0x00, 0x18, 0x47, 0x6f,
324 0x20, 0x52, 0x65, 0x64, 0x42, 0x61, 0x63, 0x6b,
325 0x20, 0x2d, 0x20, 0x65, 0x73, 0x68, 0x73, 0x68,
326 0x65, 0x73, 0x68, 0x6f, 0x6f, 0x74
348static int DecodePPPOEtest04 (
void)
352 uint8_t raw_pppoe[] = {
353 0x11, 0xbb, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01,
377static int DecodePPPOEtest05 (
void)
381 uint8_t raw_pppoe[] = {
382 0x11, 0x07, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01,
383 0x00, 0x00, 0x01, 0x02, 0x00, 0x18, 0x47, 0x6f,
384 0x20, 0x52, 0x65, 0x64, 0x42, 0x61, 0x63, 0x6b,
385 0x20, 0x2d, 0x20, 0x65, 0x73, 0x68, 0x73, 0x68
410static int DecodePPPOEtest06 (
void)
414 PPPOEDiscoveryHdr pppoedh;
416 pppoedh.pppoe_version_type = 0xCD;
429static int DecodePPPOEtest07(
void)
432 uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x1c, 0x21, 0x45, 0x00, 0x00, 0x1d, 0x97,
433 0xc3, 0x00, 0x00, 0x40, 0x01, 0x47, 0x0f, 0x0a, 0x64, 0x00, 0x00, 0xc0, 0xa8, 0xd1, 0x01,
434 0x08, 0x00, 0xd4, 0x4c, 0x1f, 0x32, 0x04, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
435 0x00, 0x00, 0x00, 0x00 };
456static int DecodePPPOEtest08(
void)
459 uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x3d, 0x21, 0x45, 0x00, 0x00, 0x3c, 0x00,
460 0x00, 0x40, 0x00, 0x40, 0x06, 0xed, 0xda, 0x0a, 0x64, 0x00, 0x00, 0x8e, 0xfa, 0xb3, 0x83,
461 0xde, 0xb5, 0x00, 0x50, 0xd4, 0xbd, 0x76, 0x54, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0xfe,
462 0xcc, 0x74, 0x2f, 0x00, 0x00, 0x02, 0x04, 0x05, 0xac, 0x01, 0x03, 0x03, 0x07, 0x04, 0x02,
463 0x08, 0x0a, 0xcb, 0xae, 0x92, 0x63, 0x00, 0x00, 0x00, 0x00 };
484static int DecodePPPOEtest09(
void)
487 uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x1c, 0x00, 0x21, 0x45, 0x00, 0x00, 0x1d,
488 0x97, 0xc3, 0x00, 0x00, 0x40, 0x01, 0x47, 0x0f, 0x0a, 0x64, 0x00, 0x00, 0xc0, 0xa8, 0xd1,
489 0x01, 0x08, 0x00, 0xd4, 0x4c, 0x1f, 0x32, 0x04, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 0x00, 0x00, 0x00, 0x00, 0x00 };
511static int DecodePPPOEtest10(
void)
514 uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x3d, 0x00, 0x21, 0x45, 0x00, 0x00, 0x3c,
515 0x00, 0x00, 0x40, 0x00, 0x40, 0x06, 0xed, 0xda, 0x0a, 0x64, 0x00, 0x00, 0x8e, 0xfa, 0xb3,
516 0x83, 0xde, 0xb5, 0x00, 0x50, 0xd4, 0xbd, 0x76, 0x54, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
517 0xfe, 0xcc, 0x74, 0x2f, 0x00, 0x00, 0x02, 0x04, 0x05, 0xac, 0x01, 0x03, 0x03, 0x07, 0x04,
518 0x02, 0x08, 0x0a, 0xcb, 0xae, 0x92, 0x63, 0x00, 0x00, 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 DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Main decoding function for PPPOE Discovery packets.
void DecodePPPOERegisterTests(void)
Registers PPPOE unit tests.
int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Main decoding function for PPPOE Session packets.
#define PPPOE_SESSION_GET_VERSION(hdr)
#define PPPOE_DISCOVERY_HEADER_MIN_LEN
#define PPPOE_SESSION_GET_TYPE(hdr)
#define PPPOE_DISCOVERY_GET_TYPE(hdr)
#define PPPOE_DISCOVERY_GET_VERSION(hdr)
#define PPPOE_SESSION_HEADER_MIN_LEN
#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
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Structure to hold thread specific data for all decode modules.
uint8_t pppoe_version_type
Per thread variable structure.
#define DEBUG_VALIDATE_BUG_ON(exp)