tcpedit_types.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2017 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  5. *
  6. * The Tcpreplay Suite of tools is free software: you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or with the authors permission any later version.
  10. *
  11. * The Tcpreplay Suite is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _TCPEDIT_TYPES_H_
  20. #define _TCPEDIT_TYPES_H_
  21. #include "defines.h"
  22. #include "common.h"
  23. #include "tcpr.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #define TCPEDIT_SOFT_ERROR -2
  28. #define TCPEDIT_ERROR -1
  29. #define TCPEDIT_OK 0
  30. #define TCPEDIT_WARN 1
  31. typedef enum {
  32. TCPEDIT_FIXLEN_OFF = 0,
  33. TCPEDIT_FIXLEN_PAD,
  34. TCPEDIT_FIXLEN_TRUNC,
  35. TCPEDIT_FIXLEN_DEL
  36. } tcpedit_fixlen;
  37. typedef enum {
  38. TCPEDIT_TTL_MODE_OFF = 0,
  39. TCPEDIT_TTL_MODE_SET,
  40. TCPEDIT_TTL_MODE_ADD,
  41. TCPEDIT_TTL_MODE_SUB
  42. } tcpedit_ttl_mode;
  43. typedef enum {
  44. TCPEDIT_EDIT_BOTH = 0,
  45. TCPEDIT_EDIT_C2S,
  46. TCPEDIT_EDIT_S2C
  47. } tcpedit_direction;
  48. typedef enum {
  49. BEFORE_PROCESS,
  50. AFTER_PROCESS
  51. } tcpedit_coder;
  52. #define TCPEDIT_ERRSTR_LEN 1024
  53. typedef struct {
  54. COUNTER packetnum;
  55. COUNTER total_bytes;
  56. COUNTER pkts_edited;
  57. int dlt1;
  58. int dlt2;
  59. char errstr[TCPEDIT_ERRSTR_LEN];
  60. char warnstr[TCPEDIT_ERRSTR_LEN];
  61. #ifdef FORCE_ALIGN
  62. u_char *l3buff;
  63. #endif
  64. } tcpedit_runtime_t;
  65. /*
  66. * need to track some packet info at runtime
  67. */
  68. typedef struct {
  69. int l2len;
  70. int l3len;
  71. int datalen;
  72. u_int8_t l4proto;
  73. u_char *l4data;
  74. u_int16_t sport, dport;
  75. union {
  76. u_int32_t ipv4;
  77. struct tcpr_in6_addr ipv6;
  78. } sip, dip;
  79. } tcpedit_packet_t;
  80. /*
  81. * portmap data struct
  82. */
  83. typedef struct tcpedit_portmap_s {
  84. long from;
  85. long to;
  86. struct tcpedit_portmap_s *next;
  87. } tcpedit_portmap_t;
  88. /*
  89. * all the arguments that the packet editing library supports
  90. */
  91. typedef struct {
  92. bool validated; /* have we run tcpedit_validate()? */
  93. struct tcpeditdlt_s *dlt_ctx;
  94. tcpedit_packet_t *packet;
  95. /* runtime variables, don't mess with these */
  96. tcpedit_runtime_t runtime;
  97. /* skip rewriting IP/MAC's which are broadcast or multicast? */
  98. bool skip_broadcast;
  99. /* pad or truncate packets */
  100. tcpedit_fixlen fixlen;
  101. tcpedit_direction editdir;
  102. /* rewrite ip? */
  103. bool rewrite_ip;
  104. /* fix IP/TCP/UDP checksums */
  105. bool fixcsum;
  106. /* remove ethernet FCS */
  107. bool efcs;
  108. tcpedit_ttl_mode ttl_mode;
  109. u_int8_t ttl_value;
  110. /* TOS/DiffServ/ECN, -1 is disabled, else copy value */
  111. int tos;
  112. /* IPv6 FlowLabel, -1 is disabled, else copy value */
  113. int flowlabel;
  114. /* IPv6 TClass, -1 is disabled, else copy value */
  115. int tclass;
  116. /* rewrite end-point IP addresses between cidrmap1 & cidrmap2 */
  117. tcpr_cidrmap_t *cidrmap1; /* tcpprep cache data */
  118. tcpr_cidrmap_t *cidrmap2;
  119. /* src & dst IP mapping */
  120. tcpr_cidrmap_t *srcipmap;
  121. tcpr_cidrmap_t *dstipmap;
  122. /* pseudo-randomize IP addresses using a seed */
  123. uint32_t seed;
  124. /* rewrite tcp/udp ports */
  125. tcpedit_portmap_t *portmap;
  126. int mtu; /* Deal with different MTU's */
  127. bool mtu_truncate; /* Should we truncate frames > MTU? */
  128. int maxpacket; /* L2 header + MTU */
  129. uint32_t fuzz_seed;
  130. uint32_t fuzz_factor;
  131. } tcpedit_t;
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif