A clone of btpd with my configuration changes.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

65 lignes
1.6 KiB

  1. #ifndef BTPD_PEER_H
  2. #define BTPD_PEER_H
  3. #define PF_I_WANT 0x01 /* We want to download from the peer */
  4. #define PF_I_CHOKE 0x02 /* We choke the peer */
  5. #define PF_P_WANT 0x04 /* The peer wants to download from us */
  6. #define PF_P_CHOKE 0x08 /* The peer is choking us */
  7. #define PF_ON_READQ 0x10
  8. #define PF_ON_WRITEQ 0x20
  9. #define PF_ATTACHED 0x40
  10. #define PF_WRITE_CLOSE 0x80 /* Close connection after writing all data */
  11. #define RATEHISTORY 20
  12. struct peer {
  13. int sd;
  14. uint8_t flags;
  15. uint8_t *piece_field;
  16. uint32_t npieces;
  17. unsigned nwant;
  18. uint8_t id[20];
  19. struct torrent *tp;
  20. struct piece_req_tq p_reqs, my_reqs;
  21. struct io_tq outq;
  22. struct event in_ev;
  23. struct event out_ev;
  24. struct input_reader *reader;
  25. unsigned long rate_to_me[RATEHISTORY];
  26. unsigned long rate_from_me[RATEHISTORY];
  27. BTPDQ_ENTRY(peer) cm_entry;
  28. BTPDQ_ENTRY(peer) rq_entry;
  29. BTPDQ_ENTRY(peer) wq_entry;
  30. };
  31. BTPDQ_HEAD(peer_tq, peer);
  32. void peer_unchoke(struct peer *p);
  33. void peer_choke(struct peer *p);
  34. void peer_unwant(struct peer *p, uint32_t index);
  35. void peer_want(struct peer *p, uint32_t index);
  36. void peer_request(struct peer *p, uint32_t index,
  37. uint32_t begin, uint32_t len);
  38. void peer_cancel(struct peer *p, uint32_t index, uint32_t begin, uint32_t len);
  39. void peer_have(struct peer *p, uint32_t index);
  40. unsigned long peer_get_rate(unsigned long *rates);
  41. void peer_create_in(int sd);
  42. void peer_create_out(struct torrent *tp, const uint8_t *id,
  43. const char *ip, int port);
  44. void peer_create_out_compact(struct torrent *tp, const char *compact);
  45. void peer_kill(struct peer *p);
  46. #endif