]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_label.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / bgpd / bgp_label.h
index 523671468b7846f1c4184ebc62330e9a5100645b..ac7fbb27fbe964ef3ea8f9f05a3dd1a18ce478fa 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* BGP carrying Label information
  * Copyright (C) 2013 Cumulus Networks, Inc.
- *
- * 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
  */
 
 #ifndef _BGP_LABEL_H
 #define BGP_WITHDRAW_LABEL 0x800000
 #define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
 
-struct bgp_node;
+struct bgp_dest;
 struct bgp_path_info;
 struct peer;
 
 extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
                                    bool allocated);
-extern void bgp_reg_dereg_for_label(struct bgp_node *rn,
+extern void bgp_reg_dereg_for_label(struct bgp_dest *dest,
                                    struct bgp_path_info *pi, bool reg);
 extern int bgp_parse_fec_update(void);
-extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi,
-                                 struct peer *to, afi_t afi, safi_t safi);
+extern mpls_label_t bgp_adv_label(struct bgp_dest *dest,
+                                 struct bgp_path_info *pi, struct peer *to,
+                                 afi_t afi, safi_t safi);
 
 extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
                                struct bgp_nlri *packet);
@@ -64,7 +50,7 @@ static inline int bgp_is_withdraw_label(mpls_label_t *label)
        return 0;
 }
 
-static inline int bgp_is_valid_label(mpls_label_t *label)
+static inline int bgp_is_valid_label(const mpls_label_t *label)
 {
        uint8_t *t = (uint8_t *)label;
        if (!t)
@@ -86,34 +72,15 @@ static inline void bgp_unset_valid_label(mpls_label_t *label)
                t[2] &= ~0x02;
 }
 
-static inline void bgp_register_for_label(struct bgp_node *rn,
+static inline void bgp_register_for_label(struct bgp_dest *dest,
                                          struct bgp_path_info *pi)
 {
-       bgp_reg_dereg_for_label(rn, pi, true);
+       bgp_reg_dereg_for_label(dest, pi, true);
 }
 
-static inline void bgp_unregister_for_label(struct bgp_node *rn)
+static inline void bgp_unregister_for_label(struct bgp_dest *dest)
 {
-       bgp_reg_dereg_for_label(rn, NULL, false);
-}
-
-/* Label stream to value */
-static inline uint32_t label_pton(mpls_label_t *label)
-{
-       uint8_t *t = (uint8_t *)label;
-       return ((((unsigned int)t[0]) << 12) | (((unsigned int)t[1]) << 4)
-               | ((unsigned int)((t[2] & 0xF0) >> 4)));
-}
-
-/* Encode label values */
-static inline void label_ntop(uint32_t l, int bos, mpls_label_t *label)
-{
-       uint8_t *t = (uint8_t *)label;
-       t[0] = ((l & 0x000FF000) >> 12);
-       t[1] = ((l & 0x00000FF0) >> 4);
-       t[2] = ((l & 0x0000000F) << 4);
-       if (bos)
-               t[2] |= 0x01;
+       bgp_reg_dereg_for_label(dest, NULL, false);
 }
 
 /* Return BOS value of label stream */