Skip to content

Commit

Permalink
[settings] Add fetch_ipv4_array_setting()
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Dec 9, 2010
1 parent 66531a5 commit cb838cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/core/settings.c
Expand Up @@ -651,21 +651,37 @@ 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
*
Expand Down
4 changes: 4 additions & 0 deletions src/include/ipxe/settings.h
Expand Up @@ -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,
Expand Down

0 comments on commit cb838cc

Please sign in to comment.