2 subnet.h -- subnet handling
4 Copyright (C) 2003-2004 Guus Sliepen <guus@tinc-vpn.org>,
5 2003-2004 Ivo Timmermans <ivo@tinc-vpn.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "support/avl.h"
42 typedef enum subnet_type {
48 typedef struct subnet_mac {
52 typedef struct subnet_ipv4 {
57 typedef struct subnet_ipv6 {
62 typedef struct subnet {
64 struct timeval expires;
66 enum subnet_type type;
69 struct subnet_mac mac;
70 struct subnet_ipv4 ipv4;
71 struct subnet_ipv6 ipv6;
75 extern subnet_t *subnet_new(void) __attribute__ ((__malloc__));
76 extern void subnet_free(struct subnet *);
77 extern bool subnet_init(void);
78 extern bool subnet_exit(void);
79 extern avl_tree_t *subnet_tree_new(void) __attribute__ ((__malloc__));
80 extern void subnet_tree_free(avl_tree_t *);
81 extern void subnet_add(struct subnet *);
82 extern void subnet_del(struct subnet *);
83 extern char *net2str(const struct subnet *);
84 extern struct subnet *str2net(const char *);
85 extern struct subnet *subnet_get(const struct subnet *);
86 extern struct subnet *subnet_get_mac(const struct mac *);
87 extern struct subnet *subnet_get_ipv4(const struct ipv4 *);
88 extern struct subnet *subnet_get_ipv6(const struct ipv6 *);