X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Froute.c;h=a762edfa63828cb84c810ece51a556907016eee6;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=5edd731512182d2c9a3a1a4d1d4bbf9f759b145d;hpb=318d79b391bf6288e3e28c840217a7097f3d0392;p=silc.git diff --git a/apps/silcd/route.c b/apps/silcd/route.c index 5edd7315..a762edfa 100644 --- a/apps/silcd/route.c +++ b/apps/silcd/route.c @@ -22,27 +22,13 @@ * routes. If route entry doesn't exist for a specific destination, server * uses primary route (default route). */ -/* - * $Id$ - * $Log$ - * Revision 1.4 2000/07/12 05:59:41 priikone - * Major rewrite of ID Cache system. Support added for the new - * ID cache system. Major rewrite of ID List stuff on server. All - * SilcXXXList's are now called SilcXXXEntry's and they are pointers - * by default. A lot rewritten ID list functions. - * - * Revision 1.3 2000/07/05 06:14:01 priikone - * Global costemic changes. - * - * Revision 1.2 2000/07/04 08:30:24 priikone - * Added silc_server_get_route to return communication object - * for fastest route. - * - * Revision 1.1.1.1 2000/06/27 11:36:56 priikone - * Imported from internal CVS/Added Log headers. - * - * - */ +/* 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" #include "server_internal.h" @@ -54,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; @@ -64,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); @@ -82,36 +68,40 @@ 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) { - unsigned int dest = 0; - unsigned short port = 0; - SilcServerEntry router = NULL; - - if (server->server_type == SILC_SERVER) - return (SilcSocketConnection)server->id_entry->router->connection; - - switch(id_type) { - case SILC_ID_CLIENT: - dest = ((SilcClientID *)id)->ip.s_addr; - port = server->id->port; - break; - case SILC_ID_SERVER: - dest = ((SilcServerID *)id)->ip.s_addr; - port = ((SilcServerID *)id)->port; - break; - case SILC_ID_CHANNEL: - dest = ((SilcChannelID *)id)->ip.s_addr; - port = ((SilcChannelID *)id)->port; - break; - default: - return NULL; + if (server->server_type == SILC_ROUTER) { + SilcUInt32 dest = 0; + SilcUInt16 port = 0; + SilcServerEntry router = NULL; +#if 0 + + switch(id_type) { + case SILC_ID_CLIENT: + dest = ((SilcClientID *)id)->ip.s_addr; + port = server->id->port; + break; + case SILC_ID_SERVER: + dest = ((SilcServerID *)id)->ip.s_addr; + port = ((SilcServerID *)id)->port; + break; + case SILC_ID_CHANNEL: + dest = ((SilcChannelID *)id)->ip.s_addr; + port = ((SilcChannelID *)id)->port; + break; + default: + return NULL; + } + +#endif + + router = silc_server_route_check(dest, port); + if (!router) + return (SilcSocketConnection)server->id_entry->router->connection; + + return (SilcSocketConnection)router->connection; } - router = silc_server_route_check(dest, port); - if (!router) - return (SilcSocketConnection)server->id_entry->router->connection; - - return (SilcSocketConnection)router->connection; + return (SilcSocketConnection)server->id_entry->router->connection; }