Refactored packet API to support struct layer (using union to contain different types of encapsulation headers)

This commit is contained in:
luwenpeng
2024-06-14 19:24:27 +08:00
parent 1f78881cbb
commit de4c15f43c
47 changed files with 834 additions and 701 deletions

View File

@@ -58,21 +58,21 @@ static int parse_cmd(int argc, char **argv)
if (host)
{
if (inet_pton(AF_INET, host, &rule.addr.data.v4) != 1)
if (inet_pton(AF_INET, host, &rule.addr4) != 1)
{
if (inet_pton(AF_INET6, host, &rule.addr.data.v6) != 1)
if (inet_pton(AF_INET6, host, &rule.addr6) != 1)
{
printf("unable to convert host %s to IPv4 / IPv6\n", host);
return -1;
}
else
{
rule.addr.family = AF_INET6;
rule.family = AF_INET6;
}
}
else
{
rule.addr.family = AF_INET;
rule.family = AF_INET;
}
}