FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/ms/src/aci/dcm_utils.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : DCM and TCPIP | |
4 | Modul : ACI | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Description : This file contains Useful DCM (Data connection manager)functions. | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 /************************************ INCLUDES ********************************************/ | |
22 #include "aci_all.h" | |
23 | |
24 #include "aci.h" | |
25 #include "aci_cmh.h" | |
26 #include "Gaci_cmh.h" | |
27 #include "dcm.h" | |
28 #include "dcm_utils.h" | |
29 #include "dcm_state.h" | |
30 #include "dcm_env.h" | |
31 #include "dcm_f.h" | |
32 #include "psa_dcm.h" | |
33 #include "socket_api.h" | |
34 | |
35 #include "wap_aci.h" | |
36 | |
37 /**************************** LOCAL VARIABLE DEFINITION ************************************/ | |
38 | |
39 /**************************** EXTERN VARIABLE DEFINITION ***********************************/ | |
40 EXTERN T_DCM_ENV_CTRL_BLK *dcm_env_ctrl_blk_p; | |
41 | |
42 | |
43 /**************************** LOCAL FUCNTION DEFINITION ************************************/ | |
44 LOCAL T_DCM_RET dcm_send_cgdcont_get_cmd(U8 row); | |
45 LOCAL T_DCM_RET dcm_send_cgdcont_cmd(U8 row); | |
46 LOCAL T_DCM_RET dcm_send_cgatt_cmd(U8 row); | |
47 LOCAL T_DCM_RET dcm_send_cgdeact_cmd(U8 row); | |
48 LOCAL T_DCM_RET dcm_send_cgpco_auth_cmd(U8 row); | |
49 LOCAL T_DCM_RET dcm_send_cgpco_get_cmd(U8 row); | |
50 LOCAL T_DCM_RET dcm_send_cgerep_cmd(U8 row); | |
51 LOCAL T_DCM_RET dcm_send_cgpaddr_cmd(U8 current_row); | |
52 LOCAL T_DCM_RET dcm_send_percentppp_cmd(U8 row); | |
53 LOCAL T_DCM_RET dcm_send_sat_dn_cmd(U8 row); | |
54 LOCAL T_DCM_RET dcm_send_percentppp_get_cmd(U8 row); | |
55 LOCAL T_DCM_RET dcm_send_percentcal_get_cmd(UBYTE row); | |
56 LOCAL T_DCM_RET dcm_send_sat_abort_cmd(U8 row); | |
57 | |
58 LOCAL ULONG dcm_ipaddr_htonl(ULONG horder_ipaddr); | |
59 | |
60 LOCAL void set_state_from_ctrl_blk(); | |
61 | |
62 /************************** EXTERN FUCNTION DEFINITION *********************************/ | |
63 EXTERN T_DCM_RET dcm_handle_message (T_DCM_HDR *msg_p); | |
64 EXTERN void psaTCPIP_Shutdown_Req(void); | |
65 | |
66 | |
67 | |
68 /*************************************************************************************** | |
69 * Function : dcm_process_unwaited_events_state_intermediate_conn | |
70 * Parameter : T_DCM_HDR * | |
71 * -Pointer on the header of the message. | |
72 * Return : T_DCM_RET | |
73 * DCM_OK or DCM errors | |
74 * Description : Function used in all intermediate states where events is unwaited, | |
75 * but must be processed. | |
76 ***************************************************************************************/ | |
77 T_DCM_RET dcm_process_unwaited_events_state_intermediate_conn(T_DCM_HDR * msg_p) | |
78 { | |
79 T_DCM_OPEN_CONN_REQ_MSG * dcm_open_conn_req_msg_p; | |
80 T_DCM_CLOSE_CONN_REQ_MSG * dcm_close_conn_req_msg_p; | |
81 U8 current_row = dcm_env_ctrl_blk_p->current_row; | |
82 | |
83 TRACE_FUNCTION("DCM: dcm_process_unwaited_events_state_intermediate_conn()"); | |
84 | |
85 switch(msg_p->msg_id) | |
86 { | |
87 case DCM_ERROR_IND_MSG: | |
88 return dcm_process_event_error_reception(msg_p); | |
89 /*lint -e527 suppress Warning -- Unreachable */ | |
90 break; | |
91 /*lint +e527 */ | |
92 case DCM_OPEN_CONN_REQ_MSG: | |
93 dcm_open_conn_req_msg_p = (T_DCM_OPEN_CONN_REQ_MSG*)msg_p; | |
94 return psaDCM_open_conn_cnf(DCM_BUSY, | |
95 dcm_open_conn_req_msg_p->conn_req.api_instance); | |
96 /*lint -e527 suppress Warning -- Unreachable */ | |
97 break; | |
98 /*lint +e527 */ | |
99 case DCM_CLOSE_CONN_REQ_MSG: | |
100 dcm_close_conn_req_msg_p = (T_DCM_CLOSE_CONN_REQ_MSG*)msg_p; | |
101 // DCM CLOSE REQ have to be accepted in ACTVATING STATE | |
102 if(dcm_env_ctrl_blk_p->state[0] == DCM_ACTIVATING_CONN) | |
103 { | |
104 dcm_process_close_conn_event(dcm_close_conn_req_msg_p); | |
105 } | |
106 else | |
107 { | |
108 psaDCM_close_conn_cnf(DCM_BUSY, | |
109 dcm_close_conn_req_msg_p->close_req.api_instance); | |
110 } | |
111 return DCM_OK; | |
112 /*lint -e527 suppress Warning -- Unreachable */ | |
113 break; | |
114 /*lint +e527 */ | |
115 default: | |
116 /* Ignore event - Stay in the same state. */ | |
117 return DCM_UNKNOWN_EVENT; | |
118 } | |
119 } | |
120 | |
121 | |
122 /* | |
123 * Function used to close a connection (with PS and later with api_instance) | |
124 * | |
125 * The closing is always on demand of the IPU_id, or may be internally launched. | |
126 * The closing of the connection begin by the closing of the port with the PS. | |
127 * - Close the connection with the PS. | |
128 * | |
129 * @param T_DCM_CLOSE_CONN_REQ_MSG* | |
130 * @return DCM_OK or DCM errors | |
131 */ | |
132 /*************************************************************************************** | |
133 * Function : dcm_process_close_conn_event | |
134 * Parameter : T_APPLI_USER | |
135 * -Pointer on the header of the message. | |
136 * Return : T_DCM_RET | |
137 * DCM_OK or DCM errors | |
138 * Description : Function used in all intermediate states where events is unwaited, | |
139 * but must be processed. | |
140 ***************************************************************************************/ | |
141 T_DCM_RET dcm_process_close_conn_event(T_DCM_CLOSE_CONN_REQ_MSG *close_conn_p ) | |
142 { | |
143 U8 i; | |
144 U8 current_bearer_count; | |
145 | |
146 TRACE_FUNCTION("DCM: dcm_process_close_conn_event()"); | |
147 | |
148 for (i=0; i < DCM_MAX_NUMBER_IPU; i++) | |
149 { | |
150 if( (dcm_env_ctrl_blk_p->ipu_list[i].api_instance == | |
151 close_conn_p->close_req.api_instance) && | |
152 (dcm_env_ctrl_blk_p->ipu_list[i].row_state) ) | |
153 { | |
154 if(dcm_env_ctrl_blk_p->ipu_list[i].bearer_type == DCM_BEARER_GPRS) | |
155 { | |
156 current_bearer_count = dcm_env_ctrl_blk_p->gprs_current_total_row; | |
157 } | |
158 else | |
159 { | |
160 current_bearer_count = dcm_env_ctrl_blk_p->gsm_current_total_row; | |
161 } | |
162 /* raise the flag that indicates a disconnection */ | |
163 dcm_env_ctrl_blk_p->ipu_list[i].row_state = ROW_CLOSING; | |
164 dcm_new_state(DCM_CLOSING_CONN , DCM_SUB_NO_ACTION); | |
165 | |
166 if(current_bearer_count == 1) | |
167 { | |
168 if(dcm_env_ctrl_blk_p->ipu_list[i].bearer_type == DCM_BEARER_GPRS) | |
169 { | |
170 dcm_send_cgdeact_cmd(i); | |
171 } | |
172 else | |
173 { | |
174 dcm_send_percentcal_get_cmd(i); | |
175 } | |
176 } | |
177 else | |
178 { | |
179 psaDCM_close_conn_cnf(DCM_OK,close_conn_p->close_req.api_instance); | |
180 /* free the row used */ | |
181 dcm_free_row(i); | |
182 set_state_from_ctrl_blk(); | |
183 } | |
184 } | |
185 } | |
186 return DCM_OK; | |
187 } | |
188 | |
189 | |
190 /******************************************************************************* | |
191 * Function used to open a connection (with PS) | |
192 * | |
193 * The opening is always on demand of the IPU_id. | |
194 * - Open the connection with the PS. | |
195 * | |
196 * @return DCM_OK or DCM errors | |
197 *******************************************************************************/ | |
198 T_DCM_RET dcm_process_open_conn_event(T_DCM_OPEN_CONN_REQ_MSG *open_conn_p) | |
199 { | |
200 U8 row_id, row_id_free; | |
201 | |
202 TRACE_FUNCTION("DCM: dcm_process_open_conn_event()"); | |
203 | |
204 /* check if the max number of IPU is reached */ | |
205 if (( dcm_env_ctrl_blk_p->gsm_current_total_row + | |
206 dcm_env_ctrl_blk_p->gprs_current_total_row ) >= DCM_MAX_NUMBER_IPU ) | |
207 { | |
208 /* Too many IPU_id opened */ | |
209 /* send the negative confirmation to the IPU */ | |
210 return psaDCM_open_conn_cnf(DCM_NOT_READY, | |
211 open_conn_p->conn_req.api_instance); | |
212 } | |
213 | |
214 /* if possible, get the next row */ | |
215 for (row_id = 0, row_id_free = DCM_MAX_NUMBER_IPU; row_id < DCM_MAX_NUMBER_IPU; row_id++) | |
216 { | |
217 if (dcm_env_ctrl_blk_p->ipu_list[row_id].row_state) | |
218 { | |
219 /* send a negative confirmation whether the IPU already exists */ | |
220 if (dcm_env_ctrl_blk_p->ipu_list[row_id].api_instance == | |
221 open_conn_p->conn_req.api_instance) | |
222 { | |
223 /* send the negative confirmation to the IPU */ | |
224 return psaDCM_open_conn_cnf(DCM_ALREADY_ACTIVATED, | |
225 open_conn_p->conn_req.api_instance); | |
226 } | |
227 } | |
228 else | |
229 { | |
230 /* get the first entry */ | |
231 if (row_id_free == DCM_MAX_NUMBER_IPU) | |
232 { | |
233 row_id_free = row_id; | |
234 } | |
235 } | |
236 } | |
237 | |
238 if (row_id_free == DCM_MAX_NUMBER_IPU) | |
239 { | |
240 /* send the negative confirmation to the IPU */ | |
241 return psaDCM_open_conn_cnf(DCM_NOT_READY, | |
242 open_conn_p->conn_req.api_instance); | |
243 } | |
244 /* Check the bearer type */ | |
245 /* check best one bearer */ | |
246 if(open_conn_p->conn_req.bearer_select == DCM_BEARER_ANY) | |
247 { | |
248 T_CGATT_STATE cgatt_state; | |
249 qAT_PlusCGATT(CMD_SRC_LCL,&cgatt_state); | |
250 | |
251 if(cgatt_state == CGATT_STATE_ATTACHED) | |
252 open_conn_p->conn_req.bearer_select = DCM_BEARER_GPRS; | |
253 else | |
254 open_conn_p->conn_req.bearer_select = DCM_BEARER_GSM; | |
255 } | |
256 | |
257 /* If application doesn't give any connection parameters than use default */ | |
258 if(open_conn_p->conn_req.bearer_select == DCM_BEARER_GSM OR | |
259 open_conn_p->conn_req.bearer_select == DCM_BEARER_GPRS) | |
260 { | |
261 psaDCM_open_conn_cnf(DCM_INVALID_PARAMETER,open_conn_p->conn_req.api_instance); | |
262 return DCM_INVALID_PARAMETER; | |
263 } | |
264 | |
265 /* If application gives the necessary parameters for a connection use these */ | |
266 else if(open_conn_p->conn_req.bearer_select == DCM_BEARER_AS_SPECIFIED) | |
267 { | |
268 dcm_env_ctrl_blk_p->ipu_list[row_id_free].bearer_handle = | |
269 open_conn_p->conn_req.dcm_info_conn.bearer_handle; | |
270 dcm_env_ctrl_blk_p->ipu_list[row_id_free].app_handle = | |
271 open_conn_p->conn_req.dcm_info_conn.app_handle; | |
272 dcm_env_ctrl_blk_p->ipu_list[row_id_free].bearer_type = | |
273 open_conn_p->conn_req.dcm_info_conn.bearer_type; | |
274 dcm_env_ctrl_blk_p->ipu_list[row_id_free].apn_valid = | |
275 open_conn_p->conn_req.dcm_info_conn.apn_valid; | |
276 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].apn_valid) | |
277 { | |
278 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].apn, | |
279 (char*)open_conn_p->conn_req.dcm_info_conn.apn); | |
280 } | |
281 else | |
282 { | |
283 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].apn,""); | |
284 } | |
285 dcm_env_ctrl_blk_p->ipu_list[row_id_free].phone_number_valid = | |
286 open_conn_p->conn_req.dcm_info_conn.phone_number_valid; | |
287 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].phone_number_valid) | |
288 { | |
289 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].phone_number, | |
290 (char*)open_conn_p->conn_req.dcm_info_conn.phone_number); | |
291 } | |
292 else | |
293 { | |
294 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].phone_number,""); | |
295 } | |
296 dcm_env_ctrl_blk_p->ipu_list[row_id_free].user_id_valid = | |
297 open_conn_p->conn_req.dcm_info_conn.user_id_valid; | |
298 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].user_id_valid) | |
299 { | |
300 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].user_id, | |
301 (char*)open_conn_p->conn_req.dcm_info_conn.user_id); | |
302 } | |
303 else | |
304 { | |
305 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].user_id,""); | |
306 } | |
307 dcm_env_ctrl_blk_p->ipu_list[row_id_free].password_valid = | |
308 open_conn_p->conn_req.dcm_info_conn.password_valid; | |
309 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].password_valid) | |
310 { | |
311 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].password, | |
312 (char*)open_conn_p->conn_req.dcm_info_conn.password); | |
313 } | |
314 else | |
315 { | |
316 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row_id_free].password,""); | |
317 } | |
318 dcm_env_ctrl_blk_p->ipu_list[row_id_free].cid = open_conn_p->conn_req.dcm_info_conn.cid; | |
319 dcm_env_ctrl_blk_p->ipu_list[row_id_free].ip_address = open_conn_p->conn_req.dcm_info_conn.ip_address; | |
320 dcm_env_ctrl_blk_p->ipu_list[row_id_free].dns1 = open_conn_p->conn_req.dcm_info_conn.dns1; | |
321 dcm_env_ctrl_blk_p->ipu_list[row_id_free].dns2 = open_conn_p->conn_req.dcm_info_conn.dns2; | |
322 dcm_env_ctrl_blk_p->ipu_list[row_id_free].gateway = open_conn_p->conn_req.dcm_info_conn.gateway; | |
323 dcm_env_ctrl_blk_p->ipu_list[row_id_free].auth_type = open_conn_p->conn_req.dcm_info_conn.auth_type; | |
324 dcm_env_ctrl_blk_p->ipu_list[row_id_free].data_compr = open_conn_p->conn_req.dcm_info_conn.data_compr; | |
325 dcm_env_ctrl_blk_p->ipu_list[row_id_free].header_compr = open_conn_p->conn_req.dcm_info_conn.header_compr; | |
326 dcm_env_ctrl_blk_p->ipu_list[row_id_free].precedence = open_conn_p->conn_req.dcm_info_conn.precedence; | |
327 dcm_env_ctrl_blk_p->ipu_list[row_id_free].delay = open_conn_p->conn_req.dcm_info_conn.delay; | |
328 dcm_env_ctrl_blk_p->ipu_list[row_id_free].reliability = open_conn_p->conn_req.dcm_info_conn.reliability; | |
329 dcm_env_ctrl_blk_p->ipu_list[row_id_free].peak_throughput = open_conn_p->conn_req.dcm_info_conn.peak_throughput; | |
330 dcm_env_ctrl_blk_p->ipu_list[row_id_free].mean_throughput = open_conn_p->conn_req.dcm_info_conn.mean_throughput; | |
331 dcm_env_ctrl_blk_p->ipu_list[row_id_free].shareable = open_conn_p->conn_req.dcm_info_conn.shareable; | |
332 } | |
333 | |
334 dcm_env_ctrl_blk_p->ipu_list[row_id_free].api_instance = | |
335 open_conn_p->conn_req.api_instance; | |
336 | |
337 /* keep the curretn row */ | |
338 dcm_env_ctrl_blk_p->current_row = row_id_free; | |
339 | |
340 /* mark the row as used */ | |
341 dcm_env_ctrl_blk_p->ipu_list[row_id_free].row_state = ROW_ASSIGNED; | |
342 | |
343 /* sum the total of actual rows */ | |
344 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].bearer_type == DCM_BEARER_GPRS) | |
345 { | |
346 dcm_env_ctrl_blk_p->gprs_current_total_row++; | |
347 } | |
348 else | |
349 { | |
350 dcm_env_ctrl_blk_p->gsm_current_total_row++; | |
351 } | |
352 | |
353 if(dcm_env_ctrl_blk_p->gprs_current_total_row > 1 OR | |
354 dcm_env_ctrl_blk_p->gsm_current_total_row > 1) | |
355 { | |
356 psaDCM_open_conn_cnf(DCM_ALREADY_ACTIVATED,open_conn_p->conn_req.api_instance); | |
357 return DCM_ALREADY_ACTIVATED; | |
358 } | |
359 | |
360 set_gpf_tcpip_call(); | |
361 | |
362 /* DCM state change */ | |
363 dcm_new_state(DCM_ACTIVATING_CONN,DCM_SUB_NO_ACTION); | |
364 | |
365 /* if GPRS: send first GPRS AT Command qAT_CGDCONT */ | |
366 if(dcm_env_ctrl_blk_p->ipu_list[row_id_free].bearer_type == DCM_BEARER_GPRS) | |
367 { | |
368 dcm_send_cgdcont_get_cmd(dcm_env_ctrl_blk_p->current_row); | |
369 } | |
370 else /*send first GSM AT Command sAT_PercentPPP */ | |
371 { | |
372 dcm_send_percentppp_cmd(dcm_env_ctrl_blk_p->current_row); | |
373 } | |
374 | |
375 return DCM_OK; | |
376 } | |
377 | |
378 | |
379 /******************************************************************************/ | |
380 T_DCM_RET dcm_process_get_current_conn_event(T_DCM_GET_CURRENT_CONN_REQ_MSG *current_conn_p) | |
381 { | |
382 TRACE_FUNCTION("DCM: dcm_process_get_current_conn_event()"); | |
383 | |
384 if(dcm_env_ctrl_blk_p->ipu_list[dcm_env_ctrl_blk_p->current_row].row_state == | |
385 ROW_ASSIGNED) { | |
386 psaDCM_get_current_conn_cnf(DCM_OK, | |
387 current_conn_p->current_conn_req.api_instance, | |
388 dcm_env_ctrl_blk_p); | |
389 } | |
390 else { | |
391 psaDCM_get_current_conn_cnf(DCM_NOT_READY, | |
392 current_conn_p->current_conn_req.api_instance, | |
393 dcm_env_ctrl_blk_p); | |
394 } | |
395 return DCM_OK; | |
396 } | |
397 | |
398 | |
399 /******************************************************************************/ | |
400 T_DCM_RET dcm_process_unknown_event_in_idle(T_DCM_HDR* msg_p) | |
401 { | |
402 T_DCM_CLOSE_CONN_REQ_MSG *close_conn_req_p; | |
403 T_DCM_RET ret; | |
404 | |
405 TRACE_FUNCTION("DCM: dcm_process_unknown_event_in_idle()"); | |
406 | |
407 if(msg_p == NULL) | |
408 return DCM_INVALID_PARAMETER; | |
409 | |
410 switch(msg_p->msg_id) | |
411 { | |
412 case DCM_CLOSE_CONN_REQ_MSG : | |
413 close_conn_req_p =(T_DCM_CLOSE_CONN_REQ_MSG *)msg_p; | |
414 psaDCM_close_conn_cnf(DCM_UNKNOWN_EVENT, | |
415 close_conn_req_p->close_req.api_instance); | |
416 set_state_from_ctrl_blk(); | |
417 ret = DCM_OK; | |
418 break; | |
419 default: | |
420 ret = DCM_UNKNOWN_EVENT; | |
421 break; | |
422 } | |
423 return ret; | |
424 } | |
425 | |
426 | |
427 /******************************************************************************/ | |
428 T_DCM_RET dcm_free_row(U8 current_row) | |
429 { | |
430 TRACE_FUNCTION("DCM: dcm_free_row()"); | |
431 | |
432 /* Decrease the current number of IPU */ | |
433 dcm_env_ctrl_blk_p->ipu_list[current_row].row_state = ROW_FREE; | |
434 if(dcm_env_ctrl_blk_p->ipu_list[current_row].bearer_type == DCM_BEARER_GPRS) | |
435 dcm_env_ctrl_blk_p->gprs_current_total_row--; | |
436 else | |
437 dcm_env_ctrl_blk_p->gsm_current_total_row--; | |
438 | |
439 /* clear the row in the structure of IP Users */ | |
440 dcm_clear_ipu_info(current_row); | |
441 return DCM_OK; | |
442 } | |
443 | |
444 | |
445 /* | |
446 * Function used to store some IPU informations | |
447 * | |
448 * @param row to access [0, 256], | |
449 * @param IPU id | |
450 * @param bearer type | |
451 * @param apn, mtu, pdp@, cid, user, password, dns1, dns2, gateway | |
452 * @return DCM_OK or DCM errors | |
453 */ | |
454 T_DCM_RET dcm_store_ipu_info(U8 row, T_BEARER_TYPE bearer_type, char *apn, | |
455 char *number, char *pdp_addr, U8 cid_used, | |
456 char *user, char *password, U32 dns1, U32 dns2, | |
457 U32 gateway) | |
458 { | |
459 TRACE_FUNCTION("DCM: dcm_store_ipu_info()"); | |
460 | |
461 if(bearer_type == DCM_BEARER_GPRS) | |
462 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].apn, apn); | |
463 else if (bearer_type == DCM_BEARER_GSM) | |
464 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].phone_number,number); | |
465 else | |
466 return DCM_INVALID_PARAMETER; | |
467 dcm_env_ctrl_blk_p->ipu_list[row].bearer_type = bearer_type; | |
468 dcm_env_ctrl_blk_p->ipu_list[row].cid = cid_used; | |
469 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].user_id, user); | |
470 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].password, password); | |
471 dcm_env_ctrl_blk_p->ipu_list[row].dns1 = dns1; | |
472 dcm_env_ctrl_blk_p->ipu_list[row].dns2 = dns2; | |
473 dcm_env_ctrl_blk_p->ipu_list[row].gateway = gateway; | |
474 | |
475 return DCM_OK; | |
476 } | |
477 | |
478 | |
479 /* resets parameters of a row */ | |
480 T_DCM_RET dcm_clear_ipu_info(U8 row) | |
481 { | |
482 char empty[] = ""; | |
483 TRACE_FUNCTION("DCM: dcm_clear_ipu_info()"); | |
484 | |
485 dcm_env_ctrl_blk_p->ipu_list[row].bearer_type = DCM_BEARER_NO; | |
486 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].apn, empty); | |
487 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].phone_number,empty); | |
488 dcm_env_ctrl_blk_p->ipu_list[row].cid = 0; | |
489 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].user_id, empty); | |
490 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].password, empty); | |
491 dcm_env_ctrl_blk_p->ipu_list[row].dns1 = 0; | |
492 dcm_env_ctrl_blk_p->ipu_list[row].dns2 = 0; | |
493 dcm_env_ctrl_blk_p->ipu_list[row].gateway = 0; | |
494 | |
495 return DCM_OK; | |
496 } | |
497 | |
498 /* | |
499 * Function used to send the <AT+CGDCONT=?> command | |
500 * | |
501 * This command is used to get the next Context IDentifier available in the PS. | |
502 * This cid will be used very often in the suite | |
503 * | |
504 * @param row in the IPU structure related to the actual command | |
505 * @return DCM_OK or DCM errors | |
506 */ | |
507 LOCAL T_DCM_RET dcm_send_cgdcont_get_cmd(U8 row) | |
508 { | |
509 T_GPRS_CONT_REC defCtxts[MAX_CID_PLUS_EINS]; | |
510 SHORT cid_array[MAX_CID_PLUS_EINS]; | |
511 UBYTE i; | |
512 | |
513 TRACE_FUNCTION("DCM: dcm_send_cgdcont_get_cmd()"); | |
514 | |
515 if(qAT_PlusCGDCONT(CMD_SRC_LCL, &defCtxts, cid_array) != AT_CMPL) | |
516 { | |
517 psaDCM_open_conn_cnf( DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
518 dcm_free_row(row); | |
519 set_state_from_ctrl_blk(); | |
520 return DCM_OK; | |
521 } | |
522 else | |
523 { | |
524 for( i= 0; i < MAX_CID_PLUS_EINS ; i++) | |
525 { | |
526 if(cid_array[i] == dcm_env_ctrl_blk_p->ipu_list[row].cid) | |
527 { | |
528 TRACE_EVENT_P2("DCM: dcm cid is the same %d=%d", | |
529 cid_array[i], | |
530 dcm_env_ctrl_blk_p->ipu_list[row].cid); | |
531 } | |
532 } | |
533 return dcm_send_cgdcont_cmd(row); | |
534 } | |
535 | |
536 } | |
537 | |
538 | |
539 /* | |
540 * Function used to send the <AT+CGDCONT=cid, "IP", "apn", "", 0, 0> command | |
541 * | |
542 * This command is used to declare the PDP Context. | |
543 * | |
544 * @param row in the IPU structure related to the actual command | |
545 * @return DCM_OK or DCM errors | |
546 */ | |
547 LOCAL T_DCM_RET dcm_send_cgdcont_cmd(U8 row) | |
548 { | |
549 T_GPRS_CONT_REC input_txt; | |
550 | |
551 TRACE_FUNCTION("DCM: dcm_send_cgdcont_cmd()"); | |
552 TRACE_EVENT_P1("DCM: ipu_list[row].apn = %s",dcm_env_ctrl_blk_p->ipu_list[row].apn); | |
553 | |
554 strcpy(input_txt.apn,(char*)dcm_env_ctrl_blk_p->ipu_list[row].apn); | |
555 strcpy(input_txt.pdp_type,"IP"); | |
556 memset(input_txt.pdp_addr,'\0',MAX_PDP_ADDR_LEN); | |
557 input_txt.d_comp = CGDCONT_D_COMP_OMITTED; | |
558 input_txt.h_comp = CGDCONT_H_COMP_OMITTED; | |
559 memset(&input_txt.qos,0,sizeof(T_QOS)); | |
560 memset(&input_txt.min_qos,0,sizeof(T_QOS)); | |
561 | |
562 if(sAT_PlusCGDCONT(CMD_SRC_LCL,dcm_env_ctrl_blk_p->ipu_list[row].cid, &input_txt) != AT_CMPL) | |
563 { | |
564 psaDCM_open_conn_cnf(DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
565 dcm_free_row(row); | |
566 set_state_from_ctrl_blk(); | |
567 return DCM_OK; | |
568 } | |
569 else | |
570 { | |
571 dcm_send_cgatt_cmd(row); | |
572 return DCM_OK; | |
573 } | |
574 } | |
575 | |
576 | |
577 /* | |
578 * Function used to send the <AT+CGATT=cid> command | |
579 * | |
580 * This command is used to force attachment to the network. | |
581 * | |
582 * @param row in the IPU structure related to the actual command | |
583 * @return DCM_OK or DCM errors | |
584 */ | |
585 LOCAL T_DCM_RET dcm_send_cgatt_cmd(U8 row) | |
586 { | |
587 TRACE_FUNCTION("DCM: dcm_send_cgatt_cmd()"); | |
588 | |
589 /* prepare the AT command including some dynamic info like cid */ | |
590 switch(sAT_PlusCGATT(CMD_SRC_LCL, CGATT_STATE_ATTACHED)) | |
591 { | |
592 case AT_FAIL: | |
593 case AT_BUSY: | |
594 psaDCM_open_conn_cnf(DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
595 dcm_free_row(row); | |
596 set_state_from_ctrl_blk(); | |
597 break; | |
598 | |
599 case AT_CMPL: | |
600 dcm_send_cgpco_auth_cmd(row); | |
601 break; | |
602 | |
603 case AT_EXCT: | |
604 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
605 dcm_new_state(DCM_ACTIVATING_CONN, DCM_SUB_WAIT_CGATT_CNF); | |
606 break; | |
607 | |
608 default : | |
609 break; | |
610 } | |
611 return DCM_OK; | |
612 } | |
613 | |
614 | |
615 /* | |
616 * Function used to send the <AT%CGPCO=0, cid, "PAP, username, | |
617 * password, 0.0.0.0, 0.0.0.0"> command | |
618 * | |
619 * This command is used to configure the PS to TCPIP over SNDCP | |
620 * | |
621 * @param row in the IPU structure related to the actual command | |
622 * @return DCM_OK or DCM errors | |
623 */ | |
624 LOCAL T_DCM_RET dcm_send_cgpco_auth_cmd(U8 row) | |
625 { | |
626 CHAR dns[2]; | |
627 strcpy(dns, ""); | |
628 | |
629 TRACE_FUNCTION("DCM: dcm_send_cgpco_auth_cmd()"); | |
630 TRACE_EVENT_P2("DCM: user=%s, password=%s", | |
631 dcm_env_ctrl_blk_p->ipu_list[row].user_id, | |
632 dcm_env_ctrl_blk_p->ipu_list[row].password); | |
633 | |
634 if(sAT_PercentCGPCO(CMD_SRC_LCL,dcm_env_ctrl_blk_p->ipu_list[row].cid, | |
635 ACI_PCO_AUTH_PROT_PAP, | |
636 (char*)dcm_env_ctrl_blk_p->ipu_list[row].user_id, | |
637 (char*)dcm_env_ctrl_blk_p->ipu_list[row].password, | |
638 dns,dns) != AT_CMPL) | |
639 { | |
640 psaDCM_open_conn_cnf(DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
641 dcm_free_row(row); | |
642 set_state_from_ctrl_blk(); | |
643 return DCM_OK; | |
644 } | |
645 else | |
646 { | |
647 dcm_send_cgerep_cmd(row); | |
648 return DCM_OK; | |
649 } | |
650 } | |
651 | |
652 | |
653 /* | |
654 * Function used to send the <AT+CGEREP=cid, 0> command | |
655 * | |
656 * This command is used to configure the PS to send EVENT to us | |
657 * | |
658 * @param row in the IPU structure related to the actual command | |
659 * @return DCM_OK or DCM errors | |
660 */ | |
661 LOCAL T_DCM_RET dcm_send_cgerep_cmd(U8 row) | |
662 { | |
663 TRACE_FUNCTION("DCM: dcm_send_cgerep_cmd()"); | |
664 | |
665 /* prepare the AT command including some dynamic info like cid */ | |
666 if (sAT_PlusCGEREP(CMD_SRC_LCL,CGEREP_MODE_BUFFER,CGEREP_BFR_CLEAR) != AT_CMPL) | |
667 { | |
668 psaDCM_open_conn_cnf(DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
669 dcm_free_row(row); | |
670 set_state_from_ctrl_blk(); | |
671 return DCM_OK; | |
672 } | |
673 else | |
674 { | |
675 strcpy((char*)dcm_env_ctrl_blk_p->ipu_list[row].phone_number,"*98*1#"); | |
676 dcm_send_sat_dn_cmd(row); | |
677 return DCM_OK; | |
678 } | |
679 } | |
680 | |
681 | |
682 /* | |
683 * Function used to send the <AT+CGACT=cid, 0> command | |
684 * | |
685 * This command is used to deactivate the PDP decontext. | |
686 * | |
687 * @param row in the IPU structure related to the actual command | |
688 * @return DCM_OK or DCM errors | |
689 */ | |
690 LOCAL T_DCM_RET dcm_send_cgdeact_cmd(U8 row) | |
691 { | |
692 T_CGATT_STATE gprs_attach_state; | |
693 SHORT cids[MAX_CID_PLUS_EINS] = {GPRS_CID_1,INVALID_CID}; | |
694 | |
695 TRACE_FUNCTION("DCM: dcm_send_cgdeact_cmd()"); | |
696 | |
697 /* Packet Counter */ | |
698 sAT_PercentSNCNT(CMD_SRC_LCL,SN_RESET_YES); | |
699 | |
700 qAT_PlusCGATT(CMD_SRC_LCL,&gprs_attach_state); | |
701 TRACE_EVENT_P1("DCM: Attatch State %d",gprs_attach_state); | |
702 | |
703 if(gprs_attach_state != CGATT_STATE_ATTACHED) | |
704 { | |
705 psaDCM_close_conn_cnf(DCM_OK,dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
706 dcm_free_row(row); | |
707 set_state_from_ctrl_blk(); | |
708 return DCM_OK; | |
709 } | |
710 | |
711 /* GPRS BEARER CLOSING */ | |
712 switch(sAT_PlusCGACT(CMD_SRC_LCL,CGACT_STATE_DEACTIVATED,cids)) | |
713 { | |
714 case AT_FAIL: | |
715 case AT_BUSY: | |
716 psaDCM_close_conn_cnf(DCM_NOT_READY, | |
717 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
718 set_state_from_ctrl_blk(); | |
719 break; | |
720 | |
721 case AT_CMPL: | |
722 psaDCM_close_conn_cnf(DCM_OK, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
723 dcm_free_row(row); | |
724 set_state_from_ctrl_blk(); | |
725 break; | |
726 | |
727 case AT_EXCT: | |
728 dcm_new_state(DCM_CLOSING_CONN, DCM_SUB_WAIT_CGDEACT_CNF); | |
729 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
730 break; | |
731 | |
732 default : | |
733 break; | |
734 } | |
735 return DCM_OK; | |
736 } | |
737 | |
738 | |
739 LOCAL T_DCM_RET dcm_send_sat_h_cmd(U8 row) | |
740 { | |
741 SHORT cid_array[1]; | |
742 cid_array[0] = INVALID_CID; | |
743 | |
744 TRACE_FUNCTION("DCM: dcm_send_sat_h_cmd()"); | |
745 | |
746 switch(sAT_H(CMD_SRC_LCL)) | |
747 { | |
748 case AT_FAIL: | |
749 case AT_BUSY: | |
750 psaDCM_close_conn_cnf(DCM_NOT_READY, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
751 set_state_from_ctrl_blk(); | |
752 break; | |
753 | |
754 case AT_CMPL: | |
755 break; | |
756 | |
757 case AT_EXCT: | |
758 dcm_new_state(DCM_CLOSING_CONN, DCM_SUB_WAIT_SATH_CNF); | |
759 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
760 break; | |
761 | |
762 default : | |
763 break; | |
764 } | |
765 return DCM_OK; | |
766 } | |
767 | |
768 | |
769 /* | |
770 * Function used to send the <AT+CGPADDR=cid> command | |
771 * | |
772 * This command is used to get back the pdp@ of the module | |
773 * | |
774 * @param row in the IPU structure related to the actual command | |
775 * @return DCM_OK or DCM errors | |
776 */ | |
777 LOCAL T_DCM_RET dcm_send_cgpaddr_cmd(U8 row) | |
778 { | |
779 T_PDP_ADDRESS pdp_address[MAX_CID]; | |
780 SHORT cid_array[MAX_CID]; | |
781 cid_array[0] = dcm_env_ctrl_blk_p->ipu_list[row].cid; | |
782 cid_array[1] =INVALID_CID; | |
783 | |
784 TRACE_FUNCTION("DCM: dcm_send_cgpaddr_cmd()"); | |
785 | |
786 memset(pdp_address , 0x00, sizeof(T_PDP_ADDRESS)*MAX_CID); | |
787 | |
788 /* prepare the AT command including some dynamic info like cid */ | |
789 if(sAT_PlusCGPADDR(CMD_SRC_LCL,cid_array,pdp_address) != AT_CMPL) | |
790 { | |
791 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
792 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
793 dcm_free_row(row); | |
794 set_state_from_ctrl_blk(); | |
795 return DCM_OK; | |
796 } | |
797 else | |
798 { | |
799 memcpy(dcm_env_ctrl_blk_p->ipu_list[row].pdp_addr, | |
800 pdp_address[0], | |
801 sizeof(T_PDP_ADDRESS)); | |
802 TRACE_EVENT_P1("DCM: PDP addr=%s",dcm_env_ctrl_blk_p->ipu_list[row].pdp_addr); | |
803 dcm_send_cgpco_get_cmd(row); | |
804 return DCM_OK; | |
805 } | |
806 } | |
807 | |
808 | |
809 /* | |
810 * Function used to send the <AT%CGPCO=1,1,,cid> command | |
811 * | |
812 * This command is used to get back the dns1, dns2 and gateway @ | |
813 * | |
814 * @param row in the IPU structure related to the actual command | |
815 * @return DCM_OK or DCM errors | |
816 */ | |
817 LOCAL T_DCM_RET dcm_send_cgpco_get_cmd(U8 row) | |
818 { | |
819 TRACE_FUNCTION("DCM: dcm_send_cgpco_get_cmd()"); | |
820 | |
821 psaDCM_open_conn_cnf(DCM_OK, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
822 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
823 dcm_new_state(DCM_CONN_ACTIVATED, DCM_SUB_NO_ACTION); | |
824 | |
825 return DCM_OK; | |
826 } | |
827 | |
828 | |
829 T_DCM_RET dcm_send_percentppp_cmd(U8 row) | |
830 { | |
831 TRACE_FUNCTION("DCM: dcm_send_percentppp_cmd()"); | |
832 if(sAT_PercentPPP(CMD_SRC_LCL, | |
833 A_PAP, | |
834 (char*)dcm_env_ctrl_blk_p->ipu_list[row].user_id, | |
835 (char*)dcm_env_ctrl_blk_p->ipu_list[row].password, | |
836 USE_NO_PPP_FOR_AAA) != AT_CMPL) | |
837 { | |
838 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
839 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
840 dcm_free_row(row); | |
841 set_state_from_ctrl_blk(); } | |
842 else | |
843 { | |
844 // reset the WAP-data if not done at call termination before | |
845 sAT_PercentWAP(0,0); | |
846 sAT_PercentWAP(0,1); | |
847 dcm_send_sat_dn_cmd(row); | |
848 } | |
849 | |
850 return DCM_OK; | |
851 } | |
852 | |
853 | |
854 LOCAL T_DCM_RET dcm_send_sat_dn_cmd(U8 row) | |
855 { | |
856 TRACE_FUNCTION("DCM: dcm_send_sat_dn_cmd()"); | |
857 | |
858 switch(sAT_Dn(CMD_SRC_LCL, | |
859 (char*)dcm_env_ctrl_blk_p->ipu_list[row].phone_number, | |
860 D_CLIR_OVRD_Default, | |
861 D_CUG_CTRL_NotPresent, | |
862 D_TOC_Data)) | |
863 { | |
864 case AT_FAIL: | |
865 case AT_BUSY: | |
866 case AT_CMPL: | |
867 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
868 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
869 dcm_free_row(row); | |
870 set_state_from_ctrl_blk(); | |
871 break; | |
872 | |
873 case AT_EXCT: | |
874 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
875 if(dcm_env_ctrl_blk_p->ipu_list[row].bearer_type == DCM_BEARER_GPRS) { | |
876 dcm_new_state(DCM_ACTIVATING_CONN, DCM_SUB_WAIT_CGACT_CNF); | |
877 } | |
878 else { | |
879 dcm_new_state(DCM_ACTIVATING_CONN, DCM_SUB_WAIT_SATDN_CNF); | |
880 } | |
881 break; | |
882 | |
883 default: | |
884 break; | |
885 } | |
886 | |
887 return DCM_OK; | |
888 } | |
889 | |
890 | |
891 LOCAL T_DCM_RET dcm_send_percentppp_get_cmd(U8 row) | |
892 { | |
893 ULONG dns1=0; | |
894 ULONG dns2 =0; | |
895 ULONG ipaddr = 0 ; | |
896 | |
897 TRACE_FUNCTION("DCM: dcm_send_percentppp_get_cmd()"); | |
898 | |
899 if(qAT_PercentPPP(CMD_SRC_LCL, &ipaddr,&dns1,&dns2) != AT_CMPL) | |
900 { | |
901 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
902 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
903 dcm_free_row(row); | |
904 set_state_from_ctrl_blk(); | |
905 } | |
906 else | |
907 { | |
908 psaDCM_open_conn_cnf(DCM_OK, | |
909 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
910 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
911 dcm_new_state(DCM_CONN_ACTIVATED,DCM_SUB_NO_ACTION); | |
912 } | |
913 | |
914 return DCM_OK; | |
915 } | |
916 | |
917 | |
918 /* | |
919 * Function used to process the events and errors received from PS | |
920 * | |
921 * @param received message | |
922 * @return DCM_OK or DCM errors | |
923 */ | |
924 T_DCM_RET dcm_process_event_error_reception(T_DCM_HDR * msg_p) | |
925 { | |
926 U8 row = dcm_env_ctrl_blk_p->current_row;; | |
927 | |
928 TRACE_FUNCTION("DCM: dcm_process_event_error_reception()"); | |
929 | |
930 /* check if this port number is really used by DCM */ | |
931 if(dcm_env_ctrl_blk_p->ipu_list[row].row_state) | |
932 { | |
933 psaDCM_error_ind((T_DCM_STATUS_IND_MSG*)msg_p, | |
934 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
935 dcm_free_row(row); | |
936 /* We cannot use this function call here (set_state_from_ctrl_blk();) | |
937 since this will execute reset_gpf_tcpip_call() immediately, but we need | |
938 to evaulate this flag later on */ | |
939 if((dcm_env_ctrl_blk_p->gsm_current_total_row + | |
940 dcm_env_ctrl_blk_p->gprs_current_total_row ) > 0) | |
941 { | |
942 /* another active connection */ | |
943 dcm_new_state(DCM_CONN_ACTIVATED, DCM_SUB_NO_ACTION); | |
944 } | |
945 else | |
946 { | |
947 dcm_new_state(DCM_IDLE, DCM_SUB_NO_ACTION); | |
948 } | |
949 } | |
950 return DCM_OK; | |
951 } | |
952 | |
953 | |
954 /* | |
955 * Function used to process the reception of the answer to AT+CGATT=... | |
956 * | |
957 * @param received message, and row in the IPU structure related to the actual command | |
958 * @return DCM_OK or DCM errors | |
959 */ | |
960 T_DCM_RET dcm_process_cgatt_ans(T_DCM_HDR * msg_p, U8 row) | |
961 { | |
962 TRACE_FUNCTION("DCM: dcm_process_cgatt_ans()"); | |
963 | |
964 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG) | |
965 { | |
966 /* send next AT command */ | |
967 return dcm_send_cgpco_auth_cmd(row); | |
968 } | |
969 else | |
970 { | |
971 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
972 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
973 dcm_free_row(row); | |
974 set_state_from_ctrl_blk(); | |
975 return DCM_OK; | |
976 } | |
977 } | |
978 | |
979 | |
980 /* | |
981 * Function used to process the reception of the answer to AT+CGACT=... | |
982 * | |
983 * @param received message, and row in the IPU structure related to the actual command | |
984 * @return DCM_OK or DCM errors | |
985 */ | |
986 T_DCM_RET dcm_process_cgact_ans(T_DCM_HDR * msg_p, U8 row) | |
987 { | |
988 TRACE_FUNCTION("DCM: dcm_process_cgact_ans()"); | |
989 | |
990 if (msg_p->msg_id == DCM_NEXT_CMD_READY_MSG) | |
991 { | |
992 return dcm_send_cgpaddr_cmd(row); | |
993 } | |
994 else | |
995 { | |
996 psaDCM_open_conn_cnf(DCM_NOT_READY, | |
997 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
998 dcm_free_row(row); | |
999 /*set_state_from_ctrl_blk();*/ | |
1000 /* We cannot use this function call here (set_state_from_ctrl_blk();) | |
1001 since this will execute reset_gpf_tcpip_call() immediately, but we need | |
1002 to evaulate this flag later on */ | |
1003 | |
1004 if((dcm_env_ctrl_blk_p->gsm_current_total_row + | |
1005 dcm_env_ctrl_blk_p->gprs_current_total_row ) > 0) | |
1006 { | |
1007 /* another active connection */ | |
1008 dcm_new_state(DCM_CONN_ACTIVATED, DCM_SUB_NO_ACTION); | |
1009 } | |
1010 else | |
1011 { | |
1012 dcm_new_state(DCM_IDLE, DCM_SUB_NO_ACTION); | |
1013 } | |
1014 return DCM_OK; | |
1015 } | |
1016 } | |
1017 | |
1018 | |
1019 T_DCM_RET dcm_process_cgdeact_ans(T_DCM_HDR * msg_p, U8 row) | |
1020 { | |
1021 TRACE_FUNCTION("DCM: dcm_process_cgdeact_ans()"); | |
1022 | |
1023 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG) | |
1024 { | |
1025 psaDCM_close_conn_cnf(DCM_OK, | |
1026 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1027 dcm_free_row(row); | |
1028 } | |
1029 else | |
1030 { | |
1031 psaDCM_close_conn_cnf(DCM_NOT_READY, | |
1032 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1033 dcm_env_ctrl_blk_p->ipu_list[row].row_state = ROW_ASSIGNED; | |
1034 } | |
1035 set_state_from_ctrl_blk(); | |
1036 return DCM_OK; | |
1037 } | |
1038 | |
1039 | |
1040 T_DCM_RET dcm_process_sat_dn_ans(T_DCM_HDR * msg_p, U8 row) | |
1041 { | |
1042 TRACE_FUNCTION("DCM: dcm_process_sat_dn_ans()"); | |
1043 | |
1044 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG) | |
1045 { | |
1046 return dcm_send_percentppp_get_cmd(row); | |
1047 } | |
1048 else | |
1049 { | |
1050 T_DCM_STATUS_IND_MSG * message = (T_DCM_STATUS_IND_MSG *)msg_p; | |
1051 /* We need to check if TCPIP has been already initialised successfully or not*/ | |
1052 if ( wap_state EQ TCPIP_Activation) | |
1053 { | |
1054 /* Make shure we shutdown TCPIP properly */ | |
1055 wap_state = TCPIP_Deactivation; | |
1056 psaTCPIP_Shutdown_Req(); | |
1057 } | |
1058 psaDCM_open_conn_cnf(message->result, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1059 dcm_free_row(row); | |
1060 set_state_from_ctrl_blk(); | |
1061 return DCM_OK; | |
1062 } | |
1063 } | |
1064 | |
1065 | |
1066 T_DCM_RET dcm_process_sat_h_ans(T_DCM_HDR * msg_p, U8 row) | |
1067 { | |
1068 TRACE_FUNCTION("DCM: dcm_process_sat_h_ans()"); | |
1069 | |
1070 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG) | |
1071 { | |
1072 psaDCM_close_conn_cnf(DCM_OK,dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1073 dcm_free_row(row); | |
1074 } | |
1075 else | |
1076 { | |
1077 psaDCM_close_conn_cnf(DCM_NOT_READY, | |
1078 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1079 } | |
1080 set_state_from_ctrl_blk(); | |
1081 return DCM_OK; | |
1082 } | |
1083 | |
1084 | |
1085 GLOBAL ULONG bytes2ipv4addr(UBYTE *host) | |
1086 { | |
1087 UBYTE c1; | |
1088 ULONG addr = 0; | |
1089 char *tmp; | |
1090 if (!host || host[0]>'9' || host[0]<'0') return -1; | |
1091 | |
1092 tmp=(char *)host; | |
1093 c1 = atoi(tmp); | |
1094 addr = addr | c1 << 24; | |
1095 tmp = strstr(tmp, "."); | |
1096 if(!tmp) return -1; | |
1097 tmp++; | |
1098 c1 = atoi(tmp); | |
1099 addr = addr | c1 << 16; | |
1100 tmp = strstr(tmp, "."); | |
1101 if(!tmp) return -1; | |
1102 tmp++; | |
1103 c1 = atoi(tmp); | |
1104 addr = addr | c1 <<8 ; | |
1105 tmp = strstr(tmp, "."); | |
1106 if(!tmp) return -1; | |
1107 tmp++; | |
1108 c1 = atoi(tmp); | |
1109 addr = addr | c1 ; | |
1110 return dcm_ipaddr_htonl(addr); | |
1111 } | |
1112 | |
1113 | |
1114 LOCAL ULONG dcm_ipaddr_htonl(ULONG horder_ipaddr) | |
1115 { | |
1116 return((U32)((((U32)(horder_ipaddr) & 0x000000ffU) << 24) | | |
1117 (((U32)(horder_ipaddr) & 0x0000ff00U) << 8) | | |
1118 (((U32)(horder_ipaddr) & 0x00ff0000U) >> 8) | | |
1119 (((U32)(horder_ipaddr) & 0xff000000U) >> 24))); | |
1120 } | |
1121 | |
1122 | |
1123 LOCAL T_DCM_RET dcm_send_percentcal_get_cmd(UBYTE row) | |
1124 { | |
1125 T_ACI_CAL_ENTR call_tab[MAX_CALL_NR]; | |
1126 UBYTE i; | |
1127 UBYTE count = 0; | |
1128 | |
1129 TRACE_FUNCTION("DCM: dcm_send_percentcal_get_cmd()"); | |
1130 | |
1131 if(qAT_PercentCAL(CMD_SRC_LCL, call_tab) EQ AT_CMPL) | |
1132 { | |
1133 for(i=0; i<MAX_CALL_NR; i++) | |
1134 { | |
1135 if(call_tab[i].index == -1) | |
1136 { | |
1137 count++; | |
1138 /* in other words no active call*/ | |
1139 if(count EQ (MAX_CALL_NR -1) ) | |
1140 { | |
1141 TRACE_EVENT("DCM: No active call"); | |
1142 psaDCM_close_conn_cnf(DCM_OK, dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1143 dcm_free_row(row); | |
1144 set_state_from_ctrl_blk(); | |
1145 } | |
1146 break; | |
1147 } | |
1148 switch(call_tab[i].status) | |
1149 { | |
1150 case CAL_STAT_Active: | |
1151 dcm_send_sat_h_cmd(row); | |
1152 break; | |
1153 case CAL_STAT_Dial: | |
1154 case CAL_STAT_Alerting: | |
1155 dcm_send_sat_abort_cmd(row); | |
1156 break; | |
1157 | |
1158 default: | |
1159 TRACE_EVENT("DCM: dcm_send_percentcal_get_cmd DEFAULT call status"); | |
1160 break; | |
1161 } | |
1162 } | |
1163 return DCM_OK; | |
1164 } | |
1165 return DCM_OK; | |
1166 } | |
1167 | |
1168 | |
1169 LOCAL T_DCM_RET dcm_send_sat_abort_cmd(U8 row) | |
1170 { | |
1171 TRACE_FUNCTION("DCM: dcm_send_sat_h_cmd()"); | |
1172 | |
1173 switch(sAT_Abort(CMD_SRC_LCL,AT_CMD_D)) | |
1174 { | |
1175 case AT_FAIL: | |
1176 case AT_BUSY: | |
1177 psaDCM_close_conn_cnf(DCM_NOT_READY, | |
1178 dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1179 set_state_from_ctrl_blk(); | |
1180 break; | |
1181 | |
1182 case AT_CMPL: | |
1183 psaDCM_close_conn_cnf(DCM_OK,dcm_env_ctrl_blk_p->ipu_list[row].api_instance); | |
1184 dcm_free_row(row); | |
1185 set_state_from_ctrl_blk(); | |
1186 break; | |
1187 | |
1188 case AT_EXCT: | |
1189 dcm_new_state(DCM_CLOSING_CONN, DCM_SUB_WAIT_SATH_CNF); | |
1190 dcm_env_ctrl_blk_p->dcm_call_back = dcm_handle_message; | |
1191 break; | |
1192 | |
1193 default : | |
1194 break; | |
1195 } | |
1196 return DCM_OK; | |
1197 } | |
1198 | |
1199 | |
1200 /* This functions checks if antother conneciton is active and changes the | |
1201 DCM state corresponding */ | |
1202 LOCAL void set_state_from_ctrl_blk() | |
1203 { | |
1204 if((dcm_env_ctrl_blk_p->gsm_current_total_row + | |
1205 dcm_env_ctrl_blk_p->gprs_current_total_row ) > 0) | |
1206 { | |
1207 /* another active connection */ | |
1208 dcm_new_state(DCM_CONN_ACTIVATED, DCM_SUB_NO_ACTION); | |
1209 } | |
1210 else | |
1211 { | |
1212 dcm_new_state(DCM_IDLE, DCM_SUB_NO_ACTION); | |
1213 reset_gpf_tcpip_call(); | |
1214 } | |
1215 } |