]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_te.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_te.h
index ed71e54f5404c79b26a0d27e4bf16b1c6f040628..49906ef713aacc9a9dcc534868adf0b70d30c4bc 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * This is an implementation of RFC3630, RFC5392 & RFC6827
  * Copyright (C) 2001 KDD R&D Laboratories, Inc.
@@ -5,22 +6,6 @@
  *
  * Copyright (C) 2012 Orange Labs
  * http://www.orange.com
- *
- * 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 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
  */
 
 /* Add support of RFC7471 */
 #define GMPLS          0x02
 #define INTER_AS       0x04
 #define PSEUDO_TE      0x08
-#define FLOOD_AREA     0x10
-#define FLOOD_AS       0x20
-#define EMULATED       0x80
+#define EMULATED       0x10
 
-#define IS_STD_TE(x)       (x & STD_TE)
+#define IS_STD_TE(x)           (x & STD_TE)
 #define IS_PSEUDO_TE(x)                (x & PSEUDO_TE)
 #define IS_INTER_AS(x)                 (x & INTER_AS)
 #define IS_EMULATED(x)         (x & EMULATED)
-#define IS_FLOOD_AREA(x)       (x & FLOOD_AREA)
-#define IS_FLOOD_AS(x)         (x & FLOOD_AS)
-#define IS_INTER_AS_EMU(x)     (x & INTER_AS & EMULATED)
-#define IS_INTER_AS_AS(x)      (x & INTER_AS & FLOOD_AS)
 
 /* Flags to manage TE Link LSA */
-#define LPFLG_LSA_INACTIVE             0x0
-#define LPFLG_LSA_ACTIVE               0x1
-#define LPFLG_LSA_ENGAGED              0x2
-#define LPFLG_LOOKUP_DONE              0x4
-#define LPFLG_LSA_FORCED_REFRESH       0x8
+#define LPFLG_LSA_INACTIVE             0x00
+#define LPFLG_LSA_ACTIVE               0x01
+#define LPFLG_LSA_ENGAGED              0x02
+#define LPFLG_LOOKUP_DONE              0x04
+#define LPFLG_LSA_FORCED_REFRESH       0x08
+#define LPFLG_LSA_FLOOD_AS             0x10
+
+#define IS_FLOOD_AS(x)         (x & LPFLG_LSA_FLOOD_AS)
+
+/* Macro to log debug message */
+#define ote_debug(...)                                                         \
+       do {                                                                   \
+               if (IS_DEBUG_OSPF_TE)                                          \
+                       zlog_debug(__VA_ARGS__);                               \
+       } while (0)
 
 /*
  * Following section defines TLV body parts.
@@ -123,8 +112,8 @@ struct te_link_subtlv_link_type {
        struct {
 #define        LINK_TYPE_SUBTLV_VALUE_PTP      1
 #define        LINK_TYPE_SUBTLV_VALUE_MA       2
-               u_char value;
-               u_char padding[3];
+               uint8_t value;
+               uint8_t padding[3];
        } link_type;
 };
 
@@ -132,49 +121,49 @@ struct te_link_subtlv_link_type {
 #define        TE_LINK_SUBTLV_LINK_ID          2
 struct te_link_subtlv_link_id {
        struct tlv_header header; /* Value length is 4 octets. */
-       struct in_addr value;   /* Same as router-lsa's link-id. */
+       struct in_addr value;     /* Same as router-lsa's link-id. */
 };
 
 /* Link Sub-TLV: Local Interface IP Address */ /* Optional */
 #define        TE_LINK_SUBTLV_LCLIF_IPADDR     3
 struct te_link_subtlv_lclif_ipaddr {
        struct tlv_header header; /* Value length is 4 x N octets. */
-       struct in_addr value[1];     /* Local IP address(es). */
+       struct in_addr value[1];  /* Local IP address(es). */
 };
 
 /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */
 #define        TE_LINK_SUBTLV_RMTIF_IPADDR     4
 struct te_link_subtlv_rmtif_ipaddr {
        struct tlv_header header; /* Value length is 4 x N octets. */
-       struct in_addr value[1];     /* Neighbor's IP address(es). */
+       struct in_addr value[1];  /* Neighbor's IP address(es). */
 };
 
 /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */
 #define        TE_LINK_SUBTLV_TE_METRIC        5
 struct te_link_subtlv_te_metric {
        struct tlv_header header; /* Value length is 4 octets. */
-       u_int32_t value;             /* Link metric for TE purpose. */
+       uint32_t value;           /* Link metric for TE purpose. */
 };
 
 /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */
 #define        TE_LINK_SUBTLV_MAX_BW           6
 struct te_link_subtlv_max_bw {
        struct tlv_header header; /* Value length is 4 octets. */
-       float value;                 /* bytes/sec */
+       float value;              /* bytes/sec */
 };
 
 /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */
 #define        TE_LINK_SUBTLV_MAX_RSV_BW       7
 struct te_link_subtlv_max_rsv_bw {
        struct tlv_header header; /* Value length is 4 octets. */
-       float value;                 /* bytes/sec */
+       float value;              /* bytes/sec */
 };
 
 /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */
 #define        TE_LINK_SUBTLV_UNRSV_BW         8
 #define TE_LINK_SUBTLV_UNRSV_SIZE      32
 struct te_link_subtlv_unrsv_bw {
-       struct tlv_header header; /* Value length is 32 octets. */
+       struct tlv_header header;    /* Value length is 32 octets. */
        float value[MAX_CLASS_TYPE]; /* One for each priority level. */
 };
 
