blob: e81c03c0da534ec20950b99e0d3aaa891adf7124 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* ipaddrcheck_functions.h: macros and prototypes for ipaddrcheck
*
* Maintainer: Daniil Baturin <daniil at baturin dot org>
*
* Copyright (C) 2013 SO3Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <pcre.h>
#include <libcidr.h>
#define INVALID_PROTO -1
#define RESULT_SUCCESS 1
#define RESULT_FAILURE 0
#define IPV4_MULTICAST "224.0.0.0/4"
#define IPV4_LOOPBACK "127.0.0.0/8"
#define IPV4_LINKLOCAL "169.254.0.0/16"
#define IPV4_RFC1918_A "10.0.0.0/8"
#define IPV4_RFC1918_B "172.16.0.0/12"
#define IPV4_RFC1918_C "192.168.0.0/16"
#define IPV6_MULTICAST "ff00::/8"
#define IPV6_LINKLOCAL "fe80::/64"
int has_mask(char* address_str);
int is_ipv4_cidr(char* address_str);
int is_ipv4_single(char* address_str);
int is_ipv6_cidr(char* address_str);
int is_ipv6_single(char* address_str);
int is_valid_address(CIDR *address);
int is_ipv4(CIDR *address);
int is_ipv4_host(CIDR *address);
int is_ipv4_net(CIDR *address);
int is_ipv4_broadcast(CIDR *address);
int is_ipv4_multicast(CIDR *address);
int is_ipv4_loopback(CIDR *address);
int is_ipv4_link_local(CIDR *address);
int is_ipv4_rfc1918(CIDR *address);
int is_ipv6(CIDR *address);
int is_ipv6_host(CIDR *address);
int is_ipv6_net(CIDR *address);
int is_ipv6_multicast(CIDR *address);
int is_ipv6_link_local(CIDR *address);
|