1 From 18cd0f7d5a979252b30a35537fa3bbaea60fdc5f Mon Sep 17 00:00:00 2001
2 From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
3 Date: Wed, 10 Oct 2012 11:32:22 +0200
4 Subject: [PATCH 16/23] s_ps: Remove plateform dependencies to setup pdp
6 Content-Type: text/plain; charset="utf-8"
7 Content-Transfer-Encoding: 8bit
10 src/s_ps.c | 130 +++++++++++++++++++++++++++++-------------------------------
11 1 file changed, 62 insertions(+), 68 deletions(-)
13 diff --git a/src/s_ps.c b/src/s_ps.c
14 index 78bb9c7..107d672 100644
23 -#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
24 -#define IOCTL_CG_DATA_SEND _IO('o', 0x37)
26 /*Invalid Session ID*/
27 #define PS_INVALID_CID 999 /*Need to check */
30 #define AT_XDNS_ENABLE 1
31 #define AT_XDNS_DISABLE 0
32 #define AT_SESSION_DOWN 0
34 static void _ps_free(void *ptr)
37 @@ -83,33 +79,6 @@ static void _unable_to_get_pending(CoreObject *co_ps, CoreObject *ps_context)
38 (void) tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATED);
41 -static TReturn _pdp_device_control(unsigned int cid)
45 - fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
47 - dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_BOOT0, strerror(errno));
50 - /*To Do for different Cids*/
51 - dbg("Send IOCTL: arg 0x05 (0101) HSIC1, cid=%d \n", cid);
53 - ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0x05);
54 - } else if (cid == 2) {
55 - ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0xA);
57 - dbg("More Than 2 context are not supported right Now");
61 - dbg("[ error ] send IOCTL_CG_DATA_SEND (0x%x) fail!! \n", IOCTL_CG_DATA_SEND);
62 - return TCORE_RETURN_FAILURE;
64 - dbg("[ ok ] send IOCTL_CG_DATA_SEND (0x%x) success!! \n", IOCTL_CG_DATA_SEND);
65 - return TCORE_RETURN_SUCCESS;
69 static gboolean on_event_cgev_handle(CoreObject *co_ps, const void *data, void *user_data)
71 @@ -445,10 +414,15 @@ static void on_response_deactivate_ps_context(TcorePending *p, int data_len, con
73 cid = tcore_context_get_id(ps_context);
75 + char *devname = tcore_context_get_ipv4_devname(ps_context);
78 /*get the data usage and report it application*/
79 (void) send_data_counter_command(co_ps, ps_context);
80 /*get the HSDPA status and report it to server*/
81 + dbg("Removing interface %s", devname);
82 + if (tcore_util_netif_down(devname) != TCORE_RETURN_SUCCESS)
83 + dbg("util_netif_down() failed.");
86 send_undefine_context_cmd(co_ps, ps_context);
87 @@ -489,11 +463,38 @@ static TReturn deactivate_ps_context(CoreObject *co_ps, CoreObject *ps_context,
88 return TCORE_RETURN_FAILURE;
91 -static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
92 +static void on_setup_pdp(CoreObject *co_ps, const char *iname, void *user_data)
94 - struct tnoti_ps_pdp_ipconfiguration noti = {0};
95 + struct tnoti_ps_pdp_ipconfiguration *noti = user_data;
96 struct tnoti_ps_call_status data_status = {0};
97 - char devname[10] = {0, };
101 + memcpy(¬i->devname, iname, strlen(iname));
102 + dbg("devname = [%s]", iname);
103 + if (tcore_util_netif_up(iname) != TCORE_RETURN_SUCCESS) {
104 + dbg("util_netif_up() failed.");
107 + dbg("Send Notification upwards of IP address");
108 + tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps, TNOTI_PS_PDP_IPCONFIGURATION,
109 + sizeof(struct tnoti_ps_pdp_ipconfiguration), noti);
111 + data_status.context_id = noti->context_id;
112 + data_status.state = 1;
113 + data_status.result = 0;
115 + tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
116 + TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_status);
123 +static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
125 + struct tnoti_ps_pdp_ipconfiguration *noti;
126 char *dns_prim = NULL;
127 char *dns_sec = NULL;
128 char *pdp_address = NULL;
129 @@ -512,6 +513,14 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
130 const TcoreATResponse *resp = data;
131 CoreObject *co_ps = tcore_pending_ref_core_object(p);
132 int cid = tcore_context_get_id(ps_context);
133 + TcorePlugin *plugin = tcore_object_ref_plugin(co_ps);
135 + struct global_data *gd;
137 + noti = g_new0(struct tnoti_ps_pdp_ipconfiguration, 1);
139 + gd = tcore_plugin_ref_user_data(plugin);
144 @@ -548,7 +557,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
146 token_add = strtok(dns_prim, ".");
147 while (token_add != NULL) {
148 - noti.primary_dns[index++] = atoi(token_add);
149 + noti->primary_dns[index++] = atoi(token_add);
150 token_add = strtok(NULL, ".");
153 @@ -563,7 +572,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
155 token_add = strtok(dns_sec, ".");
156 while (token_add != NULL) {
157 - noti.secondary_dns[index++] = atoi(token_add);
158 + noti->secondary_dns[index++] = atoi(token_add);
159 token_add = strtok(NULL, ".");
162 @@ -580,15 +589,15 @@ exit_fail:
164 dbg("Adding default DNS");
165 dbg("Adding the Primary DNS");
166 - noti.primary_dns[0] = 8;
167 - noti.primary_dns[1] = 8;
168 - noti.primary_dns[2] = 8;
169 - noti.primary_dns[3] = 8;
170 + noti->primary_dns[0] = 8;
171 + noti->primary_dns[1] = 8;
172 + noti->primary_dns[2] = 8;
173 + noti->primary_dns[3] = 8;
174 dbg("Adding Secondary DNS");
175 - noti.secondary_dns[0] = 8;
176 - noti.secondary_dns[1] = 8;
177 - noti.secondary_dns[2] = 4;
178 - noti.secondary_dns[3] = 4;
179 + noti->secondary_dns[0] = 8;
180 + noti->secondary_dns[1] = 8;
181 + noti->secondary_dns[2] = 4;
182 + noti->secondary_dns[3] = 4;
186 @@ -606,32 +615,17 @@ exit_success:
188 _ps_free(pdp_address);
189 _ps_free((void *) token_pdp_address);
190 - noti.field_flag = (0x0001 & 0x0002 & 0x0004);
192 - noti.context_id = cid;
193 - memcpy(¬i.ip_address, &addr, 4);
194 - if (_pdp_device_control(cid) != TCORE_RETURN_SUCCESS) {
195 - dbg("_pdp_device_control() failed. errno=%d", errno);
197 - snprintf(devname, 10, "pdp%d", cid - 1);
198 - memcpy(noti.devname, devname, 10);
199 - dbg("devname = [%s]", devname);
200 - if (tcore_util_netif_up(devname) != TCORE_RETURN_SUCCESS) {
201 - dbg("util_netif_up() failed. errno=%d", errno);
204 - dbg("Send Notification upwards of IP address");
205 - tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps, TNOTI_PS_PDP_IPCONFIGURATION,
206 - sizeof(struct tnoti_ps_pdp_ipconfiguration), ¬i);
207 + noti->field_flag = (0x0001 & 0x0002 & 0x0004);
209 + noti->context_id = cid;
210 + memcpy(¬i->ip_address, &addr, 4);
212 - data_status.context_id = cid;
213 - data_status.state = 1;
214 - data_status.result = 0;
215 + if (tcore_hal_setup_pdp(h, co_ps, on_setup_pdp, noti, cid) != TCORE_RETURN_SUCCESS) {
216 + err("setup PDP context failed");
220 - tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
221 - TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_status);
222 dbg("EXIT : Without error");