Commit bb33004f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Check for link-local addresses in a specific function.

parent 02e3db59
...@@ -58,8 +58,6 @@ struct timeval unicast_flush_timeout = {0, 0}; ...@@ -58,8 +58,6 @@ struct timeval unicast_flush_timeout = {0, 0};
static const unsigned char v4prefix[16] = static const unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
static const unsigned char ll_prefix[16] =
{0xFE, 0x80};
static int static int
network_prefix(int ae, int plen, unsigned int omitted, network_prefix(int ae, int plen, unsigned int omitted,
...@@ -176,7 +174,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -176,7 +174,7 @@ parse_packet(const unsigned char *from, struct network *net,
unsigned char router_id[8], v4_prefix[16], v6_prefix[16], unsigned char router_id[8], v4_prefix[16], v6_prefix[16],
v4_nh[16], v6_nh[16]; v4_nh[16], v6_nh[16];
if(!in_prefix(from, ll_prefix, 64)) { if(!linklocal(from)) {
fprintf(stderr, "Received packet from non-local address %s.\n", fprintf(stderr, "Received packet from non-local address %s.\n",
format_address(from)); format_address(from));
return; return;
...@@ -1227,7 +1225,7 @@ send_ihu(struct neighbour *neigh, struct network *net) ...@@ -1227,7 +1225,7 @@ send_ihu(struct neighbour *neigh, struct network *net)
neigh->network->ifname, neigh->network->ifname,
format_address(neigh->address)); format_address(neigh->address));
ll = in_prefix(neigh->address, ll_prefix, 64); ll = linklocal(neigh->address);
if(unicast_neighbour != neigh) { if(unicast_neighbour != neigh) {
start_message(net, MESSAGE_IHU, ll ? 14 : 22); start_message(net, MESSAGE_IHU, ll ? 14 : 22);
......
...@@ -220,6 +220,9 @@ mask_prefix(unsigned char *restrict ret, ...@@ -220,6 +220,9 @@ mask_prefix(unsigned char *restrict ret,
static const unsigned char v4prefix[16] = static const unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
static const unsigned char llprefix[16] =
{0xFE, 0x80};
const char * const char *
format_address(const unsigned char *address) format_address(const unsigned char *address)
{ {
...@@ -406,6 +409,12 @@ martian_prefix(const unsigned char *prefix, int plen) ...@@ -406,6 +409,12 @@ martian_prefix(const unsigned char *prefix, int plen)
(plen >= 100 && (prefix[12] & 0xE0) == 0xE0))); (plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
} }
int
linklocal(const unsigned char *address)
{
return memcmp(address, llprefix, 8) == 0;
}
int int
v4mapped(const unsigned char *address) v4mapped(const unsigned char *address)
{ {
......
...@@ -95,6 +95,7 @@ int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r, ...@@ -95,6 +95,7 @@ int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r,
int parse_eui64(const char *eui, unsigned char *eui_r); int parse_eui64(const char *eui, unsigned char *eui_r);
int wait_for_fd(int direction, int fd, int msecs); int wait_for_fd(int direction, int fd, int msecs);
int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure)); int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure));
int linklocal(const unsigned char *address) ATTRIBUTE ((pure));
int v4mapped(const unsigned char *address) ATTRIBUTE ((pure)); int v4mapped(const unsigned char *address) ATTRIBUTE ((pure));
void v4tov6(unsigned char *dst, const unsigned char *src); void v4tov6(unsigned char *dst, const unsigned char *src);
int daemonise(void); int daemonise(void);
......
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