/* route.c Author: Pekka Riikonen Copyright (C) 2000 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /* * Route cache routines. Server uses these to route packets to specific * routes. If route entry doesn't exist for a specific destination, server * uses primary route (default route). */ /* * $Id$ * $Log$ * Revision 1.1 2000/06/27 11:36:56 priikone * Initial revision * * */ #include "serverincludes.h" #include "route.h" /* Route cache hash table */ 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, SilcServerList *router) { silc_route_cache[index].dest = dest; silc_route_cache[index].router = router; } /* Checksk whether destination has a specific router. Returns the router data if found, NULL otherwise. */ SilcServerList *silc_server_route_check(unsigned int dest, unsigned short port) { unsigned int index; index = silc_server_route_hash(dest, port); if (silc_route_cache[index].router != NULL && silc_route_cache[index].dest == dest) return silc_route_cache[index].router; return NULL; }