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