]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_lsa.h
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / ospfd / ospf_lsa.h
index 8b9a0d4c490ea67823f3aac5a5a4ebe4810aa1ab..ba4c4c1cacf7e2489e42ffc5046017f039039151 100644 (file)
  * 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.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef _ZEBRA_OSPF_LSA_H
 #define LSA_REFRESH_FORCE      1
 
 /* OSPF LSA header. */
-struct lsa_header
-{
-  u_int16_t ls_age;
-  u_char options;
-  u_char type;
-  struct in_addr id;
-  struct in_addr adv_router;
-  u_int32_t ls_seqnum;
-  u_int16_t checksum;
-  u_int16_t length;
+struct lsa_header {
+       uint16_t ls_age;
+       uint8_t options;
+       uint8_t type;
+       struct in_addr id;
+       struct in_addr adv_router;
+       uint32_t ls_seqnum;
+       uint16_t checksum;
+       uint16_t length;
 };
 
 /* OSPF LSA. */
-struct ospf_lsa
-{
-  /* LSA origination flag. */
-  u_char flags;
+struct ospf_lsa {
+       /* LSA origination flag. */
+       uint8_t flags;
 #define OSPF_LSA_SELF            0x01
 #define OSPF_LSA_SELF_CHECKED    0x02
 #define OSPF_LSA_RECEIVED        0x04
@@ -79,41 +76,44 @@ struct ospf_lsa
 #define OSPF_LSA_PREMATURE_AGE   0x40
 #define OSPF_LSA_IN_MAXAGE       0x80
 
-  /* LSA data. */
-  struct lsa_header *data;
+       /* LSA data. */
+       struct lsa_header *data;
 
-  /* Received time stamp. */
-  struct timeval tv_recv;
+       /* Received time stamp. */
+       struct timeval tv_recv;
 
-  /* Last time it was originated */
-  struct timeval tv_orig;
+       /* Last time it was originated */
+       struct timeval tv_orig;
 
-  /* All of reference count, also lock to remove. */
-  int lock;
+       /* All of reference count, also lock to remove. */
+       int lock;
 
-  /* Flags for the SPF calculation. */
-  int stat;
-  #define LSA_SPF_NOT_EXPLORED -1
-  #define LSA_SPF_IN_SPFTREE   -2
-  /* If stat >= 0, stat is LSA position in candidates heap. */
-  
-  /* References to this LSA in neighbor retransmission lists*/
-  int retransmit_counter;
+       /* Flags for the SPF calculation. */
+       int stat;
+#define LSA_SPF_NOT_EXPLORED -1
+#define LSA_SPF_IN_SPFTREE -2
+       /* If stat >= 0, stat is LSA position in candidates heap. */
 
-  /* Area the LSA belongs to, may be NULL if AS-external-LSA. */
-  struct ospf_area *area;
+       /* References to this LSA in neighbor retransmission lists*/
+       int retransmit_counter;
 
-  /* Parent LSDB. */
-  struct ospf_lsdb *lsdb;
+       /* Area the LSA belongs to, may be NULL if AS-external-LSA. */
+       struct ospf_area *area;
 
-  /* Related Route. */
-  void *route;
+       /* Parent LSDB. */
+       struct ospf_lsdb *lsdb;
 
-  /* Refreshement List or Queue */
-  int refresh_list;
-  
-  /* For Type-9 Opaque-LSAs */
-  struct ospf_interface *oi;
+       /* Related Route. */
+       void *route;
+
+       /* Refreshement List or Queue */
+       int refresh_list;
+
+       /* For Type-9 Opaque-LSAs */
+       struct ospf_interface *oi;
+
+       /* VRF Id */
+       vrf_id_t vrf_id;
 };
 
 /* OSPF LSA Link Type. */
@@ -136,16 +136,14 @@ struct ospf_lsa
 #define IS_ROUTER_LSA_NT(x)            ((x)->flags & ROUTER_LSA_NT)
 
 /* OSPF Router-LSA Link information. */
-struct router_lsa_link
-{
-  struct in_addr link_id;
-  struct in_addr link_data;
-  struct
-  {
-    u_char type;
-    u_char tos_count;
-    u_int16_t metric;
-  } m[1];
+struct router_lsa_link {
+       struct in_addr link_id;
+       struct in_addr link_data;
+       struct {
+               uint8_t type;
+               uint8_t tos_count;
+               uint16_t metric;
+       } m[1];
 };
 
 /* OSPF Router-LSAs structure. */
@@ -157,54 +155,48 @@ struct router_lsa_link
    reached (RFC2328 12.4.1.3). In this case the Router-LSA initially received
    by the other end of the VL will have 0 link descriptor blocks, but soon will
    be replaced with the next revision having 1 descriptor block. */
-struct router_lsa
-{
-  struct lsa_header header;
-  u_char flags;
-  u_char zero;
-  u_int16_t links;
-  struct
-  {
-    struct in_addr link_id;
-    struct in_addr link_data;
-    u_char type;
-    u_char tos;
-    u_int16_t metric;
-  } link[1];
+struct router_lsa {
+       struct lsa_header header;
+       uint8_t flags;
+       uint8_t zero;
+       uint16_t links;
+       struct {
+               struct in_addr link_id;
+               struct in_addr link_data;
+               uint8_t type;
+               uint8_t tos;
+               uint16_t metric;
+       } link[1];
 };
 
 /* OSPF Network-LSAs structure. */
 #define OSPF_NETWORK_LSA_MIN_SIZE                  8U /* w/1 router-ID */
-struct network_lsa
-{
-  struct lsa_header header;
-  struct in_addr mask;
-  struct in_addr routers[1];
+struct network_lsa {
+       struct lsa_header header;
+       struct in_addr mask;
+       struct in_addr routers[1];
 };
 
 /* OSPF Summary-LSAs structure. */
 #define OSPF_SUMMARY_LSA_MIN_SIZE                  8U /* w/1 TOS metric block */
-struct summary_lsa
-{
-  struct lsa_header header;
-  struct in_addr mask;
-  u_char tos;
-  u_char metric[3];
+struct summary_lsa {
+       struct lsa_header header;
+       struct in_addr mask;
+       uint8_t tos;
+       uint8_t metric[3];
 };
 
 /* OSPF AS-external-LSAs structure. */
 #define OSPF_AS_EXTERNAL_LSA_MIN_SIZE             16U /* w/1 TOS forwarding block */
-struct as_external_lsa
-{
-  struct lsa_header header;
-  struct in_addr mask;
-  struct
-  {
-    u_char tos;
-    u_char metric[3];
-    struct in_addr fwd_addr;
-    u_int32_t route_tag;
-  } e[1];
+struct as_external_lsa {
+       struct lsa_header header;
+       struct in_addr mask;
+       struct {
+               uint8_t tos;
+               uint8_t metric[3];
+               struct in_addr fwd_addr;
+               uint32_t route_tag;
+       } e[1];
 };
 
 #include "ospfd/ospf_opaque.h"
@@ -214,121 +206,126 @@ struct as_external_lsa
 #define IS_EXTERNAL_METRIC(x)   ((x) & 0x80)
 
 #define GET_AGE(x)     (ntohs ((x)->data->ls_age) + time (NULL) - (x)->tv_recv)
-#define LS_AGE(x)      (OSPF_LSA_MAXAGE < get_age(x) ? \
-                                           OSPF_LSA_MAXAGE : get_age(x))
+#define LS_AGE(x) (OSPF_LSA_MAXAGE < get_age(x) ? OSPF_LSA_MAXAGE : get_age(x))
 #define IS_LSA_SELF(L)          (CHECK_FLAG ((L)->flags, OSPF_LSA_SELF))
 #define IS_LSA_MAXAGE(L)        (LS_AGE ((L)) == OSPF_LSA_MAXAGE)
 
 #define OSPF_LSA_UPDATE_DELAY          2
 
-#define OSPF_LSA_UPDATE_TIMER_ON(T,F) \
-      if (!(T)) \
-        (T) = thread_add_timer (master, (F), 0, 2)
+#define OSPF_LSA_UPDATE_TIMER_ON(T, F)                                         \
+       if (!(T))                                                              \
+       (T) = thread_add_timer(master, (F), 0, 2)
 
 /* Prototypes. */
 /* XXX: Eek, time functions, similar are in lib/thread.c */
-extern struct timeval int2tv (int);
-extern struct timeval msec2tv (int);
+extern struct timeval int2tv(int);
+extern struct timeval msec2tv(int);
 
-extern int get_age (struct ospf_lsa *);
-extern u_int16_t ospf_lsa_checksum (struct lsa_header *);
-extern int ospf_lsa_checksum_valid (struct lsa_header *);
-extern int ospf_lsa_refresh_delay (struct ospf_lsa *);
+extern int get_age(struct ospf_lsa *);
+extern uint16_t ospf_lsa_checksum(struct lsa_header *);
+extern int ospf_lsa_checksum_valid(struct lsa_header *);
+extern int ospf_lsa_refresh_delay(struct ospf_lsa *);
 
-extern const char *dump_lsa_key (struct ospf_lsa *);
-extern u_int32_t lsa_seqnum_increment (struct ospf_lsa *);
-extern void lsa_header_set (struct stream *, u_char, u_char, struct in_addr,
-                    struct in_addr);
-extern struct ospf_neighbor *ospf_nbr_lookup_ptop (struct ospf_interface *);
-extern int ospf_check_nbr_status (struct ospf *);
+extern const char *dump_lsa_key(struct ospf_lsa *);
+extern uint32_t lsa_seqnum_increment(struct ospf_lsa *);
+extern void lsa_header_set(struct stream *, uint8_t, uint8_t, struct in_addr,
+                          struct in_addr);
+extern struct ospf_neighbor *ospf_nbr_lookup_ptop(struct ospf_interface *);
+extern int ospf_check_nbr_status(struct ospf *);
 
 /* Prototype for LSA primitive. */
-extern struct ospf_lsa *ospf_lsa_new (void);
-extern struct ospf_lsa *ospf_lsa_dup (struct ospf_lsa *);
-extern void ospf_lsa_free (struct ospf_lsa *);
-extern struct ospf_lsa *ospf_lsa_lock (struct ospf_lsa *);
-extern void ospf_lsa_unlock (struct ospf_lsa **);
-extern void ospf_lsa_discard (struct ospf_lsa *);
-extern int ospf_lsa_flush_schedule (struct ospf *, struct ospf_lsa *);
-extern struct lsa_header *ospf_lsa_data_new (size_t);
-extern struct lsa_header *ospf_lsa_data_dup (struct lsa_header *);
-extern void ospf_lsa_data_free (struct lsa_header *);
+extern struct ospf_lsa *ospf_lsa_new(void);
+extern struct ospf_lsa *ospf_lsa_new_and_data(size_t size);
+extern struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *);
+extern void ospf_lsa_free(struct ospf_lsa *);
+extern struct ospf_lsa *ospf_lsa_lock(struct ospf_lsa *);
+extern void ospf_lsa_unlock(struct ospf_lsa **);
+extern void ospf_lsa_discard(struct ospf_lsa *);
+extern int ospf_lsa_flush_schedule(struct ospf *, struct ospf_lsa *);
+extern struct lsa_header *ospf_lsa_data_new(size_t);
+extern struct lsa_header *ospf_lsa_data_dup(struct lsa_header *);
+extern void ospf_lsa_data_free(struct lsa_header *);
 
 /* Prototype for various LSAs */
-extern int ospf_router_lsa_update (struct ospf *);
-extern int ospf_router_lsa_update_area (struct ospf_area *);
-
-extern void ospf_network_lsa_update (struct ospf_interface *);
-
-extern struct ospf_lsa *ospf_summary_lsa_originate (struct prefix_ipv4 *, u_int32_t,
-                                            struct ospf_area *);
-extern struct ospf_lsa *ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *,
-                                                 u_int32_t,
-                                                 struct ospf_area *);
-
-extern struct ospf_lsa *ospf_lsa_install (struct ospf *,
-                                  struct ospf_interface *, struct ospf_lsa *);
-
-extern void ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p);
-extern void ospf_external_lsa_flush (struct ospf *, u_char, struct prefix_ipv4 *,
-                                    ifindex_t /* , struct in_addr nexthop */);
-
-extern struct in_addr ospf_get_ip_from_ifp (struct ospf_interface *);
-
-extern struct ospf_lsa *ospf_external_lsa_originate (struct ospf *, struct external_info *);
-extern int ospf_external_lsa_originate_timer (struct thread *);
-extern int ospf_default_originate_timer (struct thread *);
-extern struct ospf_lsa *ospf_lsa_lookup (struct ospf_area *, u_int32_t,
-                                 struct in_addr, struct in_addr);
-extern struct ospf_lsa *ospf_lsa_lookup_by_id (struct ospf_area *,
-                                        u_int32_t, 
-                                        struct in_addr);
-extern struct ospf_lsa *ospf_lsa_lookup_by_header (struct ospf_area *,
-                                           struct lsa_header *);
-extern int ospf_lsa_more_recent (struct ospf_lsa *, struct ospf_lsa *);
-extern int ospf_lsa_different (struct ospf_lsa *, struct ospf_lsa *);
-extern void ospf_flush_self_originated_lsas_now (struct ospf *);
-
-extern int ospf_lsa_is_self_originated (struct ospf *, struct ospf_lsa *);
-
-extern struct ospf_lsa *ospf_lsa_lookup_by_prefix (struct ospf_lsdb *, u_char,
-                                           struct prefix_ipv4 *,
-                                           struct in_addr);
-
-extern void ospf_lsa_maxage (struct ospf *, struct ospf_lsa *);
-extern u_int32_t get_metric (u_char *);
-
-extern int ospf_lsa_maxage_walker (struct thread *);
-extern struct ospf_lsa *ospf_lsa_refresh (struct ospf *, struct ospf_lsa *);
-extern void ospf_external_lsa_refresh_default (struct ospf *);
-
-extern void ospf_external_lsa_refresh_type (struct ospf *, u_char, u_short, int);
-extern struct ospf_lsa *ospf_external_lsa_refresh (struct ospf *,
-                                                   struct ospf_lsa *,
-                                                   struct external_info *,
-                                                   int);
-extern struct in_addr ospf_lsa_unique_id (struct ospf *, struct ospf_lsdb *, u_char,
-                                  struct prefix_ipv4 *);
-extern void ospf_schedule_lsa_flood_area (struct ospf_area *, struct ospf_lsa *);
-extern void ospf_schedule_lsa_flush_area (struct ospf_area *, struct ospf_lsa *);
-
-extern void ospf_refresher_register_lsa (struct ospf *, struct ospf_lsa *);
-extern void ospf_refresher_unregister_lsa (struct ospf *, struct ospf_lsa *);
-extern int ospf_lsa_refresh_walker (struct thread *);
-
-extern void ospf_lsa_maxage_delete (struct ospf *, struct ospf_lsa *);
-
-extern void ospf_discard_from_db (struct ospf *, struct ospf_lsdb *, struct ospf_lsa*);
-extern int is_prefix_default (struct prefix_ipv4 *);
-
-extern int metric_type (struct ospf *, u_char, u_short);
-extern int metric_value (struct ospf *, u_char, u_short);
-
-extern struct in_addr ospf_get_nssa_ip (struct ospf_area *);
-extern int ospf_translated_nssa_compare (struct ospf_lsa *, struct ospf_lsa *);
-extern struct ospf_lsa *ospf_translated_nssa_refresh (struct ospf *, struct ospf_lsa *,
-                                   struct ospf_lsa *);
-extern struct ospf_lsa *ospf_translated_nssa_originate (struct ospf *, struct ospf_lsa *);
+extern int ospf_router_lsa_update(struct ospf *);
+extern int ospf_router_lsa_update_area(struct ospf_area *);
+
+extern void ospf_network_lsa_update(struct ospf_interface *);
+
+extern struct ospf_lsa *
+ospf_summary_lsa_originate(struct prefix_ipv4 *, uint32_t, struct ospf_area *);
+extern struct ospf_lsa *ospf_summary_asbr_lsa_originate(struct prefix_ipv4 *,
+                                                       uint32_t,
+                                                       struct ospf_area *);
+
+extern struct ospf_lsa *ospf_lsa_install(struct ospf *, struct ospf_interface *,
+                                        struct ospf_lsa *);
+
+extern void ospf_nssa_lsa_flush(struct ospf *ospf, struct prefix_ipv4 *p);
+extern void ospf_external_lsa_flush(struct ospf *, uint8_t,
+                                   struct prefix_ipv4 *,
+                                   ifindex_t /* , struct in_addr nexthop */);
+
+extern struct in_addr ospf_get_ip_from_ifp(struct ospf_interface *);
+
+extern struct ospf_lsa *ospf_external_lsa_originate(struct ospf *,
+                                                   struct external_info *);
+extern int ospf_external_lsa_originate_timer(struct thread *);
+extern int ospf_default_originate_timer(struct thread *);
+extern struct ospf_lsa *ospf_lsa_lookup(struct ospf *ospf, struct ospf_area *,
+                                       uint32_t, struct in_addr,
+                                       struct in_addr);
+extern struct ospf_lsa *ospf_lsa_lookup_by_id(struct ospf_area *, uint32_t,
+                                             struct in_addr);
+extern struct ospf_lsa *ospf_lsa_lookup_by_header(struct ospf_area *,
+                                                 struct lsa_header *);
+extern int ospf_lsa_more_recent(struct ospf_lsa *, struct ospf_lsa *);
+extern int ospf_lsa_different(struct ospf_lsa *, struct ospf_lsa *);
+extern void ospf_flush_self_originated_lsas_now(struct ospf *);
+
+extern int ospf_lsa_is_self_originated(struct ospf *, struct ospf_lsa *);
+
+extern struct ospf_lsa *ospf_lsa_lookup_by_prefix(struct ospf_lsdb *, uint8_t,
+                                                 struct prefix_ipv4 *,
+                                                 struct in_addr);
+
+extern void ospf_lsa_maxage(struct ospf *, struct ospf_lsa *);
+extern uint32_t get_metric(uint8_t *);
+
+extern int ospf_lsa_maxage_walker(struct thread *);
+extern struct ospf_lsa *ospf_lsa_refresh(struct ospf *, struct ospf_lsa *);
+
+extern void ospf_external_lsa_refresh_default(struct ospf *);
+
+extern void ospf_external_lsa_refresh_type(struct ospf *, uint8_t,
+                                          unsigned short, int);
+extern struct ospf_lsa *ospf_external_lsa_refresh(struct ospf *,
+                                                 struct ospf_lsa *,
+                                                 struct external_info *, int);
+extern struct in_addr ospf_lsa_unique_id(struct ospf *, struct ospf_lsdb *,
+                                        uint8_t, struct prefix_ipv4 *);
+extern void ospf_schedule_lsa_flood_area(struct ospf_area *, struct ospf_lsa *);
+extern void ospf_schedule_lsa_flush_area(struct ospf_area *, struct ospf_lsa *);
+
+extern void ospf_refresher_register_lsa(struct ospf *, struct ospf_lsa *);
+extern void ospf_refresher_unregister_lsa(struct ospf *, struct ospf_lsa *);
+extern int ospf_lsa_refresh_walker(struct thread *);
+
+extern void ospf_lsa_maxage_delete(struct ospf *, struct ospf_lsa *);
+
+extern void ospf_discard_from_db(struct ospf *, struct ospf_lsdb *,
+                                struct ospf_lsa *);
+extern int is_prefix_default(struct prefix_ipv4 *);
+
+extern int metric_type(struct ospf *, uint8_t, unsigned short);
+extern int metric_value(struct ospf *, uint8_t, unsigned short);
+
+extern struct in_addr ospf_get_nssa_ip(struct ospf_area *);
+extern int ospf_translated_nssa_compare(struct ospf_lsa *, struct ospf_lsa *);
+extern struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *,
+                                                    struct ospf_lsa *,
+                                                    struct ospf_lsa *);
+extern struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *,
+                                                      struct ospf_lsa *);
 
 #endif /* _ZEBRA_OSPF_LSA_H */