- It's 2001, all copyright notices are updated.
[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.9 2001/01/07 17:09:07 guus 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_IPV4,
32   SUBNET_IPV6,
33   SUBNET_TYPES                          /* Guardian */
34 };
35
36 typedef struct subnet_mac_t
37 {
38   mac_t address;
39 } subnet_mac_t;
40
41 typedef struct subnet_ipv4_t
42 {
43   ipv4_t address;
44   ipv4_t mask;
45 } subnet_ipv4_t;
46
47 typedef struct subnet_ipv6_t
48 {
49   ipv6_t address;
50   ipv6_t mask;
51 } subnet_ipv6_t;
52
53 typedef struct subnet_t {
54   struct connection_t *owner;           /* the owner of this subnet */
55   struct connection_t *uplink;          /* the uplink which we should send packets to for this subnet */
56
57   struct subnet_t *prev;                /* previous subnet_t for this owner */
58   struct subnet_t *next;                /* next subnet_t for this owner */
59
60   struct subnet_t *global_prev;         /* previous subnet_t for this subnet type */
61   struct subnet_t *global_next;         /* next subnet_t for this subnet type */
62
63   int type;                             /* subnet type (IPv4? IPv6? MAC? something even weirder?) */
64
65   /* And now for the actual subnet: */
66
67   union net
68     {
69       subnet_mac_t mac;
70       subnet_ipv4_t ipv4;
71       subnet_ipv6_t ipv6;
72     } net;
73     
74 } subnet_t;  
75
76 #include "connection.h"
77
78 extern subnet_t *new_subnet(void);
79 extern void free_subnet(subnet_t *);
80 extern void init_subnets(void);
81 extern void subnet_add(struct connection_t *, subnet_t *);
82 extern void subnet_del(subnet_t *);
83 extern char *net2str(subnet_t *);
84 extern subnet_t *str2net(char *);
85 extern int subnet_compare(subnet_t *, subnet_t *);
86 extern subnet_t *lookup_subnet_mac(mac_t *);
87 extern subnet_t *lookup_subnet_ipv4(ipv4_t *);
88 extern subnet_t *lookup_subnet_ipv6(ipv6_t *);
89 extern void dump_subnet_list(void);
90
91 #endif /* __TINC_SUBNET_H__ */