X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp_api.c;h=8b169f8f1e3fcbc74885d5cd406c930875c6d946;hb=1334761e1e558b2107e62ffe60ce81bd2ce5780c;hp=4c3e49ee4fbf2a4e893a59941f82ba092f2d4f7c;hpb=3bbcfab119483ef07543242df2c4bb9b4c82b9ac;p=vpp.git diff --git a/src/vnet/tcp/tcp_api.c b/src/vnet/tcp/tcp_api.c index 4c3e49ee4fb..8b169f8f1e3 100644 --- a/src/vnet/tcp/tcp_api.c +++ b/src/vnet/tcp/tcp_api.c @@ -2,7 +2,7 @@ *------------------------------------------------------------------ * tcp_api.c - vnet tcp-layer apis * - * Copyright (c) 2017 Cisco and/or its affiliates. + * Copyright (c) 2017-2019 Cisco 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: @@ -22,6 +22,8 @@ #include +#include + #include #define vl_typedefs /* define message structures */ @@ -51,20 +53,28 @@ static void vl_api_tcp_configure_src_addresses_reply_t *rmp; u32 vrf_id; int rv; + ip46_address_t first_address, last_address; + ip46_type_t fa_af, la_af; vrf_id = clib_net_to_host_u32 (mp->vrf_id); - if (mp->is_ipv6) + fa_af = ip_address_decode (&mp->first_address, &first_address); + la_af = ip_address_decode (&mp->last_address, &last_address); + + if (fa_af != la_af) + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto error; + } + + if (fa_af == IP46_TYPE_IP6) rv = tcp_configure_v6_source_address_range - (vm, - (ip6_address_t *) mp->first_address, - (ip6_address_t *) mp->last_address, vrf_id); + (vm, &first_address.ip6, &last_address.ip6, vrf_id); else rv = tcp_configure_v4_source_address_range - (vm, - (ip4_address_t *) mp->first_address, - (ip4_address_t *) mp->last_address, vrf_id); + (vm, &first_address.ip4, &last_address.ip4, vrf_id); +error: REPLY_MACRO (VL_API_TCP_CONFIGURE_SRC_ADDRESSES_REPLY); } @@ -83,7 +93,7 @@ setup_message_id_table (api_main_t * am) static clib_error_t * tcp_api_hookup (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N, #n, \ @@ -105,11 +115,6 @@ tcp_api_hookup (vlib_main_t * vm) VLIB_API_INIT_FUNCTION (tcp_api_hookup); -void -tcp_api_reference (void) -{ -} - /* * fd.io coding-style-patch-verification: ON *