tcpedit.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_H_
  20. #define _TCPEDIT_H_
  21. #include "defines.h"
  22. #include "common.h"
  23. #include "tcpedit_types.h"
  24. #include "tcpedit_api.h"
  25. #include "parse_args.h"
  26. #include "plugins.h"
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * libtcpedit common API
  32. */
  33. int tcpedit_init(tcpedit_t **tcpedit_ex, int dlt);
  34. char *tcpedit_geterr(tcpedit_t *tcpedit);
  35. char *tcpedit_getwarn(tcpedit_t *tcpedit);
  36. int tcpedit_checkerror(tcpedit_t *tcpedit, const int rcode, const char *prefix);
  37. int tcpedit_validate(tcpedit_t *tcpedit);
  38. int tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr,
  39. u_char **pktdata, tcpr_dir_t direction);
  40. int tcpedit_close(tcpedit_t *tcpedit);
  41. int tcpedit_get_output_dlt(tcpedit_t *tcpedit);
  42. int tcpedit_l2len(tcpedit_t *tcpedit, tcpedit_coder code, u_char *packet, const int pktlen);
  43. const u_char *tcpedit_l3data(tcpedit_t *tcpedit, tcpedit_coder code, u_char *packet, const int pktlen);
  44. int tcpedit_l3proto(tcpedit_t *tcpedit, tcpedit_coder code, const u_char *packet, const int pktlen);
  45. COUNTER tcpedit_get_total_bytes(tcpedit_t *tcpedit);
  46. COUNTER tcpedit_get_pkts_edited(tcpedit_t *tcpedit);
  47. /*
  48. u_char *tcpedit_srcmac(tcpedit_t *tcpedit, tcpedit_coder code, u_char *packet, const int pktlen);
  49. u_char *tcpedit_dstmac(tcpedit_t *tcpedit, tcpedit_coder code, u_char *packet, const int pktlen);
  50. int tcpedit_maclen(tcpedit_t *tcpedit, tcpedit_coder code);
  51. */
  52. /**
  53. * These functions are seen by the outside world, but nobody should ever use them
  54. * outside of internal tcpedit functions
  55. */
  56. #define tcpedit_seterr(x, y, ...) __tcpedit_seterr(x, __FUNCTION__, __LINE__, __FILE__, y, __VA_ARGS__)
  57. void __tcpedit_seterr(tcpedit_t *tcpedit, const char *func, const int line, const char *file, const char *fmt, ...);
  58. void tcpedit_setwarn(tcpedit_t *tcpedit, const char *fmt, ...);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif