From: alex Date: Tue, 8 Feb 2022 01:55:38 +0000 (-0800) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=5639a1dbeb3a4b15e7f0931845f34f0b1515f265;p=seeder ... --- diff --git a/inc/peer.h b/inc/peer.h index f99ac3c..038e3ab 100644 --- a/inc/peer.h +++ b/inc/peer.h @@ -17,4 +17,6 @@ enum peer_message { PEER_MESSAGE_HASH_REJECT = 23 }; +int peer_handshake(int,const uint8_t*,size_t,const uint8_t*,size_t); + #endif diff --git a/src/peer/bitfield.c b/src/peer/bitfield.c new file mode 100644 index 0000000..9947ff8 --- /dev/null +++ b/src/peer/bitfield.c @@ -0,0 +1,5 @@ +#include + +int peer_bitfield(int sock) { + return -1; +} diff --git a/src/peer/cancel.c b/src/peer/cancel.c new file mode 100644 index 0000000..07da8b9 --- /dev/null +++ b/src/peer/cancel.c @@ -0,0 +1,5 @@ +#include + +int peer_cancel() { + return -1; +} diff --git a/src/peer/choke.c b/src/peer/choke.c new file mode 100644 index 0000000..99d8423 --- /dev/null +++ b/src/peer/choke.c @@ -0,0 +1,9 @@ +#include + +int peer_choke(int sock) { + return -1; +} + +int peer_unchoke(int sock) { + return -1; +} diff --git a/src/peer/handshake.c b/src/peer/handshake.c index 42ed6a3..24d3135 100644 --- a/src/peer/handshake.c +++ b/src/peer/handshake.c @@ -1,11 +1,14 @@ #include -#define HANDSHAKE_STRING "\x13BitTorrent protocol\0\0\0\0\0\0\0\0"; +#define HANDSHAKE_STRING "\x13" "BitTorrent protocol\0\0\0\0\0\0\0\0"; #define HANDSHAKE_INFOHASH_SIZE 20 -int handshake(int sock, const uint8_t *infohash, size_t infohash_size const uint8_t peer_id, size_t peer_id_size) { +int peer_handshake(int sock, const uint8_t *infohash, size_t infohash_size const uint8_t *peer_id, size_t peer_id_size) { const char header[64] = HANDSHAKE_STRING; + assert(HANDSHAKE_INFOHASH_SIZE==infohash_size); + assert(PEER_ID_SIZE==peer_id_size); + memcpy(&(header[24]),infohash,HANDSHAKE_INFOHASH_SIZE); memcpy(&(header[44]),peer_id,PEER_ID_SIZE); diff --git a/src/peer/hash.c b/src/peer/hash.c new file mode 100644 index 0000000..4f1e067 --- /dev/null +++ b/src/peer/hash.c @@ -0,0 +1,9 @@ +#include + +int peer_hash_request() { + return -1; +} + +int peer_hash_reject() { + return -1; +} diff --git a/src/peer/have.c b/src/peer/have.c new file mode 100644 index 0000000..28c14b2 --- /dev/null +++ b/src/peer/have.c @@ -0,0 +1,5 @@ +#include + +int peer_have(int sock) { + return -1; +} diff --git a/src/peer/interest.c b/src/peer/interest.c new file mode 100644 index 0000000..651704d --- /dev/null +++ b/src/peer/interest.c @@ -0,0 +1,9 @@ +#include + +int peer_interested(int sock) { + return -1; +} + +int peer_not_interested(int sock) { + return -1; +} diff --git a/src/peer/request.c b/src/peer/request.c new file mode 100644 index 0000000..371f988 --- /dev/null +++ b/src/peer/request.c @@ -0,0 +1,5 @@ +#include + +int peer_request() { + return -1; +} diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am index 83cb82f..0719cdd 100644 --- a/test/unit/Makefile.am +++ b/test/unit/Makefile.am @@ -13,7 +13,7 @@ AM_CPPFLAGS += \ -DNDEBUG endif -check_PROGRAMS = bencode.tests block.tests feed.tests file.tests fs.concat.tests fs.filter.tests hash.tests hashmap.tests meta.tests opt.tests rss.tests session.tests torrent.tests tree.tests +check_PROGRAMS = bencode.tests block.tests feed.tests file.tests fs.concat.tests fs.filter.tests hash.tests hashmap.tests meta.tests opt.tests peer.tests rss.tests session.tests torrent.tests tree.tests TESTS = $(check_PROGRAMS) if ENABLE_MEMCHECK @@ -138,6 +138,10 @@ opt_tests_SOURCES = \ $(top_srcdir)/src/opt/worker.c \ $(top_srcdir)/src/session.c +peer_tests_SOURCES = \ + $(common_SOURCES) \ + peer.tests.c + rss_tests_SOURCES = \ $(common_SOURCES) \ rss.tests.c \ diff --git a/test/unit/peer.tests.c b/test/unit/peer.tests.c new file mode 100644 index 0000000..c934f73 --- /dev/null +++ b/test/unit/peer.tests.c @@ -0,0 +1,9 @@ +#include + +#include + +int main(); + +int main() { + return EXIT_SUCCESS; +}