complete: add eth interface complete support
use it on ethact Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
parent
8e6f45f54f
commit
b7fc51bd79
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <complete.h>
|
||||
#include <environment.h>
|
||||
#include <driver.h>
|
||||
#include <net.h>
|
||||
|
@ -96,5 +97,6 @@ BAREBOX_CMD_START(ethact)
|
|||
.cmd = do_ethact,
|
||||
.usage = "set current ethernet device",
|
||||
BAREBOX_CMD_HELP(cmd_ethact_help)
|
||||
BAREBOX_CMD_COMPLETE(eth_complete)
|
||||
BAREBOX_CMD_END
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ void complete_reset(void);
|
|||
int command_complete(struct string_list *sl, char *instr);
|
||||
int device_complete(struct string_list *sl, char *instr);
|
||||
int empty_complete(struct string_list *sl, char *instr);
|
||||
int eth_complete(struct string_list *sl, char *instr);
|
||||
|
||||
#endif /* __COMPLETE_ */
|
||||
|
||||
|
|
21
net/eth.c
21
net/eth.c
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <complete.h>
|
||||
#include <driver.h>
|
||||
#include <init.h>
|
||||
#include <net.h>
|
||||
|
@ -109,6 +110,26 @@ struct eth_device *eth_get_byname(char *ethname)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_AUTO_COMPLETE
|
||||
int eth_complete(struct string_list *sl, char *instr)
|
||||
{
|
||||
struct eth_device *edev;
|
||||
const char *devname;
|
||||
int len;
|
||||
|
||||
len = strlen(instr);
|
||||
|
||||
list_for_each_entry(edev, &netdev_list, list) {
|
||||
devname = dev_name(&edev->dev);
|
||||
if (strncmp(instr, devname, len))
|
||||
continue;
|
||||
|
||||
string_list_add_asprintf(sl, "%s ", devname);
|
||||
}
|
||||
return COMPLETE_CONTNINUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int eth_send(void *packet, int length)
|
||||
{
|
||||
int ret;
|
||||
|
|
Loading…
Reference in New Issue