Statistics
| Branch: | Revision:

iof-bird-daemon / lib / ipv4.c @ 25697773

History | View | Annotate | Download (591 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
#ifndef IPV6
10

    
11
#include "nest/bird.h"
12
#include "lib/ip.h"
13

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

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

    
33
#endif