]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Add fetch_ipv4_array_setting()
authorMichael Brown <mcb30@ipxe.org>
Thu, 9 Dec 2010 15:34:12 +0000 (15:34 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 9 Dec 2010 15:34:12 +0000 (15:34 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/settings.c
src/include/ipxe/settings.h

index 816ae1417ec3d7b53ed5ad0c86552d61432124a2..e2b4826309b8479bc059a4f8089271036ec5043f 100644 (file)
@@ -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
  *
index db20be5ed5051fd904e28944c77448db1cc81452..a764bf0e5ce3170e78c2d5e65b112b7499f7b9e1 100644 (file)
@@ -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,