A clone of btpd with my configuration changes.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

91 rinda
1.5 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. const uint8_t *have_field;
  19. uint8_t *down_field;
  20. BTPDQ_ENTRY(piece) entry;
  21. };
  22. BTPDQ_HEAD(piece_tq, piece);
  23. enum torrent_state {
  24. T_INACTIVE,
  25. T_STARTING,
  26. T_ACTIVE,
  27. T_STOPPING
  28. };
  29. struct torrent {
  30. const char *relpath;
  31. struct metainfo meta;
  32. enum torrent_state state;
  33. struct content *cp;
  34. struct tracker *tr;
  35. BTPDQ_ENTRY(torrent) entry;
  36. BTPDQ_ENTRY(torrent) net_entry;
  37. int net_active;
  38. uint8_t *busy_field;
  39. uint32_t npcs_busy;
  40. unsigned *piece_count;
  41. uint64_t uploaded, downloaded;
  42. unsigned long rate_up, rate_dwn;
  43. unsigned npeers;
  44. struct peer_tq peers;
  45. int endgame;
  46. struct piece_tq getlst;
  47. };
  48. BTPDQ_HEAD(torrent_tq, torrent);
  49. int torrent_create(struct torrent **res, const char *path);
  50. void torrent_activate(struct torrent *tp);
  51. void torrent_deactivate(struct torrent *tp);
  52. int torrent_has_peer(struct torrent *tp, const uint8_t *id);
  53. off_t torrent_piece_size(struct torrent *tp, uint32_t index);
  54. uint32_t torrent_block_size(struct piece *pc, uint32_t index);
  55. enum cm_state {
  56. CM_STARTED,
  57. CM_STOPPED,
  58. CM_ERROR
  59. };
  60. void torrent_cm_cb(struct torrent *tp, enum cm_state state);
  61. #endif