plugins_api.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2022 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 _PLUGINS_API_H_
  20. #define _PLUGINS_API_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Used to parse arguments if you have AutoGen */
  25. int tcpedit_dlt_post_args(tcpedit_t *tcpedit);
  26. /*
  27. * initialize the DLT plugin backend, and return a new context var.
  28. * call this once per pcap to be processed
  29. */
  30. tcpeditdlt_t *tcpedit_dlt_init(tcpedit_t *tcpedit, int srcdlt);
  31. /*
  32. * Called after tcpedit_dlt_post_args() to allow plugins to do special things
  33. * like init sub-plugins. You'll need to call this manual if you're not using
  34. * tcpedit_dlt_post_args();
  35. */
  36. int tcpedit_dlt_post_init(tcpeditdlt_t *tcpedit);
  37. /* cleans up after ourselves. Called for each initialized plugin */
  38. void tcpedit_dlt_cleanup(tcpeditdlt_t *ctx);
  39. /* What is the output DLT type? */
  40. int tcpedit_dlt_output_dlt(tcpeditdlt_t *ctx);
  41. int tcpedit_dlt_l2len(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen);
  42. /*
  43. * process the given packet, by calling decode & encode
  44. */
  45. int tcpedit_dlt_process(tcpeditdlt_t *ctx, u_char **packet, int pktlen, tcpr_dir_t direction);
  46. /*
  47. * or you can call them sperately if you want
  48. */
  49. int tcpedit_dlt_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
  50. int tcpedit_dlt_encode(tcpeditdlt_t* ctx, u_char *packet, int pktlen, tcpr_dir_t direction);
  51. /*
  52. * After processing each packet, you can get info about L2/L3
  53. */
  54. int tcpedit_dlt_proto(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen);
  55. u_char *tcpedit_dlt_l3data(tcpeditdlt_t *ctx, int dlt, u_char *packet, const int pktlen);
  56. /* merge the L2 & L3 (possibly changed?) after calling tcpedit_dlt_l3data() */
  57. u_char *tcpedit_dlt_merge_l3data(tcpeditdlt_t *ctx,
  58. int dlt,
  59. u_char *packet,
  60. const int pktlen,
  61. u_char *ipv4_data,
  62. u_char *ipv6_data);
  63. int tcpedit_dlt_src(tcpeditdlt_t *ctx);
  64. int tcpedit_dlt_dst(tcpeditdlt_t *ctx);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif