Browse Source

[settings] Add fetch_ipv6_setting()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
60c4e62e5d
2 changed files with 45 additions and 0 deletions
  1. 38
    0
      src/core/settings.c
  2. 7
    0
      src/include/ipxe/settings.h

+ 38
- 0
src/core/settings.c View File

877
 	return fetch_ipv4_array_setting ( settings, setting, inp, 1 );
877
 	return fetch_ipv4_array_setting ( settings, setting, inp, 1 );
878
 }
878
 }
879
 
879
 
880
+/**
881
+ * Fetch value of IPv6 address setting
882
+ *
883
+ * @v settings		Settings block, or NULL to search all blocks
884
+ * @v setting		Setting to fetch
885
+ * @v inp		IPv6 addresses to fill in
886
+ * @v count		Maximum number of IPv6 addresses
887
+ * @ret len		Length of setting, or negative error
888
+ */
889
+int fetch_ipv6_array_setting ( struct settings *settings,
890
+			       const struct setting *setting,
891
+			       struct in6_addr *inp, unsigned int count ) {
892
+	int len;
893
+
894
+	len = fetch_raw_setting ( settings, setting, inp,
895
+				  ( sizeof ( *inp ) * count ) );
896
+	if ( len < 0 )
897
+		return len;
898
+	if ( ( len % sizeof ( *inp ) ) != 0 )
899
+		return -ERANGE;
900
+	return len;
901
+}
902
+
903
+/**
904
+ * Fetch value of IPv6 address setting
905
+ *
906
+ * @v settings		Settings block, or NULL to search all blocks
907
+ * @v setting		Setting to fetch
908
+ * @v inp		IPv6 address to fill in
909
+ * @ret len		Length of setting, or negative error
910
+ */
911
+int fetch_ipv6_setting ( struct settings *settings,
912
+			 const struct setting *setting,
913
+			 struct in6_addr *inp ) {
914
+
915
+	return fetch_ipv6_array_setting ( settings, setting, inp, 1 );
916
+}
917
+
880
 /**
918
 /**
881
  * Extract numeric value of setting
919
  * Extract numeric value of setting
882
  *
920
  *

+ 7
- 0
src/include/ipxe/settings.h View File

16
 
16
 
17
 struct settings;
17
 struct settings;
18
 struct in_addr;
18
 struct in_addr;
19
+struct in6_addr;
19
 union uuid;
20
 union uuid;
20
 
21
 
21
 /** A setting */
22
 /** A setting */
341
 extern int fetch_ipv4_setting ( struct settings *settings,
342
 extern int fetch_ipv4_setting ( struct settings *settings,
342
 				const struct setting *setting,
343
 				const struct setting *setting,
343
 				struct in_addr *inp );
344
 				struct in_addr *inp );
345
+extern int fetch_ipv6_array_setting ( struct settings *settings,
346
+				      const struct setting *setting,
347
+				      struct in6_addr *inp, unsigned int count);
348
+extern int fetch_ipv6_setting ( struct settings *settings,
349
+				const struct setting *setting,
350
+				struct in6_addr *inp );
344
 extern int fetch_int_setting ( struct settings *settings,
351
 extern int fetch_int_setting ( struct settings *settings,
345
 			       const struct setting *setting, long *value );
352
 			       const struct setting *setting, long *value );
346
 extern int fetch_uint_setting ( struct settings *settings,
353
 extern int fetch_uint_setting ( struct settings *settings,

Loading…
Cancel
Save