tcpdump.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 __TCPDUMP_H__
  20. #define __TCPDUMP_H__
  21. /* line buffer stdout, read from stdin */
  22. #define TCPDUMP_ARGS " -n -l -r -"
  23. /* max number of tcpdump options; must be a multiple of 4 */
  24. #define OPTIONS_VEC_SIZE 32
  25. /* how long to wait (in ms) to write to tcpdump */
  26. #define TCPDUMP_POLL_TIMEOUT 500
  27. /* delim to be used for strtok() to process tcpdump args */
  28. #define OPT_DELIM " -"
  29. /* output file of data passed to tcpdump when debug level 5 is enabled */
  30. #define TCPDUMP_DEBUG "tcpdump.debug"
  31. /* taken from libpcap's savefile.c */
  32. #define TCPDUMP_MAGIC 0xa1b2c3d4
  33. #define PATCHED_TCPDUMP_MAGIC 0xa1b2cd34
  34. #define TCPDUMP_DECODE_LEN 65535
  35. typedef struct tcpdump_s {
  36. char *filename;
  37. char *args;
  38. struct pcap_file_header pfh;
  39. int pid;
  40. int infd; /* fd to write to. 1/2 of the socketpair */
  41. int outfd; /* fd to read from. */
  42. pcap_dumper_t *dumper;
  43. /* following vars are for figuring out exactly what we send to
  44. * tcpdump. See TCPDUMP_DEBUG
  45. */
  46. #ifdef DEBUG
  47. int debugfd;
  48. char debugfile[255];
  49. #endif
  50. } tcpdump_t;
  51. //int tcpdump_init(tcpdump_t *tcpdump);
  52. int tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap);
  53. //int tcpdump_open_live(tcpdump_t *tcpdump, pcap_t *pcap);
  54. int tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data);
  55. void tcpdump_close(tcpdump_t *tcpdump);
  56. void tcpdump_kill(tcpdump_t *tcpdump);
  57. #endif