flow.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __RELAY_H__
  2. #define __RELAY_H__
  3. #include <netinet/in.h>
  4. #include "ptwist.h"
  5. #define MAX_FLOWS 10
  6. #define TLS_HELLO_REQ 0x00
  7. #define TLS_CLNT_HELLO 0x01
  8. #define TLS_SERV_HELLO 0x02
  9. #define TLS_NEW_SESS 0x04
  10. #define TLS_CERT 0x0b
  11. #define TLS_SRVR_KEYEX 0x0c
  12. #define TLS_CERT_REQ 0x0d
  13. #define TLS_SRVR_HELLO_DONE 0x0e
  14. #define TLS_CERT_VERIFY 0x0f
  15. #define TLS_CLNT_KEYEX 0x10
  16. #define TLS_FINISHED 0x14
  17. struct packet_st{
  18. uint32_t seq_num;
  19. uint16_t len;
  20. uint16_t data_len;
  21. uint8_t *data;
  22. struct packet_st *next;
  23. };
  24. typedef struct packet_st packet;
  25. typedef struct flow_st {
  26. struct in_addr src_ip, dst_ip; /* Source and Destination addresses */
  27. uint16_t src_port, dst_port; /* Source and Destination ports */
  28. uint32_t seq_num; /* sequence number */
  29. byte key[16]; /* negotiated key */
  30. int state; /* TLS handshake state */
  31. int encrypted; /* indicates whether flow is encrypted */
  32. packet *packet_chain; /* currently held data */
  33. } flow;
  34. typedef struct flow_table_st {
  35. flow *table;
  36. int len;
  37. int max_len;
  38. } flow_table;
  39. int init_flow_table (void);
  40. int add_flow(flow newFlow);
  41. int update_flow(flow *f);
  42. int remove_flow(int index);
  43. int check_flow(flow observed);
  44. flow *get_flow(int index);
  45. int add_packet(flow *f, uint8_t *data);
  46. #endif /* __RELAY_H__ */