ia64/xen-unstable

view tools/vnet/vnetd/vcache.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
1 /*
2 * Copyright (C) 2004 Mike Wray <mike.wray@hp.com>.
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2.1 of the
7 * License, or (at your option) any later version. This library is
8 * distributed in the hope that it will be useful, but WITHOUT ANY
9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE.
11 * See the GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17 #ifndef _VNET_VCACHE_H_
18 #define _VNET_VCACHE_H_
20 #include "hash_table.h"
22 /** Time-to-live of varp cache entries (in seconds).*/
23 #define VCACHE_ENTRY_TTL 30.0
25 /** Maximum number of varp probes to make. */
26 #define VCACHE_PROBE_MAX 5
28 /** Interval between varp probes (in seconds). */
29 #define VCACHE_PROBE_INTERVAL 3.0
31 /** Delay before forwarding a local probe (in seconds). */
32 #define VCACHE_LOCAL_DELAY 2.0
34 /** Number of buckets in the varp cache (must be prime). */
35 #define VCACHE_BUCKETS 3001
37 enum {
38 VCACHE_STATE_INCOMPLETE = 1,
39 VCACHE_STATE_REACHABLE = 2,
40 VCACHE_STATE_FAILED = 3
41 };
43 enum {
44 VCACHE_FLAG_PROBING = 1,
45 VCACHE_FLAG_PERMANENT = 2,
46 VCACHE_FLAG_LOCAL_PROBE = 4,
47 VCACHE_FLAG_REMOTE_PROBE = 8,
48 };
51 #include <asm/byteorder.h>
52 /*
53 * Display an IP address in readable format.
54 */
56 #define NIPQUAD(addr) \
57 ((unsigned char *)&addr)[0], \
58 ((unsigned char *)&addr)[1], \
59 ((unsigned char *)&addr)[2], \
60 ((unsigned char *)&addr)[3]
62 #if defined(__LITTLE_ENDIAN)
63 #define HIPQUAD(addr) \
64 ((unsigned char *)&addr)[3], \
65 ((unsigned char *)&addr)[2], \
66 ((unsigned char *)&addr)[1], \
67 ((unsigned char *)&addr)[0]
68 #elif defined(__BIG_ENDIAN)
69 #define HIPQUAD NIPQUAD
70 #else
71 #error "Please fix asm/byteorder.h"
72 #endif /* __LITTLE_ENDIAN */
74 #define IPFMT "%u.%u.%u.%u"
75 #define MACFMT "%02x:%02x:%02x:%02x:%02x:%02x"
77 #define MAC6TUPLE(_mac) (_mac)[0], (_mac)[1], (_mac)[2], (_mac)[3], (_mac)[4], (_mac)[5]
79 typedef struct IPMessage {
80 Conn *conn;
81 struct sockaddr_in saddr;
82 struct sockaddr_in daddr;
83 void *data;
84 struct IPMessage *next;
85 } IPMessage;
87 typedef struct IPMessageQueue {
88 IPMessage *msg;
89 int len;
90 int maxlen;
91 } IPMessageQueue;
93 /** Key for varp cache entries. */
94 typedef struct VCKey {
95 /** Vnet id (network order). */
96 VnetId vnet;
97 /** Virtual MAC address. */
98 Vmac vmac;
99 } VCKey;
101 typedef struct VCEntry {
102 /** Key for the entry. */
103 VCKey key;
105 /** Care-of address for the key. */
106 VarpAddr addr;
108 /** Alias coa if we are a gateway. */
109 //uint32_t gateway;
110 /** Encapsulation to use (if a gateway). */
111 //uint32_t encaps;
113 /** Where this entry came from. */
114 VarpAddr source;
116 /** Last-updated timestamp. */
117 double timestamp;
119 /** State. */
120 short state;
122 /** Flags. */
123 short flags;
125 /** Number of probes sent. */
126 int probes;
128 /** List of messages to reply to when completes. */
129 IPMessageQueue queue;
131 } VCEntry;
133 /** The varp cache. Varp cache entries indexed by VCKey. */
134 typedef struct VarpCache {
135 HashTable *table;
136 } VarpCache;
138 int vcache_init(void);
139 int vcache_handle_message(IPMessage *msg, int local);
141 #endif /* ! _VNET_VCACHE_H_ */