[Midnightbsd-cvs] mports [20652] trunk/devel: add jech-dht

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Nov 4 20:27:22 EST 2015


Revision: 20652
          http://svnweb.midnightbsd.org/mports/?rev=20652
Author:   laffer1
Date:     2015-11-04 20:27:22 -0500 (Wed, 04 Nov 2015)
Log Message:
-----------
add jech-dht

Modified Paths:
--------------
    trunk/devel/Makefile

Added Paths:
-----------
    trunk/devel/jech-dht/
    trunk/devel/jech-dht/Makefile
    trunk/devel/jech-dht/distinfo
    trunk/devel/jech-dht/files/
    trunk/devel/jech-dht/files/BSDmakefile
    trunk/devel/jech-dht/files/Makefile.example
    trunk/devel/jech-dht/files/patch-dht-example
    trunk/devel/jech-dht/files/patch-warns
    trunk/devel/jech-dht/pkg-descr
    trunk/devel/jech-dht/pkg-plist

Modified: trunk/devel/Makefile
===================================================================
--- trunk/devel/Makefile	2015-11-05 00:58:21 UTC (rev 20651)
+++ trunk/devel/Makefile	2015-11-05 01:27:22 UTC (rev 20652)
@@ -124,6 +124,7 @@
 SUBDIR += jakarta-commons-daemon
 SUBDIR += jam
 SUBDIR += jansson
+SUBDIR += jech-dht
 SUBDIR += jenkins
 SUBDIR += json-c
 SUBDIR += json-glib

Added: trunk/devel/jech-dht/Makefile
===================================================================
--- trunk/devel/jech-dht/Makefile	                        (rev 0)
+++ trunk/devel/jech-dht/Makefile	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,31 @@
+# Created by: Mikhail Teterin <mi at aldan.algebra.com>
+# $FreeBSD: head/devel/jech-dht/Makefile 352975 2014-05-05 01:48:38Z mi $
+# $MidnightBSD$
+
+PORTNAME=	dht
+PORTVERSION=	0.22
+CATEGORIES=	devel
+MASTER_SITES=	http://www.pps.univ-paris-diderot.fr/~jch/software/files/
+
+MAINTAINER=	ports at MidnightBSD.org
+COMMENT=	Mainline variant of Kademlia Distributed Hash Table (DHT)
+
+LICENSE=	mit
+
+FAKE_OPTS=	trueprefix
+
+MAKEFILE=	${FILESDIR}/BSDmakefile
+USE_LDCONFIG=	yes
+USES=	uidfix
+
+post-build:
+	${SETENV} ${MAKE_ENV} ${MAKE} -C ${WRKSRC} -f \
+		${FILESDIR}/Makefile.example
+post-install:
+	${SETENV} ${MAKE_ENV} ${MAKE} -C ${WRKSRC} -f \
+		${FILESDIR}/Makefile.example install
+
+pre-su-install:
+	${MKDIR} ${STAGEDIR}${PREFIX}/include/dht
+
+.include <bsd.port.mk>


Property changes on: trunk/devel/jech-dht/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/distinfo
===================================================================
--- trunk/devel/jech-dht/distinfo	                        (rev 0)
+++ trunk/devel/jech-dht/distinfo	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,2 @@
+SHA256 (dht-0.22.tar.gz) = a3452322648660da43cabd34cff8505d8f655e988f31c467535ad1992c29ac3d
+SIZE (dht-0.22.tar.gz) = 27380


Property changes on: trunk/devel/jech-dht/distinfo
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/files/BSDmakefile
===================================================================
--- trunk/devel/jech-dht/files/BSDmakefile	                        (rev 0)
+++ trunk/devel/jech-dht/files/BSDmakefile	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,15 @@
+LIB=	dht
+SHLIB_MAJOR=	0
+SHLIB_MINOR=	22
+NO_PROFILE=	yes
+
+SRCS=	dht.c
+
+CFLAGS+=-DHAVE_MEMMEM
+WARNS=	3
+
+INCS=	dht.h
+INCLUDEDIR=${PREFIX}/include/dht
+LIBDIR=	${PREFIX}/lib
+
+.include <bsd.lib.mk>


Property changes on: trunk/devel/jech-dht/files/BSDmakefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/files/Makefile.example
===================================================================
--- trunk/devel/jech-dht/files/Makefile.example	                        (rev 0)
+++ trunk/devel/jech-dht/files/Makefile.example	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,9 @@
+PROG=	dht-example
+NO_MAN=	nope, too much to ask
+
+LDADD=	-L. -ldht -lcrypt -lmd
+BINDIR=	${STAGEDIR}${PREFIX}/bin
+
+WARNS=	3
+
+.include <bsd.prog.mk>


