A clone of btpd with my configuration changes.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

65 líneas
1.7 KiB

  1. #ifndef BTPD_NET_BUF_H
  2. #define BTPD_NET_BUF_H
  3. #define NB_CHOKE 0
  4. #define NB_UNCHOKE 1
  5. #define NB_INTEREST 2
  6. #define NB_UNINTEREST 3
  7. #define NB_HAVE 4
  8. #define NB_BITFIELD 5
  9. #define NB_REQUEST 6
  10. #define NB_PIECE 7
  11. #define NB_CANCEL 8
  12. #define NB_TORRENTDATA 10
  13. #define NB_MULTIHAVE 11
  14. #define NB_BITDATA 12
  15. #define NB_SHAKE 13
  16. #define NB_KEEPALIVE 14
  17. struct net_buf {
  18. short type;
  19. unsigned refs;
  20. char *buf;
  21. size_t len;
  22. void (*kill_buf)(char *, size_t);
  23. };
  24. struct nb_link {
  25. struct net_buf *nb;
  26. BTPDQ_ENTRY(nb_link) entry;
  27. };
  28. BTPDQ_HEAD(nb_tq, nb_link);
  29. struct torrent;
  30. struct peer;
  31. struct net_buf *nb_create_keepalive(void);
  32. struct net_buf *nb_create_piece(uint32_t index, uint32_t begin, size_t blen);
  33. struct net_buf *nb_create_torrentdata(void);
  34. struct net_buf *nb_create_request(uint32_t index,
  35. uint32_t begin, uint32_t length);
  36. struct net_buf *nb_create_cancel(uint32_t index,
  37. uint32_t begin, uint32_t length);
  38. struct net_buf *nb_create_have(uint32_t index);
  39. struct net_buf *nb_create_multihave(struct torrent *tp);
  40. struct net_buf *nb_create_unchoke(void);
  41. struct net_buf *nb_create_choke(void);
  42. struct net_buf *nb_create_uninterest(void);
  43. struct net_buf *nb_create_interest(void);
  44. struct net_buf *nb_create_bitfield(struct torrent *tp);
  45. struct net_buf *nb_create_bitdata(struct torrent *tp);
  46. struct net_buf *nb_create_shake(struct torrent *tp);
  47. int nb_torrentdata_fill(struct net_buf *nb, struct torrent *tp, uint32_t index,
  48. uint32_t begin, uint32_t length);
  49. int nb_drop(struct net_buf *nb);
  50. void nb_hold(struct net_buf *nb);
  51. uint32_t nb_get_index(struct net_buf *nb);
  52. uint32_t nb_get_begin(struct net_buf *nb);
  53. uint32_t nb_get_length(struct net_buf *nb);
  54. #endif