~ubuntu-branches/ubuntu/warty/quagga/warty

« back to all changes in this revision

Viewing changes to ripngd/ripngd.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2004-06-29 09:50:59 UTC
  • Revision ID: james.westby@ubuntu.com-20040629095059-px1m2m108z4qw1mr
Tags: upstream-0.96.5
ImportĀ upstreamĀ versionĀ 0.96.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * RIPng related value and structure.
 
3
 * Copyright (C) 1998 Kunihiro Ishiguro
 
4
 *
 
5
 * This file is part of GNU Zebra.
 
6
 *
 
7
 * GNU Zebra is free software; you can redistribute it and/or modify it
 
8
 * under the terms of the GNU General Public License as published by the
 
9
 * Free Software Foundation; either version 2, or (at your option) any
 
10
 * later version.
 
11
 *
 
12
 * GNU Zebra is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with GNU Zebra; see the file COPYING.  If not, write to the Free
 
19
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
 * 02111-1307, USA.  
 
21
 */
 
22
 
 
23
#ifndef _ZEBRA_RIPNG_RIPNGD_H
 
24
#define _ZEBRA_RIPNG_RIPNGD_H
 
25
 
 
26
/* RIPng version and port number. */
 
27
#define RIPNG_V1                         1
 
28
#define RIPNG_PORT_DEFAULT             521
 
29
#define RIPNG_VTY_PORT                2603
 
30
#define RIPNG_MAX_PACKET_SIZE         1500
 
31
#define RIPNG_PRIORITY_DEFAULT           0
 
32
 
 
33
/* RIPng commands. */
 
34
#define RIPNG_REQUEST                    1
 
35
#define RIPNG_RESPONSE                   2
 
36
 
 
37
/* RIPng metric and multicast group address. */
 
38
#define RIPNG_METRIC_INFINITY           16
 
39
#define RIPNG_METRIC_NEXTHOP          0xff
 
40
#define RIPNG_GROUP              "ff02::9"
 
41
 
 
42
/* RIPng timers. */
 
43
#define RIPNG_UPDATE_TIMER_DEFAULT      30
 
44
#define RIPNG_TIMEOUT_TIMER_DEFAULT    180
 
45
#define RIPNG_GARBAGE_TIMER_DEFAULT    120
 
46
 
 
47
/* RIPng peer timeout value. */
 
48
#define RIPNG_PEER_TIMER_DEFAULT       180
 
49
 
 
50
/* Default config file name. */
 
51
#define RIPNG_DEFAULT_CONFIG "ripngd.conf"
 
52
 
 
53
/* RIPng route types. */
 
54
#define RIPNG_ROUTE_RTE                  0
 
55
#define RIPNG_ROUTE_STATIC               1
 
56
#define RIPNG_ROUTE_DEFAULT              2
 
57
#define RIPNG_ROUTE_REDISTRIBUTE         3
 
58
#define RIPNG_ROUTE_INTERFACE            4
 
59
#define RIPNG_ROUTE_AGGREGATE            5
 
60
 
 
61
/* Interface send/receive configuration. */
 
62
#define RIPNG_SEND_UNSPEC                0
 
63
#define RIPNG_SEND_OFF                   1
 
64
#define RIPNG_RECEIVE_UNSPEC             0
 
65
#define RIPNG_RECEIVE_OFF                1
 
66
 
 
67
/* RIP default route's accept/announce methods. */
 
68
#define RIPNG_DEFAULT_ADVERTISE_UNSPEC   0
 
69
#define RIPNG_DEFAULT_ADVERTISE_NONE     1
 
70
#define RIPNG_DEFAULT_ADVERTISE          2
 
71
 
 
72
#define RIPNG_DEFAULT_ACCEPT_UNSPEC      0
 
73
#define RIPNG_DEFAULT_ACCEPT_NONE        1
 
74
#define RIPNG_DEFAULT_ACCEPT             2
 
75
 
 
76
/* Default value for "default-metric" command. */
 
