Skip to content

Commit

Permalink
[settings] Add fetch_ipv6_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 5, 2013
1 parent 17451b5 commit 60c4e62
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/core/settings.c
Expand Up @@ -877,6 +877,44 @@ int fetch_ipv4_setting ( struct settings *settings,
return fetch_ipv4_array_setting ( settings, setting, inp, 1 );
}

/**
* Fetch value of IPv6 address setting
*
* @v settings Settings block, or NULL to search all blocks
* @v setting Setting to fetch
* @v inp IPv6 addresses to fill in
* @v count Maximum number of IPv6 addresses
* @ret len Length of setting, or negative error
*/
int fetch_ipv6_array_setting ( struct settings *settings,
const struct setting *setting,
struct in6_addr *inp, unsigned int count ) {
int len;

len = fetch_raw_setting ( settings, setting, inp,
( sizeof ( *inp ) * count ) );
if ( len < 0 )
return len;
if ( ( len % sizeof ( *inp ) ) != 0 )
return -ERANGE;
return len;
}

/**
* Fetch value of IPv6 address setting
*
* @v settings Settings block, or NULL to search all blocks
* @v setting Setting to fetch
* @v inp IPv6 address to fill in
* @ret len Length of setting, or negative error
*/
int fetch_ipv6_setting ( struct settings *settings,
const struct setting *setting,
struct in6_addr *inp ) {

return fetch_ipv6_array_setting ( settings, setting, inp, 1 );
}

/**
* Extract numeric value of setting
*
Expand Down
7 changes: 7 additions & 0 deletions src/include/ipxe/settings.h
Expand Up @@ -16,6 +16,7 @@ FILE_LICENCE ( GPL2_OR_LATER );

struct settings;
struct in_addr;
struct in6_addr;
union uuid;

/** A setting */
Expand Down Expand Up @@ -341,6 +342,12 @@ extern int fetch_ipv4_array_setting ( struct settings *settings,
extern int fetch_ipv4_setting ( struct settings *settings,
const struct setting *setting,
struct in_addr *inp );
extern int fetch_ipv6_array_setting ( struct settings *settings,
const struct setting *setting,
struct in6_addr *inp, unsigned int count);
extern int fetch_ipv6_setting ( struct settings *settings,
const struct setting *setting,
struct in6_addr *inp );
extern int fetch_int_setting ( struct settings *settings,
const struct setting *setting, long *value );
extern int fetch_uint_setting ( struct settings *settings,
Expand Down

0 comments on commit 60c4e62

Please sign in to comment.