summaryrefslogtreecommitdiff
path: root/src/modem-manager/nm-modem.h
blob: d01aaf2cbe78946e22ddb6a4828e7a32e375d03c (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
 *
 * 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 of the License, 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) 2009 - 2011 Red Hat, Inc.
 * Copyright (C) 2009 Novell, Inc.
 */

#ifndef NM_MODEM_H
#define NM_MODEM_H

#include <dbus/dbus-glib.h>
#include <glib-object.h>
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-device.h"

G_BEGIN_DECLS

#define NM_TYPE_MODEM            (nm_modem_get_type ())
#define NM_MODEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MODEM, NMModem))
#define NM_MODEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  NM_TYPE_MODEM, NMModemClass))
#define NM_IS_MODEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_MODEM))
#define NM_IS_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  NM_TYPE_MODEM))
#define NM_MODEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_MODEM, NMModemClass))

#define NM_MODEM_UID          "uid"
#define NM_MODEM_PATH         "path"
#define NM_MODEM_CONTROL_PORT "control-port"
#define NM_MODEM_DATA_PORT    "data-port"
#define NM_MODEM_IP_METHOD    "ip-method"
#define NM_MODEM_IP_TIMEOUT   "ip-timeout"
#define NM_MODEM_ENABLED      "enabled"
#define NM_MODEM_CONNECTED    "connected"

#define NM_MODEM_PPP_STATS         "ppp-stats"
#define NM_MODEM_PPP_FAILED        "ppp-failed"
#define NM_MODEM_PREPARE_RESULT    "prepare-result"
#define NM_MODEM_IP4_CONFIG_RESULT "ip4-config-result"
#define NM_MODEM_AUTH_REQUESTED    "auth-requested"
#define NM_MODEM_AUTH_RESULT       "auth-result"

#define MM_MODEM_IP_METHOD_PPP    0
#define MM_MODEM_IP_METHOD_STATIC 1
#define MM_MODEM_IP_METHOD_DHCP   2

typedef struct {
	GObject parent;
} NMModem;

typedef struct {
	GObjectClass parent;

	gboolean (*get_user_pass)                  (NMModem *modem,
	                                            NMConnection *connection,
	                                            const char **user,
	                                            const char **pass);

	const char * (*get_setting_name)           (NMModem *modem);

	gboolean (*check_connection_compatible)    (NMModem *modem,
	                                            NMConnection *connection,
	                                            GError **error);

	gboolean (*complete_connection)            (NMModem *modem,
	                                            NMConnection *connection,
	                                            const GSList *existing_connections,
	                                            GError **error);

	NMConnection * (*get_best_auto_connection) (NMModem *modem,
	                                            GSList *connections,
	                                            char **specific_object);

	NMActStageReturn (*act_stage1_prepare)     (NMModem *modem,
	                                            NMActRequest *req,
	                                            GPtrArray **out_hints,
	                                            const char **out_setting_name,
	                                            NMDeviceStateReason *reason);

	NMActStageReturn (*static_stage3_ip4_config_start) (NMModem *self,
	                                                    NMActRequest *req,
	                                                    NMDeviceStateReason *reason);

	void (*set_mm_enabled)                     (NMModem *self, gboolean enabled);

	void (*disconnect)                         (NMModem *self, gboolean warn);

	void (*deactivate)                         (NMModem *self, NMDevice *device);

	/* Signals */
	void (*ppp_stats)  (NMModem *self, guint32 in_bytes, guint32 out_bytes);
	void (*ppp_failed) (NMModem *self, NMDeviceStateReason reason);

	void (*prepare_result)    (NMModem *self, gboolean success, NMDeviceStateReason reason);
	void (*ip4_config_result) (NMModem *self, NMIP4Config *config, GError *error);

	void (*auth_requested)    (NMModem *self);
	void (*auth_result)       (NMModem *self, GError *error);
} NMModemClass;

GType nm_modem_get_type (void);

const char *nm_modem_get_path         (NMModem *modem);
const char *nm_modem_get_uid          (NMModem *modem);
const char *nm_modem_get_control_port (NMModem *modem);
const char *nm_modem_get_data_port    (NMModem *modem);

NMConnection *nm_modem_get_best_auto_connection (NMModem *self,
                                                 GSList *connections,
                                                 char **specific_object);

gboolean nm_modem_check_connection_compatible (NMModem *self,
                                               NMConnection *connection,
                                               GError **error);

gboolean nm_modem_complete_connection (NMModem *self,
                                       NMConnection *connection,
                                       const GSList *existing_connections,
                                       GError **error);

NMActStageReturn nm_modem_act_stage1_prepare (NMModem *modem,
                                              NMActRequest *req,
                                              NMDeviceStateReason *reason);

NMActStageReturn nm_modem_act_stage2_config (NMModem *modem,
                                             NMActRequest *req,
                                             NMDeviceStateReason *reason);

NMActStageReturn nm_modem_stage3_ip4_config_start (NMModem *modem,
                                                   NMDevice *device,
                                                   NMDeviceClass *device_class,
                                                   NMDeviceStateReason *reason);

NMActStageReturn nm_modem_stage3_ip6_config_start (NMModem *modem,
                                                   NMDevice *device,
                                                   NMDeviceClass *device_class,
                                                   NMDeviceStateReason *reason);

void nm_modem_ip4_pre_commit (NMModem *modem, NMDevice *device, NMIP4Config *config);

gboolean nm_modem_get_secrets (NMModem *modem,
                               const char *setting_name,
                               gboolean request_new,
                               const char *hint);

void nm_modem_deactivate (NMModem *modem, NMDevice *device);

void nm_modem_device_state_changed (NMModem *modem,
                                    NMDeviceState new_state,
                                    NMDeviceState old_state,
                                    NMDeviceStateReason reason);

gboolean      nm_modem_get_mm_enabled (NMModem *self);

void          nm_modem_set_mm_enabled (NMModem *self, gboolean enabled);

gboolean      nm_modem_get_mm_connected (NMModem *self);

G_END_DECLS

#endif /* NM_MODEM_H */