77
#define RIPNG_DEFAULT_METRIC_DEFAULT     1
 
78
 
 
79
/* For max RTE calculation. */
 
80
#ifndef IPV6_HDRLEN
 
81
#define IPV6_HDRLEN 40
 
82
#endif /* IPV6_HDRLEN */
 
83
 
 
84
#ifndef IFMINMTU
 
85
#define IFMINMTU    576
 
86
#endif /* IFMINMTU */
 
87
 
 
88
/* RIPng structure. */
 
89
struct ripng 
 
90
{
 
91
  /* RIPng socket. */
 
92
  int sock;
 
93
 
 
94
  /* RIPng Parameters.*/
 
95
  u_char command;
 
96
  u_char version;
 
97
  unsigned long update_time;
 
98
  unsigned long timeout_time;
 
99
  unsigned long garbage_time;
 
100
  int max_mtu;
 
101
  int default_metric;
 
102
  int default_information;
 
103
 
 
104
  /* Input/output buffer of RIPng. */
 
105
  struct stream *ibuf;
 
106
  struct stream *obuf;
 
107
 
 
108
  /* RIPng routing information base. */
 
109
  struct route_table *table;
 
110
 
 
111
  /* RIPng only static route information. */
 
112
  struct route_table *route;
 
113
 
 
114
  /* RIPng aggregate route information. */
 
115
  struct route_table *aggregate;
 
116
 
 
117
  /* RIPng threads. */
 
118
  struct thread *t_read;
 
119
  struct thread *t_write;
 
120
  struct thread *t_update;
 
121
  struct thread *t_garbage;
 
122
  struct thread *t_zebra;
 
123
 
 
124
  /* Triggered update hack. */
 
125
  int trigger;
 
126
  struct thread *t_triggered_update;
 
127
  struct thread *t_triggered_interval;
 
128
 
 
129
  /* For redistribute route map. */
 
130
  struct
 
131
  {
 
132
    char *name;
 
133
    struct route_map *map;
 
134
    int metric_config;
 
135
    u_int32_t metric;
 
136
  } route_map[ZEBRA_ROUTE_MAX];
 
137
};
 
138
 
 
139
/* Routing table entry. */
 
140
struct rte
 
141
{
 
142
  struct in6_addr addr; /* RIPng destination prefix */
 
143
  u_short tag;          /* RIPng tag */
 
144
  u_char prefixlen;     /* Length of the RIPng prefix */
 
145
  u_char metric;        /* Metric of the RIPng route */
 
146
                        /* The nexthop is stored by the structure
 
147
                         * ripng_nexthop within ripngd.c */
 
148
};
 
149
 
 
150
/* RIPNG send packet. */
 
151
struct ripng_packet
 
152
{
 
153
  u_char command;
 
154
  u_char version;
 
155
  u_int16_t zero; 
 
156
  struct rte rte[1];
 
157
};
 
158
 
 
159
/* Each route's information. */
 
160
struct ripng_info
 
161
{
 
162
  /* This route's type.  Static, ripng or aggregate. */
 
163
  u_char type;
 
164
 
 
165
  /* Sub type for static route. */
 
166
  u_char sub_type;
 
167
 
 
168
  /* RIPng specific information */
 
169
  struct in6_addr nexthop;      
 
170
  struct in6_addr from;
 
171
 
 
172
  /* Which interface does this route come from. */
 
173
  unsigned int ifindex;         
 
174
 
 
175
  /* Metric of this route.  */
 
176
  u_char metric;                
 
177
 
 
178
  /* Tag field of RIPng packet.*/
 
179
  u_int16_t tag;                
 
180
 
 
181
  /* For aggregation. */
 
182
  unsigned int suppress;
 
183
 
 
184
  /* Flags of RIPng route. */
 
185
#define RIPNG_RTF_FIB      1
 
186
#define RIPNG_RTF_CHANGED  2
 
187
  u_char flags;
 
188
 
 
189
  /* Garbage collect timer. */
 
190
  struct thread *t_timeout;
 
191
  struct thread *t_garbage_collect;
 
192
 
 
193
  /* Route-map features - this variables can be changed. */
 
194
  struct in6_addr nexthop_out;
 
195
  u_char metric_set;
 
196
  u_char metric_out;
 
197
  u_short tag_out;
 
198
 
 
199
  struct route_node *rp;
 
200
};
 
