suricata
decode-pppoe.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2021 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 /**
19  * \ingroup decode
20  *
21  * @{
22  */
23 
24 /**
25  * \file
26  *
27  * \author James Riden <jamesr@europe.com>
28  *
29  * PPPOE Decoder
30  */
31 
32 #include "suricata-common.h"
33 
34 #include "packet-queue.h"
35 
36 #include "decode.h"
37 #include "decode-ppp.h"
38 #include "decode-pppoe.h"
39 #include "decode-events.h"
40 #include "flow.h"
41 
42 #include "util-validate.h"
43 #include "util-unittest.h"
44 #include "util-debug.h"
45 
46 /**
47  * \brief Main decoding function for PPPOE Discovery packets
48  */
50  ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
51 {
52  DEBUG_VALIDATE_BUG_ON(pkt == NULL);
53 
55 
58  return TM_ECODE_FAILED;
59  }
60 
61  PPPOEDiscoveryHdr *pppoedh = (PPPOEDiscoveryHdr *)pkt;
62 
63  /* parse the PPPOE code */
64  switch (pppoedh->pppoe_code) {
65  case PPPOE_CODE_PADI:
66  break;
67  case PPPOE_CODE_PADO:
68  break;
69  case PPPOE_CODE_PADR:
70  break;
71  case PPPOE_CODE_PADS:
72  break;
73  case PPPOE_CODE_PADT:
74  break;
75  default:
76  SCLogDebug("unknown PPPOE code: 0x%0" PRIX8 "", pppoedh->pppoe_code);
78  return TM_ECODE_OK;
79  }
80 
81  uint32_t pppoe_length = SCNtohs(pppoedh->pppoe_length);
82  uint32_t packet_length = len - PPPOE_DISCOVERY_HEADER_MIN_LEN;
83 
84  SCLogDebug("pppoe_length %" PRIu32 ", packet_length %" PRIu32 "", pppoe_length, packet_length);
85 
86  if (pppoe_length > packet_length) {
87  SCLogDebug("malformed PPPOE tags");
89  return TM_ECODE_OK;
90  }
91 
92 #ifdef DEBUG
93  /* parse any tags we have in the packet */
94 
95  uint32_t tag_length = 0;
96  const uint8_t *pkt_pppoedt = pkt + PPPOE_DISCOVERY_HEADER_MIN_LEN;
97 
98  // packet_length >= pppoe_length so we have enough data
99  while (pppoe_length >= sizeof(PPPOEDiscoveryTag)) {
100  PPPOEDiscoveryTag *pppoedt = (PPPOEDiscoveryTag *)pkt_pppoedt;
101  uint16_t tag_type = SCNtohs(pppoedt->pppoe_tag_type);
102  // upgrade to u32 to avoid u16 overflow
103  tag_length = SCNtohs(pppoedt->pppoe_tag_length);
104 
105  SCLogDebug("PPPoE Tag type %x, length %" PRIu32, tag_type, tag_length);
106 
107  if (pppoe_length >= (4 + tag_length)) {
108  pppoe_length -= (4 + tag_length);
109  pkt_pppoedt = pkt_pppoedt + (4 + tag_length);
110  } else {
111  pppoe_length = 0; // don't want an underflow
112  }
113  }
114 #endif
115 
116  return TM_ECODE_OK;
117 }
118 
119 /**
120  * \brief Main decoding function for PPPOE Session packets
121  */
123  ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
124 {
125  DEBUG_VALIDATE_BUG_ON(pkt == NULL);
126 
128 
131  return TM_ECODE_FAILED;
132  }
133 
134  PPPOESessionHdr *pppoesh = (PPPOESessionHdr *)pkt;
135 
136  SCLogDebug("PPPOE VERSION %" PRIu32 " TYPE %" PRIu32 " CODE %" PRIu32 " SESSIONID %" PRIu32
137  " LENGTH %" PRIu32 "",
139  pppoesh->pppoe_code, SCNtohs(pppoesh->session_id), SCNtohs(pppoesh->pppoe_length));
140 
141  /* can't use DecodePPP() here because we only get a single 2-byte word to indicate protocol
142  * instead of the full PPP header */
143  if (SCNtohs(pppoesh->pppoe_length) > 0) {
144  /* decode contained PPP packet */
145 
146  uint8_t pppoesh_len;
147  uint16_t ppp_protocol;
148  /* RFC1661: if LSB of the first protocol octet is set, it is a single-octet field. */
149  const uint8_t proto_hi = pkt[PPPOE_SESSION_HEADER_MIN_LEN - 1];
150  if (proto_hi & 0x01) {
151  /* Single-octet variant */
152  ppp_protocol = proto_hi;
153  pppoesh_len = PPPOE_SESSION_HEADER_MIN_LEN;
154  } else {
155  /* Double-octet variant; need one more byte */
156  pppoesh_len = PPPOE_SESSION_HEADER_MIN_LEN + 1;
157  if (len < pppoesh_len) {
159  return TM_ECODE_FAILED;
160  }
161  ppp_protocol =
162  (uint16_t)(((uint16_t)proto_hi << 8) | pkt[PPPOE_SESSION_HEADER_MIN_LEN]);
163  }
164 
165  SCLogDebug("Protocol %" PRIu16 " len %" PRIu8 "", ppp_protocol, pppoesh_len);
166 
167  switch (ppp_protocol) {
168  case PPP_VJ_COMP:
169  case PPP_IPX:
170  case PPP_OSI:
171  case PPP_NS:
172  case PPP_DECNET:
173  case PPP_APPLE:
174  case PPP_BRPDU:
175  case PPP_STII:
176  case PPP_VINES:
177  case PPP_HELLO:
178  case PPP_LUXCOM:
179  case PPP_SNS:
180  case PPP_MPLS_UCAST:
181  case PPP_MPLS_MCAST:
182  case PPP_OSICP:
183  case PPP_NSCP:
184  case PPP_DECNETCP:
185  case PPP_APPLECP:
186  case PPP_IPXCP:
187  case PPP_STIICP:
188  case PPP_VINESCP:
189  case PPP_MPLSCP:
191  break;
192 
193  case PPP_IPCP:
194  case PPP_IPV6CP:
195  case PPP_LCP:
196  case PPP_PAP:
197  case PPP_CHAP:
198  case PPP_CCP:
199  case PPP_LQM:
200  case PPP_CBCP:
201  case PPP_COMP_DGRAM:
202  case PPP_CDPCP:
203  /* Valid types to be in PPP but don't inspect validity. */
204  break;
205 
206  case PPP_VJ_UCOMP:
207 
208  if (len - pppoesh_len < IPV4_HEADER_LEN) {
210  return TM_ECODE_OK;
211  }
212  if (unlikely(len - pppoesh_len > USHRT_MAX)) {
213  return TM_ECODE_FAILED;
214  }
215 
216  if (IPV4_GET_RAW_VER((IPV4Hdr *)(pkt + pppoesh_len)) == 4) {
217  DecodeIPV4(tv, dtv, p, pkt + pppoesh_len, (uint16_t)(len - pppoesh_len));
218  }
219  break;
220 
221  case PPP_IP:
222  if (len - pppoesh_len < IPV4_HEADER_LEN) {
224  return TM_ECODE_OK;
225  }
226  if (unlikely(len - pppoesh_len > USHRT_MAX)) {
227  return TM_ECODE_FAILED;
228  }
229  DecodeIPV4(tv, dtv, p, pkt + pppoesh_len, (uint16_t)(len - pppoesh_len));
230  break;
231 
232  /* PPP IPv6 was not tested */
233  case PPP_IPV6:
234  if (len - pppoesh_len < IPV6_HEADER_LEN) {
236  return TM_ECODE_OK;
237  }
238  DecodeIPV6(tv, dtv, p, pkt + pppoesh_len, len - pppoesh_len);
239  break;
240 
241  default:
242  SCLogDebug("unknown PPP protocol: %" PRIx32 "", ppp_protocol);
244  return TM_ECODE_OK;
245  }
246  }
247  return TM_ECODE_OK;
248 }
249 
250 #ifdef UNITTESTS
251 /** DecodePPPOEtest01
252  * \brief Decode malformed PPPOE packet (too short)
253  * \retval 1 Expected test value
254  */
255 static int DecodePPPOEtest01(void)
256 {
257 
258  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 };
260  FAIL_IF_NULL(p);
261  ThreadVars tv;
263 
264  memset(&tv, 0, sizeof(ThreadVars));
265  memset(&dtv, 0, sizeof(DecodeThreadVars));
266 
267  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
268 
270 
271  PacketFree(p);
272  PASS;
273 }
274 
275 /** DecodePPPOEtest02
276  * \brief Valid PPPOE packet - check the invalid ICMP type encapsulated is flagged
277  * \retval 0 Expected test value
278  */
279 static int DecodePPPOEtest02(void)
280 {
281 
282  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x01, 0x00, 0x40, 0x00, 0x21, 0x45, 0x00, 0x00, 0x3c,
283  0x05, 0x5c, 0x00, 0x00, 0x20, 0x01, 0xff, 0x30, 0xc0, 0xa8, 0x0a, 0x7f, 0xc0, 0xa8, 0x0a,
284  0x65, 0xab, 0xcd, 0x16, 0x5e, 0x02, 0x00, 0x37, 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
285  0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
286  0x56, 0x57, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49 };
287 
289  FAIL_IF_NULL(p);
290  ThreadVars tv;
292 
293  memset(&tv, 0, sizeof(ThreadVars));
294  memset(&dtv, 0, sizeof(DecodeThreadVars));
295 
297 
298  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
299 
301 
302  // and we insist that the invalid ICMP encapsulated (type 0xab, code 0xcd) is flagged
304 
305  FlowShutdown();
306  PacketFree(p);
307  PASS;
308 }
309 
310 /** DecodePPPOEtest03
311  * \brief Valid example PADO packet PPPOE packet taken from RFC2516
312  * \retval 0 Expected test value
313  */
314 static int DecodePPPOEtest03(void)
315 {
316  /* example PADO packet taken from RFC2516 */
317  uint8_t raw_pppoe[] = { 0x11, 0x07, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02,
318  0x00, 0x18, 0x47, 0x6f, 0x20, 0x52, 0x65, 0x64, 0x42, 0x61, 0x63, 0x6b, 0x20, 0x2d, 0x20,
319  0x65, 0x73, 0x68, 0x73, 0x68, 0x65, 0x73, 0x68, 0x6f, 0x6f, 0x74 };
320 
322  FAIL_IF_NULL(p);
323  ThreadVars tv;
325 
326  memset(&tv, 0, sizeof(ThreadVars));
327  memset(&dtv, 0, sizeof(DecodeThreadVars));
328 
329  int r = DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
330  FAIL_IF_NOT(r == TM_ECODE_OK);
331 
332  PacketFree(p);
333  PASS;
334 }
335 
336 /** DecodePPPOEtest04
337  * \brief Valid example PPPOE packet taken from RFC2516 - but with wrong PPPOE code
338  * \retval 1 Expected test value
339  */
340 static int DecodePPPOEtest04(void)
341 {
342 
343  /* example PADI packet taken from RFC2516, but with wrong code */
344  uint8_t raw_pppoe[] = { 0x11, 0xbb, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x00, 0x00 };
345 
347  FAIL_IF_NULL(p);
348  ThreadVars tv;
350 
351  memset(&tv, 0, sizeof(ThreadVars));
352  memset(&dtv, 0, sizeof(DecodeThreadVars));
353 
354  DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
355 
357 
358  PacketFree(p);
359  PASS;
360 }
361 
362 /** DecodePPPOEtest05
363  * \brief Valid example PADO PPPOE packet taken from RFC2516, but too short for given length
364  * \retval 0 Expected test value
365  */
366 static int DecodePPPOEtest05(void)
367 {
368 
369  /* example PADI packet taken from RFC2516 */
370  uint8_t raw_pppoe[] = { 0x11, 0x07, 0x00, 0x00, 0x00, 0x20, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02,
371  0x00, 0x18, 0x47, 0x6f, 0x20, 0x52, 0x65, 0x64, 0x42, 0x61, 0x63, 0x6b, 0x20, 0x2d, 0x20,
372  0x65, 0x73, 0x68, 0x73, 0x68 };
373 
375  FAIL_IF_NULL(p);
376  ThreadVars tv;
378 
379  memset(&tv, 0, sizeof(ThreadVars));
380  memset(&dtv, 0, sizeof(DecodeThreadVars));
381 
382  DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
383 
385 
386  PacketFree(p);
387  PASS;
388 }
389 
390 /** DecodePPPOEtest06
391  * \brief Check that the macros work as expected. Type and version are
392  * fields of 4 bits length. So they are sharing the same var and the macros
393  * should extract the first 4 bits for version and the second 4 bits for type
394  * \retval 1 Expected test value
395  */
396 static int DecodePPPOEtest06(void)
397 {
398 
399  PPPOESessionHdr pppoesh;
400  PPPOEDiscoveryHdr pppoedh;
401  pppoesh.pppoe_version_type = 0xAB;
402  pppoedh.pppoe_version_type = 0xCD;
403 
404  FAIL_IF(PPPOE_SESSION_GET_VERSION(&pppoesh) != 0x0A);
405  FAIL_IF(PPPOE_SESSION_GET_TYPE(&pppoesh) != 0x0B);
406  FAIL_IF(PPPOE_DISCOVERY_GET_VERSION(&pppoedh) != 0x0C);
407  FAIL_IF(PPPOE_DISCOVERY_GET_TYPE(&pppoedh) != 0x0D);
408  PASS;
409 }
410 
411 /** DecodePPPOEtest07
412  * \brief Valid PPPOE packet with 8 bit protocol field - check the valid ICMP type is accepted
413  * \retval 1 Expected test value
414  */
415 static int DecodePPPOEtest07(void)
416 {
417 
418  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x1c, 0x21, 0x45, 0x00, 0x00, 0x1d, 0x97,
419  0xc3, 0x00, 0x00, 0x40, 0x01, 0x47, 0x0f, 0x0a, 0x64, 0x00, 0x00, 0xc0, 0xa8, 0xd1, 0x01,
420  0x08, 0x00, 0xd4, 0x4c, 0x1f, 0x32, 0x04, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421  0x00, 0x00, 0x00, 0x00 };
422 
424  FAIL_IF_NULL(p);
425  ThreadVars tv;
427 
428  memset(&tv, 0, sizeof(ThreadVars));
429  memset(&dtv, 0, sizeof(DecodeThreadVars));
430 
431  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
432 
434  PacketFree(p);
435  PASS;
436 }
437 
438 /** DecodePPPOEtest08
439  * \brief Valid PPPOE packet with 8 bit protocol field - check the valid HTTP type is accepted
440  * \retval 1 Expected test value
441  */
442 static int DecodePPPOEtest08(void)
443 {
444 
445  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x3d, 0x21, 0x45, 0x00, 0x00, 0x3c, 0x00,
446  0x00, 0x40, 0x00, 0x40, 0x06, 0xed, 0xda, 0x0a, 0x64, 0x00, 0x00, 0x8e, 0xfa, 0xb3, 0x83,
447  0xde, 0xb5, 0x00, 0x50, 0xd4, 0xbd, 0x76, 0x54, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0xfe,
448  0xcc, 0x74, 0x2f, 0x00, 0x00, 0x02, 0x04, 0x05, 0xac, 0x01, 0x03, 0x03, 0x07, 0x04, 0x02,
449  0x08, 0x0a, 0xcb, 0xae, 0x92, 0x63, 0x00, 0x00, 0x00, 0x00 };
450 
452  FAIL_IF_NULL(p);
453  ThreadVars tv;
455 
456  memset(&tv, 0, sizeof(ThreadVars));
457  memset(&dtv, 0, sizeof(DecodeThreadVars));
458 
459  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
460 
462  PacketFree(p);
463  PASS;
464 }
465 
466 /** DecodePPPOEtest09
467  * \brief Valid PPPOE packet with 16 bit protocol field - check the valid ICMP type is accepted
468  * \retval 1 Expected test value
469  */
470 static int DecodePPPOEtest09(void)
471 {
472 
473  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x1c, 0x00, 0x21, 0x45, 0x00, 0x00, 0x1d,
474  0x97, 0xc3, 0x00, 0x00, 0x40, 0x01, 0x47, 0x0f, 0x0a, 0x64, 0x00, 0x00, 0xc0, 0xa8, 0xd1,
475  0x01, 0x08, 0x00, 0xd4, 0x4c, 0x1f, 0x32, 0x04, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476  0x00, 0x00, 0x00, 0x00, 0x00 };
477 
479  FAIL_IF_NULL(p);
480  ThreadVars tv;
482 
483  memset(&tv, 0, sizeof(ThreadVars));
484  memset(&dtv, 0, sizeof(DecodeThreadVars));
485 
486  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
487 
489  PacketFree(p);
490  PASS;
491 }
492 
493 /** DecodePPPOEtest10
494  * \brief Valid PPPOE packet with 16 bit protocol field - check the valid HTTP type is accepted
495  * \retval 1 Expected test value
496  */
497 static int DecodePPPOEtest10(void)
498 {
499 
500  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x3d, 0x00, 0x21, 0x45, 0x00, 0x00, 0x3c,
501  0x00, 0x00, 0x40, 0x00, 0x40, 0x06, 0xed, 0xda, 0x0a, 0x64, 0x00, 0x00, 0x8e, 0xfa, 0xb3,
502  0x83, 0xde, 0xb5, 0x00, 0x50, 0xd4, 0xbd, 0x76, 0x54, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
503  0xfe, 0xcc, 0x74, 0x2f, 0x00, 0x00, 0x02, 0x04, 0x05, 0xac, 0x01, 0x03, 0x03, 0x07, 0x04,
504  0x02, 0x08, 0x0a, 0xcb, 0xae, 0x92, 0x63, 0x00, 0x00, 0x00, 0x00 };
505 
507  FAIL_IF_NULL(p);
508  ThreadVars tv;
510 
511  memset(&tv, 0, sizeof(ThreadVars));
512  memset(&dtv, 0, sizeof(DecodeThreadVars));
513 
514  DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
515 
517  PacketFree(p);
518  PASS;
519 }
520 
521 /**
522  * \brief PPPOE session packet of exactly PPPOE_SESSION_HEADER_MIN_LEN bytes with a
523  * double-octet protocol field, so packet is too small.
524  */
525 static int DecodePPPOEtest11(void)
526 {
527  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x01, 0x00 };
529  FAIL_IF_NULL(p);
530  ThreadVars tv;
532 
533  memset(&tv, 0, sizeof(ThreadVars));
534  memset(&dtv, 0, sizeof(DecodeThreadVars));
535 
536  int ret = DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
537  FAIL_IF(ret != TM_ECODE_FAILED);
539 
540  PacketFree(p);
541  PASS;
542 }
543 
544 /**
545  * \brief PPPOE session packet of exactly PPPOE_SESSION_HEADER_MIN_LEN bytes with a
546  * single-octet protocol field (PPP_IP)
547  */
548 static int DecodePPPOEtest12(void)
549 {
550  uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x2d, 0x00, 0x01, 0x21 };
552  FAIL_IF_NULL(p);
553  ThreadVars tv;
555 
556  memset(&tv, 0, sizeof(ThreadVars));
557  memset(&dtv, 0, sizeof(DecodeThreadVars));
558 
559  int ret = DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
560  FAIL_IF(ret != TM_ECODE_OK);
563 
564  PacketFree(p);
565  PASS;
566 }
567 #endif /* UNITTESTS */
568 
569 /**
570  * \brief Registers PPPOE unit tests
571  * \todo More PPPOE tests
572  */
574 {
575 #ifdef UNITTESTS
576  UtRegisterTest("DecodePPPOEtest01", DecodePPPOEtest01);
577  UtRegisterTest("DecodePPPOEtest02", DecodePPPOEtest02);
578  UtRegisterTest("DecodePPPOEtest03", DecodePPPOEtest03);
579  UtRegisterTest("DecodePPPOEtest04", DecodePPPOEtest04);
580  UtRegisterTest("DecodePPPOEtest05", DecodePPPOEtest05);
581  UtRegisterTest("DecodePPPOEtest06", DecodePPPOEtest06);
582  UtRegisterTest("DecodePPPOEtest07", DecodePPPOEtest07);
583  UtRegisterTest("DecodePPPOEtest08", DecodePPPOEtest08);
584  UtRegisterTest("DecodePPPOEtest09", DecodePPPOEtest09);
585  UtRegisterTest("DecodePPPOEtest10", DecodePPPOEtest10);
586  UtRegisterTest("DecodePPPOEtest11", DecodePPPOEtest11);
587  UtRegisterTest("DecodePPPOEtest12", DecodePPPOEtest12);
588 #endif /* UNITTESTS */
589 }
590 
591 /**
592  * @}
593  */
ENGINE_SET_EVENT
#define ENGINE_SET_EVENT(p, e)
Definition: decode.h:1231
PPP_MPLS_MCAST
#define PPP_MPLS_MCAST
Definition: decode-ppp.h:47
PPPVJU_PKT_TOO_SMALL
@ PPPVJU_PKT_TOO_SMALL
Definition: decode-events.h:124
len
uint8_t len
Definition: app-layer-dnp3.h:2
PPP_PAP
#define PPP_PAP
Definition: decode-ppp.h:60
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
PPPOE_SESSION_HEADER_MIN_LEN
#define PPPOE_SESSION_HEADER_MIN_LEN
Definition: decode-pppoe.h:28
PPP_HELLO
#define PPP_HELLO
Definition: decode-ppp.h:43
PPPOE_CODE_PADS
#define PPPOE_CODE_PADS
Definition: decode-pppoe.h:59
PPP_LQM
#define PPP_LQM
Definition: decode-ppp.h:61
decode-pppoe.h
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
PPP_SNS
#define PPP_SNS
Definition: decode-ppp.h:45
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
PPPOESessionHdr_
Definition: decode-pppoe.h:35
PPP_CDPCP
#define PPP_CDPCP
Definition: decode-ppp.h:57
ENGINE_ISSET_EVENT
#define ENGINE_ISSET_EVENT(p, e)
Definition: decode.h:1244
PPP_COMP_DGRAM
#define PPP_COMP_DGRAM
Definition: decode-ppp.h:65
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
PPP_NSCP
#define PPP_NSCP
Definition: decode-ppp.h:50
PPP_VINES
#define PPP_VINES
Definition: decode-ppp.h:42
PPP_CBCP
#define PPP_CBCP
Definition: decode-ppp.h:64
PPPOESessionHdr_::session_id
uint16_t session_id
Definition: decode-pppoe.h:38
packet-queue.h
DecodeThreadVars_::counter_pppoe
StatsCounterId counter_pppoe
Definition: decode.h:1046
PPP_IP
#define PPP_IP
Definition: decode-ppp.h:28
PPPOE_SESSION_GET_TYPE
#define PPPOE_SESSION_GET_TYPE(hdr)
Definition: decode-pppoe.h:31
p
Packet * p
Definition: fuzz_iprep.c:21
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
PPP_WRONG_TYPE
@ PPP_WRONG_TYPE
Definition: decode-events.h:127
ICMPV4_UNKNOWN_TYPE
@ ICMPV4_UNKNOWN_TYPE
Definition: decode-events.h:53
PPP_BRPDU
#define PPP_BRPDU
Definition: decode-ppp.h:40
util-unittest.h
FAIL_IF_NOT
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
Definition: util-unittest.h:82
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
PPP_LUXCOM
#define PPP_LUXCOM
Definition: decode-ppp.h:44
FlowInitConfig
void FlowInitConfig(bool quiet)
initialize the configuration
Definition: flow.c:576
decode.h
util-debug.h
PPP_STIICP
#define PPP_STIICP
Definition: decode-ppp.h:54
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
PPP_IPX
#define PPP_IPX
Definition: decode-ppp.h:35
PPPIPV4_PKT_TOO_SMALL
@ PPPIPV4_PKT_TOO_SMALL
Definition: decode-events.h:125
decode-ppp.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
PPP_IPCP
#define PPP_IPCP
Definition: decode-ppp.h:48
PPPOE_SESSION_GET_VERSION
#define PPPOE_SESSION_GET_VERSION(hdr)
Definition: decode-pppoe.h:30
StatsCounterIncr
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
Definition: counters.c:164
PacketFree
void PacketFree(Packet *p)
Return a malloced packet.
Definition: decode.c:221
PPPOE_WRONG_CODE
@ PPPOE_WRONG_CODE
Definition: decode-events.h:132
PPP_VJ_COMP
#define PPP_VJ_COMP
Definition: decode-ppp.h:34
PPP_VINESCP
#define PPP_VINESCP
Definition: decode-ppp.h:55
PPP_MPLSCP
#define PPP_MPLSCP
Definition: decode-ppp.h:58
PPPOE_PKT_TOO_SMALL
@ PPPOE_PKT_TOO_SMALL
Definition: decode-events.h:131
pppoe_length
uint16_t pppoe_length
Definition: decode-pppoe.h:3
PPPOE_CODE_PADI
#define PPPOE_CODE_PADI
Definition: decode-pppoe.h:56
Packet_
Definition: decode.h:516
PPPOE_CODE_PADT
#define PPPOE_CODE_PADT
Definition: decode-pppoe.h:60
IPV4_GET_RAW_VER
#define IPV4_GET_RAW_VER(ip4h)
Definition: decode-ipv4.h:95
PPP_DECNETCP
#define PPP_DECNETCP
Definition: decode-ppp.h:51
DecodeIPV6
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-ipv6.c:551
decode-events.h
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:35
IPV4Hdr_
Definition: decode-ipv4.h:72
DecodePPPOEDiscovery
int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Main decoding function for PPPOE Discovery packets.
Definition: decode-pppoe.c:49
PPP_APPLE
#define PPP_APPLE
Definition: decode-ppp.h:39
PPPOE_DISCOVERY_GET_TYPE
#define PPPOE_DISCOVERY_GET_TYPE(hdr)
Definition: decode-pppoe.h:33
FAIL_IF
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Definition: util-unittest.h:71
SCNtohs
#define SCNtohs(x)
Definition: suricata-common.h:439
suricata-common.h
PPPOE_DISCOVERY_GET_VERSION
#define PPPOE_DISCOVERY_GET_VERSION(hdr)
Definition: decode-pppoe.h:32
FlowShutdown
void FlowShutdown(void)
shutdown the flow engine
Definition: flow.c:720
PPP_MPLS_UCAST
#define PPP_MPLS_UCAST
Definition: decode-ppp.h:46
IPV4_HEADER_LEN
#define IPV4_HEADER_LEN
Definition: decode-ipv4.h:28
DecodePPPOERegisterTests
void DecodePPPOERegisterTests(void)
Registers PPPOE unit tests.
Definition: decode-pppoe.c:573
PPP_CCP
#define PPP_CCP
Definition: decode-ppp.h:63
PPP_NS
#define PPP_NS
Definition: decode-ppp.h:37
PPP_DECNET
#define PPP_DECNET
Definition: decode-ppp.h:38
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
PPPOESessionHdr_::pppoe_code
uint8_t pppoe_code
Definition: decode-pppoe.h:37
util-validate.h
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:260
PPP_UNSUP_PROTO
@ PPP_UNSUP_PROTO
Definition: decode-events.h:128
PPP_IPV6
#define PPP_IPV6
Definition: decode-ppp.h:29
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:995
PPPOE_CODE_PADO
#define PPPOE_CODE_PADO
Definition: decode-pppoe.h:57
DecodePPPOESession
int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Main decoding function for PPPOE Session packets.
Definition: decode-pppoe.c:122
PPPOE_DISCOVERY_HEADER_MIN_LEN
#define PPPOE_DISCOVERY_HEADER_MIN_LEN
Definition: decode-pppoe.h:29
PPP_STII
#define PPP_STII
Definition: decode-ppp.h:41
PPP_CHAP
#define PPP_CHAP
Definition: decode-ppp.h:62
PPP_APPLECP
#define PPP_APPLECP
Definition: decode-ppp.h:52
PPPIPV6_PKT_TOO_SMALL
@ PPPIPV6_PKT_TOO_SMALL
Definition: decode-events.h:126
ENGINE_SET_INVALID_EVENT
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition: decode.h:1239
FLOW_QUIET
#define FLOW_QUIET
Definition: flow.h:44
PPP_IPXCP
#define PPP_IPXCP
Definition: decode-ppp.h:53
PPPOESessionHdr_::pppoe_length
uint16_t pppoe_length
Definition: decode-pppoe.h:39
IPV6_HEADER_LEN
#define IPV6_HEADER_LEN
Definition: decode-ipv6.h:27
PPP_VJ_UCOMP
#define PPP_VJ_UCOMP
Definition: decode-ppp.h:30
PPPOE_CODE_PADR
#define PPPOE_CODE_PADR
Definition: decode-pppoe.h:58
flow.h
DecodeIPV4
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
Definition: decode-ipv4.c:515
PPP_IPV6CP
#define PPP_IPV6CP
Definition: decode-ppp.h:56
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:121
PPPOESessionHdr_::pppoe_version_type
uint8_t pppoe_version_type
Definition: decode-pppoe.h:36
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
PPP_OSI
#define PPP_OSI
Definition: decode-ppp.h:36
PPP_OSICP
#define PPP_OSICP
Definition: decode-ppp.h:49
PPP_LCP
#define PPP_LCP
Definition: decode-ppp.h:59
PPPOE_MALFORMED_TAGS
@ PPPOE_MALFORMED_TAGS
Definition: decode-events.h:133