summaryrefslogtreecommitdiff
path: root/src/rdisc/nm-rdisc.h
blob: 2d83f0f0201bfebd8b6ab507cba18a88c9c2c167 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* nm-rdisc.h - Perform IPv6 router discovery
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright (C) 2013 Red Hat, Inc.
 */

#ifndef __NETWORKMANAGER_RDISC_H__
#define __NETWORKMANAGER_RDISC_H__

#include <glib-object.h>

#include <stdlib.h>
#include <netinet/in.h>

#include "NetworkManagerUtils.h"

#define NM_TYPE_RDISC            (nm_rdisc_get_type ())
#define NM_RDISC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_RDISC, NMRDisc))
#define NM_RDISC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_RDISC, NMRDiscClass))
#define NM_IS_RDISC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_RDISC))
#define NM_IS_RDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_RDISC))
#define NM_RDISC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_RDISC, NMRDiscClass))

#define NM_RDISC_CONFIG_CHANGED "config-changed"
#define NM_RDISC_RA_TIMEOUT     "ra-timeout"

typedef enum {
	NM_RDISC_DHCP_LEVEL_UNKNOWN,
	NM_RDISC_DHCP_LEVEL_NONE,
	NM_RDISC_DHCP_LEVEL_OTHERCONF,
	NM_RDISC_DHCP_LEVEL_MANAGED
} NMRDiscDHCPLevel;

typedef enum {
	NM_RDISC_PREFERENCE_INVALID,
	NM_RDISC_PREFERENCE_LOW,
	NM_RDISC_PREFERENCE_MEDIUM,
	NM_RDISC_PREFERENCE_HIGH
} NMRDiscPreference;

typedef struct {
	struct in6_addr address;
	guint32 timestamp;
	guint32 lifetime;
	NMRDiscPreference preference;
} NMRDiscGateway;

typedef struct {
	struct in6_addr address;
	guint32 timestamp;
	guint32 lifetime;
	guint32 preferred;
} NMRDiscAddress;

typedef struct {
	struct in6_addr network;
	int plen;
	struct in6_addr gateway;
	guint32 timestamp;
	guint32 lifetime;
	NMRDiscPreference preference;
} NMRDiscRoute;

typedef struct {
	struct in6_addr address;
	guint32 timestamp;
	guint32 lifetime;
} NMRDiscDNSServer;

typedef struct {
	char *domain;
	guint32 timestamp;
	guint32 lifetime;
} NMRDiscDNSDomain;

typedef enum {
	NM_RDISC_CONFIG_DHCP_LEVEL                          = 1 << 0,
	NM_RDISC_CONFIG_GATEWAYS                            = 1 << 1,
	NM_RDISC_CONFIG_ADDRESSES                           = 1 << 2,
	NM_RDISC_CONFIG_ROUTES                              = 1 << 3,
	NM_RDISC_CONFIG_DNS_SERVERS                         = 1 << 4,
	NM_RDISC_CONFIG_DNS_DOMAINS                         = 1 << 5,
	NM_RDISC_CONFIG_HOP_LIMIT                           = 1 << 6,
	NM_RDISC_CONFIG_MTU                                 = 1 << 7,
} NMRDiscConfigMap;

#define NM_RDISC_MAX_ADDRESSES_DEFAULT 16
#define NM_RDISC_RTR_SOLICITATIONS_DEFAULT 3
#define NM_RDISC_RTR_SOLICITATION_INTERVAL_DEFAULT 4

/**
 * NMRDisc:
 * @ifindex: Interface index
 *
 * Interface-specific structure that handles incoming router advertisements,
 * caches advertised items and removes them when they are obsolete.
 */
typedef struct {
	GObject parent;

	int ifindex;
	char *ifname;
	NMUtilsIPv6IfaceId iid;
	gint32 max_addresses;
	gint32 rtr_solicitations;
	gint32 rtr_solicitation_interval;

	NMRDiscDHCPLevel dhcp_level;
	GArray *gateways;
	GArray *addresses;
	GArray *routes;
	GArray *dns_servers;
	GArray *dns_domains;
	int hop_limit;
	guint32 mtu;
} NMRDisc;

typedef struct {
	GObjectClass parent;

	void (*start) (NMRDisc *rdisc);
	void (*config_changed) (NMRDisc *rdisc, NMRDiscConfigMap changed);
	void (*ra_timeout) (NMRDisc *rdisc);
} NMRDiscClass;

GType nm_rdisc_get_type (void);

void nm_rdisc_set_iid (NMRDisc *rdisc, const NMUtilsIPv6IfaceId iid);
void nm_rdisc_start (NMRDisc *rdisc);

#endif /* __NETWORKMANAGER_RDISC_H__ */