[Title] translate Korean comment to English.
[platform/adaptation/emulator/vmodem-daemon-emulator.git] / vmodem / server / server_rx_ss.c
1 /*
2  *  telephony-emulator
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: 
7  * Sooyoung Ha <yoosah.ha@samsung.com>
8  * Sungmin Ha <sungmin82.ha@samsung.com>
9  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
10  * 
11  * This library is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU Lesser General Public License as published by the
13  * Free Software Foundation; either version 2.1 of the License, or (at your option)
14  * any later version.
15  * 
16  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
17  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19  * License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library; if not, write to the Free Software Foundation, Inc., 51
23  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  * 
28  */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include "vgsm_ss.h"
34 #include "oem_tx_ss.h"
35 #include "server_common_ss.h"
36 #include "db_ss.h"
37 #include "misc.h"
38 #include "vgsm_phone.h"
39 #include "state.h" // gen_resp()
40 #include "phoneserver.h"
41 #include "server_rx_ss.h"
42 #include "server_rx_call.h"
43 #include "vgsm_debug.h"
44 #include "logmsg.h"
45 #include "at_func.h"
46 #include "at_recv.h"
47 #include "at_gen_resp.h"
48
49 #define SS_ERR_NEGATIVE_PW_CHECK        0x8126
50 #define SS_PW_ATTEMPS_VIOLATION 0x812b
51
52 // 090305
53 int server_rx_ss_cw_get(int tel_class)
54 {
55         VGSM_DEBUG("\n");
56
57         call_waiting_entry_t * cw_entry;
58         char * data = 0;
59         int data_len = 64;
60         int ss_status, ret;
61
62         log_msg(MSGL_VGSM_INFO,"tel_class = %d \n", tel_class);
63         cw_entry = find_call_waiting_entry(tel_class);
64         if(cw_entry->ss_mode == SS_MODE_ACT)
65                 ss_status = AT_SS_STATUS_ACTIVE;
66         else
67                 ss_status = AT_SS_STATUS_NOT_ACTIVE;
68
69         data = malloc(sizeof(char) * data_len);
70         strcpy(data, CCWA);
71         sprintf(&data[strlen(data)], "%d", ss_status);
72         strcat(data, TOKEN);
73         sprintf(&data[strlen(data)], "%d", AT_CALL_CLASS_VOICE);
74         strcat(data, CRLF);
75
76         log_msg(MSGL_VGSM_INFO,"found & resp: tel_class = %d, ss_mode = %d, ss_status = %d \n"
77                         , cw_entry->tel_class, cw_entry->ss_mode, ss_status);
78
79         ret = oem_tx_ss_cw_resp(data, strlen(data));
80
81         free(data);
82         return 1;
83 }
84
85 int server_rx_ss_cb_get(int tel_class, int cb_type)
86 {
87         VGSM_DEBUG("\n");
88
89         call_barring_entry_t * cb_entry;
90
91         log_msg(MSGL_VGSM_INFO,"tel_class = %d, cb_type = %d \n", tel_class, cb_type);
92
93         cb_entry = find_call_barring_entry(tel_class, cb_type);
94
95         return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
96 }
97
98 int server_rx_ss_cf_get(int tel_class, int cf_type)
99 {
100         VGSM_DEBUG("\n");
101
102         call_forwarding_entry_t * cf_entry;
103         int ss_status, ret;
104         char sndbuf[SEND_BUF_SIZE];
105         memset(sndbuf, '\0', sizeof(sndbuf));
106
107         log_msg(MSGL_VGSM_INFO,"tel_class = %d, cf_type = %d \n", tel_class, cf_type);
108         cf_entry = find_call_forwarding_entry(tel_class, cf_type);
109
110         log_msg(MSGL_VGSM_INFO," entry->count = %d \n", cf_entry->count);
111
112         if(cf_entry->ss_mode == SS_MODE_REG || cf_entry->ss_mode == SS_MODE_ACT)
113                 ss_status = AT_SS_STATUS_ACTIVE;
114         else
115                 ss_status = AT_SS_STATUS_NOT_ACTIVE;
116
117         sprintf(sndbuf, "%s%d,%d", CCFC, ss_status, cf_entry->tel_class);
118         if(ss_status == AT_SS_STATUS_ACTIVE)
119         {
120                 log_msg(MSGL_VGSM_INFO, "cf number:%s\n", cf_entry->number);
121                 sprintf(&sndbuf[strlen(sndbuf)], ",%s", cf_entry->number);
122         }
123         strcat(sndbuf, CRLF);
124
125         ret = oem_tx_ss_cf_resp(sndbuf, strlen(sndbuf));
126
127         return 1;
128 }
129
130 int server_rx_ss_cli(char *api)
131 {
132         at_unimplemented(api);
133         return 1;
134 }
135
136 int server_rx_ss_cw_set(int tel_class, int ss_mode)
137 {
138         VGSM_DEBUG("\n");
139
140         int i;
141         int db_err;
142         LXT_MESSAGE packet;
143         TAPIMessageInit(&packet);
144
145         log_msg(MSGL_VGSM_INFO,"tel_class = %d, ss_mode = %d \n", tel_class, ss_mode);
146
147         /* add or update */
148         call_waiting_entry_t * entry = malloc(sizeof(call_waiting_entry_t));
149         if(entry == NULL){
150                 log_msg(MSGL_VGSM_ERR,"malloc fail \n");
151                 return 0;
152         }
153         memset(entry, 0, sizeof(call_waiting_entry_t));
154         entry->tel_class = tel_class;
155         entry->ss_mode = ss_mode;
156         strcpy(entry->number, SUBSCRIBER_NUM);
157         log_msg(MSGL_VGSM_INFO, "%s", entry->number);
158         if( ( db_err = vgsm_ss_database_add(SS_CMD_CW, entry) ) > 0){
159                 log_msg(MSGL_WARN,"vgsm_ss_database_add() is failed!!db_err = %d \n", db_err);
160         }
161
162         if(entry){
163                 free(entry);
164         }
165
166         /* resp */
167         call_waiting_entry_t * resp_entry = get_call_waiting_entry();
168         if(!resp_entry){
169                 /* Not happen ?? */
170                 log_msg(MSGL_WARN,"entry is NULL!!!\n");
171         }
172
173         if(resp_entry){
174                 for(i=0; i<resp_entry[0].count; i++){
175                         log_msg(MSGL_VGSM_INFO,"i : %d,  tel_class : %d, ss_mode : %d\n"
176                                         , i, resp_entry[i].tel_class, resp_entry[i].ss_mode);
177                 }
178         }
179
180         resp_entry[0].tel_class = 255;// temporary      
181         packet.data = resp_entry;
182         packet.group  = GSM_SUPS;
183         packet.action = GSM_SUPS_SET_CW_REQ;
184         packet.length = (sizeof(call_waiting_entry_t) * resp_entry[0].count);
185
186         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
187         resp_entry[0].tel_class = 1;
188
189         return 0;
190 }
191
192 //int server_rx_ss_cf_set(int ss_mode, int type, int tel_class, int replyTime, int num_len, char *number, int num_type, int satype, char* subaddr)
193 int server_rx_ss_cf_set(int ss_mode, int type, int tel_class, int replyTime, int num_len, char *number, int num_type)
194 {
195         VGSM_DEBUG("\n");
196
197         int i;
198         LXT_MESSAGE packet;
199         TAPIMessageInit(&packet);
200
201         call_forwarding_entry_t * entry = malloc(sizeof(call_forwarding_entry_t));
202         if(!entry)
203                 return -1;
204         memset(entry, 0, sizeof(call_forwarding_entry_t));
205
206         entry->ss_mode = ss_mode;
207         entry->type = type;
208         entry->tel_class = tel_class;
209         entry->replyTime = replyTime;
210 //      entry->number_type = num_type;
211 //      entry->satype = satype;
212 //      memcpy(entry->subaddr, subaddr, MAX_GSM_DIALED_DIGITS_NUMBER);
213         
214         if(num_len)
215         {
216                 strcpy(entry->number, number);
217                 log_msg(MSGL_VGSM_INFO,"============ %s(%d) \n", entry->number, num_len);
218         }
219
220
221         // 090326
222         log_msg(MSGL_VGSM_INFO,"=check=========== (%x)(%x) \n", entry->type, entry->ss_mode);
223         if(entry->ss_mode == SS_MODE_DEACT || entry->ss_mode == SS_MODE_DEREG)
224         {
225                 // 090326
226                 //if(entry->type == SS_CF_TYPE_CF_ALL && entry->ss_mode == SS_MODE_DEACT)               //disable all call forwarding
227                 if(entry->type == SS_CF_TYPE_CF_ALL)            //disable all call forwarding
228                 {
229                         // 090327  SS_CF_TYPE_CFU ---> SS_CF_TYPE_CF_ALL
230                         if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CF_ALL) > 0)
231                                 log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFU is failed!!\n");
232
233                 }
234                 // 090326
235                 //else if(entry->type == SS_CF_TYPE_CFC && entry->ss_mode == SS_MODE_DEACT)             //disable all conditional call forwarding
236                 else if(entry->type == SS_CF_TYPE_CFC)          //disable all conditional call forwarding
237                 {
238                         if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFB) > 0)
239                                 log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFB is failed!!\n");
240
241                         if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRy) > 0)
242                                 log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRy is failed!!\n");
243
244                         if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRc) > 0)
245                                 log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRc is failed!!\n" );
246                 }
247                 // add 090326
248                 else
249                 {
250                         if(entry->type == SS_CF_TYPE_CFU)
251                         {
252                                 if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFU) > 0)
253                                         log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFU is failed!!\n");
254                         }
255                         else if(entry->type == SS_CF_TYPE_CFB)
256                         {
257                                 if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFB) > 0)
258                                         log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFB is failed!!\n");
259                         }
260                         else if(entry->type == SS_CF_TYPE_CFNRy)
261                         {
262                                 if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRy) > 0)
263                                         log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFNRy is failed!!\n" );
264                         }
265                         else if(entry->type == SS_CF_TYPE_CFNRc)
266                         {
267                                 if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRc) > 0)
268                                         log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRc is failed!!\n");
269                         }
270                 }
271         }
272         else
273         {
274                 //call forwarding table update
275                 if(vgsm_ss_database_add(SS_CMD_CF, entry) > 0)
276                         log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_add() is failed!!\n" );                
277         }
278
279         if(entry)
280                 free(entry);
281
282         // send data to eventinjector -> ui update
283         call_forwarding_entry_t * resp_entry = get_call_forwarding_entry();
284
285         //for debug
286         if(!resp_entry)
287                 log_msg(MSGL_WARN,"entry is NULL!!! \n" );
288         if(resp_entry)
289         {
290                 for(i=0; i<resp_entry[0].count; i++)
291                 {
292                         log_msg(MSGL_WARN,"i: %d, tel_class : 0x%x, type : %d, number : %s, ss_mode : %d\n",
293                                         i, resp_entry[i].tel_class, resp_entry[i].type, resp_entry[i].number, resp_entry[i].ss_mode);
294                 }
295         }
296
297         packet.data = resp_entry;
298         packet.group  = GSM_SUPS;
299         packet.action = GSM_SUPS_SET_CCFC_REQ;
300         packet.length = (sizeof(call_forwarding_entry_t) * resp_entry[0].count);
301
302         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
303
304         return 1;
305 }
306
307 int server_rx_ss_cb_set(int cb_type, int ss_mode, int tel_class, char *passwd)
308 {
309         VGSM_DEBUG("\n");
310
311         int i, gen_resp_err;
312         LXT_MESSAGE packet;
313         TAPIMessageInit(&packet);
314         int cb_pwd_fail_count = 0;
315
316         call_barring_entry_t * entry =  malloc(sizeof(call_barring_entry_t));
317         if(!entry)
318                 return -1;
319         memset(entry, 0, sizeof(call_barring_entry_t));
320
321         entry->type =cb_type;
322         entry->ss_mode = ss_mode;
323         entry->tel_class = tel_class;
324         char* tmp_cb_pwd = get_callbarring_pwd();
325         VGSM_DEBUG("orig_pwd:%s, input_pwd:%s\n", tmp_cb_pwd, passwd);
326
327         if( strcmp(passwd, tmp_cb_pwd) != 0)
328         {
329                 VGSM_DEBUG("Wrong CallBarring Passwd\n");
330                 cb_pwd_fail_count = increase_callbarring_pwd_fail_count();
331                 VGSM_DEBUG("cb_pwd_fail_count = %d\n",cb_pwd_fail_count);
332
333                 if(cb_pwd_fail_count >= 3)
334                         gen_resp_err = SS_PW_ATTEMPS_VIOLATION; // numberOfPW_AttemptsViolation
335                 else
336                         gen_resp_err = SS_ERR_NEGATIVE_PW_CHECK; // NegativePasswordCheck
337
338                 oem_tx_ss_gen_resp(AT_CME_ERR_INCORRECT_PWD);
339                 free(entry);
340                 return 1;
341         }
342
343         VGSM_DEBUG("Right CallBarring Passwd\n");
344
345         clear_callbarring_pwd_fail_count();
346
347         /* gen resp */
348         set_ss_current_general_response_error( get_ss_general_response_error() );
349         gen_resp_err = get_ss_current_general_response_error();
350         oem_tx_ss_gen_resp(AT_GEN_ERR_NO_ERROR);
351         
352         if(gen_resp_err != 0x8000)
353         {
354                 log_msg(MSGL_WARN, "gen_resp_err : %d \n", gen_resp_err);
355                 free(entry);
356                 return 1;
357         }
358
359         if(entry->tel_class == AT_CALL_SS_CLASS_VIDEO)
360         {
361                 if(entry->type == SS_CB_TYPE_AB)
362                 {
363                         set_outgoing_video_call_barring_state(entry->ss_mode);
364                         set_incoming_video_call_barring_state(entry->ss_mode);
365                 }
366                 else if(entry->type == SS_CB_TYPE_BAOC)
367                 {
368                         set_outgoing_video_call_barring_state(entry->ss_mode);
369                 }
370                 else if(entry->type == SS_CB_TYPE_BAIC)
371                 {
372                         set_incoming_video_call_barring_state(entry->ss_mode);
373                 }
374         }
375         else
376         {
377                 if(entry->type == SS_CB_TYPE_AB)
378                 {
379                         set_outgoing_voice_call_barring_state(entry->ss_mode);
380                         set_incoming_voice_call_barring_state(entry->ss_mode);
381                 }
382                 else if(entry->type == SS_CB_TYPE_BAOC)
383                 {
384                         set_outgoing_voice_call_barring_state(entry->ss_mode);
385                 }
386                 else if(entry->type == SS_CB_TYPE_BAIC)
387                 {
388                         set_incoming_voice_call_barring_state(entry->ss_mode);
389                 }
390         }
391
392         if( (entry->type == SS_CB_TYPE_AB ) && (entry->ss_mode == SS_MODE_DEREG || entry->ss_mode == SS_MODE_DEACT)) // cancel all.
393         {
394                 entry->type = SS_CB_TYPE_BAOC;
395                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
396                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
397
398                 entry->type = SS_CB_TYPE_BOIC;
399                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
400                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
401
402                 entry->type = SS_CB_TYPE_BOIC_NOT_HC;
403                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
404                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
405
406                 entry->type = SS_CB_TYPE_BAIC;
407                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
408                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
409
410                 entry->type = SS_CB_TYPE_BIC_ROAM;                      
411                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
412                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
413
414                 entry->type = SS_CB_TYPE_AB; //rollback.
415         }               
416         else
417         {
418                 if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
419                         log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );            
420         }
421
422         if(entry)
423                 free(entry);
424
425         call_barring_entry_t * resp_entry  = get_call_barring_entry();
426
427         //for debug
428         if(!resp_entry)
429                 log_msg(MSGL_WARN, "entry is NULL!!! \n" );
430         if(resp_entry)
431         {
432                 for(i=0; i<resp_entry[0].count; i++)
433                 {
434                         log_msg(MSGL_VGSM_INFO,"i : %d,  tel_class : %d, ss_mode : %d\n",
435                                         i, resp_entry[i].tel_class, resp_entry[i].ss_mode);
436                 }
437         }
438
439         packet.data = resp_entry;
440         packet.group  = GSM_SUPS;
441         packet.action = GSM_SUPS_SET_CB_REQ;
442         packet.length = (sizeof(call_barring_entry_t) * resp_entry[0].count);
443
444         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
445
446         return 1;
447
448 }
449
450 int server_rx_ss_cb_passwd_set(char* curr_passwd, char* new_passwd)
451 {
452         VGSM_DEBUG("\n");
453         if(!curr_passwd || !new_passwd)
454                 return -1;
455
456         int gen_resp_err;
457         LXT_MESSAGE packet;
458         TAPIMessageInit(&packet);
459         int cb_pwd_fail_count = 0;
460
461         char* tmp_cb_pwd = get_callbarring_pwd();
462
463         if( memcmp(tmp_cb_pwd, curr_passwd, 4 ) != 0)
464         {
465                 VGSM_DEBUG("Wrong CallBarring Passwd\n");
466                 cb_pwd_fail_count = increase_callbarring_pwd_fail_count();
467                 VGSM_DEBUG("cb_pwd_fail_count = %d\n",cb_pwd_fail_count);
468
469                 if(cb_pwd_fail_count >= 3)
470                         gen_resp_err = SS_PW_ATTEMPS_VIOLATION; // numberOfPW_AttemptsViolation
471                 else
472                         gen_resp_err = SS_ERR_NEGATIVE_PW_CHECK; // NegativePasswordCheck
473
474                 oem_tx_ss_gen_resp(gen_resp_err);
475                 return 1;
476         }
477
478         VGSM_DEBUG("Right CallBarring Passwd\n");
479
480         clear_callbarring_pwd_fail_count();
481
482         /* gen resp */
483         set_ss_current_general_response_error( get_ss_general_response_error() );
484         gen_resp_err = get_ss_current_general_response_error();
485         oem_tx_ss_gen_resp(gen_resp_err);
486         if(gen_resp_err != 0x8000)
487         {
488                 log_msg(MSGL_WARN,"gen_resp_err : %d \n", gen_resp_err);
489                 return 1;
490         }
491
492         set_callbarring_pwd(new_passwd);
493
494         VGSM_DEBUG("CallBarring Passwd changed\n");
495
496         packet.data = new_passwd;
497         packet.group  = GSM_SUPS;
498         packet.action = GSM_SUPS_PWDSET_CB_REQ;
499         packet.length = strlen(new_passwd);
500
501         VGSM_DEBUG("CallBarring Passwd changed\n");
502
503         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
504         /* EI receives this event then,
505          * popup(callbarring password changed!!) --> callbarring password : new_passwd
506          */
507
508         return 1;
509 }
510
511 int server_rx_ss_aoc_get(void)                          // 090215   vgsm -> EI
512 {
513         LXT_MESSAGE packet;
514         unsigned char * data = 0;
515         int             data_len;
516         _AOC_t  tmp;
517
518         tmp.acm = 123;
519         tmp.ccm = 234;
520         tmp.maxacm = 345;
521         tmp.ppu = 456;
522         tmp.chartype = 7;
523
524         data_len = sizeof(tmp);
525
526         VGSM_DEBUG("\n");
527
528         get_aoc_data( &tmp);
529
530         data = malloc(sizeof(unsigned char) * data_len);
531         memset(data, 0, data_len);
532         memcpy(data, &tmp, data_len);
533
534         VGSM_DEBUG("Send AOC DATA to EI\n");
535         packet.data = data;
536         packet.group  = GSM_SUPS;
537         packet.action = GSM_SUPS_AOC_GET;
538         packet.length = data_len;
539
540         VGSM_DEBUG("Send AOC DATA to EI\n");
541         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
542
543         free(data);
544         return 1;
545 }
546
547 int server_rx_ss_ussd_get(void)                         // 090215   vgsm -> EI
548 {
549         LXT_MESSAGE packet;
550         unsigned char * data = 0;
551         int             data_len;
552         _USSD_data_t    tmp;
553
554         strcpy(tmp.time, "12:00:00, 2000");
555         strcpy(tmp.weather, "Fine");
556
557         data_len = sizeof(tmp);
558
559         VGSM_DEBUG("\n");
560
561         get_ussd_data( &tmp);
562
563         data = malloc(sizeof(unsigned char) * data_len);
564         memset(data, 0, data_len);
565         memcpy(data, &tmp, data_len);
566
567         VGSM_DEBUG("Send USSD DATA to EI\n");
568         VGSM_DEBUG("time : %s\n", tmp.time);
569         VGSM_DEBUG("weather : %s\n", tmp.weather);
570         packet.data = data;
571         packet.group  = GSM_SUPS;
572         packet.action = GSM_SUPS_USSD_GET;
573         packet.length = data_len;
574
575         VGSM_DEBUG("Send ussd DATA to EI\n");
576         FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
577
578 #if 1
579         free(data);
580 #endif
581         return 1;
582 }
583
584 int server_rx_ss_manage_call_set(char* ptr_data, int data_len)
585 {
586         int rtn=0;
587         int signal = 0;
588         char* data = strchr(ptr_data, '=');
589         char token[] = "\n";
590         char* ret = NULL;
591         int call_id = 0;
592
593         ret = strtok(data+1, token);
594         if(ret)
595                 signal = atoi(ret);
596
597         if(signal == AT_GSM_SS_CM_0_SEND)       // release all held call
598         {
599                 rtn = server_rx_call_release_incoming();
600                 if(rtn == 0)
601                         rtn = server_rx_call_release_all_held();
602         }
603         else if(signal == AT_GSM_SS_CM_1_SEND)    // release all active call and the other (held or waiting) call
604         {
605                 rtn = server_rx_call_release_all_active(); 
606         }
607         else if(signal == AT_GSM_SS_CM_2_SEND)    // active call on hold and held or waiting call on active
608         {
609                 VGSM_DEBUG("g_ss_hold_response_error: err =%x \n", g_ss_hold_response_error);   
610                 //at_gen_resp_send( g_ss_hold_response_error);
611                 if ( g_ss_hold_response_error == 0x8000 )
612                         rtn = server_rx_call_swap();
613                 else
614                         VGSM_DEBUG("g_ss_hold_response_error: err =%x \n", g_ss_hold_response_error);
615         }
616         else if(signal == AT_GSM_SS_CM_3_SEND)    // add a held call to the conversation
617         {
618                 VGSM_DEBUG("g_ss_join_response_error: err =%x \n", g_ss_join_response_error);
619                 //at_gen_resp_send( g_ss_join_response_error);
620                 if ( g_ss_join_response_error == 0x8000   )
621                         rtn = server_rx_call_join_conf();  // TODO: call id is needed?? check....
622                 else
623                         VGSM_DEBUG("g_ss_join_response_error: err =%x \n", g_ss_join_response_error);
624         }
625         else if(signal >= 10 && signal < 20 )    // AT_GSM_SS_CM_1X_SEND : connect the two call and disconnect the subscriber from both calls
626         {
627                 call_id = signal - 11;
628                 rtn = server_rx_call_release_single(call_id);
629         }
630         else if(signal >= 20 && signal < 30 )   // AT_GSM_SS_CM_2X_SEND : Places all active calls on hold except call X with which communication shall be supported.
631         {
632                 call_id = signal - 21;
633                 VGSM_DEBUG("server_rx_call_split_conf : err =%x \n", g_ss_split_response_error);
634                 //at_gen_resp_send( g_ss_split_response_error);
635                 if ( g_ss_split_response_error == 0x8000   )
636                         rtn = server_rx_call_split_conf(call_id);
637                 else
638                         VGSM_DEBUG("server_rx_call_split_conf : err =%x \n", g_ss_split_response_error);
639         }
640         else
641         {
642                 VGSM_DEBUG (" not supported ID = %d \n" , signal);
643         }
644
645         return rtn;
646 }
647
648