update to 1.03

This commit is contained in:
jolan 2004-07-12 06:16:49 +00:00
parent 1e418bcd25
commit b201527aec
7 changed files with 21 additions and 192 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.2 2004/04/18 01:04:28 jolan Exp $
# $OpenBSD: Makefile,v 1.3 2004/07/12 06:16:49 jolan Exp $
COMMENT= "c reimplementation of the BitTorrent core protocols"
DISTNAME= libbt-1.01
DISTNAME= libbt-1.03
CATEGORIES= devel net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=libbt/}
@ -29,8 +29,8 @@ do-install:
.for p in btcheck btget btlist
${INSTALL_PROGRAM} ${WRKBUILD}/src/${p} ${PREFIX}/bin
.endfor
.for i in benc bitset bterror bts context peer random segmenter strbuf stream \
types util
.for i in benc bitset bterror btmessage bts context peer random segmenter \
strbuf stream types util
${INSTALL_DATA} ${WRKSRC}/include/${i}.h ${PREFIX}/include/libbt
.endfor
${INSTALL_MAN} ${WRKSRC}/man/*.1 ${PREFIX}/man/man1

View File

@ -1,3 +1,3 @@
MD5 (libbt-1.01.tar.gz) = 6a22db0d4db9036afbb5af94b8fdd526
RMD160 (libbt-1.01.tar.gz) = 2e44d3db9e2623d517aaa5f780b3c2c514fc11f8
SHA1 (libbt-1.01.tar.gz) = be72b6d80fdd4e9140239184241e7d0f8109e8ad
MD5 (libbt-1.03.tar.gz) = f5fdd7f4b641d5da08d678130b4d6bff
RMD160 (libbt-1.03.tar.gz) = d7f342eb741e13b42896a7b83a959c0f6a0c6cec
SHA1 (libbt-1.03.tar.gz) = 7c72e2342a46c8b1cfc554aeae046918b81603f4

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-configure,v 1.1.1.1 2004/04/15 03:37:43 jolan Exp $
--- configure.orig 2004-03-21 23:58:02.000000000 -0600
+++ configure 2004-04-14 21:03:14.000000000 -0500
@@ -2495,7 +2495,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l
$OpenBSD: patch-configure,v 1.2 2004/07/12 06:16:50 jolan Exp $
--- configure.orig Wed Apr 21 00:12:50 2004
+++ configure Mon Jul 12 00:58:47 2004
@@ -2530,7 +2530,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then

View File

@ -1,25 +1,18 @@
$OpenBSD: patch-src_Makefile_in,v 1.1.1.1 2004/04/15 03:37:43 jolan Exp $
--- src/Makefile.in.orig 2004-04-07 00:05:07.000000000 -0500
+++ src/Makefile.in 2004-04-14 21:01:24.000000000 -0500
@@ -25,17 +25,17 @@ SRCS:=\
$OpenBSD: patch-src_Makefile_in,v 1.2 2004/07/12 06:16:50 jolan Exp $
--- src/Makefile.in.orig Sat Jul 10 01:49:54 2004
+++ src/Makefile.in Mon Jul 12 01:02:57 2004
@@ -25,11 +25,11 @@ SRCS:=\
bterror.c
OBJS:= ${SRCS:.c=.o}
-CPPFLAGS:=@CPPFLAGS@
-CFLAGS:=-g -Wall -I../include -I$(top_srcdir)/include
+CPPFLAGS+=@CPPFLAGS@ `curl-config --cflags`
+CFLAGS+=-Wall -I../include -I$(top_srcdir)/include
+CPPFLAGS:=@CPPFLAGS@ `curl-config --cflags`
+CFLAGS:=$(CPPFLAGS) @CFLAGS@ -Wall -I../include -I$(top_srcdir)/include
LIBS:=@LIBS@ `curl-config --libs` -lm
-LDFLAGS:=-g -L. @LDFLAGS@
+LDFLAGS:=-L. @LDFLAGS@
all: ${LIBBT} ${PROGRAMS}
docs:
doxygen *.c
depend:
- makedepend -- ${CFLAGS} - ${SRCS}
+ makedepend -- ${CPPFLAGS} ${CFLAGS} - ${SRCS}
btcheck: libbt.a btcheck.o
${CC} ${LDFLAGS} -o btcheck btcheck.o -lbt ${LIBS}
VERSION=1.03
MAKEDEPEND=@MAKEDEPEND@

View File

@ -1,32 +0,0 @@
$OpenBSD: patch-src_context_c,v 1.1.1.1 2004/04/15 03:37:43 jolan Exp $
--- src/context.c.orig 2004-04-02 23:19:47.000000000 -0600
+++ src/context.c 2004-04-14 20:56:49.000000000 -0500
@@ -45,6 +45,14 @@
# define snprintf _snprintf
#endif
+const struct addrinfo ai_template={
+ .ai_family=AF_INET, /* PF_INET */
+ .ai_socktype=SOCK_STREAM,
+ /*.ai_protocol=IPPROTO_TCP,*/
+};
+
+struct addrinfo *ai=NULL;
+
static int parse_config_digest(
const char *file, int lineno, const char *token,
unsigned char *digest, int len,
@@ -227,13 +235,6 @@ btresponse( btContext *ctx, int download
skip=0;
- const struct addrinfo ai_template={
- .ai_family=AF_INET, /* PF_INET */
- .ai_socktype=SOCK_STREAM,
- /*.ai_protocol=IPPROTO_TCP,*/
- };
- struct addrinfo *ai=NULL;
-
if (memcmp(ctx->myid, peerid->buf, IDSIZE)==0) {
printf("Skipping myself %s:%d\n", ip->buf, iport);
continue;

View File

@ -1,133 +0,0 @@
$OpenBSD: patch-src_peer_c,v 1.1.1.1 2004/04/15 03:37:43 jolan Exp $
--- src/peer.c.orig 2004-04-06 23:14:44.000000000 -0500
+++ src/peer.c 2004-04-14 20:52:25.000000000 -0500
@@ -46,6 +46,8 @@
#define REQUEST_SIZE 16384 /* Default request size */
char g_filebuffer[MAXREQUEST]; /* This should be moved to context or allocated in process_queue */
+int interest;
+
btPeerset* btPeerset_create( btPeerset *pset) {
if (!pset) {
pset = (btPeerset *)malloc(sizeof(btPeerset));
@@ -458,6 +460,13 @@ static int rate_timer( btPeerStatus *ps,
return total;
}
+#define SHIFT_INT32(ptr,nbo,ival) \
+ (nbo=htonl(ival), memcpy(ptr,&nbo,sizeof(int32_t)), ptr+=sizeof(int32_t))
+#define SHIFT_BYTE(ptr,ival) ((*((unsigned char *)(ptr))++) = ival)
+
+#define UNSHIFT_INT32(ptr,nbo,ival) \
+ (memcpy(&nbo,ptr,sizeof(int32_t)), ival=ntohl(nbo), ptr+=sizeof(int32_t))
+#define UNSHIFT_BYTE(ptr,ival) (ival = (*((unsigned char *)(ptr))++)
/*
* Return 1 if there are more messages waiting
* Return 0 on success,
@@ -470,9 +479,10 @@ recv_peermsg( btContext *ctx, btPeer *pe
int32_t nbo_len;
int len;
char msg[80];
- char *nmsg;
+ char *nmsg, *param;
int res = 0;
int err;
+ int32_t nbo;
assert(peer->download<ctx->downloadcount);
@@ -507,6 +517,7 @@ recv_peermsg( btContext *ctx, btPeer *pe
#endif
/* got message */
+ param = nmsg+5;
switch (nmsg[4]) {
case BT_MSG_CHOKE:
{
@@ -557,8 +568,9 @@ recv_peermsg( btContext *ctx, btPeer *pe
break;
case BT_MSG_HAVE:
{
- int block = ntohl(*(int *)(nmsg+5));
- int interest;
+ int block;
+
+ UNSHIFT_INT32(param,nbo,block);
bs_set( &peer->blocks, block);
interest = update_interested( ctx, peer);
if (interest &&
@@ -576,9 +588,13 @@ recv_peermsg( btContext *ctx, btPeer *pe
break;
case BT_MSG_REQUEST:
{
- int piece = ntohl(*(int *)(nmsg+5));
- int offs = ntohl(*(int *)(nmsg+9));
- int len = ntohl(*(int *)(nmsg+13));
+ int piece;
+ int offs;
+ int len;
+
+ UNSHIFT_INT32(param,nbo,piece);
+ UNSHIFT_INT32(param,nbo,offs);
+ UNSHIFT_INT32(param,nbo,len);
if (peer->local.choked) {
/* ignore requests from choked peers */
break;
@@ -599,16 +615,13 @@ recv_peermsg( btContext *ctx, btPeer *pe
break;
case BT_MSG_PIECE:
{
- int32_t ibuf;
btPartialPiece *pp=peer->currentPiece;
int piece;
int offs;
- memcpy(&ibuf,nmsg+5,sizeof(int32_t));
- piece = ntohl(ibuf);
- memcpy(&ibuf,nmsg+9,sizeof(int32_t));
- offs = ntohl(ibuf);
+ UNSHIFT_INT32(param,nbo,piece);
+ UNSHIFT_INT32(param,nbo,offs);
#if 0
printf("%d: got piece %d, offs %d, len %d\n",
@@ -670,14 +683,10 @@ recv_peermsg( btContext *ctx, btPeer *pe
case BT_MSG_CANCEL:
{
int piece, offs, len;
- int32_t ibuf;
/* this cancels a specific request */
- memcpy(&ibuf,nmsg+5,sizeof(int32_t));
- piece = ntohl(ibuf);
- memcpy(&ibuf,nmsg+9,sizeof(int32_t));
- offs = ntohl(ibuf);
- memcpy(&ibuf,nmsg+13,sizeof(int32_t));
- len = ntohl(ibuf);
+ UNSHIFT_INT32(param,nbo,piece);
+ UNSHIFT_INT32(param,nbo,offs);
+ UNSHIFT_INT32(param,nbo,len);
#if 0
printf("%d: got cancel %d, offs %d, len %d\n",
@@ -729,9 +738,6 @@ cleanup:
* -1 - permanent error sending msg size
* -2 - permanent error sending message
*/
-#define SHIFT_INT32(ptr,nbo,ival) \
- (nbo=htonl(ival), memcpy(ptr,&nbo,sizeof(int32_t)), ptr+=sizeof(int32_t))
-#define SHIFT_BYTE(ptr,ival) ((*((unsigned char *)(ptr))++) = ival)
int
send_message( btPeer *peer, char *buf, int len) {
int nslen = htonl( len);
@@ -1046,7 +1052,9 @@ int
update_interested( btContext *ctx, btPeer *p) {
btDownload *dl=ctx->downloads[p->download];
assert (p->download<ctx->downloadcount);
- int interest = bs_hasInteresting( &dl->fileset.completed, &p->blocks, &dl->interested);
+
+ interest = bs_hasInteresting( &dl->fileset.completed, &p->blocks, &dl->interested);
+
if (interest != p->local.interested) {
if (send_interested( p, interest)) return -1;
if (interest == 0 && !p->remote.choked) {

View File

@ -1,10 +1,11 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2004/04/15 03:37:43 jolan Exp $
@comment $OpenBSD: PLIST,v 1.2 2004/07/12 06:16:50 jolan Exp $
bin/btcheck
bin/btget
bin/btlist
include/libbt/benc.h
include/libbt/bitset.h
include/libbt/bterror.h
include/libbt/btmessage.h
include/libbt/bts.h
include/libbt/context.h
include/libbt/peer.h