blob: a483c931fd1ca197e8a3ed8f1d6faf9c45bfedda [file] [log] [blame]
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -06001/******************************************************************************
2
3 R M N E T C L I . C
4
Subash Abhinov Kasiviswanathandba447c2017-02-23 17:58:09 -07005Copyright (c) 2013-2015, 2017 The Linux Foundation. All rights reserved.
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -06006
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are
9met:
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16 * Neither the name of The Linux Foundation nor the names of its
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
21WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
23ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
24BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33
34/******************************************************************************
35
36 @file rmnetcli.c
37 @brief command line interface to expose rmnet control API's
38
39 DESCRIPTION
40 File containing implementation of the command line interface to expose the
41 rmnet control configuration .
42
43******************************************************************************/
44
45/*===========================================================================
46 INCLUDE FILES
47===========================================================================*/
48
49#include <sys/socket.h>
50#include <stdint.h>
51#include <linux/netlink.h>
52#include <string.h>
53#include <stdio.h>
54#include <unistd.h>
55#include <stdlib.h>
56#include "rmnetcli.h"
57#include "librmnetctl.h"
58
59#define RMNET_MAX_STR_LEN 16
60
61#define _RMNETCLI_CHECKNULL(X) do { if (!X) { \
62print_rmnet_api_status(RMNETCTL_INVALID_ARG, RMNETCTL_CFG_FAILURE_NO_COMMAND); \
63 rmnetctl_cleanup(handle); \
64 return RMNETCTL_INVALID_ARG; \
65 } } while (0);
66#define _STRTOUI32(X) (uint32_t)strtoul(X, NULL, 0)
67#define _STRTOUI16(X) (uint16_t)strtoul(X, NULL, 0)
68#define _STRTOUI8(X) (uint8_t)strtoul(X, NULL, 0)
69#define _STRTOI32(X) (int32_t)strtol(X, NULL, 0)
70
71#define _5TABS "\n\t\t\t\t\t"
72#define _2TABS "\n\t\t"
73
74/*!
75* @brief Contains a list of error message from CLI
76*/
77char rmnetcfg_error_code_text
78[RMNETCFG_TOTAL_ERR_MSGS][RMNETCTL_ERR_MSG_SIZE] = {
79 "Help option Specified",
80 "ERROR: No\\Invalid command was specified\n",
81 "ERROR: Could not allocate buffer for Egress device\n"
82};
83
84/*!
85* @brief Method to display the syntax for the commands
86* @details Displays the syntax and usage for the commands
87* @param void
88* @return void
89*/
Harout Hedeshian04d69732013-10-02 09:29:11 -060090static void rmnet_api_usage(void)
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -060091{
92 printf("RmNet API Usage:\n\n");
93 printf("rmnetcli help Displays this help\n");
94 printf("\n");
95 printf("rmnetcli assocnetdev <dev_name> Registers the RmNet");
96 printf(_5TABS" data driver on a particular");
97 printf(_5TABS" device.dev_name cannot");
98 printf(_5TABS" be larger than 15");
99 printf(_5TABS" characters. Returns");
100 printf(_5TABS" the status code.\n\n");
101 printf("rmnetcli unassocnetdev <dev_name> Unregisters the");
102 printf(_5TABS" RmNet data driver on a particular");
103 printf(_5TABS" device. dev_name cannot");
104 printf(_5TABS" be larger than 15");
105 printf(_5TABS" characters. Returns");
106 printf(_5TABS" the status code.\n\n");
107 printf("rmnetcli getnetdevassoc <dev_name> Get if the RmNet");
108 printf(_5TABS" data driver is registered on");
109 printf(_5TABS" a particular device.");
110 printf(_5TABS" dev_name cannot be");
111 printf(_5TABS" larger than 15");
112 printf(_5TABS" characters. Returns 1");
113 printf(_5TABS" if is registered and");
114 printf(_5TABS" 0 if it is not");
115 printf(_5TABS" registered\n\n");
116 printf("rmnetcli setledf <egress_flags> Sets the egress data");
117 printf(_2TABS" <agg_size> format for a particular link.");
118 printf(_2TABS" <agg_count> dev_name cannot be larger");
119 printf(_2TABS" <dev_name> than 15 characters.");
120 printf(_5TABS" Returns the status code\n\n");
121 printf("rmnetcli getledf <dev_name> Gets the egress data");
122 printf(_5TABS" format for a particular link.");
123 printf(_5TABS" dev_name cannot be larger");
124 printf(_5TABS" than 15. Returns the 4");
125 printf(_5TABS" byte unsigned integer");
126 printf(_5TABS" egress_flags\n\n");
127 printf("rmnetcli setlidf <ingress_flags> Sets the ingress");
Subash Abhinov Kasiviswanathan22fa3882014-01-16 12:55:45 -0700128 printf(_2TABS" <tail_spacing> data format for a particular");
129 printf(_2TABS" <dev_name> link. ingress_flags is 4");
130 printf(_5TABS" byte unsigned integer.");
131 printf(_5TABS" tail_spacing is a one.");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600132 printf(_5TABS" byte unsigned integer.");
133 printf(_5TABS" dev_name cannot be");
134 printf(_5TABS" larger than 15.");
135 printf(_5TABS" characters. Returns");
136 printf(_5TABS" the status code\n\n");
137 printf("rmnetcli getlidf <dev_name> Gets the ingress");
138 printf(_5TABS" data format for a particular");
139 printf(_5TABS" link. dev_name cannot be");
140 printf(_5TABS" larger than 15. Returns");
141 printf(_5TABS" the 4 byte unsigned");
142 printf(_5TABS" integer ingress_flags\n\n");
143 printf("rmnetcli setlepc <logical_ep_id> Sets the logical");
144 printf(_2TABS" <rmnet_mode> endpoint configuration for");
145 printf(_2TABS" <dev_name> a particular link.");
146 printf(_2TABS" <egress_dev_name> logical_ep_id are 32bit");
147 printf(_5TABS" integers from -1 to 31.");
148 printf(_5TABS" rmnet_mode is a 1 byte");
149 printf(_5TABS" unsigned integer of");
150 printf(_5TABS" value none, vnd or");
151 printf(_5TABS" bridged. dev_name");
152 printf(_5TABS" and egress_dev_name");
153 printf(_5TABS" cannot be larger");
Subash Abhinov Kasiviswanathancf715082015-04-14 13:51:59 -0600154 printf(_5TABS" than 15 characters");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600155 printf(_5TABS" Returns the status code\n\n");
Harout Hedeshiana9731652014-01-06 18:00:23 +0200156 printf("rmnetcli unsetlepc <logical_ep_id> Un-sets the logical");
157 printf(_2TABS" <dev_name> endpoint configuration for");
158 printf(_5TABS" a particular link.");
159 printf(_5TABS" integers from -1 to 31.");
160 printf(_5TABS" dev_name cannot be larger");
Subash Abhinov Kasiviswanathancf715082015-04-14 13:51:59 -0600161 printf(_5TABS" than 15 characters");
Harout Hedeshiana9731652014-01-06 18:00:23 +0200162 printf(_5TABS" Returns the status code\n\n");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600163 printf("rmnetcli getlepc <logical_ep_id> Sets the logical");
Subash Abhinov Kasiviswanathancf715082015-04-14 13:51:59 -0600164 printf(_2TABS" <dev_name> endpoint configuration for a");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600165 printf(_5TABS" particular link.");
166 printf(_5TABS" logical_ep_id are 32bit");
167 printf(_5TABS" integers from -1 to 31.");
168 printf(_5TABS" Returns the rmnet_mode");
169 printf(_5TABS" and egress_dev_name.");
170 printf(_5TABS" rmnet_mode is a 1");
171 printf(_5TABS" byte unsigned integer");
172 printf(_5TABS" of value none, vnd or");
173 printf(_5TABS" bridged. dev_name and");
174 printf(_5TABS" egress_dev_name cannot be");
175 printf(_5TABS" larger than 15 ");
176 printf(_5TABS" characters. Returns the");
177 printf(_5TABS" status code\n\n");
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600178 printf("rmnetcli newvnd <dev_id> Creates a new");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600179 printf(_5TABS" virtual network device node.");
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600180 printf(_5TABS" dev_id is an int");
181 printf(_5TABS" less than 32. Returns");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600182 printf(_5TABS" the status code\n\n");
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600183 printf("rmnetcli newvndprefix <dev_id> <name_prefix> Creates");
184 printf(_5TABS" virtual network device node.");
185 printf(_5TABS" dev_id is an int");
186 printf(_5TABS" less than 32. Prefix");
187 printf(_5TABS" must be less than");
188 printf(_5TABS" 15 chars. Returns");
189 printf(_5TABS" the status code\n\n");
Subash Abhinov Kasiviswanathandba447c2017-02-23 17:58:09 -0700190 printf("rmnetcli newvndname <dev_id> <name_prefix> Creates");
191 printf(_5TABS" virtual network device node.");
192 printf(_5TABS" dev_id is an int");
193 printf(_5TABS" less than 32. Name");
194 printf(_5TABS" must be less than");
195 printf(_5TABS" 15 chars. Returns");
196 printf(_5TABS" the status code\n\n");
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600197 printf("rmnetcli getvndname <dev_id> Get name of");
Harout Hedeshiana9731652014-01-06 18:00:23 +0200198 printf(_5TABS" network device node from id\n\n");
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600199 printf("rmnetcli freevnd <dev_id> Removes virtual");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600200 printf(_5TABS" network device node. dev_name");
201 printf(_5TABS" cannot be larger than 15.");
202 printf(_5TABS" Returns the status code\n\n");
Harout Hedeshian97a1e982013-11-08 09:28:53 -0700203 printf("rmnetcli addvnctcflow <dev_id> Add a modem flow");
204 printf(_2TABS" <mdm_flow_hndl> handle - tc flow handle");
205 printf(_2TABS" <tc_flow_hndl> mapping for a virtual network");
206 printf(_2TABS" device node\n\n");
207 printf("rmnetcli delvnctcflow <dev_id> Delete a modem flow");
208 printf(_2TABS" <mdm_flow_hndl> handle - tc flow handle");
209 printf(_2TABS" <tc_flow_hndl> mapping for a virtual network");
210 printf(_2TABS" device node\n\n");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600211}
212
Harout Hedeshian77825572014-02-17 10:47:14 +0200213static void print_rmnetctl_lib_errors(uint16_t error_number)
214{
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600215 if ((error_number > RMNETCTL_API_SUCCESS) &&
216 (error_number < RMNETCTL_API_ERR_ENUM_LENGTH)) {
217 printf("%s", rmnetctl_error_code_text[error_number]);
218 }
219 if ((error_number >= RMNETCFG_ERR_NUM_START) &&
220 (error_number < RMNETCFG_ERR_NUM_START + RMNETCFG_TOTAL_ERR_MSGS)) {
221 printf("%s", rmnetcfg_error_code_text
222 [error_number - RMNETCFG_ERR_NUM_START]);
223 if ((error_number == RMNETCTL_CFG_SUCCESS_HELP_COMMAND) ||
224 (error_number == RMNETCTL_CFG_FAILURE_NO_COMMAND))
225 rmnet_api_usage();
226 }
227}
228
229/*!
230* @brief Method to check the error numbers generated from API calls
231* @details Displays the error messages based on each error code
232* @param error_number Error number returned from the API and the CLI
233* @return void
234*/
235static void print_rmnet_api_status(int return_code, uint16_t error_number)
236{
237 if (return_code == RMNETCTL_SUCCESS)
238 printf("SUCCESS\n");
Harout Hedeshian77825572014-02-17 10:47:14 +0200239 else if (return_code == RMNETCTL_LIB_ERR) {
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600240 printf("LIBRARY ");
Harout Hedeshian77825572014-02-17 10:47:14 +0200241 print_rmnetctl_lib_errors(error_number);
242 } else if (return_code == RMNETCTL_KERNEL_ERR)
243 printf("KERNEL %s", rmnetctl_error_code_text[error_number]);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600244 else if (return_code == RMNETCTL_INVALID_ARG)
245 printf("INVALID_ARG\n");
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600246}
247
248/*!
249* @brief Method to make the API calls
250* @details Checks for each type of parameter and calls the appropriate
Subash Abhinov Kasiviswanathancf715082015-04-14 13:51:59 -0600251* function based on the number of parameters and parameter type
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600252* @param argc Number of arguments which vary based on the commands
253* @param argv Value of the arguments which vary based on the commands
254* @return RMNETCTL_SUCCESS if successful. Relevant data might be printed
255* based on the message type
256* @return RMNETCTL_LIB_ERR if there was a library error. Error code will be
257* printed
258* @return RMNETCTL_KERNEL_ERR if there was a error in the kernel. Error code will be
259* printed
260* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
261*/
262
263static int rmnet_api_call(int argc, char *argv[])
264{
265 struct rmnetctl_hndl_s *handle = NULL;
266 uint16_t error_number = RMNETCTL_CFG_FAILURE_NO_COMMAND;
267 int return_code = RMNETCTL_LIB_ERR;
268 if ((!argc) || (!*argv)) {
269 print_rmnet_api_status(RMNETCTL_LIB_ERR,
270 RMNETCTL_CFG_FAILURE_NO_COMMAND);
271 return RMNETCTL_LIB_ERR;
272 }
273 if (!strcmp(*argv, "help")) {
274 print_rmnet_api_status(RMNETCTL_LIB_ERR,
275 RMNETCTL_CFG_SUCCESS_HELP_COMMAND);
276 return RMNETCTL_LIB_ERR;
277 }
278 return_code = rmnetctl_init(&handle, &error_number);
279 if (return_code!= RMNETCTL_SUCCESS) {
280 print_rmnet_api_status(return_code, error_number);
281 return RMNETCTL_LIB_ERR;
282 }
283 error_number = RMNETCTL_CFG_FAILURE_NO_COMMAND;
284 return_code = RMNETCTL_LIB_ERR;
285 if (!strcmp(*argv, "assocnetdev")) {
286 return_code = rmnet_associate_network_device(handle,
287 argv[1], &error_number, RMNETCTL_DEVICE_ASSOCIATE);
288 } else if (!strcmp(*argv, "unassocnetdev")) {
289 return_code = rmnet_associate_network_device(handle,
290 argv[1], &error_number, RMNETCTL_DEVICE_UNASSOCIATE);
291 } else if (!strcmp(*argv, "getnetdevassoc")) {
292 int register_status;
293 return_code = rmnet_get_network_device_associated(handle,
294 argv[1], &register_status, &error_number);
295 if (return_code == RMNETCTL_SUCCESS)
296 printf("register_status is %d\n", register_status);
297 } else if (!strcmp(*argv, "getledf")) {
298 uint32_t egress_flags;
299 uint16_t agg_size, agg_count;
300 return_code = rmnet_get_link_egress_data_format(handle,
301 argv[1], &egress_flags, &agg_size, &agg_count, &error_number);
302 if (return_code == RMNETCTL_SUCCESS) {
303 printf("egress_flags is %u\n", egress_flags);
304 printf("agg_size is %u\n", agg_size);
305 printf("agg_count is %u\n", agg_count);
306 }
307 } else if (!strcmp(*argv, "getlidf")) {
308 uint32_t ingress_flags;
Subash Abhinov Kasiviswanathan22fa3882014-01-16 12:55:45 -0700309 uint8_t tail_spacing;
310 return_code = rmnet_get_link_ingress_data_format_tailspace(
311 handle, argv[1], &ingress_flags, &tail_spacing, &error_number);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600312 if (return_code == RMNETCTL_SUCCESS) {
313 printf("ingress_flags is %u\n", ingress_flags);
Subash Abhinov Kasiviswanathan22fa3882014-01-16 12:55:45 -0700314 printf("tail_spacing is %u\n", tail_spacing);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600315 }
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600316 } else if (!strcmp(*argv, "newvndprefix")) {
317 _RMNETCLI_CHECKNULL(argv[1]);
318 _RMNETCLI_CHECKNULL(argv[2]);
319 return_code = rmnet_new_vnd_prefix(handle,
320 _STRTOUI32(argv[1]), &error_number, RMNETCTL_NEW_VND, argv[2]);
Subash Abhinov Kasiviswanathandba447c2017-02-23 17:58:09 -0700321 } else if (!strcmp(*argv, "newvndname")) {
322 _RMNETCLI_CHECKNULL(argv[1]);
323 _RMNETCLI_CHECKNULL(argv[2]);
324 return_code = rmnet_new_vnd_name(handle,
325 _STRTOUI32(argv[1]), &error_number, argv[2]);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600326 } else if (!strcmp(*argv, "newvnd")) {
327 _RMNETCLI_CHECKNULL(argv[1]);
328 return_code = rmnet_new_vnd(handle,
329 _STRTOUI32(argv[1]), &error_number, RMNETCTL_NEW_VND);
Harout Hedeshian89a91e22013-10-09 08:59:47 -0600330 } else if (!strcmp(*argv, "getvndname")) {
331 char buffer[32];
332 memset(buffer, 0, 32);
333 _RMNETCLI_CHECKNULL(argv[1]);
334 return_code = rmnet_get_vnd_name(handle, _STRTOUI32(argv[1]),
335 &error_number, buffer, 32);
336 if (return_code == RMNETCTL_SUCCESS) {
337 printf("VND name: %s\n", buffer);
338 }
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600339 } else if (!strcmp(*argv, "freevnd")) {
340 _RMNETCLI_CHECKNULL(argv[1]);
341 return_code = rmnet_new_vnd(handle,
342 _STRTOUI32(argv[1]), &error_number, RMNETCTL_FREE_VND);
343 } else if (!strcmp(*argv, "setlidf")) {
344 _RMNETCLI_CHECKNULL(argv[1]);
Subash Abhinov Kasiviswanathan22fa3882014-01-16 12:55:45 -0700345 _RMNETCLI_CHECKNULL(argv[2]);
346 _RMNETCLI_CHECKNULL(argv[3]);
347 return_code = rmnet_set_link_ingress_data_format_tailspace(
348 handle, _STRTOUI32(argv[1]), _STRTOUI8(argv[2]), argv[3],
349 &error_number);
Harout Hedeshian97a1e982013-11-08 09:28:53 -0700350 } else if (!strcmp(*argv, "delvnctcflow")) {
351 _RMNETCLI_CHECKNULL(argv[1]);
352 _RMNETCLI_CHECKNULL(argv[2]);
353 _RMNETCLI_CHECKNULL(argv[3]);
354 return_code = rmnet_add_del_vnd_tc_flow(handle,
355 _STRTOUI32(argv[1]), _STRTOUI32(argv[2]), _STRTOUI32(argv[3]),
356 RMNETCTL_DEL_FLOW, &error_number);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600357 } else if (!strcmp(*argv, "getlepc")) {
358 _RMNETCLI_CHECKNULL(argv[1]);
359 uint8_t rmnet_mode;
360 char *egress_dev_name;
361 egress_dev_name = NULL;
362 egress_dev_name = (char *)malloc(RMNET_MAX_STR_LEN
363 * sizeof(char));
364 if (!egress_dev_name) {
365 print_rmnet_api_status(RMNETCTL_LIB_ERR,
366 RMNETCTL_CFG_FAILURE_EGRESS_DEV_NAME_NULL);
Harout Hedeshian0bf0a172014-02-19 23:52:05 -0700367 rmnetctl_cleanup(handle);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600368 return RMNETCTL_LIB_ERR;
369 }
370 return_code = rmnet_get_logical_ep_config(handle,
371 _STRTOI32(argv[1]), argv[2], &rmnet_mode,
Harout Hedeshian77825572014-02-17 10:47:14 +0200372 &egress_dev_name, RMNET_MAX_STR_LEN, &error_number);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600373 if (return_code == RMNETCTL_SUCCESS) {
374 printf("rmnet_mode is %u\n", rmnet_mode);
375 printf("egress_dev_name is %s\n", egress_dev_name);
376 }
Harout Hedeshian0bf0a172014-02-19 23:52:05 -0700377 free(egress_dev_name);
Harout Hedeshian97a1e982013-11-08 09:28:53 -0700378 } else if (!strcmp(*argv, "addvnctcflow")) {
379 _RMNETCLI_CHECKNULL(argv[1]);
380 _RMNETCLI_CHECKNULL(argv[2]);
381 _RMNETCLI_CHECKNULL(argv[3]);
382 return_code = rmnet_add_del_vnd_tc_flow(handle,
383 _STRTOUI32(argv[1]), _STRTOUI32(argv[2]), _STRTOUI32(argv[3]),
384 RMNETCTL_ADD_FLOW, &error_number);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600385 } else if (!strcmp(*argv, "setledf")) {
386 _RMNETCLI_CHECKNULL(argv[1]);
387 _RMNETCLI_CHECKNULL(argv[2]);
388 _RMNETCLI_CHECKNULL(argv[3]);
389 return_code = rmnet_set_link_egress_data_format(handle,
390 _STRTOUI32(argv[1]), _STRTOUI16(argv[2]), _STRTOUI16(argv[3]),
391 argv[4], &error_number);
392 } else if (!strcmp(*argv, "setlepc")) {
393 _RMNETCLI_CHECKNULL(argv[1]);
394 _RMNETCLI_CHECKNULL(argv[2]);
395 return_code = rmnet_set_logical_ep_config(handle,
396 _STRTOI32(argv[1]), _STRTOUI8(argv[2]), argv[3], argv[4],
397 &error_number);
Harout Hedeshiana9731652014-01-06 18:00:23 +0200398 } else if (!strcmp(*argv, "unsetlepc")) {
399 _RMNETCLI_CHECKNULL(argv[1]);
400 return_code = rmnet_unset_logical_ep_config(handle,
401 _STRTOI32(argv[1]), argv[2], &error_number);
Harout Hedeshianb2fc5b12013-09-03 13:49:00 -0600402 }
403 print_rmnet_api_status(return_code, error_number);
404 rmnetctl_cleanup(handle);
405 return return_code;
406}
407
408/*!
409* @brief Method which serves as en entry point to the rmnetcli function
410* @details Entry point for the RmNet Netlink API. This is the command line
411* interface for the RmNet API
412* @param argc Number of arguments which vary based on the commands
413* @param argv Value of the arguments which vary based on the commands
414* @return RMNETCTL_SUCCESS if successful. Relevant data might be printed
415* based on the message type
416* @return RMNETCTL_LIB_ERR if there was a library error. Error code will be
417* printed
418* @return RMNETCTL_KERNEL_ERR if there was a error in the kernel. Error code will be
419* printed
420* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
421*/
422int main(int argc, char *argv[])
423{
424 argc--;
425 argv++;
426 return rmnet_api_call(argc, argv);
427}