summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_intra.h
blob: 8a9474a815f7f653a6d58cc45766095b8ab85708 (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
210
211
212
213
214
/*
 * Copyright (C) 2003 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_INTRA_H
#define OSPF6_INTRA_H

/* Debug option */
extern unsigned char conf_debug_ospf6_brouter;
extern u_int32_t conf_debug_ospf6_brouter_specific_router_id;
extern u_int32_t conf_debug_ospf6_brouter_specific_area_id;
#define OSPF6_DEBUG_BROUTER_SUMMARY         0x01
#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA   0x04
#define OSPF6_DEBUG_BROUTER_ON() \
  (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
#define OSPF6_DEBUG_BROUTER_OFF() \
  (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
#define IS_OSPF6_DEBUG_BROUTER \
  (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)

#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id)             \
  do {                                                                \
    conf_debug_ospf6_brouter_specific_router_id = (router_id);        \
    conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER;  \
  } while (0)
#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF()                     \
  do {                                                                \
    conf_debug_ospf6_brouter_specific_router_id = 0;                  \
    conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
  } while (0)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER                        \
  (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id)          \
  (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER &&                          \
   conf_debug_ospf6_brouter_specific_router_id == (router_id))

#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id)                 \
  do {                                                                \
    conf_debug_ospf6_brouter_specific_area_id = (area_id);            \
    conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA;    \
  } while (0)
#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF()                       \
  do {                                                                \
    conf_debug_ospf6_brouter_specific_area_id = 0;                    \
    conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA;   \
  } while (0)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA                          \
  (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id)              \
  (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA &&                            \
   conf_debug_ospf6_brouter_specific_area_id == (area_id))

/* Router-LSA */
struct ospf6_router_lsa
{
  u_char bits;
  u_char options[3];
  /* followed by ospf6_router_lsdesc(s) */
};

/* Link State Description in Router-LSA */
struct ospf6_router_lsdesc
{
  u_char    type;
  u_char    reserved;
  u_int16_t metric;                /* output cost */
  u_int32_t interface_id;
  u_int32_t neighbor_interface_id;
  u_int32_t neighbor_router_id;
};

#define OSPF6_ROUTER_LSDESC_POINTTOPOINT       1
#define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK    2
#define OSPF6_ROUTER_LSDESC_STUB_NETWORK       3
#define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK       4

#define ROUTER_LSDESC_IS_TYPE(t,x)                         \
  ((((struct ospf6_router_lsdesc *)(x))->type ==           \
   OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0)
#define ROUTER_LSDESC_GET_METRIC(x)                        \
  (ntohs (((struct ospf6_router_lsdesc *)(x))->metric))
#define ROUTER_LSDESC_GET_IFID(x)                          \
  (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id))
#define ROUTER_LSDESC_GET_NBR_IFID(x)                      \
  (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
#define ROUTER_LSDESC_GET_NBR_ROUTERID(x)                  \
  (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)

/* Network-LSA */
struct ospf6_network_lsa
{
  u_char reserved;
  u_char options[3];
  /* followed by ospf6_netowrk_lsd(s) */
};

/* Link State Description in Router-LSA */
struct ospf6_network_lsdesc
{
  u_int32_t router_id;
};
#define NETWORK_LSDESC_GET_NBR_ROUTERID(x)                  \
  (((struct ospf6_network_lsdesc *)(x))->router_id)

/* Link-LSA */
struct ospf6_link_lsa
{
  u_char          priority;
  u_char          options[3];
  struct in6_addr linklocal_addr;
  u_int32_t       prefix_num;
  /* followed by ospf6 prefix(es) */
};

/* Intra-Area-Prefix-LSA */
struct ospf6_intra_prefix_lsa
{
  u_int16_t prefix_num;
  u_int16_t ref_type;
  u_int32_t ref_id;
  u_int32_t ref_adv_router;
  /* followed by ospf6 prefix(es) */
};


#define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
  do { \
    if (! (oa)->thread_router_lsa) \
      (oa)->thread_router_lsa = \
        thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
  } while (0)
#define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
  do { \
    if (! (oi)->thread_network_lsa) \
      (oi)->thread_network_lsa = \
        thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
  } while (0)
#define OSPF6_LINK_LSA_SCHEDULE(oi) \
  do { \
    if (! (oi)->thread_link_lsa) \
      (oi)->thread_link_lsa = \
        thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
  } while (0)
#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
  do { \
    if (! (oa)->thread_intra_prefix_lsa) \
      (oa)->thread_intra_prefix_lsa = \
        thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
                          oa, 0); \
  } while (0)
#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
  do { \
    if (! (oi)->thread_intra_prefix_lsa) \
      (oi)->thread_intra_prefix_lsa = \
        thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
                          oi, 0); \
  } while (0)

#define OSPF6_NETWORK_LSA_EXECUTE(oi) \
  do { \
    THREAD_OFF ((oi)->thread_network_lsa); \
    thread_execute (master, ospf6_network_lsa_originate, oi, 0); \
  } while (0)
#define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
  do { \
    THREAD_OFF ((oi)->thread_intra_prefix_lsa); \
    thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \
  } while (0)


/* Function Prototypes */
char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id,
                            u_int32_t neighbor_interface_id,
                            u_int32_t neighbor_router_id,
                            struct ospf6_lsa *lsa);
char *ospf6_network_lsdesc_lookup (u_int32_t router_id,
                                   struct ospf6_lsa *lsa);

int ospf6_router_lsa_originate (struct thread *);
int ospf6_network_lsa_originate (struct thread *);
int ospf6_link_lsa_originate (struct thread *);
int ospf6_intra_prefix_lsa_originate_transit (struct thread *);
int ospf6_intra_prefix_lsa_originate_stub (struct thread *);
void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa);
void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa);

void ospf6_intra_route_calculation (struct ospf6_area *oa);
void ospf6_intra_brouter_calculation (struct ospf6_area *oa);

void ospf6_intra_init ();

int config_write_ospf6_debug_brouter (struct vty *vty);
void install_element_ospf6_debug_brouter ();

#endif /* OSPF6_LSA_H */