diff options
author | Michael Brown | 2010-12-09 16:34:12 +0100 |
---|---|---|
committer | Michael Brown | 2010-12-09 16:34:12 +0100 |
commit | cb838cc419194e1c676cbee60e35bdc2db05af97 (patch) | |
tree | f411f27c64c129948e1df51e41e11c5ff782a81a | |
parent | [debug] Add DBG_MD5() and related macros (diff) | |
download | ipxe-cb838cc419194e1c676cbee60e35bdc2db05af97.tar.gz ipxe-cb838cc419194e1c676cbee60e35bdc2db05af97.tar.xz ipxe-cb838cc419194e1c676cbee60e35bdc2db05af97.zip |
[settings] Add fetch_ipv4_array_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/core/settings.c | 26 | ||||
-rw-r--r-- | src/include/ipxe/settings.h | 4 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index 816ae141..e2b48263 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -651,22 +651,38 @@ int fetch_string_setting_copy ( struct settings *settings, * * @v settings Settings block, or NULL to search all blocks * @v setting Setting to fetch - * @v inp IPv4 address to fill in + * @v inp IPv4 addresses to fill in + * @v count Maximum number of IPv4 addresses * @ret len Length of setting, or negative error */ -int fetch_ipv4_setting ( struct settings *settings, struct setting *setting, - struct in_addr *inp ) { +int fetch_ipv4_array_setting ( struct settings *settings, + struct setting *setting, + struct in_addr *inp, unsigned int count ) { int len; - len = fetch_setting ( settings, setting, inp, sizeof ( *inp ) ); + len = fetch_setting ( settings, setting, inp, + ( sizeof ( *inp ) * count ) ); if ( len < 0 ) return len; - if ( len < ( int ) sizeof ( *inp ) ) + if ( ( len % sizeof ( *inp ) ) != 0 ) return -ERANGE; return len; } /** + * Fetch value of IPv4 address setting + * + * @v settings Settings block, or NULL to search all blocks + * @v setting Setting to fetch + * @v inp IPv4 address to fill in + * @ret len Length of setting, or negative error + */ +int fetch_ipv4_setting ( struct settings *settings, struct setting *setting, + struct in_addr *inp ) { + return fetch_ipv4_array_setting ( settings, setting, inp, 1 ); +} + +/** * Fetch value of signed integer setting * * @v settings Settings block, or NULL to search all blocks diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h index db20be5e..a764bf0e 100644 --- a/src/include/ipxe/settings.h +++ b/src/include/ipxe/settings.h @@ -193,6 +193,10 @@ extern int fetch_string_setting ( struct settings *settings, extern int fetch_string_setting_copy ( struct settings *settings, struct setting *setting, char **data ); +extern int fetch_ipv4_array_setting ( struct settings *settings, + struct setting *setting, + struct in_addr *inp, + unsigned int count ); extern int fetch_ipv4_setting ( struct settings *settings, struct setting *setting, struct in_addr *inp ); extern int fetch_int_setting ( struct settings *settings, |