device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / 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 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
26 #error "Only <NetworkManager.h> can be included directly."
27 #endif
28
29 #include "nm-setting.h"
30 #include <linux/if_vlan.h>
31
32 G_BEGIN_DECLS
33
34 #define NM_TYPE_SETTING_VLAN            (nm_setting_vlan_get_type ())
35 #define NM_SETTING_VLAN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlan))
36 #define NM_SETTING_VLAN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_VLANCONFIG, NMSettingVlanClass))
37 #define NM_IS_SETTING_VLAN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_VLAN))
38 #define NM_IS_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_VLAN))
39 #define NM_SETTING_VLAN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_VLAN, NMSettingVlanClass))
40
41 #define NM_SETTING_VLAN_SETTING_NAME "vlan"
42
43 #define NM_SETTING_VLAN_PARENT               "parent"
44 #define NM_SETTING_VLAN_ID                   "id"
45 #define NM_SETTING_VLAN_FLAGS                "flags"
46 #define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map"
47 #define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP  "egress-priority-map"
48
49 struct _NMSettingVlan {
50         NMSetting parent;
51 };
52
53 typedef struct {
54         NMSettingClass parent;
55
56         /*< private >*/
57         gpointer padding[4];
58 } NMSettingVlanClass;
59
60 /**
61  * NMVlanPriorityMap:
62  * @NM_VLAN_INGRESS_MAP: map for incoming data
63  * @NM_VLAN_EGRESS_MAP: map for outgoing data
64  *
65  * A selector for traffic priority maps; these map Linux SKB priorities
66  * to 802.1p priorities used in VLANs.
67  **/
68 typedef enum {
69         NM_VLAN_INGRESS_MAP,
70         NM_VLAN_EGRESS_MAP
71 } NMVlanPriorityMap;
72
73 /**
74  * NMVlanFlags:
75  * @NM_VLAN_FLAG_REORDER_HEADERS: indicates that this interface should reorder
76  *  outgoing packet headers to look more like a non-VLAN Ethernet interface
77  * @NM_VLAN_FLAG_GVRP: indicates that this interface should use GVRP to register
78  *  itself with it's switch
79  * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
80  *  state is tied to the underlying network interface but other details
81  *  (like routing) are not.
82  * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
83  *  itself with it's switch
84  *
85  * #NMVlanFlags values control the behavior of the VLAN interface.
86  **/
87 typedef enum { /*< flags >*/
88         NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
89         NM_VLAN_FLAG_GVRP            = 0x2,
90         NM_VLAN_FLAG_LOOSE_BINDING   = 0x4,
91         NM_VLAN_FLAG_MVRP            = 0x8,
92
93         /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
94
95         /* NOTE: these flags must correspond to the value from the kernel
96          * header files. */
97 } NMVlanFlags;
98
99 #define NM_VLAN_FLAGS_ALL  (NM_VLAN_FLAG_REORDER_HEADERS | \
100                             NM_VLAN_FLAG_GVRP | \
101                             NM_VLAN_FLAG_LOOSE_BINDING | \
102                             NM_VLAN_FLAG_MVRP)
103
104 GType nm_setting_vlan_get_type (void);
105 NMSetting *nm_setting_vlan_new (void);
106
107 const char *nm_setting_vlan_get_parent         (NMSettingVlan *setting);
108 guint32     nm_setting_vlan_get_id             (NMSettingVlan *setting);
109 guint32     nm_setting_vlan_get_flags          (NMSettingVlan *setting);
110
111 gint32   nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map);
112
113 gboolean nm_setting_vlan_get_priority       (NMSettingVlan *setting,
114                                              NMVlanPriorityMap map,
115                                              guint32 idx,
116                                              guint32 *out_from,
117                                              guint32 *out_to);
118
119 gboolean nm_setting_vlan_add_priority       (NMSettingVlan *setting,
120                                              NMVlanPriorityMap map,
121                                              guint32 from,
122                                              guint32 to);
123
124 void     nm_setting_vlan_remove_priority    (NMSettingVlan *setting,
125                                              NMVlanPriorityMap map,
126                                              guint32 idx);
127
128 gboolean nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
129                                                    NMVlanPriorityMap map,
130                                                    guint32 from,
131                                                    guint32 to);
132
133 gboolean nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
134                                                        NMVlanPriorityMap map,
135                                                        const char *str);
136
137 void     nm_setting_vlan_clear_priorities   (NMSettingVlan *setting, NMVlanPriorityMap map);
138
139 gboolean nm_setting_vlan_add_priority_str   (NMSettingVlan *setting,
140                                              NMVlanPriorityMap map,
141                                              const char *str);
142
143 G_END_DECLS
144
145 #endif /* __NM_SETTING_VLAN_H__ */