MAP: Add API support for setting parameters.
[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 <map/map.h>
21 #include <map/map_msg_enum.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/fib/fib_table.h>
24 #include <vlibmemory/api.h>
25
26 #define vl_typedefs             /* define message structures */
27 #include <map/map_all_api_h.h>
28 #undef vl_typedefs
29
30 #define vl_endianfun            /* define message structures */
31 #include <map/map_all_api_h.h>
32 #undef vl_endianfun
33
34 /* instantiate all the print functions we know about */
35 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
36 #define vl_printfun
37 #include <map/map_all_api_h.h>
38 #undef vl_printfun
39
40 /* Get the API version number */
41 #define vl_api_version(n,v) static u32 api_version=(v);
42 #include <map/map_all_api_h.h>
43 #undef vl_api_version
44
45 #define REPLY_MSG_ID_BASE mm->msg_id_base
46 #include <vlibapi/api_helper_macros.h>
47
48 static void
49 vl_api_map_add_domain_t_handler (vl_api_map_add_domain_t * mp)
50 {
51   map_main_t *mm = &map_main;
52   vl_api_map_add_domain_reply_t *rmp;
53   int rv = 0;
54   u32 index;
55   u8 flags = 0;
56
57   if (mp->is_translation)
58     flags |= MAP_DOMAIN_TRANSLATION;
59
60   if (mp->is_rfc6052)
61     flags |= MAP_DOMAIN_RFC6052;
62
63   rv =
64     map_create_domain ((ip4_address_t *) & mp->ip4_prefix.prefix,
65                        mp->ip4_prefix.len,
66                        (ip6_address_t *) & mp->ip6_prefix.prefix,
67                        mp->ip6_prefix.len,
68                        (ip6_address_t *) & mp->ip6_src.prefix,
69                        mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset,
70                        mp->psid_length, &index, ntohs (mp->mtu), flags);
71
72   /* *INDENT-OFF* */
73   REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
74   ({
75     rmp->index = ntohl(index);
76   }));
77   /* *INDENT-ON* */
78 }
79
80 static void
81 vl_api_map_del_domain_t_handler (vl_api_map_del_domain_t * mp)
82 {
83   map_main_t *mm = &map_main;
84   vl_api_map_del_domain_reply_t *rmp;
85   int rv = 0;
86
87   rv = map_delete_domain (ntohl (mp->index));
88
89   REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
90 }
91
92 static void
93 vl_api_map_add_del_rule_t_handler (vl_api_map_add_del_rule_t * mp)
94 {
95   map_main_t *mm = &map_main;
96   vl_api_map_del_domain_reply_t *rmp;
97   int rv = 0;
98
99   rv =
100     map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
101                       (ip6_address_t *) & mp->ip6_dst, mp->is_add);
102
103   REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
104 }
105
106 static void
107 vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp)
108 {
109   vl_api_map_domain_details_t *rmp;
110   map_main_t *mm = &map_main;
111   map_domain_t *d;
112   vl_api_registration_t *reg;
113
114   if (pool_elts (mm->domains) == 0)
115     return;
116
117   reg = vl_api_client_index_to_registration (mp->client_index);
118   if (!reg)
119     return;
120
121   /* *INDENT-OFF* */
122   pool_foreach(d, mm->domains,
123   ({
124     /* Make sure every field is initiated (or don't skip the clib_memset()) */
125     rmp = vl_msg_api_alloc (sizeof (*rmp));
126     rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
127     rmp->context = mp->context;
128     rmp->domain_index = htonl(d - mm->domains);
129     clib_memcpy(&rmp->ip6_prefix.prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix.prefix));
130     clib_memcpy(&rmp->ip4_prefix.prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix.prefix));
131     clib_memcpy(&rmp->ip6_src.prefix, &d->ip6_src, sizeof(rmp->ip6_src.prefix));
132     rmp->ip6_prefix.len = d->ip6_prefix_len;
133     rmp->ip4_prefix.len = d->ip4_prefix_len;
134     rmp->ip6_src.len = d->ip6_src_len;
135     rmp->ea_bits_len = d->ea_bits_len;
136     rmp->psid_offset = d->psid_offset;
137     rmp->psid_length = d->psid_length;
138     rmp->flags = d->flags;
139     rmp->mtu = htons(d->mtu);
140     rmp->is_translation = (d->flags & MAP_DOMAIN_TRANSLATION); // Redundant
141
142     vl_api_send_msg (reg, (u8 *) rmp);
143   }));
144   /* *INDENT-ON* */
145 }
146
147 static void
148 vl_api_map_rule_dump_t_handler (vl_api_map_rule_dump_t * mp)
149 {
150   vl_api_registration_t *reg;
151   u16 i;
152   ip6_address_t dst;
153   vl_api_map_rule_details_t *rmp;
154   map_main_t *mm = &map_main;
155   u32 domain_index = ntohl (mp->domain_index);
156   map_domain_t *d;
157
158   if (pool_elts (mm->domains) == 0)
159     return;
160
161   d = pool_elt_at_index (mm->domains, domain_index);
162   if (!d || !d->rules)
163     {
164       return;
165     }
166
167   reg = vl_api_client_index_to_registration (mp->client_index);
168   if (!reg)
169     return;
170
171   for (i = 0; i < (0x1 << d->psid_length); i++)
172     {
173       dst = d->rules[i];
174       if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
175         {
176           continue;
177         }
178       rmp = vl_msg_api_alloc (sizeof (*rmp));
179       clib_memset (rmp, 0, sizeof (*rmp));
180       rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->msg_id_base);
181       rmp->psid = htons (i);
182       clib_memcpy (rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
183       rmp->context = mp->context;
184       vl_api_send_msg (reg, (u8 *) rmp);
185     }
186 }
187
188 static void
189 vl_api_map_summary_stats_t_handler (vl_api_map_summary_stats_t * mp)
190 {
191   vl_api_map_summary_stats_reply_t *rmp;
192   vlib_combined_counter_main_t *cm;
193   vlib_counter_t v;
194   int i, which;
195   u64 total_pkts[VLIB_N_RX_TX];
196   u64 total_bytes[VLIB_N_RX_TX];
197   map_main_t *mm = &map_main;
198   vl_api_registration_t *reg;
199
200   reg = vl_api_client_index_to_registration (mp->client_index);
201   if (!reg)
202     return;
203
204   rmp = vl_msg_api_alloc (sizeof (*rmp));
205   rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->msg_id_base);
206   rmp->context = mp->context;
207   rmp->retval = 0;
208
209   if (pool_elts (mm->domains) == 0)
210     {
211       rmp->retval = -1;
212       goto out;
213     }
214
215   clib_memset (total_pkts, 0, sizeof (total_pkts));
216   clib_memset (total_bytes, 0, sizeof (total_bytes));
217
218   map_domain_counter_lock (mm);
219   vec_foreach (cm, mm->domain_counters)
220   {
221     which = cm - mm->domain_counters;
222
223     for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
224       {
225         vlib_get_combined_counter (cm, i, &v);
226         total_pkts[which] += v.packets;
227         total_bytes[which] += v.bytes;
228       }
229   }
230
231   map_domain_counter_unlock (mm);
232
233   /* Note: in network byte order! */
234   rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] =
235     clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
236   rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] =
237     clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
238   rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] =
239     clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
240   rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] =
241     clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
242   rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
243   rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
244   rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] =
245     clib_host_to_net_u64 (map_error_counter_get
246                           (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
247   rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] =
248     clib_host_to_net_u64 (map_error_counter_get
249                           (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
250
251 out:
252   vl_api_send_msg (reg, (u8 *) rmp);
253 }
254
255
256 int
257 map_param_set_fragmentation (bool inner, bool ignore_df)
258 {
259   map_main_t *mm = &map_main;
260
261   mm->frag_inner = ! !inner;
262   mm->frag_ignore_df = ! !ignore_df;
263
264   return 0;
265 }
266
267 static void
268   vl_api_map_param_set_fragmentation_t_handler
269   (vl_api_map_param_set_fragmentation_t * mp)
270 {
271   map_main_t *mm = &map_main;
272   vl_api_map_param_set_fragmentation_reply_t *rmp;
273   int rv = 0;
274
275   rv = map_param_set_fragmentation (mp->inner, mp->ignore_df);
276
277   REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
278 }
279
280
281 int
282 map_param_set_icmp (ip4_address_t * icmp_src_address)
283 {
284   map_main_t *mm = &map_main;
285
286   if (icmp_src_address == 0)
287     return -1;
288
289   mm->icmp4_src_address = *icmp_src_address;
290
291   return 0;
292 }
293
294
295 static void
296 vl_api_map_param_set_icmp_t_handler (vl_api_map_param_set_icmp_t * mp)
297 {
298   map_main_t *mm = &map_main;
299   vl_api_map_param_set_icmp_reply_t *rmp;
300   int rv;
301
302   rv = map_param_set_icmp ((ip4_address_t *) & mp->ip4_err_relay_src);
303
304   REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP_REPLY);
305 }
306
307
308 int
309 map_param_set_icmp6 (u8 enable_unreachable)
310 {
311   map_main_t *mm = &map_main;
312
313   mm->icmp6_enabled = ! !enable_unreachable;
314
315   return 0;
316 }
317
318 static void
319 vl_api_map_param_set_icmp6_t_handler (vl_api_map_param_set_icmp6_t * mp)
320 {
321   map_main_t *mm = &map_main;
322   vl_api_map_param_set_icmp6_reply_t *rmp;
323   int rv;
324
325   rv = map_param_set_icmp6 (mp->enable_unreachable);
326
327   REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP6_REPLY);
328 }
329
330
331 static void
332   vl_api_map_param_add_del_pre_resolve_t_handler
333   (vl_api_map_param_add_del_pre_resolve_t * mp)
334 {
335   map_main_t *mm = &map_main;
336   vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
337   int rv = 0;
338
339   map_pre_resolve ((ip4_address_t *) & mp->ip4_nh_address,
340                    (ip6_address_t *) & mp->ip6_nh_address, mp->is_add);
341
342   REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
343 }
344
345
346 int
347 map_param_set_reassembly (bool is_ipv6,
348                           u16 lifetime_ms,
349                           u16 pool_size,
350                           u32 buffers,
351                           f64 ht_ratio, u32 * reass, u32 * packets)
352 {
353   u32 ps_reass = 0, ps_packets = 0;
354   u32 ht_reass = 0, ht_packets = 0;
355
356   if (is_ipv6)
357     {
358       if (pool_size != (u16) ~ 0)
359         {
360           if (pool_size > MAP_IP6_REASS_CONF_POOL_SIZE_MAX)
361             return MAP_ERR_BAD_POOL_SIZE;
362           if (map_ip6_reass_conf_pool_size
363               (pool_size, &ps_reass, &ps_packets))
364             return MAP_ERR_BAD_POOL_SIZE;
365         }
366
367       if (ht_ratio != (MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1))
368         {
369           if (ht_ratio > MAP_IP6_REASS_CONF_HT_RATIO_MAX)
370             return MAP_ERR_BAD_HT_RATIO;
371           if (map_ip6_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
372             return MAP_ERR_BAD_HT_RATIO;
373         }
374
375       if (lifetime_ms != (u16) ~ 0)
376         {
377           if (lifetime_ms > MAP_IP6_REASS_CONF_LIFETIME_MAX)
378             return MAP_ERR_BAD_LIFETIME;
379           if (map_ip6_reass_conf_lifetime (lifetime_ms))
380             return MAP_ERR_BAD_LIFETIME;
381         }
382
383       if (buffers != ~0)
384         {
385           if (buffers > MAP_IP6_REASS_CONF_BUFFERS_MAX)
386             return MAP_ERR_BAD_BUFFERS;
387           if (map_ip6_reass_conf_buffers (buffers))
388             return MAP_ERR_BAD_BUFFERS;
389         }
390
391       if (map_main.ip6_reass_conf_buffers >
392           map_main.ip6_reass_conf_pool_size *
393           MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY)
394         {
395           return MAP_ERR_BAD_BUFFERS_TOO_LARGE;
396         }
397     }
398   else
399     {
400       if (pool_size != (u16) ~ 0)
401         {
402           if (pool_size > MAP_IP4_REASS_CONF_POOL_SIZE_MAX)
403             return MAP_ERR_BAD_POOL_SIZE;
404           if (map_ip4_reass_conf_pool_size
405               (pool_size, &ps_reass, &ps_packets))
406             return MAP_ERR_BAD_POOL_SIZE;
407         }
408
409       if (ht_ratio != (MAP_IP4_REASS_CONF_HT_RATIO_MAX + 1))
410         {
411           if (ht_ratio > MAP_IP4_REASS_CONF_HT_RATIO_MAX)
412             return MAP_ERR_BAD_HT_RATIO;
413           if (map_ip4_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
414             return MAP_ERR_BAD_HT_RATIO;
415         }
416
417       if (lifetime_ms != (u16) ~ 0)
418         {
419           if (lifetime_ms > MAP_IP4_REASS_CONF_LIFETIME_MAX)
420             return MAP_ERR_BAD_LIFETIME;
421           if (map_ip4_reass_conf_lifetime (lifetime_ms))
422             return MAP_ERR_BAD_LIFETIME;
423         }
424
425       if (buffers != ~0)
426         {
427           if (buffers > MAP_IP4_REASS_CONF_BUFFERS_MAX)
428             return MAP_ERR_BAD_BUFFERS;
429           if (map_ip4_reass_conf_buffers (buffers))
430             return MAP_ERR_BAD_BUFFERS;
431         }
432
433       if (map_main.ip4_reass_conf_buffers >
434           map_main.ip4_reass_conf_pool_size *
435           MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY)
436         {
437           return MAP_ERR_BAD_BUFFERS_TOO_LARGE;
438         }
439     }
440
441   if (reass)
442     *reass = ps_reass + ht_reass;
443
444   if (packets)
445     *packets = ps_packets + ht_packets;
446
447   return 0;
448 }
449
450
451 static void
452   vl_api_map_param_set_reassembly_t_handler
453   (vl_api_map_param_set_reassembly_t * mp)
454 {
455   map_main_t *mm = &map_main;
456   vl_api_map_param_set_reassembly_reply_t *rmp;
457   u32 reass = 0, packets = 0;
458   int rv;
459   f64 ht_ratio;
460
461   ht_ratio = (f64) clib_net_to_host_u64 (mp->ht_ratio);
462   if (ht_ratio == ~0)
463     ht_ratio = MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1;
464
465   rv = map_param_set_reassembly (mp->is_ip6,
466                                  clib_net_to_host_u16 (mp->lifetime_ms),
467                                  clib_net_to_host_u16 (mp->pool_size),
468                                  clib_net_to_host_u32 (mp->buffers),
469                                  ht_ratio, &reass, &packets);
470
471   /*
472    * FIXME: Should the lost reass and packet counts be returned in the API?
473    */
474
475   REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
476 }
477
478
479 int
480 map_param_set_security_check (bool enable, bool fragments)
481 {
482   map_main_t *mm = &map_main;
483
484   mm->sec_check = ! !enable;
485   mm->sec_check_frag = ! !fragments;
486
487   return 0;
488 }
489
490 static void
491   vl_api_map_param_set_security_check_t_handler
492   (vl_api_map_param_set_security_check_t * mp)
493 {
494   map_main_t *mm = &map_main;
495   vl_api_map_param_set_security_check_reply_t *rmp;
496   int rv;
497
498   rv = map_param_set_security_check (mp->enable, mp->fragments);
499
500   REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
501 }
502
503
504 int
505 map_param_set_traffic_class (bool copy, u8 tc)
506 {
507   map_main_t *mm = &map_main;
508
509   mm->tc_copy = ! !copy;
510   mm->tc = tc;
511
512   return 0;
513 }
514
515 static void
516   vl_api_map_param_set_traffic_class_t_handler
517   (vl_api_map_param_set_traffic_class_t * mp)
518 {
519   map_main_t *mm = &map_main;
520   vl_api_map_param_set_traffic_class_reply_t *rmp;
521   int rv;
522
523   rv = map_param_set_traffic_class (mp->copy, mp->class);
524
525   REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
526 }
527
528
529 static void
530 vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp)
531 {
532   map_main_t *mm = &map_main;
533   vl_api_map_param_get_reply_t *rmp;
534   vl_api_registration_t *reg;
535
536   reg = vl_api_client_index_to_registration (mp->client_index);
537   if (!reg)
538     return;
539
540   rmp = vl_msg_api_alloc (sizeof (*rmp));
541   rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->msg_id_base);
542   rmp->context = mp->context;
543   rmp->retval = 0;
544
545   rmp->frag_inner = mm->frag_inner;
546   rmp->frag_ignore_df = mm->frag_ignore_df;
547
548   clib_memcpy (&rmp->icmp_ip4_err_relay_src,
549                &mm->icmp4_src_address, sizeof (rmp->icmp_ip4_err_relay_src));
550
551   rmp->icmp6_enable_unreachable = mm->icmp6_enabled;
552
553   /*
554    * FIXME: How are these addresses re-extracted from the FIB?
555    * Or should a local map_main copy be kept?
556    */
557   clib_memset (&rmp->ip4_nh_address, 0, sizeof (rmp->ip4_nh_address));
558   clib_memset (&rmp->ip6_nh_address, 0, sizeof (rmp->ip6_nh_address));
559
560   rmp->ip4_lifetime_ms =
561     clib_net_to_host_u16 (mm->ip4_reass_conf_lifetime_ms);
562   rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size);
563   rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers);
564   rmp->ip4_ht_ratio =
565     clib_net_to_host_u32 ((u32) mm->ip4_reass_conf_ht_ratio);
566
567   rmp->ip6_lifetime_ms =
568     clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms);
569   rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size);
570   rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers);
571   rmp->ip6_ht_ratio =
572     clib_net_to_host_u32 ((u32) mm->ip6_reass_conf_ht_ratio);
573
574   rmp->sec_check_enable = mm->sec_check;
575   rmp->sec_check_fragments = mm->sec_check_frag;
576
577   rmp->tc_copy = mm->tc_copy;
578   rmp->tc_class = mm->tc;
579
580   vl_api_send_msg (reg, (u8 *) rmp);
581 }
582
583
584 #define foreach_map_plugin_api_msg              \
585 _(MAP_ADD_DOMAIN, map_add_domain)               \
586 _(MAP_DEL_DOMAIN, map_del_domain)               \
587 _(MAP_ADD_DEL_RULE, map_add_del_rule)           \
588 _(MAP_DOMAIN_DUMP, map_domain_dump)             \
589 _(MAP_RULE_DUMP, map_rule_dump)                 \
590 _(MAP_SUMMARY_STATS, map_summary_stats)         \
591 _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation)     \
592 _(MAP_PARAM_SET_ICMP, map_param_set_icmp)       \
593 _(MAP_PARAM_SET_ICMP6, map_param_set_icmp6)     \
594 _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \
595 _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly)           \
596 _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check)   \
597 _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class)     \
598 _(MAP_PARAM_GET, map_param_get)
599
600 #define vl_msg_name_crc_list
601 #include <map/map_all_api_h.h>
602 #undef vl_msg_name_crc_list
603
604 static void
605 setup_message_id_table (map_main_t * mm, api_main_t * am)
606 {
607 #define _(id,n,crc)                                                     \
608   vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
609   foreach_vl_msg_name_crc_map;
610 #undef _
611 }
612
613 /* Set up the API message handling tables */
614 clib_error_t *
615 map_plugin_api_hookup (vlib_main_t * vm)
616 {
617   map_main_t *mm = &map_main;
618   u8 *name = format (0, "map_%08x%c", api_version, 0);
619
620   /* Ask for a correctly-sized block of API message decode slots */
621   mm->msg_id_base =
622     vl_msg_api_get_msg_ids ((char *) name, VL_MSG_FIRST_AVAILABLE);
623 #define _(N,n)                                                  \
624     vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base),     \
625                            #n,                                  \
626                            vl_api_##n##_t_handler,              \
627                            vl_noop_handler,                     \
628                            vl_api_##n##_t_endian,               \
629                            vl_api_##n##_t_print,                \
630                            sizeof(vl_api_##n##_t), 1);
631   foreach_map_plugin_api_msg;
632 #undef _
633
634   /*
635    * Set up the (msg_name, crc, message-id) table
636    */
637   setup_message_id_table (mm, &api_main);
638
639   vec_free (name);
640   return 0;
641 }
642
643 /*
644  * fd.io coding-style-patch-verification: ON
645  *
646  * Local Variables:
647  * eval: (c-set-style "gnu")
648  * End:
649  */