A clone of btpd with my configuration changes.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

91 wiersze
1.7 KiB

  1. #ifndef BTPD_TORRENT_H
  2. #define BTPD_TORRENT_H
  3. #define PIECE_BLOCKLEN (1 << 14)
  4. struct block {
  5. struct piece *pc;
  6. struct net_buf *msg;
  7. struct block_request_tq reqs;
  8. };
  9. struct piece {
  10. struct torrent *tp;
  11. uint32_t index;
  12. unsigned nreqs;
  13. unsigned nblocks;
  14. unsigned ngot;
  15. unsigned nbusy;
  16. unsigned next_block;
  17. struct block *blocks;
  18. uint8_t *have_field;
  19. uint8_t *down_field;
  20. BTPDQ_ENTRY(piece) entry;
  21. };
  22. BTPDQ_HEAD(piece_tq, piece);
  23. struct torrent {
  24. const char *relpath;
  25. struct metainfo meta;
  26. BTPDQ_ENTRY(torrent) entry;
  27. void *imem;
  28. size_t isiz;
  29. uint8_t *piece_field;
  30. uint8_t *block_field;
  31. uint8_t *busy_field;
  32. uint32_t npcs_busy;
  33. uint32_t have_npieces;
  34. unsigned *piece_count;
  35. uint64_t uploaded, downloaded;
  36. unsigned long choke_time;
  37. unsigned long opt_time;
  38. unsigned long tracker_time;
  39. short ndown;
  40. struct peer *optimistic;
  41. unsigned npeers;
  42. struct peer_tq peers;
  43. int endgame;
  44. struct piece_tq getlst;
  45. };
  46. BTPDQ_HEAD(torrent_tq, torrent);
  47. off_t torrent_bytes_left(struct torrent *tp);
  48. char *torrent_get_bytes(struct torrent *tp, off_t start, size_t len);
  49. void torrent_put_bytes(struct torrent *tp, const char *buf,
  50. off_t start, size_t len);
  51. int torrent_load(const char *metafile);
  52. void torrent_unload(struct torrent *tp);
  53. int torrent_has_peer(struct torrent *tp, const uint8_t *id);
  54. struct torrent *torrent_get_by_hash(const uint8_t *hash);
  55. off_t torrent_piece_size(struct torrent *tp, uint32_t index);
  56. uint32_t torrent_block_size(struct piece *pc, uint32_t index);
  57. int torrent_has_all(struct torrent *tp);
  58. #endif