c29a2a123757862866f91d778eb5fb0c89ca7659
[vpp.git] / src / plugins / map / map_api.c
1 /*
2  *------------------------------------------------------------------
3  * map_api.c - vnet map api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19
20 #include <vnet/ip/ip_types_api.h>
21 #include <map/map.h>
22 #include <map/map.api_enum.h>
23 #include <map/map.api_types.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/reass/ip4_sv_reass.h>
26 #include <vnet/ip/reass/ip6_sv_reass.h>
27 #include <vnet/fib/fib_table.h>
28 #include <vlibmemory/api.h>
29
30 #define REPLY_MSG_ID_BASE mm->msg_id_base
31 #include <vlibapi/api_helper_macros.h>
32
33 static void
34 vl_api_map_add_domain_t_handler (vl_api_map_add_domain_t * mp)
35 {
36   map_main_t *mm = &map_main;
37   vl_api_map_add_domain_reply_t *rmp;
38   int rv = 0;
39   u32 index;
40   u8 flags = 0;
41
42   u8 *tag = format (0, "%s", mp->tag);
43   rv =
44     map_create_domain ((ip4_address_t *) & mp->ip4_prefix.address,
45                        mp->ip4_prefix.len,
46                        (ip6_address_t *) & mp->ip6_prefix.address,
47                        mp->ip6_prefix.len,
48                        (ip6_address_t *) & mp->ip6_src.address,
49                        mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset,
50                        mp->psid_length, &index, ntohs (mp->mtu), flags, tag);
51   vec_free (tag);
52   /* *INDENT-OFF* */
53   REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
54   ({
55     rmp->index = ntohl(index);
56   }));
57   /* *INDENT-ON* */
58 }
59
60 static void
61 vl_api_map_del_domain_t_handler (vl_api_map_del_domain_t * mp)
62 {
63   map_main_t *mm = &map_main;
64   vl_api_map_del_domain_reply_t *rmp;
65   int rv = 0;
66
67   rv = map_delete_domain (ntohl (mp->index));
68
69   REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
70 }
71
72 static void
73 vl_api_map_add_del_rule_t_handler (vl_api_map_add_del_rule_t * mp)
74 {
75   map_main_t *mm = &map_main;
76   vl_api_map_del_domain_reply_t *rmp;
77   int rv = 0;
78
79   rv =
80     map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
81                       (ip6_address_t *) & mp->ip6_dst, mp->is_add);
82
83   REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
84 }
85
86 static void
87 vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp)
88 {
89   vl_api_map_domain_details_t *rmp;
90   map_main_t *mm = &map_main;
91   map_domain_t *d;
92   map_domain_extra_t *de;
93   vl_api_registration_t *reg;
94   u32 map_domain_index;
95
96   if (pool_elts (mm->domains) == 0)
97     return;
98
99   reg = vl_api_client_index_to_registration (mp->client_index);
100   if (!reg)
101     return;
102
103   /* *INDENT-OFF* */
104   pool_foreach(d, mm->domains,
105   ({
106     map_domain_index = d - mm->domains;
107     de = vec_elt_at_index(mm->domain_extras, map_domain_index);
108     int tag_len = clib_min(ARRAY_LEN(rmp->tag), vec_len(de->tag) + 1);
109
110     /* Make sure every field is initiated (or don't skip the clib_memset()) */
111     rmp = vl_msg_api_alloc (sizeof (*rmp) + tag_len);
112
113     rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
114     rmp->context = mp->context;
115     rmp->domain_index = htonl(map_domain_index);
116     clib_memcpy(&rmp->ip6_prefix.address, &d->ip6_prefix, sizeof(rmp->ip6_prefix.address));
117     clib_memcpy(&rmp->ip4_prefix.address, &d->ip4_prefix, sizeof(rmp->ip4_prefix.address));
118     clib_memcpy(&rmp->ip6_src.address, &d->ip6_src, sizeof(rmp->ip6_src.address));
119     rmp->ip6_prefix.len = d->ip6_prefix_len;
120     rmp->ip4_prefix.len = d->ip4_prefix_len;
121     rmp->ip6_src.len = d->ip6_src_len;
122     rmp->ea_bits_len = d->ea_bits_len;
123     rmp->psid_offset = d->psid_offset;
124     rmp->psid_length = d->psid_length;
125     rmp->flags = d->flags;
126     rmp->mtu = htons(d->mtu);
127     memcpy(rmp->tag, de->tag, tag_len-1);
128     rmp->tag[tag_len-1] = '\0';
129
130     vl_api_send_msg (reg, (u8 *) rmp);
131   }));
132   /* *INDENT-ON* */
133 }
134
135 static void
136 vl_api_map_rule_dump_t_handler (vl_api_map_rule_dump_t * mp)
137 {
138   vl_api_registration_t *reg;
139   u16 i;
140   ip6_address_t dst;
141   vl_api_map_rule_details_t *rmp;
142   map_main_t *mm = &map_main;
143   u32 domain_index = ntohl (mp->domain_index);
144   map_domain_t *d;
145
146   if (pool_elts (mm->domains) == 0)
147     return;
148
149   d = pool_elt_at_index (mm->domains, domain_index);
150   if (!d || !d->rules)
151     {
152       return;
153     }
154
155   reg = vl_api_client_index_to_registration (mp->client_index);
156   if (!reg)
157     return;
158
159   for (i = 0; i < (0x1 << d->psid_length); i++)
160     {
161       dst = d->rules[i];
162       if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
163         {
164           continue;
165         }
166       rmp = vl_msg_api_alloc (sizeof (*rmp));
167       clib_memset (rmp, 0, sizeof (*rmp));
168       rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->msg_id_base);
169       rmp->psid = htons (i);
170       clib_memcpy (&rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
171       rmp->context = mp->context;
172       vl_api_send_msg (reg, (u8 *) rmp);
173     }
174 }
175
176 static void
177 vl_api_map_summary_stats_t_handler (vl_api_map_summary_stats_t * mp)
178 {
179   vl_api_map_summary_stats_reply_t *rmp;
180   vlib_combined_counter_main_t *cm;
181   vlib_counter_t v;
182   int i, which;
183   u64 total_pkts[VLIB_N_RX_TX];
184   u64 total_bytes[VLIB_N_RX_TX];
185   map_main_t *mm = &map_main;
186   vl_api_registration_t *reg;
187
188   reg = vl_api_client_index_to_registration (mp->client_index);
189   if (!reg)
190     return;
191
192   rmp = vl_msg_api_alloc (sizeof (*rmp));
193   rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->msg_id_base);
194   rmp->context = mp->context;
195   rmp->retval = 0;
196
197   if (pool_elts (mm->domains) == 0)
198     {
199       rmp->retval = -1;
200       goto out;
201     }
202
203   clib_memset (total_pkts, 0, sizeof (total_pkts));
204   clib_memset (total_bytes, 0, sizeof (total_bytes));
205
206   map_domain_counter_lock (mm);
207   vec_foreach (cm, mm->domain_counters)
208   {
209     which = cm - mm->domain_counters;
210
211     for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
212       {
213         vlib_get_combined_counter (cm, i, &v);
214         total_pkts[which] += v.packets;
215         total_bytes[which] += v.bytes;
216       }
217   }
218
219   map_domain_counter_unlock (mm);
220
221   /* Note: in network byte order! */
222   rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] =
223     clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
224   rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] =
225     clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
226   rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] =
227     clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
228   rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] =
229     clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
230   rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
231   rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
232   rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] =
233     clib_host_to_net_u64 (map_error_counter_get
234                           (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
235   rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] =
236     clib_host_to_net_u64 (map_error_counter_get
237                           (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
238
239 out:
240   vl_api_send_msg (reg, (u8 *) rmp);
241 }
242
243
244 int
245 map_param_set_fragmentation (bool inner, bool ignore_df)
246 {
247   map_main_t *mm = &map_main;
248
249   mm->frag_inner = ! !inner;
250   mm->frag_ignore_df = ! !ignore_df;
251
252   return 0;
253 }
254
255 static void
256   vl_api_map_param_set_fragmentation_t_handler
257   (vl_api_map_param_set_fragmentation_t * mp)
258 {
259   map_main_t *mm = &map_main;
260   vl_api_map_param_set_fragmentation_reply_t *rmp;
261   int rv = 0;
262
263   rv = map_param_set_fragmentation (mp->inner, mp->ignore_df);
264
265   REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
266 }
267
268
269 int
270 map_param_set_icmp (ip4_address_t * icmp_src_address)
271 {
272   map_main_t *mm = &map_main;
273
274   if (icmp_src_address == 0)
275     return -1;
276
277   mm->icmp4_src_address = *icmp_src_address;
278
279   return 0;
280 }
281
282
283 static void
284 vl_api_map_param_set_icmp_t_handler (vl_api_map_param_set_icmp_t * mp)
285 {
286   map_main_t *mm = &map_main;
287   vl_api_map_param_set_icmp_reply_t *rmp;
288   int rv;
289
290   rv = map_param_set_icmp ((ip4_address_t *) & mp->ip4_err_relay_src);
291
292   REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP_REPLY);
293 }
294
295
296 int
297 map_param_set_icmp6 (u8 enable_unreachable)
298 {
299   map_main_t *mm = &map_main;
300
301   mm->icmp6_enabled = ! !enable_unreachable;
302
303   return 0;
304 }
305
306 static void
307 vl_api_map_param_set_icmp6_t_handler (vl_api_map_param_set_icmp6_t * mp)
308 {
309   map_main_t *mm = &map_main;
310   vl_api_map_param_set_icmp6_reply_t *rmp;
311   int rv;
312
313   rv = map_param_set_icmp6 (mp->enable_unreachable);
314
315   REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP6_REPLY);
316 }
317
318
319 static void
320   vl_api_map_param_add_del_pre_resolve_t_handler
321   (vl_api_map_param_add_del_pre_resolve_t * mp)
322 {
323   map_main_t *mm = &map_main;
324   vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
325   int rv = 0;
326
327   map_pre_resolve ((ip4_address_t *) & mp->ip4_nh_address,
328                    (ip6_address_t *) & mp->ip6_nh_address, !mp->is_add);
329
330   REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
331 }
332
333
334 int
335 map_param_set_reassembly (bool is_ipv6,
336                           u16 lifetime_ms,
337                           u16 pool_size,
338                           u32 buffers,
339                           f64 ht_ratio, u32 * reass, u32 * packets)
340 {
341   u32 ps_reass = 0, ps_packets = 0;
342   u32 ht_reass = 0, ht_packets = 0;
343
344   if (is_ipv6)
345     {
346       if (pool_size != (u16) ~ 0)
347         {
348           if (pool_size > MAP_IP6_REASS_CONF_POOL_SIZE_MAX)
349             return MAP_ERR_BAD_POOL_SIZE;
350           if (map_ip6_reass_conf_pool_size
351               (pool_size, &ps_reass, &ps_packets))
352             return MAP_ERR_BAD_POOL_SIZE;
353         }
354
355       if (ht_ratio != (MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1))
356         {
357           if (ht_ratio > MAP_IP6_REASS_CONF_HT_RATIO_MAX)
358             return MAP_ERR_BAD_HT_RATIO;
359           if (map_ip6_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
360             return MAP_ERR_BAD_HT_RATIO;
361         }
362
363       if (lifetime_ms != (u16) ~ 0)
364         {
365           if (lifetime_ms > MAP_IP6_REASS_CONF_LIFETIME_MAX)
366             return MAP_ERR_BAD_LIFETIME;
367           if (map_ip6_reass_conf_lifetime (lifetime_ms))
368             return MAP_ERR_BAD_LIFETIME;
369         }
370
371       if (buffers != ~0)
372         {
373           if (buffers > MAP_IP6_REASS_CONF_BUFFERS_MAX)
374             return MAP_ERR_BAD_BUFFERS;
375           if (map_ip6_reass_conf_buffers (buffers))
376             return MAP_ERR_BAD_BUFFERS;
377         }
378
379       if (map_main.ip6_reass_conf_buffers >
380           map_main.ip6_reass_conf_pool_size *
381           MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY)
382         {
383           return MAP_ERR_BAD_BUFFERS_TOO_LARGE;
384         }
385     }
386   else
387     {
388       if (pool_size != (u16) ~ 0)
389         {
390           if (pool_size > MAP_IP4_REASS_CONF_POOL_SIZE_MAX)
391             return MAP_ERR_BAD_POOL_SIZE;
392           if (map_ip4_reass_conf_pool_size
393               (pool_size, &ps_reass, &ps_packets))
394             return MAP_ERR_BAD_POOL_SIZE;
395         }
396
397       if (ht_ratio != (MAP_IP4_REASS_CONF_HT_RATIO_MAX + 1))
398         {
399           if (ht_ratio > MAP_IP4_REASS_CONF_HT_RATIO_MAX)
400             return MAP_ERR_BAD_HT_RATIO;
401           if (map_ip4_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
402             return MAP_ERR_BAD_HT_RATIO;
403         }
404
405       if (lifetime_ms != (u16) ~ 0)
406         {
407           if (lifetime_ms > MAP_IP4_REASS_CONF_LIFETIME_MAX)
408             return MAP_ERR_BAD_LIFETIME;
409           if (map_ip4_reass_conf_lifetime (lifetime_ms))
410             return MAP_ERR_BAD_LIFETIME;
411         }
412
413       if (buffers != ~0)
414         {
415           if (buffers > MAP_IP4_REASS_CONF_BUFFERS_MAX)
416             return MAP_ERR_BAD_BUFFERS;
417           if (map_ip4_reass_conf_buffers (buffers))
418             return MAP_ERR_BAD_BUFFERS;
419         }
420
421       if (map_main.ip4_reass_conf_buffers >
422           map_main.ip4_reass_conf_pool_size *
423           MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY)
424         {
425           return MAP_ERR_BAD_BUFFERS_TOO_LARGE;
426         }
427     }
428
429   if (reass)
430     *reass = ps_reass + ht_reass;
431
432   if (packets)
433     *packets = ps_packets + ht_packets;
434
435   return 0;
436 }
437
438
439 static void
440   vl_api_map_param_set_reassembly_t_handler
441   (vl_api_map_param_set_reassembly_t * mp)
442 {
443   map_main_t *mm = &map_main;
444   vl_api_map_param_set_reassembly_reply_t *rmp;
445   u32 reass = 0, packets = 0;
446   int rv;
447   f64 ht_ratio;
448
449   ht_ratio = (f64) clib_net_to_host_f64 (mp->ht_ratio);
450   if (ht_ratio == ~0)
451     ht_ratio = MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1;
452
453   rv = map_param_set_reassembly (mp->is_ip6,
454                                  clib_net_to_host_u16 (mp->lifetime_ms),
455                                  clib_net_to_host_u16 (mp->pool_size),
456                                  clib_net_to_host_u32 (mp->buffers),
457                                  ht_ratio, &reass, &packets);
458
459   /*
460    * FIXME: Should the lost reass and packet counts be returned in the API?
461    */
462
463   REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
464 }
465
466
467 int
468 map_param_set_security_check (bool enable, bool fragments)
469 {
470   map_main_t *mm = &map_main;
471
472   mm->sec_check = ! !enable;
473   mm->sec_check_frag = ! !fragments;
474
475   return 0;
476 }
477
478 static void
479   vl_api_map_param_set_security_check_t_handler
480   (vl_api_map_param_set_security_check_t * mp)
481 {
482   map_main_t *mm = &map_main;
483   vl_api_map_param_set_security_check_reply_t *rmp;
484   int rv;
485
486   rv = map_param_set_security_check (mp->enable, mp->fragments);
487
488   REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
489 }
490
491
492 int
493 map_param_set_traffic_class (bool copy, u8 tc)
494 {
495   map_main_t *mm = &map_main;
496
497   mm->tc_copy = ! !copy;
498   mm->tc = tc;
499
500   return 0;
501 }
502
503 static void
504   vl_api_map_param_set_traffic_class_t_handler
505   (vl_api_map_param_set_traffic_class_t * mp)
506 {
507   map_main_t *mm = &map_main;
508   vl_api_map_param_set_traffic_class_reply_t *rmp;
509   int rv;
510
511   rv = map_param_set_traffic_class (mp->copy, mp->tc_class);
512
513   REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
514 }
515
516
517 int
518 map_param_set_tcp (u16 tcp_mss)
519 {
520   map_main_t *mm = &map_main;
521
522   mm->tcp_mss = tcp_mss;
523
524   return 0;
525 }
526
527
528 static void
529 vl_api_map_param_set_tcp_t_handler (vl_api_map_param_set_tcp_t * mp)
530 {
531   map_main_t *mm = &map_main;
532   vl_api_map_param_set_tcp_reply_t *rmp;
533   int rv = 0;
534
535   map_param_set_tcp (ntohs (mp->tcp_mss));
536   REPLY_MACRO (VL_API_MAP_PARAM_SET_TCP_REPLY);
537 }
538
539
540 static void
541 vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp)
542 {
543   map_main_t *mm = &map_main;
544   vl_api_map_param_get_reply_t *rmp;
545   vl_api_registration_t *reg;
546
547   reg = vl_api_client_index_to_registration (mp->client_index);
548   if (!reg)
549     return;
550
551   rmp = vl_msg_api_alloc (sizeof (*rmp));
552   rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->msg_id_base);
553   rmp->context = mp->context;
554   rmp->retval = 0;
555
556   rmp->frag_inner = mm->frag_inner;
557   rmp->frag_ignore_df = mm->frag_ignore_df;
558
559   clib_memcpy (&rmp->icmp_ip4_err_relay_src,
560                &mm->icmp4_src_address, sizeof (rmp->icmp_ip4_err_relay_src));
561
562   rmp->icmp6_enable_unreachable = mm->icmp6_enabled;
563
564   /*
565    * FIXME: How are these addresses re-extracted from the FIB?
566    * Or should a local map_main copy be kept?
567    */
568   clib_memset (&rmp->ip4_nh_address, 0, sizeof (rmp->ip4_nh_address));
569   clib_memset (&rmp->ip6_nh_address, 0, sizeof (rmp->ip6_nh_address));
570
571   rmp->ip4_lifetime_ms =
572     clib_net_to_host_u16 (mm->ip4_reass_conf_lifetime_ms);
573   rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size);
574   rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers);
575   rmp->ip4_ht_ratio = clib_net_to_host_f64 (mm->ip4_reass_conf_ht_ratio);
576
577   rmp->ip6_lifetime_ms =
578     clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms);
579   rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size);
580   rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers);
581   rmp->ip6_ht_ratio = clib_net_to_host_f64 (mm->ip6_reass_conf_ht_ratio);
582
583   rmp->sec_check_enable = mm->sec_check;
584   rmp->sec_check_fragments = mm->sec_check_frag;
585
586   rmp->tc_copy = mm->tc_copy;
587   rmp->tc_class = mm->tc;
588
589   vl_api_send_msg (reg, (u8 *) rmp);
590 }
591
592
593 int
594 map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
595 {
596   map_main_t *mm = &map_main;
597
598   if (pool_is_free_index (mm->vnet_main->interface_main.sw_interfaces,
599                           sw_if_index))
600     return VNET_API_ERROR_INVALID_SW_IF_INDEX;
601
602   is_enable = ! !is_enable;
603
604   if (is_translation)
605     {
606       if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index)
607           == is_enable)
608         return 0;
609     }
610   else
611     {
612       if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index)
613           == is_enable)
614         return 0;
615     }
616
617   if (is_translation == false)
618     {
619       ip4_sv_reass_enable_disable_with_refcnt (sw_if_index, is_enable);
620       vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index,
621                                    is_enable ? 1 : 0, 0, 0);
622       vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index,
623                                    is_enable ? 1 : 0, 0, 0);
624       mm->bm_encap_enabled_by_sw_if =
625         clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index,
626                          is_enable);
627     }
628   else
629     {
630       vnet_feature_enable_disable ("ip4-unicast", "ip4-map-t", sw_if_index,
631                                    is_enable ? 1 : 0, 0, 0);
632       vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index,
633                                    is_enable ? 1 : 0, 0, 0);
634       mm->bm_trans_enabled_by_sw_if =
635         clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index,
636                          is_enable);
637     }
638
639   return 0;
640 }
641
642
643 static void
644 vl_api_map_if_enable_disable_t_handler (vl_api_map_if_enable_disable_t * mp)
645 {
646   map_main_t *mm = &map_main;
647   vl_api_map_if_enable_disable_reply_t *rmp;
648   int rv = 0;
649
650   VALIDATE_SW_IF_INDEX (mp);
651
652   rv =
653     map_if_enable_disable (mp->is_enable, htonl (mp->sw_if_index),
654                            mp->is_translation);
655
656   BAD_SW_IF_INDEX_LABEL;
657   REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY);
658 }
659
660 /* API definitions */
661 #include <vnet/format_fns.h>
662 #include <map/map.api.c>
663
664 /* Set up the API message handling tables */
665 clib_error_t *
666 map_plugin_api_hookup (vlib_main_t * vm)
667 {
668   map_main_t *mm = &map_main;
669
670   mm->msg_id_base = setup_message_id_table ();
671   return 0;
672 }
673
674 /*
675  * fd.io coding-style-patch-verification: ON
676  *
677  * Local Variables:
678  * eval: (c-set-style "gnu")
679  * End:
680  */