Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/message/query_route.c Sat Feb 20 21:18:28 2010 -0800 1.3 @@ -0,0 +1,82 @@ 1.4 +/* 1.5 + * $Id: query_route.c,v 1.1 2004/01/04 03:57:53 hipnod Exp $ 1.6 + * 1.7 + * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 1.8 + * 1.9 + * This program is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License as published by the 1.11 + * Free Software Foundation; either version 2, or (at your option) any 1.12 + * later version. 1.13 + * 1.14 + * This program is distributed in the hope that it will be useful, but 1.15 + * WITHOUT ANY WARRANTY; without even the implied warranty of 1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.17 + * General Public License for more details. 1.18 + */ 1.19 + 1.20 +#include "gt_gnutella.h" 1.21 +#include "msg_handler.h" 1.22 + 1.23 +#include "gt_query_route.h" 1.24 + 1.25 +/*****************************************************************************/ 1.26 + 1.27 +/* create a table for routing queries from a child node 1.28 + * disabled for now because ultrapeer mode doesnt work yet */ 1.29 +GT_MSG_HANDLER(gt_msg_query_route) 1.30 +{ 1.31 +#if 0 1.32 + uint8_t type; 1.33 + uint32_t len; 1.34 + uint8_t largest_val; 1.35 + uint8_t seq_no; 1.36 + uint8_t seq_size; 1.37 + uint8_t compressed; 1.38 + uint8_t bits; 1.39 + size_t size; 1.40 + 1.41 + GT->DBGFN (GT, "entered"); 1.42 + 1.43 + type = gt_packet_get_uint8 (packet); 1.44 + 1.45 + /* TODO: rate-limit clients calling query_route; timeouts */ 1.46 + 1.47 + switch (type) 1.48 + { 1.49 + case 0: /* reset table */ 1.50 + len = gt_packet_get_uint32 (packet); 1.51 + largest_val = gt_packet_get_uint8 (packet); 1.52 + 1.53 + if (GT_NODE(c)->query_router) 1.54 + query_router_free (GT_NODE(c)->query_router); 1.55 + 1.56 + GT_NODE(c)->query_router = query_router_new (len, largest_val); 1.57 + 1.58 + GT->DBGFN (GT, "reset table: len = %u, largest val = %u", 1.59 + len, largest_val); 1.60 + break; 1.61 + 1.62 + case 1: /* patch table */ 1.63 + seq_no = gt_packet_get_uint8 (packet); 1.64 + seq_size = gt_packet_get_uint8 (packet); 1.65 + compressed = gt_packet_get_uint8 (packet); 1.66 + bits = gt_packet_get_uint8 (packet); 1.67 + 1.68 + GT->DBGFN (GT, "patch table: seq_no=%i seq_size=%i compressed=%i bits=%i", 1.69 + seq_no, seq_size, compressed, bits); 1.70 + 1.71 + /* size of the patch is the packet length minus len of patch header */ 1.72 + size = gt_packet_payload_len (packet) - 5; 1.73 + 1.74 + GT->DBGFN (GT, "size = %u, packet->offset = %u", size, packet->offset); 1.75 + query_router_update (GT_NODE(c)->query_router, seq_no, seq_size, 1.76 + compressed, bits, &packet->data[packet->offset], 1.77 + size); 1.78 + break; 1.79 + 1.80 + default: 1.81 + GT->DBGFN (GT, "unknown query-route message type: %d", type); 1.82 + break; 1.83 + } 1.84 +#endif 1.85 +}