tcpedit-int.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* $Id: tcpedit-int.h 1983 2008-04-25 04:51:07Z aturner $ */
  2. /*
  3. * Copyright (c) 2006-2007 Aaron Turner.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright owners nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  23. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  27. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include "defines.h"
  32. #include "common.h"
  33. #include "tcpedit.h"
  34. #include "plugins/dlt_plugins-int.h"
  35. #ifndef _TCPEDIT_INT_H_
  36. #define _TCPEDIT_INT_H_
  37. #define TCPEDIT_ERRSTR_LEN 1024
  38. struct tcpedit_runtime_s {
  39. COUNTER packetnum;
  40. COUNTER total_bytes;
  41. COUNTER pkts_edited;
  42. int dlt1;
  43. int dlt2;
  44. char errstr[TCPEDIT_ERRSTR_LEN];
  45. char warnstr[TCPEDIT_ERRSTR_LEN];
  46. #ifdef FORCE_ALIGN
  47. u_char *l3buff;
  48. #endif
  49. };
  50. typedef struct tcpedit_runtime_s tcpedit_runtime_t;
  51. /*
  52. * portmap data struct
  53. */
  54. struct tcpedit_portmap_s {
  55. long from;
  56. long to;
  57. struct tcpedit_portmap_s *next;
  58. };
  59. typedef struct tcpedit_portmap_s tcpedit_portmap_t;
  60. /*
  61. * all the arguments that the packet editing library supports
  62. */
  63. struct tcpedit_s {
  64. int validated; /* have we run tcpedit_validate()? */
  65. struct tcpeditdlt_s *dlt_ctx;
  66. /* runtime variables, don't mess with these */
  67. tcpedit_runtime_t runtime;
  68. /* skip rewriting IP/MAC's which are broadcast or multicast? */
  69. int skip_broadcast;
  70. /* rewrite traffic bi-directionally */
  71. int bidir;
  72. #define TCPEDIT_BIDIR_OFF 0x0
  73. #define TCPEDIT_BIDIR_ON 0x1
  74. /* pad or truncate packets */
  75. int fixlen;
  76. #define TCPEDIT_FIXLEN_OFF 0x0
  77. #define TCPEDIT_FIXLEN_PAD 0x1
  78. #define TCPEDIT_FIXLEN_TRUNC 0x2
  79. #define TCPEDIT_FIXLEN_DEL 0x3
  80. /* rewrite ip? */
  81. int rewrite_ip;
  82. #define TCPEDIT_REWRITE_IP_OFF 0x0
  83. #define TCPEDIT_REWRITE_IP_ON 0x1
  84. /* fix IP/TCP/UDP checksums */
  85. u_int8_t fixcsum;
  86. #define TCPEDIT_FIXCSUM_OFF 0x0
  87. #define TCPEDIT_FIXCSUM_ON 0x1
  88. /* remove ethernet FCS */
  89. u_int8_t efcs;
  90. #define TCPEDIT_EFCS_OFF 0x0
  91. #define TCPEDIT_EFCS_ON 0x1
  92. u_int8_t ttl_mode;
  93. #define TCPEDIT_TTL_OFF 0x0
  94. #define TCPEDIT_TTL_SET 0x1
  95. #define TCPEDIT_TTL_ADD 0x2
  96. #define TCPEDIT_TTL_SUB 0x3
  97. u_int8_t ttl_value;
  98. /* rewrite end-point IP addresses between cidrmap1 & cidrmap2 */
  99. tcpr_cidrmap_t *cidrmap1; /* tcpprep cache data */
  100. tcpr_cidrmap_t *cidrmap2;
  101. /* src & dst IP mapping */
  102. tcpr_cidrmap_t *srcipmap;
  103. tcpr_cidrmap_t *dstipmap;
  104. /* pseudo-randomize IP addresses using a seed */
  105. int seed;
  106. /* rewrite tcp/udp ports */
  107. tcpedit_portmap_t *portmap;
  108. int mtu; /* Deal with different MTU's */
  109. int maxpacket; /* L2 header + MTU */
  110. };
  111. #define tcpedit_seterr(x, y, ...) __tcpedit_seterr(x, __FUNCTION__, __LINE__, __FILE__, y, __VA_ARGS__)
  112. void __tcpedit_seterr(tcpedit_t *tcpedit, const char *func, const int line, const char *file, const char *fmt, ...);
  113. void tcpedit_setwarn(tcpedit_t *tcpedit, const char *fmt, ...);
  114. #endif