dhcp: Move to plugin
[vpp.git] / src / plugins / dhcp / dhcp6_pd_client_cp_api.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 <vnet/vnet.h>
17 #include <vlibmemory/api.h>
18
19 #include <dhcp/dhcp6_pd_client_dp.h>
20
21 /* define message IDs */
22 #include <vnet/format_fns.h>
23 #include <dhcp/dhcp6_pd_client_cp.api_enum.h>
24 #include <dhcp/dhcp6_pd_client_cp.api_types.h>
25
26 /**
27  * Base message ID fot the plugin
28  */
29 static u32 dhcp_base_msg_id;
30 #define REPLY_MSG_ID_BASE dhcp_base_msg_id
31
32 #include <vlibapi/api_helper_macros.h>
33
34 static void
35   vl_api_dhcp6_pd_client_enable_disable_t_handler
36   (vl_api_dhcp6_pd_client_enable_disable_t * mp)
37 {
38   vl_api_dhcp6_pd_client_enable_disable_reply_t *rmp;
39   u32 sw_if_index;
40   int rv = 0;
41
42   VALIDATE_SW_IF_INDEX (mp);
43
44   sw_if_index = ntohl (mp->sw_if_index);
45
46   rv = dhcp6_pd_client_enable_disable (sw_if_index,
47                                        mp->prefix_group, mp->enable);
48
49   BAD_SW_IF_INDEX_LABEL;
50
51   REPLY_MACRO (VL_API_DHCP6_PD_CLIENT_ENABLE_DISABLE_REPLY);
52 }
53
54 static void
55   vl_api_ip6_add_del_address_using_prefix_t_handler
56   (vl_api_ip6_add_del_address_using_prefix_t * mp)
57 {
58   vl_api_ip6_add_del_address_using_prefix_reply_t *rmp;
59   u32 sw_if_index;
60   ip6_address_t address;
61   u8 prefix_length;
62   int rv = 0;
63
64   VALIDATE_SW_IF_INDEX (mp);
65
66   sw_if_index = ntohl (mp->sw_if_index);
67
68   memcpy (address.as_u8, mp->address, 16);
69   prefix_length = mp->prefix_length;
70
71   rv = dhcp6_cp_ip6_address_add_del (sw_if_index, mp->prefix_group, address,
72                                      prefix_length, mp->is_add);
73
74   BAD_SW_IF_INDEX_LABEL;
75
76   REPLY_MACRO (VL_API_IP6_ADD_DEL_ADDRESS_USING_PREFIX_REPLY);
77 }
78
79 #define vl_msg_name_crc_list
80 #include <dhcp/dhcp6_pd_client_cp.api.c>
81 #undef vl_msg_name_crc_list
82
83 static clib_error_t *
84 dhcp_pd_client_cp_api_init (vlib_main_t * vm)
85 {
86   /*
87    * Set up the (msg_name, crc, message-id) table
88    */
89   dhcp_base_msg_id = setup_message_id_table ();
90
91   return 0;
92 }
93
94 VLIB_INIT_FUNCTION (dhcp_pd_client_cp_api_init);
95
96 /*
97  * fd.io coding-style-patch-verification: ON
98  *
99  * Local Variables:
100  * eval: (c-set-style "gnu")
101  * End:
102  */