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) {
96  if (p->datalink == LINKTYPE_ETHERNET)
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  const EthernetHdr *ethh = PacketGetEthernet(p);
253  switch (dir) {
254  case REJECT_DIR_SRC:
255  lpacket->smac = ethh->eth_dst;
256  lpacket->dmac = ethh->eth_src;
257  break;
258  case REJECT_DIR_DST:
259  default:
260  lpacket->smac = ethh->eth_src;
261  lpacket->dmac = ethh->eth_dst;
262  break;
263  }
264 }
265 
266 static inline int BuildEthernet(libnet_t *c, Libnet11Packet *lpacket, uint16_t proto)
267 {
268  if ((libnet_build_ethernet(lpacket->dmac,lpacket->smac, proto , NULL, 0, c, 0)) < 0) {
269  SCLogError("libnet_build_ethernet %s", libnet_geterror(c));
270  return -1;
271  }
272  return 0;
273 }
274 
275 static inline int BuildEthernetVLAN(libnet_t *c, Libnet11Packet *lpacket, uint16_t proto, uint16_t vlan_id)
276 {
277  if (libnet_build_802_1q(lpacket->dmac, lpacket->smac, ETHERTYPE_VLAN, 0, 0, vlan_id, proto,
278  NULL, /* payload */
279  0, /* payload size */
280  c, /* libnet handle */
281  0) < 0) {
282  SCLogError("libnet_build_802_1q %s", libnet_geterror(c));
283  return -1;
284  }
285  return 0;
286 }
287 
288 int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
289 {
290  Libnet11Packet lpacket;
291  int result;
292 
293  /* fill in struct defaults */
294  lpacket.ttl = 0;
295  lpacket.id = 0;
296  lpacket.flow = 0;
297  lpacket.class = 0;
298 
299  if (!PacketIsTCP(p))
300  return 1;
301 
302  libnet_t *c = GetCtx(p, LIBNET_RAW4, dir);
303  if (c == NULL)
304  return 1;
305 
306  lpacket.len = LIBNET_IPV4_H + LIBNET_TCP_H;
307  lpacket.dsize = p->payload_len;
308 
309  switch (dir) {
310  case REJECT_DIR_SRC:
311  lpacket.src4 = GET_IPV4_DST_ADDR_U32(p);
312  lpacket.dst4 = GET_IPV4_SRC_ADDR_U32(p);
313  break;
314  case REJECT_DIR_DST:
315  default:
316  lpacket.src4 = GET_IPV4_SRC_ADDR_U32(p);
317  lpacket.dst4 = GET_IPV4_DST_ADDR_U32(p);
318  break;
319  }
320  /* TODO come up with ttl calc function */
321  lpacket.ttl = 64;
322 
323  SetupTCP(p, &lpacket, dir);
324 
325  if (BuildTCP(c, &lpacket) < 0)
326  goto cleanup;
327 
328  if (BuildIPv4(c, &lpacket, IPPROTO_TCP) < 0)
329  goto cleanup;
330 
331  if (t_inject_mode == LIBNET_LINK) {
332  SetupEthernet(p, &lpacket, dir);
333 
334  if (p->vlan_idx == 1) {
335  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IP, p->vlan_id[0]) < 0)
336  goto cleanup;
337  } else {
338  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IP) < 0)
339  goto cleanup;
340  }
341  }
342 
343  result = libnet_write(c);
344  if (result == -1) {
345  SCLogError("libnet_write failed: %s", libnet_geterror(c));
346  goto cleanup;
347  }
348 
349 cleanup:
350  ClearCtx(c, dir);
351  return 0;
352 }
353 
354 int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
355 {
356  const IPV4Hdr *ip4h = PacketGetIPv4(p);
357  Libnet11Packet lpacket;
358  int result;
359 
360  /* fill in struct defaults */
361  lpacket.ttl = 0;
362  lpacket.id = 0;
363  lpacket.flow = 0;
364  lpacket.class = 0;
365  const uint16_t iplen = IPV4_GET_RAW_IPLEN(ip4h);
366  if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + LIBNET_IPV4_H + 8) {
367  lpacket.len = MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, (LIBNET_IPV4_H + iplen));
368  } else {
369  lpacket.len = LIBNET_IPV4_H + MIN(8,iplen); // 8 bytes is the minimum we have to attach
370  }
371  lpacket.dsize = lpacket.len - (LIBNET_IPV4_H + LIBNET_ICMPV4_H);
372 
373  libnet_t *c = GetCtx(p, LIBNET_RAW4, dir);
374  if (c == NULL)
375  return 1;
376 
377  switch (dir) {
378  case REJECT_DIR_SRC:
379  lpacket.src4 = GET_IPV4_DST_ADDR_U32(p);
380  lpacket.dst4 = GET_IPV4_SRC_ADDR_U32(p);
381  break;
382  case REJECT_DIR_DST:
383  default:
384  lpacket.src4 = GET_IPV4_SRC_ADDR_U32(p);
385  lpacket.dst4 = GET_IPV4_DST_ADDR_U32(p);
386  break;
387  }
388 
389  /* TODO come up with ttl calc function */
390  lpacket.ttl = 64;
391 
392  /* build the package */
393  if ((libnet_build_icmpv4_unreach(ICMP_DEST_UNREACH, /* type */
394  ICMP_HOST_ANO, /* code */
395  0, /* checksum */
396  (uint8_t *)ip4h, /* payload */
397  lpacket.dsize, /* payload length */
398  c, /* libnet context */
399  0)) < 0) /* libnet ptag */
400  {
401  SCLogError("libnet_build_icmpv4_unreach %s", libnet_geterror(c));
402  goto cleanup;
403  }
404 
405  if (BuildIPv4(c, &lpacket, IPPROTO_ICMP) < 0)
406  goto cleanup;
407 
408  if (t_inject_mode == LIBNET_LINK) {
409  SetupEthernet(p, &lpacket, dir);
410 
411  if (p->vlan_idx == 1) {
412  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IP, p->vlan_id[0]) < 0)
413  goto cleanup;
414  } else {
415  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IP) < 0)
416  goto cleanup;
417  }
418  }
419 
420  result = libnet_write(c);
421  if (result == -1) {
422  SCLogError("libnet_write_raw_ipv4 failed: %s", libnet_geterror(c));
423  goto cleanup;
424  }
425 
426 cleanup:
427  ClearCtx(c, dir);
428  return 0;
429 }
430 
431 int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
432 {
433  Libnet11Packet lpacket;
434  int result;
435 
436  /* fill in struct defaults */
437  lpacket.ttl = 0;
438  lpacket.id = 0;
439  lpacket.flow = 0;
440  lpacket.class = 0;
441 
442  if (!PacketIsTCP(p))
443  return 1;
444 
445  libnet_t *c = GetCtx(p, LIBNET_RAW6, dir);
446  if (c == NULL)
447  return 1;
448 
449  lpacket.len = LIBNET_TCP_H;
450  lpacket.dsize = p->payload_len;
451 
452  switch (dir) {
453  case REJECT_DIR_SRC:
454  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
455  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
456  break;
457  case REJECT_DIR_DST:
458  default:
459  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
460  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
461  break;
462  }
463  /* TODO come up with ttl calc function */
464  lpacket.ttl = 64;
465 
466  SetupTCP(p, &lpacket, dir);
467 
468  BuildTCP(c, &lpacket);
469 
470  if (BuildIPv6(c, &lpacket, IPPROTO_TCP) < 0)
471  goto cleanup;
472 
473  if (t_inject_mode == LIBNET_LINK) {
474  SetupEthernet(p, &lpacket, dir);
475  if (p->vlan_idx == 1) {
476  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0)
477  goto cleanup;
478  } else {
479  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IPV6) < 0)
480  goto cleanup;
481  }
482  }
483 
484  result = libnet_write(c);
485  if (result == -1) {
486  SCLogError("libnet_write failed: %s", libnet_geterror(c));
487  goto cleanup;
488  }
489 
490 cleanup:
491  ClearCtx(c, dir);
492  return 0;
493 }
494 
495 #ifdef HAVE_LIBNET_ICMPV6_UNREACH
496 int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
497 {
498  const IPV6Hdr *ip6h = PacketGetIPv6(p);
499  Libnet11Packet lpacket;
500  int result;
501 
502  /* fill in struct defaults */
503  lpacket.ttl = 0;
504  lpacket.id = 0;
505  lpacket.flow = 0;
506  lpacket.class = 0;
507  const uint16_t iplen = IPV6_GET_RAW_PLEN(ip6h);
508  if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + IPV6_HEADER_LEN + 8) {
509  lpacket.len = IPV6_HEADER_LEN + MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, iplen);
510  } else {
511  lpacket.len = IPV6_HEADER_LEN + MIN(8, iplen);
512  }
513  lpacket.dsize = lpacket.len - LIBNET_ICMPV6_H;
514 
515  libnet_t *c = GetCtx(p, LIBNET_RAW6, dir);
516  if (c == NULL)
517  return 1;
518 
519  switch (dir) {
520  case REJECT_DIR_SRC:
521  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
522  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
523  break;
524  case REJECT_DIR_DST:
525  default:
526  memcpy(lpacket.src6.libnet_s6_addr, GET_IPV6_SRC_ADDR(p), 16);
527  memcpy(lpacket.dst6.libnet_s6_addr, GET_IPV6_DST_ADDR(p), 16);
528  break;
529  }
530 
531  /* TODO come up with ttl calc function */
532  lpacket.ttl = 64;
533 
534  /* build the package */
535  if ((libnet_build_icmpv6_unreach(ICMP6_DST_UNREACH, /* type */
536  ICMP6_DST_UNREACH_ADMIN, /* code */
537  0, /* checksum */
538  (uint8_t *)ip6h, /* payload */
539  lpacket.dsize, /* payload length */
540  c, /* libnet context */
541  0)) < 0) /* libnet ptag */
542  {
543  SCLogError("libnet_build_icmpv6_unreach %s", libnet_geterror(c));
544  goto cleanup;
545  }
546 
547  if (BuildIPv6(c, &lpacket, IPPROTO_ICMPV6) < 0)
548  goto cleanup;
549 
550  if (t_inject_mode == LIBNET_LINK) {
551  SetupEthernet(p, &lpacket, dir);
552  if (p->vlan_idx == 1) {
553  if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0)
554  goto cleanup;
555  } else {
556  if (BuildEthernet(c, &lpacket, ETHERNET_TYPE_IPV6) < 0)
557  goto cleanup;
558  }
559  }
560 
561  result = libnet_write(c);
562  if (result == -1) {
563  SCLogError("libnet_write_raw_ipv6 failed: %s", libnet_geterror(c));
564  goto cleanup;
565  }
566 
567 cleanup:
568  ClearCtx(c, dir);
569  return 0;
570 }
571 
572 #else /* HAVE_LIBNET_ICMPV6_UNREACH */
573 
574 int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
575 {
576  SCLogError("Libnet ICMPv6 based rejects are disabled."
577  "Usually this means that you don't have a patched libnet installed,"
578  " or configure couldn't find it.");
579  return 0;
580 }
581 #endif /* HAVE_LIBNET_ICMPV6_UNREACH */
582 
583 
584 #else
585 
587 {
588  SCLogError("Libnet based rejects are disabled."
589  "Usually this means that you don't have libnet installed,"
590  " or configure couldn't find it.");
591  return 0;
592 }
593 
595 {
596  SCLogError("Libnet based rejects are disabled."
597  "Usually this means that you don't have libnet installed,"
598  " or configure couldn't find it.");
599  return 0;
600 }
601 
603 {
604  SCLogError("Libnet based rejects are disabled."
605  "Usually this means that you don't have libnet installed,"
606  " or configure couldn't find it.");
607  return 0;
608 }
609 
611 {
612  SCLogError("Libnet based rejects are disabled."
613  "Usually this means that you don't have libnet installed,"
614  " or configure couldn't find it.");
615  return 0;
616 }
617 
618 void FreeCachedCtx(void)
619 {
620  SCLogDebug("no libhnet support");
621 }
622 
623 #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:602
seq
uint32_t seq
Definition: stream-tcp-private.h:2
Packet_::livedev_dst_id
uint16_t livedev_dst_id
Definition: decode.h:624
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:533
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:413
proto
uint8_t proto
Definition: decode-template.h:0
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:610
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:641
decode.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
Packet_::sp
Port sp
Definition: decode.h:512
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:586
IPV6Hdr_
Definition: decode-ipv6.h:32
RejectDirection
RejectDirection
Definition: respond-reject.h:27
Packet_
Definition: decode.h:505
FreeCachedCtx
void FreeCachedCtx(void)
Definition: respond-reject-libnet11.c:618
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:622
decode-sctp.h
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:33
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:610
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:594
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:532
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:520
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