4e61ce52e6651265edf86a6af118cd9c84582610
[platform/core/telephony/tel-plugin-imc.git] / packaging / 0016-s_ps-Remove-plateform-dependencies-to-setup-pdp-cont.patch
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
5  context
6 Content-Type: text/plain; charset="utf-8"
7 Content-Transfer-Encoding: 8bit
8
9 ---
10  src/s_ps.c |  130 +++++++++++++++++++++++++++++-------------------------------
11  1 file changed, 62 insertions(+), 68 deletions(-)
12
13 diff --git a/src/s_ps.c b/src/s_ps.c
14 index 78bb9c7..107d672 100644
15 --- a/src/s_ps.c
16 +++ b/src/s_ps.c
17 @@ -43,11 +43,6 @@
18  #include "s_common.h"
19  #include "s_ps.h"
20  
21 -
22 -
23 -#define VNET_CH_PATH_BOOT0  "/dev/umts_boot0"
24 -#define IOCTL_CG_DATA_SEND  _IO('o', 0x37)
25 -
26  /*Invalid Session ID*/
27  #define PS_INVALID_CID  999 /*Need to check */
28  
29 @@ -61,6 +56,7 @@
30  #define AT_XDNS_ENABLE 1
31  #define AT_XDNS_DISABLE 0
32  #define AT_SESSION_DOWN 0
33 +
34  static void _ps_free(void *ptr)
35  {
36         dbg("Entered");
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);
39         dbg("Exit");
40  }
41 -static TReturn _pdp_device_control(unsigned int cid)
42 -{
43 -       int fd = -1;
44 -       int ret = -1;
45 -       fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
46 -       if (fd < 0) {
47 -               dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_BOOT0, strerror(errno));
48 -               return -1;
49 -       }
50 -       /*To Do for different Cids*/
51 -       dbg("Send IOCTL: arg 0x05 (0101) HSIC1, cid=%d \n", cid);
52 -       if (cid == 1) {
53 -               ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0x05);
54 -       } else if (cid == 2) {
55 -               ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0xA);
56 -       } else {
57 -               dbg("More Than 2 context are not supported right Now");
58 -       }
59 -       close(fd);
60 -       if (ret < 0) {
61 -               dbg("[ error ] send IOCTL_CG_DATA_SEND (0x%x) fail!! \n", IOCTL_CG_DATA_SEND);
62 -               return TCORE_RETURN_FAILURE;
63 -       } else {
64 -               dbg("[ ok ] send IOCTL_CG_DATA_SEND (0x%x) success!! \n", IOCTL_CG_DATA_SEND);
65 -               return TCORE_RETURN_SUCCESS;
66 -       }
67 -}
68  
69  static gboolean on_event_cgev_handle(CoreObject *co_ps, const void *data, void *user_data)
70  {
71 @@ -445,10 +414,15 @@ static void on_response_deactivate_ps_context(TcorePending *p, int data_len, con
72  
73         cid = tcore_context_get_id(ps_context);
74         if (resp->success) {
75 +               char *devname = tcore_context_get_ipv4_devname(ps_context);
76 +
77                 dbg("Response OK");
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.");
84         } else {
85                 dbg("Response NOK");
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;
89  }
90  
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)
93  {
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, };
98 +
99 +       dbg("entry");
100 +
101 +       memcpy(&noti->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.");
105 +       }
106 +
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);
110 +
111 +       data_status.context_id = noti->context_id;
112 +       data_status.state = 1;
113 +       data_status.result = 0;
114 +
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);
117 +
118 +       g_free(noti);
119 +
120 +       dbg("exit");
121 +}
122 +
123 +static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
124 +{
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);
134 +       TcoreHal *h;
135 +       struct global_data *gd;
136 +
137 +       noti = g_new0(struct tnoti_ps_pdp_ipconfiguration, 1);
138 +
139 +       gd = tcore_plugin_ref_user_data(plugin);
140 +       h = gd->hal;
141  
142         dbg("Entered");
143  
144 @@ -548,7 +557,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
145                                 index = 0;
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, ".");
151                                 }
152                                 _ps_free(dns_prim);
153 @@ -563,7 +572,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
154                                 index = 0;
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, ".");
160                                 }
161                                 _ps_free(dns_sec);
162 @@ -580,15 +589,15 @@ exit_fail:
163         {
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;
183         }
184  exit_success:
185         {
186 @@ -606,32 +615,17 @@ exit_success:
187                 }
188                 _ps_free(pdp_address);
189                 _ps_free((void *) token_pdp_address);
190 -               noti.field_flag = (0x0001 & 0x0002 & 0x0004);
191 -               noti.err = 0;
192 -               noti.context_id = cid;
193 -               memcpy(&noti.ip_address, &addr, 4);
194 -               if (_pdp_device_control(cid) != TCORE_RETURN_SUCCESS) {
195 -                       dbg("_pdp_device_control() failed. errno=%d", errno);
196 -               }
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);
202 -               }
203 -
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), &noti);
207 +               noti->field_flag = (0x0001 & 0x0002 & 0x0004);
208 +               noti->err = 0;
209 +               noti->context_id = cid;
210 +               memcpy(&noti->ip_address, &addr, 4);
211  
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");
217 +                       return;
218 +               }
219  
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");
223 -               return;
224         }
225  }
226  
227 -- 
228 1.7.10.4
229