Import Upstream version 1.2.2
[quagga-debian.git] / isisd / isisd.h
1 /*
2  * IS-IS Rout(e)ing protocol - isisd.h   
3  *
4  * Copyright (C) 2001,2002   Sampo Saaristo
5  *                           Tampere University of Technology      
6  *                           Institute of Communications Engineering
7  *
8  * This program is free software; you can redistribute it and/or modify it 
9  * under the terms of the GNU General Public Licenseas published by the Free 
10  * Software Foundation; either version 2 of the License, or (at your option) 
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,but WITHOUT 
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16  * more details.
17
18  * You should have received a copy of the GNU General Public License along 
19  * with this program; if not, write to the Free Software Foundation, Inc., 
20  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifndef ISISD_H
24 #define ISISD_H
25
26 #define ISISD_VERSION "0.0.7"
27
28 #include "isisd/isis_constants.h"
29 #include "isisd/isis_common.h"
30 #include "isisd/isis_redist.h"
31 #include "isis_flags.h"
32 #include "dict.h"
33
34 /* uncomment if you are a developer in bug hunt */
35 /* #define EXTREME_DEBUG  */
36 /* #define EXTREME_TLV_DEBUG */
37
38 struct isis
39 {
40   u_long process_id;
41   int sysid_set;
42   u_char sysid[ISIS_SYS_ID_LEN];        /* SystemID for this IS */
43   u_int32_t router_id;          /* Router ID from zebra */
44   struct list *area_list;       /* list of IS-IS areas */
45   struct list *init_circ_list;
46   struct list *nexthops;        /* IPv4 next hops from this IS */
47 #ifdef HAVE_IPV6
48   struct list *nexthops6;       /* IPv6 next hops from this IS */
49 #endif                          /* HAVE_IPV6 */
50   u_char max_area_addrs;        /* maximumAreaAdresses */
51   struct area_addr *man_area_addrs;     /* manualAreaAddresses */
52   u_int32_t debugs;             /* bitmap for debug */
53   time_t uptime;                /* when did we start */
54   struct thread *t_dync_clean;  /* dynamic hostname cache cleanup thread */
55
56   struct route_table *ext_info[REDIST_PROTOCOL_COUNT];
57 };
58
59 extern struct isis *isis;
60
61 struct isis_area
62 {
63   struct isis *isis;                              /* back pointer */
64   dict_t *lspdb[ISIS_LEVELS];                     /* link-state dbs */
65   struct isis_spftree *spftree[ISIS_LEVELS];      /* The v4 SPTs */
66   struct route_table *route_table[ISIS_LEVELS];   /* IPv4 routes */
67 #ifdef HAVE_IPV6
68   struct isis_spftree *spftree6[ISIS_LEVELS];     /* The v6 SPTs */
69   struct route_table *route_table6[ISIS_LEVELS];  /* IPv6 routes */
70 #endif
71 #define DEFAULT_LSP_MTU 1497
72   unsigned int lsp_mtu;                           /* Size of LSPs to generate */
73   struct list *circuit_list;    /* IS-IS circuits */
74   struct flags flags;
75   struct thread *t_tick;        /* LSP walker */
76   struct thread *t_lsp_refresh[ISIS_LEVELS];
77   /* t_lsp_refresh is used in two ways:
78    * a) regular refresh of LSPs
79    * b) (possibly throttled) updates to LSPs
80    *
81    * The lsp_regenerate_pending flag tracks whether the timer is active
82    * for the a) or the b) case.
83    *
84    * It is of utmost importance to clear this flag when the timer is
85    * rescheduled for normal refresh, because otherwise, updates will
86    * be delayed until the next regular refresh.
87    */
88   int lsp_regenerate_pending[ISIS_LEVELS];
89
90   /*
91    * Configurables 
92    */
93   struct isis_passwd area_passwd;
94   struct isis_passwd domain_passwd;
95   /* do we support dynamic hostnames?  */
96   char dynhostname;
97   /* do we support new style metrics?  */
98   char newmetric;
99   char oldmetric;
100   /* identifies the routing instance   */
101   char *area_tag;
102   /* area addresses for this area      */
103   struct list *area_addrs;
104   u_int16_t max_lsp_lifetime[ISIS_LEVELS];
105   char is_type;                 /* level-1 level-1-2 or level-2-only */
106   /* are we overloaded? */
107   char overload_bit;
108   /* L1/L2 router identifier for inter-area traffic */
109   char attached_bit;
110   u_int16_t lsp_refresh[ISIS_LEVELS];
111   /* minimum time allowed before lsp retransmission */
112   u_int16_t lsp_gen_interval[ISIS_LEVELS];
113   /* min interval between between consequtive SPFs */
114   u_int16_t min_spf_interval[ISIS_LEVELS];
115   /* the percentage of LSP mtu size used, before generating a new frag */
116   int lsp_frag_threshold;
117   int ip_circuits;
118   /* logging adjacency changes? */
119   u_char log_adj_changes;
120 #ifdef HAVE_IPV6
121   int ipv6_circuits;
122 #endif                          /* HAVE_IPV6 */
123   /* Counters */
124   u_int32_t circuit_state_changes;
125   struct isis_redist redist_settings[REDIST_PROTOCOL_COUNT]
126                                     [ZEBRA_ROUTE_MAX + 1][ISIS_LEVELS];
127   struct route_table *ext_reach[REDIST_PROTOCOL_COUNT][ISIS_LEVELS];
128
129 #ifdef TOPOLOGY_GENERATE
130   struct list *topology;
131   u_char topology_baseis[ISIS_SYS_ID_LEN];  /* IS for the first IS emulated. */
132   char *topology_basedynh;                /* Dynamic hostname base. */
133   char top_params[200];                   /* FIXME: what is reasonable? */
134 #endif /* TOPOLOGY_GENERATE */
135 };
136
137 void isis_init (void);
138 void isis_new(unsigned long);
139 struct isis_area *isis_area_create(const char *);
140 struct isis_area *isis_area_lookup (const char *);
141 int isis_area_get (struct vty *vty, const char *area_tag);
142 void print_debug(struct vty *, int, int);
143
144 void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit);
145 void isis_area_attached_bit_set(struct isis_area *area, bool attached_bit);
146 void isis_area_dynhostname_set(struct isis_area *area, bool dynhostname);
147 void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
148                                bool new_metric);
149 void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu);
150 void isis_area_is_type_set(struct isis_area *area, int is_type);
151 void isis_area_max_lsp_lifetime_set(struct isis_area *area, int level,
152                                     uint16_t max_lsp_lifetime);
153 void isis_area_lsp_refresh_set(struct isis_area *area, int level,
154                                uint16_t lsp_refresh);
155 /* IS_LEVEL_1 sets area_passwd, IS_LEVEL_2 domain_passwd */
156 int isis_area_passwd_unset (struct isis_area *area, int level);
157 int isis_area_passwd_cleartext_set (struct isis_area *area, int level,
158                                     const char *passwd, u_char snp_auth);
159 int isis_area_passwd_hmac_md5_set (struct isis_area *area, int level,
160                                    const char *passwd, u_char snp_auth);
161 void isis_vty_init (void);
162
163 /* Master of threads. */
164 extern struct thread_master *master;
165
166 #define DEBUG_ADJ_PACKETS                (1<<0)
167 #define DEBUG_CHECKSUM_ERRORS            (1<<1)
168 #define DEBUG_LOCAL_UPDATES              (1<<2)
169 #define DEBUG_PROTOCOL_ERRORS            (1<<3)
170 #define DEBUG_SNP_PACKETS                (1<<4)
171 #define DEBUG_UPDATE_PACKETS             (1<<5)
172 #define DEBUG_SPF_EVENTS                 (1<<6)
173 #define DEBUG_SPF_STATS                  (1<<7)
174 #define DEBUG_SPF_TRIGGERS               (1<<8)
175 #define DEBUG_RTE_EVENTS                 (1<<9)
176 #define DEBUG_EVENTS                     (1<<10)
177 #define DEBUG_ZEBRA                      (1<<11)
178 #define DEBUG_PACKET_DUMP                (1<<12)
179 #define DEBUG_LSP_GEN                    (1<<13)
180 #define DEBUG_LSP_SCHED                  (1<<14)
181
182 #define lsp_debug(...) \
183   do \
184     { \
185       if (isis->debugs & DEBUG_LSP_GEN) \
186         zlog_debug(__VA_ARGS__); \
187     } \
188   while (0)
189
190 #define sched_debug(...) \
191   do \
192     { \
193       if (isis->debugs & DEBUG_LSP_SCHED) \
194         zlog_debug(__VA_ARGS__); \
195     } \
196   while (0)
197
198 #define DEBUG_TE                         (1<<13)
199
200 #define IS_DEBUG_ISIS(x)                 (isis->debugs & x)
201
202 #endif /* ISISD_H */