|
@@ -28,6 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
28
|
28
|
#include <errno.h>
|
29
|
29
|
#include <assert.h>
|
30
|
30
|
#include <ipxe/in.h>
|
|
31
|
+#include <ipxe/ip.h>
|
|
32
|
+#include <ipxe/ipv6.h>
|
31
|
33
|
#include <ipxe/vsprintf.h>
|
32
|
34
|
#include <ipxe/dhcp.h>
|
33
|
35
|
#include <ipxe/uuid.h>
|
|
@@ -1648,7 +1650,7 @@ const struct setting_type setting_type_uristring __setting_type = {
|
1648
|
1650
|
};
|
1649
|
1651
|
|
1650
|
1652
|
/**
|
1651
|
|
- * Parse IPv4 address setting value
|
|
1653
|
+ * Parse IPv4 address setting value (when IPv4 support is not present)
|
1652
|
1654
|
*
|
1653
|
1655
|
* @v type Setting type
|
1654
|
1656
|
* @v value Formatted setting value
|
|
@@ -1656,24 +1658,14 @@ const struct setting_type setting_type_uristring __setting_type = {
|
1656
|
1658
|
* @v len Length of buffer
|
1657
|
1659
|
* @ret len Length of raw value, or negative error
|
1658
|
1660
|
*/
|
1659
|
|
-static int parse_ipv4_setting ( const struct setting_type *type __unused,
|
1660
|
|
- const char *value, void *buf, size_t len ) {
|
1661
|
|
- struct in_addr ipv4;
|
1662
|
|
-
|
1663
|
|
- /* Parse IPv4 address */
|
1664
|
|
- if ( inet_aton ( value, &ipv4 ) == 0 )
|
1665
|
|
- return -EINVAL;
|
1666
|
|
-
|
1667
|
|
- /* Copy to buffer */
|
1668
|
|
- if ( len > sizeof ( ipv4 ) )
|
1669
|
|
- len = sizeof ( ipv4 );
|
1670
|
|
- memcpy ( buf, &ipv4, len );
|
1671
|
|
-
|
1672
|
|
- return ( sizeof ( ipv4 ) );
|
|
1661
|
+__weak int parse_ipv4_setting ( const struct setting_type *type __unused,
|
|
1662
|
+ const char *value __unused, void *buf __unused,
|
|
1663
|
+ size_t len __unused ) {
|
|
1664
|
+ return -ENOTSUP;
|
1673
|
1665
|
}
|
1674
|
1666
|
|
1675
|
1667
|
/**
|
1676
|
|
- * Format IPv4 address setting value
|
|
1668
|
+ * Format IPv4 address setting value (when IPv4 support is not present)
|
1677
|
1669
|
*
|
1678
|
1670
|
* @v type Setting type
|
1679
|
1671
|
* @v raw Raw setting value
|
|
@@ -1682,14 +1674,11 @@ static int parse_ipv4_setting ( const struct setting_type *type __unused,
|
1682
|
1674
|
* @v len Length of buffer
|
1683
|
1675
|
* @ret len Length of formatted value, or negative error
|
1684
|
1676
|
*/
|
1685
|
|
-static int format_ipv4_setting ( const struct setting_type *type __unused,
|
1686
|
|
- const void *raw, size_t raw_len, char *buf,
|
1687
|
|
- size_t len ) {
|
1688
|
|
- const struct in_addr *ipv4 = raw;
|
1689
|
|
-
|
1690
|
|
- if ( raw_len < sizeof ( *ipv4 ) )
|
1691
|
|
- return -EINVAL;
|
1692
|
|
- return snprintf ( buf, len, "%s", inet_ntoa ( *ipv4 ) );
|
|
1677
|
+__weak int format_ipv4_setting ( const struct setting_type *type __unused,
|
|
1678
|
+ const void *raw __unused,
|
|
1679
|
+ size_t raw_len __unused, char *buf __unused,
|
|
1680
|
+ size_t len __unused ) {
|
|
1681
|
+ return -ENOTSUP;
|
1693
|
1682
|
}
|
1694
|
1683
|
|
1695
|
1684
|
/** An IPv4 address setting type */
|
|
@@ -1699,6 +1688,48 @@ const struct setting_type setting_type_ipv4 __setting_type = {
|
1699
|
1688
|
.format = format_ipv4_setting,
|
1700
|
1689
|
};
|
1701
|
1690
|
|
|
1691
|
+/**
|
|
1692
|
+ * Parse IPv6 address setting value (when IPv6 support is not present)
|
|
1693
|
+ *
|
|
1694
|
+ * @v type Setting type
|
|
1695
|
+ * @v value Formatted setting value
|
|
1696
|
+ * @v buf Buffer to contain raw value
|
|
1697
|
+ * @v len Length of buffer
|
|
1698
|
+ * @ret len Length of raw value, or negative error
|
|
1699
|
+ */
|
|
1700
|
+__weak int parse_ipv6_setting ( const struct setting_type *type __unused,
|
|
1701
|
+ const char *value __unused, void *buf __unused,
|
|
1702
|
+ size_t len __unused ) {
|
|
1703
|
+ return -ENOTSUP;
|
|
1704
|
+}
|
|
1705
|
+
|
|
1706
|
+/**
|
|
1707
|
+ * Format IPv6 address setting value (when IPv6 support is not present)
|
|
1708
|
+ *
|
|
1709
|
+ * @v type Setting type
|
|
1710
|
+ * @v raw Raw setting value
|
|
1711
|
+ * @v raw_len Length of raw setting value
|
|
1712
|
+ * @v buf Buffer to contain formatted value
|
|
1713
|
+ * @v len Length of buffer
|
|
1714
|
+ * @ret len Length of formatted value, or negative error
|
|
1715
|
+ */
|
|
1716
|
+__weak int format_ipv6_setting ( const struct setting_type *type __unused,
|
|
1717
|
+ const void *raw __unused,
|
|
1718
|
+ size_t raw_len __unused, char *buf __unused,
|
|
1719
|
+ size_t len __unused ) {
|
|
1720
|
+ return -ENOTSUP;
|
|
1721
|
+}
|
|
1722
|
+
|
|
1723
|
+/** An IPv6 address setting type */
|
|
1724
|
+const struct setting_type setting_type_ipv6 __setting_type = {
|
|
1725
|
+ .name = "ipv6",
|
|
1726
|
+ .parse = parse_ipv6_setting,
|
|
1727
|
+ .format = format_ipv6_setting,
|
|
1728
|
+};
|
|
1729
|
+
|
|
1730
|
+/** IPv6 settings scope */
|
|
1731
|
+const struct settings_scope ipv6_scope;
|
|
1732
|
+
|
1702
|
1733
|
/**
|
1703
|
1734
|
* Integer setting type indices
|
1704
|
1735
|
*
|