@@ -182,7 +171,7 @@ struct te_link_subtlv_unrsv_bw {
 #define        TE_LINK_SUBTLV_RSC_CLSCLR       9
 struct te_link_subtlv_rsc_clsclr {
        struct tlv_header header; /* Value length is 4 octets. */
-       u_int32_t value;             /* Admin. group membership. */
+       uint32_t value;           /* Admin. group membership. */
 };
 
 /* For RFC6827 */
@@ -191,8 +180,8 @@ struct te_link_subtlv_rsc_clsclr {
 #define TE_LINK_SUBTLV_LRRID_SIZE      8
 struct te_link_subtlv_lrrid {
        struct tlv_header header; /* Value length is 8 octets. */
-       struct in_addr local;   /* Local TE Router Identifier */
-       struct in_addr remote;       /* Remote TE Router Identifier */
+       struct in_addr local;     /* Local TE Router Identifier */
+       struct in_addr remote;    /* Remote TE Router Identifier */
 };
 
 /* RFC4203: Link Local/Remote Identifiers */
@@ -200,8 +189,8 @@ struct te_link_subtlv_lrrid {
 #define TE_LINK_SUBTLV_LLRI_SIZE       8
 struct te_link_subtlv_llri {
        struct tlv_header header; /* Value length is 8 octets. */
-       u_int32_t local;             /* Link Local Identifier */
-       u_int32_t remote;           /* Link Remote Identifier */
+       uint32_t local;           /* Link Local Identifier */
+       uint32_t remote;          /* Link Remote Identifier */
 };
 
 /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13)
@@ -215,14 +204,14 @@ struct te_link_subtlv_llri {
 #define TE_LINK_SUBTLV_RAS             21
 struct te_link_subtlv_ras {
        struct tlv_header header; /* Value length is 4 octets. */
-       u_int32_t value;             /* Remote AS number */
+       uint32_t value;           /* Remote AS number */
 };
 
 /* IPv4 Remote ASBR ID Sub-TLV */
 #define TE_LINK_SUBTLV_RIP             22
 struct te_link_subtlv_rip {
        struct tlv_header header; /* Value length is 4 octets. */
-       struct in_addr value;   /* Remote ASBR IP address */
+       struct in_addr value;     /* Remote ASBR IP address */
 };
 
 /* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */
@@ -240,7 +229,7 @@ struct te_link_subtlv_av_delay {
         * delay in micro-seconds only 24 bits => 0 ... 16777215
         * with Anomalous Bit as Upper most bit
         */
-       u_int32_t value;
+       uint32_t value;
 };
 
 /* Link Sub-TLV: Low/High Link Delay */
@@ -252,9 +241,9 @@ struct te_link_subtlv_mm_delay {
         * low delay in micro-seconds only 24 bits => 0 ... 16777215
         * with Anomalous Bit (A) as Upper most bit
         */
-       u_int32_t low;
+       uint32_t low;
        /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */
-       u_int32_t high;
+       uint32_t high;
 };
 
 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
@@ -262,7 +251,7 @@ struct te_link_subtlv_mm_delay {
 struct te_link_subtlv_delay_var {
        struct tlv_header header; /* Value length is 4 bytes. */
        /* interval in micro-seconds only 24 bits => 0 ... 16777215 */
-       u_int32_t value;
+       uint32_t value;
 };
 
 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
@@ -273,7 +262,7 @@ struct te_link_subtlv_pkt_loss {
         * in percentage of total traffic only 24 bits (2^24 - 2)
         * with Anomalous Bit as Upper most bit
         */
-       u_int32_t value;
+       uint32_t value;
 };
 
 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
@@ -311,23 +300,23 @@ enum inter_as_mode { Off, AS, Area };
 struct te_link_subtlv {
        struct tlv_header header;
        union {
-               u_int32_t link_type;
+               uint32_t link_type;
                struct in_addr link_id;
                struct in_addr lclif;
                struct in_addr rmtif;
-               u_int32_t te_metric;
+               uint32_t te_metric;
                float max_bw;
                float max_rsv_bw;
                float unrsv[8];
-               u_int32_t rsc_clsclr;
-               u_int32_t llri[2];
-               u_int32_t ras;
+               uint32_t rsc_clsclr;
+               uint32_t llri[2];
+               uint32_t ras;
                struct in_addr rip;
                struct in_addr lrrid[2];
-               u_int32_t av_delay;
-               u_int32_t mm_delay;
-               u_int32_t delay_var;
-               u_int32_t pkt_loss;
+               uint32_t av_delay;
+               uint32_t mm_delay;
+               uint32_t delay_var;
+               uint32_t pkt_loss;
                float res_bw;
                float ava_bw;
                float use_bw;
@@ -336,9 +325,13 @@ struct te_link_subtlv {
 
 /* Following structure are internal use only. */
 struct ospf_mpls_te {
-       /* Status of MPLS-TE: enable or disbale */
+       /* Status of MPLS-TE: enable or disable */
        bool enabled;
 
+       /* Traffic Engineering Database i.e. Link State */
+       struct ls_ted *ted;
+       bool export;
+
        /* RFC5392 */
        enum inter_as_mode inter_as;
        struct in_addr interas_areaid;
@@ -357,7 +350,7 @@ struct mpls_te_link {
         * is subdivided into 8-bit "unused" field and 16-bit "instance" field.
         * In this implementation, each Link-TLV has its own instance.
         */
-       u_int32_t instance;
+       uint32_t instance;
 
        /* Reference pointer to a Zebra-interface. */
        struct interface *ifp;
@@ -366,10 +359,10 @@ struct mpls_te_link {
        struct ospf_area *area;
 
        /* Flags to manage this link parameters. */
-       u_int32_t flags;
+       uint32_t flags;
 
        /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */
-       u_int8_t type;
+       uint8_t type;
 
        /* Store Link-TLV in network byte order. */
        /* RFC3630 & RFC6827 / RFC 6827 */
@@ -410,8 +403,19 @@ extern void ospf_mpls_te_finish(void);
 extern struct ospf_mpls_te *get_ospf_mpls_te(void);
 extern void ospf_mpls_te_update_if(struct interface *);
 extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *, enum lsa_opcode);
-extern void set_linkparams_llri(struct mpls_te_link *, u_int32_t, u_int32_t);
+extern void set_linkparams_llri(struct mpls_te_link *, uint32_t, uint32_t);
 extern void set_linkparams_lrrid(struct mpls_te_link *, struct in_addr,
                                 struct in_addr);
 
+struct zapi_opaque_reg_info;
+/**
+ * Call when a client send a Link State Sync message. In turn, OSPF will send
+ * the contain of the Link State Data base.
+ *
+ * @param info    ZAPI Opaque message information
+ *
+ * @return       0 on success, -1 otherwise
+ */
+extern int ospf_te_sync_ted(struct zapi_opaque_reg_info dst);
+
 #endif /* _ZEBRA_OSPF_MPLS_TE_H */