diff options
Diffstat (limited to 'hicn-plugin/src/faces/ip/face_ip_cli.c')
-rw-r--r-- | hicn-plugin/src/faces/ip/face_ip_cli.c | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c index ba7765541..58cf8d562 100644 --- a/hicn-plugin/src/faces/ip/face_ip_cli.c +++ b/hicn-plugin/src/faces/ip/face_ip_cli.c @@ -92,57 +92,6 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm, } } - if (ip46_address_is_zero (&local_addr)) - { - if (!vnet_sw_interface_is_valid (vnm, sw_if)) - return clib_error_return (0, "interface not valid"); - - if (ip46_address_is_ip4 (&remote_addr)) - { - ip_interface_address_t *interface_address; - ip4_address_t *addr = - ip4_interface_address_matching_destination (&ip4_main, - &remote_addr.ip4, - sw_if, - &interface_address); - - if (addr == NULL) - addr = ip4_interface_first_address (&ip4_main, - sw_if, &interface_address); - - if (addr == NULL) - return clib_error_return (0, - "no valid ip address on interface %d", - sw_if); - - ip46_address_set_ip4 (&local_addr, addr); - } - else - { - ip_interface_address_t *interface_address; - ip6_interface_address_matching_destination (&ip6_main, - &remote_addr.ip6, sw_if, - &interface_address); - - ip6_address_t *addr = NULL; - if (interface_address != NULL) - addr = - (ip6_address_t *) - ip_interface_address_get_address (&ip6_main.lookup_main, - interface_address); - - if (addr == NULL) - addr = ip6_interface_first_address (&ip6_main, sw_if); - - if (addr == NULL) - return clib_error_return (0, - "no valid ip address on interface %d", - sw_if); - - ip46_address_set_ip6 (&local_addr, addr); - } - } - int rv; switch (face_op) { @@ -155,6 +104,59 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm, return clib_error_return (0, "next hop address not specified"); } + if (ip46_address_is_zero (&local_addr)) + { + if (!vnet_sw_interface_is_valid (vnm, sw_if)) + return clib_error_return (0, "interface not valid"); + + if (ip46_address_is_ip4 (&remote_addr)) + { + ip_interface_address_t *interface_address; + ip4_address_t *addr = + ip4_interface_address_matching_destination (&ip4_main, + &remote_addr.ip4, + sw_if, + &interface_address); + + if (addr == NULL) + addr = ip4_interface_first_address (&ip4_main, + sw_if, + &interface_address); + + if (addr == NULL) + return clib_error_return (0, + "no valid ip address on interface %d", + sw_if); + + ip46_address_set_ip4 (&local_addr, addr); + } + else + { + ip_interface_address_t *interface_address; + ip6_interface_address_matching_destination (&ip6_main, + &remote_addr.ip6, + sw_if, + &interface_address); + + ip6_address_t *addr = NULL; + if (interface_address != NULL) + addr = + (ip6_address_t *) + ip_interface_address_get_address (&ip6_main.lookup_main, + interface_address); + + if (addr == NULL) + addr = ip6_interface_first_address (&ip6_main, sw_if); + + if (addr == NULL) + return clib_error_return (0, + "no valid ip address on interface %d", + sw_if); + + ip46_address_set_ip6 (&local_addr, addr); + } + } + rv = hicn_face_ip_add (&local_addr, &remote_addr, sw_if, &face_id); if (rv == HICN_ERROR_NONE) |