summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_route.h
blob: 71b2562b0b47eee7fb4c1e63dc4eba1d2c976716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
 * Copyright (C) 1999 Yasuhiro Ohara
 *
 * This file is part of GNU Zebra.
 *
 * GNU Zebra 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, or (at your option) any
 * later version.
 *
 * GNU Zebra 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Zebra; see the file COPYING.  If not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.  
 */

#ifndef OSPF6_ROUTE_H
#define OSPF6_ROUTE_H

#include "ospf6_hook.h"
#include "ospf6_linklist.h"

struct ospf6_route_table
{
  char name[128];

  int freeze;

  /* radix tree */
  struct route_table *table;

  /* list of hooks */
  struct linklist *hook_list[3];
  void (*hook_add) (void *);
  void (*hook_change) (void *);
  void (*hook_remove) (void *);

  u_int32_t route_id;
};



struct ospf6_route
{
  /* Destination ID */
  struct prefix prefix;

  /* Destination Type */
  u_char type;
};

/* Path */
struct ls_origin
{
  u_int16_t type;
  u_int32_t id;
  u_int32_t adv_router;
};

struct ospf6_path
{
  /* Link State Origin */
  struct ls_origin origin;

  /* Router bits */
  u_char router_bits;

  /* Optional Capabilities */
  u_char capability[3];

  /* Prefix Options */
  u_char prefix_options;

  /* Associated Area */
  u_int32_t area_id;

  /* Path-type */
  u_char type;

  /* Cost */
  u_int8_t metric_type;
  u_int32_t cost;
  u_int32_t cost_e2;
};

/* Nexthop */
struct ospf6_nexthop
{
  /* Interface index */
  unsigned int ifindex;

  /* IP address, if any */
  struct in6_addr address;
};

struct ospf6_route_node
{
  struct ospf6_route_table *table;
  int count;
  u_int32_t route_id;

  struct route_node  *route_node;
  struct ospf6_route  route;
  struct linklist    *path_list;
};

struct ospf6_path_node
{
  struct ospf6_route_node *route_node;
  struct ospf6_path        path;
  struct linklist         *nexthop_list;
};

struct ospf6_nexthop_node
{
  int            flag;
  struct timeval installed;

  struct ospf6_path_node *path_node;
  struct ospf6_nexthop    nexthop;
};

struct ospf6_route_req
{
  struct ospf6_route_table *table;
  struct route_node    *route_node;
  struct linklist_node  path_lnode;
  struct linklist_node  nexthop_lnode;
  u_int32_t route_id;

  int count;
  struct ospf6_route   route;
  struct ospf6_path    path;
  struct ospf6_nexthop nexthop;
};

#define OSPF6_DEST_TYPE_NONE       0
#define OSPF6_DEST_TYPE_ROUTER     1
#define OSPF6_DEST_TYPE_NETWORK    2
#define OSPF6_DEST_TYPE_DISCARD    3
#define OSPF6_DEST_TYPE_MAX        4

#define OSPF6_PATH_TYPE_NONE       0
#define OSPF6_PATH_TYPE_INTRA      1
#define OSPF6_PATH_TYPE_INTER      2
#define OSPF6_PATH_TYPE_EXTERNAL1  3
#define OSPF6_PATH_TYPE_EXTERNAL2  4
#define OSPF6_PATH_TYPE_ZOFFSET    5
#define OSPF6_PATH_TYPE_ZSYSTEM  (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_SYSTEM)
#define OSPF6_PATH_TYPE_ZKERNEL  (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_KERNEL)
#define OSPF6_PATH_TYPE_ZCONNECT (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_CONNECT)
#define OSPF6_PATH_TYPE_ZSTATIC  (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_STATIC)
#define OSPF6_PATH_TYPE_ZRIP     (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIP)
#define OSPF6_PATH_TYPE_ZRIPNG   (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_RIPNG)
#define OSPF6_PATH_TYPE_ZOSPF    (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF)
#define OSPF6_PATH_TYPE_ZOSPF6   (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_OSPF6)
#define OSPF6_PATH_TYPE_ZBGP     (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_BGP)
#define OSPF6_PATH_TYPE_MAX      (OSPF6_PATH_TYPE_ZOFFSET + ZEBRA_ROUTE_MAX)

#define OSPF6_ROUTE_FLAG_ROUTE_CHANGE      0x01
#define OSPF6_ROUTE_FLAG_PATH_CHANGE       0x02
#define OSPF6_ROUTE_FLAG_ADD               0x04
#define OSPF6_ROUTE_FLAG_REMOVE            0x08
#define OSPF6_ROUTE_FLAG_CHANGE            0x10

int ospf6_route_lookup (struct ospf6_route_req *request,
                        struct prefix *prefix,
                        struct ospf6_route_table *table);
void ospf6_route_head  (struct ospf6_route_req *request,
                        struct ospf6_route_table *table);
int  ospf6_route_end   (struct ospf6_route_req *request);
void ospf6_route_next  (struct ospf6_route_req *request);

void ospf6_route_add (struct ospf6_route_req *, struct ospf6_route_table *);
void ospf6_route_remove (struct ospf6_route_req *, struct ospf6_route_table *);
void ospf6_route_remove_all (struct ospf6_route_table *);

struct ospf6_route_table *ospf6_route_table_create ();
void ospf6_route_table_delete (struct ospf6_route_table *);

void ospf6_route_table_freeze (struct ospf6_route_table *);
void ospf6_route_table_thaw (struct ospf6_route_table *);

void ospf6_route_log_request (char *what, char *where,
                              struct ospf6_route_req *request);

void
ospf6_route_hook_register (void (*add)    (struct ospf6_route_req *),
                           void (*change) (struct ospf6_route_req *),
                           void (*remove) (struct ospf6_route_req *),
                           struct ospf6_route_table *table);
void
ospf6_route_hook_unregister (void (*add)    (struct ospf6_route_req *),
                             void (*change) (struct ospf6_route_req *),
                             void (*remove) (struct ospf6_route_req *),
                             struct ospf6_route_table *table);

void ospf6_route_init ();

int ospf6_route_table_show (struct vty *, int, char **,
                            struct ospf6_route_table *);

#endif /* OSPF6_ROUTE_H */