ip: Replace Sematics for Interface IP addresses
[vpp.git] / src / plugins / ioam / ioam_test.c
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <vat/vat.h>
17 #include <vlibapi/api.h>
18 #include <vlibmemory/api.h>
19 #include <vnet/format_fns.h>
20 #include <vnet/ip/ip_types_api.h>
21
22 clib_error_t * vxlan_gpe_ioam_export_vat_plugin_register (vat_main_t * vam);
23 clib_error_t * pot_vat_plugin_register (vat_main_t *vam);
24 clib_error_t * trace_vat_plugin_register (vat_main_t * vam);
25 clib_error_t * vxlan_gpe_vat_plugin_register (vat_main_t * vam);
26 clib_error_t * udp_ping_vat_plugin_register (vat_main_t * vam);
27 clib_error_t * ioam_export_vat_plugin_register (vat_main_t * vam);
28
29 clib_error_t *
30 vat_plugin_register (vat_main_t *vam)
31 {
32   clib_error_t *err;
33
34   if ((err = pot_vat_plugin_register (vam)))
35     return err;
36
37   if ((err = vxlan_gpe_ioam_export_vat_plugin_register (vam)))
38     return err;
39
40   if ((err = trace_vat_plugin_register (vam)))
41     return err;
42
43   if ((err = vxlan_gpe_vat_plugin_register(vam)))
44     return err;
45
46   if ((err = udp_ping_vat_plugin_register (vam)))
47     return err;
48
49   if ((err = ioam_export_vat_plugin_register (vam)))
50     return err;
51
52   return 0;
53 }
54 uword unformat_ip46_address (unformat_input_t * input, va_list * args)
55 {
56   ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
57   ip46_type_t type = va_arg (*args, ip46_type_t);
58   if ((type != IP46_TYPE_IP6) &&
59       unformat(input, "%U", unformat_ip4_address, &ip46->ip4)) {
60     ip46_address_mask_ip4(ip46);
61     return 1;
62   } else if ((type != IP46_TYPE_IP4) &&
63       unformat(input, "%U", unformat_ip6_address, &ip46->ip6)) {
64     return 1;
65   }
66   return 0;
67 }