device: renew dhcp leases on awake for software devices
[NetworkManager.git] / src / nm-auth-utils.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* NetworkManager -- Network link manager
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Copyright (C) 2010 Red Hat, Inc.
19  */
20
21 #ifndef __NETWORKMANAGER_MANAGER_AUTH_H__
22 #define __NETWORKMANAGER_MANAGER_AUTH_H__
23
24 #include <nm-connection.h>
25 #include "nm-default.h"
26
27 #define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK     "org.freedesktop.NetworkManager.enable-disable-network"
28 #define NM_AUTH_PERMISSION_SLEEP_WAKE                 "org.freedesktop.NetworkManager.sleep-wake"
29 #define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI        "org.freedesktop.NetworkManager.enable-disable-wifi"
30 #define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN        "org.freedesktop.NetworkManager.enable-disable-wwan"
31 #define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX       "org.freedesktop.NetworkManager.enable-disable-wimax"
32 #define NM_AUTH_PERMISSION_NETWORK_CONTROL            "org.freedesktop.NetworkManager.network-control"
33 #define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED       "org.freedesktop.NetworkManager.wifi.share.protected"
34 #define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN            "org.freedesktop.NetworkManager.wifi.share.open"
35 #define NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM     "org.freedesktop.NetworkManager.settings.modify.system"
36 #define NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN        "org.freedesktop.NetworkManager.settings.modify.own"
37 #define NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME   "org.freedesktop.NetworkManager.settings.modify.hostname"
38 #define NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS "org.freedesktop.NetworkManager.settings.modify.global-dns"
39
40
41 typedef struct NMAuthChain NMAuthChain;
42
43 typedef enum {
44         NM_AUTH_CALL_RESULT_UNKNOWN,
45         NM_AUTH_CALL_RESULT_YES,
46         NM_AUTH_CALL_RESULT_AUTH,
47         NM_AUTH_CALL_RESULT_NO,
48 } NMAuthCallResult;
49
50 typedef void (*NMAuthChainResultFunc) (NMAuthChain *chain,
51                                        GError *error,
52                                        GDBusMethodInvocation *context,
53                                        gpointer user_data);
54
55 NMAuthChain *nm_auth_chain_new_context (GDBusMethodInvocation *context,
56                                         NMAuthChainResultFunc done_func,
57                                         gpointer user_data);
58
59 NMAuthChain *nm_auth_chain_new_subject (NMAuthSubject *subject,
60                                         GDBusMethodInvocation *context,
61                                         NMAuthChainResultFunc done_func,
62                                         gpointer user_data);
63
64 gpointer nm_auth_chain_get_data (NMAuthChain *chain, const char *tag);
65
66 gpointer nm_auth_chain_steal_data (NMAuthChain *chain, const char *tag);
67
68 void nm_auth_chain_set_data (NMAuthChain *chain,
69                              const char *tag,
70                              gpointer data,
71                              GDestroyNotify data_destroy);
72
73 void nm_auth_chain_set_data_ulong (NMAuthChain *chain,
74                                    const char *tag,
75                                    gulong data);
76
77 gulong nm_auth_chain_get_data_ulong (NMAuthChain *chain, const char *tag);
78
79 NMAuthCallResult nm_auth_chain_get_result (NMAuthChain *chain,
80                                            const char *permission);
81
82 void nm_auth_chain_add_call (NMAuthChain *chain,
83                              const char *permission,
84                              gboolean allow_interaction);
85
86 void nm_auth_chain_unref (NMAuthChain *chain);
87
88 /* Caller must free returned error description */
89 gboolean nm_auth_is_subject_in_acl (NMConnection *connection,
90                                     NMAuthSubject *subect,
91                                     char **out_error_desc);
92
93 NMAuthSubject *nm_auth_chain_get_subject (NMAuthChain *self);
94
95 #endif /* __NETWORKMANAGER_MANAGER_AUTH_H__ */
96