Statistics
| Branch: | Revision:

iof-bird-daemon / lib / ipv4.c @ 18c8241a

History | View | Annotate | Download (569 Bytes)

1
/*
2
 *        BIRD Library -- IPv4 Address Manipulation Functions
3
 *
4
 *        (c) 1998 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#include "nest/bird.h"
10
#include "lib/ip.h"
11

    
12
int
13
ipv4_classify(u32 a)
14
{
15
  u32 b = a >> 24U;
16

    
17
  if (b && b <= 0xdf)
18
    {
19
      if (b == 0x7f)
20
        return IADDR_HOST | SCOPE_HOST;
21
      else
22
        return IADDR_HOST | SCOPE_UNIVERSE;
23
    }
24
  if (b >= 0xe0 && b <= 0xef)
25
    return IADDR_MULTICAST | SCOPE_UNIVERSE;
26
  if (a == 0xffffffff)
27
    return IADDR_BROADCAST | SCOPE_LINK;
28
  return IADDR_INVALID;
29
}