device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-util / nm-setting-vlan.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2011 - 2014 Red Hat, Inc.
20  */
21
22 #ifndef NM_SETTING_VLAN_H
23 #define NM_SETTING_VLAN_H
24
25 #include "nm-setting.h"
26 #include <linux/if_vlan.h>
27
28 G_BEGIN_DECLS
29
30 #define NM_TYPE_SETTING_VLAN            (nm_setting_vlan_get_type ())
31 #define NM_SETTING_VLAN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlan))
32 #define NM_SETTING_VLAN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_VLANCONFIG, NMSettingVlanClass))
33 #define NM_IS_SETTING_VLAN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_VLAN))
34 #define NM_IS_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_VLAN))
35 #define NM_SETTING_VLAN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlanClass))
36
37 #define NM_SETTING_VLAN_SETTING_NAME "vlan"
38
39 /**
40  * NMSettingVlanError:
41  * @NM_SETTING_VLAN_ERROR_UNKNOWN: unknown or unclassified error
42  * @NM_SETTING_VLAN_ERROR_INVALID_PROPERTY: the property was invalid
43  * @NM_SETTING_VLAN_ERROR_MISSING_PROPERTY: the property was missing and is
44  *   required
45  * @NM_SETTING_VLAN_ERROR_INVALID_PARENT: the VLAN parent was specified
46  *   inconsistently
47  */
48 typedef enum {
49         NM_SETTING_VLAN_ERROR_UNKNOWN = 0,      /*< nick=Unknown >*/
50         NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
51         NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
52         NM_SETTING_VLAN_ERROR_INVALID_PARENT    /*< nick=InvalidParent >*/
53 } NMSettingVlanError;
54
55 #define NM_SETTING_VLAN_ERROR nm_setting_vlan_error_quark ()
56 GQuark nm_setting_vlan_error_quark (void);
57
58 #define NM_SETTING_VLAN_INTERFACE_NAME       "interface-name"
59 #define NM_SETTING_VLAN_PARENT               "parent"
60 #define NM_SETTING_VLAN_ID                   "id"
61 #define NM_SETTING_VLAN_FLAGS                "flags"
62 #define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map"
63 #define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP  "egress-priority-map"
64
65 typedef struct {
66         NMSetting parent;
67 } NMSettingVlan;
68
69 typedef struct {
70         NMSettingClass parent;
71
72         /* Padding for future expansion */
73         void (*_reserved1) (void);
74         void (*_reserved2) (void);
75         void (*_reserved3) (void);
76         void (*_reserved4) (void);
77 } NMSettingVlanClass;
78
79 /**
80  * NMVlanPriorityMap:
81  * @NM_VLAN_INGRESS_MAP: map for incoming data
82  * @NM_VLAN_EGRESS_MAP: map for outgoing data
83  *
84  * A selector for traffic priority maps; these map Linux SKB priorities
85  * to 802.1p priorities used in VLANs.
86  **/
87 typedef enum {
88         NM_VLAN_INGRESS_MAP,
89         NM_VLAN_EGRESS_MAP
90 } NMVlanPriorityMap;
91
92 /**
93  * NMVlanFlags:
94  * @NM_VLAN_FLAG_REORDER_HEADERS: indicates that this interface should reorder
95  *  outgoing packet headers to look more like a non-VLAN Ethernet interface
96  * @NM_VLAN_FLAG_GVRP: indicates that this interface should use GVRP to register
97  *  itself with it's switch
98  * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
99  *  state is tied to the underlying network interface but other details
100  *  (like routing) are not.
101  * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
102  *  itself with it's switch
103  *
104  * #NMVlanFlags values control the behavior of the VLAN interface.
105  **/
106 typedef enum {
107         NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
108         NM_VLAN_FLAG_GVRP            = 0x2,
109         NM_VLAN_FLAG_LOOSE_BINDING   = 0x4,
110         NM_VLAN_FLAG_MVRP            = 0x8,
111
112         /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
113 } NMVlanFlags;
114
115 #define NM_VLAN_FLAGS_ALL  (NM_VLAN_FLAG_REORDER_HEADERS | \
116                             NM_VLAN_FLAG_GVRP | \
117                             NM_VLAN_FLAG_LOOSE_BINDING | \
118                             NM_VLAN_FLAG_MVRP)
119
120 GType nm_setting_vlan_get_type (void);
121 NMSetting *nm_setting_vlan_new (void);
122
123 const char *nm_setting_vlan_get_interface_name (NMSettingVlan *setting);
124 const char *nm_setting_vlan_get_parent         (NMSettingVlan *setting);
125 guint32     nm_setting_vlan_get_id             (NMSettingVlan *setting);
126 guint32     nm_setting_vlan_get_flags          (NMSettingVlan *setting);
127
128 gint32   nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map);
129
130 gboolean nm_setting_vlan_get_priority       (NMSettingVlan *setting,
131                                              NMVlanPriorityMap map,
132                                              guint32 idx,
133                                              guint32 *out_from,
134                                              guint32 *out_to);
135
136 gboolean nm_setting_vlan_add_priority       (NMSettingVlan *setting,
137                                              NMVlanPriorityMap map,
138                                              guint32 from,
139                                              guint32 to);
140
141 void     nm_setting_vlan_remove_priority    (NMSettingVlan *setting,
142                                              NMVlanPriorityMap map,
143                                              guint32 idx);
144
145 NM_AVAILABLE_IN_0_9_10
146 gboolean nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
147                                                    NMVlanPriorityMap map,
148                                                    guint32 from,
149                                                    guint32 to);
150
151 NM_AVAILABLE_IN_0_9_10
152 gboolean nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
153                                                        NMVlanPriorityMap map,
154                                                        const char *str);
155
156 void     nm_setting_vlan_clear_priorities   (NMSettingVlan *setting, NMVlanPriorityMap map);
157
158 gboolean nm_setting_vlan_add_priority_str   (NMSettingVlan *setting,
159                                              NMVlanPriorityMap map,
160                                              const char *str);
161
162 G_END_DECLS
163
164 #endif /* NM_SETTING_VLAN_H */