summaryrefslogtreecommitdiff
path: root/src/tc-socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tc-socket.c')
-rw-r--r--src/tc-socket.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/tc-socket.c b/src/tc-socket.c
index 9904ba8..3cdeb90 100644
--- a/src/tc-socket.c
+++ b/src/tc-socket.c
@@ -12,12 +12,30 @@
#ifndef AI_V4MAPPED
# define AI_V4MAPPED 0
#endif
+#include "internal.h"
-int main(void)
+static int t_parse(void)
+{
+ char host[32] = "bogus";
+ if (HX_addrport_split("[::1]", host, sizeof(host), nullptr) != 1 ||
+ strcmp(host, "::1") != 0)
+ return 1;
+ if (HX_addrport_split("[]", host, sizeof(host), nullptr) != 1 ||
+ strcmp(host, "") != 0)
+ return 1;
+ if (HX_addrport_split("", host, sizeof(host), nullptr) != 1 ||
+ strcmp(host, "") != 0)
+ return 1;
+ return 0;
+}
+
+static int t_local(void)
{
static const char *addrs[] = {
"::1", "::2", "::ffff:127.0.0.1", "::",
+ "[::1]", "[::2]", "[::ffff:127.0.0.1]", "[::]",
"127.0.0.1", "127.0.0.2", "1.1.1.1", "255.255.255.255",
+ "[127.0.0.1]", "[127.0.0.2]", "[1.1.1.1]", "[255.255.255.255]",
};
for (size_t i = 0; i < ARRAY_SIZE(addrs); ++i) {
char host[32] = {};
@@ -73,3 +91,14 @@ int main(void)
}
return EXIT_SUCCESS;
}
+
+int main(void)
+{
+ int ret = t_parse();
+ if (ret != 0)
+ return ret;
+ ret = t_local();
+ if (ret != EXIT_SUCCESS)
+ return ret;
+ return EXIT_SUCCESS;
+}