rmnetctl: Changes for guaranteed padding

Added tail_spacing as an option for ingress data format.

CRs-Fixed: 579184
Change-Id: I1081c8672162d0858934c282a329da55dec285b7
diff --git a/rmnetctl/cli/rmnetcli.c b/rmnetctl/cli/rmnetcli.c
index 8f4d582..f868836 100644
--- a/rmnetctl/cli/rmnetcli.c
+++ b/rmnetctl/cli/rmnetcli.c
@@ -125,8 +125,10 @@
 	printf(_5TABS" byte unsigned integer");
 	printf(_5TABS" egress_flags\n\n");
 	printf("rmnetcli setlidf <ingress_flags>         Sets the ingress");
-	printf(_2TABS" <dev_name>              data format for a particular");
-	printf(_5TABS" link. egress_flags is 4");
+	printf(_2TABS" <tail_spacing>          data format for a particular");
+	printf(_2TABS" <dev_name>              link. ingress_flags is 4");
+	printf(_5TABS" byte unsigned integer.");
+	printf(_5TABS" tail_spacing is a one.");
 	printf(_5TABS" byte unsigned integer.");
 	printf(_5TABS" dev_name cannot be");
 	printf(_5TABS" larger than 15.");
@@ -299,10 +301,12 @@
 		}
 	} else if (!strcmp(*argv, "getlidf")) {
 		uint32_t ingress_flags;
-		return_code = rmnet_get_link_ingress_data_format(handle,
-		argv[1], &ingress_flags, &error_number);
+		uint8_t  tail_spacing;
+		return_code = rmnet_get_link_ingress_data_format_tailspace(
+		handle, argv[1], &ingress_flags, &tail_spacing, &error_number);
 		if (return_code == RMNETCTL_SUCCESS) {
 			printf("ingress_flags is %u\n", ingress_flags);
+			printf("tail_spacing is %u\n", tail_spacing);
 		}
 	} else if (!strcmp(*argv, "newvndprefix")) {
 		_RMNETCLI_CHECKNULL(argv[1]);
@@ -328,8 +332,11 @@
 		_STRTOUI32(argv[1]), &error_number, RMNETCTL_FREE_VND);
 	} else if (!strcmp(*argv, "setlidf")) {
 		_RMNETCLI_CHECKNULL(argv[1]);
-		return_code = rmnet_set_link_ingress_data_format(handle,
-		_STRTOUI32(argv[1]), argv[2], &error_number);
+		_RMNETCLI_CHECKNULL(argv[2]);
+		_RMNETCLI_CHECKNULL(argv[3]);
+		return_code = rmnet_set_link_ingress_data_format_tailspace(
+		handle, _STRTOUI32(argv[1]), _STRTOUI8(argv[2]), argv[3],
+		&error_number);
 	} else if (!strcmp(*argv, "delvnctcflow")) {
 		_RMNETCLI_CHECKNULL(argv[1]);
 		_RMNETCLI_CHECKNULL(argv[2]);
diff --git a/rmnetctl/inc/librmnetctl.h b/rmnetctl/inc/librmnetctl.h
index 25a1477..3c38461 100644
--- a/rmnetctl/inc/librmnetctl.h
+++ b/rmnetctl/inc/librmnetctl.h
@@ -238,6 +238,7 @@
 * @details Message type is RMNET_NETLINK_SET_LINK_INGRESS_DATA_FORMAT.
 * @param *rmnetctl_hndl_t_val RmNet handle for the Netlink message
 * @param ingress_flags Ingress flags from the device
+* @param tail_spacing Tail spacing needed for the packet
 * @param dev_name Device on which to set the ingress data format
 * @param error_code Status code of this operation returned from the kernel
 * @return RMNETCTL_SUCCESS if successful
@@ -246,10 +247,11 @@
 * Check error_code
 * @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
 */
-int rmnet_set_link_ingress_data_format(rmnetctl_hndl_t *hndl,
-				       uint32_t ingress_flags,
-				       const char *dev_name,
-				       uint16_t *error_code);
+int rmnet_set_link_ingress_data_format_tailspace(rmnetctl_hndl_t *hndl,
+						 uint32_t ingress_flags,
+						 uint8_t  tail_spacing,
+						 const char *dev_name,
+						 uint16_t *error_code);
 
 /*!
 * @brief Public API to get the ingress data format for a particular link.
@@ -257,6 +259,7 @@
 * @param *rmnetctl_hndl_t_val RmNet handle for the Netlink message
 * @param dev_name Device on which to get the ingress data format
 * @param ingress_flags Ingress flags from the device
+* @param tail_spacing Tail spacing needed for the packet
 * @param error_code Status code of this operation returned from the kernel
 * @return RMNETCTL_SUCCESS if successful
 * @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
@@ -264,10 +267,35 @@
 * Check error_code
 * @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
 */
-int rmnet_get_link_ingress_data_format(rmnetctl_hndl_t *hndl,
-				       const char *dev_name,
-				       uint32_t *ingress_flags,
-				       uint16_t *error_code);
+int rmnet_get_link_ingress_data_format_tailspace(rmnetctl_hndl_t *hndl,
+						const char *dev_name,
+						uint32_t *ingress_flags,
+						uint8_t  *tail_spacing,
+						uint16_t *error_code);
+
+inline int rmnet_set_link_ingress_data_format(rmnetctl_hndl_t *hndl,
+					      uint32_t ingress_flags,
+					      const char *dev_name,
+					      uint16_t *error_code)
+{
+	return rmnet_set_link_ingress_data_format_tailspace(hndl,
+							    ingress_flags,
+							    0,
+							    dev_name,
+							    error_code);
+}
+
+inline int rmnet_get_link_ingress_data_format(rmnetctl_hndl_t *hndl,
+					      const char *dev_name,
+					      uint32_t *ingress_flags,
+					      uint16_t *error_code)
+{
+	return rmnet_get_link_ingress_data_format_tailspace(hndl,
+							    dev_name,
+							    ingress_flags,
+							    0,
+							    error_code);
+}
 
 /*!
 * @brief Public API to set the logical endpoint configuration for a
diff --git a/rmnetctl/src/librmnetctl.c b/rmnetctl/src/librmnetctl.c
index 7cd3dcd..f87257f 100644
--- a/rmnetctl/src/librmnetctl.c
+++ b/rmnetctl/src/librmnetctl.c
@@ -501,10 +501,11 @@
 	return return_code;
 }
 
-int rmnet_set_link_ingress_data_format(rmnetctl_hndl_t *hndl,
-				       uint32_t ingress_flags,
-				       const char *dev_name,
-				       uint16_t *error_code) {
+int rmnet_set_link_ingress_data_format_tailspace(rmnetctl_hndl_t *hndl,
+						 uint32_t ingress_flags,
+						 uint8_t  tail_spacing,
+						 const char *dev_name,
+						 uint16_t *error_code) {
 	struct rmnet_nl_msg_s request, response;
 	int str_len = -1, return_code = RMNETCTL_LIB_ERR;
 	do {
@@ -523,6 +524,7 @@
 	if (_rmnetctl_check_len(str_len, error_code) != RMNETCTL_SUCCESS)
 		break;
 	request.data_format.flags = ingress_flags;
+	request.data_format.tail_spacing = tail_spacing;
 
 	if ((*error_code = rmnetctl_transact(hndl, &request, &response))
 		!= RMNETCTL_SUCCESS)
@@ -536,14 +538,15 @@
 	return return_code;
 }
 
-int rmnet_get_link_ingress_data_format(rmnetctl_hndl_t *hndl,
-				       const char *dev_name,
-				       uint32_t *ingress_flags,
-				       uint16_t *error_code) {
+int rmnet_get_link_ingress_data_format_tailspace(rmnetctl_hndl_t *hndl,
+						 const char *dev_name,
+						 uint32_t *ingress_flags,
+						 uint8_t  *tail_spacing,
+						 uint16_t *error_code) {
 	struct rmnet_nl_msg_s request, response;
 	int str_len = -1, return_code = RMNETCTL_LIB_ERR;
 	do {
-	if ((!hndl) || (!ingress_flags) || (!error_code) ||
+	if ((!hndl) || (!error_code) ||
 		_rmnetctl_check_dev_name(dev_name)) {
 		return_code = RMNETCTL_INVALID_ARG;
 		break;
@@ -565,7 +568,12 @@
 	if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
 		break;
 
-	*ingress_flags = response.data_format.flags;
+	if (ingress_flags)
+		*ingress_flags = response.data_format.flags;
+
+	if (tail_spacing)
+		*tail_spacing = response.data_format.tail_spacing;
+
 	return_code = RMNETCTL_SUCCESS;
 	} while(0);
 	return return_code;