X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=dht-bootstrap.c;h=90861fd5e4fe99995e1bd109a839ef52383fae1b;hb=ba2a8148d3206f374d72a69cde2e67f4edea8fe2;hp=a4fe67e9363ce7c698e40910ddfdb389c5478fe0;hpb=5bb5f9f8605072ff9f68723a8fd4887d709ce37f;p=dht-bootstrap.git diff --git a/dht-bootstrap.c b/dht-bootstrap.c index a4fe67e..90861fd 100644 --- a/dht-bootstrap.c +++ b/dht-bootstrap.c @@ -20,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* For memmem. */ -#define _GNU_SOURCE - #include #include #include @@ -38,35 +35,6 @@ THE SOFTWARE. #include #include -#ifndef HAVE_MEMMEM -#ifdef __GLIBC__ -#define HAVE_MEMMEM -#endif -#endif - -#ifndef MSG_CONFIRM -#define MSG_CONFIRM 0 -#endif - -/* We set sin_family to 0 to mark unused slots. */ -#if AF_INET == 0 || AF_INET6 == 0 -#error You lose -#endif - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -/* nothing */ -#elif defined(__GNUC__) -#define inline __inline -#if (__GNUC__ >= 3) -#define restrict __restrict -#else -#define restrict /**/ -#endif -#else -#define inline /**/ -#define restrict /**/ -#endif - #define MAX(x, y) ((x) >= (y) ? (x) : (y)) #define MIN(x, y) ((x) <= (y) ? (x) : (y)) @@ -81,8 +49,7 @@ send_find_node( const unsigned char *tid, int tid_len, const unsigned char *target, - int want, - int confirm); + int want); static int send_nodes( struct sockaddr *sa, @@ -395,7 +362,7 @@ send_request(struct circular_list *list, int dopop, int doping, int want) id[i] = random() & 0xFF; make_tid(ttid, "fn", 0); debugf("Sending find_node.\n"); - return send_find_node((struct sockaddr *)&ss, sslen, ttid, 4, id, want, 0); + return send_find_node((struct sockaddr *)&ss, sslen, ttid, 4, id, want); } } @@ -883,8 +850,7 @@ send_find_node( const unsigned char *tid, int tid_len, const unsigned char *target, - int want, - int confirm) + int want) { char buf[512]; int i = 0, rc; @@ -909,7 +875,7 @@ send_find_node( ADD_V(buf, i, 512); rc = snprintf(buf + i, 512 - i, "1:y1:qe"); INC(i, rc, 512); - return dht_send(buf, i, confirm ? MSG_CONFIRM : 0, sa, salen); + return dht_send(buf, i, 0, sa, salen); fail: errno = ENOSPC; @@ -1067,26 +1033,6 @@ fail: #undef COPY #undef ADD_V -#ifndef HAVE_MEMMEM -static void * -memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) -{ - const char *h = haystack; - const char *n = needle; - size_t i; - - /* size_t is unsigned */ - if (needlelen > haystacklen) - return NULL; - - for (i = 0; i <= haystacklen - needlelen; i++) { - if (memcmp(h + i, n, needlelen) == 0) - return (void *)(h + i); - } - return NULL; -} -#endif - static int parse_message( const unsigned char *buf,