[PATCH 3/4] sockettest: Check for IPv4-in-IPv6 parsing and formatting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are two standards how IPv4 address in IPv6 can be
expressed:

  ::10.1.2.3
  ::ffff:10.1.2.3

The former is obsolete and the latter should be used instead [1].
Add test cases to our sockettest to exercise parsing/formatting
of the valid address format.

1: https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.1

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/sockettest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/sockettest.c b/tests/sockettest.c
index 332def2c93..2a35b6a829 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -371,12 +371,14 @@ mymain(void)
     DO_TEST_PARSE_AND_CHECK_FORMAT("127.2", "127.2.0.0", AF_INET, false);
     DO_TEST_PARSE_AND_CHECK_FORMAT("1.2.3", "1.2.0.3", AF_INET, true);
     DO_TEST_PARSE_AND_CHECK_FORMAT("1.2.3", "1.2.3.0", AF_INET, false);
+    DO_TEST_PARSE_AND_CHECK_FORMAT("::ffff:a01:203", "::ffff:10.1.2.3", AF_INET6, true);
 
     DO_TEST_PARSE_AND_FORMAT("::1", AF_UNSPEC, true);
     DO_TEST_PARSE_AND_FORMAT("::1", AF_INET, false);
     DO_TEST_PARSE_AND_FORMAT("::1", AF_INET6, true);
     DO_TEST_PARSE_AND_FORMAT("::1", AF_UNIX, false);
     DO_TEST_PARSE_AND_FORMAT("::fffe:0:0", AF_UNSPEC, true);
+    DO_TEST_PARSE_AND_FORMAT("::ffff:10.1.2.3", AF_UNSPEC, true);
 
     /* tests that specify a network that should contain the range */
     DO_TEST_RANGE("192.168.122.1", "192.168.122.1", "192.168.122.1", 24, 1, true);
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux