suricata
respond-reject-libnet11.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2023 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  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  * \author William Metcalf <william.metcalf@gmail.com>
23  *
24  * RespondRejectLibnet11 used to send out libnet based
25  * TCP resets and ICMP unreachables.
26  *
27  * \todo calculate TTL base on average from stream tracking
28  * \todo come up with a way for users to specify icmp unreachable type
29  * \todo Possibly default to port unreachable for UDP traffic this seems
30  * to be the default in flexresp and iptables
31  */
32 
33 #include "suricata-common.h"
34 #include "suricata.h"
35 
36 #include "decode.h"
37 #include "decode-ipv4.h"
38 #include "decode-tcp.h"
39 #include "decode-sctp.h"
40 #include "decode-udp.h"
41 #include "packet-queue.h"
42 #include "threads.h"
43 #include "threadvars.h"
44 #include "tm-queuehandlers.h"
45 #include "tm-threads.h"
46 #include "action-globals.h"
47 #include "respond-reject.h"
49 #include "util-device-private.h"
50 
51 #ifdef HAVE_LIBNET11
52 
53 #ifndef HAVE_LIBNET_INIT_CONST
54 #define LIBNET_INIT_CAST (char *)
55 #else
56 #define LIBNET_INIT_CAST
57 #endif
58 
59 /* Globally configured device to use for sending resets in IDS mode. */
60 const char *g_reject_dev = NULL;
61 uint16_t g_reject_dev_mtu = 0;
62 
63 /** set to true in main if we're setting caps. We need it here if we're using
64  * reject rules as libnet 1.1 is not compatible with caps. */
65 extern bool sc_set_caps;
66 
67 #include <libnet.h>
68 
69 thread_local libnet_t *t_c[2] = { NULL, NULL };
70 thread_local int t_inject_mode = -1;
71 
72 typedef struct Libnet11Packet_ {
73  uint32_t ack, seq;
74  uint16_t window, dsize;
75  uint8_t ttl;
76  uint16_t id;
77  uint32_t flow;
78  uint8_t class;
79  struct libnet_in6_addr src6, dst6;
80  uint32_t src4, dst4;
81  uint16_t sp, dp;
82  uint16_t len;
83  const uint8_t *smac, *dmac;
84 } Libnet11Packet;
85 
86 static inline libnet_t *GetCtx(const Packet *p, int injection_type, enum RejectDirection dir)
87 {
88  /* fast path: use cache ctx */
89  if (t_c[dir])
90  return t_c[dir];
91 
92  /* slow path: setup a new ctx */
93  bool store_ctx = false;
94  const char *devname = NULL;
95  if (g_reject_dev != NULL) {
97  injection_type = t_inject_mode = LIBNET_LINK;
98  devname = g_reject_dev;
99  store_ctx = true;
100  SCLogDebug("dedicated dev: devname %s", devname);
101  } else if (EngineHostModeIsSniffer()) {
103  devname = dev ? dev->dev : NULL;
104  SCLogDebug("sniffer: devname %s", devname);
105  } else if (EngineHostModeIsBridge()) {
106  uint16_t livedev_id = (dir == REJECT_DIR_SRC) ? p->livedev_id : p->livedev_dst_id;
107  LiveDevice *dev = LiveDeviceGetById(livedev_id);
108  devname = dev ? dev->dev : NULL;
109  SCLogDebug("bridge: devname %s", devname);
110  store_ctx = true;
111  } else {
112  SCLogDebug("router: devname %s", devname);
113  }
114 
115  char ebuf[LIBNET_ERRBUF_SIZE];
116  libnet_t *c = libnet_init(injection_type, LIBNET_INIT_CAST devname, ebuf);
117  if (c == NULL) {
118  SCLogError("libnet_init failed: %s", ebuf);
119  }
120  if (store_ctx) {
121  t_c[dir] = c;
122  }
123  return c;
124 }
125 
126 static inline void ClearCtx(libnet_t *c, enum RejectDirection dir)
127 {
128  if (t_c[dir] == c)
129  libnet_clear_packet(c);
130  else
131  libnet_destroy(c);
132 }
133 
134 void FreeCachedCtx(void)
135 {
136  if (t_c[0]) {
137  libnet_destroy(t_c[0]);
138  t_c[0] = NULL;
139  }
140  if (t_c[1]) {
141  libnet_destroy(t_c[1]);
142  t_c[1] = NULL;
143  }
144 }
145 
146 static inline void SetupTCP(Packet *p, Libnet11Packet *lpacket, enum RejectDirection dir)
147 {
148  const TCPHdr *tcph = PacketGetTCP(p);
149  switch (dir) {
150  case REJECT_DIR_SRC:
151  SCLogDebug("sending a tcp reset to src");
152  /* We follow http://tools.ietf.org/html/rfc793#section-3.4 :
153  * If packet has no ACK, the seq number is 0 and the ACK is built
154  * the normal way. If packet has a ACK, the seq of the RST packet
155  * is equal to the ACK of incoming packet and the ACK is build
156  * using packet sequence number and size of the data. */
157  if (TCP_GET_RAW_ACK(tcph) == 0) {
158  lpacket->seq = 0;
159  lpacket->ack = TCP_GET_RAW_SEQ(tcph) + lpacket->dsize + 1;
160  } else {
161  lpacket->seq = TCP_GET_RAW_ACK(tcph);
162  lpacket->ack = TCP_GET_RAW_SEQ(tcph) + lpacket->dsize;
163  }
164 
165  lpacket->sp = p->dp;
166  lpacket->dp = p->sp;
167  break;
168  case REJECT_DIR_DST:
169  default:
170  SCLogDebug("sending a tcp reset to dst");
171  lpacket->seq = TCP_GET_RAW_SEQ(tcph);
172  lpacket->ack = TCP_GET_RAW_ACK(tcph);
173 
174  lpacket->sp = p->sp;
175  lpacket->dp = p->dp;
176  break;
177  }
178  lpacket->window = TCP_GET_RAW_WINDOW(tcph);
179  //lpacket.seq += lpacket.dsize;
180 }
181 
182 static inline int BuildTCP(libnet_t *c, Libnet11Packet *lpacket)
183 {
184  /* build the package */
185  if ((libnet_build_tcp(
186  lpacket->sp, /* source port */
187  lpacket->dp, /* dst port */
188  lpacket->seq, /* seq number */
189  lpacket->ack, /* ack number */
190  TH_RST|TH_ACK, /* flags */
191  lpacket->window, /* window size */
192  0, /* checksum */
193  0, /* urgent flag */
194  LIBNET_TCP_H, /* header length */
195  NULL, /* payload */
196  0, /* payload length */
197  c, /* libnet context */
198  0)) < 0) /* libnet ptag */
199  {
200  SCLogError("libnet_build_tcp %s", libnet_geterror(c));
201  return -1;
202  }
203  return 0;
204 }
205 
206 static inline int BuildIPv4(libnet_t *c, Libnet11Packet *lpacket, const uint8_t proto)
207 {
208  if ((libnet_build_ipv4(
209  lpacket->len, /* entire packet length */
210  0, /* tos */
211  lpacket->id, /* ID */
212  0, /* fragmentation flags and offset */
213  lpacket->ttl, /* TTL */
214  proto, /* protocol */
215  0, /* checksum */
216  lpacket->src4, /* source address */
217  lpacket->dst4, /* destination address */
218  NULL, /* pointer to packet data (or NULL) */
219  0, /* payload length */
220  c, /* libnet context pointer */
221  0)) < 0) /* packet id */
222  {
223  SCLogError("libnet_build_ipv4 %s", libnet_geterror(c));
224  return -1;
225  }
226  return 0;
227 }
228 
229 static inline int BuildIPv6(libnet_t *c, Libnet11Packet *lpacket, const uint8_t proto)
230 {
231  if ((libnet_build_ipv6(
232  lpacket->class, /* traffic class */
233  lpacket->flow, /* Flow label */
234  lpacket->len, /* payload length */
235  proto, /* next header */
236  lpacket->ttl, /* TTL */
237  lpacket->src6, /* source address */
238  lpacket->dst6, /* destination address */
239  NULL, /* pointer to packet data (or NULL) */
240  0, /* payload length */
241  c, /* libnet context pointer */
242  0)) < 0) /* packet id */
243  {
244  SCLogError("libnet_build_ipv6 %s", libnet_geterror(c));
245  return -1;
246  }
247  return 0;
248 }
249 
250 static inline void SetupEthernet(Packet *p, Libnet11Packet *lpacket, enum RejectDirection dir)
251 {
252  if (!PacketIsEthernet(p))
253  return;
254  const EthernetHdr *ethh = PacketGetEthernet(p);
255  switch (dir) {
256  case REJECT_DIR_SRC:
257  lpacket->smac = ethh->eth_dst;
258  lpacket->dmac = ethh->eth_src;
259  break;
260  case REJECT_DIR_DST:
261  default:
262  lpacket->smac = ethh->eth_src;
263  lpacket->dmac = ethh->eth_dst;
264  break;
265  }
266 }
267 
268 static inline int BuildEthernet(libnet_t *c, Libnet11Packet *lpacket, uint16_t proto)
269 {
270  if ((libnet_build_ethernet(lpacket->dmac,lpacket->smac, proto , NULL, 0, c, 0)) < 0) {
271  SCLogError("libnet_build_ethernet %s", libnet_geterror(c));
272  return -1;
273  }
274  return 0;
275 }
276 
277 static inline int BuildEthernetVLAN(libnet_t *c, Libnet11Packet *lpacket, uint16_t proto, uint16_t vlan_id)
278 {
279  if (libnet_build_802_1q(lpacket->dmac, lpacket->smac, ETHERTYPE_VLAN, 0, 0, vlan_id, proto,
280  NULL, /* payload */
281  0, /* payload size */
282  c, /* libnet handle */
283  0) < 0) {
284  SCLogError("libnet_build_802_1q %s", libnet_geterror(c));
285  return -1;
286  }
287  return 0;
288 }
289 
290 int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
291 {
292  Libnet11Packet lpacket;
293  int result;
294 
295  /* fill in struct defaults */
296  lpacket.ttl = 0;
297  lpacket.id = 0;
298  lpacket.flow = 0;
299  lpacket.class = 0;
300 
301  if (!PacketIsTCP(p))
302  return 1;
303 
304  libnet_t *c = GetCtx(p, LIBNET_RAW4, dir);
305  if (c == NULL)
306  return 1;
307 
308  lpacket.len = LIBNET_IPV4_H + LIBNET_TCP_H;
309  lpacket.dsize = p->payload_len;
310 
311  switch (dir) {
312  case REJECT_DIR_SRC:
313  lpacket.src4 = GET_IPV4_DST_ADDR_U32(p);
314  lpacket.dst4 = GET_IPV4_SRC_ADDR_U32(p);
315  break;
316  case REJECT_DIR_DST:
317  default:
318  lpacket.src4 = GET_IPV4_SRC_ADDR_U32(p);
319  lpacket.dst4 = GET_IPV4_DST_ADDR_U32(p);
320  break;
321  }
322  /* TODO come up with ttl calc function */
323  lpacket.ttl = 64;
324 
325  SetupTCP(p, &lpacket, dir);
326 
327  if (BuildTCP(c, &lpacket) < 0)
328  goto cleanup;
329 
330  if (BuildIPv4(c, &lpacket, IPPROTO_TCP) < 0)
331  goto cleanup;
332 
333  if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) {
334  SetupEthernet(p, &lpacket, dir);
335 
336  if (p->vlan_idx == 1) {
337  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IP, p->vlan_id[0]) < 0)
338  goto cleanup;
339  } else {
340  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IP) < 0)
341  goto cleanup;
342  }
343  }
344 
345  result = libnet_write(c);
346  if (result == -1) {
347  SCLogError("libnet_write failed: %s", libnet_geterror(c));
348  goto cleanup;
349  }
350 
351 cleanup:
352  ClearCtx(c, dir);
353  return 0;
354 }
355 
356 int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
357 {
358  const IPV4Hdr *ip4h = PacketGetIPv4(p);
359  Libnet11Packet lpacket;
360  int result;
361 
362  /* fill in struct defaults */
363  lpacket.ttl = 0;
364  lpacket.id = 0;
365  lpacket.flow = 0;
366  lpacket.class = 0;
367  const uint16_t iplen = IPV4_GET_RAW_IPLEN(ip4h);
368  if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + LIBNET_IPV4_H + 8) {
369  lpacket.len = MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, (LIBNET_IPV4_H + iplen));
370  } else {
371  lpacket.len = LIBNET_IPV4_H + MIN(8,iplen); // 8 bytes is the minimum we have to attach
372  }
373  lpacket.dsize = lpacket.len - (LIBNET_IPV4_H + LIBNET_ICMPV4_H);
374 
375  libnet_t *c = GetCtx(p, LIBNET_RAW4, dir);
376  if (c == NULL)
377  return 1;
378 
379  switch (dir) {
380  case REJECT_DIR_SRC:
381  lpacket.src4 = GET_IPV4_DST_ADDR_U32(p);
382  lpacket.dst4 = GET_IPV4_SRC_ADDR_U32(p);
383  break;
384  case REJECT_DIR_DST:
385  default:
386  lpacket.src4 = GET_IPV4_SRC_ADDR_U32(p);
387  lpacket.dst4 = GET_IPV4_DST_ADDR_U32(p);
388  break;
389  }
390 
391  /* TODO come up with ttl calc function */
392  lpacket.ttl = 64;
393 
394  /* build the package */
395  if ((libnet_build_icmpv4_unreach(ICMP_DEST_UNREACH, /* type */
396  ICMP_HOST_ANO, /* code */
397  0, /* checksum */
398  (uint8_t *)ip4h, /* payload */
399  lpacket.dsize, /* payload length */
400  c, /* libnet context */
401  0)) < 0) /* libnet ptag */
402  {
403  SCLogError("libnet_build_icmpv4_unreach %s", libnet_geterror(c));
404  goto cleanup;
405  }
406 
407  if (BuildIPv4(c, &lpacket, IPPROTO_ICMP) < 0)
408  goto cleanup;
409 
410  if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) {
411  SetupEthernet(p, &lpacket, dir);
412 
413  if (p->vlan_idx == 1) {
414  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IP, p->vlan_id[0]) < 0)
415  goto cleanup;
416  } else {
417  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IP) < 0)
418  goto cleanup;
419  }
420  }
421 
422  result = libnet_write(c);
423  if (result == -1) {
424  SCLogError("libnet_write_raw_ipv4 failed: %s", libnet_geterror(c));
425  goto cleanup;
426  }
427 
428 cleanup:
429  ClearCtx(c, dir);
430  return 0;
431 }
432 
433 int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
434 {
435  Libnet11Packet lpacket;
436  int result;
437 
438  /* fill in struct defaults */
439  lpacket.ttl = 0;
440  lpacket.id = 0;
441  lpacket.flow = 0;
442  lpacket.class = 0;
443 
444  if (!PacketIsTCP(p))
445  return 1;
446 
447  libnet_t *c = GetCtx(p, LIBNET_RAW6, dir);
448  if (c == NULL)
449  return 1;
450 
451  lpacket.len = LIBNET_TCP_H;
452  lpacket.dsize = p->payload_len;
453 
454  switch (dir) {
455  case REJECT_DIR_SRC:
456  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
457  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
458  break;
459  case REJECT_DIR_DST:
460  default:
461  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
462  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
463  break;
464  }
465  /* TODO come up with ttl calc function */
466  lpacket.ttl = 64;
467 
468  SetupTCP(p, &lpacket, dir);
469 
470  BuildTCP(c, &lpacket);
471 
472  if (BuildIPv6(c, &lpacket, IPPROTO_TCP) < 0)
473  goto cleanup;
474 
475  if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) {
476  SetupEthernet(p, &lpacket, dir);
477  if (p->vlan_idx == 1) {
478  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0)
479  goto cleanup;
480  } else {
481  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IPV6) < 0)
482  goto cleanup;
483  }
484  }
485 
486  result = libnet_write(c);
487  if (result == -1) {
488  SCLogError("libnet_write failed: %s", libnet_geterror(c));
489  goto cleanup;
490  }
491 
492 cleanup:
493  ClearCtx(c, dir);
494  return 0;
495 }
496 
497 #ifdef HAVE_LIBNET_ICMPV6_UNREACH
498 int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
499 {
500  const IPV6Hdr *ip6h = PacketGetIPv6(p);
501  Libnet11Packet lpacket;
502  int result;
503 
504  /* fill in struct defaults */
505  lpacket.ttl = 0;
506  lpacket.id = 0;
507  lpacket.flow = 0;
508  lpacket.class = 0;
509  const uint16_t iplen = IPV6_GET_RAW_PLEN(ip6h);
510  if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + IPV6_HEADER_LEN + 8) {
511  lpacket.len = IPV6_HEADER_LEN + MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, iplen);
512  } else {
513  lpacket.len = IPV6_HEADER_LEN + MIN(8, iplen);
514  }
515  lpacket.dsize = lpacket.len - LIBNET_ICMPV6_H;
516 
517  libnet_t *c = GetCtx(p, LIBNET_RAW6, dir);
518  if (c == NULL)
519  return 1;
520 
521  switch (dir) {
522  case REJECT_DIR_SRC:
523  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
524  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
525  break;
526  case REJECT_DIR_DST:
527  default:
528  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
529  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
530  break;
531  }
532 
533  /* TODO come up with ttl calc function */
534  lpacket.ttl = 64;
535 
536  /* build the package */
537  if ((libnet_build_icmpv6_unreach(ICMP6_DST_UNREACH, /* type */
538  ICMP6_DST_UNREACH_ADMIN, /* code */
539  0, /* checksum */
540  (uint8_t *)ip6h, /* payload */
541  lpacket.dsize, /* payload length */
542  c, /* libnet context */
543  0)) < 0) /* libnet ptag */
544  {
545  SCLogError("libnet_build_icmpv6_unreach %s", libnet_geterror(c));
546  goto cleanup;
547  }
548 
549  if (BuildIPv6(c, &lpacket, IPPROTO_ICMPV6) < 0)
550  goto cleanup;
551 
552  if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) {
553  SetupEthernet(p, &lpacket, dir);
554  if (p->vlan_idx == 1) {
555  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0)
556  goto cleanup;
557  } else {
558  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IPV6) < 0)
559  goto cleanup;
560  }
561  }
562 
563  result = libnet_write(c);
564  if (result == -1) {
565  SCLogError("libnet_write_raw_ipv6 failed: %s", libnet_geterror(c));
566  goto cleanup;
567  }
568 
569 cleanup:
570  ClearCtx(c, dir);
571  return 0;
572 }
573 
574 #else /* HAVE_LIBNET_ICMPV6_UNREACH */
575 
576 int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
577 {
578  SCLogError("Libnet ICMPv6 based rejects are disabled."
579  "Usually this means that you don't have a patched libnet installed,"
580  " or configure couldn't find it.");
581  return 0;
582 }
583 #endif /* HAVE_LIBNET_ICMPV6_UNREACH */
584 
585 
586 #else
587 
589 {
590  SCLogError("Libnet based rejects are disabled."
591  "Usually this means that you don't have libnet installed,"
592  " or configure couldn't find it.");
593  return 0;
594 }
595 
597 {
598  SCLogError("Libnet based rejects are disabled."
599  "Usually this means that you don't have libnet installed,"
600  " or configure couldn't find it.");
601  return 0;
602 }
603 
605 {
606  SCLogError("Libnet based rejects are disabled."
607  "Usually this means that you don't have libnet installed,"
608  " or configure couldn't find it.");
609  return 0;
610 }
611 
613 {
614  SCLogError("Libnet based rejects are disabled."
615  "Usually this means that you don't have libnet installed,"
616  " or configure couldn't find it.");
617  return 0;
618 }
619 
620 void FreeCachedCtx(void)
621 {
622  SCLogDebug("no libhnet support");
623 }
624 
625 #endif /* HAVE_LIBNET11 */
TCP_GET_RAW_SEQ
#define TCP_GET_RAW_SEQ(tcph)
Definition: decode-tcp.h:80
util-device-private.h
tm-threads.h
decode-tcp.h
len
uint8_t len
Definition: app-layer-dnp3.h:2
IPV6_GET_RAW_PLEN
#define IPV6_GET_RAW_PLEN(ip6h)
Definition: decode-ipv6.h:66
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
RejectSendLibnet11IPv6TCP
int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
Definition: respond-reject-libnet11.c:604
seq
uint32_t seq
Definition: stream-tcp-private.h:2
Packet_::livedev_dst_id
uint16_t livedev_dst_id
Definition: decode.h:635
ETHERNET_TYPE_IPV6
#define ETHERNET_TYPE_IPV6
Definition: decode-ethernet.h:39
action-globals.h
decode-udp.h
threads.h
TH_RST
#define TH_RST
Definition: decode-tcp.h:36
Packet_::vlan_idx
uint8_t vlan_idx
Definition: decode.h:544
LiveDevice_
Definition: util-device-private.h:32
packet-queue.h
LiveDeviceGetById
LiveDevice * LiveDeviceGetById(const int id)
Definition: util-device.c:460
REJECT_DIR_DST
@ REJECT_DIR_DST
Definition: respond-reject.h:29
EngineHostModeIsSniffer
bool EngineHostModeIsSniffer(void)
Definition: suricata.c:281
MIN
#define MIN(x, y)
Definition: suricata-common.h:416
proto
uint8_t proto
Definition: decode-template.h:0
p
Packet * p
Definition: fuzz_iprep.c:21
TCP_GET_RAW_WINDOW
#define TCP_GET_RAW_WINDOW(tcph)
Definition: decode-tcp.h:83
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:621
GET_IPV6_DST_ADDR
#define GET_IPV6_DST_ADDR(p)
Definition: decode.h:205
REJECT_DIR_SRC
@ REJECT_DIR_SRC
Definition: respond-reject.h:28
Packet_::datalink
int datalink
Definition: decode.h:652
decode.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
Packet_::sp
Port sp
Definition: decode.h:523
TH_ACK
#define TH_ACK
Definition: decode-tcp.h:38
LiveDevice_::dev
char * dev
Definition: util-device-private.h:33
sc_set_caps
bool sc_set_caps
Definition: suricata.c:193
ICMP6_DST_UNREACH
#define ICMP6_DST_UNREACH
Definition: decode-icmpv6.h:36
RejectSendLibnet11IPv4TCP
int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
Definition: respond-reject-libnet11.c:588
IPV6Hdr_
Definition: decode-ipv6.h:32
RejectDirection
RejectDirection
Definition: respond-reject.h:27
Packet_
Definition: decode.h:516
FreeCachedCtx
void FreeCachedCtx(void)
Definition: respond-reject-libnet11.c:620
ETHERNET_HEADER_LEN
#define ETHERNET_HEADER_LEN
Definition: decode-ethernet.h:27
IPV4Hdr_
Definition: decode-ipv4.h:72
tm-queuehandlers.h
decode-ipv4.h
suricata-common.h
respond-reject-libnet11.h
Packet_::livedev_id
uint16_t livedev_id
Definition: decode.h:633
decode-sctp.h
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
EngineHostModeIsBridge
bool EngineHostModeIsBridge(void)
Definition: suricata.c:286
RejectSendLibnet11IPv6ICMP
int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
Definition: respond-reject-libnet11.c:612
threadvars.h
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
GET_IPV6_SRC_ADDR
#define GET_IPV6_SRC_ADDR(p)
Definition: decode.h:204
RejectSendLibnet11IPv4ICMP
int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
Definition: respond-reject-libnet11.c:596
ICMP_DEST_UNREACH
#define ICMP_DEST_UNREACH
Definition: decode-icmpv4.h:36
ICMP_HOST_ANO
#define ICMP_HOST_ANO
Definition: decode-icmpv4.h:114
suricata.h
IPV6_HEADER_LEN
#define IPV6_HEADER_LEN
Definition: decode-ipv6.h:27
IPV4_GET_RAW_IPLEN
#define IPV4_GET_RAW_IPLEN(ip4h)
Definition: decode-ipv4.h:98
Packet_::vlan_id
uint16_t vlan_id[VLAN_MAX_LAYERS]
Definition: decode.h:543
GET_IPV4_SRC_ADDR_U32
#define GET_IPV4_SRC_ADDR_U32(p)
Definition: decode.h:197
GET_IPV4_DST_ADDR_U32
#define GET_IPV4_DST_ADDR_U32(p)
Definition: decode.h:198
respond-reject.h
Packet_::dp
Port dp
Definition: decode.h:531
TCP_GET_RAW_ACK
#define TCP_GET_RAW_ACK(tcph)
Definition: decode-tcp.h:81
ICMP6_DST_UNREACH_ADMIN
#define ICMP6_DST_UNREACH_ADMIN
Definition: decode-icmpv6.h:81
ETHERNET_TYPE_IP
#define ETHERNET_TYPE_IP
Definition: decode-ethernet.h:34
TCPHdr_
Definition: decode-tcp.h:149