paulo@0: /* paulo@0: * $Id: query_route.c,v 1.1 2004/01/04 03:57:53 hipnod Exp $ paulo@0: * paulo@0: * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) paulo@0: * paulo@0: * This program is free software; you can redistribute it and/or modify it paulo@0: * under the terms of the GNU General Public License as published by the paulo@0: * Free Software Foundation; either version 2, or (at your option) any paulo@0: * later version. paulo@0: * paulo@0: * This program is distributed in the hope that it will be useful, but paulo@0: * WITHOUT ANY WARRANTY; without even the implied warranty of paulo@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU paulo@0: * General Public License for more details. paulo@0: */ paulo@0: paulo@0: #include "gt_gnutella.h" paulo@0: #include "msg_handler.h" paulo@0: paulo@0: #include "gt_query_route.h" paulo@0: paulo@0: /*****************************************************************************/ paulo@0: paulo@0: /* create a table for routing queries from a child node paulo@0: * disabled for now because ultrapeer mode doesnt work yet */ paulo@0: GT_MSG_HANDLER(gt_msg_query_route) paulo@0: { paulo@0: #if 0 paulo@0: uint8_t type; paulo@0: uint32_t len; paulo@0: uint8_t largest_val; paulo@0: uint8_t seq_no; paulo@0: uint8_t seq_size; paulo@0: uint8_t compressed; paulo@0: uint8_t bits; paulo@0: size_t size; paulo@0: paulo@0: GT->DBGFN (GT, "entered"); paulo@0: paulo@0: type = gt_packet_get_uint8 (packet); paulo@0: paulo@0: /* TODO: rate-limit clients calling query_route; timeouts */ paulo@0: paulo@0: switch (type) paulo@0: { paulo@0: case 0: /* reset table */ paulo@0: len = gt_packet_get_uint32 (packet); paulo@0: largest_val = gt_packet_get_uint8 (packet); paulo@0: paulo@0: if (GT_NODE(c)->query_router) paulo@0: query_router_free (GT_NODE(c)->query_router); paulo@0: paulo@0: GT_NODE(c)->query_router = query_router_new (len, largest_val); paulo@0: paulo@0: GT->DBGFN (GT, "reset table: len = %u, largest val = %u", paulo@0: len, largest_val); paulo@0: break; paulo@0: paulo@0: case 1: /* patch table */ paulo@0: seq_no = gt_packet_get_uint8 (packet); paulo@0: seq_size = gt_packet_get_uint8 (packet); paulo@0: compressed = gt_packet_get_uint8 (packet); paulo@0: bits = gt_packet_get_uint8 (packet); paulo@0: paulo@0: GT->DBGFN (GT, "patch table: seq_no=%i seq_size=%i compressed=%i bits=%i", paulo@0: seq_no, seq_size, compressed, bits); paulo@0: paulo@0: /* size of the patch is the packet length minus len of patch header */ paulo@0: size = gt_packet_payload_len (packet) - 5; paulo@0: paulo@0: GT->DBGFN (GT, "size = %u, packet->offset = %u", size, packet->offset); paulo@0: query_router_update (GT_NODE(c)->query_router, seq_no, seq_size, paulo@0: compressed, bits, &packet->data[packet->offset], paulo@0: size); paulo@0: break; paulo@0: paulo@0: default: paulo@0: GT->DBGFN (GT, "unknown query-route message type: %d", type); paulo@0: break; paulo@0: } paulo@0: #endif paulo@0: }