201
 
 
202
#ifdef notyet
 
203
#if 0
 
204
/* RIPng tag structure. */
 
205
struct ripng_tag
 
206
{
 
207
  /* Tag value. */
 
208
  u_int16_t tag;
 
209
 
 
210
  /* Port. */
 
211
  u_int16_t port;
 
212
 
 
213
  /* Multicast group. */
 
214
  struct in6_addr maddr;
 
215
 
 
216
  /* Table number. */
 
217
  int table;
 
218
 
 
219
  /* Distance. */
 
220
  int distance;
 
221
 
 
222
  /* Split horizon. */
 
223
  u_char split_horizon;
 
224
 
 
225
  /* Poison reverse. */
 
226
  u_char poison_reverse;
 
227
};
 
228
#endif /* 0 */
 
229
#endif /* not yet */
 
230
 
 
231
typedef enum {
 
232
  RIPNG_NO_SPLIT_HORIZON = 0,
 
233
  RIPNG_SPLIT_HORIZON,
 
234
  RIPNG_SPLIT_HORIZON_POISONED_REVERSE
 
235
} split_horizon_policy_t;
 
236
 
 
237
/* RIPng specific interface configuration. */
 
238
struct ripng_interface
 
239
{
 
240
  /* RIPng is enabled on this interface. */
 
241
  int enable_network;
 
242
  int enable_interface;
 
243
 
 
244
  /* RIPng is running on this interface. */
 
245
  int running;
 
246
 
 
247
  /* Split horizon flag. */
 
248
  split_horizon_policy_t split_horizon;
 
249
  split_horizon_policy_t split_horizon_default;
 
250
  
 
251
  /* For filter type slot. */
 
252
#define RIPNG_FILTER_IN  0
 
253
#define RIPNG_FILTER_OUT 1
 
254
#define RIPNG_FILTER_MAX 2
 
255
 
 
256
  /* Access-list. */
 
257
  struct access_list *list[RIPNG_FILTER_MAX];
 
258
 
 
259
  /* Prefix-list. */
 
260
  struct prefix_list *prefix[RIPNG_FILTER_MAX];
 
261
 
 
262
  /* Route-map. */
 
263
  struct route_map *routemap[RIPNG_FILTER_MAX];
 
264
 
 
265
#ifdef notyet
 
266
#if 0
 
267
  /* RIPng tag configuration. */
 
268
  struct ripng_tag *rtag;
 
269
#endif /* 0 */
 
270
#endif /* notyet */
 
271
 
 
272
  /* Default information originate. */
 
273
  u_char default_originate;
 
274
 
 
275
  /* Default information only. */
 
276
  u_char default_only;
 
277
 
 
278
  /* Wake up thread. */
 
279
  struct thread *t_wakeup;
 
280
 
 
281
  /* Passive interface. */
 
282
  int passive;
 
283
};
 
284
 
 
285
/* RIPng peer information. */
 
286
struct ripng_peer
 
287
{
 
288
  /* Peer address. */
 
289
  struct in6_addr addr;
 
290
 
 
291
  /* Peer RIPng tag value. */
 
292
  int domain;
 
293
 
 
294
  /* Last update time. */
 
295
  time_t uptime;
 
296
 
 
297
  /* Peer RIP version. */
 
298
  u_char version;
 
299
 
 
300
  /* Statistics. */
 
301
  int recv_badpackets;
 
302
  int recv_badroutes;
 
303
 
 
304
  /* Timeout thread. */
 
305
  struct thread *t_timeout;
 
306
};
 
