aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/cli.c')
-rw-r--r--hicn-plugin/src/cli.c291
1 files changed, 80 insertions, 211 deletions
diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c
index fd1c68169..920d206f8 100644
--- a/hicn-plugin/src/cli.c
+++ b/hicn-plugin/src/cli.c
@@ -53,26 +53,6 @@ typedef enum
} interface_type_t;
/*
- * Supporting function that return if the interface is IP or ethernet
- */
-static interface_type_t
-hicn_cli_is_ip_interface (vlib_main_t * vm,
- vnet_main_t * vnm, u32 sw_if_index)
-{
-
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
-
- vnet_device_class_t *dev_class =
- vnet_get_device_class (vnm, hi->dev_class_index);
- if (!strcmp (dev_class->name, "Loopback"))
- {
- return IP;
- }
- return ETHERNET;
-
-}
-
-/*
* cli handler for 'control start'
*/
static clib_error_t *
@@ -84,7 +64,8 @@ hicn_cli_node_ctl_start_set_command_fn (vlib_main_t * vm,
ret = hicn_infra_plugin_enable_disable (1 /* enable */ ,
node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
+ node_ctl_params.
+ pit_max_lifetime_sec,
node_ctl_params.cs_max_size,
node_ctl_params.cs_reserved_app);
@@ -127,7 +108,8 @@ hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t * vm,
}
ret = hicn_infra_plugin_enable_disable (0 /* !enable */ ,
node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
+ node_ctl_params.
+ pit_max_lifetime_sec,
node_ctl_params.cs_max_size,
node_ctl_params.cs_reserved_app);
@@ -460,11 +442,12 @@ hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
}
}
- fib_prefix_from_ip46_addr(&address, &prefix);
- prefix.fp_len=plen;
+ fib_prefix_from_ip46_addr (&address, &prefix);
+ prefix.fp_len = plen;
/* Check parse */
if (addpfx <= 1
- && ((ip46_address_is_zero (&prefix.fp_addr)) || faceid == HICN_FACE_NULL))
+ && ((ip46_address_is_zero (&prefix.fp_addr))
+ || faceid == HICN_FACE_NULL))
{
cl_err =
clib_error_return (0, "Please specify prefix and a valid faceid...");
@@ -680,19 +663,16 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
unformat_input_t * main_input,
vlib_cli_command_t * cmd)
{
- hicn_main_t *sm = &hicn_main;
hicnpg_main_t *hpgm = &hicnpg_main;
ip46_address_t src_addr;
- fib_prefix_t prefix;
+ fib_prefix_t *prefix = malloc (sizeof (fib_prefix_t));
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ~0;
u16 lifetime = 4000;
int rv = VNET_API_ERROR_UNIMPLEMENTED;
u32 max_seq = ~0;
u32 n_flows = ~0;
- u16 mask = 0;
u32 n_ifaces = 1;
- u32 hicn_underneath = ~0;
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -700,13 +680,6 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "fwd"))
- {
- if (unformat (line_input, "ip"))
- hicn_underneath = 0;
- else if (unformat (line_input, "hicn"))
- hicn_underneath = 1;
- }
if (unformat
(line_input, "intfc %U", unformat_vnet_sw_interface, vnm,
&sw_if_index))
@@ -723,8 +696,8 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
;
}
else if (unformat (line_input, "name %U/%d",
- unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY,
- &prefix.fp_len))
+ unformat_ip46_address, &prefix->fp_addr,
+ IP46_TYPE_ANY, &prefix->fp_len))
{
;
}
@@ -750,72 +723,49 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
}
hpgm->interest_lifetime = lifetime;
- mask = prefix.fp_len;
if (sw_if_index == ~0)
{
return (clib_error_return (0, "Packet generator interface missing"));
}
- if (hicn_underneath == ~0)
- {
- return (clib_error_return
- (0, "Choose the underlying forwarder type ip|hicn"));
- }
- else if (hicn_underneath && !sm->is_enabled)
+
+ //Remove bits that are out of the subnet
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
- return (clib_error_return (0, "hICN not enabled in VPP"));
+ ip4_address_t mask;
+ ip4_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
}
- else if (!hicn_underneath && sm->is_enabled)
+ else
{
- return (clib_error_return (0, "hICN enabled in VPP"));
+ ip6_address_t mask;
+ ip6_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip6.as_u64[0] =
+ prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
+ prefix->fp_addr.ip6.as_u64[1] =
+ prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
}
- int skip = 1;
- int base_offset = ETH_L2;
- u8 use_current_data = HICN_CLASSIFY_NO_CURRENT_DATA_FLAG;
-
- if (hicn_cli_is_ip_interface (vm, vnm, sw_if_index) == IP)
- {
- skip = 0;
- base_offset = NO_L2;
- use_current_data = HICN_CLASSIFY_CURRENT_DATA_FLAG;
- }
/*
- * Register punting on src address generated by pg and data punting
- * on the name
+ * Enable the feature to divert data packet to the hicnpg-data node to count
+ * how many data packets have been received.
+ * Diver all the packets from the packet-generator to the hicn-pg-interest node
+ * to generate valid interests.
*/
- if (ip46_address_is_ip4 (&src_addr) && ip46_address_is_ip4 (&prefix.fp_addr))
+ if (ip46_address_is_ip4 (&src_addr)
+ && ip46_address_is_ip4 (&prefix->fp_addr))
{
- prefix.fp_proto = FIB_PROTOCOL_IP4;
- /* Add data node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.
- hicn_node_info.ip4_inacl_node_index,
- hicn_pg_data_node.index);
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
+
+ vnet_feature_enable_disable ("ip4-unicast", "hicnpg-data",
+ sw_if_index, 1, 0, 0);
/* Add pgen_client node to the vpp graph */
vlib_node_add_next (vm,
pg_input_node.index, hicn_pg_interest_node.index);
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv4, &ipv4_src, mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv4, &ipv4_dst, mask,
- hicn_punt_glb.ip4_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][mask], sw_if_index, base_offset,
- use_current_data);
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv4, &ipv4_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_add_vnetssn (&ipv4, &ipv4_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
pg_node_t *pn;
pn = pg_get_node (hicn_pg_interest_node.index);
@@ -823,39 +773,17 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
else if (!ip46_address_is_ip4 (&src_addr)
- && !ip46_address_is_ip4 (&prefix.fp_addr))
+ && !ip46_address_is_ip4 (&prefix->fp_addr))
{
- prefix.fp_proto = FIB_PROTOCOL_IP6;
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.hicn_node_info.
- ip6_inacl_node_index,
- hicn_pg_data_node.index);
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
+
+ vnet_feature_enable_disable ("ip6-unicast", "hicnpg-data",
+ sw_if_index, 1, 0, 0);
/* Add pgen_client node to the vpp graph */
vlib_node_add_next (vm, pg_input_node.index,
hicn_pg_interest_node.index);
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv6, &ipv6_src, mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv6, &ipv6_dst, mask,
- hicn_punt_glb.ip6_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][mask], sw_if_index, base_offset,
- use_current_data);
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv6, &ipv6_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_add_vnetssn (&ipv6, &ipv6_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
-
pg_node_t *pn;
pn = pg_get_node (hicn_pg_interest_node.index);
pn->unformat_edit = unformat_pg_ip6_header;
@@ -869,11 +797,11 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
hpgm->pgen_clt_src_addr = src_addr;
- hpgm->pgen_clt_hicn_name = prefix.fp_addr;
+ hpgm->pgen_clt_hicn_name = prefix;
hpgm->max_seq_number = max_seq;
hpgm->n_flows = n_flows;
hpgm->n_ifaces = n_ifaces;
- hpgm->hicn_underneath = hicn_underneath;
+ hpgm->sw_if = sw_if_index;
vlib_cli_output (vm, "ifaces %d", hpgm->n_ifaces);
rv = 0;
@@ -904,13 +832,10 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
clib_error_t *cl_err;
int rv = HICN_ERROR_NONE;
hicnpg_server_main_t *pg_main = &hicnpg_server_main;
- hicn_main_t *sm = &hicn_main;
- fib_prefix_t prefix;
- u32 subnet_mask;
- int payload_size = 0;
+ int payload_size = 1440;
u32 sw_if_index = ~0;
vnet_main_t *vnm = vnet_get_main ();
- u32 hicn_underneath = ~0;
+ fib_prefix_t *prefix = calloc (1, sizeof (fib_prefix_t));
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -919,16 +844,9 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
/* Parse the arguments */
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "fwd"))
- {
- if (unformat (line_input, "ip"))
- hicn_underneath = 0;
- else if (unformat (line_input, "hicn"))
- hicn_underneath = 1;
- }
if (unformat (line_input, "name %U/%d",
- unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY,
- &prefix.fp_len))
+ unformat_ip46_address, &prefix->fp_addr,
+ IP46_TYPE_ANY, &prefix->fp_len))
{;
}
else if (unformat (line_input, "size %d", &payload_size))
@@ -955,99 +873,50 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
}
}
}
- prefix.fp_proto = ip46_address_is_ip4(&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
- subnet_mask = prefix.fp_len;
+
/* Attach our packet-gen node for ip4 udp local traffic */
- if (payload_size == 0 || sw_if_index == ~0)
+ if ((prefix->fp_addr.ip6.as_u64[0] == (u64) 0
+ && prefix->fp_addr.ip6.as_u64[1] == 0) || payload_size == 0
+ || sw_if_index == ~0)
{
return clib_error_return (0,
- "Error: must supply local port, payload size and incoming interface");
+ "Error: must supply local port, payload size and incoming hICN prefix");
}
- if (hicn_underneath == ~0)
- {
- return (clib_error_return
- (0, "Choose the underlying forwarder type ip|hicn"));
- }
- else if (hicn_underneath && !sm->is_enabled)
+
+ //Remove bits that are out of the subnet
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
- return (clib_error_return (0, "hICN not enabled in VPP"));
+ ip4_address_t mask;
+ ip4_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
}
- else if (!hicn_underneath && sm->is_enabled)
+ else
{
- return (clib_error_return (0, "hICN enabled in VPP"));
+ ip6_address_t mask;
+ ip6_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip6.as_u64[0] =
+ prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
+ prefix->fp_addr.ip6.as_u64[1] =
+ prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
}
- pg_main->hicn_underneath = hicn_underneath;
/* Allocate the buffer with the actual content payload TLV */
vlib_buffer_alloc (vm, &pg_main->pgen_svr_buffer_idx, 1);
vlib_buffer_t *rb = NULL;
rb = vlib_get_buffer (vm, pg_main->pgen_svr_buffer_idx);
+ pg_main->pgen_srv_hicn_name = prefix;
+
/* Initialize the buffer data with zeros */
memset (rb->data, 0, payload_size);
rb->current_length = payload_size;
- int skip = 2;
- int base_offset = ETH_L2;
- u8 use_current_data = HICN_CLASSIFY_NO_CURRENT_DATA_FLAG;
-
- if (hicn_cli_is_ip_interface (vm, vnm, sw_if_index) == IP)
- {
- skip = 1;
- base_offset = NO_L2;
- use_current_data = HICN_CLASSIFY_CURRENT_DATA_FLAG;
- }
- if (ip46_address_is_ip4 (&prefix.fp_addr))
- {
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.
- hicn_node_info.ip4_inacl_node_index,
- hicn_pg_server_node.index);
-
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv4, &ipv4_src, subnet_mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv4, &ipv4_dst, subnet_mask,
- hicn_punt_glb.ip4_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][subnet_mask - 1], sw_if_index,
- base_offset, use_current_data);
-
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv4, &ipv4_dst,
- &prefix, next_hit_node, sw_if_index,
- base_offset);
-
- hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
-
- }
- else
- {
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.hicn_node_info.
- ip6_inacl_node_index,
- hicn_pg_server_node.index);
-
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv6, &ipv6_src, subnet_mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv6, &ipv6_dst, subnet_mask,
- hicn_punt_glb.ip6_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][subnet_mask - 1], sw_if_index,
- base_offset, use_current_data);
-
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv6, &ipv6_dst,
- &prefix, next_hit_node, sw_if_index,
- base_offset);
-
- hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
- }
+ vnet_feature_enable_disable ("ip4-unicast", "hicnpg-server",
+ sw_if_index, 1, 0, 0);
+ vnet_feature_enable_disable ("ip6-unicast", "hicnpg-server",
+ sw_if_index, 1, 0, 0);
switch (rv)
{
@@ -1121,17 +990,17 @@ VLIB_CLI_COMMAND(hicn_cli_show_command, static)=
/* cli declaration for 'punting' */
VLIB_CLI_COMMAND(hicn_cli_punting_command, static)=
-{
- .path = "hicn punting",
- .short_help = "hicn punting {add|delete} prefix <prefix> intfc <sw_if> {type ip | type <udp4|udp6> src_port <port> dst_port <port>}",
- .function = hicn_cli_punting_command_fn,
-};
+ {
+ .path = "hicn punting",
+ .short_help = "hicn punting {add|delete} prefix <prefix> intfc <sw_if> {type ip | type <udp4|udp6> src_port <port> dst_port <port>}",
+ .function = hicn_cli_punting_command_fn,
+ };
/* cli declaration for 'hicn pgen client' */
VLIB_CLI_COMMAND(hicn_cli_pgen_client_set_command, static)=
{
.path = "hicn pgen client",
- .short_help = "hicn pgen client fwd <ip|hicn> src <src_addr> n_ifaces <n_ifaces> name <prefix> lifetime <interest-lifetime> intfc <data in-interface> max_seq <max sequence number> n_flows <number of flows>",
+ .short_help = "hicn pgen client src <src_addr> name <prefix> { n_ifaces <n_ifaces> lifetime <interest-lifetime> intfc <data in-interface> max_seq <max sequence number> n_flows <number of flows>}",
.long_help = "Run hicn in packet-gen client mode\n",
.function = hicn_cli_pgen_client_set_command_fn,
};
@@ -1140,7 +1009,7 @@ VLIB_CLI_COMMAND(hicn_cli_pgen_client_set_command, static)=
VLIB_CLI_COMMAND(hicn_cli_pgen_server_set_command, static)=
{
.path = "hicn pgen server",
- .short_help = "hicn pgen server fwd <ip|hicn> name <prefix> intfc <interest in-interface> size <payload_size>",
+ .short_help = "hicn pgen server name <prefix> intfc <interest in-interface> size <payload_size>",
.long_help = "Run hicn in packet-gen server mode\n",
.function = hicn_cli_pgen_server_set_command_fn,
};