Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
view src/message/query_route.c @ 0:d39e1d0d75b6
initial add
author | paulo@hit-nxdomain.opendns.com |
---|---|
date | Sat, 20 Feb 2010 21:18:28 -0800 |
parents | |
children |
line source
1 /*
2 * $Id: query_route.c,v 1.1 2004/01/04 03:57:53 hipnod Exp $
3 *
4 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
17 #include "gt_gnutella.h"
18 #include "msg_handler.h"
20 #include "gt_query_route.h"
22 /*****************************************************************************/
24 /* create a table for routing queries from a child node
25 * disabled for now because ultrapeer mode doesnt work yet */
26 GT_MSG_HANDLER(gt_msg_query_route)
27 {
28 #if 0
29 uint8_t type;
30 uint32_t len;
31 uint8_t largest_val;
32 uint8_t seq_no;
33 uint8_t seq_size;
34 uint8_t compressed;
35 uint8_t bits;
36 size_t size;
38 GT->DBGFN (GT, "entered");
40 type = gt_packet_get_uint8 (packet);
42 /* TODO: rate-limit clients calling query_route; timeouts */
44 switch (type)
45 {
46 case 0: /* reset table */
47 len = gt_packet_get_uint32 (packet);
48 largest_val = gt_packet_get_uint8 (packet);
50 if (GT_NODE(c)->query_router)
51 query_router_free (GT_NODE(c)->query_router);
53 GT_NODE(c)->query_router = query_router_new (len, largest_val);
55 GT->DBGFN (GT, "reset table: len = %u, largest val = %u",
56 len, largest_val);
57 break;
59 case 1: /* patch table */
60 seq_no = gt_packet_get_uint8 (packet);
61 seq_size = gt_packet_get_uint8 (packet);
62 compressed = gt_packet_get_uint8 (packet);
63 bits = gt_packet_get_uint8 (packet);
65 GT->DBGFN (GT, "patch table: seq_no=%i seq_size=%i compressed=%i bits=%i",
66 seq_no, seq_size, compressed, bits);
68 /* size of the patch is the packet length minus len of patch header */
69 size = gt_packet_payload_len (packet) - 5;
71 GT->DBGFN (GT, "size = %u, packet->offset = %u", size, packet->offset);
72 query_router_update (GT_NODE(c)->query_router, seq_no, seq_size,
73 compressed, bits, &packet->data[packet->offset],
74 size);
75 break;
77 default:
78 GT->DBGFN (GT, "unknown query-route message type: %d", type);
79 break;
80 }
81 #endif
82 }