2
* $Id: query_route.c,v 1.1 2004/01/04 03:57:53 hipnod Exp $
4
* Copyright (C) 2001-2003 giFT project (gift.sourceforge.net)
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
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.
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)
38
GT->DBGFN (GT, "entered");
40
type = gt_packet_get_uint8 (packet);
42
/* TODO: rate-limit clients calling query_route; timeouts */
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",
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],
78
GT->DBGFN (GT, "unknown query-route message type: %d", type);