Copy cygwin driver to mingw directory. It doesn't work (yet).
[tinc] / src / subnet.h
1 /*
2     subnet.h -- header for subnet.c
3     Copyright (C) 2000,2001 Guus Sliepen <guus@sliepen.eu.org>,
4                   2000,2001 Ivo Timmermans <ivo@o2w.nl>
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.21 2003/07/06 23:16:29 guus Exp $
21 */
22
23 #ifndef __TINC_SUBNET_H__
24 #define __TINC_SUBNET_H__
25
26 #include "net.h"
27
28 enum {
29         SUBNET_MAC = 0,
30         SUBNET_IPV4,
31         SUBNET_IPV6,
32         SUBNET_TYPES                            /* Guardian */
33 };
34
35 typedef struct subnet_mac_t {
36         mac_t address;
37         time_t lastseen;
38 } subnet_mac_t;
39
40 typedef struct subnet_ipv4_t {
41         ipv4_t address;
42         int prefixlength;
43 } subnet_ipv4_t;
44
45 typedef struct subnet_ipv6_t {
46         ipv6_t address;
47         int prefixlength;
48 } subnet_ipv6_t;
49
50 #include "node.h"
51
52 typedef struct subnet_t {
53         struct node_t *owner;           /* the owner of this subnet */
54         struct node_t *uplink;          /* the uplink which we should send packets to for this subnet */
55
56         int type;                                       /* subnet type (IPv4? IPv6? MAC? something even weirder?) */
57
58         /* And now for the actual subnet: */
59
60         union net {
61                 subnet_mac_t mac;
62                 subnet_ipv4_t ipv4;
63                 subnet_ipv6_t ipv6;
64         } net;
65 } subnet_t;
66
67 extern subnet_t *new_subnet(void) __attribute__ ((malloc));
68 extern void free_subnet(subnet_t *);
69 extern void init_subnets(void);
70 extern void exit_subnets(void);
71 extern avl_tree_t *new_subnet_tree(void) __attribute__ ((malloc));
72 extern void free_subnet_tree(avl_tree_t *);
73 extern void subnet_add(struct node_t *, subnet_t *);
74 extern void subnet_del(struct node_t *, subnet_t *);
75 extern char *net2str(subnet_t *);
76 extern subnet_t *str2net(char *);
77 extern subnet_t *lookup_subnet(struct node_t *, subnet_t *);
78 extern subnet_t *lookup_subnet_mac(mac_t *);
79 extern subnet_t *lookup_subnet_ipv4(ipv4_t *);
80 extern subnet_t *lookup_subnet_ipv6(ipv6_t *);
81 extern void dump_subnets(void);
82
83 #endif                                                  /* __TINC_SUBNET_H__ */