a5e75645588a962a2415ebbad7a145be6c47d0d2
[profile/ivi/ofono.git] / include / gprs-context.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __OFONO_GPRS_CONTEXT_H
23 #define __OFONO_GPRS_CONTEXT_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <ofono/types.h>
30
31 struct ofono_gprs_context;
32
33 #define OFONO_GPRS_MAX_APN_LENGTH 127
34 #define OFONO_GPRS_MAX_USERNAME_LENGTH 63
35 #define OFONO_GPRS_MAX_PASSWORD_LENGTH 255
36
37 enum ofono_gprs_proto {
38         OFONO_GPRS_PROTO_IP = 0,
39         OFONO_GPRS_PROTO_IPV6,
40         OFONO_GPRS_PROTO_IPV4V6,
41 };
42
43 enum ofono_gprs_context_type {
44         OFONO_GPRS_CONTEXT_TYPE_ANY = 0,
45         OFONO_GPRS_CONTEXT_TYPE_INTERNET,
46         OFONO_GPRS_CONTEXT_TYPE_MMS,
47         OFONO_GPRS_CONTEXT_TYPE_WAP,
48         OFONO_GPRS_CONTEXT_TYPE_IMS,
49 };
50
51 struct ofono_gprs_primary_context {
52         unsigned int cid;
53         int direction;
54         char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
55         char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
56         char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
57         enum ofono_gprs_proto proto;
58 };
59
60 typedef void (*ofono_gprs_context_cb_t)(const struct ofono_error *error,
61                                         void *data);
62
63 struct ofono_gprs_context_driver {
64         const char *name;
65         int (*probe)(struct ofono_gprs_context *gc, unsigned int vendor,
66                         void *data);
67         void (*remove)(struct ofono_gprs_context *gc);
68         void (*activate_primary)(struct ofono_gprs_context *gc,
69                                 const struct ofono_gprs_primary_context *ctx,
70                                 ofono_gprs_context_cb_t cb, void *data);
71         void (*deactivate_primary)(struct ofono_gprs_context *gc,
72                                         unsigned int id,
73                                         ofono_gprs_context_cb_t cb, void *data);
74 };
75
76 void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc,
77                                         unsigned int id);
78
79 int ofono_gprs_context_driver_register(
80                                 const struct ofono_gprs_context_driver *d);
81 void ofono_gprs_context_driver_unregister(
82                                 const struct ofono_gprs_context_driver *d);
83
84 struct ofono_gprs_context *ofono_gprs_context_create(struct ofono_modem *modem,
85                                                 unsigned int vendor,
86                                                 const char *driver, void *data);
87 void ofono_gprs_context_remove(struct ofono_gprs_context *gc);
88
89 void ofono_gprs_context_set_data(struct ofono_gprs_context *gc, void *data);
90 void *ofono_gprs_context_get_data(struct ofono_gprs_context *gc);
91
92 struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc);
93
94 void ofono_gprs_context_set_type(struct ofono_gprs_context *gc,
95                                         enum ofono_gprs_context_type type);
96
97 void ofono_gprs_context_set_interface(struct ofono_gprs_context *gc,
98                                         const char *interface);
99
100 void ofono_gprs_context_set_ipv4_address(struct ofono_gprs_context *gc,
101                                                 const char *address,
102                                                 ofono_bool_t static_ip);
103 void ofono_gprs_context_set_ipv4_netmask(struct ofono_gprs_context *gc,
104                                                 const char *netmask);
105 void ofono_gprs_context_set_ipv4_gateway(struct ofono_gprs_context *gc,
106                                                 const char *gateway);
107 void ofono_gprs_context_set_ipv4_dns_servers(struct ofono_gprs_context *gc,
108                                                 const char **dns);
109
110 void ofono_gprs_context_set_ipv6_address(struct ofono_gprs_context *gc,
111                                                 const char *address);
112 void ofono_gprs_context_set_ipv6_prefix_length(struct ofono_gprs_context *gc,
113                                                 unsigned char length);
114 void ofono_gprs_context_set_ipv6_gateway(struct ofono_gprs_context *gc,
115                                                 const char *gateway);
116 void ofono_gprs_context_set_ipv6_dns_servers(struct ofono_gprs_context *gc,
117                                                 const char **dns);
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif /* __OFONO_GPRS_CONTEXT_H */