]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Thu, 28 Jul 2022 18:47:28 +0000 (11:47 -0700)
committeralex <[email protected]>
Thu, 28 Jul 2022 18:47:28 +0000 (11:47 -0700)
inc/net.h
src/peer/hash.c
test/integration/Makefile.am
test/integration/qbittorrent.tests.c

index 1bee9dd7f78d4d77d4696751b6be50fa55282e2f..95ac067a0b66b515a46e372c674dc84620d636a6 100644 (file)
--- a/inc/net.h
+++ b/inc/net.h
@@ -43,6 +43,12 @@ struct net_info {
        (x[2]<<8) + \
        x[3]
 
+#define UINT32_T_TO_BYTES(x,buf) \
+       buf[0] = (uint8_t) (x >> 24); \
+       buf[1] = (uint8_t) (x >> 16 & 0xff); \
+       buf[2] = (uint8_t) (x >> 8 & 0xff); \
+       buf[3] = (uint8_t) (x & 0xff);
+
 int net_cache(void**,size_t*,void*,size_t);
 ssize_t net_expected(struct peer*,enum peer_message*);
 void net_handler(int,struct peer*);
index 88574d30ca0ddb7c45b8c2caf37c060725293420..efe1b43435fbcb9c01faad4e99d260938e1d4c57 100644 (file)
@@ -1,6 +1,11 @@
 #include<peer.h>
 
-int peer_hash_request(struct peer *info) {
+#define HASH_REQUEST_LENGTH crypto_hash_sha256_BYTES+4+4+4+4
+int peer_hash_request(struct peer *info,const struct hash_request *request) {
+       unsigned char buf[HASH_REQUEST_LENGTH];
+
+       
+
        return -1;
 }
 
index 22d58d7fa96f208184cc8c8ddf93a86348cbb663..94b93aa71aa013fca8ac189233f10336287245c9 100644 (file)
@@ -40,10 +40,12 @@ qbittorrent_tests_SOURCES = \
        $(top_srcdir)/src/net/send.c \
        $(top_srcdir)/src/net/wait.c \
        $(top_srcdir)/src/peer/bitfield.c \
+       $(top_srcdir)/src/peer/choke.c \
        $(top_srcdir)/src/peer/free.c \
        $(top_srcdir)/src/peer/handshake.c \
        $(top_srcdir)/src/peer/id.c \
-       $(top_srcdir)/src/peer/init.c
+       $(top_srcdir)/src/peer/init.c \
+       $(top_srcdir)/src/peer/interest.c
 
 clean-local:
        -rm -rf $(TEST_DIRECTORY)
index f1fef6f87a67cc32599d1123d63862a7dc7724fc..28543b7dee1d615e5e26f5815a83f42b3dcba0ea 100644 (file)
@@ -60,6 +60,16 @@ void qbittorrent_integration_test() {
 
        assert(1==peer_bitfield_received(info,i));
 
+       assert(1==peer_choke(info));
+       assert(1==peer_unchoke(info));
+
+       assert(1==peer_not_interested(info));
+       assert(1==peer_interested(info));
+
+       assert(1==peer_keepalive(info));
+
+       assert(1==peer_hash_request(info));
+
        close(info->sock);
        peer_free(info);
 }