cell.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * cell.h
  3. * Cell definition.
  4. *
  5. * Matej Pfajfar <mp292@cam.ac.uk>
  6. */
  7. /*
  8. * Changes :
  9. * $Log$
  10. * Revision 1.2 2002/07/18 06:38:32 arma
  11. * changes to support sendme cells
  12. *
  13. * Revision 1.1.1.1 2002/06/26 22:45:50 arma
  14. * initial commit: current code
  15. *
  16. * Revision 1.14 2002/04/02 14:27:11 badbytes
  17. * Final finishes.
  18. *
  19. * Revision 1.13 2002/03/03 00:06:45 mp292
  20. * Modifications to support re-transmission.
  21. *
  22. * Revision 1.12 2002/02/09 17:51:52 mp292
  23. * CELL_ACK should be 4 not 3
  24. *
  25. * Revision 1.11 2002/02/03 22:41:45 mp292
  26. * Changes to cell size.
  27. *
  28. * Revision 1.10 2002/01/21 20:57:19 mp292
  29. * Reviewed according to Secure-Programs-HOWTO.
  30. *
  31. * Revision 1.9 2002/01/17 15:00:43 mp292
  32. * Fixed a bug which caused malloc() generate a seg fault.
  33. *
  34. * Revision 1.8 2002/01/14 13:05:37 badbytes
  35. * System testing in progress.
  36. *
  37. * Revision 1.7 2002/01/10 13:15:54 badbytes
  38. * Fixed ACI size from 32bits to 16bits.
  39. *
  40. * Revision 1.6 2002/01/09 08:10:32 badbytes
  41. * *** empty log message ***
  42. *
  43. * Revision 1.5 2002/01/07 13:03:28 badbytes
  44. * cell.ACI is now cell.aci
  45. *
  46. * Revision 1.4 2002/01/07 09:26:00 badbytes
  47. * Added pack_create() and pack_data().
  48. *
  49. * Revision 1.3 2002/01/07 07:48:34 badbytes
  50. * fixed new_create_cell()
  51. *
  52. * Revision 1.2 2002/01/04 12:08:34 badbytes
  53. * Added functions for cell creation.
  54. *
  55. * Revision 1.1 2002/01/04 10:02:07 badbytes
  56. * Added cell definition.
  57. *
  58. */
  59. #ifndef __CELL_H
  60. #include <unistd.h>
  61. #include <stdint.h>
  62. /* cell commands */
  63. #define CELL_PADDING 0
  64. #define CELL_CREATE 1
  65. #define CELL_DATA 2
  66. #define CELL_DESTROY 3
  67. #define CELL_ACK 4
  68. #define CELL_NACK 5
  69. #define CELL_SENDME 6
  70. #define CELL_PAYLOAD_SIZE 120
  71. /* cell definition */
  72. typedef struct
  73. {
  74. uint16_t aci; /* Anonymous Connection Identifier */
  75. unsigned char command;
  76. unsigned char length; /* of payload if data cell, else value of sendme */
  77. uint32_t seq; /* sequence number */
  78. unsigned char payload[120];
  79. } cell_t;
  80. cell_t *new_padding_cell(void);
  81. cell_t *new_create_cell(uint16_t aci, unsigned char length, unsigned char *buf);
  82. cell_t *new_destroy_cell(uint16_t aci);
  83. cell_t *new_data_cell(uint16_t aci, unsigned char length, unsigned char *buf);
  84. cell_t *new_ack_cell(uint16_t aci);
  85. cell_t *new_nack_cell(uint16_t aci);
  86. int pack_create(uint16_t aci, unsigned char *onion, uint32_t onionlen, unsigned char **cellbuf, unsigned int *cellbuflen);
  87. int pack_data(uint16_t aci, unsigned char *buf, size_t buflen, unsigned char **cellbuf, unsigned int *cellbuflen);
  88. #define __CELL_H
  89. #endif