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