libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit 7534ab0fb8db1833a70ac699db471235974a5e23
parent acf33003428d73d519a5eacafcbb855c2eb6e3c2
Author: z3bra <willy at mailoo dot org>
Date:   Mon Jul  2 18:18:17 +0200

Fix typos and missing macros here and there

Diffstat:
libeech.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -565,7 +565,7 @@ pwprxhv(struct peer *p, size_t sz, char *pl) if (sz != 4) return -1; - setbit(p->bf, U32(pl)); + setbit(p->bf, ntohl(U32(pl))); return 0; } @@ -588,17 +588,17 @@ pwprxpc(struct torrent *t, struct peer *p, size_t sz, char *pl) size_t idx, off; char *blk; - idx = U32(pl); - off = U32(pl+4); - blk = pl + 8; + idx = ntohl(U32(pl+1)); + off = ntohl(U32(pl+5)); + blk = pl + 9; memcpy(p->piece.blks + off, blk, sz - 8); - if (chkpiece(t, &p->piece, idx)) { - printf("PIECE: hash OK, piece full"); + if (!chkpiece(t, &p->piece, idx)) { + printf("PIECE: hash OK, piece full\n"); /* writepiece(t, p->piece, idx); */ } else { - printf("PIECE: has doesn't match (yet)"); + printf("PIECE: has doesn't match (yet)\n"); } return 0; @@ -666,7 +666,7 @@ pwprx(struct torrent *t, struct peer *p) p->rxbufsz = 0; p->state |= HANDSHAKERCVD; } else if (!pwprecv(p)) { - pwprxcb(t, p, p->rxbuf[4], p->rxbufsz- 5, p->rxbuf+4); + pwprxcb(t, p, p->rxbuf[4], p->rxbufsz - 5, p->rxbuf+4); memset(p->rxbuf, 0, MSGSIZ); p->rxbufsz = 0; }