X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Froute.c;h=5488bb315659a5417fbaf692ecbf5ae8b065e807;hb=c257b555225193e54d85daf541d29578b3c93882;hp=149683a479a6bea7a4e89c3c9584283b7e024714;hpb=0578dc954acedf413762549287c0487cfb070686;p=silc.git diff --git a/apps/silcd/route.c b/apps/silcd/route.c index 149683a4..5488bb31 100644 --- a/apps/silcd/route.c +++ b/apps/silcd/route.c @@ -2,9 +2,9 @@ route.c - Author: Pekka Riikonen + Author: Pekka Riikonen - Copyright (C) 2000 Pekka Riikonen + Copyright (C) 2000 - 2002 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,12 @@ * routes. If route entry doesn't exist for a specific destination, server * uses primary route (default route). */ +/* XXX Adding two ID's with same IP number replaces the old entry thus + gives wrong route. Thus, now disabled until figured out a better way + to do this or when removed the whole thing. This could be removed + because entry->router->connection gives always the most optimal route + for the ID anyway (unless new routes (faster perhaps) are established + after receiving this ID, this we don't know however). */ /* $Id$ */ #include "serverincludes.h" @@ -34,7 +40,7 @@ SilcServerRouteTable silc_route_cache[SILC_SERVER_ROUTE_SIZE]; /* Adds new route to the route cache. The argument `index' is the index value generated by silc_server_route_hash. */ -void silc_server_route_add(unsigned int index, unsigned int dest, +void silc_server_route_add(SilcUInt32 index, unsigned int dest, SilcServerEntry router) { silc_route_cache[index].dest = dest; @@ -44,10 +50,10 @@ void silc_server_route_add(unsigned int index, unsigned int dest, /* Checksk whether destination has a specific router. Returns the router data if found, NULL otherwise. */ -SilcServerEntry silc_server_route_check(unsigned int dest, - unsigned short port) +SilcServerEntry silc_server_route_check(SilcUInt32 dest, + SilcUInt16 port) { - unsigned int index; + SilcUInt32 index; index = silc_server_route_hash(dest, port); @@ -62,13 +68,14 @@ SilcServerEntry silc_server_route_check(unsigned int dest, If we are normal server then this just returns our primary route. If we are router we will do route lookup. */ -SilcSocketConnection silc_server_get_route(SilcServer server, void *id, +SilcSocketConnection silc_server_route_get(SilcServer server, void *id, SilcIdType id_type) { if (server->server_type == SILC_ROUTER) { - unsigned int dest; - unsigned short port; + SilcUInt32 dest = 0; + SilcUInt16 port = 0; SilcServerEntry router = NULL; +#if 0 switch(id_type) { case SILC_ID_CLIENT: @@ -87,12 +94,14 @@ SilcSocketConnection silc_server_get_route(SilcServer server, void *id, return NULL; } - router = silc_server_route_check(dest, port); - if (!router) - return (SilcSocketConnection)server->id_entry->router->connection; +#endif - return (SilcSocketConnection)router->connection; + router = silc_server_route_check(dest, port); + if (router) + return (SilcSocketConnection)router->connection; } - return (SilcSocketConnection)server->id_entry->router->connection; + return (server->id_entry->router) + ? (SilcSocketConnection)server->id_entry->router->connection + : NULL; }