Don't include netutl.h.
[tinc] / src / subnet.h
1 /*
2     subnet.h -- header for subnet.c
3     Copyright (C) 2000,2001 Guus Sliepen <guus@sliepen.warande.net>,
4                   2000,2001 Ivo Timmermans <itimmermans@bigfoot.com>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20     $Id: subnet.h,v 1.1.2.14 2001/11/16 12:10:54 zarq Exp $
21 */
22
23 #ifndef __TINC_SUBNET_H__
24 #define __TINC_SUBNET_H__
25
26 #include "net.h"
27
28 enum
29 {
30   SUBNET_MAC = 0,
31   SUBNET_IP,
32   SUBNET_TYPES                          /* Guardian */
33 };
34
35 typedef struct subnet_mac_t
36 {
37   mac_t address;
38 } subnet_mac_t;
39
40 typedef struct subnet_ip_t
41 {
42   struct addrinfo *address;
43   struct addrinfo *mask;
44 } subnet_ip_t;
45
46 #include "node.h"
47
48 typedef struct subnet_t {
49   struct node_t *owner;                 /* the owner of this subnet */
50   struct node_t *uplink;                /* the uplink which we should send packets to for this subnet */
51
52   int type;                             /* subnet type (IPv4? IPv6? MAC? something even weirder?) */
53
54   /* And now for the actual subnet: */
55
56   union net
57     {
58       subnet_mac_t mac;
59       subnet_ip_t ip;
60     } net;
61     
62 } subnet_t;
63
64 extern subnet_t *new_subnet(void);
65 extern void free_subnet(subnet_t *);
66 extern void init_subnets(void);
67 extern void exit_subnets(void);
68 extern avl_tree_t *new_subnet_tree(void);
69 extern void free_subnet_tree(avl_tree_t *);
70 extern void subnet_add(struct node_t *, subnet_t *);
71 extern void subnet_del(struct node_t *, subnet_t *);
72 extern char *net2str(subnet_t *);
73 extern subnet_t *str2net(char *);
74 extern subnet_t *lookup_subnet(struct node_t *, subnet_t *);
75 extern subnet_t *lookup_subnet_mac(mac_t *);
76 extern subnet_t *lookup_subnet_ip(struct addrinfo *);
77 extern void dump_subnets(void);
78
79 #endif /* __TINC_SUBNET_H__ */