Merge lp:~phablet-team/ofono/mbpi-nettime-plus-oem-fixes into lp:~phablet-team/ofono/ubuntu
- mbpi-nettime-plus-oem-fixes
- Merge into ubuntu
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Tony Espy | ||||||||||||
Approved revision: | 6870 | ||||||||||||
Merged at revision: | 6870 | ||||||||||||
Proposed branch: | lp:~phablet-team/ofono/mbpi-nettime-plus-oem-fixes | ||||||||||||
Merge into: | lp:~phablet-team/ofono/ubuntu | ||||||||||||
Diff against target: |
2623 lines (+1402/-785) 24 files modified
Makefile.am (+6/-3) debian/changelog (+19/-0) drivers/infineonmodem/infineon_constants.h (+77/-0) drivers/rilmodem/sim.c (+68/-1) drivers/rilmodem/vendor.h (+2/-1) gril/grilreply.c (+52/-0) gril/grilreply.h (+10/-0) gril/grilrequest.c (+15/-0) gril/grilrequest.h (+3/-0) gril/parcel.c (+52/-0) gril/parcel.h (+2/-0) plugins/android-apndb.c (+0/-494) plugins/android-apndb.h (+0/-33) plugins/android-provision.c (+0/-227) plugins/infineon.c (+76/-0) plugins/mtk.c (+48/-1) plugins/ril.c (+33/-24) plugins/ril.h (+30/-0) plugins/ubuntu-apndb.c (+596/-0) plugins/ubuntu-apndb.h (+33/-0) plugins/ubuntu-provision.c (+150/-0) test/rilmodem/test-sim-online (+2/-1) unit/test-grilreply.c (+72/-0) unit/test-grilrequest.c (+56/-0) |
||||||||||||
To merge this branch: | bzr merge lp:~phablet-team/ofono/mbpi-nettime-plus-oem-fixes | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email:
|
Commit message
* drivers/
* unit/rilmodem/
* plugins/mtk.c: fix race condition when onlining modem
* build, drivers/
plugins/
* build, plugins/
provisioning plugin code from android-* to ubuntu-*. Also removed
code that queries mobile-
implemented a /custom hook for custom apn dbs (LP: #1315509).
Description of the change
This branch includes the following changes and bug fixes:
1. It removes querying of the mobile-
2. It adds a custom hook to GPRS/MSS provisioning ( see bug #1315509 ).
3. It allows the custom and system apn dbs to be overriden by environment variables ( OFONO_CUSTOM_
4. It adds new OEM hooks which allow enablement of Infeon-based modems.
5. It fixes a race condition with dual-SIM MTK-based modems.
6. The rilmodem driver code now notifies the ofono core when SIM card removal is detected ( see bug #1332306 ).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
Preview Diff
1 | === modified file 'Makefile.am' | |||
2 | --- Makefile.am 2014-06-24 18:59:26 +0000 | |||
3 | +++ Makefile.am 2014-07-21 18:55:43 +0000 | |||
4 | @@ -127,6 +127,9 @@ | |||
5 | 127 | builtin_modules += mtk | 127 | builtin_modules += mtk |
6 | 128 | builtin_sources += plugins/mtk.c | 128 | builtin_sources += plugins/mtk.c |
7 | 129 | 129 | ||
8 | 130 | builtin_modules += infineon | ||
9 | 131 | builtin_sources += plugins/infineon.c | ||
10 | 132 | |||
11 | 130 | builtin_modules += androidspntable | 133 | builtin_modules += androidspntable |
12 | 131 | builtin_sources += plugins/android-spn-table.c | 134 | builtin_sources += plugins/android-spn-table.c |
13 | 132 | 135 | ||
14 | @@ -506,13 +509,13 @@ | |||
15 | 506 | 509 | ||
16 | 507 | if PROVISION | 510 | if PROVISION |
17 | 508 | builtin_sources += plugins/mbpi.h plugins/mbpi.c | 511 | builtin_sources += plugins/mbpi.h plugins/mbpi.c |
19 | 509 | builtin_sources += plugins/android-apndb.h plugins/android-apndb.c | 512 | builtin_sources += plugins/ubuntu-apndb.h plugins/ubuntu-apndb.c |
20 | 510 | 513 | ||
21 | 511 | builtin_modules += provision | 514 | builtin_modules += provision |
22 | 512 | builtin_sources += plugins/provision.c | 515 | builtin_sources += plugins/provision.c |
23 | 513 | 516 | ||
26 | 514 | builtin_modules += android_provision | 517 | builtin_modules += ubuntu_provision |
27 | 515 | builtin_sources += plugins/android-provision.c | 518 | builtin_sources += plugins/ubuntu-provision.c |
28 | 516 | 519 | ||
29 | 517 | builtin_modules += cdma_provision | 520 | builtin_modules += cdma_provision |
30 | 518 | builtin_sources += plugins/cdma-provision.c | 521 | builtin_sources += plugins/cdma-provision.c |
31 | 519 | 522 | ||
32 | === modified file 'debian/changelog' | |||
33 | --- debian/changelog 2014-06-25 00:58:02 +0000 | |||
34 | +++ debian/changelog 2014-07-21 18:55:43 +0000 | |||
35 | @@ -1,3 +1,22 @@ | |||
36 | 1 | ofono (1.12.bzr6870+14.10.20140625-0ubuntu1) UNRELEASED; urgency=medium | ||
37 | 2 | |||
38 | 3 | [ Martti Piirainen ] | ||
39 | 4 | * drivers/rilmodem/sim.c: notify on SIM removal (LP: #1332306) | ||
40 | 5 | * unit/rilmodem/test-sim-online: fix serial number check (LP: #1334867) | ||
41 | 6 | |||
42 | 7 | [ Alfonso Sanchez-Beato ] | ||
43 | 8 | * plugins/mtk.c: fix race condition when onlining modem | ||
44 | 9 | * build, drivers/infeonmodem, drivers/rilmodem, gril, | ||
45 | 10 | plugins/infeon.c, plugins/ril.*, unit: add Infeon OEM hooks | ||
46 | 11 | |||
47 | 12 | [ Tony Espy ] | ||
48 | 13 | * build, plugins/ubuntu-provision.c, ubuntu-apndb.*: re-named | ||
49 | 14 | provisioning plugin code from android-* to ubuntu-*. Also removed | ||
50 | 15 | code that queries mobile-broadband-provider-info's db, and finally | ||
51 | 16 | implemented a /custom hook for custom apn dbs (LP: #1315509). | ||
52 | 17 | |||
53 | 18 | -- Tony Espy <espy@canonical.com> Wed, 16 Jul 2014 15:06:02 -0400 | ||
54 | 19 | |||
55 | 1 | ofono (1.12.bzr6868+14.10.20140625-0ubuntu1) utopic; urgency=medium | 20 | ofono (1.12.bzr6868+14.10.20140625-0ubuntu1) utopic; urgency=medium |
56 | 2 | 21 | ||
57 | 3 | [ Alfonso Sanchez-Beato ] | 22 | [ Alfonso Sanchez-Beato ] |
58 | 4 | 23 | ||
59 | === added directory 'drivers/infineonmodem' | |||
60 | === added file 'drivers/infineonmodem/infineon_constants.h' | |||
61 | --- drivers/infineonmodem/infineon_constants.h 1970-01-01 00:00:00 +0000 | |||
62 | +++ drivers/infineonmodem/infineon_constants.h 2014-07-21 18:55:43 +0000 | |||
63 | @@ -0,0 +1,77 @@ | |||
64 | 1 | /* | ||
65 | 2 | * | ||
66 | 3 | * RIL constants for infineon modem | ||
67 | 4 | * | ||
68 | 5 | * Copyright (C) 2014 Canonical Ltd. | ||
69 | 6 | * | ||
70 | 7 | * This program is free software; you can redistribute it and/or modify | ||
71 | 8 | * it under the terms of the GNU General Public License version 2 as | ||
72 | 9 | * published by the Free Software Foundation. | ||
73 | 10 | * | ||
74 | 11 | * This program is distributed in the hope that it will be useful, | ||
75 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
76 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
77 | 14 | * GNU General Public License for more details. | ||
78 | 15 | * | ||
79 | 16 | * You should have received a copy of the GNU General Public License | ||
80 | 17 | * along with this program; if not, write to the Free Software | ||
81 | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
82 | 19 | * | ||
83 | 20 | */ | ||
84 | 21 | |||
85 | 22 | #ifndef INFINEON_CONSTANTS_H | ||
86 | 23 | #define INFINEON_CONSTANTS_H | ||
87 | 24 | |||
88 | 25 | /* Messages encapsulated in RIL_REQUEST_OEM_HOOK_RAW requests */ | ||
89 | 26 | #define INF_RIL_REQUEST_OEM_QUERY_SELECT_BAND 1 | ||
90 | 27 | #define INF_RIL_REQUEST_OEM_SET_SELECT_BAND 2 | ||
91 | 28 | #define INF_RIL_REQUEST_OEM_SET_CIRCUIT_SWITCHING_PAGING 3 | ||
92 | 29 | #define INF_RIL_REQUEST_OEM_GET_LAST_FAILURE_REPORT_FOR_CS_REGISTRATION 4 | ||
93 | 30 | #define INF_RIL_REQUEST_OEM_GET_SELECT_BEARER_SERVICE_TYPE 5 | ||
94 | 31 | #define INF_RIL_REQUEST_OEM_GET_XPROGRESS_STATUS 6 | ||
95 | 32 | #define INF_RIL_REQUEST_OEM_SET_SS_NOTIFY 7 | ||
96 | 33 | #define INF_RIL_REQUEST_OEM_GET_SS_NOTIFY 8 | ||
97 | 34 | #define INF_RIL_REQUEST_OEM_SET_AUTHENTICATION_TYPE 9 | ||
98 | 35 | #define INF_RIL_REQUEST_OEM_SWITCH_OFF_MS 10 | ||
99 | 36 | #define INF_RIL_REQUEST_OEM_SET_AUTO_TIMEZONE_UPDATE 11 | ||
100 | 37 | #define INF_RIL_REQUEST_OEM_SET_TIMEZONE_RESPORTING 12 | ||
101 | 38 | #define INF_RIL_REQUEST_OEM_SET_DISPLAY_SIM_AND_PB_STATUS 13 | ||
102 | 39 | #define INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS 14 | ||
103 | 40 | #define INF_RIL_REQUEST_OEM_SET_AUTO_REDIAL 15 | ||
104 | 41 | #define INF_RIL_REQUEST_OEM_QUERY_CALL_STATUS_REPORTING 16 | ||
105 | 42 | #define INF_RIL_REQUEST_OEM_SET_AUTO_ANSWER 17 | ||
106 | 43 | #define INF_RIL_REQUEST_OEM_SET_LINE 18 | ||
107 | 44 | #define INF_RIL_REQUEST_OEM_PDP_ACTIVATE_OR_DEACTIVATE 19 | ||
108 | 45 | #define INF_RIL_REQUEST_OEM_QUERY_GPRS_MS_CLASS 20 | ||
109 | 46 | #define INF_RIL_REQUEST_OEM_SET_TRACE_AND_AT_INTERFACES 21 | ||
110 | 47 | #define INF_RIL_REQUEST_OEM_QUERY_TRACE_AND_AT_INTERFACES_CONFIGURE 22 | ||
111 | 48 | #define INF_RIL_REQUEST_OEM_SWITCH_TRACE_ON_OR_OFF 23 | ||
112 | 49 | #define INF_RIL_REQUEST_OEM_READ_EXCEPTION_LOG 24 | ||
113 | 50 | #define INF_RIL_REQUEST_OEM_GET_PHONE_ACTIVITY_STATUS 25 | ||
114 | 51 | #define INF_RIL_REQUEST_OEM_INITIATE_RESEND_SMS_IF_GPRS_FAILS 26 | ||
115 | 52 | #define INF_RIL_REQUEST_OEM_GET_DEVICE_NUMBER 27 | ||
116 | 53 | #define INF_RIL_REQUEST_OEM_ENABLE_STK 28 | ||
117 | 54 | #define INF_RIL_REQUEST_OEM_GET_SUBSCRIBER_NUMBER 29 | ||
118 | 55 | #define INF_RIL_REQUEST_OEM_SELECT_PHONE_BOOK 30 | ||
119 | 56 | #define INF_RIL_REQUEST_OEM_READ_PHONE_BOOK 31 | ||
120 | 57 | #define INF_RIL_REQUEST_OEM_INSERT_RECORD_TO_PHONE_BOOK 32 | ||
121 | 58 | #define INF_RIL_REQUEST_OEM_DELECT_RECORD_IN_PHONE_BOOK 33 | ||
122 | 59 | #define INF_RIL_REQUEST_OEM_GET_RECORD_FIELDS_MAX_LEN 34 | ||
123 | 60 | #define INF_RIL_REQUEST_OEM_SET_SERIAL_PORT 35 | ||
124 | 61 | #define INF_RIL_REQUEST_OEM_SET_DATA_PREFERED 36 | ||
125 | 62 | #define INF_RIL_REQUEST_OEM_SET_MODEM_ROUTING 37 | ||
126 | 63 | #define INF_RIL_REQUEST_OEM_CLEAR_MISS_NUMBER 38 | ||
127 | 64 | #define INF_RIL_REQUEST_OEM_ATH 39 | ||
128 | 65 | #define INF_RIL_REQUEST_OEM_NOSIG_MODE_TEST 40 | ||
129 | 66 | #define INF_RIL_REQUEST_OEM_SELECT_3G_BAND 41 | ||
130 | 67 | #define INF_RIL_REQUEST_OEM_QUERY_3G_BAND 42 | ||
131 | 68 | #define INF_RIL_REQUEST_OEM_HW_RESET_MODEM 43 | ||
132 | 69 | #define INF_RIL_REQUEST_OEM_QUERY_DIRECT 44 | ||
133 | 70 | #define INF_RIL_REQUEST_OEM_USER_PLMN_QUERY 45 | ||
134 | 71 | #define INF_RIL_REQUEST_OEM_USER_PLMN_SET 46 | ||
135 | 72 | #define INF_RIL_REQUEST_OEM_USER_PLMN_DELTE 47 | ||
136 | 73 | #define INF_RIL_REQUEST_OEM_SET_USB_LOG 48 | ||
137 | 74 | #define INF_RIL_REQUEST_OEM_UPDATE_CSQ 49 | ||
138 | 75 | #define INF_RIL_REQUEST_OEM_DUMP_CELL_ENV 50 | ||
139 | 76 | |||
140 | 77 | #endif /* INFINEON_CONSTANTS_H */ | ||
141 | 0 | 78 | ||
142 | === modified file 'drivers/rilmodem/sim.c' | |||
143 | --- drivers/rilmodem/sim.c 2014-06-24 18:59:26 +0000 | |||
144 | +++ drivers/rilmodem/sim.c 2014-07-21 18:55:43 +0000 | |||
145 | @@ -51,6 +51,8 @@ | |||
146 | 51 | #include "grilrequest.h" | 51 | #include "grilrequest.h" |
147 | 52 | #include "grilunsol.h" | 52 | #include "grilunsol.h" |
148 | 53 | 53 | ||
149 | 54 | #include "drivers/infineonmodem/infineon_constants.h" | ||
150 | 55 | |||
151 | 54 | /* | 56 | /* |
152 | 55 | * Based on ../drivers/atmodem/sim.c. | 57 | * Based on ../drivers/atmodem/sim.c. |
153 | 56 | * | 58 | * |
154 | @@ -72,6 +74,7 @@ | |||
155 | 72 | */ | 74 | */ |
156 | 73 | struct sim_data { | 75 | struct sim_data { |
157 | 74 | GRil *ril; | 76 | GRil *ril; |
158 | 77 | enum ofono_ril_vendor vendor; | ||
159 | 75 | gchar *aid_str; | 78 | gchar *aid_str; |
160 | 76 | guint app_type; | 79 | guint app_type; |
161 | 77 | gchar *app_str; | 80 | gchar *app_str; |
162 | @@ -675,6 +678,9 @@ | |||
163 | 675 | */ | 678 | */ |
164 | 676 | __ofono_sim_recheck_pin(sim); | 679 | __ofono_sim_recheck_pin(sim); |
165 | 677 | } | 680 | } |
166 | 681 | } else if (status && status->card_state == RIL_CARDSTATE_ABSENT) { | ||
167 | 682 | ofono_info("SIM card absent"); | ||
168 | 683 | ofono_sim_inserted_notify(sim, FALSE); | ||
169 | 678 | } | 684 | } |
170 | 679 | 685 | ||
171 | 680 | g_ril_reply_free_sim_status(status); | 686 | g_ril_reply_free_sim_status(status); |
172 | @@ -703,12 +709,72 @@ | |||
173 | 703 | send_get_sim_status(sim); | 709 | send_get_sim_status(sim); |
174 | 704 | } | 710 | } |
175 | 705 | 711 | ||
176 | 712 | static void inf_pin_retries_cb(struct ril_msg *message, gpointer user_data) | ||
177 | 713 | { | ||
178 | 714 | struct cb_data *cbd = user_data; | ||
179 | 715 | ofono_sim_pin_retries_cb_t cb = cbd->cb; | ||
180 | 716 | struct sim_data *sd = cbd->user; | ||
181 | 717 | struct reply_oem_hook *reply = NULL; | ||
182 | 718 | int32_t *ret_data; | ||
183 | 719 | |||
184 | 720 | if (message->error != RIL_E_SUCCESS) { | ||
185 | 721 | ofono_error("Reply failure: %s", | ||
186 | 722 | ril_error_to_string(message->error)); | ||
187 | 723 | goto error; | ||
188 | 724 | } | ||
189 | 725 | |||
190 | 726 | reply = g_ril_reply_oem_hook_raw(sd->ril, message); | ||
191 | 727 | if (reply == NULL) { | ||
192 | 728 | ofono_error("%s: parse error", __func__); | ||
193 | 729 | goto error; | ||
194 | 730 | } | ||
195 | 731 | |||
196 | 732 | if (reply->length < 5 * (int) sizeof(int32_t)) { | ||
197 | 733 | ofono_error("%s: reply too small", __func__); | ||
198 | 734 | goto error; | ||
199 | 735 | } | ||
200 | 736 | |||
201 | 737 | /* First integer is INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS */ | ||
202 | 738 | ret_data = reply->data; | ||
203 | 739 | sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = *(++ret_data); | ||
204 | 740 | sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = *(++ret_data); | ||
205 | 741 | sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = *(++ret_data); | ||
206 | 742 | sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = *(++ret_data); | ||
207 | 743 | |||
208 | 744 | g_ril_reply_free_oem_hook(reply); | ||
209 | 745 | CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data); | ||
210 | 746 | |||
211 | 747 | return; | ||
212 | 748 | |||
213 | 749 | error: | ||
214 | 750 | g_ril_reply_free_oem_hook(reply); | ||
215 | 751 | CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); | ||
216 | 752 | } | ||
217 | 753 | |||
218 | 706 | static void ril_query_pin_retries(struct ofono_sim *sim, | 754 | static void ril_query_pin_retries(struct ofono_sim *sim, |
219 | 707 | ofono_sim_pin_retries_cb_t cb, | 755 | ofono_sim_pin_retries_cb_t cb, |
220 | 708 | void *data) | 756 | void *data) |
221 | 709 | { | 757 | { |
222 | 710 | struct sim_data *sd = ofono_sim_get_data(sim); | 758 | struct sim_data *sd = ofono_sim_get_data(sim); |
224 | 711 | CALLBACK_WITH_SUCCESS(cb, sd->retries, data); | 759 | |
225 | 760 | if (sd->vendor == OFONO_RIL_VENDOR_INFINEON) { | ||
226 | 761 | struct cb_data *cbd = cb_data_new(cb, data, sd); | ||
227 | 762 | struct parcel rilp; | ||
228 | 763 | int32_t oem_req = | ||
229 | 764 | INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS; | ||
230 | 765 | |||
231 | 766 | g_ril_request_oem_hook_raw(sd->ril, &oem_req, | ||
232 | 767 | sizeof(oem_req), &rilp); | ||
233 | 768 | |||
234 | 769 | /* Send request to RIL */ | ||
235 | 770 | if (g_ril_send(sd->ril, RIL_REQUEST_OEM_HOOK_RAW, &rilp, | ||
236 | 771 | inf_pin_retries_cb, cbd, g_free) == 0) { | ||
237 | 772 | g_free(cbd); | ||
238 | 773 | CALLBACK_WITH_FAILURE(cb, NULL, data); | ||
239 | 774 | } | ||
240 | 775 | } else { | ||
241 | 776 | CALLBACK_WITH_SUCCESS(cb, sd->retries, data); | ||
242 | 777 | } | ||
243 | 712 | } | 778 | } |
244 | 713 | 779 | ||
245 | 714 | static void ril_query_passwd_state(struct ofono_sim *sim, | 780 | static void ril_query_passwd_state(struct ofono_sim *sim, |
246 | @@ -893,6 +959,7 @@ | |||
247 | 893 | 959 | ||
248 | 894 | sd = g_new0(struct sim_data, 1); | 960 | sd = g_new0(struct sim_data, 1); |
249 | 895 | sd->ril = g_ril_clone(ril); | 961 | sd->ril = g_ril_clone(ril); |
250 | 962 | sd->vendor = vendor; | ||
251 | 896 | sd->aid_str = NULL; | 963 | sd->aid_str = NULL; |
252 | 897 | sd->app_str = NULL; | 964 | sd->app_str = NULL; |
253 | 898 | sd->app_type = RIL_APPTYPE_UNKNOWN; | 965 | sd->app_type = RIL_APPTYPE_UNKNOWN; |
254 | 899 | 966 | ||
255 | === modified file 'drivers/rilmodem/vendor.h' | |||
256 | --- drivers/rilmodem/vendor.h 2014-03-20 07:46:16 +0000 | |||
257 | +++ drivers/rilmodem/vendor.h 2014-07-21 18:55:43 +0000 | |||
258 | @@ -24,7 +24,8 @@ | |||
259 | 24 | 24 | ||
260 | 25 | enum ofono_ril_vendor { | 25 | enum ofono_ril_vendor { |
261 | 26 | OFONO_RIL_VENDOR_AOSP = 0, | 26 | OFONO_RIL_VENDOR_AOSP = 0, |
263 | 27 | OFONO_RIL_VENDOR_MTK | 27 | OFONO_RIL_VENDOR_MTK, |
264 | 28 | OFONO_RIL_VENDOR_INFINEON | ||
265 | 28 | }; | 29 | }; |
266 | 29 | 30 | ||
267 | 30 | #endif /* RILMODEM_VENDOR_H */ | 31 | #endif /* RILMODEM_VENDOR_H */ |
268 | 31 | 32 | ||
269 | === modified file 'gril/grilreply.c' | |||
270 | --- gril/grilreply.c 2014-05-13 01:21:09 +0000 | |||
271 | +++ gril/grilreply.c 2014-07-21 18:55:43 +0000 | |||
272 | @@ -1204,6 +1204,11 @@ | |||
273 | 1204 | retries[OFONO_SIM_PASSWORD_SIM_PUK], | 1204 | retries[OFONO_SIM_PASSWORD_SIM_PUK], |
274 | 1205 | retries[OFONO_SIM_PASSWORD_SIM_PUK2]); | 1205 | retries[OFONO_SIM_PASSWORD_SIM_PUK2]); |
275 | 1206 | break; | 1206 | break; |
276 | 1207 | case OFONO_RIL_VENDOR_INFINEON: | ||
277 | 1208 | ofono_error("%s: infineon type should not arrive here", | ||
278 | 1209 | __func__); | ||
279 | 1210 | g_assert(FALSE); | ||
280 | 1211 | break; | ||
281 | 1207 | } | 1212 | } |
282 | 1208 | 1213 | ||
283 | 1209 | if (rilp.malformed) { | 1214 | if (rilp.malformed) { |
284 | @@ -1220,3 +1225,50 @@ | |||
285 | 1220 | 1225 | ||
286 | 1221 | return NULL; | 1226 | return NULL; |
287 | 1222 | } | 1227 | } |
288 | 1228 | |||
289 | 1229 | void g_ril_reply_free_oem_hook(struct reply_oem_hook *oem_hook) | ||
290 | 1230 | { | ||
291 | 1231 | if (oem_hook) { | ||
292 | 1232 | g_free(oem_hook->data); | ||
293 | 1233 | g_free(oem_hook); | ||
294 | 1234 | } | ||
295 | 1235 | } | ||
296 | 1236 | |||
297 | 1237 | struct reply_oem_hook *g_ril_reply_oem_hook_raw(GRil *gril, | ||
298 | 1238 | const struct ril_msg *message) | ||
299 | 1239 | { | ||
300 | 1240 | struct reply_oem_hook *reply = NULL; | ||
301 | 1241 | struct parcel rilp; | ||
302 | 1242 | |||
303 | 1243 | reply = g_try_malloc0(sizeof(*reply)); | ||
304 | 1244 | if (reply == NULL) { | ||
305 | 1245 | ofono_error("%s: out of memory", __func__); | ||
306 | 1246 | goto end; | ||
307 | 1247 | } | ||
308 | 1248 | |||
309 | 1249 | g_ril_init_parcel(message, &rilp); | ||
310 | 1250 | |||
311 | 1251 | reply->data = parcel_r_raw(&rilp, &(reply->length)); | ||
312 | 1252 | |||
313 | 1253 | if (rilp.malformed) { | ||
314 | 1254 | ofono_error("%s: malformed parcel", __func__); | ||
315 | 1255 | g_ril_reply_free_oem_hook(reply); | ||
316 | 1256 | reply = NULL; | ||
317 | 1257 | goto end; | ||
318 | 1258 | } | ||
319 | 1259 | |||
320 | 1260 | g_ril_append_print_buf(gril, "{%d", reply->length); | ||
321 | 1261 | |||
322 | 1262 | if (reply->data != NULL) { | ||
323 | 1263 | char *hex_dump; | ||
324 | 1264 | hex_dump = encode_hex(reply->data, reply->length, '\0'); | ||
325 | 1265 | g_ril_append_print_buf(gril, "%s,%s", print_buf, hex_dump); | ||
326 | 1266 | g_free(hex_dump); | ||
327 | 1267 | } | ||
328 | 1268 | |||
329 | 1269 | g_ril_append_print_buf(gril, "%s}", print_buf); | ||
330 | 1270 | g_ril_print_response(gril, message); | ||
331 | 1271 | |||
332 | 1272 | end: | ||
333 | 1273 | return reply; | ||
334 | 1274 | } | ||
335 | 1223 | 1275 | ||
336 | === modified file 'gril/grilreply.h' | |||
337 | --- gril/grilreply.h 2014-04-29 15:50:22 +0000 | |||
338 | +++ gril/grilreply.h 2014-07-21 18:55:43 +0000 | |||
339 | @@ -89,6 +89,11 @@ | |||
340 | 89 | int provisioned; | 89 | int provisioned; |
341 | 90 | }; | 90 | }; |
342 | 91 | 91 | ||
343 | 92 | struct reply_oem_hook { | ||
344 | 93 | int length; | ||
345 | 94 | void *data; | ||
346 | 95 | }; | ||
347 | 96 | |||
348 | 92 | void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply); | 97 | void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply); |
349 | 93 | 98 | ||
350 | 94 | struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril, | 99 | struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril, |
351 | @@ -160,6 +165,11 @@ | |||
352 | 160 | int *g_ril_reply_parse_retries(GRil *gril, const struct ril_msg *message, | 165 | int *g_ril_reply_parse_retries(GRil *gril, const struct ril_msg *message, |
353 | 161 | enum ofono_sim_password_type passwd_type); | 166 | enum ofono_sim_password_type passwd_type); |
354 | 162 | 167 | ||
355 | 168 | void g_ril_reply_free_oem_hook(struct reply_oem_hook *oem_hook); | ||
356 | 169 | |||
357 | 170 | struct reply_oem_hook *g_ril_reply_oem_hook_raw(GRil *gril, | ||
358 | 171 | const struct ril_msg *message); | ||
359 | 172 | |||
360 | 163 | #ifdef __cplusplus | 173 | #ifdef __cplusplus |
361 | 164 | } | 174 | } |
362 | 165 | #endif | 175 | #endif |
363 | 166 | 176 | ||
364 | === modified file 'gril/grilrequest.c' | |||
365 | --- gril/grilrequest.c 2014-06-12 08:29:40 +0000 | |||
366 | +++ gril/grilrequest.c 2014-07-21 18:55:43 +0000 | |||
367 | @@ -1030,3 +1030,18 @@ | |||
368 | 1030 | g_ril_append_print_buf(gril, "(%s,%s,%s)", | 1030 | g_ril_append_print_buf(gril, "(%s,%s,%s)", |
369 | 1031 | facility, old_passwd, new_passwd); | 1031 | facility, old_passwd, new_passwd); |
370 | 1032 | } | 1032 | } |
371 | 1033 | |||
372 | 1034 | void g_ril_request_oem_hook_raw(GRil *gril, const void *payload, size_t length, | ||
373 | 1035 | struct parcel *rilp) | ||
374 | 1036 | { | ||
375 | 1037 | char *hex_dump = NULL; | ||
376 | 1038 | |||
377 | 1039 | parcel_init(rilp); | ||
378 | 1040 | parcel_w_raw(rilp, payload, length); | ||
379 | 1041 | |||
380 | 1042 | if (payload != NULL) | ||
381 | 1043 | hex_dump = encode_hex(payload, length, '\0'); | ||
382 | 1044 | |||
383 | 1045 | g_ril_append_print_buf(gril, "(%s)", hex_dump? hex_dump: "(null)"); | ||
384 | 1046 | g_free(hex_dump); | ||
385 | 1047 | } | ||
386 | 1033 | 1048 | ||
387 | === modified file 'gril/grilrequest.h' | |||
388 | --- gril/grilrequest.h 2014-06-12 08:29:40 +0000 | |||
389 | +++ gril/grilrequest.h 2014-07-21 18:55:43 +0000 | |||
390 | @@ -265,6 +265,9 @@ | |||
391 | 265 | const char *new_passwd, | 265 | const char *new_passwd, |
392 | 266 | struct parcel *rilp); | 266 | struct parcel *rilp); |
393 | 267 | 267 | ||
394 | 268 | void g_ril_request_oem_hook_raw(GRil *gril, const void *payload, size_t length, | ||
395 | 269 | struct parcel *rilp); | ||
396 | 270 | |||
397 | 268 | #ifdef __cplusplus | 271 | #ifdef __cplusplus |
398 | 269 | } | 272 | } |
399 | 270 | #endif | 273 | #endif |
400 | 271 | 274 | ||
401 | === modified file 'gril/parcel.c' | |||
402 | --- gril/parcel.c 2013-12-05 13:53:09 +0000 | |||
403 | +++ gril/parcel.c 2014-07-21 18:55:43 +0000 | |||
404 | @@ -201,6 +201,58 @@ | |||
405 | 201 | return ret; | 201 | return ret; |
406 | 202 | } | 202 | } |
407 | 203 | 203 | ||
408 | 204 | int parcel_w_raw(struct parcel *p, const void* data, size_t len) | ||
409 | 205 | { | ||
410 | 206 | if (data == NULL) { | ||
411 | 207 | parcel_w_int32(p, -1); | ||
412 | 208 | return 0; | ||
413 | 209 | } | ||
414 | 210 | |||
415 | 211 | parcel_w_int32(p, len); | ||
416 | 212 | |||
417 | 213 | for (;;) { | ||
418 | 214 | |||
419 | 215 | if (p->offset + len < p->capacity) { | ||
420 | 216 | /* There's enough space */ | ||
421 | 217 | memcpy(p->data + p->offset, data, len); | ||
422 | 218 | p->offset += len; | ||
423 | 219 | p->size += len; | ||
424 | 220 | break; | ||
425 | 221 | } else { | ||
426 | 222 | /* Grow data and retry */ | ||
427 | 223 | parcel_grow(p, len); | ||
428 | 224 | } | ||
429 | 225 | } | ||
430 | 226 | return 0; | ||
431 | 227 | } | ||
432 | 228 | |||
433 | 229 | void *parcel_r_raw(struct parcel *p, int *len) | ||
434 | 230 | { | ||
435 | 231 | char *ret; | ||
436 | 232 | |||
437 | 233 | *len = parcel_r_int32(p); | ||
438 | 234 | |||
439 | 235 | if (p->malformed || *len <= 0) | ||
440 | 236 | return NULL; | ||
441 | 237 | |||
442 | 238 | if (p->offset + *len > p->size) { | ||
443 | 239 | ofono_error("%s: parcel is too small", __func__); | ||
444 | 240 | p->malformed = 1; | ||
445 | 241 | return NULL; | ||
446 | 242 | } | ||
447 | 243 | |||
448 | 244 | ret = g_try_malloc0(*len); | ||
449 | 245 | if (ret == NULL) { | ||
450 | 246 | ofono_error("%s: out of memory (%d bytes)", __func__, *len); | ||
451 | 247 | return NULL; | ||
452 | 248 | } | ||
453 | 249 | |||
454 | 250 | memcpy(ret, p->data + p->offset, *len); | ||
455 | 251 | p->offset += *len; | ||
456 | 252 | |||
457 | 253 | return ret; | ||
458 | 254 | } | ||
459 | 255 | |||
460 | 204 | size_t parcel_data_avail(struct parcel *p) | 256 | size_t parcel_data_avail(struct parcel *p) |
461 | 205 | { | 257 | { |
462 | 206 | return (p->size - p->offset); | 258 | return (p->size - p->offset); |
463 | 207 | 259 | ||
464 | === modified file 'gril/parcel.h' | |||
465 | --- gril/parcel.h 2013-12-05 13:53:09 +0000 | |||
466 | +++ gril/parcel.h 2014-07-21 18:55:43 +0000 | |||
467 | @@ -39,6 +39,8 @@ | |||
468 | 39 | int parcel_w_int32(struct parcel *p, int32_t val); | 39 | int parcel_w_int32(struct parcel *p, int32_t val); |
469 | 40 | int parcel_w_string(struct parcel *p, const char *str); | 40 | int parcel_w_string(struct parcel *p, const char *str); |
470 | 41 | char *parcel_r_string(struct parcel *p); | 41 | char *parcel_r_string(struct parcel *p); |
471 | 42 | int parcel_w_raw(struct parcel *p, const void *data, size_t len); | ||
472 | 43 | void *parcel_r_raw(struct parcel *p, int *len); | ||
473 | 42 | size_t parcel_data_avail(struct parcel *p); | 44 | size_t parcel_data_avail(struct parcel *p); |
474 | 43 | 45 | ||
475 | 44 | #endif | 46 | #endif |
476 | 45 | 47 | ||
477 | === removed file 'plugins/android-apndb.c' | |||
478 | --- plugins/android-apndb.c 2014-04-25 16:10:01 +0000 | |||
479 | +++ plugins/android-apndb.c 1970-01-01 00:00:00 +0000 | |||
480 | @@ -1,494 +0,0 @@ | |||
481 | 1 | /* | ||
482 | 2 | * | ||
483 | 3 | * oFono - Open Source Telephony | ||
484 | 4 | * | ||
485 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
486 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
487 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
488 | 8 | * | ||
489 | 9 | * This program is free software; you can redistribute it and/or modify | ||
490 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
491 | 11 | * published by the Free Software Foundation. | ||
492 | 12 | * | ||
493 | 13 | * This program is distributed in the hope that it will be useful, | ||
494 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
495 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
496 | 16 | * GNU General Public License for more details. | ||
497 | 17 | * | ||
498 | 18 | * You should have received a copy of the GNU General Public License | ||
499 | 19 | * along with this program; if not, write to the Free Software | ||
500 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
501 | 21 | * | ||
502 | 22 | */ | ||
503 | 23 | |||
504 | 24 | #ifdef HAVE_CONFIG_H | ||
505 | 25 | #include <config.h> | ||
506 | 26 | #endif | ||
507 | 27 | |||
508 | 28 | #include <string.h> | ||
509 | 29 | #include <fcntl.h> | ||
510 | 30 | #include <sys/mman.h> | ||
511 | 31 | #include <sys/stat.h> | ||
512 | 32 | #include <sys/types.h> | ||
513 | 33 | #include <errno.h> | ||
514 | 34 | #include <stdlib.h> | ||
515 | 35 | #include <unistd.h> | ||
516 | 36 | |||
517 | 37 | #include <glib.h> | ||
518 | 38 | |||
519 | 39 | #define OFONO_API_SUBJECT_TO_CHANGE | ||
520 | 40 | #include <ofono/modem.h> | ||
521 | 41 | #include <ofono/gprs-provision.h> | ||
522 | 42 | #include <ofono/log.h> | ||
523 | 43 | |||
524 | 44 | #include "android-apndb.h" | ||
525 | 45 | |||
526 | 46 | /* TODO: consider reading path from an environment variable */ | ||
527 | 47 | |||
528 | 48 | #ifndef ANDROID_APN_DATABASE | ||
529 | 49 | #define ANDROID_APN_DATABASE "/android/system/etc/apns-conf.xml" | ||
530 | 50 | #endif | ||
531 | 51 | |||
532 | 52 | struct apndb_data { | ||
533 | 53 | const char *match_mcc; | ||
534 | 54 | const char *match_mnc; | ||
535 | 55 | const char *match_imsi; | ||
536 | 56 | const char *match_spn; | ||
537 | 57 | const char *match_gid1; | ||
538 | 58 | GSList *apns; | ||
539 | 59 | gboolean allow_duplicates; | ||
540 | 60 | gboolean mvno_found; | ||
541 | 61 | }; | ||
542 | 62 | |||
543 | 63 | void android_apndb_ap_free(gpointer data) | ||
544 | 64 | { | ||
545 | 65 | struct apndb_provision_data *ap = data; | ||
546 | 66 | |||
547 | 67 | g_free(ap->gprs_data.name); | ||
548 | 68 | g_free(ap->gprs_data.apn); | ||
549 | 69 | g_free(ap->gprs_data.username); | ||
550 | 70 | g_free(ap->gprs_data.password); | ||
551 | 71 | g_free(ap->gprs_data.message_proxy); | ||
552 | 72 | g_free(ap->gprs_data.message_center); | ||
553 | 73 | |||
554 | 74 | g_free(ap); | ||
555 | 75 | } | ||
556 | 76 | |||
557 | 77 | static void android_apndb_g_set_error(GMarkupParseContext *context, | ||
558 | 78 | GError **error, | ||
559 | 79 | GQuark domain, | ||
560 | 80 | gint code, | ||
561 | 81 | const gchar *fmt, ...) | ||
562 | 82 | { | ||
563 | 83 | va_list ap; | ||
564 | 84 | gint line_number, char_number; | ||
565 | 85 | |||
566 | 86 | g_markup_parse_context_get_position(context, &line_number, | ||
567 | 87 | &char_number); | ||
568 | 88 | va_start(ap, fmt); | ||
569 | 89 | |||
570 | 90 | *error = g_error_new_valist(domain, code, fmt, ap); | ||
571 | 91 | |||
572 | 92 | va_end(ap); | ||
573 | 93 | |||
574 | 94 | g_prefix_error(error, "%s:%d ", ANDROID_APN_DATABASE, line_number); | ||
575 | 95 | } | ||
576 | 96 | |||
577 | 97 | static gboolean imsi_match(const char *imsi, const char *match) | ||
578 | 98 | { | ||
579 | 99 | gboolean result = FALSE; | ||
580 | 100 | size_t imsi_len = strlen(imsi); | ||
581 | 101 | size_t match_len = strlen(match); | ||
582 | 102 | unsigned int i; | ||
583 | 103 | |||
584 | 104 | DBG("imsi %s match %s", imsi, match); | ||
585 | 105 | |||
586 | 106 | if (imsi_len != match_len) | ||
587 | 107 | goto done; | ||
588 | 108 | |||
589 | 109 | for (i = 0; i < imsi_len; i++) { | ||
590 | 110 | if (*(imsi + i) == *(match + i)) | ||
591 | 111 | continue; | ||
592 | 112 | else if (*(match + i) == 'x') | ||
593 | 113 | continue; | ||
594 | 114 | else | ||
595 | 115 | goto done; | ||
596 | 116 | } | ||
597 | 117 | |||
598 | 118 | result = TRUE; | ||
599 | 119 | |||
600 | 120 | done: | ||
601 | 121 | return result; | ||
602 | 122 | } | ||
603 | 123 | |||
604 | 124 | static enum ofono_gprs_context_type determine_apn_type(const char *types) | ||
605 | 125 | { | ||
606 | 126 | /* | ||
607 | 127 | * The database contains entries with the following type field contents: | ||
608 | 128 | * - default | ||
609 | 129 | * - default,mms | ||
610 | 130 | * - default,supl | ||
611 | 131 | * - defualt,supl,dun | ||
612 | 132 | * - default,supl,mms | ||
613 | 133 | * - mms | ||
614 | 134 | */ | ||
615 | 135 | |||
616 | 136 | if (g_strcmp0(types, "mms") == 0) | ||
617 | 137 | return OFONO_GPRS_CONTEXT_TYPE_MMS; | ||
618 | 138 | else if (g_str_has_prefix(types, "default")) | ||
619 | 139 | return OFONO_GPRS_CONTEXT_TYPE_INTERNET; | ||
620 | 140 | else | ||
621 | 141 | return OFONO_GPRS_CONTEXT_TYPE_ANY; | ||
622 | 142 | } | ||
623 | 143 | |||
624 | 144 | static char *android_apndb_sanitize_ipv4_address(const char *address) | ||
625 | 145 | { | ||
626 | 146 | char **numbers = NULL; | ||
627 | 147 | char *sanitized_numbers[4]; | ||
628 | 148 | unsigned int count = 0; | ||
629 | 149 | char *result = NULL; | ||
630 | 150 | char *numeral; | ||
631 | 151 | |||
632 | 152 | /* | ||
633 | 153 | * As src/gprs.c expects MMS proxies to always be | ||
634 | 154 | * specified using IPV4 numbers-and-dot notation, | ||
635 | 155 | * we need to strip any leading "0"s from the | ||
636 | 156 | * individual numeric components, otherwise they | ||
637 | 157 | * will be treated as octal numbers | ||
638 | 158 | * ( see 'man inet_aton' for details ). | ||
639 | 159 | */ | ||
640 | 160 | |||
641 | 161 | if (g_ascii_isdigit(*address) == FALSE) | ||
642 | 162 | goto done; | ||
643 | 163 | |||
644 | 164 | numbers = g_strsplit(address, ".", 4); | ||
645 | 165 | |||
646 | 166 | for (; (numeral = *(numbers+count)); count++) { | ||
647 | 167 | if (count > 3) | ||
648 | 168 | goto done; | ||
649 | 169 | |||
650 | 170 | for (; *numeral; numeral++) { | ||
651 | 171 | if (g_ascii_isdigit(*numeral) == FALSE) | ||
652 | 172 | goto done; | ||
653 | 173 | else if (*numeral == '0') | ||
654 | 174 | continue; | ||
655 | 175 | else | ||
656 | 176 | break; | ||
657 | 177 | } | ||
658 | 178 | |||
659 | 179 | if (*numeral) | ||
660 | 180 | sanitized_numbers[count] = numeral; | ||
661 | 181 | else | ||
662 | 182 | sanitized_numbers[count] = "0"; | ||
663 | 183 | } | ||
664 | 184 | |||
665 | 185 | if (count != 4) | ||
666 | 186 | goto done; | ||
667 | 187 | |||
668 | 188 | result = g_strdup_printf("%s.%s.%s.%s", | ||
669 | 189 | sanitized_numbers[0], | ||
670 | 190 | sanitized_numbers[1], | ||
671 | 191 | sanitized_numbers[2], | ||
672 | 192 | sanitized_numbers[3]); | ||
673 | 193 | |||
674 | 194 | done: | ||
675 | 195 | if (numbers != NULL) | ||
676 | 196 | g_strfreev(numbers); | ||
677 | 197 | |||
678 | 198 | return result; | ||
679 | 199 | } | ||
680 | 200 | |||
681 | 201 | static void toplevel_apndb_start(GMarkupParseContext *context, | ||
682 | 202 | const gchar *element_name, | ||
683 | 203 | const gchar **attribute_names, | ||
684 | 204 | const gchar **attribute_values, | ||
685 | 205 | gpointer userdata, GError **error) | ||
686 | 206 | { | ||
687 | 207 | struct apndb_data *apndb = userdata; | ||
688 | 208 | struct apndb_provision_data *ap = NULL; | ||
689 | 209 | int i; | ||
690 | 210 | const gchar *carrier = NULL; | ||
691 | 211 | const gchar *mcc = NULL; | ||
692 | 212 | const gchar *mnc = NULL; | ||
693 | 213 | const gchar *apn = NULL; | ||
694 | 214 | const gchar *username = NULL; | ||
695 | 215 | const gchar *password = NULL; | ||
696 | 216 | const gchar *types = NULL; | ||
697 | 217 | const gchar *protocol = NULL; | ||
698 | 218 | const gchar *mmsproxy = NULL; | ||
699 | 219 | const gchar *mmsport = NULL; | ||
700 | 220 | const gchar *mmscenter = NULL; | ||
701 | 221 | const gchar *mvnomatch = NULL; | ||
702 | 222 | const gchar *mvnotype = NULL; | ||
703 | 223 | enum ofono_gprs_proto proto = OFONO_GPRS_PROTO_IP; | ||
704 | 224 | enum ofono_gprs_context_type type; | ||
705 | 225 | |||
706 | 226 | if (g_strcmp0(element_name, "apn") != 0) | ||
707 | 227 | return; | ||
708 | 228 | |||
709 | 229 | for (i = 0; attribute_names[i]; i++) { | ||
710 | 230 | if (g_strcmp0(attribute_names[i], "carrier") == 0) | ||
711 | 231 | carrier = attribute_values[i]; | ||
712 | 232 | else if (g_strcmp0(attribute_names[i], "mcc") == 0) | ||
713 | 233 | mcc = attribute_values[i]; | ||
714 | 234 | else if (g_strcmp0(attribute_names[i], "mnc") == 0) | ||
715 | 235 | mnc = attribute_values[i]; | ||
716 | 236 | } | ||
717 | 237 | |||
718 | 238 | if (mcc == NULL) { | ||
719 | 239 | android_apndb_g_set_error(context, error, G_MARKUP_ERROR, | ||
720 | 240 | G_MARKUP_ERROR_MISSING_ATTRIBUTE, | ||
721 | 241 | "Missing attribute: mcc"); | ||
722 | 242 | return; | ||
723 | 243 | } | ||
724 | 244 | |||
725 | 245 | if (mnc == NULL) { | ||
726 | 246 | android_apndb_g_set_error(context, error, G_MARKUP_ERROR, | ||
727 | 247 | G_MARKUP_ERROR_MISSING_ATTRIBUTE, | ||
728 | 248 | "Missing attribute: mnc"); | ||
729 | 249 | return; | ||
730 | 250 | } | ||
731 | 251 | |||
732 | 252 | if (g_strcmp0(mcc, apndb->match_mcc) != 0 || | ||
733 | 253 | g_strcmp0(mnc, apndb->match_mnc) != 0) | ||
734 | 254 | return; | ||
735 | 255 | |||
736 | 256 | for (i = 0; attribute_names[i]; i++) { | ||
737 | 257 | if (g_strcmp0(attribute_names[i], "apn") == 0) | ||
738 | 258 | apn = attribute_values[i]; | ||
739 | 259 | else if (g_strcmp0(attribute_names[i], "user") == 0) | ||
740 | 260 | username = attribute_values[i]; | ||
741 | 261 | else if (g_strcmp0(attribute_names[i], "password") == 0) | ||
742 | 262 | password = attribute_values[i]; | ||
743 | 263 | else if (g_strcmp0(attribute_names[i], "type") == 0) | ||
744 | 264 | types = attribute_values[i]; | ||
745 | 265 | else if (g_strcmp0(attribute_names[i], "protocol") == 0) | ||
746 | 266 | protocol = attribute_values[i]; | ||
747 | 267 | else if (g_strcmp0(attribute_names[i], "mmsc") == 0) | ||
748 | 268 | mmscenter = attribute_values[i]; | ||
749 | 269 | else if (g_strcmp0(attribute_names[i], "mmsproxy") == 0) | ||
750 | 270 | mmsproxy = attribute_values[i]; | ||
751 | 271 | else if (g_strcmp0(attribute_names[i], "mmsport") == 0) | ||
752 | 272 | mmsport = attribute_values[i]; | ||
753 | 273 | else if (g_strcmp0(attribute_names[i], "mvno_match_data") == 0) | ||
754 | 274 | mvnomatch = attribute_values[i]; | ||
755 | 275 | else if (g_strcmp0(attribute_names[i], "mvno_type") == 0) | ||
756 | 276 | mvnotype = attribute_values[i]; | ||
757 | 277 | } | ||
758 | 278 | |||
759 | 279 | if (apn == NULL) { | ||
760 | 280 | android_apndb_g_set_error(context, error, G_MARKUP_ERROR, | ||
761 | 281 | G_MARKUP_ERROR_MISSING_ATTRIBUTE, | ||
762 | 282 | "APN attribute missing"); | ||
763 | 283 | return; | ||
764 | 284 | } | ||
765 | 285 | |||
766 | 286 | if (types == NULL) { | ||
767 | 287 | ofono_error("%s: apn for %s missing type attribute", __func__, | ||
768 | 288 | carrier); | ||
769 | 289 | return; | ||
770 | 290 | } | ||
771 | 291 | |||
772 | 292 | if (protocol != NULL) { | ||
773 | 293 | if (g_strcmp0(protocol, "IP") == 0) { | ||
774 | 294 | proto = OFONO_GPRS_PROTO_IP; | ||
775 | 295 | } else if (g_strcmp0(protocol, "IPV6") == 0) { | ||
776 | 296 | proto = OFONO_GPRS_PROTO_IPV6; | ||
777 | 297 | } else if (g_strcmp0(protocol, "IPV4V6") == 0) { | ||
778 | 298 | proto = OFONO_GPRS_PROTO_IPV4V6; | ||
779 | 299 | } else { | ||
780 | 300 | ofono_error("%s: APN %s has invalid protocol=%s" | ||
781 | 301 | "attribute", __func__, carrier, | ||
782 | 302 | protocol); | ||
783 | 303 | return; | ||
784 | 304 | } | ||
785 | 305 | } | ||
786 | 306 | |||
787 | 307 | if (mvnotype != NULL && mvnomatch != NULL) { | ||
788 | 308 | |||
789 | 309 | if (g_strcmp0(mvnotype, "imsi") == 0) { | ||
790 | 310 | DBG("APN %s is mvno_type 'imsi'", carrier); | ||
791 | 311 | |||
792 | 312 | if (apndb->match_imsi == NULL || | ||
793 | 313 | imsi_match(apndb->match_imsi, | ||
794 | 314 | mvnomatch) == FALSE) { | ||
795 | 315 | DBG("Skipping MVNO 'imsi' APN %s with" | ||
796 | 316 | " match_data: %s", carrier, mvnomatch); | ||
797 | 317 | return; | ||
798 | 318 | } | ||
799 | 319 | } else if (g_strcmp0(mvnotype, "spn") == 0) { | ||
800 | 320 | DBG("APN %s is mvno_type 'spn'", carrier); | ||
801 | 321 | |||
802 | 322 | if (g_strcmp0(mvnomatch, apndb->match_spn) != 0) { | ||
803 | 323 | DBG("Skipping mvno 'spn' APN %s with" | ||
804 | 324 | " match_data: %s", carrier, mvnomatch); | ||
805 | 325 | return; | ||
806 | 326 | } | ||
807 | 327 | |||
808 | 328 | } else if (g_strcmp0(mvnotype, "gid") == 0) { | ||
809 | 329 | int match_len = strlen(mvnomatch); | ||
810 | 330 | |||
811 | 331 | DBG("APN %s is mvno_type 'gid'", carrier); | ||
812 | 332 | |||
813 | 333 | /* Check initial part of GID1 against match data */ | ||
814 | 334 | if (apndb->match_gid1 == NULL || | ||
815 | 335 | g_ascii_strncasecmp(mvnomatch, | ||
816 | 336 | apndb->match_gid1, | ||
817 | 337 | match_len) != 0) { | ||
818 | 338 | DBG("Skipping mvno 'gid' APN %s with" | ||
819 | 339 | " match_data: %s", carrier, mvnomatch); | ||
820 | 340 | return; | ||
821 | 341 | } | ||
822 | 342 | } | ||
823 | 343 | } | ||
824 | 344 | |||
825 | 345 | type = determine_apn_type(types); | ||
826 | 346 | |||
827 | 347 | if (type == OFONO_GPRS_CONTEXT_TYPE_ANY || | ||
828 | 348 | (type == OFONO_GPRS_CONTEXT_TYPE_MMS && mmsproxy == NULL)) { | ||
829 | 349 | DBG("Skipping %s context; types: %s", apn, types); | ||
830 | 350 | return; | ||
831 | 351 | } | ||
832 | 352 | |||
833 | 353 | ap = g_try_new0(struct apndb_provision_data, 1); | ||
834 | 354 | if (ap == NULL) { | ||
835 | 355 | ofono_error("%s: out-of-memory trying to provision APN - %s", | ||
836 | 356 | __func__, carrier); | ||
837 | 357 | return; | ||
838 | 358 | } | ||
839 | 359 | |||
840 | 360 | ap->gprs_data.type = type; | ||
841 | 361 | |||
842 | 362 | if (carrier != NULL) | ||
843 | 363 | ap->gprs_data.name = g_strdup(carrier); | ||
844 | 364 | |||
845 | 365 | if (apn != NULL) | ||
846 | 366 | ap->gprs_data.apn = g_strdup(apn); | ||
847 | 367 | |||
848 | 368 | if (username != NULL) | ||
849 | 369 | ap->gprs_data.username = g_strdup(username); | ||
850 | 370 | |||
851 | 371 | if (password != NULL) | ||
852 | 372 | ap->gprs_data.password = g_strdup(password); | ||
853 | 373 | |||
854 | 374 | if (mmscenter != NULL && strlen(mmscenter) > 0) | ||
855 | 375 | ap->gprs_data.message_center = g_strdup(mmscenter); | ||
856 | 376 | |||
857 | 377 | if (mmsproxy != NULL && strlen(mmsproxy) > 0) { | ||
858 | 378 | char *tmp = android_apndb_sanitize_ipv4_address(mmsproxy); | ||
859 | 379 | if (tmp != NULL) | ||
860 | 380 | mmsproxy = tmp; | ||
861 | 381 | |||
862 | 382 | if (mmsport != NULL) | ||
863 | 383 | ap->gprs_data.message_proxy = | ||
864 | 384 | g_strdup_printf("%s:%s", mmsproxy, mmsport); | ||
865 | 385 | else | ||
866 | 386 | ap->gprs_data.message_proxy = g_strdup(mmsproxy); | ||
867 | 387 | |||
868 | 388 | g_free(tmp); | ||
869 | 389 | } | ||
870 | 390 | |||
871 | 391 | ap->gprs_data.proto = proto; | ||
872 | 392 | |||
873 | 393 | if (mvnotype != NULL) { | ||
874 | 394 | ap->mvno = TRUE; | ||
875 | 395 | apndb->mvno_found = TRUE; | ||
876 | 396 | } | ||
877 | 397 | |||
878 | 398 | apndb->apns = g_slist_append(apndb->apns, ap); | ||
879 | 399 | } | ||
880 | 400 | |||
881 | 401 | static void toplevel_apndb_end(GMarkupParseContext *context, | ||
882 | 402 | const gchar *element_name, | ||
883 | 403 | gpointer userdata, GError **error) | ||
884 | 404 | { | ||
885 | 405 | } | ||
886 | 406 | |||
887 | 407 | static const GMarkupParser toplevel_apndb_parser = { | ||
888 | 408 | toplevel_apndb_start, | ||
889 | 409 | toplevel_apndb_end, | ||
890 | 410 | NULL, | ||
891 | 411 | NULL, | ||
892 | 412 | NULL, | ||
893 | 413 | }; | ||
894 | 414 | |||
895 | 415 | static gboolean android_apndb_parse(const GMarkupParser *parser, | ||
896 | 416 | gpointer userdata, | ||
897 | 417 | GError **error) | ||
898 | 418 | { | ||
899 | 419 | struct stat st; | ||
900 | 420 | char *db; | ||
901 | 421 | int fd; | ||
902 | 422 | GMarkupParseContext *context; | ||
903 | 423 | gboolean ret; | ||
904 | 424 | const char *apndb_path; | ||
905 | 425 | |||
906 | 426 | if ((apndb_path = getenv("OFONO_APNDB_PATH")) == NULL) | ||
907 | 427 | apndb_path = ANDROID_APN_DATABASE; | ||
908 | 428 | |||
909 | 429 | fd = open(apndb_path, O_RDONLY); | ||
910 | 430 | if (fd < 0) { | ||
911 | 431 | g_set_error(error, G_FILE_ERROR, | ||
912 | 432 | g_file_error_from_errno(errno), | ||
913 | 433 | "open(%s) failed: %s", apndb_path, | ||
914 | 434 | g_strerror(errno)); | ||
915 | 435 | return FALSE; | ||
916 | 436 | } | ||
917 | 437 | |||
918 | 438 | if (fstat(fd, &st) < 0) { | ||
919 | 439 | close(fd); | ||
920 | 440 | g_set_error(error, G_FILE_ERROR, | ||
921 | 441 | g_file_error_from_errno(errno), | ||
922 | 442 | "fstat(%s) failed: %s", apndb_path, | ||
923 | 443 | g_strerror(errno)); | ||
924 | 444 | return FALSE; | ||
925 | 445 | } | ||
926 | 446 | |||
927 | 447 | db = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); | ||
928 | 448 | if (db == MAP_FAILED) { | ||
929 | 449 | close(fd); | ||
930 | 450 | g_set_error(error, G_FILE_ERROR, | ||
931 | 451 | g_file_error_from_errno(errno), | ||
932 | 452 | "mmap(%s) failed: %s", apndb_path, | ||
933 | 453 | g_strerror(errno)); | ||
934 | 454 | return FALSE; | ||
935 | 455 | } | ||
936 | 456 | |||
937 | 457 | context = g_markup_parse_context_new(parser, | ||
938 | 458 | G_MARKUP_TREAT_CDATA_AS_TEXT, | ||
939 | 459 | userdata, NULL); | ||
940 | 460 | |||
941 | 461 | ret = g_markup_parse_context_parse(context, db, st.st_size, error); | ||
942 | 462 | |||
943 | 463 | if (ret == TRUE) | ||
944 | 464 | g_markup_parse_context_end_parse(context, error); | ||
945 | 465 | |||
946 | 466 | munmap(db, st.st_size); | ||
947 | 467 | close(fd); | ||
948 | 468 | g_markup_parse_context_free(context); | ||
949 | 469 | |||
950 | 470 | return ret; | ||
951 | 471 | } | ||
952 | 472 | |||
953 | 473 | GSList *android_apndb_lookup_apn(const char *mcc, const char *mnc, | ||
954 | 474 | const char *spn, const char *imsi, const char *gid1, | ||
955 | 475 | gboolean *mvno_found, GError **error) | ||
956 | 476 | { | ||
957 | 477 | struct apndb_data apndb = { NULL }; | ||
958 | 478 | |||
959 | 479 | apndb.match_mcc = mcc; | ||
960 | 480 | apndb.match_mnc = mnc; | ||
961 | 481 | apndb.match_spn = spn; | ||
962 | 482 | apndb.match_imsi = imsi; | ||
963 | 483 | apndb.match_gid1 = gid1; | ||
964 | 484 | |||
965 | 485 | if (android_apndb_parse(&toplevel_apndb_parser, &apndb, | ||
966 | 486 | error) == FALSE) { | ||
967 | 487 | g_slist_free_full(apndb.apns, android_apndb_ap_free); | ||
968 | 488 | apndb.apns = NULL; | ||
969 | 489 | } | ||
970 | 490 | |||
971 | 491 | *mvno_found = apndb.mvno_found; | ||
972 | 492 | |||
973 | 493 | return apndb.apns; | ||
974 | 494 | } | ||
975 | 495 | 0 | ||
976 | === removed file 'plugins/android-apndb.h' | |||
977 | --- plugins/android-apndb.h 2014-04-14 13:59:23 +0000 | |||
978 | +++ plugins/android-apndb.h 1970-01-01 00:00:00 +0000 | |||
979 | @@ -1,33 +0,0 @@ | |||
980 | 1 | /* | ||
981 | 2 | * | ||
982 | 3 | * oFono - Open Source Telephony | ||
983 | 4 | * | ||
984 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
985 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
986 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
987 | 8 | * | ||
988 | 9 | * This program is free software; you can redistribute it and/or modify | ||
989 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
990 | 11 | * published by the Free Software Foundation. | ||
991 | 12 | * | ||
992 | 13 | * This program is distributed in the hope that it will be useful, | ||
993 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
994 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
995 | 16 | * GNU General Public License for more details. | ||
996 | 17 | * | ||
997 | 18 | * You should have received a copy of the GNU General Public License | ||
998 | 19 | * along with this program; if not, write to the Free Software | ||
999 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1000 | 21 | * | ||
1001 | 22 | */ | ||
1002 | 23 | |||
1003 | 24 | struct apndb_provision_data { | ||
1004 | 25 | struct ofono_gprs_provision_data gprs_data; | ||
1005 | 26 | gboolean mvno; | ||
1006 | 27 | }; | ||
1007 | 28 | |||
1008 | 29 | void android_apndb_ap_free(gpointer data); | ||
1009 | 30 | |||
1010 | 31 | GSList *android_apndb_lookup_apn(const char *mcc, const char *mnc, | ||
1011 | 32 | const char *spn, const char *imsi, const char *gid1, | ||
1012 | 33 | gboolean *mvno_found, GError **error); | ||
1013 | 34 | 0 | ||
1014 | === removed file 'plugins/android-provision.c' | |||
1015 | --- plugins/android-provision.c 2014-05-13 17:15:55 +0000 | |||
1016 | +++ plugins/android-provision.c 1970-01-01 00:00:00 +0000 | |||
1017 | @@ -1,227 +0,0 @@ | |||
1018 | 1 | /* | ||
1019 | 2 | * | ||
1020 | 3 | * oFono - Open Source Telephony | ||
1021 | 4 | * | ||
1022 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
1023 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
1024 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
1025 | 8 | * | ||
1026 | 9 | * This program is free software; you can redistribute it and/or modify | ||
1027 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
1028 | 11 | * published by the Free Software Foundation. | ||
1029 | 12 | * | ||
1030 | 13 | * This program is distributed in the hope that it will be useful, | ||
1031 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1032 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1033 | 16 | * GNU General Public License for more details. | ||
1034 | 17 | * | ||
1035 | 18 | * You should have received a copy of the GNU General Public License | ||
1036 | 19 | * along with this program; if not, write to the Free Software | ||
1037 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1038 | 21 | * | ||
1039 | 22 | */ | ||
1040 | 23 | |||
1041 | 24 | #ifdef HAVE_CONFIG_H | ||
1042 | 25 | #include <config.h> | ||
1043 | 26 | #endif | ||
1044 | 27 | |||
1045 | 28 | #include <errno.h> | ||
1046 | 29 | #include <string.h> | ||
1047 | 30 | |||
1048 | 31 | #include <glib.h> | ||
1049 | 32 | |||
1050 | 33 | #define OFONO_API_SUBJECT_TO_CHANGE | ||
1051 | 34 | #include <ofono/types.h> | ||
1052 | 35 | #include <ofono/log.h> | ||
1053 | 36 | #include <ofono/plugin.h> | ||
1054 | 37 | #include <ofono/modem.h> | ||
1055 | 38 | #include <ofono/gprs-provision.h> | ||
1056 | 39 | |||
1057 | 40 | #include "android-apndb.h" | ||
1058 | 41 | #include "mbpi.h" | ||
1059 | 42 | |||
1060 | 43 | static unsigned int filter_apns(GSList **apns, GSList *mbpi_apns, | ||
1061 | 44 | gboolean mvno_found) | ||
1062 | 45 | { | ||
1063 | 46 | GSList *l = NULL; | ||
1064 | 47 | GSList *l2 = NULL; | ||
1065 | 48 | gboolean found = FALSE; | ||
1066 | 49 | unsigned int ap_count = g_slist_length(*apns); | ||
1067 | 50 | struct apndb_provision_data *ap; | ||
1068 | 51 | |||
1069 | 52 | if (mvno_found == TRUE) { | ||
1070 | 53 | |||
1071 | 54 | for (l = *apns; l;) { | ||
1072 | 55 | ap = l->data; | ||
1073 | 56 | l = l->next; | ||
1074 | 57 | |||
1075 | 58 | if (ap->mvno == FALSE) { | ||
1076 | 59 | DBG("Removing: %s", ap->gprs_data.apn); | ||
1077 | 60 | *apns = g_slist_remove(*apns, | ||
1078 | 61 | (gconstpointer) ap); | ||
1079 | 62 | android_apndb_ap_free(ap); | ||
1080 | 63 | ap_count--; | ||
1081 | 64 | } | ||
1082 | 65 | } | ||
1083 | 66 | |||
1084 | 67 | goto done; | ||
1085 | 68 | } | ||
1086 | 69 | |||
1087 | 70 | for (l = mbpi_apns; l; l = l->next, found = FALSE) { | ||
1088 | 71 | struct ofono_gprs_provision_data *ap2 = l->data; | ||
1089 | 72 | |||
1090 | 73 | if (ap2->apn == NULL) { | ||
1091 | 74 | ofono_error("%s: invalid mbpi entry - %s found", | ||
1092 | 75 | __func__, ap2->name); | ||
1093 | 76 | continue; | ||
1094 | 77 | } | ||
1095 | 78 | |||
1096 | 79 | for (l2 = *apns; l2; l2 = l2->next) { | ||
1097 | 80 | ap = l2->data; | ||
1098 | 81 | |||
1099 | 82 | if (ap->gprs_data.apn != NULL && | ||
1100 | 83 | ap->gprs_data.type == | ||
1101 | 84 | OFONO_GPRS_CONTEXT_TYPE_INTERNET && | ||
1102 | 85 | g_strcmp0(ap2->apn, ap->gprs_data.apn) == 0) { | ||
1103 | 86 | |||
1104 | 87 | found = TRUE; | ||
1105 | 88 | break; | ||
1106 | 89 | } | ||
1107 | 90 | } | ||
1108 | 91 | |||
1109 | 92 | if (found == FALSE) { | ||
1110 | 93 | DBG("Adding %s to apns", ap2->apn); | ||
1111 | 94 | |||
1112 | 95 | ap = g_try_new0(struct apndb_provision_data, 1); | ||
1113 | 96 | if (ap == NULL) { | ||
1114 | 97 | ofono_error("%s: out-of-memory trying to" | ||
1115 | 98 | " provision APN - %s", | ||
1116 | 99 | __func__, ap2->name); | ||
1117 | 100 | goto done; | ||
1118 | 101 | } | ||
1119 | 102 | |||
1120 | 103 | memcpy(&ap->gprs_data, ap2, sizeof(ap->gprs_data)); | ||
1121 | 104 | *apns = g_slist_append(*apns, ap); | ||
1122 | 105 | ap_count++; | ||
1123 | 106 | g_free(ap2); | ||
1124 | 107 | } else { | ||
1125 | 108 | mbpi_ap_free(ap2); | ||
1126 | 109 | } | ||
1127 | 110 | } | ||
1128 | 111 | |||
1129 | 112 | done: | ||
1130 | 113 | return ap_count; | ||
1131 | 114 | } | ||
1132 | 115 | |||
1133 | 116 | static int provision_get_settings(const char *mcc, const char *mnc, | ||
1134 | 117 | const char *spn, | ||
1135 | 118 | const char *imsi, const char *gid1, | ||
1136 | 119 | struct ofono_gprs_provision_data **settings, | ||
1137 | 120 | int *count) | ||
1138 | 121 | { | ||
1139 | 122 | GSList *apns = NULL; | ||
1140 | 123 | GSList *mbpi_apns = NULL; | ||
1141 | 124 | GSList *l = NULL; | ||
1142 | 125 | GError *error = NULL; | ||
1143 | 126 | gboolean mvno_found = FALSE; | ||
1144 | 127 | unsigned int ap_count; | ||
1145 | 128 | unsigned int i; | ||
1146 | 129 | |||
1147 | 130 | ofono_info("Provisioning for MCC %s, MNC %s, SPN '%s', IMSI '%s', " | ||
1148 | 131 | "GID1 '%s'", mcc, mnc, spn, imsi, gid1); | ||
1149 | 132 | |||
1150 | 133 | apns = android_apndb_lookup_apn(mcc, mnc, spn, imsi, gid1, | ||
1151 | 134 | &mvno_found, &error); | ||
1152 | 135 | if (apns == NULL) { | ||
1153 | 136 | if (error != NULL) { | ||
1154 | 137 | ofono_error("%s: apndb_lookup error -%s for mcc %s" | ||
1155 | 138 | " mnc %s spn %s imsi %s", __func__, | ||
1156 | 139 | error->message, mcc, mnc, spn, imsi); | ||
1157 | 140 | g_error_free(error); | ||
1158 | 141 | error = NULL; | ||
1159 | 142 | } | ||
1160 | 143 | } | ||
1161 | 144 | |||
1162 | 145 | /* If an mvno apn was found, only provision mvno apns */ | ||
1163 | 146 | if (mvno_found == FALSE) { | ||
1164 | 147 | mbpi_apns = mbpi_lookup_apn(mcc, mnc, | ||
1165 | 148 | OFONO_GPRS_CONTEXT_TYPE_INTERNET, | ||
1166 | 149 | TRUE, &error); | ||
1167 | 150 | if (mbpi_apns == NULL) { | ||
1168 | 151 | if (error != NULL) { | ||
1169 | 152 | ofono_error("%s: MBPI error - %s for mcc %s" | ||
1170 | 153 | " mnc %s spn: %s", __func__, | ||
1171 | 154 | error->message, mcc, mnc, spn); | ||
1172 | 155 | g_error_free(error); | ||
1173 | 156 | error = NULL; | ||
1174 | 157 | } | ||
1175 | 158 | } | ||
1176 | 159 | } | ||
1177 | 160 | |||
1178 | 161 | ap_count = filter_apns(&apns, mbpi_apns, mvno_found); | ||
1179 | 162 | if (ap_count == 0) { | ||
1180 | 163 | ofono_warn("%s: No APNs found for mcc %s mnc %s spn: %s" | ||
1181 | 164 | " imsi: %s", __func__, mcc, mnc, spn, imsi); | ||
1182 | 165 | |||
1183 | 166 | *count = 0; | ||
1184 | 167 | return -ENOENT; | ||
1185 | 168 | } | ||
1186 | 169 | |||
1187 | 170 | *settings = g_try_new0(struct ofono_gprs_provision_data, ap_count); | ||
1188 | 171 | if (*settings == NULL) { | ||
1189 | 172 | ofono_error("%s: provisioning failed: %s", __func__, | ||
1190 | 173 | g_strerror(errno)); | ||
1191 | 174 | |||
1192 | 175 | g_slist_free_full(apns, android_apndb_ap_free); | ||
1193 | 176 | |||
1194 | 177 | *count = 0; | ||
1195 | 178 | return -ENOMEM; | ||
1196 | 179 | } | ||
1197 | 180 | |||
1198 | 181 | *count = ap_count; | ||
1199 | 182 | |||
1200 | 183 | for (l = apns, i = 0; l; l = l->next, i++) { | ||
1201 | 184 | struct apndb_provision_data *ap = l->data; | ||
1202 | 185 | |||
1203 | 186 | DBG("Name: '%s'", ap->gprs_data.name); | ||
1204 | 187 | DBG("APN: '%s'", ap->gprs_data.apn); | ||
1205 | 188 | DBG("Type: %s", mbpi_ap_type(ap->gprs_data.type)); | ||
1206 | 189 | DBG("Username: '%s'", ap->gprs_data.username); | ||
1207 | 190 | DBG("Password: '%s'", ap->gprs_data.password); | ||
1208 | 191 | DBG("Message Proxy: '%s'", ap->gprs_data.message_proxy); | ||
1209 | 192 | DBG("Message Center: '%s'", ap->gprs_data.message_center); | ||
1210 | 193 | DBG("MVNO: %u", ap->mvno); | ||
1211 | 194 | |||
1212 | 195 | memcpy(*settings + i, &ap->gprs_data, sizeof(ap->gprs_data)); | ||
1213 | 196 | |||
1214 | 197 | g_free(ap); | ||
1215 | 198 | } | ||
1216 | 199 | |||
1217 | 200 | if (apns != NULL) | ||
1218 | 201 | g_slist_free(apns); | ||
1219 | 202 | |||
1220 | 203 | if (mbpi_apns != NULL) | ||
1221 | 204 | g_slist_free(mbpi_apns); | ||
1222 | 205 | |||
1223 | 206 | return 0; | ||
1224 | 207 | } | ||
1225 | 208 | |||
1226 | 209 | static struct ofono_gprs_provision_driver android_provision_driver = { | ||
1227 | 210 | .name = "Android APN database Provisioning", | ||
1228 | 211 | .get_settings = provision_get_settings | ||
1229 | 212 | }; | ||
1230 | 213 | |||
1231 | 214 | static int android_provision_init(void) | ||
1232 | 215 | { | ||
1233 | 216 | return ofono_gprs_provision_driver_register(&android_provision_driver); | ||
1234 | 217 | } | ||
1235 | 218 | |||
1236 | 219 | static void android_provision_exit(void) | ||
1237 | 220 | { | ||
1238 | 221 | ofono_gprs_provision_driver_unregister(&android_provision_driver); | ||
1239 | 222 | } | ||
1240 | 223 | |||
1241 | 224 | OFONO_PLUGIN_DEFINE(android_provision, | ||
1242 | 225 | "Android APN database Provisioning Plugin", VERSION, | ||
1243 | 226 | OFONO_PLUGIN_PRIORITY_DEFAULT, | ||
1244 | 227 | android_provision_init, android_provision_exit) | ||
1245 | 228 | 0 | ||
1246 | === added file 'plugins/infineon.c' | |||
1247 | --- plugins/infineon.c 1970-01-01 00:00:00 +0000 | |||
1248 | +++ plugins/infineon.c 2014-07-21 18:55:43 +0000 | |||
1249 | @@ -0,0 +1,76 @@ | |||
1250 | 1 | /* | ||
1251 | 2 | * | ||
1252 | 3 | * oFono - Open Source Telephony - RIL-based devices: infineon modems | ||
1253 | 4 | * | ||
1254 | 5 | * Copyright (C) 2014 Canonical Ltd. | ||
1255 | 6 | * | ||
1256 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1257 | 8 | * it under the terms of the GNU General Public License version 2 as | ||
1258 | 9 | * published by the Free Software Foundation. | ||
1259 | 10 | * | ||
1260 | 11 | * This program is distributed in the hope that it will be useful, | ||
1261 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1262 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1263 | 14 | * GNU General Public License for more details. | ||
1264 | 15 | * | ||
1265 | 16 | * You should have received a copy of the GNU General Public License | ||
1266 | 17 | * along with this program; if not, write to the Free Software | ||
1267 | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1268 | 19 | * | ||
1269 | 20 | */ | ||
1270 | 21 | |||
1271 | 22 | #ifdef HAVE_CONFIG_H | ||
1272 | 23 | #include <config.h> | ||
1273 | 24 | #endif | ||
1274 | 25 | |||
1275 | 26 | #define OFONO_API_SUBJECT_TO_CHANGE | ||
1276 | 27 | |||
1277 | 28 | #include <ofono/plugin.h> | ||
1278 | 29 | #include <ofono/log.h> | ||
1279 | 30 | #include <ofono/modem.h> | ||
1280 | 31 | |||
1281 | 32 | #include "ofono.h" | ||
1282 | 33 | |||
1283 | 34 | #include "drivers/rilmodem/vendor.h" | ||
1284 | 35 | #include "ril.h" | ||
1285 | 36 | |||
1286 | 37 | static int inf_probe(struct ofono_modem *modem) | ||
1287 | 38 | { | ||
1288 | 39 | return ril_create(modem, OFONO_RIL_VENDOR_INFINEON); | ||
1289 | 40 | } | ||
1290 | 41 | |||
1291 | 42 | static struct ofono_modem_driver infineon_driver = { | ||
1292 | 43 | .name = "infineon", | ||
1293 | 44 | .probe = inf_probe, | ||
1294 | 45 | .remove = ril_remove, | ||
1295 | 46 | .enable = ril_enable, | ||
1296 | 47 | .disable = ril_disable, | ||
1297 | 48 | .pre_sim = ril_pre_sim, | ||
1298 | 49 | .post_sim = ril_post_sim, | ||
1299 | 50 | .post_online = ril_post_online, | ||
1300 | 51 | .set_online = ril_set_online, | ||
1301 | 52 | }; | ||
1302 | 53 | |||
1303 | 54 | /* | ||
1304 | 55 | * This plugin is a device plugin for infineon modems that use RIL interface. | ||
1305 | 56 | * The plugin 'rildev' is used to determine which RIL plugin should be loaded | ||
1306 | 57 | * based upon an environment variable. | ||
1307 | 58 | */ | ||
1308 | 59 | static int inf_init(void) | ||
1309 | 60 | { | ||
1310 | 61 | int retval = 0; | ||
1311 | 62 | |||
1312 | 63 | if ((retval = ofono_modem_driver_register(&infineon_driver))) | ||
1313 | 64 | DBG("ofono_modem_driver_register returned: %d", retval); | ||
1314 | 65 | |||
1315 | 66 | return retval; | ||
1316 | 67 | } | ||
1317 | 68 | |||
1318 | 69 | static void inf_exit(void) | ||
1319 | 70 | { | ||
1320 | 71 | DBG(""); | ||
1321 | 72 | ofono_modem_driver_unregister(&infineon_driver); | ||
1322 | 73 | } | ||
1323 | 74 | |||
1324 | 75 | OFONO_PLUGIN_DEFINE(infineon, "Infineon modem driver", VERSION, | ||
1325 | 76 | OFONO_PLUGIN_PRIORITY_DEFAULT, inf_init, inf_exit) | ||
1326 | 0 | 77 | ||
1327 | === modified file 'plugins/mtk.c' | |||
1328 | --- plugins/mtk.c 2014-06-12 10:52:45 +0000 | |||
1329 | +++ plugins/mtk.c 2014-07-21 18:55:43 +0000 | |||
1330 | @@ -92,6 +92,8 @@ | |||
1331 | 92 | int slot; | 92 | int slot; |
1332 | 93 | struct ril_sim_data sim_data; | 93 | struct ril_sim_data sim_data; |
1333 | 94 | struct ofono_devinfo *devinfo; | 94 | struct ofono_devinfo *devinfo; |
1334 | 95 | struct cb_data *pending_online_cbd; | ||
1335 | 96 | ofono_bool_t pending_online; | ||
1336 | 95 | }; | 97 | }; |
1337 | 96 | 98 | ||
1338 | 97 | /* | 99 | /* |
1339 | @@ -106,6 +108,8 @@ | |||
1340 | 106 | static void send_get_sim_status(struct ofono_modem *modem); | 108 | static void send_get_sim_status(struct ofono_modem *modem); |
1341 | 107 | static int create_gril(struct ofono_modem *modem); | 109 | static int create_gril(struct ofono_modem *modem); |
1342 | 108 | static gboolean mtk_connected(gpointer user_data); | 110 | static gboolean mtk_connected(gpointer user_data); |
1343 | 111 | static void mtk_set_online(struct ofono_modem *modem, ofono_bool_t online, | ||
1344 | 112 | ofono_modem_online_cb_t callback, void *data); | ||
1345 | 109 | 113 | ||
1346 | 110 | static void mtk_debug(const char *str, void *user_data) | 114 | static void mtk_debug(const char *str, void *user_data) |
1347 | 111 | { | 115 | { |
1348 | @@ -372,14 +376,23 @@ | |||
1349 | 372 | send_get_sim_status(modem); | 376 | send_get_sim_status(modem); |
1350 | 373 | } | 377 | } |
1351 | 374 | 378 | ||
1352 | 379 | static struct mtk_data *ril_complement(struct mtk_data *ril) | ||
1353 | 380 | { | ||
1354 | 381 | if (ril->slot == MULTISIM_SLOT_0) | ||
1355 | 382 | return mtk_1; | ||
1356 | 383 | else | ||
1357 | 384 | return mtk_0; | ||
1358 | 385 | } | ||
1359 | 386 | |||
1360 | 375 | static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data) | 387 | static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data) |
1361 | 376 | { | 388 | { |
1362 | 377 | struct cb_data *cbd = user_data; | 389 | struct cb_data *cbd = user_data; |
1363 | 378 | ofono_modem_online_cb_t cb = cbd->cb; | 390 | ofono_modem_online_cb_t cb = cbd->cb; |
1364 | 379 | struct ofono_modem *modem = cbd->user; | 391 | struct ofono_modem *modem = cbd->user; |
1365 | 380 | struct mtk_data *ril = ofono_modem_get_data(modem); | 392 | struct mtk_data *ril = ofono_modem_get_data(modem); |
1366 | 393 | struct mtk_data *ril_c; | ||
1367 | 381 | 394 | ||
1369 | 382 | ril->pending_cb = NULL; | 395 | mtk_0->pending_cb = NULL; |
1370 | 383 | 396 | ||
1371 | 384 | if (message->error == RIL_E_SUCCESS) { | 397 | if (message->error == RIL_E_SUCCESS) { |
1372 | 385 | g_ril_print_response_no_args(ril->modem, message); | 398 | g_ril_print_response_no_args(ril->modem, message); |
1373 | @@ -390,6 +403,21 @@ | |||
1374 | 390 | ril_error_to_string(message->error)); | 403 | ril_error_to_string(message->error)); |
1375 | 391 | CALLBACK_WITH_FAILURE(cb, cbd->data); | 404 | CALLBACK_WITH_FAILURE(cb, cbd->data); |
1376 | 392 | } | 405 | } |
1377 | 406 | |||
1378 | 407 | /* Execute possible pending operation on the other modem */ | ||
1379 | 408 | |||
1380 | 409 | ril_c = ril_complement(ril); | ||
1381 | 410 | |||
1382 | 411 | if (ril_c->pending_online_cbd) { | ||
1383 | 412 | struct cb_data *pending_cbd = ril_c->pending_online_cbd; | ||
1384 | 413 | ofono_modem_online_cb_t pending_cb = pending_cbd->cb; | ||
1385 | 414 | |||
1386 | 415 | mtk_set_online(pending_cbd->user, ril_c->pending_online, | ||
1387 | 416 | pending_cb, pending_cbd->data); | ||
1388 | 417 | |||
1389 | 418 | g_free(ril_c->pending_online_cbd); | ||
1390 | 419 | ril_c->pending_online_cbd = NULL; | ||
1391 | 420 | } | ||
1392 | 393 | } | 421 | } |
1393 | 394 | 422 | ||
1394 | 395 | static int sim_state() | 423 | static int sim_state() |
1395 | @@ -484,6 +512,25 @@ | |||
1396 | 484 | ofono_modem_online_cb_t cb = cbd->cb; | 512 | ofono_modem_online_cb_t cb = cbd->cb; |
1397 | 485 | int current_state, next_state; | 513 | int current_state, next_state; |
1398 | 486 | 514 | ||
1399 | 515 | /* | ||
1400 | 516 | * Serialize online requests to avoid incoherent states. When changing | ||
1401 | 517 | * the online state of *one* of the modems, we need to send a | ||
1402 | 518 | * DUAL_SIM_MODE_SWITCH request, which affects *both* modems. Also, when | ||
1403 | 519 | * we want to online one modem and at that time both modems are | ||
1404 | 520 | * offline a RADIO_POWERON needs to be sent before DUAL_SIM_MODE_SWITCH, | ||
1405 | 521 | * with the additional complexity of being disconnected from the rild | ||
1406 | 522 | * socket while doing the sequence. This can take some time, and we | ||
1407 | 523 | * cannot change the state of the other modem while the sequence is | ||
1408 | 524 | * happenig, as DUAL_SIM_MODE_SWITCH affects both states. Therefore, we | ||
1409 | 525 | * need to do this serialization, which is different from the one done | ||
1410 | 526 | * per modem by ofono core. | ||
1411 | 527 | */ | ||
1412 | 528 | if (mtk_0->pending_cb != NULL) { | ||
1413 | 529 | ril->pending_online_cbd = cbd; | ||
1414 | 530 | ril->pending_online = online; | ||
1415 | 531 | return; | ||
1416 | 532 | } | ||
1417 | 533 | |||
1418 | 487 | current_state = sim_state(); | 534 | current_state = sim_state(); |
1419 | 488 | 535 | ||
1420 | 489 | ril->ofono_online = online; | 536 | ril->ofono_online = online; |
1421 | 490 | 537 | ||
1422 | === modified file 'plugins/ril.c' | |||
1423 | --- plugins/ril.c 2014-06-24 18:59:26 +0000 | |||
1424 | +++ plugins/ril.c 2014-07-21 18:55:43 +0000 | |||
1425 | @@ -60,6 +60,7 @@ | |||
1426 | 60 | #include <grilrequest.h> | 60 | #include <grilrequest.h> |
1427 | 61 | #include <grilunsol.h> | 61 | #include <grilunsol.h> |
1428 | 62 | 62 | ||
1429 | 63 | #include "ril.h" | ||
1430 | 63 | #include "drivers/rilmodem/rilmodem.h" | 64 | #include "drivers/rilmodem/rilmodem.h" |
1431 | 64 | #include "drivers/rilmodem/vendor.h" | 65 | #include "drivers/rilmodem/vendor.h" |
1432 | 65 | 66 | ||
1433 | @@ -69,6 +70,7 @@ | |||
1434 | 69 | 70 | ||
1435 | 70 | struct ril_data { | 71 | struct ril_data { |
1436 | 71 | GRil *modem; | 72 | GRil *modem; |
1437 | 73 | enum ofono_ril_vendor vendor; | ||
1438 | 72 | int sim_status_retries; | 74 | int sim_status_retries; |
1439 | 73 | ofono_bool_t connected; | 75 | ofono_bool_t connected; |
1440 | 74 | ofono_bool_t have_sim; | 76 | ofono_bool_t have_sim; |
1441 | @@ -118,7 +120,7 @@ | |||
1442 | 118 | if (ril->voice == NULL) | 120 | if (ril->voice == NULL) |
1443 | 119 | ril->voice = | 121 | ril->voice = |
1444 | 120 | ofono_voicecall_create(modem, | 122 | ofono_voicecall_create(modem, |
1446 | 121 | 0, | 123 | ril->vendor, |
1447 | 122 | RILMODEM, | 124 | RILMODEM, |
1448 | 123 | ril->modem); | 125 | ril->modem); |
1449 | 124 | 126 | ||
1450 | @@ -205,7 +207,7 @@ | |||
1451 | 205 | sim_status_cb, modem, NULL); | 207 | sim_status_cb, modem, NULL); |
1452 | 206 | } | 208 | } |
1453 | 207 | 209 | ||
1455 | 208 | static int ril_probe(struct ofono_modem *modem) | 210 | int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor) |
1456 | 209 | { | 211 | { |
1457 | 210 | struct ril_data *ril = g_try_new0(struct ril_data, 1); | 212 | struct ril_data *ril = g_try_new0(struct ril_data, 1); |
1458 | 211 | if (ril == NULL) { | 213 | if (ril == NULL) { |
1459 | @@ -215,6 +217,7 @@ | |||
1460 | 215 | 217 | ||
1461 | 216 | DBG(""); | 218 | DBG(""); |
1462 | 217 | 219 | ||
1463 | 220 | ril->vendor = vendor; | ||
1464 | 218 | ril->have_sim = FALSE; | 221 | ril->have_sim = FALSE; |
1465 | 219 | ril->ofono_online = FALSE; | 222 | ril->ofono_online = FALSE; |
1466 | 220 | ril->radio_state = RADIO_STATE_OFF; | 223 | ril->radio_state = RADIO_STATE_OFF; |
1467 | @@ -229,11 +232,15 @@ | |||
1468 | 229 | return -errno; | 232 | return -errno; |
1469 | 230 | } | 233 | } |
1470 | 231 | 234 | ||
1472 | 232 | static void ril_remove(struct ofono_modem *modem) | 235 | static int ril_probe(struct ofono_modem *modem) |
1473 | 236 | { | ||
1474 | 237 | return ril_create(modem, OFONO_RIL_VENDOR_AOSP); | ||
1475 | 238 | } | ||
1476 | 239 | |||
1477 | 240 | void ril_remove(struct ofono_modem *modem) | ||
1478 | 233 | { | 241 | { |
1479 | 234 | struct ril_data *ril = ofono_modem_get_data(modem); | 242 | struct ril_data *ril = ofono_modem_get_data(modem); |
1480 | 235 | 243 | ||
1481 | 236 | |||
1482 | 237 | ofono_modem_set_data(modem, NULL); | 244 | ofono_modem_set_data(modem, NULL); |
1483 | 238 | 245 | ||
1484 | 239 | if (!ril) | 246 | if (!ril) |
1485 | @@ -244,24 +251,24 @@ | |||
1486 | 244 | g_free(ril); | 251 | g_free(ril); |
1487 | 245 | } | 252 | } |
1488 | 246 | 253 | ||
1490 | 247 | static void ril_pre_sim(struct ofono_modem *modem) | 254 | void ril_pre_sim(struct ofono_modem *modem) |
1491 | 248 | { | 255 | { |
1492 | 249 | struct ril_data *ril = ofono_modem_get_data(modem); | 256 | struct ril_data *ril = ofono_modem_get_data(modem); |
1493 | 250 | struct ril_sim_data sim_data; | 257 | struct ril_sim_data sim_data; |
1494 | 251 | 258 | ||
1495 | 252 | DBG(""); | 259 | DBG(""); |
1496 | 253 | 260 | ||
1498 | 254 | ofono_devinfo_create(modem, 0, RILMODEM, ril->modem); | 261 | ofono_devinfo_create(modem, ril->vendor, RILMODEM, ril->modem); |
1499 | 255 | 262 | ||
1500 | 256 | sim_data.gril = ril->modem; | 263 | sim_data.gril = ril->modem; |
1501 | 257 | sim_data.modem = modem; | 264 | sim_data.modem = modem; |
1502 | 258 | sim_data.ril_state_watch = NULL; | 265 | sim_data.ril_state_watch = NULL; |
1503 | 259 | 266 | ||
1505 | 260 | ril->sim = ofono_sim_create(modem, 0, RILMODEM, &sim_data); | 267 | ril->sim = ofono_sim_create(modem, ril->vendor, RILMODEM, &sim_data); |
1506 | 261 | g_assert(ril->sim != NULL); | 268 | g_assert(ril->sim != NULL); |
1507 | 262 | } | 269 | } |
1508 | 263 | 270 | ||
1510 | 264 | static void ril_post_sim(struct ofono_modem *modem) | 271 | void ril_post_sim(struct ofono_modem *modem) |
1511 | 265 | { | 272 | { |
1512 | 266 | struct ril_data *ril = ofono_modem_get_data(modem); | 273 | struct ril_data *ril = ofono_modem_get_data(modem); |
1513 | 267 | struct ofono_gprs *gprs; | 274 | struct ofono_gprs *gprs; |
1514 | @@ -273,10 +280,11 @@ | |||
1515 | 273 | * - stk ( SIM toolkit ) | 280 | * - stk ( SIM toolkit ) |
1516 | 274 | * - radio_settings | 281 | * - radio_settings |
1517 | 275 | */ | 282 | */ |
1519 | 276 | ofono_sms_create(modem, 0, RILMODEM, ril->modem); | 283 | ofono_sms_create(modem, ril->vendor, RILMODEM, ril->modem); |
1520 | 277 | 284 | ||
1523 | 278 | gprs = ofono_gprs_create(modem, 0, RILMODEM, ril->modem); | 285 | gprs = ofono_gprs_create(modem, ril->vendor, RILMODEM, ril->modem); |
1524 | 279 | gc = ofono_gprs_context_create(modem, 0, RILMODEM, ril->modem); | 286 | gc = ofono_gprs_context_create(modem, ril->vendor, |
1525 | 287 | RILMODEM, ril->modem); | ||
1526 | 280 | 288 | ||
1527 | 281 | if (gc) { | 289 | if (gc) { |
1528 | 282 | ofono_gprs_context_set_type(gc, | 290 | ofono_gprs_context_set_type(gc, |
1529 | @@ -284,7 +292,8 @@ | |||
1530 | 284 | ofono_gprs_add_context(gprs, gc); | 292 | ofono_gprs_add_context(gprs, gc); |
1531 | 285 | } | 293 | } |
1532 | 286 | 294 | ||
1534 | 287 | gc = ofono_gprs_context_create(modem, 0, RILMODEM, ril->modem); | 295 | gc = ofono_gprs_context_create(modem, ril->vendor, |
1535 | 296 | RILMODEM, ril->modem); | ||
1536 | 288 | 297 | ||
1537 | 289 | if (gc) { | 298 | if (gc) { |
1538 | 290 | ofono_gprs_context_set_type(gc, | 299 | ofono_gprs_context_set_type(gc, |
1539 | @@ -296,19 +305,19 @@ | |||
1540 | 296 | if (mw) | 305 | if (mw) |
1541 | 297 | ofono_message_waiting_register(mw); | 306 | ofono_message_waiting_register(mw); |
1542 | 298 | 307 | ||
1544 | 299 | ofono_call_forwarding_create(modem, 0, RILMODEM, ril->modem); | 308 | ofono_call_forwarding_create(modem, ril->vendor, RILMODEM, ril->modem); |
1545 | 300 | } | 309 | } |
1546 | 301 | 310 | ||
1548 | 302 | static void ril_post_online(struct ofono_modem *modem) | 311 | void ril_post_online(struct ofono_modem *modem) |
1549 | 303 | { | 312 | { |
1550 | 304 | struct ril_data *ril = ofono_modem_get_data(modem); | 313 | struct ril_data *ril = ofono_modem_get_data(modem); |
1551 | 305 | 314 | ||
1558 | 306 | ofono_call_volume_create(modem, 0, RILMODEM, ril->modem); | 315 | ofono_call_volume_create(modem, ril->vendor, RILMODEM, ril->modem); |
1559 | 307 | ofono_netreg_create(modem, 0, RILMODEM, ril->modem); | 316 | ofono_netreg_create(modem, ril->vendor, RILMODEM, ril->modem); |
1560 | 308 | ofono_ussd_create(modem, 0, RILMODEM, ril->modem); | 317 | ofono_ussd_create(modem, ril->vendor, RILMODEM, ril->modem); |
1561 | 309 | ofono_call_settings_create(modem, 0, RILMODEM, ril->modem); | 318 | ofono_call_settings_create(modem, ril->vendor, RILMODEM, ril->modem); |
1562 | 310 | ofono_radio_settings_create(modem, 0, RILMODEM, ril->modem); | 319 | ofono_radio_settings_create(modem, ril->vendor, RILMODEM, ril->modem); |
1563 | 311 | ofono_call_barring_create(modem, 0, RILMODEM, ril->modem); | 320 | ofono_call_barring_create(modem, ril->vendor, RILMODEM, ril->modem); |
1564 | 312 | } | 321 | } |
1565 | 313 | 322 | ||
1566 | 314 | static void ril_set_online_cb(struct ril_msg *message, gpointer user_data) | 323 | static void ril_set_online_cb(struct ril_msg *message, gpointer user_data) |
1567 | @@ -354,8 +363,8 @@ | |||
1568 | 354 | } | 363 | } |
1569 | 355 | } | 364 | } |
1570 | 356 | 365 | ||
1573 | 357 | static void ril_set_online(struct ofono_modem *modem, ofono_bool_t online, | 366 | void ril_set_online(struct ofono_modem *modem, ofono_bool_t online, |
1574 | 358 | ofono_modem_online_cb_t callback, void *data) | 367 | ofono_modem_online_cb_t callback, void *data) |
1575 | 359 | { | 368 | { |
1576 | 360 | struct ril_data *ril = ofono_modem_get_data(modem); | 369 | struct ril_data *ril = ofono_modem_get_data(modem); |
1577 | 361 | struct cb_data *cbd = cb_data_new(callback, data, ril); | 370 | struct cb_data *cbd = cb_data_new(callback, data, ril); |
1578 | @@ -417,7 +426,7 @@ | |||
1579 | 417 | return 0; | 426 | return 0; |
1580 | 418 | } | 427 | } |
1581 | 419 | 428 | ||
1583 | 420 | static int ril_enable(struct ofono_modem *modem) | 429 | int ril_enable(struct ofono_modem *modem) |
1584 | 421 | { | 430 | { |
1585 | 422 | int ret; | 431 | int ret; |
1586 | 423 | 432 | ||
1587 | @@ -430,7 +439,7 @@ | |||
1588 | 430 | return -EINPROGRESS; | 439 | return -EINPROGRESS; |
1589 | 431 | } | 440 | } |
1590 | 432 | 441 | ||
1592 | 433 | static int ril_disable(struct ofono_modem *modem) | 442 | int ril_disable(struct ofono_modem *modem) |
1593 | 434 | { | 443 | { |
1594 | 435 | struct ril_data *ril = ofono_modem_get_data(modem); | 444 | struct ril_data *ril = ofono_modem_get_data(modem); |
1595 | 436 | 445 | ||
1596 | 437 | 446 | ||
1597 | === added file 'plugins/ril.h' | |||
1598 | --- plugins/ril.h 1970-01-01 00:00:00 +0000 | |||
1599 | +++ plugins/ril.h 2014-07-21 18:55:43 +0000 | |||
1600 | @@ -0,0 +1,30 @@ | |||
1601 | 1 | /* | ||
1602 | 2 | * | ||
1603 | 3 | * oFono - Open Source Telephony - RIL-based devices | ||
1604 | 4 | * | ||
1605 | 5 | * Copyright (C) 2014 Canonical Ltd. | ||
1606 | 6 | * | ||
1607 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1608 | 8 | * it under the terms of the GNU General Public License version 2 as | ||
1609 | 9 | * published by the Free Software Foundation. | ||
1610 | 10 | * | ||
1611 | 11 | * This program is distributed in the hope that it will be useful, | ||
1612 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1613 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1614 | 14 | * GNU General Public License for more details. | ||
1615 | 15 | * | ||
1616 | 16 | * You should have received a copy of the GNU General Public License | ||
1617 | 17 | * along with this program; if not, write to the Free Software | ||
1618 | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1619 | 19 | * | ||
1620 | 20 | */ | ||
1621 | 21 | |||
1622 | 22 | int ril_create(struct ofono_modem *modem, enum ofono_ril_vendor vendor); | ||
1623 | 23 | void ril_remove(struct ofono_modem *modem); | ||
1624 | 24 | int ril_enable(struct ofono_modem *modem); | ||
1625 | 25 | int ril_disable(struct ofono_modem *modem); | ||
1626 | 26 | void ril_pre_sim(struct ofono_modem *modem); | ||
1627 | 27 | void ril_post_sim(struct ofono_modem *modem); | ||
1628 | 28 | void ril_post_online(struct ofono_modem *modem); | ||
1629 | 29 | void ril_set_online(struct ofono_modem *modem, ofono_bool_t online, | ||
1630 | 30 | ofono_modem_online_cb_t callback, void *data); | ||
1631 | 0 | 31 | ||
1632 | === added file 'plugins/ubuntu-apndb.c' | |||
1633 | --- plugins/ubuntu-apndb.c 1970-01-01 00:00:00 +0000 | |||
1634 | +++ plugins/ubuntu-apndb.c 2014-07-21 18:55:43 +0000 | |||
1635 | @@ -0,0 +1,596 @@ | |||
1636 | 1 | /* | ||
1637 | 2 | * | ||
1638 | 3 | * oFono - Open Source Telephony | ||
1639 | 4 | * | ||
1640 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
1641 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
1642 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
1643 | 8 | * | ||
1644 | 9 | * This program is free software; you can redistribute it and/or modify | ||
1645 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
1646 | 11 | * published by the Free Software Foundation. | ||
1647 | 12 | * | ||
1648 | 13 | * This program is distributed in the hope that it will be useful, | ||
1649 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1650 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1651 | 16 | * GNU General Public License for more details. | ||
1652 | 17 | * | ||
1653 | 18 | * You should have received a copy of the GNU General Public License | ||
1654 | 19 | * along with this program; if not, write to the Free Software | ||
1655 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1656 | 21 | * | ||
1657 | 22 | */ | ||
1658 | 23 | |||
1659 | 24 | #ifdef HAVE_CONFIG_H | ||
1660 | 25 | #include <config.h> | ||
1661 | 26 | #endif | ||
1662 | 27 | |||
1663 | 28 | #include <string.h> | ||
1664 | 29 | #include <fcntl.h> | ||
1665 | 30 | #include <sys/mman.h> | ||
1666 | 31 | #include <sys/stat.h> | ||
1667 | 32 | #include <sys/types.h> | ||
1668 | 33 | #include <errno.h> | ||
1669 | 34 | #include <stdlib.h> | ||
1670 | 35 | #include <unistd.h> | ||
1671 | 36 | |||
1672 | 37 | #include <glib.h> | ||
1673 | 38 | |||
1674 | 39 | #define OFONO_API_SUBJECT_TO_CHANGE | ||
1675 | 40 | #include <ofono/modem.h> | ||
1676 | 41 | #include <ofono/gprs-provision.h> | ||
1677 | 42 | #include <ofono/log.h> | ||
1678 | 43 | |||
1679 | 44 | #include "ubuntu-apndb.h" | ||
1680 | 45 | |||
1681 | 46 | #ifndef SYSTEM_APNDB_PATH | ||
1682 | 47 | #define SYSTEM_APNDB_PATH "/system/etc/apns-conf.xml" | ||
1683 | 48 | #define CUSTOM_APNDB_PATH "/custom/etc/apns-conf.xml" | ||
1684 | 49 | #endif | ||
1685 | 50 | |||
1686 | 51 | struct apndb_data { | ||
1687 | 52 | const char *match_mcc; | ||
1688 | 53 | const char *match_mnc; | ||
1689 | 54 | const char *match_imsi; | ||
1690 | 55 | const char *match_spn; | ||
1691 | 56 | const char *match_gid1; | ||
1692 | 57 | GSList *apns; | ||
1693 | 58 | gboolean allow_duplicates; | ||
1694 | 59 | gboolean mvno_found; | ||
1695 | 60 | }; | ||
1696 | 61 | |||
1697 | 62 | void ubuntu_apndb_ap_free(gpointer data) | ||
1698 | 63 | { | ||
1699 | 64 | struct apndb_provision_data *ap = data; | ||
1700 | 65 | |||
1701 | 66 | g_free(ap->gprs_data.name); | ||
1702 | 67 | g_free(ap->gprs_data.apn); | ||
1703 | 68 | g_free(ap->gprs_data.username); | ||
1704 | 69 | g_free(ap->gprs_data.password); | ||
1705 | 70 | g_free(ap->gprs_data.message_proxy); | ||
1706 | 71 | g_free(ap->gprs_data.message_center); | ||
1707 | 72 | |||
1708 | 73 | g_free(ap); | ||
1709 | 74 | } | ||
1710 | 75 | |||
1711 | 76 | static gboolean imsi_match(const char *imsi, const char *match) | ||
1712 | 77 | { | ||
1713 | 78 | gboolean result = FALSE; | ||
1714 | 79 | size_t imsi_len = strlen(imsi); | ||
1715 | 80 | size_t match_len = strlen(match); | ||
1716 | 81 | unsigned int i; | ||
1717 | 82 | |||
1718 | 83 | DBG("imsi %s match %s", imsi, match); | ||
1719 | 84 | |||
1720 | 85 | if (imsi_len != match_len) | ||
1721 | 86 | goto done; | ||
1722 | 87 | |||
1723 | 88 | for (i = 0; i < imsi_len; i++) { | ||
1724 | 89 | if (*(imsi + i) == *(match + i)) | ||
1725 | 90 | continue; | ||
1726 | 91 | else if (*(match + i) == 'x') | ||
1727 | 92 | continue; | ||
1728 | 93 | else | ||
1729 | 94 | goto done; | ||
1730 | 95 | } | ||
1731 | 96 | |||
1732 | 97 | result = TRUE; | ||
1733 | 98 | |||
1734 | 99 | done: | ||
1735 | 100 | return result; | ||
1736 | 101 | } | ||
1737 | 102 | |||
1738 | 103 | static void strip_non_mvno_apns(GSList **apns) | ||
1739 | 104 | { | ||
1740 | 105 | GSList *l = NULL; | ||
1741 | 106 | unsigned int ap_count = g_slist_length(*apns); | ||
1742 | 107 | struct apndb_provision_data *ap; | ||
1743 | 108 | |||
1744 | 109 | DBG(""); | ||
1745 | 110 | |||
1746 | 111 | for (l = *apns; l;) { | ||
1747 | 112 | ap = l->data; | ||
1748 | 113 | l = l->next; | ||
1749 | 114 | |||
1750 | 115 | if (ap->mvno == FALSE) { | ||
1751 | 116 | DBG("Removing: %s", ap->gprs_data.apn); | ||
1752 | 117 | *apns = g_slist_remove(*apns, | ||
1753 | 118 | (gconstpointer) ap); | ||
1754 | 119 | ubuntu_apndb_ap_free(ap); | ||
1755 | 120 | ap_count--; | ||
1756 | 121 | } | ||
1757 | 122 | } | ||
1758 | 123 | } | ||
1759 | 124 | |||
1760 | 125 | static GSList *merge_apn_lists(GSList *custom_apns, GSList *base_apns) | ||
1761 | 126 | { | ||
1762 | 127 | GSList *l = NULL; | ||
1763 | 128 | GSList *l2 = NULL; | ||
1764 | 129 | gboolean found = FALSE; | ||
1765 | 130 | struct apndb_provision_data *ap; | ||
1766 | 131 | |||
1767 | 132 | DBG(""); | ||
1768 | 133 | |||
1769 | 134 | if (custom_apns == NULL) | ||
1770 | 135 | return base_apns; | ||
1771 | 136 | |||
1772 | 137 | for (l = custom_apns; l; l = l->next, found = FALSE) { | ||
1773 | 138 | struct apndb_provision_data *ap2 = l->data; | ||
1774 | 139 | |||
1775 | 140 | if (ap2->gprs_data.apn == NULL) { | ||
1776 | 141 | ofono_error("%s: invalid custom apn entry - %s found", | ||
1777 | 142 | __func__, ap2->gprs_data.name); | ||
1778 | 143 | continue; | ||
1779 | 144 | } | ||
1780 | 145 | |||
1781 | 146 | for (l2 = base_apns; l2; l2 = l2->next) { | ||
1782 | 147 | ap = l2->data; | ||
1783 | 148 | |||
1784 | 149 | if (ap->gprs_data.apn != NULL && | ||
1785 | 150 | ap->gprs_data.type == ap2->gprs_data.type && | ||
1786 | 151 | g_strcmp0(ap2->gprs_data.apn, | ||
1787 | 152 | ap->gprs_data.apn) == 0) { | ||
1788 | 153 | |||
1789 | 154 | found = TRUE; | ||
1790 | 155 | break; | ||
1791 | 156 | } | ||
1792 | 157 | } | ||
1793 | 158 | |||
1794 | 159 | if (found == TRUE) { | ||
1795 | 160 | DBG("found=TRUE; removing '%s'", ap->gprs_data.apn); | ||
1796 | 161 | |||
1797 | 162 | base_apns = g_slist_remove(base_apns, ap); | ||
1798 | 163 | ubuntu_apndb_ap_free(ap); | ||
1799 | 164 | } | ||
1800 | 165 | } | ||
1801 | 166 | |||
1802 | 167 | custom_apns = g_slist_reverse(custom_apns); | ||
1803 | 168 | |||
1804 | 169 | for (l = custom_apns; l; l = l->next) { | ||
1805 | 170 | struct ap2 *ap2 = l->data; | ||
1806 | 171 | |||
1807 | 172 | base_apns = g_slist_prepend(base_apns, ap2); | ||
1808 | 173 | } | ||
1809 | 174 | |||
1810 | 175 | g_slist_free(custom_apns); | ||
1811 | 176 | |||
1812 | 177 | return base_apns; | ||
1813 | 178 | } | ||
1814 | 179 | |||
1815 | 180 | static enum ofono_gprs_context_type determine_apn_type(const char *types) | ||
1816 | 181 | { | ||
1817 | 182 | /* | ||
1818 | 183 | * The database contains entries with the following type field contents: | ||
1819 | 184 | * - default | ||
1820 | 185 | * - default,mms | ||
1821 | 186 | * - default,supl | ||
1822 | 187 | * - defualt,supl,dun | ||
1823 | 188 | * - default,supl,mms | ||
1824 | 189 | * - mms | ||
1825 | 190 | */ | ||
1826 | 191 | |||
1827 | 192 | if (g_strcmp0(types, "mms") == 0) | ||
1828 | 193 | return OFONO_GPRS_CONTEXT_TYPE_MMS; | ||
1829 | 194 | else if (g_str_has_prefix(types, "default")) | ||
1830 | 195 | return OFONO_GPRS_CONTEXT_TYPE_INTERNET; | ||
1831 | 196 | else | ||
1832 | 197 | return OFONO_GPRS_CONTEXT_TYPE_ANY; | ||
1833 | 198 | } | ||
1834 | 199 | |||
1835 | 200 | static char *ubuntu_apndb_sanitize_ipv4_address(const char *address) | ||
1836 | 201 | { | ||
1837 | 202 | char **numbers = NULL; | ||
1838 | 203 | char *sanitized_numbers[4]; | ||
1839 | 204 | unsigned int count = 0; | ||
1840 | 205 | char *result = NULL; | ||
1841 | 206 | char *numeral; | ||
1842 | 207 | |||
1843 | 208 | /* | ||
1844 | 209 | * As src/gprs.c expects MMS proxies to always be | ||
1845 | 210 | * specified using IPV4 numbers-and-dot notation, | ||
1846 | 211 | * we need to strip any leading "0"s from the | ||
1847 | 212 | * individual numeric components, otherwise they | ||
1848 | 213 | * will be treated as octal numbers | ||
1849 | 214 | * ( see 'man inet_aton' for details ). | ||
1850 | 215 | */ | ||
1851 | 216 | |||
1852 | 217 | if (g_ascii_isdigit(*address) == FALSE) | ||
1853 | 218 | goto done; | ||
1854 | 219 | |||
1855 | 220 | numbers = g_strsplit(address, ".", 4); | ||
1856 | 221 | |||
1857 | 222 | for (; (numeral = *(numbers+count)); count++) { | ||
1858 | 223 | if (count > 3) | ||
1859 | 224 | goto done; | ||
1860 | 225 | |||
1861 | 226 | for (; *numeral; numeral++) { | ||
1862 | 227 | if (g_ascii_isdigit(*numeral) == FALSE) | ||
1863 | 228 | goto done; | ||
1864 | 229 | else if (*numeral == '0') | ||
1865 | 230 | continue; | ||
1866 | 231 | else | ||
1867 | 232 | break; | ||
1868 | 233 | } | ||
1869 | 234 | |||
1870 | 235 | if (*numeral) | ||
1871 | 236 | sanitized_numbers[count] = numeral; | ||
1872 | 237 | else | ||
1873 | 238 | sanitized_numbers[count] = "0"; | ||
1874 | 239 | } | ||
1875 | 240 | |||
1876 | 241 | if (count != 4) | ||
1877 | 242 | goto done; | ||
1878 | 243 | |||
1879 | 244 | result = g_strdup_printf("%s.%s.%s.%s", | ||
1880 | 245 | sanitized_numbers[0], | ||
1881 | 246 | sanitized_numbers[1], | ||
1882 | 247 | sanitized_numbers[2], | ||
1883 | 248 | sanitized_numbers[3]); | ||
1884 | 249 | |||
1885 | 250 | done: | ||
1886 | 251 | if (numbers != NULL) | ||
1887 | 252 | g_strfreev(numbers); | ||
1888 | 253 | |||
1889 | 254 | return result; | ||
1890 | 255 | } | ||
1891 | 256 | |||
1892 | 257 | static void toplevel_apndb_start(GMarkupParseContext *context, | ||
1893 | 258 | const gchar *element_name, | ||
1894 | 259 | const gchar **attribute_names, | ||
1895 | 260 | const gchar **attribute_values, | ||
1896 | 261 | gpointer userdata, GError **error) | ||
1897 | 262 | { | ||
1898 | 263 | struct apndb_data *apndb = userdata; | ||
1899 | 264 | struct apndb_provision_data *ap = NULL; | ||
1900 | 265 | int i; | ||
1901 | 266 | const gchar *carrier = NULL; | ||
1902 | 267 | const gchar *mcc = NULL; | ||
1903 | 268 | const gchar *mnc = NULL; | ||
1904 | 269 | const gchar *apn = NULL; | ||
1905 | 270 | const gchar *username = NULL; | ||
1906 | 271 | const gchar *password = NULL; | ||
1907 | 272 | const gchar *types = NULL; | ||
1908 | 273 | const gchar *protocol = NULL; | ||
1909 | 274 | const gchar *mmsproxy = NULL; | ||
1910 | 275 | const gchar *mmsport = NULL; | ||
1911 | 276 | const gchar *mmscenter = NULL; | ||
1912 | 277 | const gchar *mvnomatch = NULL; | ||
1913 | 278 | const gchar *mvnotype = NULL; | ||
1914 | 279 | enum ofono_gprs_proto proto = OFONO_GPRS_PROTO_IP; | ||
1915 | 280 | enum ofono_gprs_context_type type; | ||
1916 | 281 | |||
1917 | 282 | if (g_strcmp0(element_name, "apn") != 0) | ||
1918 | 283 | return; | ||
1919 | 284 | |||
1920 | 285 | for (i = 0; attribute_names[i]; i++) { | ||
1921 | 286 | if (g_strcmp0(attribute_names[i], "carrier") == 0) | ||
1922 | 287 | carrier = attribute_values[i]; | ||
1923 | 288 | else if (g_strcmp0(attribute_names[i], "mcc") == 0) | ||
1924 | 289 | mcc = attribute_values[i]; | ||
1925 | 290 | else if (g_strcmp0(attribute_names[i], "mnc") == 0) | ||
1926 | 291 | mnc = attribute_values[i]; | ||
1927 | 292 | } | ||
1928 | 293 | |||
1929 | 294 | if (mcc == NULL) { | ||
1930 | 295 | ofono_error("%s: apn for %s missing 'mcc' attribute", __func__, | ||
1931 | 296 | carrier); | ||
1932 | 297 | return; | ||
1933 | 298 | } | ||
1934 | 299 | |||
1935 | 300 | if (mnc == NULL) { | ||
1936 | 301 | ofono_error("%s: apn for %s missing 'mnc' attribute", __func__, | ||
1937 | 302 | carrier); | ||
1938 | 303 | return; | ||
1939 | 304 | } | ||
1940 | 305 | |||
1941 | 306 | if (g_strcmp0(mcc, apndb->match_mcc) != 0 || | ||
1942 | 307 | g_strcmp0(mnc, apndb->match_mnc) != 0) | ||
1943 | 308 | return; | ||
1944 | 309 | |||
1945 | 310 | for (i = 0; attribute_names[i]; i++) { | ||
1946 | 311 | if (g_strcmp0(attribute_names[i], "apn") == 0) | ||
1947 | 312 | apn = attribute_values[i]; | ||
1948 | 313 | else if (g_strcmp0(attribute_names[i], "user") == 0) | ||
1949 | 314 | username = attribute_values[i]; | ||
1950 | 315 | else if (g_strcmp0(attribute_names[i], "password") == 0) | ||
1951 | 316 | password = attribute_values[i]; | ||
1952 | 317 | else if (g_strcmp0(attribute_names[i], "type") == 0) | ||
1953 | 318 | types = attribute_values[i]; | ||
1954 | 319 | else if (g_strcmp0(attribute_names[i], "protocol") == 0) | ||
1955 | 320 | protocol = attribute_values[i]; | ||
1956 | 321 | else if (g_strcmp0(attribute_names[i], "mmsc") == 0) | ||
1957 | 322 | mmscenter = attribute_values[i]; | ||
1958 | 323 | else if (g_strcmp0(attribute_names[i], "mmsproxy") == 0) | ||
1959 | 324 | mmsproxy = attribute_values[i]; | ||
1960 | 325 | else if (g_strcmp0(attribute_names[i], "mmsport") == 0) | ||
1961 | 326 | mmsport = attribute_values[i]; | ||
1962 | 327 | else if (g_strcmp0(attribute_names[i], "mvno_match_data") == 0) | ||
1963 | 328 | mvnomatch = attribute_values[i]; | ||
1964 | 329 | else if (g_strcmp0(attribute_names[i], "mvno_type") == 0) | ||
1965 | 330 | mvnotype = attribute_values[i]; | ||
1966 | 331 | } | ||
1967 | 332 | |||
1968 | 333 | if (apn == NULL) { | ||
1969 | 334 | ofono_error("%s: apn for %s missing 'apn' attribute", __func__, | ||
1970 | 335 | carrier); | ||
1971 | 336 | return; | ||
1972 | 337 | } | ||
1973 | 338 | |||
1974 | 339 | if (types == NULL) { | ||
1975 | 340 | ofono_error("%s: apn for %s missing type attribute", __func__, | ||
1976 | 341 | carrier); | ||
1977 | 342 | return; | ||
1978 | 343 | } | ||
1979 | 344 | |||
1980 | 345 | if (protocol != NULL) { | ||
1981 | 346 | if (g_strcmp0(protocol, "IP") == 0) { | ||
1982 | 347 | proto = OFONO_GPRS_PROTO_IP; | ||
1983 | 348 | } else if (g_strcmp0(protocol, "IPV6") == 0) { | ||
1984 | 349 | proto = OFONO_GPRS_PROTO_IPV6; | ||
1985 | 350 | } else if (g_strcmp0(protocol, "IPV4V6") == 0) { | ||
1986 | 351 | proto = OFONO_GPRS_PROTO_IPV4V6; | ||
1987 | 352 | } else { | ||
1988 | 353 | ofono_error("%s: APN %s has invalid protocol=%s" | ||
1989 | 354 | "attribute", __func__, carrier, | ||
1990 | 355 | protocol); | ||
1991 | 356 | return; | ||
1992 | 357 | } | ||
1993 | 358 | } | ||
1994 | 359 | |||
1995 | 360 | if (mvnotype != NULL && mvnomatch != NULL) { | ||
1996 | 361 | |||
1997 | 362 | if (g_strcmp0(mvnotype, "imsi") == 0) { | ||
1998 | 363 | DBG("APN %s is mvno_type 'imsi'", carrier); | ||
1999 | 364 | |||
2000 | 365 | if (apndb->match_imsi == NULL || | ||
2001 | 366 | imsi_match(apndb->match_imsi, | ||
2002 | 367 | mvnomatch) == FALSE) { | ||
2003 | 368 | DBG("Skipping MVNO 'imsi' APN %s with" | ||
2004 | 369 | " match_data: %s", carrier, mvnomatch); | ||
2005 | 370 | return; | ||
2006 | 371 | } | ||
2007 | 372 | } else if (g_strcmp0(mvnotype, "spn") == 0) { | ||
2008 | 373 | DBG("APN %s is mvno_type 'spn'", carrier); | ||
2009 | 374 | |||
2010 | 375 | if (g_strcmp0(mvnomatch, apndb->match_spn) != 0) { | ||
2011 | 376 | DBG("Skipping mvno 'spn' APN %s with" | ||
2012 | 377 | " match_data: %s", carrier, mvnomatch); | ||
2013 | 378 | return; | ||
2014 | 379 | } | ||
2015 | 380 | |||
2016 | 381 | } else if (g_strcmp0(mvnotype, "gid") == 0) { | ||
2017 | 382 | int match_len = strlen(mvnomatch); | ||
2018 | 383 | |||
2019 | 384 | DBG("APN %s is mvno_type 'gid'", carrier); | ||
2020 | 385 | |||
2021 | 386 | /* Check initial part of GID1 against match data */ | ||
2022 | 387 | if (apndb->match_gid1 == NULL || | ||
2023 | 388 | g_ascii_strncasecmp(mvnomatch, | ||
2024 | 389 | apndb->match_gid1, | ||
2025 | 390 | match_len) != 0) { | ||
2026 | 391 | DBG("Skipping mvno 'gid' APN %s with" | ||
2027 | 392 | " match_data: %s", carrier, mvnomatch); | ||
2028 | 393 | return; | ||
2029 | 394 | } | ||
2030 | 395 | } | ||
2031 | 396 | } | ||
2032 | 397 | |||
2033 | 398 | type = determine_apn_type(types); | ||
2034 | 399 | |||
2035 | 400 | if (type == OFONO_GPRS_CONTEXT_TYPE_ANY || | ||
2036 | 401 | (type == OFONO_GPRS_CONTEXT_TYPE_MMS && mmsproxy == NULL)) { | ||
2037 | 402 | DBG("Skipping %s context; types: %s", apn, types); | ||
2038 | 403 | return; | ||
2039 | 404 | } | ||
2040 | 405 | |||
2041 | 406 | ap = g_try_new0(struct apndb_provision_data, 1); | ||
2042 | 407 | if (ap == NULL) { | ||
2043 | 408 | ofono_error("%s: out-of-memory trying to provision APN - %s", | ||
2044 | 409 | __func__, carrier); | ||
2045 | 410 | return; | ||
2046 | 411 | } | ||
2047 | 412 | |||
2048 | 413 | ap->gprs_data.type = type; | ||
2049 | 414 | |||
2050 | 415 | if (carrier != NULL) | ||
2051 | 416 | ap->gprs_data.name = g_strdup(carrier); | ||
2052 | 417 | |||
2053 | 418 | if (apn != NULL) | ||
2054 | 419 | ap->gprs_data.apn = g_strdup(apn); | ||
2055 | 420 | |||
2056 | 421 | if (username != NULL) | ||
2057 | 422 | ap->gprs_data.username = g_strdup(username); | ||
2058 | 423 | |||
2059 | 424 | if (password != NULL) | ||
2060 | 425 | ap->gprs_data.password = g_strdup(password); | ||
2061 | 426 | |||
2062 | 427 | if (mmscenter != NULL && strlen(mmscenter) > 0) | ||
2063 | 428 | ap->gprs_data.message_center = g_strdup(mmscenter); | ||
2064 | 429 | |||
2065 | 430 | if (mmsproxy != NULL && strlen(mmsproxy) > 0) { | ||
2066 | 431 | char *tmp = ubuntu_apndb_sanitize_ipv4_address(mmsproxy); | ||
2067 | 432 | if (tmp != NULL) | ||
2068 | 433 | mmsproxy = tmp; | ||
2069 | 434 | |||
2070 | 435 | if (mmsport != NULL) | ||
2071 | 436 | ap->gprs_data.message_proxy = | ||
2072 | 437 | g_strdup_printf("%s:%s", mmsproxy, mmsport); | ||
2073 | 438 | else | ||
2074 | 439 | ap->gprs_data.message_proxy = g_strdup(mmsproxy); | ||
2075 | 440 | |||
2076 | 441 | g_free(tmp); | ||
2077 | 442 | } | ||
2078 | 443 | |||
2079 | 444 | ap->gprs_data.proto = proto; | ||
2080 | 445 | |||
2081 | 446 | if (mvnotype != NULL) { | ||
2082 | 447 | ap->mvno = TRUE; | ||
2083 | 448 | apndb->mvno_found = TRUE; | ||
2084 | 449 | } | ||
2085 | 450 | |||
2086 | 451 | apndb->apns = g_slist_append(apndb->apns, ap); | ||
2087 | 452 | } | ||
2088 | 453 | |||
2089 | 454 | static void toplevel_apndb_end(GMarkupParseContext *context, | ||
2090 | 455 | const gchar *element_name, | ||
2091 | 456 | gpointer userdata, GError **error) | ||
2092 | 457 | { | ||
2093 | 458 | } | ||
2094 | 459 | |||
2095 | 460 | static const GMarkupParser toplevel_apndb_parser = { | ||
2096 | 461 | toplevel_apndb_start, | ||
2097 | 462 | toplevel_apndb_end, | ||
2098 | 463 | NULL, | ||
2099 | 464 | NULL, | ||
2100 | 465 | NULL, | ||
2101 | 466 | }; | ||
2102 | 467 | |||
2103 | 468 | static gboolean ubuntu_apndb_parse(const GMarkupParser *parser, | ||
2104 | 469 | gpointer userdata, | ||
2105 | 470 | const char *apndb_path, | ||
2106 | 471 | GError **error) | ||
2107 | 472 | { | ||
2108 | 473 | struct stat st; | ||
2109 | 474 | char *db; | ||
2110 | 475 | int fd; | ||
2111 | 476 | GMarkupParseContext *context; | ||
2112 | 477 | gboolean ret; | ||
2113 | 478 | |||
2114 | 479 | fd = open(apndb_path, O_RDONLY); | ||
2115 | 480 | if (fd < 0) { | ||
2116 | 481 | g_set_error(error, G_FILE_ERROR, | ||
2117 | 482 | g_file_error_from_errno(errno), | ||
2118 | 483 | "open(%s) failed: %s", apndb_path, | ||
2119 | 484 | g_strerror(errno)); | ||
2120 | 485 | return FALSE; | ||
2121 | 486 | } | ||
2122 | 487 | |||
2123 | 488 | if (fstat(fd, &st) < 0) { | ||
2124 | 489 | close(fd); | ||
2125 | 490 | g_set_error(error, G_FILE_ERROR, | ||
2126 | 491 | g_file_error_from_errno(errno), | ||
2127 | 492 | "fstat(%s) failed: %s", apndb_path, | ||
2128 | 493 | g_strerror(errno)); | ||
2129 | 494 | return FALSE; | ||
2130 | 495 | } | ||
2131 | 496 | |||
2132 | 497 | db = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); | ||
2133 | 498 | if (db == MAP_FAILED) { | ||
2134 | 499 | close(fd); | ||
2135 | 500 | g_set_error(error, G_FILE_ERROR, | ||
2136 | 501 | g_file_error_from_errno(errno), | ||
2137 | 502 | "mmap(%s) failed: %s", apndb_path, | ||
2138 | 503 | g_strerror(errno)); | ||
2139 | 504 | return FALSE; | ||
2140 | 505 | } | ||
2141 | 506 | |||
2142 | 507 | context = g_markup_parse_context_new(parser, | ||
2143 | 508 | G_MARKUP_TREAT_CDATA_AS_TEXT, | ||
2144 | 509 | userdata, NULL); | ||
2145 | 510 | |||
2146 | 511 | ret = g_markup_parse_context_parse(context, db, st.st_size, error); | ||
2147 | 512 | |||
2148 | 513 | if (ret == TRUE) | ||
2149 | 514 | g_markup_parse_context_end_parse(context, error); | ||
2150 | 515 | |||
2151 | 516 | munmap(db, st.st_size); | ||
2152 | 517 | close(fd); | ||
2153 | 518 | g_markup_parse_context_free(context); | ||
2154 | 519 | |||
2155 | 520 | return ret; | ||
2156 | 521 | } | ||
2157 | 522 | |||
2158 | 523 | GSList *ubuntu_apndb_lookup_apn(const char *mcc, const char *mnc, | ||
2159 | 524 | const char *spn, const char *imsi, const char *gid1, | ||
2160 | 525 | GError **error) | ||
2161 | 526 | { | ||
2162 | 527 | struct apndb_data apndb = { NULL }; | ||
2163 | 528 | struct apndb_data custom_apndb = { NULL }; | ||
2164 | 529 | const char *apndb_path; | ||
2165 | 530 | GSList *merged_apns; | ||
2166 | 531 | |||
2167 | 532 | /* | ||
2168 | 533 | * Lookup /custom apns first, if mvno apns found, | ||
2169 | 534 | * strip non-mvno apns from list | ||
2170 | 535 | * | ||
2171 | 536 | * Lookup /system next, apply same mvno logic... | ||
2172 | 537 | * | ||
2173 | 538 | * Merge both lists, any custom apns that match the type | ||
2174 | 539 | * and apn fields of a /system apn replace it. | ||
2175 | 540 | */ | ||
2176 | 541 | |||
2177 | 542 | custom_apndb.match_mcc = mcc; | ||
2178 | 543 | custom_apndb.match_mnc = mnc; | ||
2179 | 544 | custom_apndb.match_spn = spn; | ||
2180 | 545 | custom_apndb.match_imsi = imsi; | ||
2181 | 546 | custom_apndb.match_gid1 = gid1; | ||
2182 | 547 | |||
2183 | 548 | if ((apndb_path = getenv("OFONO_CUSTOM_APNDB_PATH")) == NULL) | ||
2184 | 549 | apndb_path = CUSTOM_APNDB_PATH; | ||
2185 | 550 | |||
2186 | 551 | if (ubuntu_apndb_parse(&toplevel_apndb_parser, &custom_apndb, | ||
2187 | 552 | apndb_path, | ||
2188 | 553 | error) == FALSE) { | ||
2189 | 554 | g_slist_free_full(custom_apndb.apns, ubuntu_apndb_ap_free); | ||
2190 | 555 | custom_apndb.apns = NULL; | ||
2191 | 556 | |||
2192 | 557 | if (*error) { | ||
2193 | 558 | if ((*error)->domain != G_FILE_ERROR) | ||
2194 | 559 | ofono_error("%s: custom apn_lookup error -%s", | ||
2195 | 560 | __func__, (*error)->message); | ||
2196 | 561 | |||
2197 | 562 | g_error_free(*error); | ||
2198 | 563 | *error = NULL; | ||
2199 | 564 | } | ||
2200 | 565 | } | ||
2201 | 566 | |||
2202 | 567 | if (custom_apndb.apns && custom_apndb.mvno_found) | ||
2203 | 568 | strip_non_mvno_apns(&custom_apndb.apns); | ||
2204 | 569 | |||
2205 | 570 | DBG("custom_apndb: found '%d' APNs", g_slist_length(custom_apndb.apns)); | ||
2206 | 571 | |||
2207 | 572 | apndb.match_mcc = mcc; | ||
2208 | 573 | apndb.match_mnc = mnc; | ||
2209 | 574 | apndb.match_spn = spn; | ||
2210 | 575 | apndb.match_imsi = imsi; | ||
2211 | 576 | apndb.match_gid1 = gid1; | ||
2212 | 577 | |||
2213 | 578 | if ((apndb_path = getenv("OFONO_SYSTEM_APNDB_PATH")) == NULL) | ||
2214 | 579 | apndb_path = SYSTEM_APNDB_PATH; | ||
2215 | 580 | |||
2216 | 581 | if (ubuntu_apndb_parse(&toplevel_apndb_parser, &apndb, | ||
2217 | 582 | apndb_path, | ||
2218 | 583 | error) == FALSE) { | ||
2219 | 584 | g_slist_free_full(apndb.apns, ubuntu_apndb_ap_free); | ||
2220 | 585 | apndb.apns = NULL; | ||
2221 | 586 | } | ||
2222 | 587 | |||
2223 | 588 | DBG("apndb: found '%d' APNs", g_slist_length(apndb.apns)); | ||
2224 | 589 | |||
2225 | 590 | if (apndb.apns && apndb.mvno_found) | ||
2226 | 591 | strip_non_mvno_apns(&apndb.apns); | ||
2227 | 592 | |||
2228 | 593 | merged_apns = merge_apn_lists(custom_apndb.apns, apndb.apns); | ||
2229 | 594 | |||
2230 | 595 | return merged_apns; | ||
2231 | 596 | } | ||
2232 | 0 | 597 | ||
2233 | === added file 'plugins/ubuntu-apndb.h' | |||
2234 | --- plugins/ubuntu-apndb.h 1970-01-01 00:00:00 +0000 | |||
2235 | +++ plugins/ubuntu-apndb.h 2014-07-21 18:55:43 +0000 | |||
2236 | @@ -0,0 +1,33 @@ | |||
2237 | 1 | /* | ||
2238 | 2 | * | ||
2239 | 3 | * ofono - Open Source Telephony | ||
2240 | 4 | * | ||
2241 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
2242 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
2243 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
2244 | 8 | * | ||
2245 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2246 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
2247 | 11 | * published by the Free Software Foundation. | ||
2248 | 12 | * | ||
2249 | 13 | * This program is distributed in the hope that it will be useful, | ||
2250 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2251 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2252 | 16 | * GNU General Public License for more details. | ||
2253 | 17 | * | ||
2254 | 18 | * You should have received a copy of the GNU General Public License | ||
2255 | 19 | * along with this program; if not, write to the Free Software | ||
2256 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
2257 | 21 | * | ||
2258 | 22 | */ | ||
2259 | 23 | |||
2260 | 24 | struct apndb_provision_data { | ||
2261 | 25 | struct ofono_gprs_provision_data gprs_data; | ||
2262 | 26 | gboolean mvno; | ||
2263 | 27 | }; | ||
2264 | 28 | |||
2265 | 29 | void ubuntu_apndb_ap_free(gpointer data); | ||
2266 | 30 | |||
2267 | 31 | GSList *ubuntu_apndb_lookup_apn(const char *mcc, const char *mnc, | ||
2268 | 32 | const char *spn, const char *imsi, const char *gid1, | ||
2269 | 33 | GError **error); | ||
2270 | 0 | 34 | ||
2271 | === added file 'plugins/ubuntu-provision.c' | |||
2272 | --- plugins/ubuntu-provision.c 1970-01-01 00:00:00 +0000 | |||
2273 | +++ plugins/ubuntu-provision.c 2014-07-21 18:55:43 +0000 | |||
2274 | @@ -0,0 +1,150 @@ | |||
2275 | 1 | /* | ||
2276 | 2 | * | ||
2277 | 3 | * oFono - Open Source Telephony | ||
2278 | 4 | * | ||
2279 | 5 | * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. | ||
2280 | 6 | * 2013 Simon Busch <morphis@gravedo.de> | ||
2281 | 7 | * Copyright (C) 2014 Canonical Ltd. | ||
2282 | 8 | * | ||
2283 | 9 | * This program is free software; you can redistribute it and/or modify | ||
2284 | 10 | * it under the terms of the GNU General Public License version 2 as | ||
2285 | 11 | * published by the Free Software Foundation. | ||
2286 | 12 | * | ||
2287 | 13 | * This program is distributed in the hope that it will be useful, | ||
2288 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2289 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2290 | 16 | * GNU General Public License for more details. | ||
2291 | 17 | * | ||
2292 | 18 | * You should have received a copy of the GNU General Public License | ||
2293 | 19 | * along with this program; if not, write to the Free Software | ||
2294 | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
2295 | 21 | * | ||
2296 | 22 | */ | ||
2297 | 23 | |||
2298 | 24 | #ifdef HAVE_CONFIG_H | ||
2299 | 25 | #include <config.h> | ||
2300 | 26 | #endif | ||
2301 | 27 | |||
2302 | 28 | #include <errno.h> | ||
2303 | 29 | #include <stdlib.h> | ||
2304 | 30 | #include <string.h> | ||
2305 | 31 | |||
2306 | 32 | #include <glib.h> | ||
2307 | 33 | |||
2308 | 34 | #define OFONO_API_SUBJECT_TO_CHANGE | ||
2309 | 35 | #include <ofono/types.h> | ||
2310 | 36 | #include <ofono/log.h> | ||
2311 | 37 | #include <ofono/plugin.h> | ||
2312 | 38 | #include <ofono/modem.h> | ||
2313 | 39 | #include <ofono/gprs-provision.h> | ||
2314 | 40 | |||
2315 | 41 | #include "ubuntu-apndb.h" | ||
2316 | 42 | #include "mbpi.h" | ||
2317 | 43 | |||
2318 | 44 | static int provision_get_settings(const char *mcc, const char *mnc, | ||
2319 | 45 | const char *spn, | ||
2320 | 46 | const char *imsi, const char *gid1, | ||
2321 | 47 | struct ofono_gprs_provision_data **settings, | ||
2322 | 48 | int *count) | ||
2323 | 49 | { | ||
2324 | 50 | GSList *apns = NULL; | ||
2325 | 51 | GSList *l = NULL; | ||
2326 | 52 | GError *error = NULL; | ||
2327 | 53 | unsigned int i; | ||
2328 | 54 | char *tmp; | ||
2329 | 55 | int retval = 0; | ||
2330 | 56 | |||
2331 | 57 | if ((tmp = getenv("OFONO_CUSTOM_MCC")) != NULL) | ||
2332 | 58 | mcc = tmp; | ||
2333 | 59 | |||
2334 | 60 | if ((tmp = getenv("OFONO_CUSTOM_MNC")) != NULL) | ||
2335 | 61 | mnc = tmp; | ||
2336 | 62 | |||
2337 | 63 | if ((tmp = getenv("OFONO_CUSTOM_SPN")) != NULL) | ||
2338 | 64 | spn = tmp; | ||
2339 | 65 | |||
2340 | 66 | if ((tmp = getenv("OFONO_CUSTOM_IMSI")) != NULL) | ||
2341 | 67 | imsi = tmp; | ||
2342 | 68 | |||
2343 | 69 | if ((tmp = getenv("OFONO_CUSTOM_GID1")) != NULL) | ||
2344 | 70 | gid1 = tmp; | ||
2345 | 71 | |||
2346 | 72 | ofono_info("Provisioning for MCC %s, MNC %s, SPN '%s', IMSI '%s', " | ||
2347 | 73 | "GID1 '%s'", mcc, mnc, spn, imsi, gid1); | ||
2348 | 74 | |||
2349 | 75 | apns = ubuntu_apndb_lookup_apn(mcc, mnc, spn, imsi, gid1, &error); | ||
2350 | 76 | if (apns == NULL) { | ||
2351 | 77 | if (error != NULL) { | ||
2352 | 78 | ofono_error("%s: apndb_lookup error -%s for mcc %s" | ||
2353 | 79 | " mnc %s spn %s imsi %s", __func__, | ||
2354 | 80 | error->message, mcc, mnc, spn, imsi); | ||
2355 | 81 | g_error_free(error); | ||
2356 | 82 | error = NULL; | ||
2357 | 83 | } | ||
2358 | 84 | } | ||
2359 | 85 | |||
2360 | 86 | *count = g_slist_length(apns); | ||
2361 | 87 | |||
2362 | 88 | DBG("ap_count: '%d'", *count); | ||
2363 | 89 | |||
2364 | 90 | if (*count == 0) { | ||
2365 | 91 | ofono_error("%s: provisioning failed - no APNs found.", | ||
2366 | 92 | __func__); | ||
2367 | 93 | |||
2368 | 94 | retval = -1; | ||
2369 | 95 | goto done; | ||
2370 | 96 | } | ||
2371 | 97 | |||
2372 | 98 | *settings = g_try_new0(struct ofono_gprs_provision_data, *count); | ||
2373 | 99 | if (*settings == NULL) { | ||
2374 | 100 | ofono_error("%s: provisioning failed: out-of-memory", __func__); | ||
2375 | 101 | |||
2376 | 102 | g_slist_free_full(apns, ubuntu_apndb_ap_free); | ||
2377 | 103 | |||
2378 | 104 | *count = 0; | ||
2379 | 105 | return -ENOMEM; | ||
2380 | 106 | } | ||
2381 | 107 | |||
2382 | 108 | for (l = apns, i = 0; l; l = l->next, i++) { | ||
2383 | 109 | struct apndb_provision_data *ap = l->data; | ||
2384 | 110 | |||
2385 | 111 | DBG("Name: '%s'", ap->gprs_data.name); | ||
2386 | 112 | DBG("APN: '%s'", ap->gprs_data.apn); | ||
2387 | 113 | DBG("Type: %s", mbpi_ap_type(ap->gprs_data.type)); | ||
2388 | 114 | DBG("Username: '%s'", ap->gprs_data.username); | ||
2389 | 115 | DBG("Password: '%s'", ap->gprs_data.password); | ||
2390 | 116 | DBG("Message Proxy: '%s'", ap->gprs_data.message_proxy); | ||
2391 | 117 | DBG("Message Center: '%s'", ap->gprs_data.message_center); | ||
2392 | 118 | DBG("MVNO: %u", ap->mvno); | ||
2393 | 119 | |||
2394 | 120 | memcpy(*settings + i, &ap->gprs_data, sizeof(ap->gprs_data)); | ||
2395 | 121 | |||
2396 | 122 | g_free(ap); | ||
2397 | 123 | } | ||
2398 | 124 | |||
2399 | 125 | done: | ||
2400 | 126 | if (apns != NULL) | ||
2401 | 127 | g_slist_free(apns); | ||
2402 | 128 | |||
2403 | 129 | return retval; | ||
2404 | 130 | } | ||
2405 | 131 | |||
2406 | 132 | static struct ofono_gprs_provision_driver ubuntu_provision_driver = { | ||
2407 | 133 | .name = "Ubuntu APN database Provisioning", | ||
2408 | 134 | .get_settings = provision_get_settings | ||
2409 | 135 | }; | ||
2410 | 136 | |||
2411 | 137 | static int ubuntu_provision_init(void) | ||
2412 | 138 | { | ||
2413 | 139 | return ofono_gprs_provision_driver_register(&ubuntu_provision_driver); | ||
2414 | 140 | } | ||
2415 | 141 | |||
2416 | 142 | static void ubuntu_provision_exit(void) | ||
2417 | 143 | { | ||
2418 | 144 | ofono_gprs_provision_driver_unregister(&ubuntu_provision_driver); | ||
2419 | 145 | } | ||
2420 | 146 | |||
2421 | 147 | OFONO_PLUGIN_DEFINE(ubuntu_provision, | ||
2422 | 148 | "Ubuntu APN database Provisioning Plugin", VERSION, | ||
2423 | 149 | OFONO_PLUGIN_PRIORITY_DEFAULT, | ||
2424 | 150 | ubuntu_provision_init, ubuntu_provision_exit) | ||
2425 | 0 | 151 | ||
2426 | === modified file 'test/rilmodem/test-sim-online' | |||
2427 | --- test/rilmodem/test-sim-online 2014-06-24 18:59:26 +0000 | |||
2428 | +++ test/rilmodem/test-sim-online 2014-07-21 18:55:43 +0000 | |||
2429 | @@ -193,7 +193,8 @@ | |||
2430 | 193 | assert properties["Model"] == "Fake Modem Model" | 193 | assert properties["Model"] == "Fake Modem Model" |
2431 | 194 | assert properties["Type"] == "hardware" | 194 | assert properties["Type"] == "hardware" |
2432 | 195 | 195 | ||
2434 | 196 | assert properties["Serial"] == "000000000000000" | 196 | if args.emulator: |
2435 | 197 | assert properties["Serial"] == "000000000000000" | ||
2436 | 197 | 198 | ||
2437 | 198 | assert properties["Manufacturer"] == "Fake Manufacturer" | 199 | assert properties["Manufacturer"] == "Fake Manufacturer" |
2438 | 199 | 200 | ||
2439 | 200 | 201 | ||
2440 | === modified file 'unit/test-grilreply.c' | |||
2441 | --- unit/test-grilreply.c 2014-05-13 01:21:09 +0000 | |||
2442 | +++ unit/test-grilreply.c 2014-07-21 18:55:43 +0000 | |||
2443 | @@ -79,6 +79,12 @@ | |||
2444 | 79 | const struct ril_msg msg; | 79 | const struct ril_msg msg; |
2445 | 80 | }; | 80 | }; |
2446 | 81 | 81 | ||
2447 | 82 | struct oem_hook_raw_test { | ||
2448 | 83 | const unsigned char *data; | ||
2449 | 84 | int size; | ||
2450 | 85 | const struct ril_msg msg; | ||
2451 | 86 | }; | ||
2452 | 87 | |||
2453 | 82 | /* Invalid RIL_REQUEST_DATA_REGISTRATION_STATE: buffer too small */ | 88 | /* Invalid RIL_REQUEST_DATA_REGISTRATION_STATE: buffer too small */ |
2454 | 83 | static const struct ril_msg reply_data_reg_state_invalid_1 = { | 89 | static const struct ril_msg reply_data_reg_state_invalid_1 = { |
2455 | 84 | .buf = "XYZ", | 90 | .buf = "XYZ", |
2456 | @@ -1451,6 +1457,49 @@ | |||
2457 | 1451 | } | 1457 | } |
2458 | 1452 | }; | 1458 | }; |
2459 | 1453 | 1459 | ||
2460 | 1460 | /* | ||
2461 | 1461 | * The following structure contains test data for a valid | ||
2462 | 1462 | * RIL_REQUEST_OEM_HOOK_RAW reply with parameter {4,0x11111111} | ||
2463 | 1463 | */ | ||
2464 | 1464 | static const guchar reply_oem_hook_raw_valid_parcel1[] = { | ||
2465 | 1465 | 0x04, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 | ||
2466 | 1466 | }; | ||
2467 | 1467 | |||
2468 | 1468 | static const struct oem_hook_raw_test reply_oem_hook_raw_valid_1 = { | ||
2469 | 1469 | .data = reply_oem_hook_raw_valid_parcel1 + sizeof(int32_t), | ||
2470 | 1470 | .size = (int) (sizeof(reply_oem_hook_raw_valid_parcel1) | ||
2471 | 1471 | - sizeof(int32_t)), | ||
2472 | 1472 | .msg = { | ||
2473 | 1473 | .buf = (gchar *) reply_oem_hook_raw_valid_parcel1, | ||
2474 | 1474 | .buf_len = sizeof(reply_oem_hook_raw_valid_parcel1), | ||
2475 | 1475 | .unsolicited = FALSE, | ||
2476 | 1476 | .req = RIL_REQUEST_OEM_HOOK_RAW, | ||
2477 | 1477 | .serial_no = 0, | ||
2478 | 1478 | .error = RIL_E_SUCCESS, | ||
2479 | 1479 | } | ||
2480 | 1480 | }; | ||
2481 | 1481 | |||
2482 | 1482 | /* | ||
2483 | 1483 | * The following structure contains test data for a valid | ||
2484 | 1484 | * RIL_REQUEST_OEM_HOOK_RAW reply with parameter {-1} | ||
2485 | 1485 | */ | ||
2486 | 1486 | static const guchar reply_oem_hook_raw_valid_parcel2[] = { | ||
2487 | 1487 | 0xFF, 0xFF, 0xFF, 0xFF | ||
2488 | 1488 | }; | ||
2489 | 1489 | |||
2490 | 1490 | static const struct oem_hook_raw_test reply_oem_hook_raw_valid_2 = { | ||
2491 | 1491 | .data = NULL, | ||
2492 | 1492 | .size = -1, | ||
2493 | 1493 | .msg = { | ||
2494 | 1494 | .buf = (gchar *) reply_oem_hook_raw_valid_parcel2, | ||
2495 | 1495 | .buf_len = sizeof(reply_oem_hook_raw_valid_parcel2), | ||
2496 | 1496 | .unsolicited = FALSE, | ||
2497 | 1497 | .req = RIL_REQUEST_OEM_HOOK_RAW, | ||
2498 | 1498 | .serial_no = 0, | ||
2499 | 1499 | .error = RIL_E_SUCCESS, | ||
2500 | 1500 | } | ||
2501 | 1501 | }; | ||
2502 | 1502 | |||
2503 | 1454 | static void test_reply_reg_state_invalid(gconstpointer data) | 1503 | static void test_reply_reg_state_invalid(gconstpointer data) |
2504 | 1455 | { | 1504 | { |
2505 | 1456 | struct reply_reg_state *reply = g_ril_reply_parse_reg_state(NULL, data); | 1505 | struct reply_reg_state *reply = g_ril_reply_parse_reg_state(NULL, data); |
2506 | @@ -1669,6 +1718,19 @@ | |||
2507 | 1669 | g_free(retries); | 1718 | g_free(retries); |
2508 | 1670 | } | 1719 | } |
2509 | 1671 | 1720 | ||
2510 | 1721 | static void test_reply_oem_hook_raw_valid(gconstpointer data) | ||
2511 | 1722 | { | ||
2512 | 1723 | const struct oem_hook_raw_test *test = data; | ||
2513 | 1724 | struct reply_oem_hook *reply = | ||
2514 | 1725 | g_ril_reply_oem_hook_raw(NULL, &test->msg); | ||
2515 | 1726 | |||
2516 | 1727 | g_assert(reply->length == test->size); | ||
2517 | 1728 | if (reply->length >= 0) | ||
2518 | 1729 | g_assert(!memcmp(reply->data, test->data, test->size)); | ||
2519 | 1730 | else | ||
2520 | 1731 | g_assert(reply->data == NULL); | ||
2521 | 1732 | } | ||
2522 | 1733 | |||
2523 | 1672 | #endif | 1734 | #endif |
2524 | 1673 | 1735 | ||
2525 | 1674 | int main(int argc, char **argv) | 1736 | int main(int argc, char **argv) |
2526 | @@ -1958,6 +2020,16 @@ | |||
2527 | 1958 | &reply_enter_sim_pin_valid_2, | 2020 | &reply_enter_sim_pin_valid_2, |
2528 | 1959 | test_reply_enter_sim_pin_valid); | 2021 | test_reply_enter_sim_pin_valid); |
2529 | 1960 | 2022 | ||
2530 | 2023 | g_test_add_data_func("/testgrilreply/oem: " | ||
2531 | 2024 | "valid OEM_HOOK_RAW Test 1", | ||
2532 | 2025 | &reply_oem_hook_raw_valid_1, | ||
2533 | 2026 | test_reply_oem_hook_raw_valid); | ||
2534 | 2027 | |||
2535 | 2028 | g_test_add_data_func("/testgrilreply/oem: " | ||
2536 | 2029 | "valid OEM_HOOK_RAW Test 2", | ||
2537 | 2030 | &reply_oem_hook_raw_valid_2, | ||
2538 | 2031 | test_reply_oem_hook_raw_valid); | ||
2539 | 2032 | |||
2540 | 1961 | #endif | 2033 | #endif |
2541 | 1962 | 2034 | ||
2542 | 1963 | return g_test_run(); | 2035 | return g_test_run(); |
2543 | 1964 | 2036 | ||
2544 | === modified file 'unit/test-grilrequest.c' | |||
2545 | --- unit/test-grilrequest.c 2014-06-24 18:59:26 +0000 | |||
2546 | +++ unit/test-grilrequest.c 2014-07-21 18:55:43 +0000 | |||
2547 | @@ -790,6 +790,37 @@ | |||
2548 | 790 | .parcel_size = sizeof(req_change_barring_password_valid_1), | 790 | .parcel_size = sizeof(req_change_barring_password_valid_1), |
2549 | 791 | }; | 791 | }; |
2550 | 792 | 792 | ||
2551 | 793 | /* oem_hook_raw tests */ | ||
2552 | 794 | |||
2553 | 795 | struct request_test_oem_hook_raw_data { | ||
2554 | 796 | const guchar *data; | ||
2555 | 797 | gsize size; | ||
2556 | 798 | const guchar *parcel_data; | ||
2557 | 799 | gsize parcel_size; | ||
2558 | 800 | }; | ||
2559 | 801 | |||
2560 | 802 | static const guchar req_oem_hook_raw_valid_1[] = { | ||
2561 | 803 | 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
2562 | 804 | }; | ||
2563 | 805 | |||
2564 | 806 | static const struct request_test_oem_hook_raw_data oem_hook_raw_valid_test_1 = { | ||
2565 | 807 | .data = req_oem_hook_raw_valid_1 + sizeof(int32_t), | ||
2566 | 808 | .size = sizeof(req_oem_hook_raw_valid_1) - sizeof(int32_t), | ||
2567 | 809 | .parcel_data = (guchar *) &req_oem_hook_raw_valid_1, | ||
2568 | 810 | .parcel_size = sizeof(req_oem_hook_raw_valid_1), | ||
2569 | 811 | }; | ||
2570 | 812 | |||
2571 | 813 | static const guchar req_oem_hook_raw_valid_2[] = { | ||
2572 | 814 | 0xFF, 0xFF, 0xFF, 0xFF | ||
2573 | 815 | }; | ||
2574 | 816 | |||
2575 | 817 | static const struct request_test_oem_hook_raw_data oem_hook_raw_valid_test_2 = { | ||
2576 | 818 | .data = NULL, | ||
2577 | 819 | .size = 0, | ||
2578 | 820 | .parcel_data = (guchar *) &req_oem_hook_raw_valid_2, | ||
2579 | 821 | .parcel_size = sizeof(req_oem_hook_raw_valid_2), | ||
2580 | 822 | }; | ||
2581 | 823 | |||
2582 | 793 | /* | 824 | /* |
2583 | 794 | * The following hexadecimal data represents a serialized Binder parcel | 825 | * The following hexadecimal data represents a serialized Binder parcel |
2584 | 795 | * instance containing a valid RIL_REQUEST_RADIO_POWER 'OFF' message. | 826 | * instance containing a valid RIL_REQUEST_RADIO_POWER 'OFF' message. |
2585 | @@ -1322,6 +1353,21 @@ | |||
2586 | 1322 | 1353 | ||
2587 | 1323 | parcel_free(&rilp); | 1354 | parcel_free(&rilp); |
2588 | 1324 | } | 1355 | } |
2589 | 1356 | |||
2590 | 1357 | static void test_request_oem_hook_raw(gconstpointer data) | ||
2591 | 1358 | { | ||
2592 | 1359 | const struct request_test_oem_hook_raw_data *test_data = data; | ||
2593 | 1360 | struct parcel rilp; | ||
2594 | 1361 | |||
2595 | 1362 | g_ril_request_oem_hook_raw(NULL, test_data->data, | ||
2596 | 1363 | test_data->size, &rilp); | ||
2597 | 1364 | |||
2598 | 1365 | g_assert(!memcmp(rilp.data, test_data->parcel_data, | ||
2599 | 1366 | test_data->parcel_size)); | ||
2600 | 1367 | |||
2601 | 1368 | parcel_free(&rilp); | ||
2602 | 1369 | } | ||
2603 | 1370 | |||
2604 | 1325 | #endif | 1371 | #endif |
2605 | 1326 | 1372 | ||
2606 | 1327 | int main(int argc, char **argv) | 1373 | int main(int argc, char **argv) |
2607 | @@ -1571,6 +1617,16 @@ | |||
2608 | 1571 | &change_barring_password_valid_test_1, | 1617 | &change_barring_password_valid_test_1, |
2609 | 1572 | test_request_change_barring_password); | 1618 | test_request_change_barring_password); |
2610 | 1573 | 1619 | ||
2611 | 1620 | g_test_add_data_func("/testgrilrequest/oem-hook-raw: " | ||
2612 | 1621 | "valid OEM_HOOK_RAW Test 1", | ||
2613 | 1622 | &oem_hook_raw_valid_test_1, | ||
2614 | 1623 | test_request_oem_hook_raw); | ||
2615 | 1624 | |||
2616 | 1625 | g_test_add_data_func("/testgrilrequest/oem-hook-raw: " | ||
2617 | 1626 | "valid OEM_HOOK_RAW Test 2", | ||
2618 | 1627 | &oem_hook_raw_valid_test_2, | ||
2619 | 1628 | test_request_oem_hook_raw); | ||
2620 | 1629 | |||
2621 | 1574 | #endif | 1630 | #endif |
2622 | 1575 | return g_test_run(); | 1631 | return g_test_run(); |
2623 | 1576 | } | 1632 | } |
PASSED: Continuous integration, rev:6870 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- ci/55/ jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- utopic- amd64-ci/ 12 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- utopic- armhf-ci/ 9 jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- utopic- armhf-ci/ 9/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ phablet- team-ofono- ubuntu- utopic- i386-ci/ 9
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/phablet- team-ofono- ubuntu- ci/55/rebuild
http://