flows.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  3. * Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  4. *
  5. * The Tcpreplay Suite of tools is free software: you can redistribute it
  6. * and/or modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or with the authors permission any later version.
  9. *
  10. * The Tcpreplay Suite is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #include "defines.h"
  20. #include "common.h"
  21. #define DEFAULT_FLOW_HASH_BUCKET_SIZE (1 << 16) /* 64K - must be a power of two */
  22. typedef enum flow_entry_type_e {
  23. FLOW_ENTRY_INVALID, /* unknown packet type */
  24. FLOW_ENTRY_NON_IP, /* is a flow, but non-IP */
  25. FLOW_ENTRY_NEW, /* flow never seen before */
  26. FLOW_ENTRY_EXISTING, /* flow already seen */
  27. FLOW_ENTRY_EXPIRED, /* flow existed but was expired */
  28. } flow_entry_type_t;
  29. typedef struct flow_hash_table flow_hash_table_t;
  30. flow_hash_table_t *flow_hash_table_init(size_t n);
  31. void flow_hash_table_release(flow_hash_table_t *table);
  32. flow_entry_type_t flow_decode(flow_hash_table_t *fht,
  33. const struct pcap_pkthdr *pkthdr,
  34. const u_char *pktdata,
  35. const int datalink,
  36. const int expiry,
  37. COUNTER packetnum);