mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
tests: updated ipv6-prefix check for new internal functions
This commit is contained in:
@@ -18,75 +18,90 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "../src/common.h"
|
||||
|
||||
static char* my_ipv6_prefix_to_mask(const char *str, unsigned prefix)
|
||||
{
|
||||
struct in6_addr in;
|
||||
static char out[64];
|
||||
|
||||
if (ipv6_prefix_to_mask(&in, prefix) == 0)
|
||||
return NULL;
|
||||
|
||||
if (inet_ntop(AF_INET6, &in, out, sizeof(out)) == NULL)
|
||||
return NULL;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char *p;
|
||||
char str[MAX_IP_STR];
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 128);
|
||||
p = my_ipv6_prefix_to_mask(str, 128);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 127);
|
||||
p = my_ipv6_prefix_to_mask(str, 127);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 97);
|
||||
p = my_ipv6_prefix_to_mask(str, 97);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:ffff:ffff:8000:0") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 96);
|
||||
p = my_ipv6_prefix_to_mask(str, 96);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:ffff:ffff::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 95);
|
||||
p = my_ipv6_prefix_to_mask(str, 95);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:ffff:fffe::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 67);
|
||||
p = my_ipv6_prefix_to_mask(str, 67);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff:e000::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 64);
|
||||
p = my_ipv6_prefix_to_mask(str, 64);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffff::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 59);
|
||||
p = my_ipv6_prefix_to_mask(str, 59);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff:ffe0::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 48);
|
||||
p = my_ipv6_prefix_to_mask(str, 48);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff:ffff::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 32);
|
||||
p = my_ipv6_prefix_to_mask(str, 32);
|
||||
if (p == NULL || strcmp(p, "ffff:ffff::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = ipv6_prefix_to_mask(str, 12);
|
||||
p = my_ipv6_prefix_to_mask(str, 12);
|
||||
if (p == NULL || strcmp(p, "fff0::") != 0) {
|
||||
fprintf(stderr, "error in %d: %s\n", __LINE__, p);
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user