jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_lsp.h |
| 3 | * LSP processing |
| 4 | * |
| 5 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 6 | * Tampere University of Technology |
| 7 | * Institute of Communications Engineering |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public Licenseas published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | */ |
| 23 | |
| 24 | #ifndef _ZEBRA_ISIS_LSP_H |
| 25 | #define _ZEBRA_ISIS_LSP_H |
| 26 | |
| 27 | /* The grand plan is to support 1024 circuits so we have 32*32 bit flags |
| 28 | * the support will be achived using the newest drafts */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 29 | #define ISIS_MAX_CIRCUITS 32 /* = 1024 - FIXME:defined in flags.h as well */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 30 | |
| 31 | /* Structure for isis_lsp, this structure will only support the fixed |
| 32 | * System ID (Currently 6) (atleast for now). In order to support more |
| 33 | * We will have to split the header into two parts, and for readability |
| 34 | * sake it should better be avoided */ |
| 35 | struct isis_lsp |
| 36 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 37 | struct isis_fixed_hdr *isis_header; /* normally equals pdu */ |
| 38 | struct isis_link_state_hdr *lsp_header; /* pdu + isis_header_len */ |
| 39 | struct stream *pdu; /* full pdu lsp */ |
| 40 | union |
| 41 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 42 | struct list *frags; |
| 43 | struct isis_lsp *zero_lsp; |
| 44 | } lspu; |
| 45 | u_int32_t SRMflags[ISIS_MAX_CIRCUITS]; |
| 46 | u_int32_t SSNflags[ISIS_MAX_CIRCUITS]; |
| 47 | u_int32_t rexmit_queue[ISIS_MAX_CIRCUITS]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 48 | int level; /* L1 or L2? */ |
| 49 | int purged; /* have purged this one */ |
| 50 | int scheduled; /* scheduled for sending */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 51 | time_t installed; |
| 52 | time_t last_generated; |
| 53 | time_t last_sent; |
| 54 | int own_lsp; |
| 55 | #ifdef TOPOLOGY_GENERATE |
| 56 | int from_topology; |
| 57 | struct thread *t_lsp_top_ref; |
| 58 | #endif |
| 59 | /* used for 60 second counting when rem_lifetime is zero */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 60 | int age_out; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 61 | struct isis_adjacency *adj; |
hasso | f1082d1 | 2005-09-19 04:23:34 +0000 | [diff] [blame] | 62 | /* FIXME: For now only topology LSP's use this. Is it helpful for others? */ |
| 63 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 64 | struct tlvs tlv_data; /* Simplifies TLV access */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | dict_t *lsp_db_init (void); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 68 | void lsp_db_destroy (dict_t * lspdb); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 69 | int lsp_tick (struct thread *thread); |
| 70 | |
| 71 | int lsp_l1_generate (struct isis_area *area); |
| 72 | int lsp_l2_generate (struct isis_area *area); |
| 73 | int lsp_refresh_l1 (struct thread *thread); |
| 74 | int lsp_refresh_l2 (struct thread *thread); |
| 75 | int lsp_regenerate_schedule (struct isis_area *area); |
| 76 | |
| 77 | int lsp_l1_pseudo_generate (struct isis_circuit *circuit); |
| 78 | int lsp_l2_pseudo_generate (struct isis_circuit *circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 79 | int lsp_l1_refresh_pseudo (struct thread *thread); |
| 80 | int lsp_l2_refresh_pseudo (struct thread *thread); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 81 | int isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 82 | int pdulen, struct isis_passwd *passwd); |
| 83 | struct isis_lsp *lsp_new (u_char * lsp_id, u_int16_t rem_lifetime, |
| 84 | u_int32_t seq_num, u_int8_t lsp_bits, |
| 85 | u_int16_t checksum, int level); |
| 86 | struct isis_lsp *lsp_new_from_stream_ptr (struct stream *stream, |
| 87 | u_int16_t pdu_len, |
| 88 | struct isis_lsp *lsp0, |
| 89 | struct isis_area *area); |
| 90 | void lsp_insert (struct isis_lsp *lsp, dict_t * lspdb); |
| 91 | struct isis_lsp *lsp_search (u_char * id, dict_t * lspdb); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 92 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 93 | void lsp_build_list (u_char * start_id, u_char * stop_id, |
| 94 | struct list *list, dict_t * lspdb); |
| 95 | void lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id, |
| 96 | struct list *list, dict_t * lspdb); |
| 97 | void lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list, |
| 98 | dict_t * lspdb); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 99 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 100 | void lsp_search_and_destroy (u_char * id, dict_t * lspdb); |
| 101 | void lsp_purge_dr (u_char * id, struct isis_circuit *circuit, int level); |
| 102 | void lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr, |
| 103 | struct isis_area *area); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 104 | |
| 105 | #define LSP_EQUAL 1 |
| 106 | #define LSP_NEWER 2 |
| 107 | #define LSP_OLDER 3 |
| 108 | |
hasso | c83dcd3 | 2004-09-26 15:42:44 +0000 | [diff] [blame] | 109 | #define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN]) |
| 110 | #define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1]) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 111 | #define OWNLSPID(I) \ |
| 112 | memcpy ((I), isis->sysid, ISIS_SYS_ID_LEN);\ |
| 113 | (I)[ISIS_SYS_ID_LEN] = 0;\ |
| 114 | (I)[ISIS_SYS_ID_LEN + 1] = 0 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 115 | int lsp_id_cmp (u_char * id1, u_char * id2); |
| 116 | int lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num, |
| 117 | u_int16_t checksum, u_int16_t rem_lifetime); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 118 | void lsp_update (struct isis_lsp *lsp, struct isis_link_state_hdr *lsp_hdr, |
hasso | a96d8d1 | 2005-09-16 14:44:23 +0000 | [diff] [blame] | 119 | struct stream *stream, struct isis_area *area, int level); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 120 | void lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 121 | int lsp_print_all (struct vty *vty, dict_t * lspdb, char detail, |
| 122 | char dynhost); |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 123 | const char *lsp_bits2string (u_char *); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 124 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 125 | #ifdef TOPOLOGY_GENERATE |
| 126 | void generate_topology_lsps (struct isis_area *area); |
| 127 | void remove_topology_lsps (struct isis_area *area); |
| 128 | void build_topology_lsp_data (struct isis_lsp *lsp, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 129 | struct isis_area *area, int lsp_top_num); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 130 | #endif /* TOPOLOGY_GENERATE */ |
| 131 | |
| 132 | #endif /* ISIS_LSP */ |