1 /*
2
3 route.h
4
5 Author: Pekka Riikonen <priikone@silcnet.org>
6
7 Copyright (C) 2000 - 2002 Pekka Riikonen
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 */
20
21 #ifndef ROUTE_H
22 #define ROUTE_H
23
24 /* Definitions */
25
26 /* Size of the route cache hash table */
27 #define SILC_SERVER_ROUTE_SIZE 256
28
29 /*
30 SILC Server Route table
31
32 Following short description of the fields.
33
34 SilcUInt32 dest
35
36 Destination IPv4 address. Can be used to quickly check whether
37 the found route entry is what the caller wanted.
38
39 SilcServerEntry router
40
41 Pointer to the router specific data.
42
43 */
44 typedef struct {
45 SilcUInt32 dest;
46 SilcServerEntry router;
47 } SilcServerRouteTable;
48
49 /* Route cache hash table */
50 extern SilcServerRouteTable silc_route_cache[SILC_SERVER_ROUTE_SIZE];
51
52 /* Macros and super macros */
53
54 /* Returns route cache hash table entry index. This is IPv4 specific.
55 `port' argument may be zero (0) if it doesn't exist. This has been
56 taken from Linux kernel's route cache code. */
57 static inline
58 SilcUInt32 silc_server_route_hash(unsigned int addr,
59 SilcUInt16 port)
60 {
61 SilcUInt32 hash;
62
63 hash = ((addr & 0xf0f0f0f0) >> 4) | ((addr & 0x0f0f0f0f) << 4);
64 hash ^= port;
65 hash ^= (hash >> 16);
66 hash ^= (hash >> 8);
67
68 return hash & 0xff;
69 }
70
71 /* Prototypes */
72 void silc_server_route_add(SilcUInt32 index, unsigned int dest,
73 SilcServerEntry router);
74 SilcServerEntry silc_server_route_check(SilcUInt32 dest,
75 SilcUInt16 port);
76 SilcSocketConnection silc_server_route_get(SilcServer server, void *id,
77 SilcIdType id_type);
78
79 #endif
80
This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse