]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_encap_tlv.c
bgpd: Additional check on presence of tag/label
[mirror_frr.git] / bgpd / bgp_encap_tlv.c
index c554ade27eeb56cf2a80cfe79cd40485a7b3c6ce..eee2cb72c3d3d91501ee65457aed5376571edd9b 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 this program; 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
  */
 
 #include <zebra.h>
 
+#include "command.h"
 #include "memory.h"
 #include "prefix.h"
-#include "vty.h"
 #include "filter.h"
 
 #include "bgpd.h"
@@ -390,8 +389,30 @@ bgp_encap_type_vxlan_to_tlv(
     struct attr                                *attr)
 {
     struct attr_extra                  *extra = bgp_attr_extra_get(attr);
+    struct bgp_attr_encap_subtlv       *tlv;
+    uint32_t vnid;
 
     extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN;
+
+    if(bet == NULL ||!bet->vnid)
+      return;
+    if(extra->encap_subtlvs)
+      XFREE(MTYPE_ENCAP_TLV, extra->encap_subtlvs);
+    tlv = XCALLOC (MTYPE_ENCAP_TLV, sizeof(struct bgp_attr_encap_subtlv)-1+12);
+    tlv->type = 1; /* encapsulation type */
+    tlv->length = 12;
+    if(bet->vnid)
+      {
+        vnid = htonl(bet->vnid | VXLAN_ENCAP_MASK_VNID_VALID);
+        memcpy(&tlv->value, &vnid, 4);
+      }
+    if(bet->mac_address)
+      {
+        char *ptr = (char *)&tlv->value + 4;
+        memcpy( ptr, bet->mac_address, 6);
+      }
+    extra->encap_subtlvs = tlv;
+    return;
 }
 
 void