From 3a67224c622332c4e75484b4510780e7818ac2e4 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 4 Nov 2013 17:05:16 +0000 Subject: [PATCH] [parseopt] Add parse_netdev_configurator() Signed-off-by: Michael Brown --- src/core/parseopt.c | 23 +++++++++++++++++++++++ src/include/ipxe/parseopt.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/core/parseopt.c b/src/core/parseopt.c index 51450835..334ffb2c 100644 --- a/src/core/parseopt.c +++ b/src/core/parseopt.c @@ -139,6 +139,29 @@ int parse_netdev ( char *text, struct net_device **netdev ) { return 0; } +/** + * Parse network device configurator name + * + * @v text Text + * @ret configurator Network device configurator + * @ret rc Return status code + */ +int parse_netdev_configurator ( char *text, + struct net_device_configurator **configurator ){ + + /* Sanity check */ + assert ( text != NULL ); + + /* Find network device configurator */ + *configurator = find_netdev_configurator ( text ); + if ( ! *configurator ) { + printf ( "\"%s\": no such configurator\n", text ); + return -ENOTSUP; + } + + return 0; +} + /** * Parse menu name * diff --git a/src/include/ipxe/parseopt.h b/src/include/ipxe/parseopt.h index e3b54c8e..840de749 100644 --- a/src/include/ipxe/parseopt.h +++ b/src/include/ipxe/parseopt.h @@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include struct net_device; +struct net_device_configurator; struct menu; struct parameters; @@ -128,6 +129,9 @@ extern int parse_string ( char *text, char **value ); extern int parse_integer ( char *text, unsigned int *value ); extern int parse_timeout ( char *text, unsigned long *value ); extern int parse_netdev ( char *text, struct net_device **netdev ); +extern int +parse_netdev_configurator ( char *text, + struct net_device_configurator **configurator ); extern int parse_menu ( char *text, struct menu **menu ); extern int parse_flag ( char *text __unused, int *flag ); extern int parse_key ( char *text, unsigned int *key );