Property changes on: trunk/devel/jech-dht/files/Makefile.example
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/files/patch-dht-example
===================================================================
--- trunk/devel/jech-dht/files/patch-dht-example	                        (rev 0)
+++ trunk/devel/jech-dht/files/patch-dht-example	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,118 @@
+This allow switching the hashing algorithm (between a crypt(3)-based
+one and MD5) at run-time, rather than at compile-time.
+
+	-mi
+
+--- dht-example.c	2014-05-03 14:37:50.000000000 -0400
++++ dht-example.c	2014-05-04 21:34:58.000000000 -0400
+@@ -12,4 +12,5 @@
+ #include <fcntl.h>
+ #include <sys/time.h>
++#include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <sys/types.h>
+@@ -17,4 +18,7 @@
+ #include <netdb.h>
+ #include <sys/signal.h>
++#include <signal.h>
++#include <unistd.h>
++#include <md5.h>
+ 
+ #include "dht.h"
+@@ -91,4 +95,11 @@
+ static unsigned char buf[4096];
+ 
++typedef void (hashing_method)(void *, int,
++	const void *, int,
++	const void *, int,
++	const void *, int);
++
++static hashing_method *hasher, crypt_hash, md5_hash;
++
+ int
+ main(int argc, char **argv)
+@@ -112,9 +123,8 @@
+     memset(&sin6, 0, sizeof(sin6));
+     sin6.sin6_family = AF_INET6;
+-
+-
++    hasher = crypt_hash;
+ 
+     while(1) {
+-        opt = getopt(argc, argv, "q46b:i:");
++        opt = getopt(argc, argv, "q46b:i:m");
+         if(opt < 0)
+             break;
+@@ -143,4 +153,6 @@
+             id_file = optarg;
+             break;
++	case 'm':
++            hasher = md5_hash;
+         default:
+             goto usage;
+@@ -405,6 +417,7 @@
+     
+  usage:
+-    printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...\n"
+-           "                   port [address port]...\n");
++    printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address] [-m]\n"
++           "                   port [address port]...\n"
++           "(Use -m to use MD5 digest instead of crypt()-based one)\n");
+     exit(1);
+ }
+@@ -420,25 +433,28 @@
+ /* We need to provide a reasonably strong cryptographic hashing function.
+    Here's how we'd do it if we had RSA's MD5 code. */
+-#if 0
+-void
+-dht_hash(void *hash_return, int hash_size,
++static void
++md5_hash(void *hash_return, int hash_size,
+          const void *v1, int len1,
+          const void *v2, int len2,
+          const void *v3, int len3)
+ {
+-    static MD5_CTX ctx;
++    MD5_CTX ctx;
+     MD5Init(&ctx);
+     MD5Update(&ctx, v1, len1);
+     MD5Update(&ctx, v2, len2);
+     MD5Update(&ctx, v3, len3);
+-    MD5Final(&ctx);
+-    if(hash_size > 16)
+-        memset((char*)hash_return + 16, 0, hash_size - 16);
+-    memcpy(hash_return, ctx.digest, hash_size > 16 ? 16 : hash_size);
++    if (hash_size >= 16) {
++        MD5Final(hash_return, &ctx);
++        if(hash_size > 16)
++            memset((char*)hash_return + 16, 0, hash_size - 16);
++    } else {
++        unsigned char digest[16];
++        MD5Final(digest, &ctx);
++	memcpy(hash_return, digest, hash_size);
++    }
+ }
+-#else
+ /* But for this example, we might as well use something weaker. */
+-void
+-dht_hash(void *hash_return, int hash_size,
++static void
++crypt_hash(void *hash_return, int hash_size,
+          const void *v1, int len1,
+          const void *v2, int len2,
+@@ -460,5 +476,14 @@
+     strncpy(hash_return, crypt(key, "jc"), hash_size);
+ }
+-#endif
++
++void
++dht_hash(void *hash_return, int hash_size,
++         const void *v1, int len1,
++         const void *v2, int len2,
++         const void *v3, int len3)
++{
++	hasher(hash_return, hash_size, v1, len1,
++	    v2, len2, v3, len3);
++}
+ 
+ int


Property changes on: trunk/devel/jech-dht/files/patch-dht-example
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/files/patch-warns
===================================================================
--- trunk/devel/jech-dht/files/patch-warns	                        (rev 0)
+++ trunk/devel/jech-dht/files/patch-warns	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,114 @@
+--- dht.c	2011-07-25 17:59:36.000000000 -0400
++++ dht.c	2012-07-28 16:21:07.000000000 -0400
+@@ -356,5 +356,5 @@
+     switch(sa->sa_family) {
+     case AF_INET: {
+-        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
++        const struct sockaddr_in *sin = (const struct sockaddr_in*)sa;
+         const unsigned char *address = (const unsigned char*)&sin->sin_addr;
+         return sin->sin_port == 0 ||
+@@ -364,5 +364,5 @@
+     }
+     case AF_INET6: {
+-        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
++        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
+         const unsigned char *address = (const unsigned char*)&sin6->sin6_addr;
+         return sin6->sin6_port == 0 ||
+@@ -1281,13 +1281,13 @@
+     int i, len;
+     struct storage *st;
+-    unsigned char *ip;
++    const unsigned char *ip;
+ 
+     if(sa->sa_family == AF_INET) {
+-        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
+-        ip = (unsigned char*)&sin->sin_addr;
++        const struct sockaddr_in *sin = (const struct sockaddr_in*)sa;
++        ip = (const unsigned char*)&sin->sin_addr;
+         len = 4;
+     } else if(sa->sa_family == AF_INET6) {
+-        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
+-        ip = (unsigned char*)&sin6->sin6_addr;
++        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
++        ip = (const unsigned char*)&sin6->sin6_addr;
+         len = 16;
+     } else {
+@@ -1406,15 +1406,15 @@
+ make_token(const struct sockaddr *sa, int old, unsigned char *token_return)
+ {
+-    void *ip;
++    const void *ip;
+     int iplen;
+     unsigned short port;
+ 
+     if(sa->sa_family == AF_INET) {
+-        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
++        const struct sockaddr_in *sin = (const struct sockaddr_in*)sa;
+         ip = &sin->sin_addr;
+         iplen = 4;
+         port = htons(sin->sin_port);
+     } else if(sa->sa_family == AF_INET6) {
+-        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
++        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
+         ip = &sin6->sin6_addr;
+         iplen = 16;
+@@ -1892,5 +1892,5 @@
+         }
+ 
+-        if(((char*)buf)[buflen] != '\0') {
++        if(((const char*)buf)[buflen] != '\0') {
+             debugf("Unterminated message.\n");
+             errno = EINVAL;
+@@ -2743,5 +2743,5 @@
+ 
+ #define CHECK(ptr, len)                                                 \
+-    if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
++    if(((const unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
+ 
+     if(tid_return) {
+@@ -2750,5 +2750,5 @@
+             long l;
+             char *q;
+-            l = strtol((char*)p + 3, &q, 10);
++            l = strtol((const char*)p + 3, &q, 10);
+             if(q && *q == ':' && l > 0 && l < *tid_len) {
+                 CHECK(q + 1, l);
+@@ -2782,5 +2782,5 @@
+             long l;
+             char *q;
+-            l = strtol((char*)p + 5, &q, 10);
++            l = strtol((const char*)p + 5, &q, 10);
+             if(q && *q == 'e' && l > 0 && l < 0x10000)
+                 *port_return = l;
+@@ -2804,5 +2804,5 @@
+             long l;
+             char *q;
+-            l = strtol((char*)p + 7, &q, 10);
++            l = strtol((const char*)p + 7, &q, 10);
+             if(q && *q == ':' && l > 0 && l < *token_len) {
+                 CHECK(q + 1, l);
+@@ -2820,5 +2820,5 @@
+             long l;
+             char *q;
+-            l = strtol((char*)p + 7, &q, 10);
++            l = strtol((const char*)p + 7, &q, 10);
+             if(q && *q == ':' && l > 0 && l < *nodes_len) {
+                 CHECK(q + 1, l);
+@@ -2836,5 +2836,5 @@
+             long l;
+             char *q;
+-            l = strtol((char*)p + 8, &q, 10);
++            l = strtol((const char*)p + 8, &q, 10);
+             if(q && *q == ':' && l > 0 && l < *nodes6_len) {
+                 CHECK(q + 1, l);
+@@ -2855,8 +2855,8 @@
+                 long l;
+                 char *q;
+-                l = strtol((char*)buf + i, &q, 10);
++                l = strtol((const char*)buf + i, &q, 10);
+                 if(q && *q == ':' && l > 0) {
+                     CHECK(q + 1, l);
+-                    i = q + 1 + l - (char*)buf;
++                    i = q + 1 + l - (const char*)buf;
+                     if(l == 6) {
+                         if(j + l > *values_len)


Property changes on: trunk/devel/jech-dht/files/patch-warns
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/pkg-descr
===================================================================
--- trunk/devel/jech-dht/pkg-descr	                        (rev 0)
+++ trunk/devel/jech-dht/pkg-descr	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,6 @@
+The files dht.c and dht.h implement the variant of the Kademlia
+Distributed Hash Table (DHT) used in the Bittorrent network
+(``mainline'' variant).
+
+WWW: http://www.pps.univ-paris-diderot.fr/~jch/software/bittorrent/
+WWW: https://github.com/jech/dht


Property changes on: trunk/devel/jech-dht/pkg-descr
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/devel/jech-dht/pkg-plist
===================================================================
--- trunk/devel/jech-dht/pkg-plist	                        (rev 0)
+++ trunk/devel/jech-dht/pkg-plist	2015-11-05 01:27:22 UTC (rev 20652)
@@ -0,0 +1,5 @@
+lib/libdht.so.0
+lib/libdht.so
+lib/libdht.a
+bin/dht-example
+include/dht/dht.h


Property changes on: trunk/devel/jech-dht/pkg-plist
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list