Kaynağa Gözat

[settings] Add fetch_ipv6_setting()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 yıl önce
ebeveyn
işleme
60c4e62e5d
2 değiştirilmiş dosya ile 45 ekleme ve 0 silme
  1. 38
    0
      src/core/settings.c
  2. 7
    0
      src/include/ipxe/settings.h

+ 38
- 0
src/core/settings.c Dosyayı Görüntüle

@@ -877,6 +877,44 @@ int fetch_ipv4_setting ( struct settings *settings,
877 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 919
  * Extract numeric value of setting
882 920
  *

+ 7
- 0
src/include/ipxe/settings.h Dosyayı Görüntüle

@@ -16,6 +16,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
16 16
 
17 17
 struct settings;
18 18
 struct in_addr;
19
+struct in6_addr;
19 20
 union uuid;
20 21
 
21 22
 /** A setting */
@@ -341,6 +342,12 @@ extern int fetch_ipv4_array_setting ( struct settings *settings,
341 342
 extern int fetch_ipv4_setting ( struct settings *settings,
342 343
 				const struct setting *setting,
343 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 351
 extern int fetch_int_setting ( struct settings *settings,
345 352
 			       const struct setting *setting, long *value );
346 353
 extern int fetch_uint_setting ( struct settings *settings,

Loading…
İptal
Kaydet