l2: Add bridge_domain_add_del_v2 to l2 api
[vpp.git] / src / vnet / l2 / l2_api.c
index c555a17..cb22547 100644 (file)
@@ -3,6 +3,7 @@
  * l2_api.c - layer 2 forwarding api
  *
  * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Copyright (c) 2022 Nordix Foundation.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -510,6 +511,37 @@ vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
   REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
 }
 
+static void
+vl_api_bridge_domain_add_del_v2_t_handler (
+  vl_api_bridge_domain_add_del_v2_t *mp)
+{
+  vl_api_bridge_domain_add_del_v2_reply_t *rmp;
+  u32 bd_id = ntohl (mp->bd_id);
+  int rv = 0;
+
+  if ((~0 == bd_id) && (mp->is_add))
+    bd_id = bd_get_unused_id ();
+
+  if ((~0 == bd_id) && (mp->is_add))
+    rv = VNET_API_ERROR_EAGAIN;
+  else
+    {
+      l2_bridge_domain_add_del_args_t a = { .is_add = mp->is_add,
+                                           .flood = mp->flood,
+                                           .uu_flood = mp->uu_flood,
+                                           .forward = mp->forward,
+                                           .learn = mp->learn,
+                                           .arp_term = mp->arp_term,
+                                           .arp_ufwd = mp->arp_ufwd,
+                                           .mac_age = mp->mac_age,
+                                           .bd_id = bd_id,
+                                           .bd_tag = mp->bd_tag };
+      rv = bd_add_del (&a);
+    }
+  REPLY_MACRO2 (VL_API_BRIDGE_DOMAIN_ADD_DEL_V2_REPLY,
+               ({ rmp->bd_id = htonl (bd_id); }));
+}
+
 static void
 send_bridge_domain_details (l2input_main_t * l2im,
                            vl_api_registration_t * reg,