307
 
 
308
/* All RIPng events. */
 
309
enum ripng_event
 
310
{
 
311
  RIPNG_READ,
 
312
  RIPNG_ZEBRA,
 
313
  RIPNG_REQUEST_EVENT,
 
314
  RIPNG_UPDATE_EVENT,
 
315
  RIPNG_TRIGGERED_UPDATE,
 
316
};
 
317
 
 
318
/* RIPng timer on/off macro. */
 
319
#define RIPNG_TIMER_ON(T,F,V) \
 
320
do { \
 
321
   if (!(T)) \
 
322
      (T) = thread_add_timer (master, (F), rinfo, (V)); \
 
323
} while (0)
 
324
 
 
325
#define RIPNG_TIMER_OFF(T) \
 
326
do { \
 
327
   if (T) \
 
328
     { \
 
329
       thread_cancel(T); \
 
330
       (T) = NULL; \
 
331
     } \
 
332
} while (0)
 
333
 
 
334
/* Count prefix size from mask length */
 
335
#define PSIZE(a) (((a) + 7) / (8))
 
336
 
 
337
/* Extern variables. */
 
338
extern struct ripng *ripng;
 
339
 
 
340
extern struct thread_master *master;
 
341
 
 
342
/* Prototypes. */
 
343
void ripng_init ();
 
344
void ripng_reset ();
 
345
void ripng_clean ();
 
346
void ripng_clean_network ();
 
347
void ripng_interface_clean ();
 
348
void ripng_interface_reset ();
 
349
void ripng_passive_interface_clean ();
 
350
void ripng_if_init ();
 
351
void ripng_route_map_init ();
 
352
void ripng_route_map_reset ();
 
353
void ripng_terminate ();
 
354
 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
 
355
void zebra_init ();
 
356
void ripng_zclient_start ();
 
357
void ripng_zclient_reset ();
 
358
void ripng_offset_init ();
 
359
 
 
360
int config_write_ripng_offset_list (struct vty *);
 
361
 
 
362
void ripng_peer_init ();
 
363
void ripng_peer_update (struct sockaddr_in6 *, u_char);
 
364
void ripng_peer_bad_route (struct sockaddr_in6 *);
 
365
void ripng_peer_bad_packet (struct sockaddr_in6 *);
 
366
void ripng_peer_display (struct vty *);
 
367
struct ripng_peer *ripng_peer_lookup (struct in6_addr *);
 
368
struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *);
 
369
 
 
370
int ripng_offset_list_apply_in (struct prefix_ipv6 *, struct interface *, u_char *);
 
371
int ripng_offset_list_apply_out (struct prefix_ipv6 *, struct interface *, u_char *);
 
372
void ripng_offset_clean ();
 
373
 
 
374
struct ripng_info * ripng_info_new ();
 
375
void ripng_info_free (struct ripng_info *rinfo);
 
376
void ripng_event (enum ripng_event, int);
 
377
int ripng_request (struct interface *ifp);
 
378
void ripng_redistribute_add (int, int, struct prefix_ipv6 *, unsigned int,
 
379
                             struct in6_addr *);
 
380
void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, unsigned int);
 
381
void ripng_redistribute_withdraw (int type);
 
382
 
 
383
void ripng_distribute_update_interface (struct interface *);
 
384
void ripng_if_rmap_update_interface (struct interface *);
 
385
 
 
386
void ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
 
387
void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
 
388
 
 
389
void ripng_redistribute_clean ();
 
390
 
 
391
const char *inet6_ntop (struct in6_addr *p);
 
392
 
 
393
int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p,
 
394
                     struct in6_addr *nexthop, u_int16_t tag, u_char metric);
 
395
int ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to, 
 
396
                       struct interface *ifp);
 
397
 
 
398
void ripng_packet_dump (struct ripng_packet *packet, int size, char *sndrcv);
 
399
 
 
400
 
 
401
#endif /* _ZEBRA_RIPNG_RIPNGD_H */