Commit 1c152a25 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Move checking for V4-mapped addresses to util.c.

parent c32f2f63
......@@ -24,15 +24,12 @@ THE SOFTWARE.
#include "util.h"
#include "filter.h"
static unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
int
import_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen,
const unsigned char *nexthop)
{
if(plen >= 96 && in_prefix(prefix, v4prefix, 96))
if(plen >= 96 && v4mapped(prefix))
return 1;
return 0;
......
......@@ -275,3 +275,12 @@ martian_prefix(const unsigned char *prefix, int plen)
(plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
(plen >= 128 && memcmp(prefix, zeroes, 16) == 0);
}
static unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
int
v4mapped(const unsigned char *address)
{
return in_prefix(address, v4prefix, 96);
}
......@@ -49,6 +49,7 @@ int parse_address(const char *address, unsigned char *addr_r);
int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r);
int wait_for_fd(int direction, int fd, int msecs);
int martian_prefix(const unsigned char *prefix, int plen);
int v4mapped(const unsigned char *address);
/* If debugging is disabled, we want to avoid calling format_address
for every omitted debugging message. So debug is a macro. But
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment