relay.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Slitheen - a decoy routing system for censorship resistance
  2. * Copyright (C) 2017 Cecylia Bocovich (cbocovic@uwaterloo.ca)
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 3.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. * Additional permission under GNU GPL version 3 section 7
  17. *
  18. * If you modify this Program, or any covered work, by linking or combining
  19. * it with the OpenSSL library (or a modified version of that library),
  20. * containing parts covered by the terms of the OpenSSL Licence and the
  21. * SSLeay license, the licensors of this Program grant you additional
  22. * permission to convey the resulting work. Corresponding Source for a
  23. * non-source form of such a combination shall include the source code
  24. * for the parts of the OpenSSL library used as well as that of the covered
  25. * work.
  26. */
  27. #ifndef RELAY_H
  28. #define RELAY_H
  29. #include "flow.h"
  30. #include <stdint.h>
  31. typedef struct stream_table_st stream_table;
  32. typedef struct client_st {
  33. uint8_t slitheen_id[SLITHEEN_ID_LEN];
  34. stream_table *streams;
  35. data_queue *downstream_queue;
  36. sem_t queue_lock;
  37. uint16_t encryption_counter;
  38. struct client_st *next;
  39. uint8_t *header_key;
  40. uint8_t *body_key;
  41. EVP_MD_CTX *mac_ctx;
  42. } client;
  43. typedef struct client_table_st {
  44. client *first;
  45. } client_table;
  46. extern client_table *clients;
  47. int replace_packet(flow *f, struct packet_info *info);
  48. uint16_t tcp_checksum(struct packet_info *info);
  49. int fill_with_downstream(flow *f, uint8_t *data, int32_t length);
  50. #define BEGIN_HEADER 0x10
  51. #define PARSE_HEADER 0x20
  52. #define MID_CONTENT 0x30
  53. #define BEGIN_CHUNK 0x40
  54. #define MID_CHUNK 0x50
  55. #define END_CHUNK 0x60
  56. #define END_BODY 0x70
  57. #define FORFEIT_REST 0x80
  58. #define USE_REST 0x90
  59. #endif /* RELAY_H */