+/*
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020 Doc.ai and/or its affiliates.
+ * 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <vnet/adj/adj_midchain.h>
#include <vnet/udp/udp.h>
*sw_if_indexp = (u32) ~ 0;
+ /*
+ * Check if the required port is already in use
+ */
+ udp_dst_port_info_t *pi = udp_get_dst_port_info (&udp_main, port, UDP_IP4);
+ if (pi)
+ return VNET_API_ERROR_UDP_PORT_TAKEN;
+
/*
* Allocate a wg_if instance. Either select on dynamically
* or try to use the desired user_instance number.
index_t wgii;
/* *INDENT-OFF* */
- pool_foreach_index (wgii, wg_if_pool,
+ pool_foreach_index (wgii, wg_if_pool)
{
if (WALK_STOP == fn(wgii, data))
break;
- });
+ }
/* *INDENT-ON* */
}