ikev2: support responder hostname
[vpp.git] / src / plugins / ikev2 / ikev2_test.c
index 98b3fa0..b63778e 100644 (file)
@@ -1060,6 +1060,53 @@ api_ikev2_set_tunnel_interface (vat_main_t * vam)
   return (0);
 }
 
+static int
+api_ikev2_set_responder_hostname (vat_main_t *vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_ikev2_set_responder_hostname_t *mp;
+  int ret;
+  u8 *name = 0, *hn = 0;
+
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "%U hostname %v", unformat_token, valid_chars, &name,
+                   &hn))
+       {
+         vec_add1 (name, 0);
+         vec_add1 (hn, 0);
+       }
+      else
+       {
+         errmsg ("parse error '%U'", format_unformat_error, i);
+         return -99;
+       }
+    }
+
+  if (!vec_len (name))
+    {
+      errmsg ("profile name must be specified");
+      return -99;
+    }
+
+  if (vec_len (name) > 64)
+    {
+      errmsg ("profile name too long");
+      return -99;
+    }
+
+  M (IKEV2_SET_RESPONDER_HOSTNAME, mp);
+
+  clib_memcpy (mp->name, name, vec_len (name));
+  clib_memcpy (mp->hostname, hn, vec_len (hn));
+  vec_free (name);
+  vec_free (hn);
+
+  S (mp);
+  W (ret);
+  return ret;
+}
+
 static int
 api_ikev2_set_responder (vat_main_t * vam)
 {