device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / nm-setting-connection.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 2007 - 2014 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #ifndef __NM_SETTING_CONNECTION_H__
24 #define __NM_SETTING_CONNECTION_H__
25
26 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
27 #error "Only <NetworkManager.h> can be included directly."
28 #endif
29
30 #include "nm-setting.h"
31
32 G_BEGIN_DECLS
33
34 #define NM_TYPE_SETTING_CONNECTION            (nm_setting_connection_get_type ())
35 #define NM_SETTING_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_CONNECTION, NMSettingConnection))
36 #define NM_SETTING_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionClass))
37 #define NM_IS_SETTING_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_CONNECTION))
38 #define NM_IS_SETTING_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_CONNECTION))
39 #define NM_SETTING_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionClass))
40
41 #define NM_SETTING_CONNECTION_SETTING_NAME "connection"
42
43 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN -999
44 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX 999
45 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT 0
46
47 #define NM_SETTING_CONNECTION_ID             "id"
48 #define NM_SETTING_CONNECTION_UUID           "uuid"
49 #define NM_SETTING_CONNECTION_INTERFACE_NAME "interface-name"
50 #define NM_SETTING_CONNECTION_TYPE           "type"
51 #define NM_SETTING_CONNECTION_AUTOCONNECT    "autoconnect"
52 #define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY "autoconnect-priority"
53 #define NM_SETTING_CONNECTION_TIMESTAMP      "timestamp"
54 #define NM_SETTING_CONNECTION_READ_ONLY      "read-only"
55 #define NM_SETTING_CONNECTION_PERMISSIONS    "permissions"
56 #define NM_SETTING_CONNECTION_ZONE           "zone"
57 #define NM_SETTING_CONNECTION_MASTER         "master"
58 #define NM_SETTING_CONNECTION_SLAVE_TYPE     "slave-type"
59 #define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves"
60 #define NM_SETTING_CONNECTION_SECONDARIES    "secondaries"
61 #define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout"
62 #define NM_SETTING_CONNECTION_METERED        "metered"
63 #define NM_SETTING_CONNECTION_LLDP           "lldp"
64
65 /* Types for property values */
66 /**
67  * NMSettingConnectionAutoconnectSlaves:
68  * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: default value
69  * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO: slaves are not brought up when
70  *   master is activated
71  * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES: slaves are brought up when
72  *   master is activated
73  *
74  * #NMSettingConnectionAutoconnectSlaves values indicate whether slave connections
75  * should be activated when master is activated.
76  */
77 typedef enum {
78         NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT = -1,
79         NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO = 0,
80         NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES = 1,
81 } NMSettingConnectionAutoconnectSlaves;
82
83 /**
84  * NMSettingConnectionLldp:
85  * @NM_SETTING_CONNECTION_LLDP_DEFAULT: default value
86  * @NM_SETTING_CONNECTION_LLDP_DISABLE: disable LLDP
87  * @NM_SETTING_CONNECTION_LLDP_ENABLE_RX: enable reception of LLDP frames
88  *
89  * #NMSettingConnectionLldp values indicate whether LLDP should be enabled.
90  */
91 typedef enum {
92         NM_SETTING_CONNECTION_LLDP_DEFAULT = -1,
93         NM_SETTING_CONNECTION_LLDP_DISABLE = 0,
94         NM_SETTING_CONNECTION_LLDP_ENABLE_RX = 1,
95 } NMSettingConnectionLldp;
96
97 /**
98  * NMSettingConnection:
99  *
100  * The NMSettingConnection struct contains only private data.
101  * It should only be accessed through the functions described below.
102  */
103 struct _NMSettingConnection {
104         NMSetting parent;
105 };
106
107 typedef struct {
108         NMSettingClass parent;
109
110         /*< private >*/
111         gpointer padding[4];
112 } NMSettingConnectionClass;
113
114 GType nm_setting_connection_get_type (void);
115
116 NMSetting * nm_setting_connection_new                  (void);
117 const char *nm_setting_connection_get_id               (NMSettingConnection *setting);
118 const char *nm_setting_connection_get_uuid             (NMSettingConnection *setting);
119 const char *nm_setting_connection_get_interface_name   (NMSettingConnection *setting);
120 const char *nm_setting_connection_get_connection_type  (NMSettingConnection *setting);
121 gboolean    nm_setting_connection_get_autoconnect      (NMSettingConnection *setting);
122 gint        nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting);
123 guint64     nm_setting_connection_get_timestamp        (NMSettingConnection *setting);
124 gboolean    nm_setting_connection_get_read_only        (NMSettingConnection *setting);
125
126 guint32     nm_setting_connection_get_num_permissions  (NMSettingConnection *setting);
127 gboolean    nm_setting_connection_get_permission       (NMSettingConnection *setting,
128                                                         guint32 idx,
129                                                         const char **out_ptype,
130                                                         const char **out_pitem,
131                                                         const char **out_detail);
132 const char *nm_setting_connection_get_zone             (NMSettingConnection *setting);
133 gboolean    nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting, const char *uname);
134 gboolean    nm_setting_connection_add_permission       (NMSettingConnection *setting,
135                                                         const char *ptype,
136                                                         const char *pitem,
137                                                         const char *detail);
138 void        nm_setting_connection_remove_permission    (NMSettingConnection *setting,
139                                                         guint32 idx);
140 gboolean    nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
141                                                               const char *ptype,
142                                                               const char *pitem,
143                                                               const char *detail);
144
145 const char *nm_setting_connection_get_master           (NMSettingConnection *setting);
146 gboolean    nm_setting_connection_is_slave_type        (NMSettingConnection *setting,
147                                                         const char *type);
148 const char *nm_setting_connection_get_slave_type       (NMSettingConnection *setting);
149 NM_AVAILABLE_IN_1_2
150 NMSettingConnectionAutoconnectSlaves nm_setting_connection_get_autoconnect_slaves (NMSettingConnection *setting);
151
152 guint32     nm_setting_connection_get_num_secondaries  (NMSettingConnection *setting);
153 const char *nm_setting_connection_get_secondary        (NMSettingConnection *setting, guint32 idx);
154 gboolean    nm_setting_connection_add_secondary        (NMSettingConnection *setting, const char *sec_uuid);
155 void        nm_setting_connection_remove_secondary     (NMSettingConnection *setting, guint32 idx);
156 gboolean    nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting, const char *sec_uuid);
157
158 guint32     nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting);
159 NM_AVAILABLE_IN_1_2
160 NMMetered   nm_setting_connection_get_metered (NMSettingConnection *setting);
161 NM_AVAILABLE_IN_1_2
162 NMSettingConnectionLldp nm_setting_connection_get_lldp (NMSettingConnection *setting);
163
164 G_END_DECLS
165
166 #endif /* __NM_SETTING_CONNECTION_H__ */