upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:02:09 +0000 (17:02 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:02:09 +0000 (17:02 +0900)
319 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
NOTICE [new file with mode: 0644]
build.sh [new file with mode: 0644]
build_dpkg.sh [new file with mode: 0644]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/vmodemd-emul.install.in [new file with mode: 0644]
debian/vmodemd-emul.postinst.in [new file with mode: 0644]
lib/libcommon/Makefile.in [new file with mode: 0644]
lib/libcommon/fileio.c [new file with mode: 0644]
lib/libcommon/fileio.h [new file with mode: 0644]
lib/libcommon/logmsg.c [new file with mode: 0644]
lib/libcommon/logmsg.h [new file with mode: 0644]
lib/libcommon/process.c [new file with mode: 0644]
lib/libcommon/process.h [new file with mode: 0644]
lib/libcommon/safestring.c [new file with mode: 0644]
lib/libcommon/safestring.h [new file with mode: 0644]
lib/libsms/Makefile.in [new file with mode: 0644]
lib/libsms/sms_header.h [new file with mode: 0644]
lib/libsms/sms_tool.c [new file with mode: 0644]
lib/libsms/sms_util.c [new file with mode: 0644]
lib/libsms/sms_util.h [new file with mode: 0644]
lib/libui/Makefile.in [new file with mode: 0644]
lib/libui/dialog.c [new file with mode: 0644]
lib/libui/dialog.h [new file with mode: 0644]
lib/libui/imageutil.c [new file with mode: 0644]
lib/libui/imageutil.h [new file with mode: 0644]
lib/libui/ui_imageid.h [new file with mode: 0644]
lib/libui/utils.c [new file with mode: 0644]
lib/libui/utils.h [new file with mode: 0644]
libvmodem/Makefile.in [new file with mode: 0644]
libvmodem/db_phonebook.h [new file with mode: 0644]
libvmodem/libvgsm_call.c [new file with mode: 0644]
libvmodem/libvgsm_data.c [new file with mode: 0644]
libvmodem/libvgsm_debug.h [new file with mode: 0644]
libvmodem/libvgsm_display.c [new file with mode: 0644]
libvmodem/libvgsm_edb.c [new file with mode: 0644]
libvmodem/libvgsm_emul.c [new file with mode: 0644]
libvmodem/libvgsm_gprs.c [new file with mode: 0644]
libvmodem/libvgsm_hdlc.c [new file with mode: 0644]
libvmodem/libvgsm_init.c [new file with mode: 0644]
libvmodem/libvgsm_network.c [new file with mode: 0644]
libvmodem/libvgsm_power.c [new file with mode: 0644]
libvmodem/libvgsm_sat.c [new file with mode: 0644]
libvmodem/libvgsm_sim.c [new file with mode: 0644]
libvmodem/libvgsm_sms.c [new file with mode: 0644]
libvmodem/libvgsm_ss.c [new file with mode: 0644]
libvmodem/linuxtapi.h [new file with mode: 0644]
libvmodem/linuxtapi4gsm.h [new file with mode: 0644]
libvmodem/linuxtapi4gsm_type.h [new file with mode: 0644]
libvmodem/linuxtapi4type.h [new file with mode: 0644]
libvmodem/lxtsms.c [new file with mode: 0644]
libvmodem/lxtsms.h [new file with mode: 0644]
libvmodem/lxtsmstypedef.h [new file with mode: 0644]
libvmodem/lxtutil.c [new file with mode: 0644]
libvmodem/lxtutil.h [new file with mode: 0644]
libvmodem/phoneprotocol.h [new file with mode: 0644]
libvmodem/phoneprotocol4gsm.h [new file with mode: 0644]
libvmodem/samsungtapi.h [new file with mode: 0644]
libvmodem/sqlite3.h [new file with mode: 0644]
libvmodem/tapi4phonebook.h [new file with mode: 0644]
libvmodem/types4cardboot.h [new file with mode: 0644]
libvmodem/vgsm.h [new file with mode: 0644]
libvmodem/vgsm_call.h [new file with mode: 0644]
libvmodem/vgsm_data.h [new file with mode: 0644]
libvmodem/vgsm_display.h [new file with mode: 0644]
libvmodem/vgsm_edb.h [new file with mode: 0644]
libvmodem/vgsm_error.h [new file with mode: 0644]
libvmodem/vgsm_gprs.h [new file with mode: 0644]
libvmodem/vgsm_hdlc.h [new file with mode: 0644]
libvmodem/vgsm_network.h [new file with mode: 0644]
libvmodem/vgsm_pb.h [new file with mode: 0644]
libvmodem/vgsm_phone.h [new file with mode: 0644]
libvmodem/vgsm_power.h [new file with mode: 0644]
libvmodem/vgsm_sat.h [new file with mode: 0644]
libvmodem/vgsm_sim.h [new file with mode: 0644]
libvmodem/vgsm_sms.h [new file with mode: 0644]
libvmodem/vgsm_ss.h [new file with mode: 0644]
packaging/vmodemd-emul.spec [new file with mode: 0644]
vmodem/DO_NO_MERGE [new file with mode: 0644]
vmodem/Makefile.in [new file with mode: 0644]
vmodem/at/at_func.c [new file with mode: 0644]
vmodem/at/at_gen_resp.c [new file with mode: 0644]
vmodem/at/at_msg.c [new file with mode: 0644]
vmodem/at/at_recv.c [new file with mode: 0644]
vmodem/at/at_rx_call.c [new file with mode: 0644]
vmodem/at/at_rx_data.c [new file with mode: 0644]
vmodem/at/at_rx_display.c [new file with mode: 0644]
vmodem/at/at_rx_gprs.c [new file with mode: 0644]
vmodem/at/at_rx_gps.c [new file with mode: 0644]
vmodem/at/at_rx_misc.c [new file with mode: 0644]
vmodem/at/at_rx_network.c [new file with mode: 0644]
vmodem/at/at_rx_phonebook.c [new file with mode: 0644]
vmodem/at/at_rx_power.c [new file with mode: 0644]
vmodem/at/at_rx_sap.c [new file with mode: 0644]
vmodem/at/at_rx_sat.c [new file with mode: 0644]
vmodem/at/at_rx_security.c [new file with mode: 0644]
vmodem/at/at_rx_sms.c [new file with mode: 0644]
vmodem/at/at_rx_snd.c [new file with mode: 0644]
vmodem/at/at_rx_ss.c [new file with mode: 0644]
vmodem/at/at_send.c [new file with mode: 0644]
vmodem/at/at_tx_call.c [new file with mode: 0644]
vmodem/at/at_tx_data.c [new file with mode: 0644]
vmodem/at/at_tx_display.c [new file with mode: 0644]
vmodem/at/at_tx_emulator.c [new file with mode: 0644]
vmodem/at/at_tx_gprs.c [new file with mode: 0644]
vmodem/at/at_tx_misc.c [new file with mode: 0644]
vmodem/at/at_tx_network.c [new file with mode: 0644]
vmodem/at/at_tx_phonebook.c [new file with mode: 0644]
vmodem/at/at_tx_power.c [new file with mode: 0644]
vmodem/at/at_tx_sat.c [new file with mode: 0644]
vmodem/at/at_tx_security.c [new file with mode: 0644]
vmodem/at/at_tx_sms.c [new file with mode: 0644]
vmodem/at/at_tx_snd.c [new file with mode: 0644]
vmodem/at/at_tx_ss.c [new file with mode: 0644]
vmodem/db/db/gprs.db [new file with mode: 0644]
vmodem/db/db/network.db [new file with mode: 0644]
vmodem/db/db/sim.db [new file with mode: 0644]
vmodem/db/db/ss.db [new file with mode: 0644]
vmodem/db/db_gprs.c [new file with mode: 0644]
vmodem/db/db_network.c [new file with mode: 0644]
vmodem/db/db_phonebook.c [new file with mode: 0644]
vmodem/db/db_security.c [new file with mode: 0644]
vmodem/db/db_ss.c [new file with mode: 0644]
vmodem/db/gprs.db [new file with mode: 0644]
vmodem/db/network.db [new file with mode: 0644]
vmodem/db/pb.db [new file with mode: 0644]
vmodem/db/sim.db [new file with mode: 0644]
vmodem/db/ss.db [new file with mode: 0644]
vmodem/db/tmp/gprs.db [new file with mode: 0644]
vmodem/db/tmp/network.db [new file with mode: 0644]
vmodem/db/tmp/pb.db [new file with mode: 0644]
vmodem/db/tmp/sim.db [new file with mode: 0644]
vmodem/db/tmp/ss.db [new file with mode: 0644]
vmodem/include/at/at_func.h [new file with mode: 0644]
vmodem/include/at/at_gen_resp.h [new file with mode: 0644]
vmodem/include/at/at_msg.h [new file with mode: 0644]
vmodem/include/at/at_recv.h [new file with mode: 0644]
vmodem/include/at/at_rx_call.h [new file with mode: 0644]
vmodem/include/at/at_rx_data.h [new file with mode: 0644]
vmodem/include/at/at_rx_display.h [new file with mode: 0644]
vmodem/include/at/at_rx_func.h [new file with mode: 0644]
vmodem/include/at/at_rx_gprs.h [new file with mode: 0644]
vmodem/include/at/at_rx_gps.h [new file with mode: 0644]
vmodem/include/at/at_rx_misc.h [new file with mode: 0644]
vmodem/include/at/at_rx_network.h [new file with mode: 0644]
vmodem/include/at/at_rx_phonebook.h [new file with mode: 0644]
vmodem/include/at/at_rx_sap.h [new file with mode: 0644]
vmodem/include/at/at_rx_sat.h [new file with mode: 0644]
vmodem/include/at/at_rx_security.h [new file with mode: 0644]
vmodem/include/at/at_rx_sms.h [new file with mode: 0644]
vmodem/include/at/at_rx_snd.h [new file with mode: 0644]
vmodem/include/at/at_rx_ss.h [new file with mode: 0644]
vmodem/include/at/at_send.h [new file with mode: 0644]
vmodem/include/at/at_tx_call.h [new file with mode: 0644]
vmodem/include/at/at_tx_data.h [new file with mode: 0644]
vmodem/include/at/at_tx_display.h [new file with mode: 0644]
vmodem/include/at/at_tx_func.h [new file with mode: 0644]
vmodem/include/at/at_tx_gprs.h [new file with mode: 0644]
vmodem/include/at/at_tx_misc.h [new file with mode: 0644]
vmodem/include/at/at_tx_network.h [new file with mode: 0644]
vmodem/include/at/at_tx_phonebook.h [new file with mode: 0644]
vmodem/include/at/at_tx_power.h [new file with mode: 0644]
vmodem/include/at/at_tx_security.h [new file with mode: 0644]
vmodem/include/at/at_tx_sms.h [new file with mode: 0644]
vmodem/include/at/at_tx_snd.h [new file with mode: 0644]
vmodem/include/at/at_tx_ss.h [new file with mode: 0644]
vmodem/include/db/db_gprs.h [new file with mode: 0644]
vmodem/include/db/db_network.h [new file with mode: 0644]
vmodem/include/db/db_phonebook.h [new file with mode: 0644]
vmodem/include/db/db_security.h [new file with mode: 0644]
vmodem/include/db/db_ss.h [new file with mode: 0644]
vmodem/include/logmsg.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_call.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_data.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_display.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_gprs.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_misc.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_network.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_phonebook.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_power.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_security.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_sms.h [new file with mode: 0644]
vmodem/include/oem/oem_rx_ss.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_call.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_data.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_display.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_gprs.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_misc.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_network.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_phonebook.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_power.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_security.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_sms.h [new file with mode: 0644]
vmodem/include/oem/oem_tx_ss.h [new file with mode: 0644]
vmodem/include/sat/sat_util.h [new file with mode: 0644]
vmodem/include/sat/sat_values.h [new file with mode: 0644]
vmodem/include/server/eloop.h [new file with mode: 0644]
vmodem/include/server/flight.h [new file with mode: 0644]
vmodem/include/server/gsm.h [new file with mode: 0644]
vmodem/include/server/lxtsms.h [new file with mode: 0644]
vmodem/include/server/lxtsmstypedef.h [new file with mode: 0644]
vmodem/include/server/lxtutil.h [new file with mode: 0644]
vmodem/include/server/misc.h [new file with mode: 0644]
vmodem/include/server/phoneprotocol.h [new file with mode: 0644]
vmodem/include/server/phoneprotocol4gsm.h [new file with mode: 0644]
vmodem/include/server/phoneserver.h [new file with mode: 0644]
vmodem/include/server/server_client.h [new file with mode: 0644]
vmodem/include/server/server_common.h [new file with mode: 0644]
vmodem/include/server/server_common_call.h [new file with mode: 0644]
vmodem/include/server/server_common_network.h [new file with mode: 0644]
vmodem/include/server/server_common_security.h [new file with mode: 0644]
vmodem/include/server/server_common_ss.h [new file with mode: 0644]
vmodem/include/server/server_rx_call.h [new file with mode: 0644]
vmodem/include/server/server_rx_data.h [new file with mode: 0644]
vmodem/include/server/server_rx_display.h [new file with mode: 0644]
vmodem/include/server/server_rx_gprs.h [new file with mode: 0644]
vmodem/include/server/server_rx_misc.h [new file with mode: 0644]
vmodem/include/server/server_rx_network.h [new file with mode: 0644]
vmodem/include/server/server_rx_phonebook.h [new file with mode: 0644]
vmodem/include/server/server_rx_power.h [new file with mode: 0644]
vmodem/include/server/server_rx_security.h [new file with mode: 0644]
vmodem/include/server/server_rx_sms.h [new file with mode: 0644]
vmodem/include/server/server_rx_ss.h [new file with mode: 0644]
vmodem/include/server/server_tx_call.h [new file with mode: 0644]
vmodem/include/server/server_tx_data.h [new file with mode: 0644]
vmodem/include/server/server_tx_display.h [new file with mode: 0644]
vmodem/include/server/server_tx_gprs.h [new file with mode: 0644]
vmodem/include/server/server_tx_network.h [new file with mode: 0644]
vmodem/include/server/server_tx_phonebook.h [new file with mode: 0644]
vmodem/include/server/server_tx_power.h [new file with mode: 0644]
vmodem/include/server/server_tx_security.h [new file with mode: 0644]
vmodem/include/server/server_tx_sms.h [new file with mode: 0644]
vmodem/include/server/server_tx_ss.h [new file with mode: 0644]
vmodem/include/server/state.h [new file with mode: 0644]
vmodem/include/server/state_sim.h [new file with mode: 0644]
vmodem/include/server/tapi4phonebook.h [new file with mode: 0644]
vmodem/include/server/vgsm_debug.h [new file with mode: 0644]
vmodem/include/sms/sms_header.h [new file with mode: 0644]
vmodem/include/sms/sms_util.h [new file with mode: 0644]
vmodem/include/transport/dpram.h [new file with mode: 0644]
vmodem/include/transport/gsmstate.h [new file with mode: 0644]
vmodem/include/transport/onedram.h [new file with mode: 0644]
vmodem/oem/oem_rx_call.c [new file with mode: 0644]
vmodem/oem/oem_rx_data.c [new file with mode: 0644]
vmodem/oem/oem_rx_display.c [new file with mode: 0644]
vmodem/oem/oem_rx_gprs.c [new file with mode: 0644]
vmodem/oem/oem_rx_misc.c [new file with mode: 0644]
vmodem/oem/oem_rx_network.c [new file with mode: 0644]
vmodem/oem/oem_rx_phonebook.c [new file with mode: 0644]
vmodem/oem/oem_rx_power.c [new file with mode: 0644]
vmodem/oem/oem_rx_security.c [new file with mode: 0644]
vmodem/oem/oem_rx_sms.c [new file with mode: 0644]
vmodem/oem/oem_rx_ss.c [new file with mode: 0644]
vmodem/oem/oem_tx_call.c [new file with mode: 0644]
vmodem/oem/oem_tx_data.c [new file with mode: 0644]
vmodem/oem/oem_tx_display.c [new file with mode: 0644]
vmodem/oem/oem_tx_gprs.c [new file with mode: 0644]
vmodem/oem/oem_tx_misc.c [new file with mode: 0644]
vmodem/oem/oem_tx_network.c [new file with mode: 0644]
vmodem/oem/oem_tx_phonebook.c [new file with mode: 0644]
vmodem/oem/oem_tx_power.c [new file with mode: 0644]
vmodem/oem/oem_tx_security.c [new file with mode: 0644]
vmodem/oem/oem_tx_sms.c [new file with mode: 0644]
vmodem/oem/oem_tx_ss.c [new file with mode: 0644]
vmodem/sat/apdu_tool.c [new file with mode: 0644]
vmodem/sat/sat_util.c [new file with mode: 0644]
vmodem/sat/sat_util.h [new file with mode: 0644]
vmodem/sat/sat_values.h [new file with mode: 0644]
vmodem/server/client.c [new file with mode: 0644]
vmodem/server/eloop.c [new file with mode: 0644]
vmodem/server/flight.c [new file with mode: 0644]
vmodem/server/func_ps.c [new file with mode: 0644]
vmodem/server/gsm.c [new file with mode: 0644]
vmodem/server/logmsg.c [new file with mode: 0644]
vmodem/server/main.c [new file with mode: 0644]
vmodem/server/misc.c [new file with mode: 0644]
vmodem/server/phoneserver.c [new file with mode: 0644]
vmodem/server/server.c [new file with mode: 0644]
vmodem/server/server_client.c [new file with mode: 0644]
vmodem/server/server_common.c [new file with mode: 0644]
vmodem/server/server_common_call.c [new file with mode: 0644]
vmodem/server/server_common_gprs.c [new file with mode: 0644]
vmodem/server/server_common_network.c [new file with mode: 0644]
vmodem/server/server_common_security.c [new file with mode: 0644]
vmodem/server/server_common_ss.c [new file with mode: 0644]
vmodem/server/server_dpram.c [new file with mode: 0644]
vmodem/server/server_rx_call.c [new file with mode: 0644]
vmodem/server/server_rx_data.c [new file with mode: 0644]
vmodem/server/server_rx_display.c [new file with mode: 0644]
vmodem/server/server_rx_gprs.c [new file with mode: 0644]
vmodem/server/server_rx_misc.c [new file with mode: 0644]
vmodem/server/server_rx_network.c [new file with mode: 0644]
vmodem/server/server_rx_phonebook.c [new file with mode: 0644]
vmodem/server/server_rx_power.c [new file with mode: 0644]
vmodem/server/server_rx_security.c [new file with mode: 0644]
vmodem/server/server_rx_sms.c [new file with mode: 0644]
vmodem/server/server_rx_ss.c [new file with mode: 0644]
vmodem/server/server_tx_call.c [new file with mode: 0644]
vmodem/server/server_tx_data.c [new file with mode: 0644]
vmodem/server/server_tx_display.c [new file with mode: 0644]
vmodem/server/server_tx_gprs.c [new file with mode: 0644]
vmodem/server/server_tx_network.c [new file with mode: 0644]
vmodem/server/server_tx_phonebook.c [new file with mode: 0644]
vmodem/server/server_tx_power.c [new file with mode: 0644]
vmodem/server/server_tx_security.c [new file with mode: 0644]
vmodem/server/server_tx_sms.c [new file with mode: 0644]
vmodem/server/server_tx_ss.c [new file with mode: 0644]
vmodem/server/state.c [new file with mode: 0644]
vmodem/server/state_sim.c [new file with mode: 0644]
vmodem/transport/gsmstate.c [new file with mode: 0644]
vmodem/transport/transport_dpram.c [new file with mode: 0644]
vmodem/transport/transport_onedram.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..fe14544
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,13 @@
+YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+DongKyun Yun <dk77.yun@samsung.com>
+DoHyung Hong <don.hong@samsung.com>
+SeokYeon Hwang <syeon.hwang@samsung.com>
+Hyunjun Son <hj79.son@samsung.com>
+SangJin Kim <sangjin3.kim@samsung.com>
+KiTae Kim <kt920.kim@samsung.com>
+JinHyung Jo <jinhyung.jo@samsung.com>
+SungMin Ha <sungmin82.ha@samsung.com>
+MunKyu Im <munkyu.im@samsung.com>
+JiHye Kim <jihye1128.kim@samsung.com>
+GiWoong Kim <giwoong.kim@samsung.com>
+HyunGoo Kang <hyungoo1.kang@samsung.com>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..df654d8
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,342 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                     GNU GENERAL PUBLIC LICENSE
+                        Version 2, June 1991
+  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                        51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+  Everyone is permitted to copy and distribute verbatim copies
+  of this license document, but changing it is not allowed.
+                             Preamble
+   The licenses for most software are designed to take away your
+ freedom to share and change it.  By contrast, the GNU General Public
+ License is intended to guarantee your freedom to share and change free
+ software--to make sure the software is free for all its users.  This
+ General Public License applies to most of the Free Software
+ Foundation's software and to any other program whose authors commit to
+ using it.  (Some other Free Software Foundation software is covered by
+ the GNU Library General Public License instead.)  You can apply it to
+ your programs, too.
+   When we speak of free software, we are referring to freedom, not
+ price.  Our General Public Licenses are designed to make sure that you
+ have the freedom to distribute copies of free software (and charge for
+ this service if you wish), that you receive source code or can get it
+ if you want it, that you can change the software or use pieces of it
+ in new free programs; and that you know you can do these things.
+   To protect your rights, we need to make restrictions that forbid
+ anyone to deny you these rights or to ask you to surrender the rights.
+ These restrictions translate to certain responsibilities for you if you
+ distribute copies of the software, or if you modify it.
+   For example, if you distribute copies of such a program, whether
+ gratis or for a fee, you must give the recipients all the rights that
+ you have.  You must make sure that they, too, receive or can get the
+ source code.  And you must show them these terms so they know their
+ rights.
+   We protect your rights with two steps: (1) copyright the software, and
+ (2) offer you this license which gives you legal permission to copy,
+ distribute and/or modify the software.
+   Also, for each author's protection and ours, we want to make certain
+ that everyone understands that there is no warranty for this free
+ software.  If the software is modified by someone else and passed on, we
+ want its recipients to know that what they have is not the original, so
+ that any problems introduced by others will not reflect on the original
+ authors' reputations.
+   Finally, any free program is threatened constantly by software
+ patents.  We wish to avoid the danger that redistributors of a free
+ program will individually obtain patent licenses, in effect making the
+ program proprietary.  To prevent this, we have made it clear that any
+ patent must be licensed for everyone's free use or not licensed at all.
+   The precise terms and conditions for copying, distribution and
+ modification follow.
+ \f
+                     GNU GENERAL PUBLIC LICENSE
+    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+   0. This License applies to any program or other work which contains
+ a notice placed by the copyright holder saying it may be distributed
+ under the terms of this General Public License.  The "Program", below,
+ refers to any such program or work, and a "work based on the Program"
+ means either the Program or any derivative work under copyright law:
+ that is to say, a work containing the Program or a portion of it,
+ either verbatim or with modifications and/or translated into another
+ language.  (Hereinafter, translation is included without limitation in
+ the term "modification".)  Each licensee is addressed as "you".
+ Activities other than copying, distribution and modification are not
+ covered by this License; they are outside its scope.  The act of
+ running the Program is not restricted, and the output from the Program
+ is covered only if its contents constitute a work based on the
+ Program (independent of having been made by running the Program).
+ Whether that is true depends on what the Program does.
+   1. You may copy and distribute verbatim copies of the Program's
+ source code as you receive it, in any medium, provided that you
+ conspicuously and appropriately publish on each copy an appropriate
+ copyright notice and disclaimer of warranty; keep intact all the
+ notices that refer to this License and to the absence of any warranty;
+ and give any other recipients of the Program a copy of this License
+ along with the Program.
+ You may charge a fee for the physical act of transferring a copy, and
+ you may at your option offer warranty protection in exchange for a fee.
+   2. You may modify your copy or copies of the Program or any portion
+ of it, thus forming a work based on the Program, and copy and
+ distribute such modifications or work under the terms of Section 1
+ above, provided that you also meet all of these conditions:
+     a) You must cause the modified files to carry prominent notices
+     stating that you changed the files and the date of any change.
+     b) You must cause any work that you distribute or publish, that in
+     whole or in part contains or is derived from the Program or any
+     part thereof, to be licensed as a whole at no charge to all third
+     parties under the terms of this License.
+     c) If the modified program normally reads commands interactively
+     when run, you must cause it, when started running for such
+     interactive use in the most ordinary way, to print or display an
+     announcement including an appropriate copyright notice and a
+     notice that there is no warranty (or else, saying that you provide
+     a warranty) and that users may redistribute the program under
+     these conditions, and telling the user how to view a copy of this
+     License.  (Exception: if the Program itself is interactive but
+     does not normally print such an announcement, your work based on
+     the Program is not required to print an announcement.)
+ \f
+ These requirements apply to the modified work as a whole.  If
+ identifiable sections of that work are not derived from the Program,
+ and can be reasonably considered independent and separate works in
+ themselves, then this License, and its terms, do not apply to those
+ sections when you distribute them as separate works.  But when you
+ distribute the same sections as part of a whole which is a work based
+ on the Program, the distribution of the whole must be on the terms of
+ this License, whose permissions for other licensees extend to the
+ entire whole, and thus to each and every part regardless of who wrote it.
+ Thus, it is not the intent of this section to claim rights or contest
+ your rights to work written entirely by you; rather, the intent is to
+ exercise the right to control the distribution of derivative or
+ collective works based on the Program.
+ In addition, mere aggregation of another work not based on the Program
+ with the Program (or with a work based on the Program) on a volume of
+ a storage or distribution medium does not bring the other work under
+ the scope of this License.
+   3. You may copy and distribute the Program (or a work based on it,
+ under Section 2) in object code or executable form under the terms of
+ Sections 1 and 2 above provided that you also do one of the following:
+     a) Accompany it with the complete corresponding machine-readable
+     source code, which must be distributed under the terms of Sections
+     1 and 2 above on a medium customarily used for software interchange; or,
+     b) Accompany it with a written offer, valid for at least three
+     years, to give any third party, for a charge no more than your
+     cost of physically performing source distribution, a complete
+     machine-readable copy of the corresponding source code, to be
+     distributed under the terms of Sections 1 and 2 above on a medium
+     customarily used for software interchange; or,
+     c) Accompany it with the information you received as to the offer
+     to distribute corresponding source code.  (This alternative is
+     allowed only for noncommercial distribution and only if you
+     received the program in object code or executable form with such
+     an offer, in accord with Subsection b above.)
+ The source code for a work means the preferred form of the work for
+ making modifications to it.  For an executable work, complete source
+ code means all the source code for all modules it contains, plus any
+ associated interface definition files, plus the scripts used to
+ control compilation and installation of the executable.  However, as a
+ special exception, the source code distributed need not include
+ anything that is normally distributed (in either source or binary
+ form) with the major components (compiler, kernel, and so on) of the
+ operating system on which the executable runs, unless that component
+ itself accompanies the executable.
+ If distribution of executable or object code is made by offering
+ access to copy from a designated place, then offering equivalent
+ access to copy the source code from the same place counts as
+ distribution of the source code, even though third parties are not
+ compelled to copy the source along with the object code.
+ \f
+   4. You may not copy, modify, sublicense, or distribute the Program
+ except as expressly provided under this License.  Any attempt
+ otherwise to copy, modify, sublicense or distribute the Program is
+ void, and will automatically terminate your rights under this License.
+ However, parties who have received copies, or rights, from you under
+ this License will not have their licenses terminated so long as such
+ parties remain in full compliance.
+   5. You are not required to accept this License, since you have not
+ signed it.  However, nothing else grants you permission to modify or
+ distribute the Program or its derivative works.  These actions are
+ prohibited by law if you do not accept this License.  Therefore, by
+ modifying or distributing the Program (or any work based on the
+ Program), you indicate your acceptance of this License to do so, and
+ all its terms and conditions for copying, distributing or modifying
+ the Program or works based on it.
+   6. Each time you redistribute the Program (or any work based on the
+ Program), the recipient automatically receives a license from the
+ original licensor to copy, distribute or modify the Program subject to
+ these terms and conditions.  You may not impose any further
+ restrictions on the recipients' exercise of the rights granted herein.
+ You are not responsible for enforcing compliance by third parties to
+ this License.
+   7. If, as a consequence of a court judgment or allegation of patent
+ infringement or for any other reason (not limited to patent issues),
+ conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License.  If you cannot
+ distribute so as to satisfy simultaneously your obligations under this
+ License and any other pertinent obligations, then as a consequence you
+ may not distribute the Program at all.  For example, if a patent
+ license would not permit royalty-free redistribution of the Program by
+ all those who receive copies directly or indirectly through you, then
+ the only way you could satisfy both it and this License would be to
+ refrain entirely from distribution of the Program.
+ If any portion of this section is held invalid or unenforceable under
+ any particular circumstance, the balance of the section is intended to
+ apply and the section as a whole is intended to apply in other
+ circumstances.
+ It is not the purpose of this section to induce you to infringe any
+ patents or other property right claims or to contest validity of any
+ such claims; this section has the sole purpose of protecting the
+ integrity of the free software distribution system, which is
+ implemented by public license practices.  Many people have made
+ generous contributions to the wide range of software distributed
+ through that system in reliance on consistent application of that
+ system; it is up to the author/donor to decide if he or she is willing
+ to distribute software through any other system and a licensee cannot
+ impose that choice.
+ This section is intended to make thoroughly clear what is believed to
+ be a consequence of the rest of this License.
+ \f
+   8. If the distribution and/or use of the Program is restricted in
+ certain countries either by patents or by copyrighted interfaces, the
+ original copyright holder who places the Program under this License
+ may add an explicit geographical distribution limitation excluding
+ those countries, so that distribution is permitted only in or among
+ countries not thus excluded.  In such case, this License incorporates
+ the limitation as if written in the body of this License.
+   9. The Free Software Foundation may publish revised and/or new versions
+ of the General Public License from time to time.  Such new versions will
+ be similar in spirit to the present version, but may differ in detail to
+ address new problems or concerns.
+ Each version is given a distinguishing version number.  If the Program
+ specifies a version number of this License which applies to it and "any
+ later version", you have the option of following the terms and conditions
+ either of that version or of any later version published by the Free
+ Software Foundation.  If the Program does not specify a version number of
+ this License, you may choose any version ever published by the Free Software
+ Foundation.
+   10. If you wish to incorporate parts of the Program into other free
+ programs whose distribution conditions are different, write to the author
+ to ask for permission.  For software which is copyrighted by the Free
+ Software Foundation, write to the Free Software Foundation; we sometimes
+ make exceptions for this.  Our decision will be guided by the two goals
+ of preserving the free status of all derivatives of our free software and
+ of promoting the sharing and reuse of software generally.
+                             NO WARRANTY
+   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+ REPAIR OR CORRECTION.
+   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES.
+                      END OF TERMS AND CONDITIONS
+ \f
+             How to Apply These Terms to Your New Programs
+   If you develop a new program, and you want it to be of the greatest
+ possible use to the public, the best way to achieve this is to make it
+ free software which everyone can redistribute and change under these terms.
+   To do so, attach the following notices to the program.  It is safest
+ to attach them to the start of each source file to most effectively
+ convey the exclusion of warranty; and each file should have at least
+ the "copyright" line and a pointer to where the full notice is found.
+     <one line to give the program's name and a brief idea of what it does.>
+     Copyright (C) <year>  <name of author>
+     This program is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation; either version 2 of the License, or
+     (at your option) any later version.
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+     You should have received a copy of the GNU General Public License
+     along with this program; if not, write to the Free Software
+     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Also add information on how to contact you by electronic and paper mail.
+ If the program is interactive, make it output a short notice like this
+ when it starts in an interactive mode:
+     Gnomovision version 69, Copyright (C) year name of author
+     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+     This is free software, and you are welcome to redistribute it
+     under certain conditions; type `show c' for details.
+ The hypothetical commands `show w' and `show c' should show the appropriate
+ parts of the General Public License.  Of course, the commands you use may
+ be called something other than `show w' and `show c'; they could even be
+ mouse-clicks or menu items--whatever suits your program.
+ You should also get your employer (if you work as a programmer) or your
+ school, if any, to sign a "copyright disclaimer" for the program, if
+ necessary.  Here is a sample; alter the names:
+   Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+   `Gnomovision' (which makes passes at compilers) written by James Hacker.
+   <signature of Ty Coon>, 1 April 1989
+   Ty Coon, President of Vice
+ This General Public License does not permit incorporating your program into
+ proprietary programs.  If your program is a subroutine library, you may
+ consider it more useful to permit linking proprietary applications with the
+ library.  If this is what you want to do, use the GNU Library General
+ Public License instead of this License.
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..b3748ae
--- /dev/null
@@ -0,0 +1,17 @@
+all:
+       cd lib/libcommon && $(MAKE)
+       cd lib/libsms && $(MAKE)
+       cd libvmodem && $(MAKE)
+       cd vmodem && $(MAKE)
+
+clean:
+       cd lib/libcommon && $(MAKE) clean
+       cd lib/libsms && $(MAKE) clean
+       cd libvmodem && $(MAKE) clean
+       cd vmodem && $(MAKE) clean
+
+install:
+       cd vmodem && $(MAKE) install
+
+distclean: clean
+       rm -rf autom4te.cache config.log config.status configure
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..f085dc6
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
diff --git a/build.sh b/build.sh
new file mode 100644 (file)
index 0000000..74b5e40
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+autoconf
+./configure
+make
+
diff --git a/build_dpkg.sh b/build_dpkg.sh
new file mode 100644 (file)
index 0000000..7d61a6d
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+__option=$1
+
+if [ "x$__option" = "x" ]; then
+       exec dpkg-buildpackage -sa -rfakeroot
+elif [ "x$__option" = "xno-sign" ]; then
+       echo "This build command is only for packaging."
+       exec dpkg-buildpackage -b -us -uc -rfakeroot
+else
+       echo "This options is invalid."
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..ee5109f
--- /dev/null
@@ -0,0 +1,41 @@
+AC_PREREQ(2.61)
+AC_INIT(telephony_simulator, 1.0)
+
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PROG_CXX
+
+AC_CHECK_PROGS(PKG_CONFIG, pkg-config, false)
+AC_CHECK_PROGS(AR, ar, false)
+#AC_PREFIX_DEFAULT(/opt/samsung_sdk)
+
+if test "$PKG_CONFIG" = "false"
+then
+       AC_MSG_ERROR([pkg-config not present, please install])
+fi
+
+CFLAGS="${CFLAGS} -Wall"
+
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0`
+GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0`
+
+AC_SUBST(XML_CFLAGS)
+AC_SUBST(XML_LIBS)
+XML_CFLAGS=`$PKG_CONFIG --cflags libxml-2.0`
+XML_LIBS=`$PKG_CONFIG --libs libxml-2.0`
+
+AC_SUBST(GTHREAD_CFLAGS)
+AC_SUBST(GTHREAD_LIBS)
+GTHREAD_CFLAGS=`$PKG_CONFIG --cflags gthread-2.0`
+GTHREAD_LIBS=`$PKG_CONFIG --libs gthread-2.0`
+
+AC_CONFIG_FILES([
+       Makefile
+       lib/libcommon/Makefile
+       lib/libsms/Makefile
+       libvmodem/Makefile
+       vmodem/Makefile])
+
+AC_OUTPUT
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..80b376b
--- /dev/null
@@ -0,0 +1,62 @@
+vmodemd-emul (0.2.10) unstable; urgency=low
+
+  * modified default rssi value
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Sat, 21 Apr 2012 20:00:28 +0900
+
+vmodemd-emul (0.2.9) unstable; urgency=low
+
+  * fixed bug of concatenated mo sms
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Tue, 17 Apr 2012 18:57:28 +0900
+
+vmodemd-emul (0.2.8) unstable; urgency=low
+
+  * modified boilerplate for protex
+  * call release bug fixed when 1waiting, 1active call 
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Thu, 5 Apr 2012 19:57:28 +0900
+
+vmodemd-emul (0.2.7) unstable; urgency=low
+
+  * unlimited check sim bug is fixed.
+  * add CRSM param get command for mo sms.
+  * modified ss.db for support query of video call 
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Fri, 30 Mar 2012 08:57:28 +0900
+
+vmodemd-emul (0.2.6) unstable; urgency=low
+
+  * modified initialize ss.db when booting time.
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Fri, 30 Mar 2012 08:57:28 +0900
+
+vmodemd-emul (0.2.5) unstable; urgency=low
+
+  * modified temporary patch for waiting call.
+
+ -- SungMin Ha <sungmin82.ha@samsung.com> Thu, 29 Mar 2012 17:39:28 +0900
+
+vmodemd-emul (0.2.4) unstable; urgency=low
+
+  * modified for support call and sms.
+
+ -- SungMin Ha <sungmin82.ha@samsung.com>  Tue, 27 Mar 2012 17:10:52 +0900
+
+vmodemd-emul (0.2.3) unstable; urgency=low
+
+  * modified for support at command additional features.
+
+ -- SungMin Ha <sungmin82.ha@samsung.com>  Thu, 22 Mar 2012 18:10:52 +0900
+
+vmodemd-emul (0.2.2) unstable; urgency=low
+
+  * modified for support at command.
+
+ -- SungMin Ha <sungmin82.ha@samsung.com>  Sat, 17 Mar 2012 10:10:52 +0900
+
+vmodemd-emul (0.2.1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- DongKyun Yun <dk77.yun@samsung.com>  Fri, 16 Dec 2011 17:29:52 +0900
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..1db9094
--- /dev/null
@@ -0,0 +1,11 @@
+Source: vmodemd-emul
+Section: devel
+Priority: extra
+Maintainer: DongKyun Yun  <dk77.yun@samsung.com>, SungMin Ha <sungmin82.ha@samsung.com>
+Build-Depends: bison, flex, autoconf, gcc, debhelper, libglib2.0-dev, libxml2-dev, libvconf-dev
+Standards-Version: 0.2.10
+
+Package: vmodemd-emul
+Architecture: i386
+Depends: 
+Description: Modem Emulator
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..3b6b827
--- /dev/null
@@ -0,0 +1,6 @@
+This package was debianized by DongKyun YUn <dk77.yun@samsung.com>
+Fri, 16 Dec 1998 17:22:14 +0900.
+
+Copyright:
+(c) 2011 Samsung Electronics, Inc.
+
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..e772481
--- /dev/null
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..e8ce8d9
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/make -f
+
+package=vmodemd-emul 
+
+SRCDIR = .
+CC     = gcc
+
+export DH_VERBOSE=1
+
+build:
+       cd $(SRCDIR) && autoconf && ./configure && $(MAKE)
+       touch build
+
+binary:
+
+clean:
+       dh_testdir
+       dh_clean
+       rm -rf debian/tmp debian/files* debian/substvars
+       rm -f build
+
+install: build
+       dh_clean
+       dh_installdirs
+       cd $(SRCDIR) && $(MAKE) prefix=$(CURDIR)/debian/tmp install
+
+binary-arch: install
+       dh_testdir
+       dh_testroot
+#      dh_installchangelogs 
+#      dh_installdocs
+#      dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+#      dh_installman
+#      dh_link
+#      dh_strip
+#      dh_compress
+#      dh_fixperms
+#      dh_perl
+#      dh_makeshlibs
+#      dh_installdeb
+#      dh_shlibdeps
+       dh_gencontrol
+#      dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: binary binary-arch binary-indep clean checkroot
diff --git a/debian/vmodemd-emul.install.in b/debian/vmodemd-emul.install.in
new file mode 100644 (file)
index 0000000..4148e89
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/vmodem_x86
diff --git a/debian/vmodemd-emul.postinst.in b/debian/vmodemd-emul.postinst.in
new file mode 100644 (file)
index 0000000..3a9908a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+chmod 755 /usr/bin/vmodem_x86
+       
diff --git a/lib/libcommon/Makefile.in b/lib/libcommon/Makefile.in
new file mode 100644 (file)
index 0000000..855c958
--- /dev/null
@@ -0,0 +1,31 @@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS   = @GLIB_LIBS@
+
+XML_CFLAGS  = @XML_CFLAGS@
+XML_LIBS    = @XML_LIBS@
+
+CC = @CC@
+AR = @AR@
+
+CFLAGS  = @CFLAGS@
+# for bypass __stack_chk_fail
+CFLAGS +=-fno-stack-protector
+CFLAGS += $(GLIB_CFLAGS) $(XML_CFLAGS) -DISE_LOGGING -DISE_DEBUG
+
+LIBS   = $(GLIB_LIBS) $(XML_LIBS)
+
+OBJS = logmsg.o \
+       process.o \
+       safestring.o \
+       fileio.o
+
+.SUFFIXES: .c
+
+all: libcommon.a
+
+libcommon.a: $(OBJS)
+       $(AR) r $@ $(OBJS)
+
+clean:
+       rm -f $(OBJS) libcommon.a
+
diff --git a/lib/libcommon/fileio.c b/lib/libcommon/fileio.c
new file mode 100644 (file)
index 0000000..387ccb5
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "fileio.h"
+
+gchar *get_simulator_path(void)
+{
+       gchar *simulator_path = NULL;
+       int length = 0;
+       
+#ifndef _WIN32
+       simulator_path = (char *)malloc( 512);
+       memset(simulator_path, 0, 512);
+
+       length = readlink("/proc/self/exe", simulator_path, 512);
+       simulator_path[length] = '\0';
+#else
+       gchar simulator_org_path[512] = {0, };
+       GetModuleFileName(NULL, simulator_org_path, 512);
+       simulator_path = change_path_to_slash(simulator_org_path);
+#endif 
+
+       /* exception precess */
+
+       if (length < 0) {
+               exit(-1);
+       }
+
+       if (length >= 512) {
+               fprintf(stderr, "Path too long. Truncated.\n");
+               exit(-1);
+       }
+
+       return simulator_path;
+}
+
+gchar *get_bin_path(void)
+{
+       gchar *simulator_path = NULL;
+       simulator_path = get_simulator_path();
+
+       gchar *bin_path = NULL;
+       bin_path = g_path_get_dirname(simulator_path);
+
+       if (simulator_path)
+               g_free(simulator_path);
+
+       return bin_path;
+}
+
+gchar *get_path(void)
+{
+       gchar *simulator_path = NULL;
+       simulator_path = get_simulator_path();
+
+       gchar *path = NULL;
+       path = g_path_get_dirname(simulator_path);
+
+       if (simulator_path)
+               g_free(simulator_path);
+
+       return path;
+}
+
+gchar *get_skin_path(void)
+{
+       gchar *path = NULL;
+       path = get_path();
+
+       gchar *skin_path = NULL;
+       skin_path = (char *)malloc( 512);
+       memset(skin_path, 0, 512);
+       strncpy(skin_path, path, 512);
+
+       sprintf(skin_path, "%s%s", path, "/skins");
+
+       if (path)
+               g_free(path);
+
+       return skin_path;
+}
+
+gchar *get_data_path(void)
+{
+       gchar *path = NULL;
+       path = get_path();
+
+       gchar *data_path = NULL;
+       data_path = (char *)malloc( 512);
+       memset(data_path, 0, 512);
+       strncpy(data_path, path, 512);
+
+       sprintf(data_path, "%s%s", path, "/data");
+
+       if (path)
+               g_free(path);
+       
+       return data_path;
+}
+
+gchar *get_kernel_path(void)
+{
+       gchar *path = NULL;
+       path = get_data_path();
+
+       gchar *kernel_path = NULL;
+       kernel_path = (char *)malloc( 512);
+       memset(kernel_path, 0, 512);
+       strncpy(kernel_path, path, 512);
+
+       sprintf(kernel_path, "%s%s", path, "/kernel-img");
+
+       if (path)
+               g_free(path);
+
+       return kernel_path;
+}
+
+
+/**
+ * @brief      change_path_to_slash (\, \\ -> /)
+ * @param      org path to change (C:\\test\\test\\test)
+ * @return     changed path (C:/test/test/test)
+ * @date    Nov 19. 2009
+ * */ 
+gchar *change_path_to_slash(gchar *org_path)
+{      
+       if (!org_path || strlen(org_path) < 1)
+               return NULL;
+
+       int     length, i = 0;
+       length = strlen(org_path);
+
+       gchar *changed_path = NULL;
+       changed_path = (char *)malloc( 512);
+       memset(changed_path, 0, 512);
+       
+       sprintf(changed_path, "%s", org_path);
+
+       for (i = 0 ; i < length; i ++) {
+               if (org_path[i] == '\\') {
+                       changed_path[i] = '/';  
+               }
+       }
+       
+       return changed_path;
+}
+
+gchar *get_conf_path(void)
+{      
+       gchar *conf_path = NULL;
+
+#ifndef _WIN32 
+       conf_path = (char *)malloc( 512);
+       memset(conf_path, 0, 512);
+
+       gchar *path = NULL;
+       path = get_path();
+
+       strncpy(conf_path, path, 512);
+
+       sprintf(conf_path, "%s%s", path, "/conf");
+
+       if (path)
+               g_free(path);
+#else
+       TCHAR APP_PATH[MAX_PATH];
+       gchar org_conf_path[128] = {0, };
+       
+       SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, APP_PATH);
+       sprintf(org_conf_path, "%s%s", APP_PATH, PID_DIR);
+       conf_path = change_path_to_slash(org_conf_path);                
+#endif
+
+       return conf_path;
+}
+
+
+
+/**
+ * @brief      get_simulator conf file path
+ * */
+gchar *get_simulator_conf_filepath(void)
+{
+       gchar *simulator_conf_filepath = NULL;
+       simulator_conf_filepath = (char *)malloc( 512);
+       memset(simulator_conf_filepath, 0, 512);
+       
+#ifndef _WIN32 
+       if (!strncmp(g_get_user_name(), "root", 4))
+               sprintf(simulator_conf_filepath, "/root%ssimulator.conf", PID_DIR);
+       else
+               sprintf(simulator_conf_filepath, "/home/%s%ssimulator.conf", g_get_user_name(), PID_DIR);
+#else
+       gchar *conf_path = get_conf_path();
+       sprintf(simulator_conf_filepath, "%ssimulator.conf", conf_path);
+
+       if (conf_path)
+               g_free(conf_path);
+#endif
+
+       return simulator_conf_filepath;
+}
+
+
+/**
+ * @brief      get_default target conf file path
+ * */
+gchar *get_platform_conf_filepath(void)
+{
+       gchar *simultor_path = NULL;
+       simultor_path = get_path();
+
+       gchar *default_conf_filepath = NULL;
+       default_conf_filepath = (char *)malloc( 512);
+       memset(default_conf_filepath, 0, 512);
+
+       sprintf(default_conf_filepath, "%s/.default_target.conf", simultor_path);
+
+       if (simultor_path)
+               g_free(simultor_path);
+
+       return default_conf_filepath;
+}
+
+
+/**
+       @brief  search target name in directory name
+       @param  directory_name: target directory name of scratchbox
+       @return target name
+*/
+char *search_target_name(char *directory_name)
+{
+       int directory_len = 0;
+       int search_i = 0;
+       char *found_name = NULL;
+
+       directory_len = strlen(directory_name);
+
+       /* search target name pointer */
+       for (search_i = directory_len; search_i > 0; search_i--) {
+               if (directory_name[search_i-1] == '/') {
+                       found_name = directory_name + search_i;
+                       return found_name;
+               }
+       }
+
+       return NULL;
+}
+
+char *find_exec_path(char *line) {
+       int loc;
+       int find_loc = 0;
+       char *ldpath = NULL;
+       char *start_p = NULL;
+       static char exec_path[512] = "";
+       int nfound = 0;
+
+#if 0
+       // ld path -> factoryfs of bash_profile
+       //ldpath = strstr(line, "LD_LIBRARY_PATH");
+#endif
+
+       ldpath = strstr(line, "FACTORY_FS");
+       if (ldpath == NULL) {
+               return NULL;
+       }
+
+       find_loc = (int)ldpath - (int)line;
+
+       for (loc = 0; loc < find_loc;loc++) {
+               if (line[loc] == '#') {
+                       return NULL;
+               }
+       }
+
+       for (loc = 0; loc < strlen(ldpath);loc++) {
+
+               if (ldpath[loc] == '#') {
+                       return NULL;
+               }
+               if (ldpath[loc] == '=') {
+                       start_p = &ldpath[loc];
+                       nfound = 1;
+                       break;
+               }
+       }
+
+       if (nfound == 0) {
+               return NULL;
+       }
+
+#if 0
+       // lib directory
+       end_p = strstr(start_p, "/lib");
+       if (end_p == NULL) {
+               return NULL;
+       }
+
+       strncpy(exec_path, start_p+1, (int)end_p - (int)start_p -1);
+#endif
+
+       strncpy(exec_path, start_p+1, strlen(start_p+1)-1);
+
+
+       return exec_path;
+}
+
+char *find_exec_path_by_bash_profile(char *target_path)
+{
+       char *exec_path;
+       char pathname[BUFSIZ] = "";
+       char line[BUFSIZ];
+       FILE * fp;
+
+       sprintf(pathname, "%s/root/.bash_profile", target_path);
+
+       if ((fp = fopen(pathname, "r")) == NULL) {
+               return NULL;
+       }
+
+       while (fgets(line, BUFSIZ, fp)) {
+               exec_path = find_exec_path(line);
+
+               if (exec_path != NULL) {
+                       fclose(fp);
+                       return exec_path;
+               }
+       }
+
+       fclose(fp);
+       return NULL;
+}
+
+
+char *find_ld_path(char *line) {
+       int loc;
+       char *ldpath = NULL;
+       char *start_p = NULL;
+       int find_loc = 0;
+
+       ldpath = strstr(line, "LD_LIBRARY_PATH");
+       if (ldpath == NULL) {
+               return NULL;
+       }
+
+       find_loc = (int)ldpath - (int)line;
+
+       for (loc = 0; loc < find_loc;loc++) {
+               if (line[loc] == '#') {
+                       return NULL;
+               }
+       }
+
+       for (loc = 0; loc < strlen(ldpath);loc++) {
+               if (ldpath[loc] == '#') {
+                       return NULL;
+               }
+               if (ldpath[loc] == '=') {
+                       start_p = &ldpath[loc];
+                       break;
+               }
+       }
+
+       return &ldpath[loc] + 1;
+}
+
+char *find_ld_path_by_bash_profile(char *target_path)
+{
+       char *exec_path;
+       char pathname[BUFSIZ] = "";
+       static char line[BUFSIZ] = "";
+       FILE * fp;
+
+       sprintf(pathname, "%s/root/.bash_profile", target_path);
+
+       if ((fp = fopen(pathname, "r")) == NULL) {
+               return NULL;
+       }
+
+       while (fgets(line, BUFSIZ, fp)) {
+               exec_path = find_ld_path(line);
+
+               if (exec_path != NULL) {
+                       if (exec_path[strlen(exec_path) - 1] == '\n')
+                               exec_path[strlen(exec_path) - 1] = '\0';
+                       fclose(fp);
+                       return exec_path;
+               }
+       }
+
+       fclose(fp);
+       return NULL;
+}
+
+
diff --git a/lib/libcommon/fileio.h b/lib/libcommon/fileio.h
new file mode 100644 (file)
index 0000000..60c311b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __SIMULATOR_FILEIO_H__
+#define __SIMULATOR_FILEIO_H__
+
+#include <unistd.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef _WIN32
+#include <shlobj.h>
+#endif
+#include "process.h"
+
+gchar *get_simulator_path(void);
+gchar *get_bin_path(void);
+gchar *get_path(void);
+gchar *get_skin_path(void);
+gchar *get_data_path(void);
+gchar *get_kernel_path(void);
+gchar *get_conf_path(void);
+gchar *get_simulator_conf_filepath(void);
+gchar *get_platform_conf_filepath(void);
+char *search_target_name(char *directory_name);
+char *find_exec_path_by_bash_profile(char *target_path);
+char *find_ld_path_by_bash_profile(char *target_path);
+gchar *change_path_to_slash(gchar *org_path);
+//#define MIDBUF       64
+
+#ifndef _WIN32
+#define PATH_SEP "/"
+#else
+#define PATH_SEP "\\"
+#endif
+
+#endif //__SIMULATOR_FILEIO_H__
diff --git a/lib/libcommon/logmsg.c b/lib/libcommon/logmsg.c
new file mode 100644 (file)
index 0000000..382e6f8
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+ * Copyright (C) 2007 All rights reserved.
+ *
+ * @file logmsg.c
+ * @brief - implementation file
+ *
+ * @defgroup
+ *
+ * $Id: logmsg.c,v 1.4 2009-11-17 00:39:47 cosmos Exp $
+ *
+ * <Revision History>
+ *             0000-00-00:
+ */
+
+#include "logmsg.h"
+
+const char *msglevel[7] = { "[ fatal ]", "[ error ]", "[warning]", "[ info  ]", "[ debug ]",
+       "[**dbg1**]", "[**dbg2**]"
+};
+int msg_level = MSGL_DEFAULT;
+static char *daemon_name = NULL;
+
+static char module[MODNAME_MAX] = { 0, };
+static char logfile[256] = { 0, };
+
+
+/**
+ * @brief      real_log_msg
+ * @param      level
+ * @param      format
+ * @param ...
+ * @date    Nov 18. 2008
+ * */
+void real_log_msg(int level, const char *format, ...)
+{
+       char tmp[MSGSIZE_MAX] = { 0, };
+       char txt[MSGSIZE_MAX] = { 0, };
+       char timeinfo[256] = { 0, };
+       FILE *fp;
+       struct tm *tm_time;
+       struct timeval tval;
+
+       va_list va;
+
+       /* If directed daemon name exist and is not same as module name, return  */
+       if (daemon_name != NULL) {
+               if (daemon_name[0] !=  module[0]) {
+                       return;
+               }
+       }
+
+       if (level > msg_level)
+               return;
+
+       va_start(va, format);
+       vsnprintf(tmp, MSGSIZE_MAX, format, va);
+       va_end(va);
+
+       /* when logfile no exit, just print */
+
+       if (strlen(logfile) <= 0) {
+               fprintf(stdout, "%s %s / %s", msglevel[level], module, tmp);
+               return;
+       }
+
+       tmp[MSGSIZE_MAX - 2] = '\n';
+       tmp[MSGSIZE_MAX - 1] = 0;
+
+       if ((msg_level == MSGL_ALL) || (msg_level != MSGL_FILE))
+               fprintf(stdout, "%s %s / %s", msglevel[level], module, tmp);
+
+       if ((msg_level == MSGL_ALL) || (msg_level == MSGL_FILE)) {
+               gettimeofday(&tval, NULL);
+               tm_time = gmtime(&(tval.tv_sec));
+               strftime(timeinfo, sizeof(timeinfo), "%Y/%m/%d %H:%M:%S", tm_time);
+
+               sprintf(txt, "%s %s %s / %s", timeinfo, msglevel[level], module, tmp);
+
+               if ((fp = fopen(logfile, "a+")) == NULL) {
+                       fprintf(stdout, "log file can't open. (%s)\n", logfile);
+                       return;
+               }
+
+               fputs(txt, fp);
+               fclose(fp);
+
+               return;
+       }
+
+       return;
+}
+
+/**
+ * @brief      log msg initialize
+ * @param      mod: simulator, vinit
+ * @date    Nov 18. 2008
+ * */
+
+void log_msg_init(char *mod, int level)
+{
+       char *env = getenv("SIM_VERBOSE");
+       gchar *conf_path = NULL;
+
+       /* 1.1 when getting SIM_VERBOSE env */
+
+       if (env) {
+               if (strstr(env, ":")) {
+                       daemon_name=strtok(env, ":");
+                       msg_level = atoi(strtok(NULL, ":"));
+                       printf("a=%s, bj=%d\n", daemon_name, msg_level);
+
+               }
+               else {
+                       msg_level = atoi(env);
+               }
+
+               /* 1.1.1 check message level range */
+
+               if (!(0 < msg_level && msg_level < 7) && msg_level != MSGL_FILE) {
+                       fprintf(stdout, "\n>>> debug_level must be 0,1,2,3,4,9 <otherwise: MSGL_INFO<3>\n");
+                       msg_level = MSGL_DEFAULT;
+               }
+       }
+
+       if (level) {
+               msg_level = level;
+
+               /* 1.1.1 check message level range */
+
+               if (!(0 < msg_level && msg_level < 7) && msg_level != MSGL_FILE) {
+                       fprintf(stdout, "\n>>> debug_level must be 0,1,2,3,4,9 <otherwise: MSGL_INFO<3>\n");
+                       msg_level = MSGL_DEFAULT;
+               }
+       }
+
+       /* 1.2 when not getting SIM_VERBOSE env (MSGL_DEFAULT = 3) */
+
+       else
+               msg_level = MSGL_DEFAULT;
+
+       /* 2 check module name */
+
+       if (!mod) {
+               fprintf(stderr, "module name needed\n");
+               exit(0);
+       }
+
+       strncpy(module, mod, strlen(mod));
+
+       if ((msg_level == MSGL_ALL) || (msg_level == MSGL_FILE)) {
+//             conf_path = get_conf_path();
+               conf_path = get_path();
+               sprintf(logfile, "%s/simulator.log", conf_path);
+               fprintf(stdout, "\n>>> save log-messages to %s\n", logfile);
+       }
+
+       else
+               fprintf(stdout, "\n>>> msg_level: %d, module_name: %s\n\n", msg_level, module);
+
+       if (conf_path)
+               g_free(conf_path);
+
+       log_msg(MSGL_DEBUG, "log level init complete\n");
+
+       return;
+}
+/**
+ * vim:set tabstop=4 shiftwidth=4 foldmethod=marker wrap:
+ *
+ */
+
+
+/**
+ * @brief      return log level
+ * @date    Feb 23. 2009
+ * */
+
+int get_log_level(void)
+{
+       return msg_level;
+}
+
diff --git a/lib/libcommon/logmsg.h b/lib/libcommon/logmsg.h
new file mode 100644 (file)
index 0000000..fe7d120
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+ * Copyright (C) 2007 All rights reserved.
+ *
+ * @file logmsg.h
+ * @brief - header file
+ *
+ * @defgroup
+ *
+ */
+
+#ifndef LOGMSG_H
+#define LOGMSG_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <time.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <libgen.h>
+
+#include "fileio.h"
+
+#ifndef _WIN32
+#define __FILENAME__ basename(__FILE__)
+#else
+#define __FILENAME__ __FILE__
+#endif
+
+#define log_msg(level, fmt, args...)   real_log_msg(level, "%s:%d %s -> " fmt , __FILENAME__, __LINE__, __FUNCTION__, ##args)
+
+#define MODNAME_MAX    64
+#define MSGSIZE_MAX    2048
+#define MSGL_DEFAULT   0
+
+#define MSGL_FATAL     0       /* system reboot, rmmod  */
+#define        MSGL_ERROR      1       /* exit/terminate/abort */
+#define MSGL_WARN      2       /* continue but problems */
+#define        MSGL_INFO       3       /* hint, system status */
+#define MSGL_DEBUG     4       /* for developement */
+#define MSGL_DBG1      5       /* reservation for future */
+#define MSGL_DBG2      6       /* reservation for future */
+#define MSGL_FILE      9       /* save all above info as file */
+#define MSGL_ALL       10      /* save all and all print */
+
+void real_log_msg(int level, const char *format, ...);
+void log_msg_init(char *mod, int level);
+int get_log_level(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ifndef LOGMSG_H */
+/**
+ * vim:set tabstop=4 shiftwidth=4 foldmethod=marker wrap:
+ *
+ */
+
diff --git a/lib/libcommon/process.c b/lib/libcommon/process.c
new file mode 100644 (file)
index 0000000..7c86a24
--- /dev/null
@@ -0,0 +1,486 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+#include "process.h"
+#ifndef _WIN32
+#include <wait.h>
+#endif
+#include <assert.h>
+
+#define        SHELL   "/bin/sh"
+
+struct pid_list {
+       pid_t pid;
+       int fd;
+       struct pid_list *next;
+};
+
+static struct pid_list *pid_list_head;
+
+
+#ifdef _WIN32
+static char *mbstok_r (char *string, const char *delim, char **save_ptr)
+{
+       if (MB_CUR_MAX > 1)
+       {
+               if (string == NULL)
+               {
+                       string = *save_ptr;
+                       if (string == NULL)
+                       return NULL; /* reminder that end of token sequence has been
+                           reached */
+               }
+
+               /* Skip leading delimiters.  */
+               string += _mbsspn (string, delim);
+
+               /* Found a token?  */
+               if (*string == '\0')
+               {
+                       *save_ptr = NULL;
+                       return NULL;
+               }
+
+               /* Move past the token.  */
+               {
+                       char *token_end = _mbspbrk (string, delim);
+
+                       if (token_end != NULL)
+                       {
+                               /* NUL-terminate the token.  */
+                               *token_end = '\0';
+                               *save_ptr = token_end + 1;
+                       }
+                       else
+                               *save_ptr = NULL;
+               }
+               return string;
+       }
+       else
+               return NULL;
+}
+#endif
+
+
+static pid_t pid_from_fd(int fd, int delete)
+{
+       struct pid_list **p;
+
+       for (p = &pid_list_head; *p; p = &((*p)->next)) {
+               if ((*p)->fd == fd) {
+                       int pid = (*p)->pid;
+                       if (delete) {
+                               struct pid_list *tmp = *p;
+                               *p = (*p)->next;
+                               free(tmp);
+                       }
+                       return pid;
+               }
+       }
+       return 0;
+}
+
+
+static void close_all_pid_fds(void)
+{
+       struct pid_list *p;
+
+       for (p = pid_list_head; p; ) {
+               struct pid_list *tmp = p->next;
+               free(p);
+               p = tmp;
+       }
+}
+
+
+static void save_pid(int fd, pid_t pid)
+{
+       struct pid_list *p;
+       p = malloc(sizeof *p);
+       assert(p);
+       p->fd = fd;
+       p->pid = pid;
+       p->next = pid_list_head;
+       pid_list_head = p;
+}
+
+
+/**
+ * @brief      make pid directory
+ * @param      pidfname : pid file name
+ * @date    Nov 25. 2008
+ * */ 
+
+static int make_pid_path(const char *pidfname)
+{
+       char dir[512] = "", buf[512] = "";
+       char *ptr, *last = NULL, *lptr;
+       int dirnamelen = 0;
+
+       sprintf(buf, "%s", pidfname);
+#ifndef _WIN32 
+       lptr = ptr = strtok_r(buf+1, "/", &last);
+#else
+       lptr = ptr = mbstok_r(buf, "/", &last);
+#endif
+
+       for (;;) {
+#ifndef _WIN32
+               if ((ptr = strtok_r(NULL, "/", &last)) == NULL) break;
+#else
+               if ((ptr = mbstok_r(NULL, "/", &last)) == NULL) break;
+#endif
+               dirnamelen = strlen(lptr) + 1;
+
+               if (sizeof(dir) < dirnamelen) {
+                       return -1;
+               }
+#ifdef _WIN32
+               if (dir != NULL && strlen (dir) > 0) 
+#endif                 
+               strcat(dir, "/");
+               strcat(dir, lptr);
+
+               if (access(dir, R_OK) != 0) 
+#ifndef _WIN32
+                       mkdir(dir, S_IRWXU | S_IRWXG);
+#else
+                       mkdir(dir);             
+#endif
+               lptr = ptr;
+       }
+
+       return 0;
+       
+}
+
+
+/**
+ * @brief      check pid file
+ * @param      filename: process name
+ * @date    Dec 24. 2008
+ * */
+
+int run_check_simulator(const char *filename)
+{
+       FILE    *fp;
+       char    buff[128] = "";
+       char    pidfname[64] = "";
+       char    procpidname[512] = "";
+       int             simulatorpid = 0;
+
+       //sprintf(pidfname, "%s%s.pid", PID_DIR, filename);
+
+       if (!strncmp(g_get_user_name(), "root", 4))
+               sprintf(pidfname, "/root%s%s.pid", PID_DIR, filename);
+       else
+               sprintf(pidfname, "/home/%s%s%s.pid", g_get_user_name(), PID_DIR, filename);
+
+       if ((fp = fopen(pidfname, "r")) == NULL) {
+               return 0;
+       }
+
+       if (fgets(buff, sizeof(buff)-1, fp) == NULL) {
+               fclose(fp);
+               return 0;
+       }
+
+       simulatorpid = atoi(buff);
+
+       sprintf(procpidname, "/proc/%d", simulatorpid);
+
+       if( access( procpidname, F_OK ) == 0 ) {
+               fclose(fp);
+               return simulatorpid;
+       }
+
+       fclose(fp);
+
+       return 0;
+}
+
+/**
+ * @brief      wirte pid file
+ * @param      mod: simulator, vinit
+ * @date    Nov 25. 2008
+ * */
+
+int write_pidfile(const char *filename)
+{
+       int             fd = -1;
+       char    buf[128] = "";
+       char    pidfname[512] = ""; 
+
+       //      sprintf (pidfname, "%s%s.pid", PID_DIR, filename);
+#ifndef _WIN32
+       if (!strncmp(g_get_user_name(), "root", 4))
+               sprintf(pidfname, "/root%s%s.pid", PID_DIR, filename);
+       else
+               sprintf(pidfname, "/home/%s%s%s.pid", g_get_user_name(), PID_DIR, filename);
+#else
+       gchar *conf_path = get_conf_path();
+       sprintf(pidfname, "%ssimulator.pid", conf_path);
+       
+       if (conf_path)
+               g_free(conf_path);
+#endif
+
+       if (access(PID_DIR, R_OK) != 0) {
+               make_pid_path(pidfname);
+       }
+
+       if ((fd = open(pidfname, O_RDWR | O_CREAT, 0666)) < 0) {
+               log_msg(MSGL_ERROR, "%s at %s(%d)\n", strerror(errno), __FILE__, __LINE__);
+               return -1;
+       }
+
+       /* ±âÁ¸ ³»¿ë »èÁ¦ */
+       
+       ftruncate(fd, 0);
+       memset(buf, 0, sizeof(buf));
+       sprintf(buf, "%d", (int)getpid());
+       write(fd, buf, strlen(buf));
+
+#ifndef _WIN32
+       chmod(pidfname, S_IRWXU | S_IRWXG | S_IRWXO);
+#else
+       chmod(pidfname, S_IRWXU);
+#endif
+       close(fd);
+
+       return 0;
+}
+
+/**
+ * @brief      wirte pid file
+ * @param      mod: simulator, vinit
+ * @date    Nov 25. 2008
+ * */
+
+int remove_pidfile(const char *filename)
+{
+       char    pidfname[512] = ""; 
+
+       if (filename == NULL) {
+               return -1;
+       }
+
+       //sprintf (pidfname, "%s%s.pid", PID_DIR, filename);
+#ifndef _WIN32
+       if (!strncmp(g_get_user_name(), "root", 4))
+               sprintf(pidfname, "/root%s%s.pid", PID_DIR, filename);
+       else
+               sprintf(pidfname, "/home/%s%s%s.pid", g_get_user_name(), PID_DIR, filename);
+#else
+       gchar *conf_path = get_conf_path();
+       sprintf(pidfname, "%ssimulator.pid", conf_path);
+       
+       if (conf_path)
+               g_free(conf_path);
+#endif
+
+       if (strlen(pidfname) <= 0) {
+               return -1;
+       }
+
+       if (remove (pidfname) < 0) {
+               log_msg(MSGL_ERROR, "Can't remove pid file. (%s)\n", pidfname);
+       }
+
+       return 0;
+}
+
+FILE * 
+popen_target(const char *cmdstring, const char *type)
+{
+       FILE    *fp;
+#ifndef _WIN32
+       int     pfd[2];
+       pid_t   pid;
+
+       /* only allow "r" or "w" */
+       if ((type[0] != 'r' && type[0] != 'w') || type[1] != 0) {
+               errno = EINVAL;         /* required by POSIX.2 */
+               return(NULL);
+       }
+
+       if (pipe(pfd) < 0)
+               return(NULL);   /* errno set by pipe() */
+
+       if ( (pid = vfork()) < 0)
+               return(NULL);   /* errno set by fork() */
+       else if (pid == 0) {                                                    /* child */
+
+               if (*type == 'r') {
+                       close(pfd[0]);
+                       if (pfd[1] != STDOUT_FILENO) {
+                               dup2(pfd[1], STDOUT_FILENO);
+                               close(pfd[1]);
+                       }
+               } else {
+                       close(pfd[1]);
+                       if (pfd[0] != STDIN_FILENO) {
+                               dup2(pfd[0], STDIN_FILENO);
+                               close(pfd[0]);
+                       }
+               }
+               close_all_pid_fds();
+               execlp("ssh", "ssh", "-o StrictHostKeyChecking=no", "-p 1202", "root@127.0.0.1", cmdstring, (char *)0);
+               _exit(127);
+       }
+
+       /* parent */
+       if (*type == 'r') {
+               close(pfd[1]);
+               if ( (fp = fdopen(pfd[0], type)) == NULL)
+                       return(NULL);
+       } else {
+               close(pfd[0]);
+               if ( (fp = fdopen(pfd[1], type)) == NULL)
+                       return(NULL);
+       }
+       save_pid(fileno(fp), pid);      /* remember child pid for this fd */
+#endif
+       return(fp);
+
+}
+
+/**
+ * @brief      pclose for finding error
+ * @param      FILE
+ * */
+int pclose_target(FILE *fp)
+{
+       int             fd, stat;
+#ifndef _WIN32
+       pid_t   pid;
+
+       fd = fileno(fp);
+       if ( (pid = pid_from_fd(fd, 1)) == 0)
+               return(-1);             /* fp wasn't opened by popen() */
+
+       while (waitpid(pid, &stat, 0) < 0)
+               if (errno != EINTR)
+                       return(-1);     /* error other than EINTR from waitpid() */
+#endif
+       return(stat);   /* return child's termination status */
+}
+
+
+/**
+ * @brief      popen for finding error
+ * @param      cmdstring
+ * @param      type
+ * @return     FILE
+ * */
+
+FILE *
+popen_err(const char *cmdstring, const char *type)
+{
+       FILE    *fp;
+#ifndef _WIN32
+       int     pfd[2];
+       pid_t   pid;
+
+       /* only allow "r" or "w" */
+       if ((type[0] != 'r' && type[0] != 'w') || type[1] != 0) {
+               errno = EINVAL;         /* required by POSIX.2 */
+               return(NULL);
+       }
+
+       if (pipe(pfd) < 0)
+               return(NULL);   /* errno set by pipe() */
+
+       if ( (pid = fork()) < 0)
+               return(NULL);   /* errno set by fork() */
+       else if (pid == 0) {                                                    /* child */
+
+               if (*type == 'r') {
+                       close(pfd[0]);
+                       if (pfd[1] != STDERR_FILENO) {
+                               dup2(pfd[1], STDERR_FILENO);
+                               close(pfd[1]);
+                       }
+               } else {
+                       close(pfd[1]);
+                       if (pfd[0] != STDIN_FILENO) {
+                               dup2(pfd[0], STDIN_FILENO);
+                               close(pfd[0]);
+                       }
+               }
+               close_all_pid_fds();
+               execl(SHELL, "sh", "-c", cmdstring, (char *) 0);
+               _exit(127);
+       }
+
+       /* parent */
+       if (*type == 'r') {
+               close(pfd[1]);
+               if ( (fp = fdopen(pfd[0], type)) == NULL)
+                       return(NULL);
+       } else {
+               close(pfd[0]);
+               if ( (fp = fdopen(pfd[1], type)) == NULL)
+                       return(NULL);
+       }
+       save_pid(fileno(fp), pid);      /* remember child pid for this fd */
+#endif
+       return(fp);
+}
+
+/**
+ * @brief      pclose for finding error
+ * @param      FILE
+ * */
+int pclose_err(FILE *fp)
+{
+       int             fd, stat;
+       pid_t   pid;
+#ifndef _WIN32
+       fd = fileno(fp);
+       if ( (pid = pid_from_fd(fd, 1)) == 0)
+               return(-1);             /* fp wasn't opened by popen() */
+
+       if (fclose(fp) == EOF)
+               return(-1);
+
+       while (waitpid(pid, &stat, 0) < 0)
+               if (errno != EINTR)
+                       return(-1);     /* error other than EINTR from waitpid() */
+#else
+/*
+       while(WaitForSingleObject(handle, INFINITE) == WAIT_FAILED)
+       {
+               printf("WaitForSingleObject FAILED: err=%d\n", GetLastError());
+               return (-1);
+       }
+*/
+#endif
+       return(stat);   /* return child's termination status */
+}
+
diff --git a/lib/libcommon/process.h b/lib/libcommon/process.h
new file mode 100644 (file)
index 0000000..c6dc422
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef PROCESS_H
+#define PROCESS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <strings.h>
+#include "logmsg.h"
+
+int run_check_simulator(const char *filename);
+int write_pidfile(const char *filename);
+int remove_pidfile(const char *filename);
+
+FILE * popen_err(const char *cmdstring, const char *type);
+int pclose_err(FILE *fp);
+
+//#define PID_DIR "/var/run/simulator/"
+#ifndef _WIN32
+#define PID_DIR "/.samsung_sdk/simulator/1/"
+#else
+#define PID_DIR "/samsung_sdk/simulator/1/"
+#endif
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <mbstring.h>
+
+char * mbstok_r (char *string, const char *delim, char **save_ptr);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/lib/libcommon/safestring.c b/lib/libcommon/safestring.c
new file mode 100644 (file)
index 0000000..c69d843
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "safestring.h"
+
+/**
+ * @brief      secure wrapper of strncpy
+ * @param      dst : dest buffer
+ * @param      src : source buffer
+ * @param      n : copy size
+ * @date    Apr 29. 2008
+ * */
+
+gsize s_strncpy(char *dst, const char *src, int n)
+{
+       if (!src || n == 0)
+       {
+               log_msg (MSGL_DEBUG, "Cannot copy the string. Null args or size zero.\n");
+               return -1;
+       }
+
+       if (!dst)
+       {
+               log_msg (MSGL_ERROR, "Cannot copy the string. Null args or size zero.\n");
+               exit(0);
+       }
+
+       strncpy(dst, src, n);
+       return 0;
+
+}
+
+/**
+ * @brief      secure wrapper of strcpy
+ * @param      dst : dest buffer
+ * @param      src : source buffer
+ * @date    Apr 29. 2008
+ * */
+
+gsize s_strcpy(char *dst, const char *src)
+{
+       if (!dst || !src || (strlen(src) == 0))
+       {
+               log_msg(MSGL_WARN, "Cannot copy the string. Null args or size zero.\n");
+               return -1;
+       }
+
+       //g_strlcpy(dst, src, (gsize)strlen(src));
+       strcpy(dst, src);
+       return 0;
+
+}
+
+/**
+ * @brief      secure wrapper of strcmp
+ * @param      dst : dest buffer
+ * @param      src : source buffer
+ * @date    Apr 29. 2008
+ * */
+
+gsize s_strcmp(const char *dst, const char *src)
+{
+       int srcsize;
+       int dstsize;
+
+       srcsize = strlen(src);
+       dstsize = strlen(dst);
+
+       if ((srcsize == 0) && (dstsize == 0)) {
+               return 0;
+       }
+
+       if (!dst || !src || srcsize == 0 || dstsize == 0)
+       {
+               return -1;
+       }
+
+       if (srcsize==dstsize) {
+               return (strcmp(src, dst));
+       }
+       else {
+               return -1;
+       }
+
+}
+
+
+/**
+ * @brief      secure wrapper of strncmp
+ * @param      dst : dest buffer
+ * @param      src : source buffer
+ * @date    Apr 29. 2008
+ * */
+
+gsize s_strncmp(const char *dst, const char *src, int n)
+{
+       int srcsize;
+       int dstsize;
+
+       srcsize = strlen(src);
+       dstsize = strlen(dst);
+
+       if ((srcsize == 0) && (dstsize == 0))
+               return 0;
+
+       if (!dst || !src || srcsize == 0 || dstsize == 0 || n == 0) {
+               log_msg (MSGL_WARN, "Cannot compare the string. Null args or size zero.\n");
+               return -1;
+       }
+
+       if (srcsize==dstsize)
+               return (strncmp(src, dst, n));
+
+       else
+               return -1;
+}
diff --git a/lib/libcommon/safestring.h b/lib/libcommon/safestring.h
new file mode 100644 (file)
index 0000000..aaa7578
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef SAFESTRING_H
+#define SAFESTRING_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "logmsg.h"
+
+
+gsize s_strncpy(char *dst, const char *src, int n);
+gsize s_strcpy(char *dst, const char *src);
+gsize s_strcmp(const char *dst, const char *src);
+gsize s_strncmp(const char *dst, const char *src, int n);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libsms/Makefile.in b/lib/libsms/Makefile.in
new file mode 100644 (file)
index 0000000..c5a8b1e
--- /dev/null
@@ -0,0 +1,43 @@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS   = @GLIB_LIBS@
+
+DEFINES += __arm__
+DEFINES += _VGSM_DEBUG
+DEFINES += IPC_DEBUG
+DEFINES += IPC_VERSION=4
+
+CFLAGS  = @CFLAGS@
+CFLAGS += $(INCDIRS:%=-I%) $(DEFINES:%=-D%) $(GLIB_CFLAGS)
+CFLAGS += -Wstrict-prototypes
+CFLAGS += -Wmissing-prototypes
+CFLAGS += -Wuninitialized
+CFLAGS += -Wpointer-arith
+CFLAGS += -Wp,-MD,$(dir $@).$(notdir $@).d -Wp,-MT,$@
+# for bypass __stack_chk_fail
+CFLAGS +=-fno-stack-protector
+CC = @CC@
+AR = @AR@
+
+SOURCES = \
+       sms_util.c \
+       sms_tool.c
+
+LIBS = $(GLIB_LIBS)
+
+OBJECTS += $(SOURCES:%.c=%.o)
+
+DEPFILES += $(foreach object,$(OBJECTS),$(dir $(object)).$(notdir $(object)).d)
+
+TARGET = libsms.a
+
+all: $(TARGET)
+
+-include $(DEPFILES)
+
+$(TARGET): $(OBJECTS)
+       $(AR) r $@ $(OBJECTS)
+
+clean:
+       rm -f $(OBJECTS) $(TARGET)
+       rm -f $(DEPFILES)
+
diff --git a/lib/libsms/sms_header.h b/lib/libsms/sms_header.h
new file mode 100644 (file)
index 0000000..ed80198
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SMS_HEADER_H_
+#define _SMS_HEADER_H_
+
+typedef unsigned char BYTE;
+typedef unsigned short UINT8;
+typedef unsigned short UINT;
+typedef unsigned int UINT32;
+typedef int BOOL;
+
+#define TAPI_NETTEXT_CB_SIZE_MAX           255
+#define TAPI_NETTEXT_MSG_SIZE_MAX          500
+#define TAPI_NETTEXT_SCADDRESS_LEN_MAX     20
+#define TAPI_NETTEXT_SMDATA_SIZE_MAX       255
+#define TAPI_NETTEXT_ADDRESS_LEN_MAX       255
+
+#ifndef        TRUE
+#define TRUE   1
+#endif /* TRUE */
+
+#ifndef FALSE
+#define FALSE  0
+#endif /* FALSE */
+
+/**
+ * @enum TapiNetTextVPType
+ * This enumeration defines the validity period type.
+ */
+typedef enum
+{
+       TAPI_NETTEXT_VP_NOT_USED = 0,           /**< validity period not used */
+       TAPI_NETTEXT_VP_RELATIVE = 2,           /**< after a predetermined time period after the service center has received the message */
+       TAPI_NETTEXT_VP_ABSOLUTE = 3,
+       TAPI_NETTEXT_VP_ENHANCED = 1,
+
+       TAPI_NETTEXT_VP_MAX
+} TapiNetTextVPType;
+
+/**
+ * @enum TapiNetTextVPRelValue
+ * This structure defines the validity period type.
+ */
+typedef enum
+{
+       TAPI_NETTEXT_VP_REL_1H,         /**< One hour */
+       TAPI_NETTEXT_VP_REL_6H,         /**< Six hours */
+       TAPI_NETTEXT_VP_REL_12H,        /**< Twelve hours */
+       TAPI_NETTEXT_VP_REL_1D,         /**< One day */
+       TAPI_NETTEXT_VP_REL_3D,         /**< Three days */
+       TAPI_NETTEXT_VP_REL_1W,         /**< One week */
+       TAPI_NETTEXT_VP_REL_1M,         /**< One Month */
+       TAPI_NETTEXT_VP_REL_MAX         /**< Max = 63 weeks */
+} TapiNetTextVPRelValue;
+
+typedef struct
+{
+       TapiNetTextVPType vpType;                         /**< Validity period format */
+       TapiNetTextVPRelValue vpRelativeType; /**< Validity period value duration the message must retain in the service center while application attempts delivery */
+       UINT32 vpValue;                                           /** Validity period value */
+} TapiNetTextVP;
+
+/**
+ * @enum TapiNetTextCodingGroupType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS,                     /**< Bits 7..4 00xx */
+       TAPI_NETTEXT_CODGRP_CB_GENERAL_LANG,            /**< 0000 */
+       TAPI_NETTEXT_CODGRP_CB_ALPHA,                           /**< 0001 */
+       TAPI_NETTEXT_CODGRP_CB_RES1,                            /**< 0010 */
+       TAPI_NETTEXT_CODGRP_CB_RES2,                            /**< 0011 */
+       TAPI_NETTEXT_CODGRP_SM_AUTO_DELETION,           /**< 01xx Bits 5..0 are coded the same as SM_GENERAL_DCS */
+       TAPI_NETTEXT_CODGRP_CB_GENERAL_DCS,                     /**< 01xx behavior is as SM_GENERAL_DCS */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_DISCARD,         /**< 1100 */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_STORE,           /**< 1101 */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_STORE_UCS2,      /**< 1110 */
+       TAPI_NETTEXT_CODGRP_CB_WAP,                                     /**< 1110 Cell Broadcast */
+       TAPI_NETTEXT_CODGRP_SM_CLASS_CODING,            /**< 1111 */
+       TAPI_NETTEXT_CODGRP_CB_CLASS_CODING,            /**< 1111 Cell Broadcast */
+       TAPI_NETTEXT_CODGRP_SM_RESERVED,                        /* reserved coding group */
+       TAPI_NETTEXT_CODGRP_MAX
+} TapiNetTextCodingGroupType;
+
+/**
+ * @enum TapiNetTextWaitingType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_WAITING_VOICE_MSG,         /**< voice message waiting */
+       TAPI_NETTEXT_WAITING_FAX_MSG,           /**< FAX message waiting */
+       TAPI_NETTEXT_WAITING_EMAIL_MSG,         /**< E-mail waiting */
+       TAPI_NETTEXT_WAITING_OTHER_MSG,         /**< Other message waiting */
+
+       TAPI_NETTEXT_WAITING_MAX
+} TapiNetTextWaitingType;
+
+/**
+ * @enum TapiNetTextAlphabetType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_ALPHABET_DEFAULT,  /**< GSM alphabet default 7bit */
+       TAPI_NETTEXT_ALPHABET_8BIT,             /**< 8bit */
+       TAPI_NETTEXT_ALPHABET_UCS2,             /**< 16bit ucs2 */
+
+       TAPI_NETTEXT_ALPHABET_KSC5601,  /**< for Korean */
+
+       TAPI_NETTEXT_ALPHABET_MAX
+} TapiNetTextAlphabetType;
+
+/**
+ * @enum TapiNetTextClassType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_CLASS_0,   /**< display immediately */
+       TAPI_NETTEXT_CLASS_1,   /**< may be stored */
+       TAPI_NETTEXT_CLASS_2,   /**< store in SIM */
+       TAPI_NETTEXT_CLASS_3,   /**< transfer to TE */
+       TAPI_NETTEXT_CLASS_NONE,
+
+       TAPI_NETTEXT_CLASS_MAX
+} TapiNetTextClassType;
+
+typedef struct
+{
+       BOOL                                                    bSMSCinSIM;                     /**< if SMSC is stored in SIM this is TRUE */
+       BOOL                                                    bCompressed;            /**< if text is compressed this is TRUE */
+       BOOL                                                    bMsgClassSet;           /**< message class indication. if TRUE = bits 1..0, if FALSE = reserved */
+       BOOL                                                    bMsgIndActive;          /**< message indication group. if TRUE = on, FALSE = off */
+       TapiNetTextCodingGroupType              codingGroupType;        /**< Coding group, GSM 03.38 */
+       TapiNetTextWaitingType                  waitingType;            /**< Type of message waiting */
+       TapiNetTextAlphabetType                 alphabetType;           /**< How to encode a message. */
+       TapiNetTextClassType                    classType;                      /**< The message class */
+       BYTE                                    codingGroup;            /* reserved coding group 7...4 */
+       BYTE                                    code;                   /* code 3...0 */
+
+} TapiNetTextCodingScheme;
+
+////////////////////////////////Adddress Field/////////////////////////////////
+#define ADDRESS_LEN_MAX        20
+
+//type of number
+typedef enum
+{
+       TYPEOFNUMBER_UNKNOWN                                            =0x00,
+       TYPEOFNUMBER_INTERNATION_NUMER                          =0x01,
+       TYPEOFNUMBER_NATIONAL_NUMBER                            =0x02,
+       TYPEOFNUMBER_NETWORK_SPECIFIC_NUMBER            =0x03,
+       TYPEOFNUMBER_SUBSCRIBER_NUMBER                          =0x04,
+       TYPEOFNUMBER_ALPHANUMERIC                               =0x05,
+       TYPEOFNUMBER_ABBREVIATED                                =0x06,
+       TYPEOFNUMBER_RESERVED_FOR_EXTENSION             =0x07
+       
+}NumberType;
+
+// Numbering-plan-identification (applies for type of number 000,001,010)
+typedef enum
+{
+       NUMBERING_PLAN_IDENTIFICATION_UNKNOWN                   =0x00,
+       NUMBERING_PLAN_IDENTIFICATION_ISDN_TELEPHONE            =0x01,
+       NUMBERING_PLAN_IDENTIFICATION_DATA                              =0x03,
+       NUMBERING_PLAN_IDENTIFICATION_TELEX                             =0x04,
+       NUMBERING_PLAN_IDENTIFICATION_NATIONAL                  =0x08,
+       NUMBERING_PLAN_IDENTIFICATION_PRIVATE                           =0x09,
+       NUMBERING_PLAN_IDENTIFICATION_ERMES                             =0x0A,  // refer 3GPP_ts_23.040-9.1.2.5
+       NUMBERING_PLAN_IDENTIFICATION_RESERVED                  =0x0F
+       
+}NumberingPlan;
+
+typedef struct 
+{
+       NumberType              ton;
+       
+       NumberingPlan           npi;
+               
+       UINT32                  dialnumLen;
+       
+       unsigned char           diallingNum[ADDRESS_LEN_MAX+1];
+       
+} SmsAddressInfo;
+
+#endif /* _SMS_HEADER_H_ */
diff --git a/lib/libsms/sms_tool.c b/lib/libsms/sms_tool.c
new file mode 100644 (file)
index 0000000..e21bfae
--- /dev/null
@@ -0,0 +1,2803 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <glib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "sms_util.h"
+
+
+
+/*==================================================================================================
+  IMPLEMENTATION OF MsgConvertText - Member Functions
+  ==================================================================================================*/
+// ETSI GSM 03.38 7-bit default alphabet -> Unicode scalar value (UCS2)
+// index : gsm 7bit char value
+static const unsigned short g_GSM7BitToUCS2Table[] = 
+{
+       0x40/*@*/, 0xA3, 0x24, 0xA5, 0xE8, 0xE9, 0xF9, 0xEC,            0xF2, 0xC7/*0xE7*/, 0x0A, 0xD8, 0xF8, 0x0D, 0xC5, 0xE5, 
+       0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0,         0x03A8, 0x03A3, 0x0398, 0x039E, 0x0000, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
+       0x20/*space*/, 33, 34, 35, 164, 37, 38, 39,                             40, 41, 42, 43, 44, 45, 46, 47, 
+       48, 49, 50, 51, 52, 53, 54, 55,                                                         56, 57, 58, 59, 60, 61, 62, 63,
+       161, 65, 66, 67, 68, 69, 70, 71,                                                        72, 73, 74, 75, 76, 77, 78, 79, 
+       80, 81, 82, 83, 84, 85, 86, 87,                                                         88, 89, 90, 196, 214, 209, 220, 167,
+       191, 97, 98, 99, 100, 101, 102, 103,                                            104, 105, 106, 107, 108, 109, 110,      111, 
+       112, 113, 114, 115, 116, 117, 118, 119,                                         120, 121, 122, 228, 246, 241, 252, 224
+               /*
+                  '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec,0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5,
+                  '?', '_', '?', '?', '?', '?', '?', '?','?', '?', '?', '?', 0xc6, 0xe6, 0xdf, 0xc9,
+                  ' ', '!', '\"', '#', 0xa4, '%', '&','\'','(', ')', '*', '+', ',', '-', '.', '/',
+                  '0', '1', '2', '3', '4', '5', '6', '7','8', '9', ':', ';', '<', '=', '>', '?',0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+                  'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O','P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+                  'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7,0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+                  'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o','p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+                  'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0
+                */
+};
+
+static const char g_UCS2ToGSM7BitTable[] = 
+{
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x0a, 0x1b, 0x1b, 0x0d, 0x1b, 0x1b,
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27,                 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /*40, 41, 42, 43, 44, 45, 46, 47,*/
+       0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,                         0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /*48, 49, 50, 51, 52, 53, 54, 55,       56, 57, 58, 59, 60, 61, 62, 63, */
+       0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,                 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /*0, 65, 66, 67, 68, 69, 70, 71,        72, 73, 74, 75, 76, 77, 78, 79,*/
+       0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,                 0x58, 0x59, 0x5a, 0x1b, 0x1b, 0x1b, 0x1b, 0x11,         /*80, 81, 82, 83, 84, 85, 86, 87,       88, 89, 90, 0x1b, 0x1b, 0x1b, 0x1b, 0x11,               */
+       0x1b, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,                 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /*0x1b, 97, 98, 99, 100, 101, 102, 103,         104, 105, 106, 107, 108, 109, 110, 111,*/
+       0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,                 0x78, 0x79, 0x7a, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, /*112, 113, 114, 115, 116, 117, 118, 119,                                       120, 121, 122, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,*/
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x40, 0x1b, 0x01, 0x24, 0x03, 0x1b, 0x5f,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, // 0xA0 ~
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x60, 
+       0x1b, 0x1b, 0x1b, 0x1b, 0x5B, 0x0E, 0x1C, 0x09,                 0x1b, 0x1f, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x5D, 0x1b, 0x1b, 0x1b, 0x1b, 0x5c, 0x1b,                 0x0b, 0x1b, 0x1b, 0x1b, 0x5e, 0x1b, 0x1b, 0x1e,
+       0x7f, 0x1b, 0x1b, 0x1b, 0x7b, 0x0f, 0x1d, 0x09,                 0x04, 0x05, 0x1b, 0x1b, 0x07, 0x1b, 0x1b, 0x1b, 
+       0x1b, 0x7d, 0x08, 0x1b, 0x1b, 0x1b, 0x7C, 0x1b,                 0x0c, 0x06, 0x1b, 0x1b, 0x7e, 0x1b, 0x1b, 0x1b
+};
+
+static const  unsigned short g_GSM7BitToUCS2TableExt[] = 
+{      // 0x20 -> for invalid code
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,                         0x20, 0x20, 12/**/, 0x20, 0x20, 0x20, 0x20, 0x20, 
+       0x20, 0x20, 0x20, 0x20, 94/**/, 0x20, 0x20, 0x20,                       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,                 123/**/, 125/**/, 0x20, 0x20, 0x20, 0x20, 0x20, 92/**/, 
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,                         0x20, 0x20, 0x20, 0x20, 91/**/, 126/**/, 93/**/, 0x20,  //64
+       124/**/, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,              0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,                 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,         //104
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20AC/**/, 0x20, 0x20,           0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+       0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,                 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
+};
+
+static const char g_UCS2ToGSM7BitTableExt[] = 
+{      // 0x1b -> for invalid code
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x0a/**/, 0x1b, 0x1b, 0x1b,             //16
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //32
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //64
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x3c/**/, 0x2f/**/, 0x3e/**/, 0x14/**/, 0x1b, //96
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x28/**/, 0x40/**/, 0x29/**/, 0x3d/**/, 0x1b, //128
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //144
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //160
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b/*0x65?*/, 0x1b, 0x1b, 0x1b,                0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //176   // 0xA0~
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //192
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //208
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //224
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 //240
+       0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b,                 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b                  //256
+};
+
+
+#ifdef CONVERT_DUMP
+
+#define MAX_DUMP_COLUMN        16
+void MsgConvertDumpTextToHex(const unsigned char *pText, int length)
+{
+       int i, j;
+
+       fprintf(stderr, "\n=======================================\n");
+       fprintf(stderr, "   Dump Text To Hex - Length :%d\n", length);
+       fprintf(stderr, "=======================================");
+       for ( i = 0; i < length; i++ )
+       {
+               if ( i % MAX_DUMP_COLUMN == 0 )
+               {
+                       fprintf(stderr, "\n\t");
+               }
+               fprintf(stderr, "%02x ", pText[i]);
+       }
+       fprintf(stderr, "\n=======================================\n\n");
+}
+
+#else
+
+#define MsgConvertDumpTextToHex(pText, length)
+
+#endif // CONVERT_DUMP
+
+
+/**
+args :
+unsigned char *pDestText                               : destination text (UCS2) - byte order depends on local byte order
+const unsigned char *pSrcText          : source text (gsm7bit)
+int maxLength                  : max destination buffer size
+int srcTextLen                 : byte length of source text (gsm7bit)
+return : 
+byte length of converted UCS2 characters
+-1 : The alpha isn't the gsm 7bit code
+ */
+int MsgConvertGSM7bitToUCS2(unsigned char *pDestText, int maxLength, const unsigned char *pSrcText, int srcTextLen)
+{
+       int outTextLen = 0;
+       int i = 0;
+       unsigned char lowerByte, upperByte;
+
+       if(srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               fprintf(stderr, "UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }       
+
+       for(i = 0 ; i<srcTextLen ; i++)
+       {
+               if ( maxLength == 0 )
+               {
+                       break;
+               }
+               if (pSrcText[i] >= 0x80)
+               {
+                       //error
+                       fprintf(stderr, ">>>>>>>a_pTextString[i]=%x, The alpha isn't the gsm 7bit code, Never Come here!!!\n", pSrcText[i]);
+                       return -1;
+               }
+               if(g_GSM7BitToUCS2Table[ pSrcText[i] ] == 0x0/*0*/)
+               {       //extended gsm7bit
+                       i++;
+                       lowerByte = g_GSM7BitToUCS2TableExt[ pSrcText[i] ] & 0x00FF;
+                       upperByte = (g_GSM7BitToUCS2TableExt[ pSrcText[i] ] & 0xFF00) >> 8;
+               }
+               else
+               {
+                       lowerByte = g_GSM7BitToUCS2Table[ pSrcText[i] ] & 0x00FF;
+                       upperByte = (g_GSM7BitToUCS2Table[ pSrcText[i] ] & 0xFF00) >> 8;
+               }
+               pDestText[outTextLen++] = upperByte;
+               pDestText[outTextLen++] = lowerByte;
+               maxLength -= 2;
+       }
+
+#ifdef CONVERT_DUMP
+       fprintf(stderr, "\n########## Dump GSM7bit -> UCS2\n");
+       MsgConvertDumpTextToHex((unsigned char*)pSrcText, srcTextLen);
+       MsgConvertDumpTextToHex((unsigned char*)pDestText, outTextLen);
+#endif
+
+       return outTextLen;
+}
+
+
+/**
+
+args:
+unsigned char *pDestText
+int maxLength                          : max destination buffer size
+const unsigned char *pSrcText
+int srcTextLen                         : BYTE length of src text (UCS2)
+return:
+bytelength of gsm7bit text
+-1 : converting error
+ */
+int MsgConvertUCS2toGSM7bit(unsigned char *pDestText, int maxLength, const unsigned char *pSrcText, int srcTextLen, BOOL *bUnknown)
+{
+       // for UNICODE
+       int outTextLen = 0;
+       int nTextLen = srcTextLen;              // # of bytes of UCS2 charaters
+       unsigned char lowerByte, upperByte;
+
+       if(srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               fprintf(stderr, "UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }       
+
+       int i = 0;
+       for( i = 0 ; i<nTextLen ; i += 2 )
+       {
+               upperByte = pSrcText[i];
+               lowerByte = pSrcText[i+1];
+               if ( upperByte == 0x00 )
+               {       // 0x00XX -> converts with mapping table
+                       if(  g_UCS2ToGSM7BitTable[ lowerByte ] == 0x1b/*27*/ )
+                       {  
+                               if(g_UCS2ToGSM7BitTableExt[ lowerByte ] == 0x1b)        
+                               {       // unknown character
+                                       pDestText[outTextLen++] = 0x20;
+                                       *bUnknown = TRUE;
+                               }
+                               else                                                                                    
+                               {       //extended gsm7bit
+                                       // prevent buffer overflow.
+                                       if ( maxLength <= outTextLen + 1 )
+                                       {
+                                               fprintf(stderr, "Buffer full\n");
+                                               goto FINISH_CONVERT;
+                                       }                       
+                                       pDestText[outTextLen++] = 0x1b;         
+                                       pDestText[outTextLen++] = g_UCS2ToGSM7BitTableExt[ lowerByte ];
+                               }
+                       }
+                       else
+                       {
+                               pDestText[outTextLen++] = g_UCS2ToGSM7BitTable[ lowerByte ];
+                       }               
+               }
+               else
+               {       // unicode : GREEK CAPITAL LETTERS
+                       unsigned short ucsChar = (upperByte << 8) | lowerByte;
+                       switch ( ucsChar )
+                       {
+                               case 0x0394:    // ¥Ä   GREEK CAPITAL LETTER DELTA
+                                       pDestText[outTextLen++] = 0x10;
+                                       break;
+                               case 0x03A6:    // ¥Õ   GREEK CAPITAL LETTER PHI
+                                       pDestText[outTextLen++] = 0x12;
+                                       break;
+                               case 0x0393:    // ¥Ã   GREEK CAPITAL LETTER GAMMA
+                                       pDestText[outTextLen++] = 0x13;
+                                       break;
+                               case 0x039B:    // ¥Ë   GREEK CAPITAL LETTER LAMDA
+                                       pDestText[outTextLen++] = 0x14;
+                                       break;
+                               case 0x03A9:    // ¥Ø   GREEK CAPITAL LETTER OMEGA
+                                       pDestText[outTextLen++] = 0x15;
+                                       break;
+                               case 0x03A0:    // ¥Ð   GREEK CAPITAL LETTER PI
+                                       pDestText[outTextLen++] = 0x16;
+                                       break;
+                               case 0x03A8:    // ¥×   GREEK CAPITAL LETTER PSI
+                                       pDestText[outTextLen++] = 0x17;
+                                       break;
+                               case 0x03A3:    // ¥Ò   GREEK CAPITAL LETTER SIGMA
+                                       pDestText[outTextLen++] = 0x18;
+                                       break;
+                               case 0x0398:    // ¥È   GREEK CAPITAL LETTER THETA
+                                       pDestText[outTextLen++] = 0x19;
+                                       break;
+                               case 0x039E:    // ¥Î   GREEK CAPITAL LETTER XI
+                                       pDestText[outTextLen++] = 0x1A;
+                                       break;
+                               case 0x20AC:    // ¢æ: EURO SIGN
+                                       // prevent buffer overflow.
+                                       if ( maxLength <= outTextLen + 1 )
+                                       {
+                                               fprintf(stderr, "Buffer full\n");
+                                               goto FINISH_CONVERT;
+                                       }                                       
+                                       pDestText[outTextLen++] = 0x1B;
+                                       pDestText[outTextLen++] = 0x65;
+                                       break;
+                               default:
+                                       pDestText[outTextLen++] = 0x20;
+                                       *bUnknown = TRUE;
+
+                       }
+               }
+
+               // prevent buffer overflow.
+               if ( maxLength <= outTextLen )
+               {
+                       fprintf(stderr, "Buffer full\n");
+                       goto FINISH_CONVERT;
+               }       
+       }
+
+FINISH_CONVERT:
+
+#ifdef CONVERT_DUMP
+       fprintf(stderr, "\n########## Dump UCS2 -> GSM7bit\n");
+       MsgConvertDumpTextToHex((unsigned char*)pSrcText, srcTextLen);
+       MsgConvertDumpTextToHex((unsigned char*)pDestText, outTextLen);
+#endif
+
+       return outTextLen;
+}
+
+
+/**
+  if srcTextLen ispSrcText should be null terminated
+return :
+byte length of converted UCS2 characters
+-1 : converting error
+ */
+int MsgConvertUTF8toUCS2(unsigned char *pDestText, int maxLength, const unsigned char *pSrcText, int srcTextLen)
+{
+       int i, j;
+       int textLen;    
+       unsigned char *unicodeTemp = (unsigned char*)pDestText;
+       int ucs2Length = 0;
+       int remainedBuffer = maxLength;
+
+#ifdef CONVERT_DUMP
+       int srcLen = srcTextLen;
+       const unsigned char * pTempSrcText = pSrcText;
+       const unsigned char * pTempDestText = pDestText;
+#endif
+
+       i = j = 0;      
+
+       if(maxLength == 0 || pSrcText == NULL || pDestText ==  NULL)
+       {
+               fprintf(stderr, "UTF8 to UCS2 Failed as text length is 0\n");
+               return -1;
+       }       
+
+       // null terminated string
+       if ( srcTextLen == -1 )
+       {
+               textLen = strlen((char*)pSrcText);
+               srcTextLen = textLen;
+       }
+       else
+       {
+               textLen = srcTextLen;
+       }
+
+       GIConv cd;
+       int err=0;
+
+       cd = g_iconv_open("UCS-2BE", "UTF8");
+
+       if (cd > 0)
+       {
+               err = g_iconv(cd, (char**)&pSrcText, (gsize*)&textLen, (char**)&unicodeTemp, (gsize*)&remainedBuffer);
+       }
+
+       ucs2Length = maxLength - remainedBuffer;
+
+#ifdef CONVERT_DUMP
+       fprintf(stderr, "\n########## Dump UTF8 -> UCS2\n");
+       MsgConvertDumpTextToHex((unsigned char*)pTempSrcText, srcLen);
+       MsgConvertDumpTextToHex((unsigned char*)pTempDestText, ucs2Length);
+#endif
+
+       g_iconv_close(cd);
+
+       return ucs2Length;
+}
+
+
+/**
+args:
+unsigned char *pDestText
+int maxLength          : max byte length of destination text
+const unsigned char *pSrcText
+int srcTextLen         : byte length of UCS2 source text
+return :
+byte length of converted UTF8 characters
+-1 : The alpha isn't the gsm 7bit code
+ */
+int MsgConvertUCS2toUTF8(unsigned char *pDestText, int maxLength, const unsigned char *pSrcText,  int srcTextLen)
+{
+       int i , j ;
+       int remainedBuffer = maxLength;
+       int utf8Length;
+
+#ifdef CONVERT_DUMP
+       int srcLen = srcTextLen;
+       const unsigned char * pTempSrcText = pSrcText;
+#endif
+       unsigned char * pTempDestText = pDestText;
+
+       i= j = 0;
+       if(srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0)
+       {
+               fprintf(stderr, "UCS2 to UTF8 Failed as text length is 0\n");
+               return FALSE;
+       }               
+
+       GIConv cd;
+       int err=0;
+
+       cd = g_iconv_open( "UTF8", "UCS-2BE" );
+
+       if (cd > 0)
+       {
+               err = g_iconv(cd, (char**)&pSrcText, (gsize*)&srcTextLen, (char**)&pDestText, (gsize*)&remainedBuffer);
+       }
+
+       utf8Length = maxLength - remainedBuffer;
+       pTempDestText[utf8Length] = 0x00;
+
+#ifdef CONVERT_DUMP
+       fprintf(stderr, "\n########## Dump UCS2 -> UTF8\n");
+       MsgConvertDumpTextToHex((unsigned char*)pTempSrcText, srcLen);
+       MsgConvertDumpTextToHex((unsigned char*)pTempDestText, utf8Length);
+#endif
+
+       g_iconv_close(cd);
+
+       return utf8Length;
+}
+
+
+/**
+  pDestText must be freed when it is not used.
+ */
+int MsgConvertLocaleToUTF8(unsigned char *pDestText, int maxLength, const unsigned char *pSrcText, int srcTextLen)
+{
+       int utf8Length = 0;
+       unsigned char *utf8Text = NULL;
+
+       utf8Text = (unsigned char *)g_locale_to_utf8((char*)pSrcText, srcTextLen, NULL, (gsize*)&utf8Length, NULL);
+       if ( utf8Text == NULL )
+       {
+               fprintf(stderr, "Convert Error : Local to UTF8\n");
+               return -1;
+       }
+
+       if (utf8Length >=  maxLength )
+       {
+               utf8Length = maxLength - 1;
+       }
+       strncpy((char*)pDestText, (char*)utf8Text,  utf8Length);
+       pDestText[utf8Length] = 0x00;
+       //      utf8Length++;           // 091029 is NULL char not included in length? should be confirmed
+
+
+#ifdef CONVERT_DUMP
+       fprintf(stderr, "\n########## Dump Locale -> UTF8\n");
+       MsgConvertDumpTextToHex((unsigned char*)pSrcText, srcTextLen);
+       MsgConvertDumpTextToHex((unsigned char*)pDestText, utf8Length);
+#endif
+
+       free(utf8Text);
+
+       return utf8Length;
+}
+
+
+/**
+return:
+bytelength of UTF8 text
+ */
+int MsgConvertGSM7bitToUTF8(unsigned char *pDestText, int maxLength,  const unsigned char *pSrcText, int srcTextLen)
+{
+       int utf8Length = 0;
+       int ucs2Length = 0;
+       int maxUCS2Length = srcTextLen;         // max # of UCS2 chars, NOT bytes. when all gsm7 chars are only one byte(-there is no extenstion), UCS2Length is maxUCS2 Length. otherwise(ex: gsm7 char starts with 0x1b) UCS2Length must be less than gsm7 legnth
+       unsigned short pUCS2Text[maxUCS2Length];
+       bzero(pUCS2Text, maxUCS2Length);
+
+       fprintf(stderr, "srcTextLen = %d\n", srcTextLen);
+       fprintf(stderr, "max dest Length = %d\n", maxLength);
+
+       ucs2Length = MsgConvertGSM7bitToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(unsigned short), pSrcText,  srcTextLen);
+       utf8Length = MsgConvertUCS2toUTF8(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length);
+
+       return utf8Length;
+}
+
+
+int MsgConvertUTF8ToGSM7bit(unsigned char *pDestText, int maxLength,  const unsigned char *pSrcText, int srcTextLen)
+{
+       int utf8Length = 0;
+       int gsm7bitLength = 0;
+       int ucs2Length = 0;
+
+       BOOL bUnknown = FALSE;
+
+       if ( srcTextLen == -1 )
+       {
+               utf8Length = strlen((char*)pSrcText);
+               srcTextLen = utf8Length;
+       }
+       else
+       {
+               utf8Length = srcTextLen;
+       }
+       int maxUCS2Length = utf8Length;         // max # of UCS2 chars, NOT bytes. when all utf8 chars are only one byte, UCS2Length is maxUCS2 Length. otherwise (ex: 2 bytes of UTF8 is one char) UCS2Length must be  less than utf8Length
+       unsigned short pUCS2Text[maxUCS2Length];
+       bzero(pUCS2Text, maxUCS2Length);
+
+       fprintf(stderr, "srcTextLen = %d\n", srcTextLen);
+       fprintf(stderr, "temp buffer size = %d\n", maxUCS2Length * sizeof(unsigned short));
+       fprintf(stderr, "max dest Length = %d\n", maxLength);
+
+       ucs2Length = MsgConvertUTF8toUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(unsigned short), pSrcText, srcTextLen);
+       gsm7bitLength = MsgConvertUCS2toGSM7bit(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+
+       return gsm7bitLength;
+}
+
+#if CPU_ENDIAN == CPU_ENDIAN_LITTLE
+#define prv_endian_swap_uint16(_x) (_x)
+
+#else
+#define prv_endian_swap_uint16(_x)     (((((uint16_t) (_x)) << 8) & 0xFF00) | \
+               ((((uint16_t) (_x)) >> 8) & 0x00FF))
+#endif
+
+#define BUFF_SIZE 256
+
+BOOL EncodeSmsDeliverTpdu(SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, char *rawdata, int *rawdata_len, BYTE pid)
+{
+       BYTE *packet = (BYTE *)rawdata;
+       UINT8 tp_pid = pid;
+       BYTE tp_dcs; //=17; //class_1(17),class_2(18)
+       BYTE tmp_buff[BUFF_SIZE];;
+       unsigned char timeStamp[20];
+       int index = 0;
+       int i = 0, size = 0;
+
+       unsigned char  scaNumber[ADDRESS_LEN_MAX + 1];
+       int                       scaLength;
+
+       if(tpdu_deliver.dcs.bSMSCinSIM) {
+               //packet[index++] = 0x0;
+               index += SmsReadSMSCfromSIM(packet);
+       }
+       else {          
+               if(SCA.diallingNum[0]=='+')
+               {
+                       memcpy(scaNumber,&SCA.diallingNum[1],SCA.dialnumLen -1);
+                       scaLength = SCA.dialnumLen -1;
+                       scaNumber[scaLength+1] = '\0';
+               }
+               else
+               {
+                       memcpy(scaNumber,SCA.diallingNum,SCA.dialnumLen);
+                       scaLength = SCA.dialnumLen;
+                       scaNumber[scaLength] = '\0';
+               }
+
+               index += SmsUtilEncodeAddrField_sca(packet, scaNumber, scaLength, SCA.ton, SCA.npi);
+       }
+
+       /* TP-MTI, TP-MMS, TP-RP, TP_UDHI, TP-SRI */
+       tpdu_deliver.msgType = SMS_TPDU_DELIVER;
+
+       packet[index] =  tpdu_deliver.msgType;                                                  /* DELIVER: bits 0, 1 */
+       packet[index] |= tpdu_deliver.mms? 0x04 : 0;                                            /* bit 2 */
+       packet[index] |= tpdu_deliver.sri ? 0x20 : 0;                                           /* bit 5 */
+       packet[index] |= tpdu_deliver.udhi? 0x40 : 0;                                           /* bit 6 */
+       packet[index] |= tpdu_deliver.rp ? 0x80 : 0;                                            /* bit 7 */
+
+       index++;
+
+       /* TP-OA */
+       unsigned char  orgNumber[ADDRESS_LEN_MAX + 1];
+       int                       orgLength;
+
+       if(tpdu_deliver.orgAddr.diallingNum[0]=='+')
+       {
+               memcpy(orgNumber,&tpdu_deliver.orgAddr.diallingNum[1],tpdu_deliver.orgAddr.dialnumLen -1);
+               orgLength = tpdu_deliver.orgAddr.dialnumLen -1;
+               orgNumber[orgLength+1] = '\0';
+       }
+       else
+       {
+               memcpy(orgNumber,tpdu_deliver.orgAddr.diallingNum,tpdu_deliver.orgAddr.dialnumLen);
+               orgLength = tpdu_deliver.orgAddr.dialnumLen;
+               orgNumber[orgLength] = '\0';
+       }
+
+       fprintf(stderr, "\nafter: orgNumber : %s , %x\n",orgNumber, orgLength);
+
+       index +=  SmsUtilEncodeAddrField_dst(packet+index, orgNumber, orgLength, tpdu_deliver.orgAddr.ton, tpdu_deliver.orgAddr.npi);
+
+       /*TP-PID*/
+       packet[index++] = tp_pid;
+
+       SmsUtilEncodeDCS(&tp_dcs, &tpdu_deliver.dcs);
+
+       //packet[index++] = dcs;
+       packet[index++] = tp_dcs;
+
+       /*TP-SCTS*/
+       SmsUtilEncodeTimeStamp(&tpdu_deliver.scts, timeStamp);
+       memcpy(&packet[index], timeStamp, 7);
+       index += 7;
+
+       /*********TP-UDL & TP-UD **********/
+       int pos;
+       switch(tpdu_deliver.dcs.alphabetType) {
+               case TAPI_NETTEXT_ALPHABET_DEFAULT:
+                       size = strlen((char*)tpdu_deliver.userData);
+                       packet[index++] = size + 1;
+                       memset(tmp_buff, '\0', BUFF_SIZE);
+                       pos = MsgConvertUTF8ToGSM7bit ( tmp_buff, BUFF_SIZE, (char*)tpdu_deliver.userData, size);
+                       memcpy(tpdu_deliver.userData, tmp_buff, pos);
+                       pos =SmsUtilPackGSMCode( packet + index, (char *)tpdu_deliver.userData, pos);
+                       index += pos;
+                       break;
+               case TAPI_NETTEXT_ALPHABET_8BIT:
+                       packet[index++] = strlen((char *)tpdu_deliver.userData);
+                       pos =SmsUtilpackGSM8Code( packet + index, (char *)tpdu_deliver.userData, strlen((char *)tpdu_deliver.userData));
+                       index += pos;
+                       break;
+               case TAPI_NETTEXT_ALPHABET_UCS2:
+                       size = strlen((char*)tpdu_deliver.userData) * 2;
+                       packet[index++] = size; //one unicode has 2 bytes
+                       memset(tmp_buff, '\0', BUFF_SIZE);
+                       pos = MsgConvertUTF8toUCS2 ( tmp_buff, BUFF_SIZE, (char*)tpdu_deliver.userData, size );
+                       memcpy(tpdu_deliver.userData, tmp_buff, pos);
+                       memcpy(packet + index, tmp_buff, pos);
+                       index += pos;
+                       break;
+               default:
+                       fprintf(stderr, "Unknown alphabetType!\n");
+                       exit(1);
+       }
+
+       *rawdata_len = index;
+
+       for(i=0; i< index ; i++ )
+       {
+               fprintf(stderr, "[%02x]", packet[i]);
+               if( i%10 == 9)
+                       fprintf(stderr, "\n");
+       }
+       fprintf(stderr, "\n");
+
+       return TRUE;
+
+}
+
+int DecodeSmsSubmitTpdu(TPDU_SMS_SUBMIT *tpdu_submit, int pdu_len , char * pPDU, int MO_sms)
+{
+       BYTE              scaAddr_len =0;
+       int                  destAddr_len = 0;
+       BYTE                 diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       BYTE              scaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX+1]; //service center address
+       BYTE                 destAddr[TAPI_NETTEXT_ADDRESS_LEN_MAX+1]; //destination number
+       int                  sca_ton, sca_npi, dest_ton,dest_npi;
+       int                  position;
+       BYTE    inData[TAPI_NETTEXT_SMDATA_SIZE_MAX+1];
+       BYTE    tmp_buff[BUFF_SIZE];
+       int size, udhl = 0;
+       int i = 0, fillbits = 0;
+       position=0;
+
+       /* SCA_ADDR */
+       memset(diallingNum, 0, sizeof(diallingNum));
+
+       SmsUtilDecodeAddrField_sca((char *)diallingNum, (unsigned char *)&pPDU[position],&sca_ton, &sca_npi);
+
+       position+=2;  //include Address-Length, Type of Address
+
+       scaAddr_len = strlen( (char *)diallingNum );
+
+       if ( scaAddr_len % 2 )
+               position += scaAddr_len / 2 + 1;
+       else
+               position += scaAddr_len / 2;
+
+
+       if ( sca_ton == SIM_TON_INTERNATIONAL )
+       {
+               scaAddr[0] = '+';
+               memcpy( &scaAddr[1], diallingNum, scaAddr_len );
+               scaAddr[scaAddr_len+1] = '\0';
+       }
+       else
+       {
+               memcpy( scaAddr, diallingNum, scaAddr_len );
+               scaAddr[scaAddr_len] = '\0';
+       }
+
+       /* TP-MTI, TP-RD, TP-VPF,  TP-RP, TP_UDHI, TP-SRR */
+
+       tpdu_submit->msgType = SMS_TPDU_SUBMIT; // bit 0,1(Message Type Indicator )
+       tpdu_submit->rd = ( pPDU[position] & 0x04 ) ? TRUE : FALSE;// bit 2 (Message Type Indicator)
+       tpdu_submit->vpf =( pPDU[position] & 0x18) >> 3; //  bits 3, 4 ( validity period format)
+       tpdu_submit->srr=( pPDU[position] & 0x20 ) ? TRUE : FALSE;      // bit 5 (Status Report Request)
+       tpdu_submit->udhi=( pPDU[position] & 0x40 ) ? TRUE : FALSE;     // bit 6 (User Data Header Indicator)
+       tpdu_submit->rp = ( pPDU[position] & 0x80 ) ? TRUE : FALSE;     // bit 7 (Reply Path)
+
+       position++ ;
+
+       if( MO_sms == 1 ){
+               /* Only for Mobile oriented sms */
+               /* TP-MR */
+               tpdu_submit->mr = pPDU[position];
+               position++ ;
+       }
+
+       /* TP-DA */
+       memset(diallingNum, 0, sizeof(diallingNum));
+       SmsUtilDecodeAddrField_dst((char *)diallingNum, (unsigned char *)&pPDU[position],&dest_ton, &dest_npi);
+
+       position+=2;
+
+       destAddr_len = strlen( (char*) diallingNum );
+       if ( destAddr_len % 2 )
+               position += destAddr_len / 2 + 1;
+       else
+               position += destAddr_len / 2;
+
+       if ( dest_ton == SIM_TON_INTERNATIONAL )
+       {
+               destAddr[0] = '+';
+               memcpy( &destAddr[1], diallingNum, destAddr_len );
+               destAddr[destAddr_len+1] = '\0';
+               tpdu_submit->desAddr.dialnumLen= destAddr_len + 1;
+               memcpy(tpdu_submit->desAddr.diallingNum, destAddr , destAddr_len + 1);
+       }
+       else
+       {
+               memcpy( destAddr, diallingNum, destAddr_len );
+               destAddr[destAddr_len] = '\0';
+               tpdu_submit->desAddr.dialnumLen= destAddr_len;
+               memcpy(tpdu_submit->desAddr.diallingNum, destAddr , destAddr_len);
+       }
+
+       tpdu_submit->desAddr.npi = dest_npi;
+       tpdu_submit->desAddr.ton = dest_ton;
+
+       /* TP-PID */
+       tpdu_submit->pId = pPDU[position];
+       position++ ;
+
+       /* TP DCS */
+       SmsUtilDecodeDCS( &tpdu_submit->dcs, pPDU[position] );
+       position ++;
+
+       /* TP VP */
+       //tpdu_submit->vp.vpType = TAPI_NETTEXT_VP_RELATIVE;  //temp
+
+       switch (tpdu_submit->vpf)
+       {
+               case TAPI_NETTEXT_VP_RELATIVE:
+                       {
+                               tpdu_submit->vp.vpValue = pPDU[position];
+                               tpdu_submit->vp.vpRelativeType = TAPI_NETTEXT_VP_REL_1D;
+                               position++;
+                               break;
+                       }
+               case TAPI_NETTEXT_VP_ABSOLUTE:
+               case TAPI_NETTEXT_VP_ENHANCED:
+                       {
+                               position += 7;
+                               break;
+                       }
+               default:
+                       break;
+       }
+
+       /* TP UDL */
+       tpdu_submit->udl = pPDU[position] & 0x00FF;
+
+       if ( tpdu_submit->udl > TAPI_NETTEXT_SMDATA_SIZE_MAX )
+               tpdu_submit->udl = TAPI_NETTEXT_SMDATA_SIZE_MAX;
+
+       position++;
+
+       /* TP UD */
+       tpdu_submit->userData = malloc( sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+       memset(tpdu_submit->userData, 0, sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+       memset( inData, 0x00, TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 );
+       memcpy( (void*) inData, (void*) &pPDU[position], tpdu_submit->udl );
+       fprintf(stderr, "inData [%s] \n", inData);
+
+       if(tpdu_submit->udhi)
+       {
+                udhl = pPDU[position] + 1;
+               fillbits = 7 - ((udhl * 8) % 7);
+       }
+
+       switch(tpdu_submit->dcs.alphabetType) {
+               case TAPI_NETTEXT_ALPHABET_DEFAULT:             
+                       //size = SmsUtilUnpackGSMCode((char *)tpdu_submit->userData, inData, (UINT8) tpdu_submit->udl);
+                       {
+                                int i;
+                                BYTE    tmpData[TAPI_NETTEXT_SMDATA_SIZE_MAX+1];
+                                memset( tmpData, 0x00, TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 );
+                                memcpy( (void*) tmpData, (void*)(inData + udhl), tpdu_submit->udl - udhl);
+                                if(tpdu_submit->udhi) {
+                                        for(i = 0; i < (tpdu_submit->udl - udhl); i++)
+                                        {
+                                                tmpData[i] = (tmpData[i] >> fillbits) | (tmpData[i+1] << (8-fillbits));
+                                        }
+                                }
+                                size = SmsUtilUnpackGSMCode((char *)(tpdu_submit->userData + udhl), tmpData, (UINT8) tpdu_submit->udl - udhl);
+                        }
+                       
+                       memset(tmp_buff, '\0', BUFF_SIZE);
+                       //MsgConvertGSM7bitToUTF8( tmp_buff, BUFF_SIZE, (char *)tpdu_submit->userData, size );
+                       MsgConvertGSM7bitToUTF8( tmp_buff, BUFF_SIZE, (char *)(tpdu_submit->userData + udhl), size );
+                       memcpy(tpdu_submit->userData, inData, udhl);
+                       memcpy(tpdu_submit->userData + udhl, tmp_buff, size);
+                       break;  
+               case TAPI_NETTEXT_ALPHABET_8BIT:
+                       SmsUtilUnpackGSM8Code((char *)tpdu_submit->userData, inData, (UINT8) tpdu_submit->udl);
+                       break;
+               case TAPI_NETTEXT_ALPHABET_UCS2:        
+                       //size = SmsUtilUnpackUCS2Code((char *)tpdu_submit->userData, inData, (UINT8) tpdu_submit->udl);
+                       memcpy((void*)tpdu_submit->userData, (void*) inData, tpdu_submit->udl );
+                       memset(tmp_buff, '\0', BUFF_SIZE);
+                       MsgConvertUCS2toUTF8( tmp_buff, BUFF_SIZE, (char *)tpdu_submit->userData, (UINT8) tpdu_submit->udl );
+                       //memcpy(tpdu_submit->userData, tmp_buff, size);
+                       break;
+               default:
+                       fprintf(stderr, "Unknown alphabetType!\n");
+       }
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Msg Type: TPDU_SUBMIT\n");
+
+       if(tpdu_submit->rd)
+               fprintf(stderr, "RD: Reject Duplicate\n");
+       else if(!tpdu_submit->rd)
+               fprintf(stderr, "RD: Accept Duplicate\n");
+
+       if(tpdu_submit->srr)
+               fprintf(stderr, "SRR: A status report is requested\n");
+       else if(!tpdu_submit->srr)
+               fprintf(stderr, "SRR: A status report is not  requested\n");
+
+       if(tpdu_submit->udhi)
+               fprintf(stderr, "UDHI: Contains a Header in addition to the short message.\n");
+       else if(!tpdu_submit->udhi)
+               fprintf(stderr, "UDHI: Only Short Message\n");
+
+       if(tpdu_submit->rp)
+               fprintf(stderr, "RP: Set Reply Path\n");
+       else if(!tpdu_submit->rp)
+               fprintf(stderr, "RP: Not set Reply Path\n");
+
+       fprintf(stderr, "SCA Addr : %s\n",scaAddr);
+       fprintf(stderr, "To : %s, %s\n" , destAddr, tpdu_submit->desAddr.diallingNum);
+       fprintf(stderr, "Message : %s \n" , tpdu_submit->userData);
+       fprintf(stderr, "*************************************\n");
+
+       //return TRUE;
+       return position;
+}
+
+//BOOL EncodeSmsSubmitReportTpdu()
+BOOL EncodeSmsSubmitReportTpdu(unsigned char *packet, int *rawdata_len)
+{
+       TPDU_SMS_SUBMIT_REPORT submit_report;
+       BYTE tp_dcs;
+       BYTE mask=0x69;
+       int index=0;
+       int i ;
+       TmDateTime tmTimeStamp;
+       unsigned char timeStamp[20];
+       time_t c_time;
+       struct tm *tmTime;
+
+       /* TP-MTI , TP-UDHI */
+       submit_report.msgType = SMS_TPDU_SUBMIT_REPORT;
+       submit_report.udhi = FALSE;
+
+       packet[index] = submit_report.msgType;                                          //DELIVER REPORT
+       packet[index] |= submit_report.udhi? 0x40 : 0;  //bit 6
+
+       index ++;
+
+       /* TP -PI */
+       submit_report.paraInd = mask;
+       packet[index] = submit_report.paraInd ;
+
+       /*TP-SCTS*/
+       c_time = time((time_t *)NULL);
+       tmTime = localtime(&c_time);
+       index++;
+       tmTimeStamp.year = tmTime->tm_year+1900;
+       tmTimeStamp.month = tmTime->tm_mon+1;
+       tmTimeStamp.day = tmTime->tm_mday;
+       tmTimeStamp.hour = tmTime->tm_hour;
+       tmTimeStamp.minute = tmTime->tm_min;
+       tmTimeStamp.second = tmTime->tm_sec;
+       SmsUtilEncodeTimeStamp(&tmTimeStamp, timeStamp);
+       memcpy(&packet[index], timeStamp, 7);
+       index += 7;
+
+       if ( ( mask != 0xFF ) && ( mask != 0 ) )
+       {
+               index++;
+               /* TP-PID */
+               if ( mask & 0x01)
+               {
+                       submit_report.pId = 0x65 ;
+                       packet[index++] = submit_report.pId;
+               }
+
+               /* TP-DCS */
+               if ( mask & 0x02)
+               {
+                       submit_report.dcs.bCompressed = FALSE;
+                       submit_report.dcs.bMsgClassSet = TRUE;
+                       submit_report.dcs.codingGroupType =TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS;
+                       submit_report.dcs.alphabetType = TAPI_NETTEXT_ALPHABET_DEFAULT;
+                       submit_report.dcs.classType = TAPI_NETTEXT_CLASS_2;
+
+                       SmsUtilEncodeDCS(&tp_dcs, &submit_report.dcs);
+                       packet[index++] = tp_dcs;
+               }
+               /* TP-UDL */
+               if ( mask & 0x04)
+               {
+                       submit_report.udl =0x00;
+                       packet[index++] = submit_report.udl;
+
+                       /* TP-UD */
+
+                       if (submit_report.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+                       {
+                               //SmsUtilPackGSMCode( packet + index, msg, msg_len);
+                       }
+               }
+       }
+
+       *rawdata_len = index;
+
+       fprintf(stderr, "\nEncodeSmsSubmitReportTpdu");
+       fprintf(stderr, "\nSend packet to phonseSever[%d] -----\n", index);
+
+       for(i=0; i< index ; i++ )
+       {
+               fprintf(stderr, "[%02x]", packet[i]);
+               if( i%10 == 9)
+                       fprintf(stderr, "\n");
+       }
+       fprintf(stderr, "\n");
+
+       return TRUE;
+}
+BOOL EncodeCB_GSM(CELLBROADCASTING cb_msg, char *rawdata, int *rawdata_len)
+{
+       BYTE *packet = (BYTE *)rawdata;
+       BYTE tmp_buff[BUFF_SIZE];
+
+       int             index = 0;
+       int             i = 0;
+       int             pos, size;
+
+       fprintf(stderr, "\n\nEncodeCB_GSM.......\n");
+
+       if (cb_msg.accessNetwork== CB_GSM)
+       {
+               // Serial Number
+
+               BYTE serialNumber[2];
+               serialNumber[0] = (cb_msg.geographicalScope <<6)|((cb_msg.messageCode>>4) & 0x3f);
+               serialNumber[1] = ((cb_msg.messageCode & 0x0f)<<4)|(cb_msg.updateNumber & 0x0f);
+
+               fprintf(stderr, "Serial Number : [%02x][%02x]\n", serialNumber[0], serialNumber[1]);
+
+#if CPU_ENDIAN == CPU_ENDIAN_LITTLE
+               packet[index++] = serialNumber[0];
+               packet[index++] = serialNumber[1];
+#else
+               packet[index++] = serialNumber[1];
+               packet[index++] = serialNumber[0];
+#endif
+
+               fprintf(stderr, " packet[0] = %02x, packet[1] = %02x\n", packet[0], packet[1]);
+
+               // Message Id
+               BYTE messageID[2];
+
+               messageID[0] = (cb_msg.messageId >> 8) & 0xff;
+               messageID[1] = cb_msg.messageId & 0xff;
+               fprintf(stderr, "messageId = [%02x],[%02x]\n", messageID[0],messageID[1]);
+
+#if CPU_ENDIAN == CPU_ENDIAN_LITTLE
+               packet[index++] = messageID[0];
+               packet[index++] = messageID[1];
+#else
+               packet[index++] = messageID[1];
+               packet[index++] = messageID[0];
+#endif
+
+               fprintf(stderr, " packet[2] = %02x, packet[3] = %02x\n", packet[2], packet[3]);
+
+               // DCS
+               packet[index++] = cb_msg.language;
+
+               // Page Parameter
+               packet[index++] =  cb_msg.page;
+
+
+       }
+
+       else if(cb_msg.accessNetwork== CB_UMTS)
+       {
+
+               // Message Type
+               packet[index++] = cb_msg.messageType;
+
+               // Message Id
+               BYTE messageID[2];
+
+               messageID[0] = (cb_msg.messageId >> 8) & 0xff;
+               messageID[1] = cb_msg.messageId & 0xff;
+
+               fprintf(stderr, "messageId = [%02x],[%02x]\n", messageID[0],messageID[1]);
+
+#if CPU_ENDIAN == CPU_ENDIAN_LITTLE
+               packet[index++] = messageID[0];
+               packet[index++] = messageID[1];
+#else
+               packet[index++] = messageID[1];
+               packet[index++] = messageID[0];
+#endif
+
+               fprintf(stderr, " packet[1] = %02x, packet[2] = %02x\n", packet[1], packet[2]);
+
+
+               // Serial Number
+
+               BYTE serialNumber[2];
+               serialNumber[0] = (cb_msg.geographicalScope <<6)|((cb_msg.messageCode>>4) & 0x3f);
+               serialNumber[1] = ((cb_msg.messageCode & 0x0f)<<4)|(cb_msg.updateNumber & 0x0f);
+
+               fprintf(stderr, "Serial Number : [%02x][%02x]\n", serialNumber[0], serialNumber[1]);
+
+#if CPU_ENDIAN == CPU_ENDIAN_LITTLE
+               packet[index++] = serialNumber[0];
+               packet[index++] = serialNumber[1];
+#else
+               packet[index++] = serialNumber[1];
+               packet[index++] = serialNumber[0];
+#endif
+
+               fprintf(stderr, " packet[3] = %02x, packet[4] = %02x\n", packet[3], packet[4]);
+
+               // DCS
+               packet[index++] = cb_msg.language;
+
+       }
+
+       memset( tmp_buff, '\0', BUFF_SIZE);
+       size = strlen((char*)cb_msg.message);
+       MsgConvertUTF8ToGSM7bit ( tmp_buff, BUFF_SIZE, (char *)cb_msg.message, size );
+       memcpy( cb_msg.message, tmp_buff, size );
+       pos =SmsUtilPackGSMCode( packet + index, (char *)cb_msg.message, strlen((char *)cb_msg.message));
+       index += pos;
+
+       *rawdata_len = index;
+
+       for(i=0; i< index ; i++ )
+       {
+               fprintf(stderr, "[%02x]", packet[i]);
+               if( i%10 == 9)
+                       fprintf(stderr, "\n");
+       }
+       fprintf(stderr, "\n");
+
+       return TRUE;
+}
+
+#if 0
+BOOL EncodeSmsSubmitTpdu(char* diallingNum, int dialNumLen, char* msg, int msg_len)
+{
+
+       TPDU_SMS_SUBMIT tpdu_submit;
+
+       BYTE  packet[TAPI_NETTEXT_MSG_SIZE_MAX];
+
+       BYTE  SCA[TAPI_NETTEXT_SCADDRESS_LEN_MAX]; //send SMS ÇÒ¶§ »ç¿ëÇϴ ½ÇÁ¦ SCA°ª
+       //BYTE  ScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];  // in
+       SmsAddressInfo  szSCAddr;
+       BYTE  decodeScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+
+       UINT8 tp_mr = 0x01;
+       UINT8 tp_pid = 65; //reaplace type (65)
+       UINT8 tp_dcs; //=17; //class_1(17),class_2(18)
+       UINT8 tp_vp;
+
+       int index = 0;
+       int i;
+
+       unsigned char             sca_len =0;
+       int                                 sca_ton, sca_npi;
+
+       /*
+          TapiNetTextDataPackage *pDataPackage= malloc(sizeof(TapiNetTextDataPackage));
+
+          memset(pDataPackage, 0, sizeof(TapiNetTextDataPackage));
+        */
+
+       memset(packet, 0, TAPI_NETTEXT_MSG_SIZE_MAX);
+
+       /************SCA ADDRESS GET START**************/
+       //TO DO
+       //SCA°ª Ã¤¿ì±â
+       //TapiGetServiceCenterAddress(&szSCAddr);
+       strcpy( SCA, "820199111" );
+       /*
+          SmsUtilDecodeAddrField(decodeScaAddr, &szSCAddr.diallingNum[0],&szSCAddr.ton, &szSCAddr.npi);
+          sca_len = strlen( decodeScaAddr );
+
+          memcpy( SCA, decodeScaAddr, sca_len);
+          SCA[sca_len] = '\0';
+
+          fprintf(stderr, "Decode SCA Address =========\n");
+          fprintf(stderr, "SCA Number :%s, SCA Length :%d \n",SCA , sca_len);
+          fprintf(stderr, "========================\n");
+          fprintf(stderr, "decodeScaAddr :%s\n",decodeScaAddr);
+        */
+
+       /************SCA ADDRESS GET END**************/
+
+       /*SCA*/
+
+       //TODO : SCA
+       index +=SmsUtilEncodeAddrField(packet,SCA, strlen(SCA)  ,0x01,0x01);
+
+       //fprintf(stderr, "SCA ADDR Encoded =========\n");
+
+       /* TP-MTI, TP-RD, TP-VPF, TP-SRR, TP_UDHI, TP-RP */
+       tpdu_submit.msgType = SMS_TPDU_SUBMIT;
+       tpdu_submit.rd   =TRUE; //FALSE :accept duplicate msg , true: reject duplicate msg
+       tpdu_submit.vpf = TAPI_NETTEXT_VP_RELATIVE;
+       tpdu_submit.srr  = FALSE;   //FALSE :A status report is not requested , true: A status report is requested
+       tpdu_submit.udhi = FALSE ; //FALSE: contains only the short message , true :a Header in addition to the short message
+       tpdu_submit.rp = TRUE  ; //FALSE :TP Reply Path parameter is not set in this SMS SUBMIT, true : TP Reply Path parameter is set in this SMS SUBMIT
+
+       packet[index] =  tpdu_submit.msgType;                                                   /* SUBMIT: bits 0, 1 */
+       packet[index] |= tpdu_submit.rd? 0x04 : 0;                                              /* bit 2 */
+       packet[index] |= tpdu_submit.vpf  << 3; /* bits 3, 4 */
+       packet[index] |= tpdu_submit.srr ? 0x20 : 0;                                            /* bit 5 */
+       packet[index] |= tpdu_submit.udhi? 0x40 : 0;                                            /* bit 6 */
+       packet[index] |= tpdu_submit.rp ? 0x80 : 0;                                             /* bit 7 */
+
+       index++;
+
+       /* TP-MR */
+       packet[index++] = tp_mr;
+
+       /* TP-DA */
+       index +=  SmsUtilEncodeAddrField( packet+index, diallingNum, dialNumLen, 0x01, 0x01);
+
+       //fprintf(stderr, "DESTINATTION  ADDR Encoded =========\n");
+
+       /*TP-PID*/
+       packet[index++] = tp_pid;
+
+       /* TP_DCS (Data Coding Scheme) */
+
+       tpdu_submit.dcs.bCompressed = FALSE;
+       tpdu_submit.dcs.bMsgClassSet = TRUE;
+       tpdu_submit.dcs.codingGroupType =TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS;
+       tpdu_submit.dcs.alphabetType = TAPI_NETTEXT_ALPHABET_DEFAULT;
+       tpdu_submit.dcs.classType = TAPI_NETTEXT_CLASS_2;
+
+       SmsUtilEncodeDCS(&tp_dcs, &tpdu_submit.dcs);
+
+       packet[index++] = tp_dcs;
+
+       //fprintf(stderr, "DCS Encoded:tp_dcs =%d =========\n",tp_dcs);
+
+       /*TP-VP*/
+
+       tpdu_submit.vp.vpRelativeType = TAPI_NETTEXT_VP_REL_6H ;
+       tpdu_submit.vp.vpType = TAPI_NETTEXT_VP_RELATIVE;
+       tpdu_submit.vp.vpValue =0xff ;
+
+       SmsUtilEncodeValidity(&tp_vp,&tpdu_submit.vp);
+
+       //tp_vp =65;
+       packet[index++] = tp_vp;
+       //fprintf(stderr, "Validity Encoded :tp_vp =%d =========\n",tp_vp);
+
+       /* UDL */
+       packet[index++] = msg_len;
+
+       /*********TP-UD **********/
+
+       if (tpdu_submit.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+       {
+               int pos;
+               memset(tmp_buff, '\0', BUFF_SIZE);
+               MsgConvertUTF8ToGSM7bit( tmp_buff, BUFF_SIZE, msg, msg_len);
+               memcpy(msg, tmp_buff, msg_len);
+               pos =SmsUtilPackGSMCode( packet + index, msg, msg_len);
+               index += pos;
+       }
+
+
+       //fprintf(stderr, "\nSend packet to phonseSever[%d] -----\n", index);
+
+       for(i=0; i< index ; i++ )
+       {
+               fprintf(stderr, "[%02x]", packet[i]);
+               if( i%10 == 9)
+                       fprintf(stderr, "\n");
+       }
+       fprintf(stderr, "\n");
+
+#if 0
+       memcpy( pDataPackage->szData, packet, index);
+       pDataPackage->msgLength = index;
+
+       /* SEND SMS */
+       TapiSendNetText( pDataPackage, NULL);
+
+       free(pDataPackage);
+#endif /* 0 */
+
+       return TRUE;
+
+}
+
+int   DecodeSmsDeliverTpdu(int tpdu_len , char * pTPDU)
+{
+       TPDU_SMS_DELIVER   tpdu_deliver;
+       TmDateTime                 SCTimeStamp;;
+       int                 orgAddr_len = 0;
+       BYTE                diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       BYTE                orgAddr[TAPI_NETTEXT_ADDRESS_LEN_MAX]; //originating number
+       int                 sca_ton, sca_npi, org_ton,org_npi;
+       int                 position;
+       int                 dcs_pos =0;
+       int i;
+
+       position=0;
+
+       /* TP-MTI, TP-MMS, TP-SRI, TP_UDHI, TP-RP */
+       tpdu_deliver.msgType = SMS_TPDU_DELIVER;
+       tpdu_deliver.mms = ( pTPDU[position] & 0x04 ) ? TRUE : FALSE;// bit 2 (Message Type Indicator)
+       tpdu_deliver.sri =( pTPDU[position] & 0x20 ) ? TRUE : FALSE;    // bit 5 (Status Report Indication)
+       tpdu_deliver.udhi=( pTPDU[position] & 0x40 ) ? TRUE : FALSE;    // bit 6 (User Data Header Indicator)
+       tpdu_deliver.rp = ( pTPDU[position] & 0x80 ) ? TRUE : FALSE;    // bit 7 (Reply Path)
+
+       position++ ;
+
+       /* TP-OA */
+
+       memset(diallingNum, 0, sizeof(diallingNum));
+
+       SmsUtilDecodeAddrField(diallingNum, &pTPDU[position],&org_ton, &org_npi);
+
+       position+=2;
+
+       orgAddr_len = strlen( (char*) diallingNum );
+       if ( orgAddr_len % 2 )
+               position += orgAddr_len / 2 + 1;
+       else
+               position += orgAddr_len / 2;
+
+
+       if ( org_ton == SIM_TON_INTERNATIONAL )
+       {
+               orgAddr[0] = '+';
+               memcpy( &orgAddr[1], diallingNum, orgAddr_len );
+               orgAddr[orgAddr_len+1] = '\0';
+       }
+       else
+       {
+               memcpy( orgAddr, diallingNum, orgAddr_len );
+               orgAddr[orgAddr_len] = '\0';
+       }
+
+       /* TP-PID */
+       tpdu_deliver.pId= pTPDU[position];
+
+       position ++;
+
+       /* TP-DCS */
+       SmsUtilDecodeDCS( &tpdu_deliver.dcs, pTPDU[position] );
+       dcs_pos = position;
+       position++;
+
+       /* TP-SCTS */
+       SmsUtilDecodeTimeStamp( &pTPDU[position], & SCTimeStamp );
+
+       position+=7;
+
+       /* TP-UDL */
+       tpdu_deliver.udl = pTPDU[position];
+
+       if ( tpdu_deliver.udl > TAPI_NETTEXT_SMDATA_SIZE_MAX )
+       {
+               tpdu_deliver.udl = TAPI_NETTEXT_SMDATA_SIZE_MAX;
+               pTPDU[position] = tpdu_deliver.udl;
+       }
+
+       position++;
+
+       /* TP-UD */
+       tpdu_deliver.userData = malloc( sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+       memset(tpdu_deliver.userData, 0, sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+       if (tpdu_deliver.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+       {
+               BYTE    inData[TAPI_NETTEXT_SMDATA_SIZE_MAX+1];
+
+               memset( inData, 0x00, TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 );
+
+               memcpy( (void*) inData, (void*) &pTPDU[position], tpdu_deliver.udl );
+
+               SmsUtilUnpackGSMCode(tpdu_deliver.userData, inData, (UINT8) tpdu_deliver.udl);
+       }
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Msg Type: TPDU_DELIVER\n");
+
+       if(tpdu_deliver.rp )
+               fprintf(stderr, "RP: Set Reply Path\n");
+       else if(!tpdu_deliver.rp )
+               fprintf(stderr, "RP: Not set Reply Path\n");
+
+       if(tpdu_deliver.sri)
+               fprintf(stderr, "SRI: A status report shall be returned to the SME\n");
+       else if(!tpdu_deliver.sri)
+               fprintf(stderr, "SRI: A status report shall be not returned to the SME\n");
+
+       if(tpdu_deliver.mms)
+               fprintf(stderr, "MMS: No more messages are waiting for the MS in this SC\n");
+       else if(!tpdu_deliver.mms)
+               fprintf(stderr, "MMS: More messages are waiting for the MS in this SC\n");
+
+       if(tpdu_deliver.udhi)
+               fprintf(stderr, "UDHI: Contains a Header in addition to the short message.\n");
+       else    if(!tpdu_deliver.udhi)
+               fprintf(stderr, "UDHI: Only short message.\n");
+
+       fprintf(stderr, "From : %s\n" ,orgAddr );
+       fprintf(stderr, "Time : %d-%d-%d  , %d:%d:%d\n",
+                       SCTimeStamp.year, SCTimeStamp.month, SCTimeStamp.day, SCTimeStamp.hour, SCTimeStamp.minute ,SCTimeStamp.second);
+       fprintf(stderr, "Message : %s \n" , tpdu_deliver.userData);
+       fprintf(stderr, "*************************************\n");
+
+
+       return dcs_pos;
+}
+
+BOOL EncodeSmsDeliverReportTpdu()
+{
+       TPDU_SMS_DELIVER_REPORT deliver_report;
+       unsigned char packet[500];
+       //TapiNetTextDataPackage* pDataPackage;
+       BYTE tp_dcs;
+       BYTE mask=0x69;
+       int index=0;
+       int i ;
+
+       /*
+          pDataPackage = malloc(sizeof(TapiNetTextDataPackage));
+          memset(pDataPackage, 0, sizeof(TapiNetTextDataPackage));
+        */
+
+       memset(packet, 0, 500);
+
+       /* TP-MTI , TP-UDHI */
+       deliver_report.msgType = SMS_TPDU_DELIVER_REPORT;
+       deliver_report.udhi = FALSE;
+
+       packet[index] = deliver_report.msgType;                                         //DELIVER REPORT
+       packet[index] |= deliver_report.udhi? 0x40 : 0; //bit 6
+
+       index ++;
+
+       /* TP-FCS */
+       //if(result==FAIL)
+       //{
+
+
+       //}
+
+
+       /* TP -PI */
+       deliver_report.paraInd = mask;
+       packet[index] = deliver_report.paraInd ;
+
+       if ( ( mask != 0xFF ) && ( mask != 0 ) )
+       {
+               index++;
+               /* TP-PID */
+               if ( mask & 0x01)
+               {
+                       deliver_report.pId = 0x65 ;
+                       packet[index++] = deliver_report.pId;
+               }
+
+               /* TP-DCS */
+               if ( mask & 0x02)
+               {
+                       deliver_report.dcs.bCompressed = FALSE;
+                       deliver_report.dcs.bMsgClassSet = TRUE;
+                       deliver_report.dcs.codingGroupType =TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS;
+                       deliver_report.dcs.alphabetType = TAPI_NETTEXT_ALPHABET_DEFAULT;
+                       deliver_report.dcs.classType = TAPI_NETTEXT_CLASS_2;
+
+                       SmsUtilEncodeDCS(&tp_dcs, &deliver_report.dcs);
+                       packet[index++] = tp_dcs;
+               }
+               /* TP-UDL */
+               if ( mask & 0x04)
+               {
+                       deliver_report.udl =0x00;
+                       packet[index++] = deliver_report.udl;
+
+                       /* TP-UD */
+
+                       if (deliver_report.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+                       {
+                               //SmsUtilPackGSMCode( packet + index, msg, msg_len);
+                       }
+               }
+       }
+       fprintf(stderr, "\nEncodeSmsDeliverReportTpdu");
+       fprintf(stderr, "\nSend packet to phonseSever[%d] -----\n", index);
+
+       for(i=0; i< index ; i++ )
+       {
+               fprintf(stderr, "[%02x]", packet[i]);
+               if( i%10 == 9)
+                       fprintf(stderr, "\n");
+       }
+       fprintf(stderr, "\n");
+
+       /*
+          memcpy( pDataPackage->szData, packet, index);
+          pDataPackage->msgLength = index;
+
+          TapiSetDeliverReport(pDataPackage);
+        */
+
+       return TRUE;
+}
+
+BOOL DecodeCellBroadcastMsg(int length,char * pPDU)
+{
+       UINT8           msgType;
+       int                     msgLength;
+       int                     sn = 0; //serial number
+       int                     msgID; //message identifier
+       TapiNetTextCodingScheme  dcs;
+
+       UINT8   page[2];
+       int                     contents_length;
+       UINT8    contents[TAPI_NETTEXT_CB_SIZE_MAX];
+
+       UINT8   gs;
+       UINT8   msgCode;
+       UINT8   updateNumber;
+       UINT8   fillBits = 0;
+
+       sn = (pPDU[0] <<8 ) |pPDU[1] ;
+
+       gs = (pPDU[0] & 0xC0) >> 6;  //bit 7, bit 6
+
+       msgCode =((pPDU[0] & 0x3F)<<4) |pPDU[1] & 0xF0 ;
+
+       updateNumber = pPDU[1] & 0x0F;  //bit3, bit2, bit1, bit0
+
+       msgID = pPDU[2] << 4 |pPDU[3];
+
+       SmsUtilDecodeDCS( &dcs, pPDU[4] );
+
+       page[0] = pPDU[5] & 0x0F; //total page
+       page[1] = (pPDU[5] & 0xF0)>>4 ; //current page
+
+
+       msgLength = length -2;
+
+       contents_length = msgLength -6;
+
+       if (dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+       {
+               BYTE    inData[TAPI_NETTEXT_CB_SIZE_MAX+1];
+
+               memset( inData, 0x00, TAPI_NETTEXT_CB_SIZE_MAX + 1 );
+
+               memcpy( (void*) inData, (void*) &pPDU[6], contents_length);
+               SmsUtilUnpackGSMCode(contents,  &pPDU[6], msgLength );
+       }
+       else
+       {
+               memcpy( contents, &pPDU[6], msgLength);
+               contents[msgLength] = NULL;
+       }
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "serical number : 0x%04x \n" , sn);
+       fprintf(stderr, "Geographical Scope: %x\n" , gs);
+       fprintf(stderr, "message code : %x\n", msgCode);
+       fprintf(stderr, "update Number : %x\n",updateNumber);
+       fprintf(stderr, "message identifier :  %x\n" , msgID);
+       fprintf(stderr, "data coding scheme :  %x\n" , dcs);
+       fprintf(stderr, "contents bytes size : %d\n", contents_length);
+       fprintf(stderr, "page : (%d /%d) (page /total ) \n", page[1], page[0] );
+       fprintf(stderr, "contents: %s\n", contents);
+       fprintf(stderr, "*************************************\n");
+
+       /*
+          if(dcs.classType = TAPI_NETTEXT_CLASS_2)
+          {
+          TapiNetTextDataPackage * pDataPackage;
+
+          pDataPackage = malloc(sizeof(TapiNetTextDataPackage));
+
+          pDataPackage->msgLength =length ;
+          memcpy(pDataPackage->szData, pPDU, pDataPackage->msgLength);
+
+          TapiWriteNetText(0x01, pDataPackage);
+          }
+        */
+
+       return TRUE;
+}
+
+BOOL DecodeSmsSubmitReportTpdu(int length , char *data)
+{
+
+       TPDU_SMS_SUBMIT_REPORT  submit_report;
+       TmDateTime                              SCTimeStamp;
+       int                                             position=0;
+       int                                             i=0;
+       BYTE                                            msgType, udhi;
+       BYTE                                            result ,msgRef, tpdu_len;
+       BYTE                                    mask;
+
+       /* Result */
+
+       result = data[position];
+       position ++;
+
+       /* Msg Reference */
+
+       msgRef =  data[position];
+       position ++;
+
+       /* TPDU Length */
+
+       tpdu_len = data[position];
+       position ++;
+
+       position ++; //temp, delete later
+
+       /**** SUBMIT REPORT TPDU PARSING ***/
+
+       /* TP-MTI , TP-UDHI */
+
+       submit_report.msgType = data[position] & 0x03; //bit 0,1
+       submit_report.udhi = data[position] & 0x40 ? TRUE : FALSE;       //bit 6;
+
+       position ++;
+
+       if(result == FAIL)
+       {
+               /* TP-FCS */
+               submit_report.fcs =  data[position] ;
+               position ++;
+       }
+
+       /* TP-PI  - set to a 1 indicates that a particular optional parameter is present in the fields which follow. */
+       /* Masking Bit  - TP -PID (bit 0), TP-DCS(bit 1), TP-UDL(bit 2) */
+
+       submit_report.paraInd = data[position] ;
+       mask =  submit_report.paraInd;
+       position ++;
+
+       //fprintf(stderr, "Parmeter Indication mask =%x\n", mask);
+
+       /* TP-SCTS */
+
+       SmsUtilDecodeTimeStamp( &data[position], & SCTimeStamp );
+
+       position+=7;
+
+       if( ( mask != 0xFF ) && ( mask != 0 ) )
+       {
+               /* TP-PID */
+               if ( mask & 0x01)
+               {
+                       submit_report.pId= data[position];
+                       position ++;
+                       fprintf(stderr, "TP-PID :%x\n", submit_report.pId);
+               }
+
+               /* TP-DCS */
+               if ( mask & 0x02)
+               {
+                       SmsUtilDecodeDCS( &submit_report.dcs, data[position] );
+                       position ++;
+                       fprintf(stderr, "TP-DCS :%x\n",data[position] );
+               }
+
+               if ( mask & 0x04)
+               {
+                       /* TP-UDL */
+                       submit_report.udl = data[position];
+                       position++;
+
+                       fprintf(stderr, "TP-UDL :%x\n",data[position] );
+
+                       /* TP-UD */
+
+                       submit_report.userData = malloc( sizeof ( BYTE ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+                       memset(submit_report.userData, 0, sizeof ( BYTE ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+                       if (submit_report.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+                       {
+                               BYTE    inData[TAPI_NETTEXT_SMDATA_SIZE_MAX+1];
+
+                               memset( inData, 0x00, TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 );
+
+                               memcpy( (void*) inData, (void*) &data[position], submit_report.udl );
+
+                               SmsUtilUnpackGSMCode(submit_report.userData, inData, (UINT8) submit_report.udl);
+                       }
+
+               }
+       }
+
+       fprintf(stderr, "*************************************\n");
+
+       if(result ==FAIL)
+               fprintf(stderr, "SMS SEND FAIL!!\n");
+       else if(result ==SUCCESS)
+               fprintf(stderr, "SMS SEND SUCCESS!!\n");
+
+       if(result == FAIL)
+               fprintf(stderr, "Failure Code : %x\n",submit_report.fcs);
+
+#if 0
+       fprintf(stderr, "TPDU Length : %d\n", tpdu_len);
+
+       fprintf(stderr, "Time : %d-%d-%d  , %d:%d:%d\n",
+                       SCTimeStamp.year, SCTimeStamp.month, SCTimeStamp.day, SCTimeStamp.hour, SCTimeStamp.minute ,SCTimeStamp.second);
+       if(result == FAIL)
+               fprintf(stderr, "Failure Code : %x\n",submit_report.fcs);
+
+       if ( mask & 0x04)
+               fprintf(stderr, "Msg : %s\n",submit_report.userData);
+#endif
+
+       fprintf(stderr, "*************************************\n");
+
+       return TRUE;
+}
+
+BOOL DecodeSmsStatusReportTpdu(int tpdu_len, char * pTPDU)
+{
+       TPDU_SMS_STATUS_REPORT status_report;
+
+
+       TmDateTime   SCTimeStamp;
+       TmDateTime   DischargeTime;
+
+       //int                  scaAddr_len =0;
+       int                   rcpAddr_len = 0;
+       BYTE                  diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       //BYTE              scaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX]; //service center address
+       BYTE                  rcpAddr[TAPI_NETTEXT_ADDRESS_LEN_MAX]; //recipient number
+       //int                 sca_ton, sca_npi, rcp_ton,rcp_npi;
+       int                   rcp_ton,rcp_npi;
+       int                   position=0;
+       UINT                  mask;
+
+       //int i;
+
+       /* TP-MTI, TP MMS, TP SRQ, TP_UDHI */
+
+       status_report.msgType = pTPDU[position] & 0x03; // bit 0,1
+       status_report.mms = pTPDU[position] & 0x04 ? TRUE : FALSE ; // bit 2
+       status_report.srq = pTPDU[position] &  0x20 ? TRUE : FALSE ; //bit 5
+       status_report.udhi = pTPDU[position] & 0x40 ? TRUE : FALSE;      //bit 6
+
+       position ++;
+
+       /* TP-MR */
+       status_report.mr = pTPDU[position];
+       position ++;
+
+       /* TP-RA */
+
+       memset(diallingNum, 0, sizeof(diallingNum));
+
+       SmsUtilDecodeAddrField(diallingNum, &pTPDU[position],&rcp_ton, &rcp_npi);
+
+       position+=2;
+
+       rcpAddr_len = strlen( (char*) diallingNum );
+       if ( rcpAddr_len % 2 )
+               position += rcpAddr_len / 2 + 1;
+       else
+               position += rcpAddr_len / 2;
+
+
+       if ( rcp_ton == SIM_TON_INTERNATIONAL )
+       {
+               rcpAddr[0] = '+';
+               memcpy( &rcpAddr[1], diallingNum, rcpAddr_len );
+               rcpAddr[rcpAddr_len+1] = '\0';
+       }
+       else
+       {
+               memcpy( rcpAddr, diallingNum, rcpAddr_len );
+               rcpAddr[rcpAddr_len] = '\0';
+       }
+
+       status_report.rcpAddr.dialnumLen= rcpAddr_len;
+       memcpy(status_report.rcpAddr.diallingNum, rcpAddr , rcpAddr_len);
+       status_report.rcpAddr.npi = rcp_npi;
+       status_report.rcpAddr.ton = rcp_ton;
+
+       /* TP-SCTS */
+       SmsUtilDecodeTimeStamp( &pTPDU[position], & SCTimeStamp );
+       position+=7;
+
+       /* TP-DT */
+       SmsUtilDecodeTimeStamp( &pTPDU[position], & DischargeTime );
+       position+=7;
+
+       /* TP-ST */
+       status_report.status = pTPDU[position];
+       position ++;
+
+       /* TP-PI */
+       status_report.paraInd = pTPDU[position];
+
+       mask = status_report.paraInd  ;
+
+       if ( ( mask != 0xFF ) && ( mask != 0 ) )
+       {
+               /* Increment only if mask is valid */
+               position ++;
+
+               /* TP-PID */
+               if ( mask & 0x01)
+               {
+                       status_report.pId= pTPDU[position];
+                       position ++;
+               }
+               /* TP-DCS */
+               if ( mask & 0x02)
+               {
+                       SmsUtilDecodeDCS( &status_report.dcs, pTPDU[position] );
+                       position ++;
+               }
+               if ( mask & 0x04)
+               {
+                       /* TP-UDL */
+                       status_report.udl = pTPDU[position];
+                       position++;
+
+                       /* TP-UD */
+
+                       status_report.userData = malloc( sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+                       memset(status_report.userData, 0, sizeof ( unsigned char ) * ( TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 ) );
+
+                       if (status_report.dcs.alphabetType == TAPI_NETTEXT_ALPHABET_DEFAULT )
+                       {
+                               BYTE    inData[TAPI_NETTEXT_SMDATA_SIZE_MAX+1];
+
+                               memset( inData, 0x00, TAPI_NETTEXT_SMDATA_SIZE_MAX + 1 );
+
+                               memcpy( (void*) inData, (void*) &pTPDU[position], status_report.udl );
+
+                               SmsUtilUnpackGSMCode(status_report.userData, inData, (UINT8) status_report.udl);
+                       }
+
+               }
+       }
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Msg Type: STATUS_REPORT\n");
+       if(status_report.mms)
+               fprintf(stderr, "MMS: No more messages are waiting for the MS in this SC\n");
+       else if(!status_report.mms)
+               fprintf(stderr, "MMS: More messages are waiting for the MS in this SC\n");
+
+       if(status_report.srq)
+               fprintf(stderr, "SRQ: the result of an SMS COMMAND \n");
+       else if(!status_report.srq)
+               fprintf(stderr, "SRQ: the result of a SMS SUBMIT.\n");
+
+       if(status_report.udhi)
+               fprintf(stderr, "UDHI: Contains a Header in addition to the short message.\n");
+       else if(!status_report.udhi)
+               fprintf(stderr, "UDHI: Only Short Message\n");
+
+       if(status_report.status==0x00)
+               fprintf(stderr, "STATUS : Short message received by the SME\n");
+       else if(status_report.status==0x01)
+               fprintf(stderr, "STATUS : Short message forwarded by the SC to the SME\nbut the SC is unable to confirm delivery\n");
+       else if(status_report.status==0x02)
+               fprintf(stderr, "STATUS : Short message replaced by the SC\n");
+
+       fprintf(stderr, "Recipient Number : %s\n" ,rcpAddr );
+       fprintf(stderr, "SC Time Stamp : %d-%d-%d  , %d:%d:%d\n",
+                       SCTimeStamp.year, SCTimeStamp.month, SCTimeStamp.day, SCTimeStamp.hour, SCTimeStamp.minute ,SCTimeStamp.second);
+       fprintf(stderr, "Discharge Time : %d-%d-%d  , %d:%d:%d\n",
+                       DischargeTime.year, DischargeTime.month, DischargeTime.day, DischargeTime.hour, DischargeTime.minute ,DischargeTime.second);
+
+       if(mask & 0x04)
+               fprintf(stderr, "Message : %s \n" , status_report.userData);
+
+       fprintf(stderr, "*************************************\n");
+
+       return TRUE;
+}
+
+void ActionStatusNotification(int length, char *pData)
+{
+       BYTE  actionCmd;
+       BYTE  result;
+       int  index;
+
+       actionCmd = pData[0];
+       result = pData[1];
+       index = (int) pData[2];
+
+       fprintf(stderr, "=====================================\n");
+       if(actionCmd == 0x04)
+       {
+               if(result==0x00)
+                       fprintf(stderr, "\nSAVE MSESSAGE!! - FAIL\n");
+               else if(result ==0x01)
+                       fprintf(stderr, "\nSAVE MSESSAGE:  INDEX = %d SUCCESS!!!\n",index);
+       }
+       else if(actionCmd == 0x05)
+       {
+               if(result==0x00)
+                       fprintf(stderr, "\nDELETE MSESSAGE!! - FAIL\n");
+               else if(result ==0x01)
+                       fprintf(stderr, "\nDELETE MSESSAGE: INDEX = %d SUCCESS!!!\n",index);
+       }
+
+       fprintf(stderr, "=====================================\n");
+}
+
+static int tapi_callback(TapiEventClass eventClass, TapiEventType eventType, int param1, void* param2)
+{
+       int i;
+       fprintf(stderr, ">>>>> sms tapi_callback() is called\n");
+       char *pData ;
+       int value;
+
+       if(param2 !=NULL)
+       {
+               pData = malloc(sizeof((char *)param2));
+               if(pData!=NULL)
+               {
+                       pData= (char *)param2;
+                       value = (int)pData[0];
+               }
+       }
+       fprintf(stderr, "eventClass=%x, eventType=%x, param1 = %x \n", eventClass, eventType, param1);
+
+       switch(eventClass)
+       {
+               case TAPI_NETTEXT:
+               case TAPI_NETTEXT_SMS:
+                       {
+                               switch(eventType)
+                               {
+                                       case TAPI_EVENT_NETTEXT_INCOM :
+                                               {
+                                                       fprintf(stderr, "\n$$$$$$ INCOMING MESSAGE NOTIFICATION $$$$$$ \n");
+                                                       ReceiveMessage(param1,pData);
+                                                       //system("cat sent.wav > /dev/dsp");
+                                                       break;
+                                               }
+
+                                       case TAPI_EVENT_NETTEXT_SENTSTATUS:
+                                               {
+                                                       fprintf(stderr, "\n$$$$$$ RECEIVE  ACK NOTIFICATION $$$$$$ \n");
+                                                       DecodeSmsSubmitReportTpdu(param1,pData);
+                                                       system("cat chimeup.wav > /dev/dsp");
+                                                       break;
+                                               }
+
+                                       case TAPI_EVENT_NETTEXT_CB_INCOM:
+                                               {
+                                                       fprintf(stderr, "\n$$$$$$ INCOMING CB NOTIFICATION $$$$$$ \n");
+                                                       DecodeCellBroadcastMsg(param1, pData);
+                                                       system("cat sent.wav > /dev/dsp");
+                                                       break;
+                                               }
+                                       case TAPI_EVENT_NETTEXT_ACTION_STATUS:
+                                               {
+                                                       fprintf(stderr, "\n$$$$$$ ACTION STATUS  NOTIFICATION $$$$$$ \n");
+                                                       ActionStatusNotification(param1,pData);
+                                                       break;
+                                               }
+                                       case TAPI_EVENT_NETTEXT_MEMORY_STATUS_IND:
+                                               {
+                                                       fprintf(stderr, "\n$$$$$$ MEMORYF  FULL NOTIFICATION $$$$$$ \n");
+                                                       break;
+                                               }
+                                       default:
+                                               break;
+                               }
+                       }
+               default:
+                       break;
+       }
+       return 0;
+}
+
+int  SendMessage()
+{
+       int             ret;
+       int             len=0,msg_len=0;
+       char            buf[512];
+       char            message[512];
+       char    diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       char    ScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+       int             diallingNum_len=0;
+
+       memset(buf,0, sizeof(buf));
+       memset(diallingNum,0,sizeof(diallingNum));
+       diallingNum_len=0;
+
+       sfprintf(stderr, diallingNum,"82103001");
+
+       fprintf(stderr, "Enter destination Number:\n");
+
+       ret = read(0, buf, sizeof(buf));
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       diallingNum_len=strlen(diallingNum);
+       memcpy(&diallingNum[diallingNum_len], buf,4);
+
+       diallingNum_len = strlen(diallingNum); //recalculate
+       diallingNum[diallingNum_len]=0;
+       diallingNum_len-1;
+
+       fprintf(stderr, "Enter Message\n");
+       memset(message,0,sizeof(message));
+
+       ret = read(0, message, sizeof(message));
+
+       if (ret <= 0) {
+               fprintf(stderr, " NULL msg can NOT be sent \n");
+               return -1;
+       }
+
+       msg_len=strlen(message);
+
+       fprintf(stderr, "==========================\n");
+       fprintf(stderr, "To :%s\n", diallingNum);
+       fprintf(stderr, "Message: %s\nMsg Length:%d\n",message, msg_len);
+       fprintf(stderr, "Dialling number Length : %d\n" ,diallingNum_len);
+       fprintf(stderr, "==========================\n\n");
+
+       //TapiGetServiceCenterAddress(&ScaAddr);
+       EncodeSmsSubmitTpdu(diallingNum, diallingNum_len,message, msg_len) ;
+       return 1;
+
+}
+
+int ReadMessage()
+{
+       int             menu;
+       int             ret;
+       BYTE    buf[100];
+       int i;
+
+       /************** Count Info *************/
+       StoredMsgCountInfo msgCountInfo;
+       /************* memory type************/
+       int  * memoryType;
+       int  * totalSize;
+       int  * usedSize;
+       /************read Msg****************/
+       int     index=0;
+       int     * msgStatus;
+       TapiNetTextDataPackage DataPackage;
+
+       int                scaAddr_len =0;
+       char                * pTPDU;
+       int                 tpdu_len =0;
+       BYTE                diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       BYTE             scaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX]; //service center address
+       int                 sca_ton, sca_npi;
+       int                 position;
+
+       memset(buf,0, sizeof(buf));
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "1. SIM Message\n");
+       //fprintf(stderr, "2. Incoming Msg\n");
+       //fprintf(stderr, "3. Sent Msg\n");
+       //fprintf(stderr, "4. Status Report\n");
+       //fprintf(stderr, "5. Go back\n");
+       //fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Select Number:\n");
+
+       ret = read(0, buf, sizeof(buf));
+
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       menu = atoi(buf);
+
+       switch(menu)
+       {
+               case 1:  //SIM Message
+                       {
+                               TapiSetSelectMemory(0x02);  // 0x02: SIM memory
+
+                               TapiGetSelectMemory(&memoryType,&totalSize,&usedSize);
+
+                               if(memoryType == 0x02)
+                               {
+                                       TapiGetNetTextCount(&msgCountInfo);
+
+                                       fprintf(stderr, "totalCount =%d , usedCount=%d\n", msgCountInfo.totalCount,msgCountInfo.usedCount);
+
+                                       if(msgCountInfo.usedCount!=0x00)
+                                       {       fprintf(stderr, "Index LIST..........\n");
+                                               for(i  = 0; i < msgCountInfo.usedCount ;  i++)
+                                                       fprintf(stderr, "[%02x]", msgCountInfo.index_list[i]);
+                                       }
+
+                                       fprintf(stderr, "\n=====================================\n");
+
+                                       for (i = 0 ; i < msgCountInfo.usedCount ; i++)
+                                       {
+                                               TapiReadNetText(msgCountInfo.index_list[i], &msgStatus,&DataPackage);
+
+                                               fprintf(stderr, "\n=======READ MESSAGE(index = %d)=======\n", msgCountInfo.index_list[i]);
+
+
+                                               if(msgStatus == 0x00)
+                                                       fprintf(stderr, "Msg Staus : unknown msg\n");
+                                               else if(msgStatus == 0x01)
+                                                       fprintf(stderr, "Msg Staus : received unread msg\n");
+                                               else if(msgStatus ==0x02)
+                                                       fprintf(stderr, "Msg Staus : received read msg\n");
+                                               else if(msgStatus ==0x03)
+                                                       fprintf(stderr, "Msg Staus : unsent msg\n");
+                                               else if(msgStatus ==0x04)
+                                                       fprintf(stderr, "Msg Staus : stored sent msg\n");
+
+                                               if(msgStatus==0x01 || msgStatus ==0x02)
+                                               {
+                                                       position=0;
+
+                                                       /* SCA_ADDR */
+
+                                                       memset(diallingNum, 0, sizeof(diallingNum));
+
+                                                       SmsUtilDecodeAddrField(diallingNum, &DataPackage.szData[position],&sca_ton, &sca_npi);
+
+                                                       position+=2;  //include Address-Length, Type of Address
+
+                                                       scaAddr_len = strlen( diallingNum );
+
+                                                       if ( scaAddr_len % 2 )
+                                                               position += scaAddr_len / 2 + 1;
+                                                       else
+                                                               position += scaAddr_len / 2;
+
+
+                                                       if ( sca_ton == SIM_TON_INTERNATIONAL )
+                                                       {
+                                                               scaAddr[0] = '+';
+                                                               memcpy( &scaAddr[1], diallingNum, scaAddr_len );
+                                                               scaAddr[scaAddr_len+1] = '\0';
+                                                       }
+                                                       else
+                                                       {
+                                                               memcpy( scaAddr, diallingNum, scaAddr_len );
+                                                               scaAddr[scaAddr_len] = '\0';
+                                                       }
+
+                                                       tpdu_len = DataPackage.msgLength -position;
+
+                                                       fprintf(stderr, "SCA Number : %s\n",scaAddr);
+
+                                                       pTPDU = malloc(sizeof(BYTE) * tpdu_len);
+
+                                                       memcpy(pTPDU, &DataPackage.szData[position], tpdu_len);
+
+                                                       DecodeSmsDeliverTpdu(tpdu_len, pTPDU);
+                                               }
+
+                                               fprintf(stderr, "=====================================\n");
+
+                                       }
+                               }
+
+                               break;
+                       }
+                       /*
+                          case 2: //Incoming Msg
+                          {
+                          TapiSetSelectMemory(0x01);  // 0x01: Phone Flash memory
+                          TapiGetSelectMemory(&memoryType,&totalSize,&usedSize);
+                          if(memoryType ==0x01)
+                          {
+
+                       //DecodeSmsDeliverTpdu(int pdu_len, char * pPDU, BOOL bRead);
+                       }
+                       break;
+                       }
+                       case 3: //Sent Msg
+                       {
+                       TapiSetSelectMemory(0x01);  // 0x01: Phone Flash memory
+                       TapiGetSelectMemory(&memoryType,&totalSize,&usedSize);
+                       if(memoryType ==0x01)
+                       {
+                       //DecodeSmsSubmitTpdu(int length, char * data);
+                       }
+                       break;
+                       }
+                       case 4: //Status Report Msg
+                       {
+                       TapiSetSelectMemory(0x01);  // 0x01: Phone Flash memory
+                       TapiGetSelectMemory(&memoryType,&totalSize,&usedSize);
+                       if(memoryType ==0x01)
+                       {
+                       //DecodeSmsStatusReportTpdu(int pdu_len, char * pPDU);
+                       }
+
+                       break;
+                       }
+                        */
+               case 5:
+                       return;
+
+       }
+       return 1;
+}
+
+int DeleteMessage()
+{
+       int     ret;
+       int     index;
+       BYTE buf[100];
+
+       StoredMsgCountInfo msgCountInfo;
+
+       int     i;
+
+       memset(buf, 0, sizeof(buf));
+
+       fprintf(stderr, "Enter delete index >>\n");
+
+       ret = read(0, buf, sizeof(buf));
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       index=atoi(buf);
+
+       TapiDeleteNetText(index);
+       TapiGetNetTextCount(&msgCountInfo);
+
+       fprintf(stderr, "======Current Memory Infomation======\n");
+
+       fprintf(stderr, "totalCount =%d , usedCount=%d\n", msgCountInfo.totalCount,msgCountInfo.usedCount);
+
+       if(msgCountInfo.usedCount!=0x00)
+       {       fprintf(stderr, "Index LIST..........\n");
+               for(i  = 0; i < msgCountInfo.usedCount ;  i++)
+                       fprintf(stderr, "[%02x]", msgCountInfo.index_list[i]);
+       }
+       fprintf(stderr, "\n=====================================\n");
+       return 1;
+
+}
+
+int ReceiveMessage(int pdu_len, char * pPDU)
+{
+
+       int                scaAddr_len =0;
+       char                * pTPDU;
+       int                 tpdu_len =0;
+       BYTE                diallingNum[TAPI_NETTEXT_ADDRESS_LEN_MAX];
+       BYTE             scaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX]; //service center address
+       int                 sca_ton, sca_npi;
+       int                 position;
+       int                 dcs_pos =0;
+       BYTE        mti; //message type
+       BYTE        sri; //status report indication
+       int i;
+       TapiNetTextCodingScheme dcs;
+
+       position=0;
+
+       /* SCA_ADDR */
+
+       memset(diallingNum, 0, sizeof(diallingNum));
+
+       SmsUtilDecodeAddrField(diallingNum, &pPDU[position],&sca_ton, &sca_npi);
+
+       position+=2;  //include Address-Length, Type of Address
+
+       scaAddr_len = strlen( diallingNum );
+
+       if ( scaAddr_len % 2 )
+               position += scaAddr_len / 2 + 1;
+       else
+               position += scaAddr_len / 2;
+
+
+       if ( sca_ton == SIM_TON_INTERNATIONAL )
+       {
+               scaAddr[0] = '+';
+               memcpy( &scaAddr[1], diallingNum, scaAddr_len );
+               scaAddr[scaAddr_len+1] = '\0';
+       }
+       else
+       {
+               memcpy( scaAddr, diallingNum, scaAddr_len );
+               scaAddr[scaAddr_len] = '\0';
+       }
+
+       mti =pPDU[position] & 0x03;
+
+       tpdu_len = pdu_len -position;
+
+       fprintf(stderr, "SCA Number : %s\n",scaAddr);
+
+       pTPDU = malloc(sizeof(BYTE) * tpdu_len);
+
+       memcpy(pTPDU, &pPDU[position], tpdu_len);
+
+       if(mti ==SMS_TPDU_DELIVER)
+       {
+               DecodeSmsDeliverTpdu(tpdu_len, pTPDU);
+
+               fprintf(stderr, "dcs_pos : %d\n", dcs_pos);
+
+               SmsUtilDecodeDCS(&dcs, pPDU[position+dcs_pos]);
+
+               /*
+                  if(dcs.classType == TAPI_NETTEXT_CLASS_2)
+                  {
+                  TapiNetTextDataPackage * pDataPackage;
+
+                  pDataPackage = malloc(sizeof(TapiNetTextDataPackage));
+
+                  pDataPackage->msgLength = pdu_len ;
+                  memcpy(pDataPackage->szData, pPDU, pDataPackage->msgLength);
+
+                  TapiWriteNetText(0x01, pDataPackage);
+
+                  free(pDataPackage);
+                  }
+                */
+
+       }
+       else if(mti ==SMS_TPDU_STATUS_REPORT)
+       {
+               DecodeSmsStatusReportTpdu(tpdu_len, pTPDU);
+       }
+
+
+       free(pTPDU);
+
+
+       return 1;
+
+}
+
+int GetInformation()
+{
+       //SysDebug(MID_TAPI | DBG_TAPI_NETTEXT, "====Information\n");
+
+       int             menu;
+       int             ret;
+       BYTE    buf[100];
+       int i,k;
+
+       /* Get Service Center Number */
+       //BYTE          ScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+       SmsAddressInfo  szSCAddr;
+
+       BYTE    decodeScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+       BYTE    realScaAddr[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+       int            sca_len =0;
+       //int           sca_ton, sca_npi;
+
+       /* Get Beare Type */
+       int  *  svc;
+
+       /* Get Stored Msg Count */
+       int * pMemoryType;
+       int * pTotalSize;
+       int * pUsedSize;
+
+       StoredMsgCountInfo msgCountInfo;
+
+       /* Get CB Setting Information */
+       TapiNetTextCBConfig  CBConfig;
+       UINT16 CBChannel[MAX_GSM_SMS_CBMI_LIST_SIZE];
+
+       memset(buf,0, sizeof(buf));
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "1.Get Service Center Number\n");
+       fprintf(stderr, "2.Get Bearer Type\n");
+       fprintf(stderr, "3.Get Current Memory Information\n");
+       fprintf(stderr, "4.Get CB Setting Information\n");
+       //fprintf(stderr, "5.Go back\n");
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Select Number:\n");
+
+       ret = read(0, buf, sizeof(buf));
+       //fprintf(stderr, "ret :%d\n",ret);
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       menu = atoi(buf);
+
+       switch(menu)
+       {
+               case 1:
+                       {
+                               TapiGetServiceCenterAddress(&szSCAddr);
+
+                               SmsUtilDecodeAddrField(decodeScaAddr, &szSCAddr.diallingNum[0],&szSCAddr.ton, &szSCAddr.npi);
+
+                               sca_len = strlen( decodeScaAddr );
+
+                               if ( szSCAddr.ton == SIM_TON_INTERNATIONAL )
+                               {
+                                       realScaAddr[0] = '+';
+                                       memcpy( &realScaAddr[1], decodeScaAddr, sca_len );
+                                       realScaAddr[sca_len+1] = '\0';
+                               }
+                               else
+                               {
+                                       memcpy( realScaAddr, decodeScaAddr, sca_len );
+                                       realScaAddr[sca_len] = '\0';
+                               }
+
+                               fprintf(stderr, "===== Decode SCA Address =====\n");
+                               fprintf(stderr, "SCA Number :%s \n",realScaAddr);
+                               fprintf(stderr, "==============================\n");
+
+                               break;
+                       }
+               case 2:
+                       {
+                               TapiGetPreferredBearer(&svc);
+
+                               fprintf(stderr, "====== Current Bearer ======\n");
+
+                               if(svc== TAPI_NETTEXT_BEARER_PS_ONLY)
+                                       fprintf(stderr, "Packet Domain\n");
+                               else if(svc== TAPI_NETTEXT_BEARER_CS_ONLY)
+                                       fprintf(stderr, "Circuit Switched\n");
+                               else if(svc== TAPI_NETTEXT_BEARER_PS_PREFERRED)
+                                       fprintf(stderr, "Packet Domain preferred \n");
+                               else if(svc== TAPI_NETTEXT_BEARER_CS_PREFERRED)
+                                       fprintf(stderr, "Circuit Switched preferred\n");
+
+
+                               fprintf(stderr, "===========================\n");
+
+                               break;
+                       }
+               case 3:
+                       {
+                               TapiGetSelectMemory(&pMemoryType, &pTotalSize, & pUsedSize);
+
+                               fprintf(stderr, "========Current Memory ==========\n");
+
+                               if(pMemoryType==0x01)
+                               {
+                                       fprintf(stderr, "Select Memroy: Phone Flash\n");
+                               }
+                               else if(pMemoryType==0x02)
+                               {
+                                       fprintf(stderr, "Select Memroy: SIM\n");
+                               }
+                               TapiGetNetTextCount(&msgCountInfo);
+                               fprintf(stderr, "Total Count : %d , Used Count :%d\n",msgCountInfo.totalCount ,msgCountInfo.usedCount);
+                               fprintf(stderr, "===========================\n");
+
+                               break;
+                       }
+               case 4:
+                       {
+                               TapiGetCBConfig(&CBConfig);
+
+                               fprintf(stderr, "=========CB Configuration=========\n");
+
+                               /*** CB Enable/Diable ***/
+                               if(CBConfig.CBEnabled==0x01)
+                                       fprintf(stderr, "Cell Broadcast Msg Enabled...\n");
+                               else if(CBConfig.CBEnabled==0x02)
+                                       fprintf(stderr, "Cell Broadcast Msg Disabled...\n");
+
+                               /*** Selected ID ***/
+                               if(CBConfig.selectedId == 0x01)
+                                       fprintf(stderr, "All CBMI is selected... \n");
+                               else if(CBConfig.selectedId == 0x02)
+                                       fprintf(stderr, "There are some selected CBMI...\n");
+
+                               /*** CBMI  Count ***/
+                               fprintf(stderr, "CBMI Count: %d \n\n",CBConfig.nMsgIdCount);
+
+                               /*** CBMI  List ***/
+                               if(CBConfig.nMsgIdCount !=0)
+                               {
+                                       fprintf(stderr, "----- CBMI List -----\n");
+
+                                       for(i =0 ; i < CBConfig.nMsgIdCount; i++)
+                                       {
+                                               fprintf(stderr, "No.%d - [0x%04x]\n", i,CBConfig.MsgIDs[i]);
+                                       }
+
+                               }
+                               fprintf(stderr, "\n==================================\n");
+                               break;
+                       }
+               case 5:
+                       return;
+
+       }
+
+       return 1;
+}
+
+int Setting()
+{
+       //SysDebug(MID_TAPI | DBG_TAPI_NETTEXT, "====Setting\n");
+       int                             settingMenu;
+       int                             ret;
+       BYTE                    buf[512];
+
+       BYTE                            memoryType[2]; //2006/8/8
+       BYTE                    bearerType[2];  //2006/8/8
+       BYTE                            cbEnable[2];//2006/8/8
+
+       BYTE                            scabuf[512];
+       BYTE                            scaNum[TAPI_NETTEXT_SCADDRESS_LEN_MAX];
+       BYTE                            scaNum_len =0;
+       SmsAddressInfo       * szSCAddr;
+
+       TapiNetTextCBConfig   *pCBConfig;
+
+       int                             memType;
+       int                             index;
+       int                             msgStauts;
+       int *                           CurMsgStauts;
+       TapiNetTextDataPackage DataPackage;
+
+       int                             idx=0;
+       int                             i =0;
+       BYTE                    packet[500];
+
+       memset(buf,0, sizeof(buf));
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "1.Set Service Center Number\n");
+       fprintf(stderr, "2.Set Meomry Type\n");
+       fprintf(stderr, "3.Set Bearer Type\n");
+       fprintf(stderr, "4.Set Memory Full Notification\n");
+       fprintf(stderr, "5.Set Deliver Report\n");
+       fprintf(stderr, "6.Set CB Enable/Disable\n");
+       fprintf(stderr, "7.Set Stored MsgStaus\n");
+       //fprintf(stderr, "8.Go back\n");
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Select Number:\n");
+
+       ret = read(0, buf, sizeof(buf));
+
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       settingMenu = atoi(buf);
+
+
+       switch(settingMenu)
+       {
+               case 1:  //Set Service Center Number
+                       {
+                               szSCAddr =malloc(sizeof(SmsAddressInfo));
+                               memset(szSCAddr,0, sizeof(szSCAddr));
+                               memset(scaNum, 0, sizeof(scaNum));
+                               memset(scabuf,0,sizeof(scabuf));
+
+                               sfprintf(stderr, scaNum,"821091");
+
+                               fprintf(stderr, "Enter SCA Number Last 4 Digit :\n");
+
+                               ret = read(0, scabuf, sizeof(scabuf));
+                               if (ret < 0)
+                               {
+                                       if (errno == EINTR)
+                                               perror("read(1)");
+                                       return -1;
+                               }
+                               else if (ret == 0)
+                                       return ret;
+
+                               scaNum_len=strlen(scaNum);
+                               memcpy(&scaNum[scaNum_len], scabuf, 4);
+
+                               scaNum_len = strlen(scaNum);
+                               scaNum[scaNum_len] = 0;
+                               scaNum_len-1;
+
+                               fprintf(stderr, "==========================\n");
+                               fprintf(stderr, "Sca Number :%s\n", scaNum);
+                               fprintf(stderr, "sca  number length : %d \n",  scaNum_len);
+                               fprintf(stderr, "==========================\n");
+
+                               idx = SmsUtilEncodeAddrField( packet, scaNum, scaNum_len, 0x01, 0x01);
+
+                               fprintf(stderr, "idx =%d\n",idx);
+
+                               for(i = 0; i < idx ; i++)
+                                       fprintf(stderr, "[%02x]",packet[i]);
+
+                               szSCAddr->dialnumLen = idx ;
+
+                               memcpy(szSCAddr->diallingNum , packet, idx);
+
+                               TapiSetServiceCenterAddress(szSCAddr);
+
+                               free(szSCAddr);
+
+                               break;
+                       }
+               case 2: //Set Meomry Type
+                       {
+                               fprintf(stderr, "Enter set memory type(1:Phone Flash,2:SIM):\n");
+
+                               memset(memoryType,0 ,sizeof(memoryType));
+
+                               ret = read(0, memoryType, sizeof(memoryType));
+
+                               if (ret <= 0) {
+                                       fprintf(stderr, " NULL msg can NOT be sent \n");
+                                       return -1;
+                               }
+
+                               fprintf(stderr, "MemoryType: %d\n", atoi(memoryType));
+
+                               TapiSetSelectMemory(atoi(memoryType));
+
+                               break;
+                       }
+               case 3: //Set Bearer Type
+                       {
+                               fprintf(stderr, "Enter Bearer Type(1:PD, 2:CS, 3:PDP 4:CSP):\n");
+
+                               memset(bearerType,0 ,sizeof(bearerType));
+
+                               ret = read(0, bearerType, sizeof(bearerType));
+                               if (ret <= 0) {
+                                       fprintf(stderr, " NULL msg can NOT be sent \n");
+                                       return -1;
+                               }
+                               fprintf(stderr, "Set Preferred Bearer : bearerType =%d \n", atoi(bearerType));
+                               TapiSetPreferredBearer(atoi(bearerType));
+
+                               break;
+                       }
+               case 4: //Set Memory Full Notification
+                       {
+                               fprintf(stderr, "Request  Set Memory Full  Notification:\n");
+                               TapiSetNetTextMemoryFull();
+                               break;
+                       }
+               case 5: //Set Deliver Report
+                       {
+                               fprintf(stderr, "Set Deliver Report\n");
+                               EncodeSmsDeliverReportTpdu();
+                               break;
+                       }
+               case 6: //Set CB Enable/Disable
+                       {
+                               fprintf(stderr, "Enter CB ON/OFF (1: Enable, 2:Disable):\n");
+
+                               memset(cbEnable,0 ,sizeof(cbEnable));
+                               pCBConfig = malloc(sizeof(TapiNetTextCBConfig));
+
+                               ret = read(0, cbEnable, sizeof(cbEnable));
+
+                               if (ret <= 0) {
+                                       fprintf(stderr, " NULL msg can NOT be sent \n");
+                                       return -1;
+                               }
+
+                               pCBConfig->CBEnabled = atoi(cbEnable);
+                               pCBConfig->selectedId = 0x01;
+                               pCBConfig->nMsgIdCount = 0x02;
+
+                               pCBConfig->MsgIDs[0] = 0x0c;
+                               pCBConfig->MsgIDs[1] = 0x0c;
+                               pCBConfig->MsgIDs[2] = 0xdf;
+                               pCBConfig->MsgIDs[3] = 0x00;
+
+                               TapiSetCBConfig(pCBConfig);
+
+                               free(pCBConfig);
+                               break;
+                       }
+               case 7: //Set Stored MsgStaus
+                       {
+                               memType=0x02;
+                               index=0x02;
+                               msgStauts =0x02;
+
+                               TapiReadNetText(index, &CurMsgStauts, &DataPackage);
+
+                               fprintf(stderr, "Before set status : index = %d, CurMsgStauts=%d\n");
+
+                               TapiSetMsgStatus(memoryType,  index,  msgStauts);
+
+                               TapiReadNetText(index, &CurMsgStauts, &DataPackage);
+
+                               fprintf(stderr, "After set status :index = %d, CurMsgStauts=%d\n");
+
+                               break;
+                       }
+               case 8:
+                       return;
+       }
+       return 1;
+}
+
+int get_handle()
+{
+       _handle = TapiRegisterClient( TAPI_NETTEXT_SMS , tapi_callback, TRUE);
+       if(!TapiRegisterNetText()) fprintf(stderr, "register Failure!\n");
+
+       if(_handle == NULL)
+       {
+               fprintf(stderr, "handle get error\n");
+               return -1;
+       }
+}
+
+int read_phoneserver_pkt(void)
+{
+       lxt_callback(_handle);
+       return 0;
+}
+int read_key_input(void)
+{
+
+       int     ret;
+       char    buf[512];
+
+       //initialize value
+       memset(buf,0, sizeof(buf));
+
+       ret = read(0, buf, sizeof(buf));
+       if (ret < 0)
+       {
+               if (errno == EINTR)
+                       perror("read(1)");
+               return -1;
+       }
+       else if (ret == 0)
+               return ret;
+
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "1.Send New Message\n");
+       fprintf(stderr, "2.Read Message\n");
+       fprintf(stderr, "3.Delete Message\n");
+       fprintf(stderr, "4.Delete All Message\n");
+       fprintf(stderr, "5.Setting\n");
+       fprintf(stderr, "6.SMS Information\n");
+       fprintf(stderr, "7.SMS Exit\n");
+       fprintf(stderr, "*************************************\n");
+       fprintf(stderr, "Select Number : %s\n", buf);
+
+       if( memcmp(buf,"1",sizeof("1")-1) == 0 ){ SendMessage();}
+       if( memcmp(buf,"2",sizeof("2")-1) == 0 ){ ReadMessage();}
+       if( memcmp(buf,"3",sizeof("3")-1) == 0 ){ DeleteMessage();}
+       if( memcmp(buf,"4",sizeof("4")-1) == 0 ){ TapiDeleteNetText(0xFF);}
+       if( memcmp(buf,"5",sizeof("5")-1) == 0 ){ Setting();}
+       if( memcmp(buf,"6",sizeof("6")-1) == 0 ){ GetInformation();}
+
+       if( memcmp(buf,"7",sizeof("7")-1) == 0 ){
+               fprintf(stderr, "SMS Program is terminated.\n");
+               exit(0);
+       }
+
+       return 0;
+}
+
+void select_loop(void)
+{
+       int ret;
+       fd_set readfds;
+       int fd=_handle->fd;
+       char buf[512];
+
+       while (1) {
+               FD_ZERO(&readfds);
+               FD_SET(fd, &readfds);
+               FD_SET(0, &readfds);
+
+
+               ret = select(fd + 1, &readfds, NULL, NULL, NULL);
+               if (ret) {
+                       if (FD_ISSET(fd, &readfds)) {
+                               read_phoneserver_pkt();
+                       }
+
+                       if (FD_ISSET(0, &readfds)) {
+                               read_key_input();
+
+                       }
+
+               }
+       }
+}
+
+int main(int argc, char *argv[])
+{
+
+       char buf[1000];
+       int ret=0;
+
+       ret=get_handle();
+
+       select_loop();
+
+
+}
+
+#endif /* 0 */
diff --git a/lib/libsms/sms_util.c b/lib/libsms/sms_util.c
new file mode 100644 (file)
index 0000000..4af8c53
--- /dev/null
@@ -0,0 +1,1137 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "sms_header.h"
+#include "sms_util.h"
+
+
+void  reverse(char* x, int len)
+{
+       int i, j = len - 1;
+
+       for (i = 0; i < j; i++)
+       {
+               int t = x[i];
+               x[i] = x[j];
+               x[j--] = t;
+       }
+}
+
+char*  AcItoa(int n, char* str, int b)
+{
+       int i = 0;
+
+       do
+               str[i++] = "0123456789ABCDEF"[n%b];
+
+       while ((n /= b) > 0);
+       reverse(str, i);
+       str[i] = '\0';
+
+       return str;
+}
+
+int  AcToupper(int ch)
+{
+       return (('a' <= (ch) && (ch) <= 'z')? ((ch) - ('a'-'A')) : (ch));
+}
+
+char* SmsUtilUnpackGSM8Code( char* szData, const BYTE* pIn, int in_len )
+{
+       int i;
+  
+    for (i = 0; i < in_len; i ++) {  
+               szData [i] = pIn [i];
+       }  
+
+    return szData;     
+}
+
+
+int SmsUtilUnpackGSMCode( char* szData, const BYTE* pIn, int in_len )
+{
+       int i;
+       int pos = 0;
+       int shift = 0;
+
+       /* If the number of fill bits != 0, then it would cause an additional shift */
+       /*
+       if ( shift != 0 )
+               pos = pos + 1;
+
+       if ( shift ==7 )
+               shift = 0;
+       */
+
+       for ( i = 0; i < in_len; i++, pos++ )
+       {
+               szData[i] = ( pIn[pos] << shift ) & 0x7F;
+
+               if ( pos != 0 )
+               {
+                       /* except the first byte, a character contains some bits
+                       ** from the previous byte.
+                       */
+                       szData[i] |= pIn[pos-1] >> (8-shift);
+               }
+
+               shift ++;
+
+               if ( shift == 7 )
+               {
+                       shift = 0;
+
+                       /* a possible extra complete character is available */
+                       i++;
+                       szData[i] = pIn[pos] >> 1;
+
+                       if( szData[i] == 0 )
+                       {
+                               /* this is the end of the input, quit */
+               //              break;
+                       }
+               }
+       }
+
+       return i;
+}
+
+int SmsUtilpackGSM8Code( BYTE* pOut, const char* szData, int in_len )
+{
+       int i;
+       int pos = 0;
+  
+    for (i = 0; i < in_len; i ++) {  
+               pOut[i] = szData [i];
+               pos++;
+       }  
+
+    return pos;        
+}
+
+int SmsUtilPackGSMCode( BYTE* pOut, const char* szData, int in_len )
+{
+       int i;
+       int pos;
+       int shift = 0;
+       //shift = fill_bits;
+
+       //  memset( out, 0, out_len_max );
+
+       /* pack the ASCII characters
+       */
+       /*
+       if ( shift == 7 )
+               shift = 0;
+       */
+
+       for( pos = 0, i = 0; /*pos < out_len_max &&*/ i < in_len; pos++, i++ )
+       {
+               /* pack the low bits */
+               pOut[pos] = szData[i] >> shift;
+
+               if ( i + 1 < in_len )
+               {
+                       /* pack the high bits using the low bits of the next character */
+                       pOut[pos] |= szData[i+1] << ( 7 - shift );
+
+                       shift++;
+
+                       if( shift == 7 )
+                       {
+                               shift = 0;
+                               i++;
+                       }
+               }
+       }
+
+       /* done */
+       return pos;
+}
+
+
+void SmsUtilConvertBCD2Digit( char* pDigits, char* pBCD, int digitLen )
+{
+       int             i, bcdLen;
+       char    c[2];
+       unsigned char   higher, lower;
+
+       //SysDebug( ( MID_SMS, "__SmsConvertBCD2Digit: start.\n" ) );
+
+       if ( pBCD == NULL || pDigits == NULL )
+       {
+               printf("__SmsConvertBCD2Digit: pBCD == NULL || pDigits == NULL. return.\n"  );
+               return;
+       }
+
+       if ( digitLen == 0 )
+       {
+               //printf("__SmsConvertBCD2Digit: digitLen == 0. return.\n" );
+
+               pDigits[0] = 0x00;
+
+               return;
+       }
+
+       if ( digitLen % 2 )
+               bcdLen = digitLen / 2 + 1;
+       else
+               bcdLen = digitLen / 2;
+
+       memset( pDigits, 0, bcdLen * 2 );
+
+       for ( i = 0; i < bcdLen; i++ )
+       {
+               lower = pBCD[i] & 0x0F;                                 // get low nibble
+
+               if ( lower == 0x0A )
+                       lower = '*';
+               else if ( lower == 0x0B )
+                       lower = '#';
+               else if ( lower == 0x0C )
+                       lower = 'p';                    //DTMF Control pDigits seperator
+               else if ( lower == 0x0F )
+                       lower = 0;
+               else
+               {
+                       AcItoa( lower, c, 16 );
+                       lower = (char) AcToupper(c[0]);
+               }
+
+               higher = ( pBCD[i] >> 4 ) & 0x0F;                       // get high nibble
+
+               if ( higher == 0x0A )
+                       higher = '*';           // =0x2A
+               else if ( higher == 0x0B )
+                       higher = '#';           // =0x23
+               else if ( higher == 0x0C )
+                       higher = 'p';           // =0x70, DTMF Control pDigits seperator
+               else if ( higher == 0x0F ) // if higher semi-octet is 0x0F, filled bits.
+               {
+                       //higher = 0;
+                       sprintf(pDigits + strlen(pDigits), "%c", lower);
+                       pDigits[/*digitLen-1*/bcdLen*2-1] = '\0';
+
+                       //printf("__SmsConvertBCD2Digit: pDigits [%s].\n", pDigits  );
+
+                       return;
+               }
+               else
+               {
+                       AcItoa(higher, c, 16);
+                       higher = (char) AcToupper(c[0]);
+               }
+
+               //sprintf(pDigits, "%s%c%c", pDigits, lower, higher);
+               sprintf(pDigits + strlen(pDigits), "%c%c", lower, higher);
+       }
+
+       pDigits[digitLen] = '\0';
+
+       //printf("__SmsConvertBCD2Digit: pDigits [%s].\n", pDigits  );
+}
+
+
+void SmsUtilConvertDigit2BCD( char* pBCD, char* pDigits, int digitLen )
+{
+       int     i, j, digit;
+
+       unsigned char   higher, lower;
+
+       if ( pBCD == NULL || pDigits == NULL )
+               return;
+
+       // 0123456789 -> 1032547698
+       for ( i = 0, j = 0; i < digitLen; i = i + 2, j++ )
+       {
+               if ( pDigits[i] == '*' )
+                       digit = 0x0A;
+               else if ( pDigits[i] == '#' )
+                       digit = 0x0B;
+               else if ( AcToupper( pDigits[i] ) == 'P' )
+                       digit = 0x0C;
+               else
+                       digit = (int) ( pDigits[i] - '0' );
+
+               lower = digit & 0x0F;
+
+               if ( digitLen != i + 1 )
+               {
+                       if ( pDigits[i+1] == '*' )
+                               digit = 0x0A;
+                       else if ( pDigits[i+1] == '#' )
+                               digit = 0x0B;
+                       else if ( AcToupper( pDigits[i+1] ) == 'P' )
+                               digit = 0x0C;
+                       else
+                               digit = (int) ( pDigits[i+1] - '0' );
+
+                       higher = digit & 0x0F;
+               }
+               else
+               {
+                       higher = 0xFF;
+               }
+
+               pBCD[j] = ( higher << 4 ) | lower;
+       }
+}
+
+
+TmDateTime* SmsUtilDecodeTimeStamp(unsigned char * pTimeStamp, TmDateTime *tmDateTime )
+{
+       //TmDateTime tmDateTime;
+       char szBuf[3];
+       //UINT32        time;
+
+       if ( pTimeStamp == NULL )
+               return NULL;
+
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[0], 2 );
+       tmDateTime->year = atoi( szBuf ) + 2000;
+       if ( ( tmDateTime->year >= 1900 + MAX_YEAR )/* && ( tmDateTime->year < 2000 + BASE_YEAR )*/ )
+               tmDateTime->year -= 100;
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[1], 2 );
+       tmDateTime->month = atoi( szBuf );
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[2], 2 );
+       tmDateTime->day = atoi( szBuf );
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[3], 2 );
+       tmDateTime->hour = atoi( szBuf );
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[4], 2 );
+       tmDateTime->minute = atoi( szBuf );
+       SmsUtilConvertBCD2Digit( szBuf, (char*) &pTimeStamp[5], 2 );
+       tmDateTime->second = atoi( szBuf );
+
+       if ( ( tmDateTime->year < 1900 + BASE_YEAR ) || ( tmDateTime->year > 1900 + MAX_YEAR ) )
+               tmDateTime->year = 1900 + BASE_YEAR;
+
+       /*
+       time = TmDateTimeToSeconds( &tmDateTime );
+       if ( time > MAX_SECONDS )
+               time = MAX_SECONDS;
+
+       */
+
+       return tmDateTime;
+}
+
+unsigned char* SmsUtilEncodeTimeStamp( TmDateTime* tmDateTime, unsigned char* pTimeStamp )
+{
+       char szBuf[3];
+       int     year;
+
+       if ( pTimeStamp == NULL )
+               return NULL;
+
+       memset( (void*) pTimeStamp, 0x00, sizeof ( unsigned char ) * 7 );
+
+       year = tmDateTime->year - 2000;
+       if ( year < 0 )
+               year += 100;
+       
+       sprintf( szBuf, "%02d", year );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[0], szBuf, 2 );
+       sprintf( szBuf, "%02d", tmDateTime->month );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[1], szBuf, 2 );
+       sprintf( szBuf, "%02d", tmDateTime->day );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[2], szBuf, 2 );
+       sprintf( szBuf, "%02d", tmDateTime->hour );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[3], szBuf, 2 );
+       sprintf( szBuf, "%02d", tmDateTime->minute );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[4], szBuf, 2 );
+       sprintf( szBuf, "%02d", tmDateTime->second );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[5], szBuf, 2 );
+
+       sprintf( szBuf, "%02d", 0x00 );
+       SmsUtilConvertDigit2BCD( (char*) &pTimeStamp[6], szBuf, 2 );
+
+       return pTimeStamp;
+}
+
+void  SmsUtilDecodeAddrField_sca(char *diallingNum, unsigned char* pAddrField, int *result_ton, int *result_npi )
+{
+       int index = 0;
+       int  ton,npi;
+       int dialnumLen=0;
+       int length = 0;
+
+
+       ton = ( pAddrField[index+1] & 0x70 ) >> 4;
+       npi = pAddrField[index+1] & 0x0F;
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               // Origination/Destination address Çʵ忡¼­ÀÇ length´Â ½ÇÁ¦ address length
+               // origination/destination address ÇʵåÀΠ°æ¿ì length°¡ 0 ÀÏ ¶§¶óµµ number type/plan Çʵå´Â 0xFF °ªÀ» °®´Â´Ù.
+               //dialnumLen = pAddrField[index++];
+               length = pAddrField[index];
+               // º¸³»Áö ¾ÊÀº ¸Þ½ÃÁöÀÇ °æ¿ì¿¡´Â service center address°¡ ¾øÀ» ¼öµµ ÀÖ´Ù.
+               // ÀÌ °æ¿ì¿¡ length °¡ 0 À̸é number type, plan µµ ¾ø´Â °æ¿ì
+               // length °¡ 1 À̸é type, plan ¸¸ Àִ °æ¿ì
+               if ( length > 1 )
+               {
+                       dialnumLen = ( pAddrField[index++] - 1 ) * 2; // -1Àº TON/API Çʵå
+               }
+       }
+       else
+       {
+               dialnumLen = ( ( ( pAddrField[index++] + 1 ) / 2 ) * 8 ) / 7;
+       }
+
+
+
+
+       // SIM_SMSP_ADDRESS_LEN º¸´Ù address length °¡ Å©¸é SIM_SMSP_ADDRESS_LEN ¸¸Å­¸¸ º¯È¯À» ÇÑ´Ù.
+
+       if ( dialnumLen > SIM_SMSP_ADDRESS_LEN )
+       {
+               dialnumLen = SIM_SMSP_ADDRESS_LEN;
+       }
+
+       //printf(" dialnumLen = %d\n", dialnumLen  );
+
+       index++; /* ignore Type of Address field */
+
+       if (ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               SmsUtilConvertBCD2Digit( (char*)diallingNum, (char*) &pAddrField[index],dialnumLen );
+       }
+       else
+       {
+               SmsUtilUnpackGSMCode( diallingNum, &pAddrField[index],dialnumLen );
+
+       }
+
+
+       //printf(  "__SmsDecodeAddrField: diallingNum [%s].\n", (char*) diallingNum  );
+
+       *result_ton=ton;
+       *result_npi=npi;
+}
+
+
+void  SmsUtilDecodeAddrField_dst(char *diallingNum, unsigned char* pAddrField, int *result_ton, int *result_npi )
+{
+       int index = 0;
+       int  ton,npi;
+       int dialnumLen=0;
+
+       ton = ( pAddrField[index+1] & 0x70 ) >> 4;
+       npi = pAddrField[index+1] & 0x0F;
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               // Origination/Destination address Çʵ忡¼­ÀÇ length´Â ½ÇÁ¦ address length
+               // origination/destination address ÇʵåÀΠ°æ¿ì length°¡ 0 ÀÏ ¶§¶óµµ number type/plan Çʵå´Â 0xFF °ªÀ» °®´Â´Ù.
+               dialnumLen = pAddrField[index++];
+               
+       }
+       else
+       {
+               dialnumLen = ( ( ( pAddrField[index++] + 1 ) / 2 ) * 8 ) / 7;
+       }
+
+
+
+
+       // SIM_SMSP_ADDRESS_LEN º¸´Ù address length °¡ Å©¸é SIM_SMSP_ADDRESS_LEN ¸¸Å­¸¸ º¯È¯À» ÇÑ´Ù.
+
+       if ( dialnumLen > SIM_SMSP_ADDRESS_LEN )
+       {
+               dialnumLen = SIM_SMSP_ADDRESS_LEN;
+       }
+
+       //printf(" dialnumLen = %d\n", dialnumLen  );
+
+       index++; /* ignore Type of Address field */
+
+       if (ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               SmsUtilConvertBCD2Digit( (char*)diallingNum, (char*) &pAddrField[index],dialnumLen );
+       }
+       else
+       {
+               SmsUtilUnpackGSMCode( diallingNum, &pAddrField[index],dialnumLen );
+
+       }
+
+       *result_ton=ton;
+       *result_npi=npi;
+}
+
+int SmsReadSMSCfromSIM(unsigned char* pAddrFiled)
+{
+       int index = 0;
+       int i;
+       
+       pAddrFiled[index++] = 0x7; //there are 7 octets following
+       pAddrFiled[index++] = 0x91; //internatial format
+       for(i=0; i<6; i++)
+               pAddrFiled[index++]=0x11; // SMSC number stored in SIM is 111111111111
+               
+       return index;   
+}
+
+int  SmsUtilEncodeAddrField_sca(unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi)
+{
+       int index = 0;
+
+       if ( diallingNum == NULL || pAddrField == NULL )
+               return -1;
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               if ( dialnumLen % 2 )
+               {
+                       pAddrField[index++] = dialnumLen / 2 + 1 + 1; 
+               }
+               else
+               {
+                       pAddrField[index++] = dialnumLen / 2 + 1; 
+               }
+       }
+       else
+       {
+               pAddrField[index] = (unsigned char) ( ( ( dialnumLen * 7 + 7 ) / 8 ) * 2 );
+
+               if ( ( ( dialnumLen * 7 ) % 8 ) <= 4 )
+                       pAddrField[index]--;
+
+               printf(" addr len packet: %d out of SIM_TON_ALPAHA\n", pAddrField[index]);
+
+               index++;
+       }
+
+       SET_TON_NPI( pAddrField[index], ton, npi );
+
+       index++; 
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               SmsUtilConvertDigit2BCD( (char*) &pAddrField[index], (char*) diallingNum, dialnumLen );
+
+               if ( dialnumLen % 2 )
+                       index += dialnumLen / 2 + 1;
+               else
+                       index += dialnumLen / 2;
+       }
+       else
+       {
+               index += SmsUtilPackGSMCode( &pAddrField[index], (char *)diallingNum, (int) dialnumLen );
+       }
+
+       return index;
+}
+
+int  SmsUtilEncodeAddrField_dst(unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi )
+{
+       int index = 0;
+
+       if ( diallingNum == NULL || pAddrField == NULL )
+               return -1;
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               // Origination/Destination address Çʵ忡¼­ÀÇ length´Â ½ÇÁ¦ address length
+               pAddrField[index++] = (unsigned char)dialnumLen;
+               //printf(" addr len packet: %d\n", pAddrField[index]);
+       }
+       else
+       {
+               pAddrField[index] = (unsigned char) ( ( ( dialnumLen * 7 + 7 ) / 8 ) * 2 );
+
+               // ¸¶Áö¸· ¹ÙÀÌÆ®¿¡¼­ »óÀ§ 4ºñÆ®°¡ »ç¿ëµÇÁö ¾ÊÀ¸¸é length Çʵ尪À» -1À» ÇÑ´Ù.
+               if ( ( ( dialnumLen * 7 ) % 8 ) <= 4 )
+                       pAddrField[index]--;
+
+               printf(" addr len packet: %d out of SIM_TON_ALPAHA\n", pAddrField[index]);
+
+               index++;
+
+
+
+       }
+
+       SET_TON_NPI( pAddrField[index], ton, npi );
+
+       index++; // SET_TON_NPI °¡ MACRO À̹ǷΠ³»ºÎ¿¡¼­ Áõ°¡½ÃÅ°¸é ¹ö±×
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               SmsUtilConvertDigit2BCD( (char*) &pAddrField[index], (char*) diallingNum, dialnumLen );
+
+               if ( dialnumLen % 2 )
+                       index += dialnumLen / 2 + 1;
+               else
+                       index += dialnumLen / 2;
+       }
+       else
+       {
+               index += SmsUtilPackGSMCode( &pAddrField[index], (char *)diallingNum, (int) dialnumLen );
+       }
+
+       return index;
+}
+
+int  SmsUtilEncodeAddrField(unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi )
+{
+       int index = 0;
+
+       if ( diallingNum == NULL || pAddrField == NULL )
+               return -1;
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               // Origination/Destination address Çʵ忡¼­ÀÇ length´Â ½ÇÁ¦ address length
+               pAddrField[index++] = (unsigned char)dialnumLen;
+               //printf(" addr len packet: %d\n", pAddrField[index]);
+       }
+       else
+       {
+               pAddrField[index] = (unsigned char) ( ( ( dialnumLen * 7 + 7 ) / 8 ) * 2 );
+
+               // ¸¶Áö¸· ¹ÙÀÌÆ®¿¡¼­ »óÀ§ 4ºñÆ®°¡ »ç¿ëµÇÁö ¾ÊÀ¸¸é length Çʵ尪À» -1À» ÇÑ´Ù.
+               if ( ( ( dialnumLen * 7 ) % 8 ) <= 4 )
+                       pAddrField[index]--;
+
+               printf(" addr len packet: %d out of SIM_TON_ALPAHA\n", pAddrField[index]);
+
+               index++;
+
+
+
+       }
+
+       SET_TON_NPI( pAddrField[index], ton, npi );
+
+       index++; // SET_TON_NPI °¡ MACRO À̹ǷΠ³»ºÎ¿¡¼­ Áõ°¡½ÃÅ°¸é ¹ö±×
+
+       if ( ton != SIM_TON_ALPHA_NUMERIC )
+       {
+               SmsUtilConvertDigit2BCD( (char*) &pAddrField[index], (char*) diallingNum, dialnumLen );
+
+               if ( dialnumLen % 2 )
+                       index += dialnumLen / 2 + 1;
+               else
+                       index += dialnumLen / 2;
+       }
+       else
+       {
+               index += SmsUtilPackGSMCode( &pAddrField[index], (char *)diallingNum, (int) dialnumLen );
+       }
+
+       return index;
+}
+int SmsUtilDecodeScAddrField( SmsAddressInfo* pSmsAddrField, BYTE* pAddrField )
+{
+       printf("SmsUtilDecodeScAddrField\n");
+       int index = 0;
+       int length = 0;
+
+       //SysDebug( ( MID_SMS, "__SmsDecodeScAddrField: start.\n" ) );
+
+       if ( pSmsAddrField == NULL || pAddrField == NULL )
+       {
+               printf( "SmsUtilDecodeScAddrField: pSimAddrField or pAddrField is NULL.\n"  );
+
+               return 0;
+       }
+
+       // Service Center address Çʵ忡¼­ÀÇ length´Â µÚ¿¡ ³ª¿À´Â byteÀÇ ¼ö
+       // -> ½ÇÁ¦ address ±æÀ̴ TON/API ¹ÙÀÌÆ®¸¦ Á¦¿ÜÇÏ°í ³ª¸ÓÁö ¹ÙÀÌÆ®ÀÇ 2¹è or 2¹è - 1(½ÇÁ¦ ±æÀÌ°¡ È¦¼öÀΰæ¿ì)
+       length = pAddrField[index];
+       // º¸³»Áö ¾ÊÀº ¸Þ½ÃÁöÀÇ °æ¿ì¿¡´Â service center address°¡ ¾øÀ» ¼öµµ ÀÖ´Ù.
+       // ÀÌ °æ¿ì¿¡ length °¡ 0 À̸é number type, plan µµ ¾ø´Â °æ¿ì
+       // length °¡ 1 À̸é type, plan ¸¸ Àִ °æ¿ì
+       if ( length > 1 )
+       {
+               pSmsAddrField->dialnumLen = ( pAddrField[index++] - 1 ) * 2; // -1Àº TON/API Çʵå
+
+               // SIM_SMSP_ADDRESS_LEN º¸´Ù address length °¡ Å©¸é SIM_SMSP_ADDRESS_LEN ¸¸Å­¸¸ º¯È¯À» ÇÑ´Ù.
+               if ( pSmsAddrField->dialnumLen > SIM_SMSP_ADDRESS_LEN )
+               {
+                       pSmsAddrField->dialnumLen = SIM_SMSP_ADDRESS_LEN;
+               }
+
+               pSmsAddrField->ton = ( pAddrField[index] & 0x70 ) >> 4;
+               pSmsAddrField->npi = pAddrField[index] & 0x0F;
+
+               index++; /* ignore Type of Address field */
+
+               SmsUtilConvertBCD2Digit( (char*) pSmsAddrField->diallingNum, (char*) &pAddrField[index], pSmsAddrField->dialnumLen );
+
+               printf( "SmsUtilDecodeScAddrField: diallingNum [%s].\n", (char*) pSmsAddrField->diallingNum  );
+
+               printf( "length=%d , ton %d, npi =%d\n",pSmsAddrField->dialnumLen, pSmsAddrField->ton,pSmsAddrField->npi );
+       }
+
+       return ++length;
+}
+
+ int  SmsUtilEncodeScAddrField( BYTE* pAddrField, SmsAddressInfo * pSmsAddrField )
+{
+       int index = 0;
+
+       if ( pSmsAddrField == NULL || pAddrField == NULL )
+               return -1;
+
+       // Service Center address Çʵ忡¼­ÀÇ length´Â µÚ¿¡ ³ª¿À´Â byteÀÇ ¼ö
+       // -> ½ÇÁ¦ address ±æÀ̴ TON/API ¹ÙÀÌÆ®¸¦ Á¦¿ÜÇÏ°í ³ª¸ÓÁö ¹ÙÀÌÆ®ÀÇ 2¹è or 2¹è - 1(½ÇÁ¦ ±æÀÌ°¡ È¦¼öÀΰæ¿ì)
+       if ( pSmsAddrField->dialnumLen % 2 )
+       {
+               pAddrField[index++] = pSmsAddrField->dialnumLen / 2 + 1 + 1; // +1 Àº TON/NPI Çʵå, È¦¼ö°³ÀΠ°æ¿ì´Â °³¼ö¸¦ ¸ÂÃß±â À§ÇØ Çѹø ´õ +1
+       }
+       else
+       {
+               pAddrField[index++] = pSmsAddrField->dialnumLen / 2 + 1; // +1 Àº TON/NPI Çʵå
+       }
+
+       SET_TON_NPI( pAddrField[index], pSmsAddrField->ton, pSmsAddrField->npi );
+
+       index++; // SET_TON_NPI °¡ MACRO À̹ǷΠ³»ºÎ¿¡¼­ Áõ°¡½ÃÅ°¸é ¹ö±×¹ß»ý
+
+       SmsUtilConvertDigit2BCD( (char*) &pAddrField[index], (char*) pSmsAddrField->diallingNum, pSmsAddrField->dialnumLen );
+
+       if ( pSmsAddrField->dialnumLen % 2 )
+               index += pSmsAddrField->dialnumLen / 2 + 1;
+       else
+               index += pSmsAddrField->dialnumLen / 2;
+
+       return index;
+}
+
+void SmsUtilDecodeDCS( TapiNetTextCodingScheme* pCodingScheme,   unsigned char dcs )
+{
+       assert( pCodingScheme != NULL );
+
+       memset( pCodingScheme, 0, sizeof ( TapiNetTextCodingScheme ) );
+
+       if ( dcs < 0x40 ) // bits 7..4 = 00xx : general data coding indication
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS;
+
+               if ( dcs & 0x20 ) // bit 5 = 1 : indicates the text is compressed
+                       pCodingScheme->bCompressed = TRUE;
+
+               if ( dcs & 0x10 ) // bit 4 = 1 : indicates that bits  1 to 0 have a message class meaning
+               {
+                       pCodingScheme->bMsgClassSet = TRUE;
+
+                       switch ( dcs & 0x03 ) // bits 1 to 0 : message class
+                       {
+                               case 0x00:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_0;
+                                       break;
+                               case 0x01:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_1;
+                                       break;
+                               case 0x02:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_2;
+                                       break;
+                               case 0x03:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_3;
+                                       break;
+                       }
+               }
+               else // bit 4 = 0 : indicates that bits 1 to 0 are reserved and have no message class meaning
+                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_NONE;
+
+               switch ( dcs & 0x0C ) // bits 4 to 3 : character set
+               {
+                       case 0x00:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_DEFAULT;
+                               break;
+                       case 0x04:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_8BIT;
+                               break;
+                       case 0x08:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_UCS2;
+                               break;
+                       case 0x0C:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_MAX;
+                               break;
+               }
+       }
+       else if ( dcs >= 0x40 && dcs < 0x80 ) // bits 7..4 = 01xx : message marked for automatic deletion group. bits 5..0 are coded exactly the same as group 00xx
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_AUTO_DELETION;
+
+               if ( dcs & 0x20 ) // bit 5 = 1 : indicates the text is compressed
+                       pCodingScheme->bCompressed = TRUE;
+
+               if ( dcs & 0x10 ) // bit 4 = 1 : indicates that bits  1 to 0 have a message class meaning
+               {
+                       pCodingScheme->bMsgClassSet = TRUE;
+
+                       switch ( dcs & 0x03 ) // bits 1 to 0 : message class
+                       {
+                               case 0x00:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_0;
+                                       break;
+                               case 0x01:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_1;
+                                       break;
+                               case 0x02:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_2;
+                                       break;
+                               case 0x03:
+                                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_3;
+                                       break;
+                       }
+               }
+               else // bit 4 = 0 : indicates that bits 1 to 0 are reserved and have no message class meaning
+                       pCodingScheme->classType = TAPI_NETTEXT_CLASS_NONE;
+
+               switch ( dcs & 0x0C ) // bits 4 to 3 : character set
+               {
+                       case 0x00:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_DEFAULT;
+                               break;
+                       case 0x04:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_8BIT;
+                               break;
+                       case 0x08:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_UCS2;
+                               break;
+                       case 0x0C:
+                               pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_MAX;
+                               break;
+               }
+       }
+       // bits 7..4 = 1000 ~ 1011 : reserved
+       else if ( dcs == 0xC0 ) // bits 7..4 = 1100 : message waiting indication group, discard message
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_WAITING_DISCARD;
+       }
+       else if ( dcs < 0xE0 )
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_WAITING_STORE;
+
+               if ( dcs & 0x08 )
+                       pCodingScheme->bMsgIndActive = TRUE;
+
+               switch ( dcs & 0x03 )
+               {
+                       case 0x00:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_VOICE_MSG;
+                               break;
+                       case 0x01:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_FAX_MSG;
+                               break;
+                       case 0x02:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_EMAIL_MSG;
+                               break;
+                       case 0x03:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_OTHER_MSG;
+                               break;
+               }
+       }
+       else if ( dcs < 0xF0 )
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_WAITING_STORE_UCS2;
+
+               if ( dcs & 0x08 )
+                       pCodingScheme->bMsgIndActive = TRUE;
+
+               switch ( dcs & 0x03 )
+               {
+                       case 0x00:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_VOICE_MSG;
+                               break;
+                       case 0x01:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_FAX_MSG;
+                               break;
+                       case 0x02:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_EMAIL_MSG;
+                               break;
+                       case 0x03:
+                               pCodingScheme->waitingType = TAPI_NETTEXT_WAITING_OTHER_MSG;
+                               break;
+               }
+       }
+       else
+       {
+               pCodingScheme->codingGroupType = TAPI_NETTEXT_CODGRP_SM_CLASS_CODING;
+
+               if ( dcs & 0x04 )
+                       pCodingScheme->alphabetType = TAPI_NETTEXT_ALPHABET_8BIT;
+
+               switch ( dcs & 0x03 )
+               {
+                       case 0x00:
+                               pCodingScheme->classType = TAPI_NETTEXT_CLASS_0;
+                               break;
+                       case 0x01:
+                               pCodingScheme->classType = TAPI_NETTEXT_CLASS_1;
+                               break;
+                       case 0x02:
+                               pCodingScheme->classType = TAPI_NETTEXT_CLASS_2;
+                               break;
+                       case 0x03:
+                               pCodingScheme->classType = TAPI_NETTEXT_CLASS_3;
+                               break;
+               }
+       }
+}
+
+void SmsUtilEncodeDCS( BYTE* pDCS, TapiNetTextCodingScheme* pCodingScheme )
+{
+       BYTE dcs = 0x00;
+
+       assert( pCodingScheme != NULL );
+
+       switch ( pCodingScheme->codingGroupType )
+       {
+               case TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS: // bit 7..4 is 00xx
+               {
+                       if ( pCodingScheme->bCompressed )
+                               dcs |= 0x20; // bit 5 is 1
+
+                       if ( pCodingScheme->bMsgClassSet )
+                       {
+                               dcs |= 0x10; // bit 4 is 1
+
+                               switch ( pCodingScheme->classType )
+                               {
+                                       case TAPI_NETTEXT_CLASS_0: // bit 1..0 is 00
+                                       {
+                                               dcs |= 0x00;
+                                               break;
+                                       }
+                                       case TAPI_NETTEXT_CLASS_1: // bit 1..0 is 01
+                                       {
+                                               dcs |= 0x01;
+                                               break;
+                                       }
+                                       case TAPI_NETTEXT_CLASS_2: // bit 1..0 is 10
+                                       {
+                                               dcs |= 0x02;
+                                               break;
+                                       }
+                                       case TAPI_NETTEXT_CLASS_3: // bit 1..0 is 11
+                                       {
+                                               dcs |= 0x03;
+                                               break;
+                                       }
+                                       default:
+                                           break;
+                               }
+                       }
+
+                       switch ( pCodingScheme->alphabetType )
+                       {
+                               case TAPI_NETTEXT_ALPHABET_DEFAULT: // bit 3..2 is 00
+                               {
+                                       dcs |= 0x00;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_ALPHABET_8BIT: // bit 3..2 is 01
+                               {
+                                       dcs |= 0x04;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_ALPHABET_UCS2: // bit 3..2 is 10
+                               {
+                                       dcs |= 0x08;
+                                       break;
+                               }
+                               default: // bit 3..2 is 11
+                               {
+                                       dcs |= 0x0C;
+                                       break;
+                               }
+                       }
+
+                       break;
+               }
+               case TAPI_NETTEXT_CODGRP_SM_WAITING_DISCARD: // bit 7..4 is 1100
+               {
+                       dcs |= 0xC0;
+
+                       break;
+               }
+               case TAPI_NETTEXT_CODGRP_SM_WAITING_STORE: // bit 7..4 is 1101
+               {
+                       dcs |= 0xD0;
+
+                       if ( pCodingScheme->bMsgIndActive ) // bit 3..2 is 10
+                               dcs |= 0x08;
+
+                       switch ( pCodingScheme->waitingType )
+                       {
+                               case TAPI_NETTEXT_WAITING_VOICE_MSG: // bit 1..0 is 00
+                               {
+                                       dcs |= 0x00;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_FAX_MSG: // bit 1..0 is 01
+                               {
+                                       dcs |= 0x01;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_EMAIL_MSG: // bit 1..0 is 10
+                               {
+                                       dcs |= 0x02;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_OTHER_MSG: // bit 1..0 is 11
+                               {
+                                       dcs |= 0x03;
+                                       break;
+                               }
+                               default:
+                                   break;
+                       }
+
+                       break;
+               }
+               case TAPI_NETTEXT_CODGRP_SM_WAITING_STORE_UCS2: // bit 7..4 is 1110
+               {
+                       dcs |= 0xE0;
+
+                       if ( pCodingScheme->bMsgIndActive ) // bit 3..2 is 10
+                               dcs |= 0x08;
+
+                       switch ( pCodingScheme->waitingType )
+                       {
+                               case TAPI_NETTEXT_WAITING_VOICE_MSG: // bit 1..0 is 00
+                               {
+                                       dcs |= 0x00;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_FAX_MSG: // bit 1..0 is 01
+                               {
+                                       dcs |= 0x01;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_EMAIL_MSG: // bit 1..0 is 10
+                               {
+                                       dcs |= 0x02;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_WAITING_OTHER_MSG: // bit 1..0 is 11
+                               {
+                                       dcs |= 0x03;
+                                       break;
+                               }
+                               default:
+                                   break;
+                       }
+
+                       break;
+               }
+               case TAPI_NETTEXT_CODGRP_SM_CLASS_CODING: // bit 7..4 is 1111
+               {
+                       dcs |= 0xF0;
+
+                       switch ( pCodingScheme->alphabetType )
+                       {
+                               case TAPI_NETTEXT_ALPHABET_DEFAULT: // bit 2 is 0
+                               {
+                                       dcs |= 0x00;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_ALPHABET_8BIT: // bit 2 is 1
+                               {
+                                       dcs |= 0x04;
+                                       break;
+                               }
+                               default:
+                                   break;
+                       }
+
+                       switch ( pCodingScheme->classType )
+                       {
+                               case TAPI_NETTEXT_CLASS_0: // bit 1..0 is 00
+                               {
+                                       break;
+                               }
+                               case TAPI_NETTEXT_CLASS_1: // bit 1..0 is 01
+                               {
+                                       dcs |= 0x01;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_CLASS_2: // bit 1..0 is 10
+                               {
+                                       dcs |= 0x02;
+                                       break;
+                               }
+                               case TAPI_NETTEXT_CLASS_3: // bit 1..0 is 11
+                               {
+                                       dcs |= 0x03;
+                                       break;
+                               }
+                               default:
+                                   break;
+                       }
+
+                       break;
+               }
+               case TAPI_NETTEXT_CODGRP_SM_RESERVED: // bit 7..4 is 1111
+               {
+                   dcs = (pCodingScheme->codingGroup << 4) & 0xF0;
+                   dcs |= (pCodingScheme->code & 0x0F);
+                   break;
+               }
+               default:
+                   break;
+       }
+
+       memcpy( pDCS, &dcs, sizeof ( BYTE ) );
+}
+
+ UINT8 SmsUtilEncodeValidity( BYTE* pValidity, TapiNetTextVP* pVP )
+{
+       UINT8   pos = 0;
+
+       switch( pVP->vpType )
+       {
+               case TAPI_NETTEXT_VP_NOT_USED:
+                       break;
+
+               case TAPI_NETTEXT_VP_RELATIVE:
+                       pValidity[pos] = (UINT8) pVP->vpValue;
+                       pos ++;
+                       break;
+
+               case TAPI_NETTEXT_VP_ABSOLUTE:
+                       //TO DO
+                       //SmsUtilEncodeTimeStamp( pValidity, pVP->vpValue );
+                       pos += 7;
+                       break;
+
+               case TAPI_NETTEXT_VP_ENHANCED:
+                       break;
+       }
+
+       return pos;
+}
+
diff --git a/lib/libsms/sms_util.h b/lib/libsms/sms_util.h
new file mode 100644 (file)
index 0000000..fa896f0
--- /dev/null
@@ -0,0 +1,351 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SMS_UTIL_H_
+#define _SMS_UTIL_H_
+
+#include "sms_header.h"
+
+//#include <linuxtapi.h>
+
+#define        SIM_TON_UNKNOWN                                 0 //unknown
+#define        SIM_TON_INTERNATIONAL                           1 //international number
+#define        SIM_TON_NATIONAL                                        2 //national number
+#define        SIM_TON_NETWORK_SPECIFIC                        3 //natwork specific number
+#define        SIM_TON_DEDICATED_ACCESS                        4 //subscriber number
+#define        SIM_TON_ALPHA_NUMERIC                           5//alphanumeric, GSM 7-bit default alphabet)
+#define        SIM_TON_ABBREVIATED_NUMBER              6 //abbreviated number
+#define        SIM_TON_RESERVED_FOR_EXT                        7 //reserved for extension
+
+
+#define MAX_UDH_LEN            137 
+#define UDH_MAX                                7
+#define SMDATA_SIZE_MAX        160
+
+
+#define FAIL                   0x00
+#define SUCCESS                0x01
+//////////////////////////////////TPDU type////////////////////////////////
+typedef enum 
+{
+       SMS_TPDU_DELIVER                                = 0x00, // sc -> ms
+       SMS_TPDU_DELIVER_REPORT         = 0x00, // ms -> sc
+       SMS_TPDU_SUBMIT                         = 0x01, // ms -> sc
+       SMS_TPDU_SUBMIT_REPORT          = 0x01, // sc -> ms
+       SMS_TPDU_STATUS_REPORT          = 0x02, // sc -> ms
+       SMS_TPDU_COMMAND                                = 0x02, // ms -> sc
+       SMS_PDU_INVALID_TYPE
+       
+} SmsTPDUType;
+
+typedef struct
+{
+       int             year;
+       int             month;
+       int             day;
+       int             hour;
+       int             minute;
+       int             second;
+       
+} TmDateTime;
+
+
+#define BASE_YEAR              70L                                     /* 1970 is the base year */
+#define MAX_YEAR                       130L                                    /* 2030 is the max year */
+
+
+#define        SIM_SMSP_ADDRESS_LEN                                    20      // digit length
+
+#define SET_TON_NPI(dest, ton, npi) {  \
+       dest = 0x80;                                            \
+       dest |= (ton & 0x07) << 4;                      \
+       dest |= npi & 0x0F;                                     \
+}
+
+
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType ;   //bit 0 ,1
+
+       // reject duplicates [M]
+       BOOL rd ;  // bit 2
+
+       // validity period format [M]
+       TapiNetTextVPType vpf ; //  bits 3, 4
+
+       // reply path [M]
+       BOOL rp ; //bit 7
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       // status report request
+       BOOL  srr ;  // bit 5
+
+       /************BODY************/
+
+       //message reference [M]
+       UINT mr;
+
+       // destination address [M]
+       SmsAddressInfo desAddr;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme [M]
+       TapiNetTextCodingScheme dcs;
+
+       // validity period
+       TapiNetTextVP vp;
+
+       // user data length [M]
+       UINT32 udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT;
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType;  //bit 0 ,1
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       /************BODY************/
+
+       // failure Cause [M]
+        UINT   fcs;
+
+       // parameter indicator [M]
+       BYTE paraInd;
+
+       // service centre time stamp [M]
+       TmDateTime scts;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme 
+       TapiNetTextCodingScheme dcs;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT_REPORT;
+
+
+typedef struct
+{      
+       /************HEADER************/
+       SmsTPDUType msgType;   //bit 0 ,1
+       
+       BOOL mms; // bit 2 
+       
+       BOOL rp; // bit 7 
+       
+       BOOL udhi;  //bit 6
+       
+       BOOL sri; // bit , 5status_report_indication
+       
+       /************BODY************/
+
+       SmsAddressInfo orgAddr;
+
+       BYTE  pId;
+
+       TmDateTime scts;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE  * userData;
+       
+}TPDU_SMS_DELIVER;
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ;  //bit 6
+       
+       /************BODY************/
+
+       UINT fcs;
+
+       BYTE paraInd;
+
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_DELIVER_REPORT;
+
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ; //bit 6
+
+       BOOL srr; //bit 5, status_report_request
+
+       /************BODY************/
+
+       UINT  mr; //message_ref
+
+       BYTE pId;
+
+       BYTE cmdType;
+
+       BYTE msgNum;
+
+       SmsAddressInfo destAddr;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_COMMAND;
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL  udhi ; //bit 6
+
+       BOOL mms ; //bit 2
+
+       BOOL srq; //bit 5, status_report_qualifier
+
+       /************BODY************/
+       
+       UINT  mr;
+
+       SmsAddressInfo rcpAddr; //recipient_addr
+
+       TmDateTime scts;
+
+       TmDateTime dt; //discharge_time
+
+        BYTE  status;
+       
+        BYTE paraInd;
+               
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_STATUS_REPORT;
+
+#define CB_GSM                 0x01
+#define CB_UMTS        0x02
+
+typedef struct
+{
+       BYTE            accessNetwork;                          //GSM or UMTS
+       BYTE            messageType;                            //!< The type of cellbroadcast message. [only UMTS use]
+       UINT            messageId;                                      //!< The source and type of cellbroadcast message.
+       BYTE            geographicalScope;                    //!< The geographical area over which the cellbroadcast message is sent.
+       BYTE            updateNumber;                           //!< Identifies a change of the message content of the same cellbroadcast message.
+       UINT            messageCode;                            //!< Identifies different message themes.
+       BYTE            language;                                       //!< Language of the cellbroadcast message content.
+       BYTE            messageClass;                           //!< Class of the cellbroadcast message.
+       BYTE            page;
+
+       BYTE      *     message;
+       
+}CELLBROADCASTING;  //june
+
+
+
+/**************************************************************************************
+*** (main.c) function header****************************************************************
+***************************************************************************************
+***************************************************************************************/
+
+BOOL EncodeSmsDeliverTpdu(SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, char *rawdata, int *rawdata_len, BYTE pid);
+BOOL EncodeSmsSubmitReportTpdu(unsigned char *rawdata, int *rawdata_len);
+int DecodeSmsSubmitTpdu(TPDU_SMS_SUBMIT *tpdu_submit, int pdu_len , char * pPDU, int MO_sms);
+BOOL EncodeCB_GSM(CELLBROADCASTING cb_msg, char *rawdata, int *rawdata_len);
+
+/***************************************************************************************/
+void reverse(char* x, int len);
+char* AcItoa(int n, char* str, int b) ;
+int AcToupper(int ch);
+
+int SmsUtilUnpackGSMCode( char* szData, const BYTE* pIn, int in_len );
+int SmsUtilPackGSMCode( BYTE* pOut, const char* szData, int in_len );
+
+void SmsUtilConvertBCD2Digit( char* pDigits, char* pBCD, int digitLen );
+void SmsUtilConvertDigit2BCD( char* pBCD, char* pDigits, int digitLen );
+
+TmDateTime* SmsUtilDecodeTimeStamp( unsigned char* pTimeStamp, TmDateTime *tmDateTime );
+unsigned char* SmsUtilEncodeTimeStamp( TmDateTime* tmDateTime, unsigned char* pTimeStamp );
+
+
+void  SmsUtilDecodeAddrField(char *diallingNum, unsigned char * pAddrField, int *result_ton, int *result_npi );
+int SmsUtilEncodeAddrField( unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi );
+
+int SmsUtilDecodeScAddrField( SmsAddressInfo* pSmsAddrField, BYTE* pAddrField );
+int SmsUtilEncodeScAddrField( BYTE* pAddrField, SmsAddressInfo * pSmsAddrField );
+void SmsUtilDecodeDCS( TapiNetTextCodingScheme* pCodingScheme,   unsigned char dcs );
+void SmsUtilEncodeDCS( BYTE* pDCS, TapiNetTextCodingScheme* pCodingScheme);
+
+UINT8 SmsUtilEncodeValidity( BYTE* pValidity, TapiNetTextVP* pVP );
+
+#endif /* _SMS_UTIL_H_ */
diff --git a/lib/libui/Makefile.in b/lib/libui/Makefile.in
new file mode 100644 (file)
index 0000000..fed8756
--- /dev/null
@@ -0,0 +1,36 @@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS   = @GLIB_LIBS@
+
+GTK_CFLAGS  = @GTK_CFLAGS@
+GTK_LIBS    = @GTK_LIBS@
+
+XML_CFLAGS  = @XML_CFLAGS@
+XML_LIBS    = @XML_LIBS@
+
+CC = @CC@
+AR = @AR@
+
+CFLAGS  = @CFLAGS@
+CFLAGS += $(GLIB_CFLAGS) $(GTK_CFLAGS) $(XML_CFLAGS) -DISE_LOGGING -DISE_DEBUG
+LIBS   = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS)
+
+OBJS = \
+       utils.o \
+       dialog.o \
+       imageutil.o
+       
+
+.SUFFIXES: .c
+
+.c.o:
+       $(CC) -c $(CFLAGS) -o $@ $<
+
+all: libui.a
+
+libui.a: $(OBJS)
+       $(AR) r libui.a $(OBJS)
+
+clean:
+       rm -rf *.o *.a
+
+
diff --git a/lib/libui/dialog.c b/lib/libui/dialog.c
new file mode 100644 (file)
index 0000000..0d4056a
--- /dev/null
@@ -0,0 +1,550 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+       @file   dialog.c
+       @brief  miscellaneous functions
+*/
+
+#include "dialog.h"
+
+
+/**
+ * @brief   show message dialog
+ * @param   dialog title 
+ * @param   dialog message 
+ * @date    Nov 21. 2008
+ * */
+gchar current_filename[255];
+
+void show_message(const char *szTitle, const char *szMessage)
+{
+       GtkWidget *label;
+       GtkWidget *button;
+       GtkWidget *dialog_window;
+       PangoFontDescription *pPangoFont = NULL;
+
+       /* create Dialog */
+       
+       dialog_window = gtk_dialog_new();
+
+       /* Widget Icon set */
+
+       GdkPixbuf* tmppixbuf = NULL;
+       tmppixbuf=gtk_widget_render_icon((GtkWidget *) (dialog_window), GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU, NULL);
+       gtk_window_set_icon(GTK_WINDOW (dialog_window), tmppixbuf);
+
+       /* set Title and Border */
+       
+       gtk_window_set_title(GTK_WINDOW(dialog_window), szTitle);
+       gtk_container_set_border_width(GTK_CONTAINER(dialog_window), 0);
+
+       /* create OK Button and Set Reponse */
+       
+       button = gtk_dialog_add_button(GTK_DIALOG(dialog_window), GTK_STOCK_OK, GTK_RESPONSE_OK);
+
+       /* set OK Button to Default Button */
+       
+       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_grab_default(button);
+
+       /* create Label */
+       
+       label = gtk_label_new(szMessage);
+
+       /* set Mono Space Font */
+       
+       pPangoFont = pango_font_description_from_string("Monospace 11");
+       gtk_widget_modify_font(label, pPangoFont);
+
+       /* set Padding arround Label */ 
+       
+       gtk_misc_set_padding(GTK_MISC(label), 10, 10);
+
+       /* pack Label to Dialog */
+       
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox), label, TRUE, TRUE, 0);
+
+       gtk_widget_show_all(dialog_window);
+
+       gtk_dialog_run(GTK_DIALOG(dialog_window));
+
+       gtk_widget_destroy(dialog_window);
+}
+
+
+void show_message_for_qemu(const char *szTitle, const char *szMessage)
+{
+       GtkWidget *label;
+       GtkWidget *button;
+       GtkWidget *dialog_window;
+       PangoFontDescription *pPangoFont = NULL;
+
+       /* create Dialog */
+       
+       dialog_window = gtk_dialog_new();
+
+       /* Widget Icon set */
+
+       GdkPixbuf* tmppixbuf = NULL;
+       tmppixbuf=gtk_widget_render_icon((GtkWidget *) (dialog_window), GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU, NULL);
+       gtk_window_set_icon(GTK_WINDOW (dialog_window), tmppixbuf);
+
+       /* set Title and Border */
+       
+       gtk_window_set_title(GTK_WINDOW(dialog_window), szTitle);
+       gtk_container_set_border_width(GTK_CONTAINER(dialog_window), 0);
+
+       /* create OK Button and Set Reponse */
+       
+       button = gtk_dialog_add_button(GTK_DIALOG(dialog_window), GTK_STOCK_OK, GTK_RESPONSE_OK);
+
+       /* set OK Button to Default Button */
+       
+       GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+       gtk_widget_grab_default(button);
+
+       /* create Label */
+       
+       label = gtk_label_new(szMessage);
+
+       /* set Mono Space Font */
+       
+       pPangoFont = pango_font_description_from_string("Monospace 11");
+       gtk_widget_modify_font(label, pPangoFont);
+
+       /* set Padding arround Label */ 
+       
+       gtk_misc_set_padding(GTK_MISC(label), 10, 10);
+
+       /* pack Label to Dialog */
+       
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox), label, TRUE, TRUE, 0);
+
+       gtk_widget_show_all(dialog_window);
+
+    g_signal_connect_swapped (dialog_window, "response", G_CALLBACK (gtk_widget_destroy),
+                             (gpointer) dialog_window);
+
+       g_signal_connect_swapped (dialog_window, "delete-event", G_CALLBACK (gtk_widget_destroy),
+                             (gpointer) dialog_window);
+
+//     gtk_dialog_run(GTK_DIALOG(dialog_window));
+
+//     gtk_widget_destroy(dialog_window);
+}
+
+
+/**
+ * @brief   remove show message window
+ * @param   widget: wiget to remove
+ * @return  data: pointer to data
+ * @date    Nov 21. 2008
+ * */
+void clear_show_message(GtkWidget *widget, gpointer data)
+{
+       gtk_grab_remove(widget);
+}
+
+
+/**
+ * @brief   dialog for file open
+ * @param   title: title of dialog
+ * @param      parent: parent window
+ * @param      ext: extension of file to filter
+ * @param   call_back: callback function called when OK clicked
+ * @date    Nov 21. 2008
+ * */
+void file_open_dialog (gchar *title, GtkWindow *parent, gchar *ext, void (*call_back) (gchar *))
+{
+    GtkWidget *file_chooser = gtk_file_chooser_dialog_new (title,
+                                                          parent,
+                                                          GTK_FILE_CHOOSER_ACTION_OPEN,
+                                                          GTK_STOCK_CANCEL,
+                                                          GTK_RESPONSE_CANCEL,
+                                                          GTK_STOCK_OPEN,
+                                                          GTK_RESPONSE_ACCEPT,
+                                                          NULL);
+
+       /* path setting (20090310) */
+       gchar *ptr = get_bin_path();
+
+       if ((ptr != NULL) && (strlen(ptr) > 1))
+               if ((current_filename == NULL) || (strlen(current_filename) < 1))
+                       snprintf(current_filename, sizeof(current_filename), "%s", ptr);
+
+       g_free(ptr);
+    gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), current_filename);
+
+    if (ext) {
+               char *t;
+               GtkFileFilter *filter;
+               filter = gtk_file_filter_new ();
+
+               t = g_malloc (strlen (ext) + 1);
+               strcpy (t, ext);
+
+               gtk_file_filter_add_pattern (filter, t);
+               gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_chooser), filter);
+    }
+
+    if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) {
+               gchar *filename, *t;
+               filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
+
+               t = (gchar *) g_malloc (strlen (filename) + 1);
+               strcpy (t, filename);
+               call_back (t);
+               g_free (filename);
+    }
+
+    gtk_widget_destroy (file_chooser);
+
+
+}
+
+
+/**
+ * @brief   dialog for file save
+ * @param   title: title of dialog
+ * @param      parent: parent window
+ * @param      default_filename: default filename for save
+ * @param   ext: extension of file to filter
+ * @param   call_back: callback function called when OK clicked
+ * @date    Nov 21. 2008
+ * */
+void file_save_dialog (gchar *title, GtkWindow *parent, gchar *default_filename, gchar *ext, void (*call_back) (gchar *))
+{
+    GtkWidget *file_chooser = gtk_file_chooser_dialog_new (title,
+                                                          parent,
+                                                          GTK_FILE_CHOOSER_ACTION_SAVE,
+                                                          GTK_STOCK_CANCEL,
+                                                          GTK_RESPONSE_CANCEL,
+                                                          GTK_STOCK_SAVE,
+                                                          GTK_RESPONSE_ACCEPT,
+                                                          NULL);
+
+    if (ext) {
+               GtkFileFilter *filter;
+               filter = gtk_file_filter_new ();
+
+               gtk_file_filter_add_pattern (filter, ext);
+               gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_chooser), filter);
+    }
+
+    if (default_filename)
+               gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_chooser), default_filename);
+
+       /* path setting (20090310) */
+       gchar *ptr = get_bin_path();
+
+       if ((ptr != NULL) && (strlen(ptr) > 1))
+               if ((current_filename == NULL) || (strlen(current_filename) < 1))
+                       snprintf(current_filename, sizeof(current_filename), "%s", ptr);
+
+       g_free(ptr);
+    gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), current_filename);
+
+    if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) {
+               gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
+               strncpy(current_filename, filename, sizeof(current_filename));
+               call_back (filename);
+               g_free (filename);
+    }
+       
+    gtk_widget_destroy (file_chooser);
+}
+
+
+/**
+ * @brief   dialog for get name
+ * @param   dlg_title: title of dialog
+ * @param      dlg_label: label of dialog
+ * @param      call_back: callback function called when OK clicked
+ * @return     dialog window widget
+ * @date    Nov 21. 2008
+ * */
+GtkWidget *input_name_dialog (gchar *dlg_title, gchar *dlg_label, void (*call_back) (GtkWidget *, gpointer))
+{
+    GtkWidget *dlg;
+
+    dlg = gtk_dialog_new ();
+
+    gtk_window_set_title (GTK_WINDOW (dlg), (dlg_title));
+    gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+    gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+    GtkWidget *vbox, *hbox;
+    vbox = GTK_DIALOG (dlg)->vbox;
+
+
+    GtkWidget *label;
+
+    label = gtk_label_new (_(dlg_label));
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+
+    hbox = gtk_hbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+    label = gtk_label_new (_("Name : "));
+    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new ();
+    gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *dlg_action_area = GTK_DIALOG (dlg)->action_area;
+    gtk_button_box_set_layout (GTK_BUTTON_BOX (dlg_action_area), GTK_BUTTONBOX_END);
+
+    GtkWidget *cancel_btn = gtk_button_new_from_stock ("gtk-cancel");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), cancel_btn, GTK_RESPONSE_CANCEL);
+    GTK_WIDGET_SET_FLAGS (cancel_btn, GTK_CAN_DEFAULT);
+
+    GtkWidget *ok_btn = gtk_button_new_from_stock ("gtk-ok");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), ok_btn, GTK_RESPONSE_OK);
+    gtk_widget_show_all (dlg);
+
+    g_signal_connect ((gpointer) ok_btn, "clicked", G_CALLBACK (call_back), (gpointer) entry);
+    g_signal_connect_swapped ((gpointer) ok_btn, "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) dlg);
+    g_signal_connect_swapped ((gpointer) cancel_btn, "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) dlg);
+
+    return dlg;
+}
+
+
+/**
+       @brief  dialog for rename dialog
+       @param  default_text: default text
+       @param  dlg_title: diglog title
+       @param  dlg_label: dialog label
+       @param  call_back: callback function called when OK clicked
+       @return dialog window widget
+*/
+GtkWidget *rename_dialog (gchar *default_text, gchar *dlg_title, gchar *dlg_label, void (*call_back) (GtkWidget *, gpointer))
+{
+    GtkWidget *dlg;
+
+    dlg = gtk_dialog_new ();
+
+    gtk_window_set_title (GTK_WINDOW (dlg), _(dlg_title));
+    gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+    gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+    GtkWidget *vbox, *hbox;
+    vbox = GTK_DIALOG (dlg)->vbox;
+
+
+    GtkWidget *label;
+
+    label = gtk_label_new (_(dlg_label));
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+
+    hbox = gtk_hbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+    label = gtk_label_new (_("Name : "));
+    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY (entry), default_text);
+    gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *dlg_action_area = GTK_DIALOG (dlg)->action_area;
+    gtk_button_box_set_layout (GTK_BUTTON_BOX (dlg_action_area),
+                              GTK_BUTTONBOX_END);
+
+    GtkWidget *cancel_btn = gtk_button_new_from_stock ("gtk-cancel");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), cancel_btn,
+                                 GTK_RESPONSE_CANCEL);
+    GTK_WIDGET_SET_FLAGS (cancel_btn, GTK_CAN_DEFAULT);
+
+    GtkWidget *ok_btn = gtk_button_new_from_stock ("gtk-ok");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), ok_btn, GTK_RESPONSE_OK);
+    gtk_widget_show_all (dlg);
+
+#if 0
+       g_signal_connect ((gpointer) entry, "key-press-event", G_CALLBACK (enter_key_pressed), (gpointer) dlg);
+#endif
+    g_signal_connect ((gpointer) ok_btn, "clicked", G_CALLBACK (call_back), (gpointer) entry);
+    g_signal_connect_swapped ((gpointer) ok_btn, "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) dlg);
+    g_signal_connect_swapped ((gpointer) cancel_btn, "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) dlg);
+
+    return dlg;
+}
+
+/**
+       @brief  add combo box for plmn status message
+       @param  combo: combo box to append text
+       
+*/
+
+static void
+add_plmn_status_msg (GtkWidget * combo)
+{
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("PLMN_UNKNOWN"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("PLMN_AVAIL"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("PLMN_CURRENT"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("PLMN_FORBIDDEN"));
+}
+
+
+/**
+       @brief  add combo box for technology message
+       @param  combo: combo box to append text
+       
+*/
+
+static void
+add_access_technology_msg (GtkWidget * combo)
+{
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("GSM"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("GSM Compact"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("GPRS"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("UTRAN"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("EGPRS"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("NOT SPECIFIED"));
+}
+
+
+/**
+       @brief  dialog for combo box
+       @param  dlg_title: title of dialog
+       @param  select_column: combo box to display
+       @param  call_back: callback function called when OK clicked
+       @return dialog window widget
+*/
+
+GtkWidget *combo_dialog (gchar * dlg_title, gint select_column, void (*call_back) (GtkWidget *, gpointer))
+{
+    GtkWidget *dlg;
+    GtkWidget *label;
+
+    dlg = gtk_dialog_new ();
+
+    gtk_window_set_title (GTK_WINDOW (dlg), _(dlg_title));
+    gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+    gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+    GtkWidget *vbox, *hbox;
+    vbox = GTK_DIALOG (dlg)->vbox;
+
+    hbox = gtk_hbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 20);
+
+    label = gtk_label_new (_("Select : "));
+    // gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    gtk_box_pack_start_defaults (GTK_BOX (hbox), label);
+
+    GtkWidget *combo = gtk_combo_box_new_text ();
+    // gtk_box_pack_start (GTK_BOX(hbox), combo, FALSE, FALSE, 0);
+    gtk_box_pack_start_defaults (GTK_BOX (hbox), combo);
+
+    if (select_column == 1) {
+       // FIXME
+       add_plmn_status_msg (combo);
+    }
+
+    else {
+       // FIXME
+       add_access_technology_msg (combo);
+       // add_rssi_level_msg(combo); 
+    }
+
+    GtkWidget *dlg_action_area = GTK_DIALOG (dlg)->action_area;
+    gtk_button_box_set_layout (GTK_BUTTON_BOX (dlg_action_area),
+                              GTK_BUTTONBOX_END);
+
+    GtkWidget *cancel_btn = gtk_button_new_from_stock ("gtk-cancel");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), cancel_btn,
+                                 GTK_RESPONSE_CANCEL);
+    GTK_WIDGET_SET_FLAGS (cancel_btn, GTK_CAN_DEFAULT);
+
+    GtkWidget *ok_btn = gtk_button_new_from_stock ("gtk-ok");
+    gtk_dialog_add_action_widget (GTK_DIALOG (dlg), ok_btn, GTK_RESPONSE_OK);
+    gtk_widget_show_all (dlg);
+
+    g_signal_connect ((gpointer) ok_btn, "clicked", G_CALLBACK (call_back),
+                     (gpointer) combo);
+
+    g_signal_connect_swapped ((gpointer) ok_btn, "clicked",
+                             G_CALLBACK (gtk_widget_destroy),
+                             (gpointer) dlg);
+
+    g_signal_connect_swapped ((gpointer) cancel_btn, "clicked",
+                             G_CALLBACK (gtk_widget_destroy),
+                             (gpointer) dlg);
+
+    return dlg;
+}
+
+
+/**
+       @brief  callback when enter key pressed in rename_dialgo and set_up_menu_dialog
+       @param  widget  the Widget event happend
+       @param  event   event type
+       @param  user_data       dialog widget
+       @return true if event is enter key or false
+*/
+
+gboolean
+enter_key_pressed (GtkWidget * widget, GdkEventKey * event,
+                  gpointer user_data)
+{
+    if (event->keyval == GDK_Return) {
+       GtkWidget *entry = GTK_WIDGET (widget);
+       GtkWidget *clist = get_widget (EVENT_MANAGER_ID, "ID_CLIST_ES_DESC");
+       const gchar *text;
+       text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+       gtk_clist_set_text (GTK_CLIST (clist), GTK_CLIST (clist)->focus_row,
+                           5, text);
+       gtk_widget_destroy (GTK_WIDGET (GTK_WIDGET (user_data)));
+       return TRUE;
+    } else
+       return FALSE;
+}
+
+/**
+       @brief  dialog for message
+       @param  parent: widget of parent window
+       @param  type: GTK message type
+       @param  buttons: type of button
+       @param  message: mesage for dialog
+
+*/
+
+void
+message_dialog (GtkWindow * parent, GtkMessageType type,
+               GtkButtonsType buttons, gchar * message)
+{
+    GtkWidget *dialog =
+       gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+                               type,
+                               buttons, message);
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+}
+
diff --git a/lib/libui/dialog.h b/lib/libui/dialog.h
new file mode 100644 (file)
index 0000000..a8b9d53
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __DIALOG_H__
+#define __DIALOG_H__
+
+#include <gtk/gtk.h>
+#include <string.h>
+#include <stdio.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "ui_imageid.h"
+#include "utils.h"
+
+void show_message(const char *szTitle, const char *szMessage);
+void show_message_for_qemu(const char *szTitle, const char *szMessage);
+void clear_show_message(GtkWidget *widget, gpointer data);
+void file_open_dialog (gchar *title, GtkWindow *parent, gchar *ext, void (*call_back) (gchar *));
+void file_save_dialog (gchar *title, GtkWindow *parent, gchar *default_filename, gchar *ext, void (*call_back) (gchar *));
+GtkWidget *input_name_dialog (gchar *dlg_title, gchar *dlg_label, void (*call_back) (GtkWidget *, gpointer));
+GtkWidget *rename_dialog (gchar *default_text, gchar *dlg_title, gchar *dlg_label, void (*call_back) (GtkWidget *, gpointer));
+GtkWidget *combo_dialog(gchar* dlg_title, gint select_column, void (*call_back)(GtkWidget *, gpointer));
+void message_dialog(GtkWindow *parent, GtkMessageType type, GtkButtonsType buttons, gchar *message);
+gboolean enter_key_pressed (GtkWidget * widget, GdkEventKey * event, gpointer user_data);
+
+#define _(String)                      String
+
+#endif
diff --git a/lib/libui/imageutil.c b/lib/libui/imageutil.c
new file mode 100644 (file)
index 0000000..4725549
--- /dev/null
@@ -0,0 +1,440 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "imageutil.h"
+
+#if 0 /* deleted by opensource (20090309) */
+static char *folder_xpm[] = {
+    "16 16 8 1",
+    "   c None",
+    ".  c #909000",
+    "+  c #000000",
+    "@  c #EFE8EF",
+    "#  c #FFF8CF",
+    "$  c #FFF890",
+    "%  c #CFC860",
+    "&  c #FFC890",
+    "                ",
+    "  .....+        ",
+    " .@##$$.+       ",
+    ".%%%%%%%......  ",
+    ".###########$%+ ",
+    ".#$$$$$$$$$$&%+ ",
+    ".#$$$$$$$&$&$%+ ",
+    ".#$$$$$$$$&$&%+ ",
+    ".#$$$$$&$&$&$%+ ",
+    ".#$$$$$$&$&$&%+ ",
+    ".#$$$&$&$&$&&%+ ",
+    ".#&$&$&$&$&&&%+ ",
+    ".%%%%%%%%%%%%%+ ",
+    " ++++++++++++++ ",
+    "                ",
+    "                "
+};
+
+static char *ofolder_xpm[] = {
+    "16 16 12 1",
+    "   c None",
+    ".  c #808080",
+    "+  c #E0E0D0",
+    "@  c #4F484F",
+    "#  c #909000",
+    "$  c #FFF8EF",
+    "%  c #CFC860",
+    "&  c #003090",
+    "*  c #7F7800",
+    "=  c #FFC890",
+    "-  c #FFF890",
+    ";  c #2F3000",
+    "        .       ",
+    "       .+@      ",
+    "   ###.$$+@     ",
+    "  #%%.$$$$+@    ",
+    "  #%.$$$&$$+@** ",
+    "  #.+++&+&+++@* ",
+    "############++@ ",
+    "#$$$$$$$$$=%#++@",
+    "#$-------=-=#+; ",
+    " #---=--=-==%#; ",
+    " #-----=-=-==#; ",
+    " #-=--=-=-=-=#; ",
+    "  #=-=-=-=-==#; ",
+    "  ############; ",
+    "   ;;;;;;;;;;;  ",
+    "                "
+};
+#endif
+
+/* XPM */
+static char * ofolder_xpm[] = {
+"16 22 14 1",
+"      c None",
+".     c #848400",
+"+     c #D6D67B",
+"@     c #CECE7B",
+"#     c #CECE73",
+"$     c #C6C66B",
+"%     c #BDBD5A",
+"&     c #BDBD52",
+"*     c #ADAD39",
+"=     c #ADAD42",
+"-     c #B5B54A",
+";     c #C6C663",
+">     c #CECE6B",
+",     c #A5A5C6",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+" ....           ",
+".+@@#.....      ",
+".@@##$$%%&.     ",
+".@#..........   ",
+".#.*==--&%%;;.  ",
+".#.==--&%%;;.   ",
+"..==--&%%;;$.   ",
+"..=--&%%;;$.    ",
+".=--&%%;;$>.    ",
+"...........     ",
+"                ",
+"     ,          ",
+"                ",
+"     ,          ",
+"                ",
+"     ,          "
+};
+
+
+/* XPM */
+static char * folder_xpm[] = {
+"16 22 15 1",
+"      c None",
+".     c #848400",
+"+     c #E7E79C",
+"@     c #E7E794",
+"#     c #DEDE8C",
+"$     c #ADAD39",
+"%     c #ADAD42",
+"&     c #B5B54A",
+"*     c #B5B552",
+"=     c #BDBD5A",
+"-     c #9C9C29",
+";     c #A5A531",
+">     c #C6C663",
+",     c #C6C66B",
+"'     c #CECE73",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+" ....           ",
+".+@@#.......    ",
+".....$%%&&*=.   ",
+".-;;$%%&&*==.   ",
+".;;$%%&&*===.   ",
+".;$%%&&*===>.   ",
+".$%%&&*===>,.   ",
+".%%&&*===>,,.   ",
+".%&&*===>,,'.   ",
+".............   ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                "
+};
+
+
+#if 1
+static char *check_page_xpm[] = {
+    "16 16 5 1",
+    "       c None s None",
+    ".      c black",
+    "X      c white",
+    "o      c #808080",
+    "r      c red",
+    "                ",
+    "   .......      ",
+    "   .XXXXX..     ",
+    "   .XoooX.X.    ",
+    "   .XXXXX....   ",
+    "   rrooooXoorr  ",
+    "   rrXXXXXXrro  ",
+    "   .rrooooorro  ",
+    "   .rrXXXXrr.o  ",
+    "   .Xrrooorr.o  ",
+    "   .XXrrXrrX.o  ",
+    "   .XoorrroX.o  ",
+    "   .XXXXrXXX.o  ",
+    "   ..........o  ",
+    "    oooooooooo  ",
+    "                "
+};
+
+
+static char *page_xpm[] = {
+    "16 16 4 1",
+    "       c None s None",
+    ".      c black",
+    "X      c white",
+    "o      c #808080",
+    "                ",
+    "   .......      ",
+    "   .XXXXX..     ",
+    "   .XoooX.X.    ",
+    "   .XXXXX....   ",
+    "   .XooooXoo.o  ",
+    "   .XXXXXXXX.o  ",
+    "   .XooooooX.o  ",
+    "   .XXXXXXXX.o  ",
+    "   .XooooooX.o  ",
+    "   .XXXXXXXX.o  ",
+    "   .XooooooX.o  ",
+    "   .XXXXXXXX.o  ",
+    "   ..........o  ",
+    "    oooooooooo  ",
+    "                "
+};
+#endif
+
+
+static char *bk_on_xpm[] = {
+    "16 16 3 1",
+    "   c None",
+    ".  c red",
+    "o  c black",
+    "                ",
+    "     oooooo     ",
+    "   oo......oo   ",
+    "  o..........o  ",
+    "  o..........o  ",
+    " oo...........o ",
+    " o............o ",
+    " o............o ",
+    " o............o ",
+    " oo..........oo ",
+    "  o..........o  ",
+    "  o..........o  ",
+    "   oo......oo   ",
+    "     oooooo     ",
+    "                ",
+    "                "
+};
+
+
+static char *bk_off_xpm[] = {
+    "16 16 3 1",
+    "   c None",
+    ".  c blue",
+    "o  c black",
+    "                ",
+    "     oooooo     ",
+    "   oo......oo   ",
+    "  o..........o  ",
+    "  o..........o  ",
+    " oo...........o ",
+    " o............o ",
+    " o............o ",
+    " o............o ",
+    " oo..........oo ",
+    "  o..........o  ",
+    "  o..........o  ",
+    "   oo......oo   ",
+    "     oooooo     ",
+    "                ",
+    "                "
+};
+
+
+static char *bk_null_xpm[] = {
+    "16 16 1 1",
+    "       c None s None",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                ",
+    "                "
+};
+
+
+#if 0
+static char *pointer_off_xpm[] = {
+    "16 16 2 1",
+    "   c None",
+    ".  c black",
+    "                ",
+    "                ",
+    "  ............  ",
+    "  ............  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ............  ",
+    "  ............  ",
+    "                ",
+    "                "
+};
+
+
+static char *pointer_on_xpm[] = {
+    "16 16 2 1",
+    "   c None",
+    ".  c black",
+    "                ",
+    "                ",
+    "  ............  ",
+    "  ............  ",
+    "  ..        ..  ",
+    "  ..        ..  ",
+    "  ...      ...  ",
+    "  ....    ....  ",
+    "  .. ...... ..  ",
+    "  ..  ....  ..  ",
+    "  ..   ..   ..  ",
+    "  ..        ..  ",
+    "  ............  ",
+    "  ............  ",
+    "                ",
+    "                "
+};
+#endif
+
+
+/* XPM */
+static char * pointer_on_xpm[] = {
+"16 16 3 1",
+"      c None",
+".     c #FFFFFF",
+"+     c #000000",
+"................",
+".++++++++++++++.",
+".+............+.",
+".+.........++.+.",
+".+.........++.+.",
+".+........++..+.",
+".+........++..+.",
+".+..++...++...+.",
+".+..++...++...+.",
+".+...++.++....+.",
+".+...++.++....+.",
+".+....+++.....+.",
+".+....+++.....+.",
+".+............+.",
+".++++++++++++++.",
+"................"
+};
+
+/* XPM */
+static char * pointer_off_xpm[] = {
+"16 16 3 1",
+"      c None",
+".     c #FFFFFF",
+"+     c #000000",
+"................",
+".++++++++++++++.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".+............+.",
+".++++++++++++++.",
+"................"
+};
+
+
+GdkColormap *colormap;
+
+GdkPixmap *pointer_on_image, *pointer_off_image;
+GdkBitmap *pointer_on_mask, *pointer_off_mask;
+
+GdkPixmap *bk_null_image = NULL, *bk_on_image = NULL, *bk_off_image = NULL;
+GdkBitmap *bk_null_mask = NULL, *bk_on_mask = NULL, *bk_off_mask = NULL;
+
+GdkPixmap *page_image, *check_image;
+GdkBitmap *page_mask, *check_mask;
+
+GdkPixmap *opened_image, *closed_image;
+GdkBitmap *opened_mask, *closed_mask;
+
+
+/**
+       @brief  initialize image icon
+       @return void
+*/
+void init_icon_image ()
+{
+    colormap = gdk_colormap_get_system ();
+    pointer_on_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap,
+                                               &pointer_on_mask, NULL, pointer_on_xpm);
+    pointer_off_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap,
+                                               &pointer_off_mask, NULL,pointer_off_xpm);
+
+    bk_on_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &bk_on_mask, NULL, bk_on_xpm);
+    bk_off_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &bk_off_mask, NULL, bk_off_xpm);
+    bk_null_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &bk_null_mask, NULL, bk_null_xpm);
+
+    page_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &page_mask, NULL, page_xpm);
+    check_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &check_mask, NULL, check_page_xpm);
+
+    opened_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &opened_mask, NULL, ofolder_xpm);
+    closed_image = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, 
+                                                       &closed_mask, NULL, folder_xpm);
+}
diff --git a/lib/libui/imageutil.h b/lib/libui/imageutil.h
new file mode 100644 (file)
index 0000000..6677b57
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __IMAGE_UTIL_H__
+#define __IMAGE_UTIL_H__
+
+#include <gtk/gtk.h>
+#include "utils.h"
+
+extern GdkColormap *colormap;
+extern GdkPixmap *pointer_on_image, *pointer_off_image;
+extern GdkBitmap *pointer_on_mask, *pointer_off_mask;
+extern GdkPixmap *bk_null_image, *bk_on_image, *bk_off_image;
+extern GdkBitmap *bk_null_mask, *bk_on_mask, *bk_off_mask;
+extern GdkPixmap *page_image, *check_image;
+extern GdkBitmap *page_mask, *check_mask;
+extern GdkPixmap *opened_image, *closed_image;
+extern GdkBitmap *opened_mask, *closed_mask;
+
+void init_icon_image ();
+
+#endif
diff --git a/lib/libui/ui_imageid.h b/lib/libui/ui_imageid.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/libui/utils.c b/lib/libui/utils.c
new file mode 100644 (file)
index 0000000..990a1a2
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+       @file   utils.c
+       @brief  miscellaneous functions used in ISE
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <time.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "utils.h"
+
+static GHashTable *windows_hash = NULL; /* hash table to get widow and widget of Simulator */
+//GHashTable *attribute_hash = NULL;
+
+gchar *current_es_save_filename;               /**<event manager save file */
+gchar *current_testcase_save_filename; /**<testcase save file*/
+GPid simulator_pid = -1;               /**<pid of simulator window*/
+
+
+/**
+       @brief  hash intialization
+*/
+GHashTable *window_hash_init (void)
+{
+       windows_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+       return windows_hash;
+}
+
+
+/**
+       @brief  add window widget to hash
+*/
+void add_window (GtkWidget *win, gint window_id)
+{
+    g_hash_table_insert (windows_hash, GINT_TO_POINTER (window_id), win);
+}
+
+
+/**
+       @brief  search window widget by using window id as a key
+       @return matched window widget
+*/
+GtkWidget *get_window (gint window_id)
+{
+    GtkWidget *win = (GtkWidget *) g_hash_table_lookup (windows_hash, GINT_TO_POINTER (window_id));
+    return win;
+}
+
+
+/**
+       @brief  destroy hash
+*/
+void window_hash_destroy (void)
+{
+    g_hash_table_destroy (windows_hash);
+}
+
+
+/**
+       @brief  add widget to hash 
+       @param  window_id: ID of widget
+       @param  widget_name: widget name
+       @param  widget: widget to add in hash
+*/
+void add_widget (gint window_id, gchar * widget_name, GtkWidget * widget)
+{
+    if (!windows_hash) {
+               log_msg(MSGL_WARN,"Parent window not exist!\n");
+               return;
+    }
+       
+    GtkWidget *parent = get_window (window_id);
+    if (!parent) {
+               log_msg(MSGL_WARN,"Parent window not exist!\n");
+               return;
+    }
+       
+    g_object_set_data_full (G_OBJECT (parent), widget_name, gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref);
+}
+
+
+/**
+       @brief  get widget from hash
+       @param  window_id: ID of widget
+       @param  widget_name: widget name to search in hash
+       @return widget: widget to matched widget_name
+*/
+GtkWidget *get_widget (gint window_id, gchar *widget_name)
+{
+    GtkWidget *parent;
+       
+    parent = get_window (window_id);
+    if (!parent) {
+               log_msg(MSGL_WARN, "Parent window not exist!\n");
+               return NULL;
+    }
+
+    GtkWidget *w = (GtkWidget *) g_object_get_data (G_OBJECT (parent), widget_name);
+    if (!w) {
+               log_msg(MSGL_INFO, "Widget(%s) not found!\n", widget_name);
+               return NULL;
+    }
+       
+    return w;
+}
+
+
+/*
+void
+raise_window (GtkWidget * win)
+{
+    if (!gtk_window_has_toplevel_focus (GTK_WINDOW (win)))
+       gtk_window_present (GTK_WINDOW (win));
+}
+
+void
+remove_window (gint window_id)
+{
+    g_hash_table_remove (windows_hash, GINT_TO_POINTER (window_id));
+}
+*/
+
+
+/*
+void
+print_window (void)
+{
+    g_hash_table_foreach (windows_hash, print_entry, NULL);
+}
+*/
+
+
+/*
+void
+process_events (void)
+{
+    while (g_main_iteration (FALSE));
+}
+*/
+
+/**
+       @brief  create icon widget
+       @param  img_dir: directory of icon file exist
+       @param  filename: icon file name
+       @return newly created image widget
+*/
+
+GtkWidget *create_pixmap (const gchar* img_dir, const gchar * filename)
+{
+    gchar* image_file;
+    image_file = g_strdup_printf("%s/%s", img_dir, filename);
+    GtkWidget *pixmap;
+
+    if (!image_file) {
+               g_warning ("Couldn't find pixmap file: %s", image_file);
+               return gtk_image_new ();
+    }
+       
+    pixmap = gtk_image_new_from_file (image_file);
+    g_free(image_file);
+    return pixmap;
+}
+
+/*
+//======================= Attribute Hash Table Fuction ================================
+GHashTable *
+attr_tlb_init (void)
+{
+    return (GHashTable *) g_hash_table_new_full (g_direct_hash,
+                                                g_direct_equal, NULL, NULL);
+}
+
+int
+attr_tlb_set_ent (GHashTable * hash, gint key, gpointer value, int size)
+{
+    AttrTlbEnt *new_entry;
+
+    new_entry = g_hash_table_lookup (hash, GINT_TO_POINTER (key));
+    if (new_entry != NULL) {
+       g_hash_table_remove (hash, GINT_TO_POINTER (key));
+       new_entry = NULL;
+    }
+
+    new_entry = (AttrTlbEnt *) g_malloc (sizeof (AttrTlbEnt));
+    if (new_entry == NULL)
+       return -1;
+
+    new_entry->size = size;
+    new_entry->value = (gpointer) g_malloc (size);
+    if (new_entry->value == NULL)
+       return -1;
+    // g_print("%d: key_str: %s\n", ++i, (gchar*)key);
+    g_memcpy (new_entry->value, value, size);
+    g_hash_table_insert (hash, GINT_TO_POINTER (key), (gpointer) new_entry);
+
+    return 0;
+}
+
+int
+attr_tlb_del_ent (GHashTable * hash, gint key)
+{
+    AttrTlbEnt *old_entry;
+    old_entry = g_hash_table_lookup (hash, GINT_TO_POINTER (key));
+    if (old_entry == NULL)
+       return -1;
+
+    g_free (old_entry->value);
+    old_entry->size = 0;
+    old_entry->value = NULL;
+
+    g_hash_table_remove (hash, GINT_TO_POINTER (key));
+    g_free (old_entry);
+
+    return 0;
+}
+
+gpointer
+attr_tlb_find_ent (GHashTable * hash, gint key)
+{
+    AttrTlbEnt *ret_entry;
+
+    ret_entry =
+       (AttrTlbEnt *) g_hash_table_lookup (hash, GINT_TO_POINTER (key));
+    if (ret_entry == NULL)
+       return NULL;
+
+    return ret_entry->value;
+}
+
+GHashTable *
+attr_tlb_open (const gchar * fileName)
+{
+    FILE *fp;
+    GHashTable *hash;
+    gint valueSize;
+    gint prevValueSize = 0;
+    gint key;
+    gpointer value;
+
+    if ((fp = fopen (fileName, "r")) == NULL) {
+       //g_print ("Can't %s file open\n", fileName);
+       //g_log(ISE_DOMAIN, G_LOG_LEVEL_DEBUG, "[%s:%s:%5d]Can't %s file open",__FILE__, __func__,  __LINE__, fileName);
+       return NULL;
+    }
+
+    hash = attr_tlb_init ();
+
+    while (!feof (fp)) {
+       fread (&key, sizeof (int), 1, fp);
+
+       fread (&valueSize, sizeof (int), 1, fp);
+
+       // ff();
+       // g_print("key =%s. keyLength=%d. valuesize = %d.\n", (gchar*)key, keyLength, valueSize);
+       // ff();
+
+       if (prevValueSize == 0) {
+           value = (gpointer) g_malloc (valueSize);
+           prevValueSize = valueSize;
+       } else if (valueSize > prevValueSize) {
+           value = (gpointer) g_realloc (value, valueSize);
+           prevValueSize = valueSize;
+       }
+       fread (value, valueSize, 1, fp);
+
+       // g_print ("%d: key =%s. keyLength=%d. valuesize = %d.\n", ++i, (gchar*)key, keyLength, valueSize);
+       attr_tlb_set_ent (hash, key, value, valueSize);
+    }
+
+    g_free (value);
+    fclose (fp);
+
+    return hash;
+}
+
+static void save_entry (gpointer key, gpointer value, gpointer data)
+{
+    AttrTlbEnt *entry = (AttrTlbEnt *) value;
+    FILE *fp = (FILE *) data;
+    gint key_int = (gint) key;
+
+    fwrite (&key_int, sizeof (gint), 1, fp);
+    fwrite (&entry->size, sizeof (gint), 1, fp);
+    fwrite (entry->value, entry->size, 1, fp);
+}
+
+int
+attr_tlb_save (GHashTable * hash, const gchar * fileName)
+{
+    FILE *fp;
+
+    if ((fp = fopen (fileName, "w")) == NULL) {
+       //g_print ("Can't %s file open\n", fileName);
+       g_log(ISE_DOMAIN, G_LOG_LEVEL_DEBUG, "[%s:%s:%5d]Can't %s file open",__FILE__, __func__,  __LINE__, fileName);
+       return -1;
+    };
+
+    g_hash_table_foreach (hash, save_entry, fp);
+    fclose (fp);
+
+    return 0;
+}
+
+static void
+del_entry (gpointer key, gpointer value, gpointer data)
+{
+    AttrTlbEnt *old_entry;
+
+    old_entry = (AttrTlbEnt *) value;
+    g_free (old_entry->value);
+    g_free (old_entry);
+}
+
+void
+attr_tlb_close (GHashTable * hash)
+{
+    g_hash_table_foreach (hash, del_entry, NULL);
+    g_hash_table_destroy (hash);
+}
+
+void
+print_entry (gpointer key, gpointer value, gpointer data)
+{
+    //g_print ("key=0x%x.\n", (gint) key);
+    g_log(ISE_DOMAIN, G_LOG_LEVEL_INFO, "[%s:%s:%5d]key=0x%x.",__FILE__, __func__,  __LINE__, (gint)key);
+}
+
+
+//======================= Etc Util Function ======================= 
+
+*/
+
+/**
+       @brief  convert string  to lower case string
+       @param  string string to covert
+*/
+#ifndef _WIN32
+void
+strlwr (char *string)
+{
+    //while (0 != (*string++ = (char) tolower (*string)));
+    while (1)
+       {
+
+               *string = (char) tolower (*string);
+
+               if (*string == 0)  {
+                       return;
+               }
+#if 0
+               *string++;
+#else
+               string++;
+#endif
+       }
+}
+#endif
+
diff --git a/lib/libui/utils.h b/lib/libui/utils.h
new file mode 100644 (file)
index 0000000..9de2f8d
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+#include <gtk/gtk.h>
+
+#include "../libcommon/fileio.h"
+#include "../libcommon/logmsg.h"
+
+extern GHashTable *attribute_hash;
+extern gint menu_id_array[];
+extern gint window_id_array[];
+
+extern gchar *current_es_save_filename;
+extern gchar *current_testcase_save_filename;
+extern GPid simulator_pid;
+
+GHashTable *window_hash_init (void);
+void add_window (GtkWidget * win, gint id);
+void raise_window (GtkWidget * win);
+void remove_window (gint id);
+GtkWidget *get_window (gint id);
+void print_window (void);
+void window_hash_destroy (void);
+void add_widget (gint window_id, gchar * widget_name, GtkWidget * widget);
+GtkWidget *get_widget (gint window_id, gchar * widget_name);
+
+void process_events (void);
+GtkWidget *create_pixmap (const gchar *, const gchar*);
+/*
+typedef struct _AttrTlbEnt {
+    gint size;
+    gpointer value;
+} AttrTlbEnt;
+
+typedef struct _iseToolkit {
+    gint x;
+    gint y;
+    gint width;
+    gint height;
+
+    gboolean is_active;
+
+    GtkWidget *(*create) (GtkWidget * window);
+    GtkWidget *(*destroy) (GtkWidget * window);
+} ISEToolkit;
+
+
+GHashTable *attr_tlb_init (void);
+
+int attr_tlb_set_ent (GHashTable * hash, gint key, gpointer value, int size);
+int attr_tlb_del_ent (GHashTable * hash, gint key);
+gpointer attr_tlb_find_ent (GHashTable * hash, gint key);
+GHashTable *attr_tlb_open (const gchar * fileName);
+int attr_tlb_save (GHashTable * hash, const gchar * fileName);
+void attr_tlb_close (GHashTable * hash);
+void print_entry (gpointer key, gpointer value, gpointer data);
+*/
+// void dynamic_strcpy(gchar** dest, const gchar* src);
+
+#ifndef _WIN32
+void strlwr (char *string);
+#endif
+
+#endif
diff --git a/libvmodem/Makefile.in b/libvmodem/Makefile.in
new file mode 100644 (file)
index 0000000..4a944f4
--- /dev/null
@@ -0,0 +1,39 @@
+CC=@CC@
+AR=@AR@
+INCLUDES =     \
+       -I. \
+       -I../lib/libsms
+
+CFLAGS  = @CFLAGS@
+CFLAGS  += -Wall $(INCLUDES)  -DEMTRACE_I878 -D_LIBVGSM_DEBUG
+
+LIBS    = -lpthread
+
+OBJ =                  \
+       lxtutil.o \
+       libvgsm_edb.o \
+       libvgsm_emul.o \
+       libvgsm_init.o \
+       libvgsm_call.o \
+       libvgsm_ss.o \
+       libvgsm_sms.o \
+       libvgsm_network.o \
+       libvgsm_data.o \
+       libvgsm_gprs.o \
+       libvgsm_display.o \
+       libvgsm_power.o \
+       libvgsm_hdlc.o \
+       libvgsm_sim.o \
+       libvgsm_sat.o
+
+.SUFFIXES: .c
+
+all: libvmodem.a
+
+libvmodem.a: $(OBJ)
+       $(AR) r $@ $(OBJ)
+
+clean:
+       rm -f $(OBJ) libvmodem.a
+
+install:
diff --git a/libvmodem/db_phonebook.h b/libvmodem/db_phonebook.h
new file mode 100644 (file)
index 0000000..bc59794
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+
+#ifndef __DB_PHONEBOOK_H__
+#define __DB_PHONEBOOK_H__
+
+#include <sqlite3.h>
+
+typedef struct _PB PB;
+struct _PB {
+       int db_st_type;
+       //int index;
+       char name[30];
+       char number[20];
+       char address[30];
+       int cnt;
+};
+
+typedef enum {
+DB_REQ=0,
+DB_DC =1,
+DB_EN =2,
+DB_FD,
+DB_LD,
+DB_MC,
+DB_ME,
+DB_MT,
+DB_ON,
+DB_RC,
+DB_SIM,
+DB_SDN,
+}PB_ST_type;
+
+
+
+int db_sim_pb_restore_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_cnt_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_get_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_setted_storage_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_create(void);
+
+
+int db_sim_pb_add(PB *pb);
+
+
+int db_sim_pb_remove(PB *pb);
+
+
+int db_sim_pb_cnt_mgr(sqlite3 * db,int pb_type,int action);
+
+
+int db_sim_pb_restore(PB *pb);
+
+
+int db_sim_pb_get(PB *pb);
+
+
+int db_sim_pb_set_mgr(int pb_type,int action);
+
+
+#endif
+
diff --git a/libvmodem/libvgsm_call.c b/libvmodem/libvgsm_call.c
new file mode 100644 (file)
index 0000000..2240591
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+
+
+/*     ++ 2008-08-13
+       ++ Name : vgsm_call_make
+       ++ Description : This function is called from on_injecting_call_mt_start_clicked() in Event Injector.
+       ++                               When "Dial" button of Event Injector is clicked, this function will work.
+*/
+int vgsm_call_make(LXT_HANDLE* handle, gsm_call_info_t callinfo)
+{
+       int nretn = 0;
+       int     length = callinfo.numlen + 8;
+
+
+       length = sizeof(gsm_call_info_t);
+       
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)callinfo.calltype;
+       pdata[1] = (unsigned char)callinfo.forwardedstatus;
+       pdata[2] = (unsigned char)callinfo.clirstatus;
+
+       /*      ++ 2008-08-13
+               ++ Type of numlen is unsigned short.
+               ++ Type of pdata is char.
+               ++ I think that this is mis-casting.
+       */
+       pdata[3] = (unsigned char)callinfo.numlen;
+       pdata[4] = (unsigned char)callinfo.numtype;
+
+       pdata[5] = (unsigned char)callinfo.present_ind;
+//     pdata[6] = (unsigned char)callinfo.redirected_num;
+       pdata[6] = (unsigned char)callinfo.no_cli_cause;
+
+       if(callinfo.numlen > 0)
+               memcpy(&pdata[7], callinfo.number, callinfo.numlen);
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_CALL,
+                                                                       GSM_CALL_MAKE_REQ,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
+int vgsm_call_disconnect_cause(LXT_HANDLE* handle, int call_error_cause)
+{
+       //unsigned char data = (unsigned char )call_error_cause;
+       unsigned char data[2];
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] = (unsigned short)call_error_cause & 0x00ff;
+       data[1] = ((unsigned short)call_error_cause >> 8) & 0x00ff;
+
+       printf("!!!!!!! value !!!!!!! disconnect : %x\n",GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR);
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_CALL,
+                                                                       GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR,
+                                                                       2,
+                                                                       data);
+}
+
+int vgsm_call_hangup(LXT_HANDLE* handle, int call_id)
+{
+       unsigned char data = (unsigned char )call_id;
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_CALL,
+                                                                       GSM_CALL_HANGUP_REQ,
+                                                                       0x01,
+                                                                       &data);
+}
+
+int vgsm_call_answer(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_CALL,
+                                                                       GSM_CALL_ANSWER_REQ,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+int vgsm_call_alert(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_CALL,
+                                                                       GSM_CALL_ALERT_IND,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+
diff --git a/libvmodem/libvgsm_data.c b/libvmodem/libvgsm_data.c
new file mode 100644 (file)
index 0000000..955d3cd
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+
+int vgsm_data_status(LXT_HANDLE* handle, GSM_DataCallStatus status)
+{
+       int nretn = 0;
+       int     length = 4;
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)status.cid;
+       pdata[1] = (unsigned char)status.data_call_state;
+       pdata[2] = (unsigned char)status.data_call_state_rsn;
+       pdata[3] = (unsigned char)status.external_ps_call;
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_DATA,
+                                                                       GSM_DATA_STATUS,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
diff --git a/libvmodem/libvgsm_debug.h b/libvmodem/libvgsm_debug.h
new file mode 100644 (file)
index 0000000..33b10bf
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _VGSM_DEBUG_H_
+#define _VGSM_DEBUG_H_
+
+#include <stdio.h>
+
+#ifdef _LIBVGSM_DEBUG
+/*--> 2008-09-20
+#define LIBVGSM_DEBUG(frmt, args...)  {do {printf("[LIBVGSM] [%s:%d] " frmt ,  __func__,  __LINE__, ##args); } while (0) ;}
+<-- */
+/*++> 2008-09-20 */
+#define LIBVGSM_DEBUG(frmt, args...)  printf("[LIBVGSM] [%s %s:%d] " frmt ,  __func__,  __FILE__, __LINE__, ##args)
+/*<++*/
+
+#else
+#define LIBVGSM_DEBUG(frmt, args...)
+#endif
+
+#endif
+
diff --git a/libvmodem/libvgsm_display.c b/libvmodem/libvgsm_display.c
new file mode 100644 (file)
index 0000000..670d9e3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+
+int vgsm_display_icon_information(LXT_HANDLE* handle, disp_icon_info_t info)
+{
+       int nretn = 0;
+       int     length = 5; 
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)info.icon_type;
+       pdata[1] = (unsigned char)info.rssi;
+       pdata[2] = (unsigned char)info.battery;
+       pdata[3] = (unsigned char)info.act;
+       pdata[4] = (unsigned char)info.reg_status;
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_DISPLAY,
+                                                                       GSM_DISPLAY_INDICATOR_NOTI,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
diff --git a/libvmodem/libvgsm_edb.c b/libvmodem/libvgsm_edb.c
new file mode 100644 (file)
index 0000000..cf9c46f
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/***************************************************************************************
+ *
+ * Copyright (c) 2008 SAMSUNG Co. Ltd,
+ * All rights reserved.
+ *
+ * File: vgsm_edb.c
+ *
+ * Release:
+ *
+ * Description: libvgsm interface.
+ *
+ * Revision History
+ * September/08/2009 Initial revision
+ *
+****************************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "lxtutil.h"
+#include "vgsm.h"
+#include "vgsm_edb.h"
+
+int vgsm_get_pb_edb(LXT_HANDLE * handle)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_pb_edb\n");
+
+       _Pb_edb *pb_edb;
+       pb_edb = malloc(sizeof(_Pb_edb));
+       memset(pb_edb,0,sizeof(_Pb_edb));
+       int ret;
+       
+       if( handle == NULL )
+               return -1;
+       
+       ret =  lxt_msg_send_message
+               (
+                       handle->fd,
+                       FUNC_EDB,
+                       FUNC_GET_PB_DB_REQ,
+                       sizeof(_Pb_edb),
+                       pb_edb
+               );
+
+       if(pb_edb) free(pb_edb);
+       
+       return ret;
+}
+
+
+int vgsm_add_pb_edb(LXT_HANDLE * handle, _Pb_edb* pb_edb)
+{
+       printf("[LIBVGSM-SIM] vgsm_add_pb_db\n");
+       int ret;
+
+       if( handle == NULL )
+               return -1;
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       FUNC_EDB,
+                       FUNC_ADD_PB_DB_REQ,
+                       sizeof(*pb_edb),                                        // size of _Pb_edb structure
+                       pb_edb
+               );
+
+//     if(pb_edb) free(pb_edb);
+       
+       return ret;
+}
+
+int vgsm_del_pb_edb(LXT_HANDLE * handle, char* text)
+{
+       printf("[LIBVGSM-SIM] vgsm_delete_pb_db\n");
+
+       if( handle == NULL )
+               return -1;
+       
+       int ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       FUNC_EDB,
+                       FUNC_DEL_PB_DB_REQ,
+                       strlen(text),
+                       text    
+               );
+       
+       return ret;
+}
+
+int vgsm_get_one_pb_edb(LXT_HANDLE * handle, char* text)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_one_item_pb_db\n");
+
+       if( handle == NULL )
+               return -1;
+       
+       int ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       FUNC_EDB,
+                       FUNC_GET_ONE_PB_DB_REQ,
+                       strlen(text),
+                       text    
+               );
+       
+       return ret;
+}
+
diff --git a/libvmodem/libvgsm_emul.c b/libvmodem/libvgsm_emul.c
new file mode 100644 (file)
index 0000000..cf85212
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+#include <string.h>
+#include <stdlib.h>
+#include "lxtutil.h"
+#include "vgsm_hdlc.h"
+#include "libvgsm_debug.h"
+
+/* Event Inject Releas Notify */
+
+int vgsm_client_release_notify(LXT_HANDLE* handle)
+{
+       LIBVGSM_DEBUG("\n");
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_CLIENT,
+                                                                       GSM_CLIENT_RELEASE_NOTI,
+                                                                       0,
+                                                                       NULL);
+}
+
+int vgsm_set_call_general_response_error(LXT_HANDLE* handle, int error)
+{
+       unsigned char data[2];
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] = (unsigned short)error & 0x00ff;
+       data[1] = ((unsigned short)error >> 8) & 0x00ff;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_EMULATOR,
+                                                                       GSM_EMULATOR_SET_CALL_GENERAL_RESPONSE_ERROR,
+                                                                       2,
+                                                                       data);
+}
+
+int vgsm_set_ss_general_response_error(LXT_HANDLE* handle, int error)
+{
+       unsigned char data[2];
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] = (unsigned short)error & 0x00ff;
+       data[1] = ((unsigned short)error >> 8) & 0x00ff;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_EMULATOR,
+                                                                       GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR,
+                                                                       2,
+                                                                       data);
+}
+
+int vgsm_set_call_status_error(LXT_HANDLE* handle, int type, int error)
+{
+    unsigned char response_type = (unsigned char)type;
+    //unsigned char data = (unsigned char)error;
+       unsigned char data[2];
+
+    if( handle == NULL )
+       return -1;
+
+       data[0] = (unsigned short)error & 0x00ff;
+       data[1] = ((unsigned short)error >> 8) & 0x00ff;
+
+       //GSM_EMULATOR_SET_CALL_STATUS_ERROR -> response type
+    return lxt_msg_send_message
+           (
+               handle->fd,
+               GSM_EMULATOR,
+               response_type,
+               2,
+               data
+           );
+}
+
+int vgsm_set_sca(LXT_HANDLE* handle, SmsAddressInfo SCA)
+{
+    if( handle == NULL )
+       return -1;
+
+    return lxt_msg_send_message
+           (
+               handle->fd,
+               GSM_EMULATOR,
+               GSM_EMULATOR_SET_SCA,
+               sizeof(SmsAddressInfo),
+               &SCA
+           );
+}
+
+int vgsm_convert_callbackinfo( void *data, TCallbackInfo *info )
+{
+       int len;
+       unsigned char *rawdata = (unsigned char *)data;
+
+       if( data == NULL )
+               return -1;
+
+       info->time = *(time_t *)rawdata;
+       len = sizeof(time_t);
+
+       info->rx = rawdata[len++];
+       len += sizeof(unsigned short);
+       return 1;
+}
+
+int vgsm_get_at_length_callbackinfo( TCallbackInfo info )
+{
+    return strlen(info.at.atmsg);
+}
+
+int vgsm_convert_atinfo( void *data, TAT *at )
+{
+       return 1;
+}
+
+int vgsm_get_at_length_atinfo( TAT at )
+{
+    return strlen(at.atmsg);
+}
+
+int vgsm_set_hdlc_mode(LXT_HANDLE *handle, int mode)
+{
+    unsigned char data = (unsigned char )mode;
+
+    if( handle == NULL )
+       return -1;
+
+    return lxt_msg_send_message
+           (
+               handle->fd,
+               GSM_EMULATOR,
+               GSM_EMULATOR_HDLC_MODE,
+               0x01,
+               &data
+           );
+}
+
+int vgsm_send_hdlc(LXT_HANDLE * handle, const char *hdlc, int hdlc_len)
+{
+    if( handle == NULL )
+       return -1;
+
+    return lxt_msg_send_message
+           (
+               handle->fd,
+               GSM_EMULATOR,
+               GSM_EMULATOR_HDLC_REQ,
+               hdlc_len,
+               (void *)hdlc
+           );
+}
+
+int vgsm_clear_hdlc(LXT_HANDLE * handle)
+{
+    if( handle == NULL )
+       return -1;
+
+    FreeAllMultiNodeList();
+
+    return lxt_msg_send_message
+           (
+               handle->fd,
+               GSM_EMULATOR,
+               GSM_EMULATOR_HDLC_CLEAR,
+               0x00,
+               NULL
+           );
+}
+
+
diff --git a/libvmodem/libvgsm_gprs.c b/libvmodem/libvgsm_gprs.c
new file mode 100644 (file)
index 0000000..58e1faa
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+#include "vgsm_gprs.h"
+
+int vgsm_gprs_ip_configuration(LXT_HANDLE* handle, gsm_GprsConfList list)
+{
+       int nretn = 0;
+       int length, i;
+       unsigned char *pdata, *pos;
+       gsm_GprsDbEntry *pentry;
+
+       if (handle == NULL)
+               return -1;
+
+       length = sizeof(int) + (list.num * (255 + 10 + 23));
+
+       pdata = (unsigned char *) malloc(length);
+       if (!pdata)
+               return -1;
+
+       memset(pdata, 0, length);
+
+       *((int *)pdata) = list.num;
+
+       pos = pdata + sizeof(int);
+
+       for (i = 0; i < list.num; i++ ) {
+               pentry = &(list.pentry[i]);
+
+               strcpy((char *)pos, pentry->apn);
+
+               strcpy((char *)(pos + 255), pentry->intf);
+
+               pos[265] = pentry->ipconf.cid;
+
+               memcpy(pos + 266, (char *)(&(pentry->ipconf.fieldflag)), 2);
+               memcpy(pos + 268, (char *)(pentry->ipconf.ip_addr), 4);
+               memcpy(pos + 272, (char *)(pentry->ipconf.primary_dns), 4);
+               memcpy(pos + 276, (char *)(pentry->ipconf.secondary_dns), 4);
+               memcpy(pos + 280, (char *)(pentry->ipconf.default_gateway), 4);
+               memcpy(pos + 284, (char *)(pentry->ipconf.subnet_mask), 4);
+
+               pos += 255 + 10 + 23;
+       }
+
+       nretn = lxt_msg_send_message(handle->fd,
+                                                               GSM_GPRS, GSM_GPRS_IP_CONFIGURATION,
+                                                               length, pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return 0;
+}
diff --git a/libvmodem/libvgsm_hdlc.c b/libvmodem/libvgsm_hdlc.c
new file mode 100644 (file)
index 0000000..cf10aad
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// vgsm_hdlc.c
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_hdlc.h"
+
+#define TRACE(a,s,...)
+
+static HDLCFrame_t s_FrameSentInfo;
+static HDLCFrame_t s_FrameRecvInfo;
+
+// Last sent HDLC frame info
+void SetLastSentHDLCFrameInfo(HDLCFrame_t const* pframe)
+{
+       TRACE(MSGL_VGSM_INFO, "%s(%s)", __FUNCTION__, __FILE__);
+
+       s_FrameSentInfo.m_CtrlInfo = pframe->m_CtrlInfo;
+       s_FrameSentInfo.m_Length = pframe->m_Length;
+}
+
+HDLCFrame_t const* GetLastSentHDLCFrameInfo()
+{
+       TRACE(MSGL_VGSM_INFO, "%s(%s)", __FUNCTION__, __FILE__);
+
+       return &s_FrameSentInfo;
+}
+
+// Last receive HDLC frame info
+void SetLastRecvHDLCFrameInfo(HDLCFrame_t const* pframe)
+{
+       TRACE(MSGL_VGSM_INFO, "%s(%s)", __FUNCTION__, __FILE__);
+
+       s_FrameRecvInfo.m_CtrlInfo = pframe->m_CtrlInfo;
+       s_FrameRecvInfo.m_Length = pframe->m_Length;
+}
+
+HDLCFrame_t const* GetLastRecvHDLCFrameInfo()
+{
+       TRACE(MSGL_VGSM_INFO, "%s(%s)", __FUNCTION__, __FILE__);
+
+       return &s_FrameRecvInfo;
+}
+
+// For multi HDLC frame.
+typedef struct tagHDLCNode {
+       struct tagHDLCNode* m_pNext;
+       HDLCFrame_t m_HDLCNode;
+} HDLCNode;
+
+HDLCNode* g_pHead = NULL;
+HDLCNode* g_pTail = NULL;
+
+void FreeAllMultiNodeList()
+{
+       HDLCNode* pnode_tmp;
+       HDLCNode* pnode = g_pHead;
+       while (pnode) {
+               pnode_tmp = pnode;
+               pnode = pnode->m_pNext;
+
+               // free data
+               if (pnode_tmp->m_HDLCNode.m_pValue)
+                       free(pnode_tmp->m_HDLCNode.m_pValue);
+               free(pnode_tmp);
+       }
+
+       g_pHead = g_pTail = NULL;
+}
+
+void PushHDLCMultiFrameInfo(HDLCFrame_t const* pframe)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       HDLCNode* pnode = malloc(sizeof(HDLCNode));
+
+       if (!pframe)
+               return;
+
+       memset(pnode, 0, sizeof(HDLCNode));
+
+       pnode->m_HDLCNode.m_Length = pframe->m_Length;
+       pnode->m_HDLCNode.m_CtrlInfo = pframe->m_CtrlInfo;
+
+       if (pframe->m_Length - 3 > 0) {
+               pnode->m_HDLCNode.m_pValue = malloc(pframe->m_Length - 3);
+               memcpy(pnode->m_HDLCNode.m_pValue, pframe->m_pValue, pframe->m_Length - 3);
+       }
+
+       if (!g_pHead) {
+               g_pHead = pnode;
+       } else {
+               if (g_pTail)
+                       g_pTail->m_pNext = pnode;
+       }
+
+       g_pTail = pnode;
+}
+
+HDLCFrame_t const* GetLastRecvHDLCMultiFrameInfo()
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       if (g_pTail)
+               return &(g_pTail->m_HDLCNode);
+
+       return NULL;
+}
+
+TAT* ConvertHDLCMultiFrameToAT()
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       unsigned char* pat_data = NULL;
+       unsigned char* ptr = NULL;
+       int at_size = 0;
+       HDLCNode* pnode = g_pHead;
+
+       while (pnode) {
+               at_size += pnode->m_HDLCNode.m_Length - 3;
+               pnode = pnode->m_pNext;
+       }
+
+       if (at_size > 0) {
+               pat_data = (unsigned char*)malloc(at_size);
+               ptr = pat_data;
+               pnode = g_pHead;
+               while (pnode) {
+                       memcpy(ptr, pnode->m_HDLCNode.m_pValue, pnode->m_HDLCNode.m_Length - 3);
+                       ptr += pnode->m_HDLCNode.m_Length - 3;
+
+                       pnode = pnode->m_pNext;
+               }
+       }
+
+       FreeAllMultiNodeList();
+
+       return (TAT*)pat_data;
+}
+
diff --git a/libvmodem/libvgsm_init.c b/libvmodem/libvgsm_init.c
new file mode 100644 (file)
index 0000000..9bbdd46
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "vgsm.h"
+#include "libvgsm_debug.h"
+
+static int lxt_internal_setClientClass(LXT_HANDLE* handle);
+static int lxt_internal_MissedMessage(LXT_HANDLE* handle);
+
+// +++++++++++++++++++++++++++++++++++++++++++++define area
+#define DEF_REV                                        "20040901.11"
+#define DEF_DOMAIN_SOCKET_NAME "/tmp/.vgsm_socket"
+static int exit_status;
+
+// internal function ++++++++++++++++++++++++++++++++++++++
+static void get_domain_socket_name(char* result)
+{
+    strcpy(result, DEF_DOMAIN_SOCKET_NAME);
+    strcat(result, (const char*)"-");
+    strcat(result, getenv("USER"));
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    LIBVGSM_DEBUG("[VGSM] SOCKET NAME [%s]\n", result);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    return;
+}
+
+
+#if 1
+static int connect_af_unix()
+{
+    int sockfd;
+    int len;
+    struct sockaddr_un address;
+    int rc;
+    char socket_name[64] = {0, };
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    printf("[VGSM] UNIX SOCKET\n");
+#endif // _NO_ESPRESSO_DEBUG_
+
+    // get domain socket name
+    get_domain_socket_name(socket_name);
+
+    // create socket
+    sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+    // set address type
+    address.sun_family = AF_UNIX;
+
+    strcpy(address.sun_path, socket_name);
+    //strcpy(address.sun_path, PHONE_SERVER_SOCKET_PATH);
+
+    // get size of address
+    len = sizeof(address.sun_family) + strlen(socket_name);
+    //len = sizeof(address.sun_family) + strlen(PHONE_SERVER_SOCKET_PATH);
+
+    // connect to phone server
+    rc = connect(sockfd, (struct sockaddr *)&address, len);
+
+    if (rc == -1)
+    {
+        perror("connect");
+        return -1;
+    }
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    printf("[VGSM] SOCKET [%d]\n", sockfd);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    return sockfd;
+}
+#endif
+
+
+#if 0
+static int connect_af_inet(const char* hostname)
+{
+    int sockfd;
+    struct sockaddr_in address;
+    int rc;
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    LIBVGSM_DEBUG("[VGSM] INET SOCKET [%s]\n", hostname);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+    memset(&address, 0, sizeof(address));
+    address.sin_family = AF_INET;
+    //address.sin_port = htons(4007);
+    address.sin_port = htons(4009);
+    address.sin_addr.s_addr = inet_addr(hostname);
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    LIBVGSM_DEBUG("[VGSM] CONNECT [%s]\n", hostname);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    // connect to phone server
+    rc = connect(sockfd, (struct sockaddr_in *)&address, sizeof(address));
+
+    if (rc == -1)
+    {
+        perror(" vgsm connect err : ");
+        return -1;
+    }
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    LIBVGSM_DEBUG("[VGSM] CONNECT : OK [%s]\n", hostname);
+    LIBVGSM_DEBUG("[VGSM] SOCKET [%d]\n", sockfd);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    return sockfd;
+}
+#else
+#define SIZE   sizeof(struct sockaddr_in)
+
+static int connect_af_inet(const char* hostname)
+{
+       int sockfd;
+       struct sockaddr_in server; // = {AF_INET, 3578, {INADDR_ANY}};
+
+       server.sin_family = AF_INET;
+       server.sin_port = htons(3578);
+       server.sin_addr.s_addr = inet_addr(hostname);
+       if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+       {
+               printf("fail to call socket()\n");
+               return -1;
+       }
+
+       if(connect(sockfd, (struct sockaddr*)&server, SIZE) == -1)
+       {
+               perror("connect() failed");
+               return -1;
+       }
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    printf("[VGSM] SOCKET [%d]\n", sockfd);
+#endif // _NO_ESPRESSO_DEBUG_
+
+    return sockfd;
+}
+#endif
+
+#if 0
+static char is_inet_mode()
+{
+       char file_name_cal[128] = {0, };
+       int fd = 0;
+       char result = 0;
+
+       sprintf(file_name_cal,"/tmp/.vgsm_inet_mode");
+       fd = open(file_name_cal, O_RDONLY);
+
+       if(fd >=0)
+       {
+               result = 1;
+               close(fd);
+               perror(" is_inet_mode open err:");
+       }
+       else
+       {
+               result = 0;
+       }
+
+       return result;
+}
+#endif
+
+// initialize handle
+LXT_HANDLE* lxt_initialize(LXT_ID_CLIENT clientclass, LXT_CALLBACK cb)
+{
+       LXT_HANDLE *handle;
+       int sockfd;
+       int rc;
+
+       exit_status = 0;
+
+       //if(is_inet_mode()) //FALSE
+       if(1) // 090501 prevent segfault in qemu
+       {
+               //printf("[VGSM] INET MODE : LINUX TAPI with coruscant on i819 : [%s][%s]\n", __DATE__, __TIME__);        
+               LIBVGSM_DEBUG("INET MODE : LINUX VGSM\n");        
+               if((sockfd = connect_af_inet("127.0.0.1")) == -1)
+               {
+                       LIBVGSM_DEBUG("LINUX VGSM : connect to target failed");
+
+                       /*
+                       if((sockfd = connect_af_unix()) == -1)
+                       {
+                               return NULL;
+                       }
+                       */
+               }
+               LIBVGSM_DEBUG("LINUX VGSM : connect to target");
+
+       }
+       else
+       {
+               //printf("[VGSM] DOMAIN MODE : LINUX TAPI with coruscant on i819 : [%s][%s]\n", __DATE__, __TIME__);
+               LIBVGSM_DEBUG("DOMAIN MODE : LINUX VGSM\n");
+               sockfd = connect_af_unix();
+               LIBVGSM_DEBUG("sockfd = %d\n",sockfd);
+       }
+
+       if (sockfd < 0)
+               return NULL;
+
+       // allocate memory
+       handle = malloc(sizeof(LXT_HANDLE));
+       if (!handle)
+               return NULL;
+
+       // save client class
+       handle->clientclass = clientclass;
+
+       // save socket
+       handle->fd = sockfd;
+
+       // save call back function
+       handle->cb = cb;
+
+       // register id
+       rc = lxt_internal_setClientClass(handle);
+
+       if (rc < 0)
+       {
+#ifndef _NO_ESPRESSO_DEBUG_
+               printf("[VGSM] id registration failed\n");
+#endif // _NO_ESPRESSO_DEBUG_
+
+               // realease memory
+               free(handle);
+               return NULL;
+       }
+
+       // request missed message
+       rc = lxt_internal_MissedMessage(handle);
+
+       // request current state
+       rc = lxt_requestCurruntState(handle); // not implemented . Is it needed?
+
+       vgsm_ss_restoreEI(handle);
+
+       // return handle
+       return handle;
+}
+
+int vgsm_injector_get_fd(LXT_HANDLE *handle)
+{
+       return handle->fd;
+}
+
+/*
+int vgsm_release(LXT_HANDLE* handle)
+{
+    int rc = -1;
+    int exit_status; 
+
+    // check handle
+    if (handle == NULL)
+        return rc;
+
+    // check handle
+    if (handle->fd > 0)
+        rc = close(handle->fd);
+    else
+        rc = -1;
+    
+    
+
+    // free handle's memory
+    lxt_util_free(handle);
+
+    return rc;
+}
+*/
+
+// missed message request
+static int lxt_internal_MissedMessage(LXT_HANDLE* handle)
+{
+       return lxt_msg_send_message(    handle->fd,
+                                                                       LXT_GRP_INTERNAL,
+                                                                       LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST,
+                                                                       0x00,
+                                                                       NULL);
+
+}
+
+// tx client id to phone server
+static int lxt_internal_setClientClass(LXT_HANDLE* handle)
+{
+       return lxt_msg_send_message(    handle->fd,
+                                                                       LXT_GRP_INTERNAL,
+                                                                       LXT_PDA_INTERNAL_ID_REQUEST,
+                                                                       sizeof(int),
+                                                                       &(handle->clientclass));
+}
+
+int lxt_requestCurruntState(LXT_HANDLE* handle)
+{
+       return lxt_msg_send_message(    handle->fd,
+                                                                       LXT_GRP_INTERNAL,
+                                                                       LXT_PDA_INTERNAL_STATE_REQUEST,
+                                                                       0,
+                                                                       NULL);
+}
+
+// call back
+static int lxt_callback(LXT_HANDLE* handle)
+{
+       LIBVGSM_DEBUG("\n");
+
+       LXT_MESSAGE packet;
+       int length;
+       int group;
+       int action;
+       void *data;
+       int rc;
+
+       // check handle
+       if (handle == NULL)
+               return -1;
+
+       packet.data = NULL;
+
+       // rx information from server
+       rc = lxt_util_readRawBytes(handle->fd, &packet, 4);
+
+       if(rc != 4)
+       {
+               group = LXT_GRP_INTERNAL;
+               action = LXT_PHN_INTERNAL_SERVER_DIE_EMERGENCY;
+               handle->cb(group, action, 0, 0);
+               return -1;
+       }
+
+       // check length
+       if (packet.length > 0)
+       {
+               // allocated memory
+               packet.data = malloc(packet.length);
+               assert(packet.data != NULL);
+
+               // clear memory
+               memset(packet.data, 0, packet.length);
+
+               // rx data from server
+               rc = lxt_util_readRawBytes(handle->fd, packet.data, packet.length);
+
+#ifndef _NO_ESPRESSO_DEBUG_
+               assert(rc == packet.length);
+#endif
+       }
+       else
+       {
+               // init
+               packet.data = NULL;
+       }
+
+       // length
+       length = packet.length;
+
+       // group
+       group = packet.group;
+
+       // action
+       action = packet.action;
+
+       // data
+       data = packet.data;
+
+       if ( rc != length)
+               LIBVGSM_DEBUG ("Read data : read len = %d, len = %d \n",rc, length);
+
+       LIBVGSM_DEBUG("Client Read Data : CID[0x%x]length[%d]group[0x%x]action[0x%x]\n", handle->clientclass, length, group, action);
+       //lxt_util_rawdataPrint(data, length, "=============Call Back Data==================");
+
+       // call back
+       handle->cb(group, action, data, length);
+
+       if (packet.data != NULL)
+               free(packet.data);
+
+       return rc;
+}
+
+int vgsm_socket_read_callback(LXT_HANDLE* handle)
+{
+       return lxt_callback(handle);
+}
+
+LXT_HANDLE* vgsm_injector_initialize(LXT_CALLBACK cb)
+{
+       return lxt_initialize( LXT_ID_CLIENT_EVENT_INJECTOR, cb );
+}
+
+LXT_HANDLE* vgsm_manager_rx_initialize(LXT_CALLBACK cb)
+{
+       return lxt_initialize( LXT_ID_CLIENT_EVENT_MANAGER_RX, cb );
+}
+
+LXT_HANDLE* vgsm_manager_tx_initialize(LXT_CALLBACK cb)
+{
+       return lxt_initialize( LXT_ID_CLIENT_EVENT_MANAGER_TX, cb );
+}
+
+LXT_HANDLE* vgsm_manager_initialize(LXT_CALLBACK cb)
+{
+       return lxt_initialize( LXT_ID_CLIENT_EVENT_MANAGER, cb );
+}
+
+int vgsm_injector_release(LXT_HANDLE* handle)
+{
+       LIBVGSM_DEBUG("handle->fd = %d \n", handle->fd);
+
+       // check handle
+       if (handle == NULL)
+               return -1;
+
+       vgsm_client_release_notify(handle);
+
+       return 1;
+}
+
diff --git a/libvmodem/libvgsm_network.c b/libvmodem/libvgsm_network.c
new file mode 100644 (file)
index 0000000..27f856f
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+//#include "../vgsm/db_network.h"
+
+
+int vgsm_network_registration(LXT_HANDLE* handle, gsm_network_reg_t reg)
+{
+       int nretn = 0;
+       int     length = 9;
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)reg.act;
+       pdata[1] = (unsigned char)reg.service_domain;
+       pdata[2] = (unsigned char)reg.reg_status;
+       pdata[3] = (unsigned char)reg.edge_support;
+       pdata[4] = (unsigned char)reg.lac[0];
+       pdata[5] = (unsigned char)reg.lac[1];
+       pdata[6] = (unsigned char)reg.cell_id[0];
+       pdata[7] = (unsigned char)reg.cell_id[1];
+       pdata[8] = (unsigned char)reg.rej_cause;
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_NETWORK,
+                                                                       GSM_NETWORK_REG_NOTI,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
+
+/* vgsm network plmn information by cosmos in 20090212 */
+int vgsm_network_plmn_information(LXT_HANDLE* handle, gsm_network_plmn_info_t reg)
+{
+       int nretn = 0;
+       int     length = 9;
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, '0', length);
+
+       pdata[0] = (unsigned char)reg.act;
+       pdata[1] = (unsigned char)reg.statusplmn.status;
+       memcpy(pdata + 2, reg.statusplmn.plmn, 6);
+       pdata[8] = (unsigned char)reg.mode;
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_NETWORK,
+                                                                       GSM_NETWORK_CURRENT_PLMN_INFO,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+
+}
+
+/* vgsm network plmn information by cosmos in 20090212 */
+int vgsm_network_nitz_information(LXT_HANDLE* handle, gsm_network_nitz_info_t reg)
+{
+       int nretn = 0;
+       int     length = 56;
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       printf("size of gsm_network_nitz_info_t : %d\n",sizeof(reg));
+
+       if( handle == NULL )
+               return -1;
+
+       if (!pdata)
+               return (-1);
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)reg.mm_info_type;
+       pdata[1] = (unsigned char)reg.mask;
+
+       pdata[2] = (unsigned char)reg.shortname_ci;
+       pdata[3] = (unsigned char)reg.shortname_len;
+       pdata[4] = (unsigned char)reg.shortname_dcs;
+       memcpy(pdata + 5, reg.shortname, 16);
+
+       pdata[21] = (unsigned char)reg.longname_ci;
+       pdata[22] = (unsigned char)reg.longname_len;
+       pdata[23] = (unsigned char)reg.longname_dcs;
+       memcpy(pdata + 24, reg.longname, 32);
+
+       nretn = lxt_msg_send_message(   handle->fd,
+                                                                       GSM_NETWORK,
+                                                                       GSM_NETWORK_CURRENT_NITZ_INFO,
+                                                                       length,
+                                                                       pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
+int vgsm_network_plmn_list(LXT_HANDLE* handle, gsm_network_plmn_list_t plmn_list)
+{
+       int nretn = 0, i = 0, j = 1;
+       int length = 1+(plmn_list.num_record*8);
+
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
+       if (handle == NULL)
+               return -1;
+
+       if (!pdata)
+               return -1;
+
+       memset(pdata, 0, length);
+
+       pdata[0] = (unsigned char)plmn_list.num_record;
+
+       for (i = 0; i < pdata[0]; ++i) {
+               pdata[j++] = plmn_list.precord[i].status;
+               memcpy(&pdata[j], plmn_list.precord[i].plmn, 6);
+               j += 6;
+               pdata[j++] = plmn_list.precord[i].act;
+       }
+
+       nretn = lxt_msg_send_message( handle->fd, GSM_NETWORK,
+                                                               GSM_NETWORK_PLMN_LIST,  length, pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
+
+// added by mckim (2007.2.26)
+int vgsm_network_current_plmn(LXT_HANDLE *handle, gsm_network_plmn_record_t plmn)
+{
+       int length = 8;
+       int nretn = 0;
+
+       unsigned char *pdata = (unsigned char *)malloc(length);
+
+       if (handle == NULL || !pdata)
+               return -1;
+
+       memset(pdata, 0, length);
+
+       pdata[0] = 2;
+       pdata[1] = plmn.status;
+       memcpy(pdata + 2, plmn.plmn, 6);
+       pdata[8] = plmn.act;
+
+       lxt_msg_send_message(handle->fd, GSM_NETWORK,
+                                                 GSM_NETWORK_CURRENT_PLMN_NOTI, length, pdata);
+
+       if (pdata)
+               free(pdata);
+
+       return nretn;
+}
+
diff --git a/libvmodem/libvgsm_power.c b/libvmodem/libvgsm_power.c
new file mode 100644 (file)
index 0000000..7902102
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+#include "lxtutil.h"
+#include "vgsm_phone.h"
+
+int vgsm_power_modem_on_req_send(LXT_HANDLE * handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_POWER,
+                                                                       GSM_POWER_MODEM_ON_REQ,
+                                                                       0,
+                                                                       NULL);
+}
+
+int vgsm_power_battery_status(LXT_HANDLE* handle, battery_status_type_e level)
+{
+       unsigned char data = (unsigned char )level;
+
+       printf("level : %d, %x\n", data, data);
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_POWER,
+                                                                       GSM_POWER_BATTERY_STATUS_NOTI,
+                                                                       0x01,
+                                                                       &data);
+}
+
diff --git a/libvmodem/libvgsm_sat.c b/libvmodem/libvgsm_sat.c
new file mode 100644 (file)
index 0000000..be689ff
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/***************************************************************************************
+ *
+ * Copyright (c) 2008 SAMSUNG Co. Ltd,
+ * All rights reserved.
+ *
+ * File: vgsm_sat.c
+ *
+ * Release:
+ *
+ * Description: libvgsm interface.
+ *
+ * Revision History
+ *
+****************************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "lxtutil.h"
+#include "vgsm.h"
+#include "../vmodem/include/sat/sat_values.h"
+
+
+int vgsm_proactive_cmd_send(LXT_HANDLE * handle,int command)
+{
+       printf("\[LIBVGSM-SIM] vgsm_proactive_cmd_send\n\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SAT,
+                                                                       GSM_SAT_PROACTIVE_COMMAND_SEND,
+                                                                       1,
+                                                                       (void *)command);
+}
+
+
+int vgsm_sat_display_text(LXT_HANDLE * handle,char priority,char  clear_msg,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit )
+{
+       printf("\n vgsm_sat_display_text\n");
+
+       DP_TEXT *dp_text;
+       dp_text = malloc(sizeof(DP_TEXT));
+       int ret;
+
+       memset(dp_text,0,sizeof(DP_TEXT));
+
+       if( handle == NULL )
+               return -1;
+
+       dp_text->priority                               =       priority;
+       dp_text->clear_msg                      =       clear_msg;
+       memcpy(dp_text->text_string,textstring,strlen(textstring));
+       dp_text->coding_scheme          =       coding_scheme;
+       dp_text->icon_identifier_flag           =       icon_identifier_flag;
+       dp_text->icon_qualifier                 =       icon_qualifier;
+       dp_text->icon_identifier                        =       0;
+       dp_text->immediate_response     =       immediate_response;
+       dp_text->duration                               =       duration;
+       dp_text->duration_unit                  =       duration_unit;
+
+       //printf("IN libvgsm - text is %s and  netxt test is %s",textstring,dp_text->text_string);
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_DISPLAY_TEXT,
+                       sizeof(DP_TEXT),
+                       dp_text
+               );
+
+       if(dp_text)
+               free(dp_text);
+
+       return ret;
+}
+
+
+int vgsm_sat_get_inkey(LXT_HANDLE * handle,char cmd_detail,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit )
+{
+       printf("\n vgsm_sat_get_inkey\n");
+
+       GET_INKEY *get_inkey;
+       get_inkey = malloc(sizeof(GET_INKEY));
+       int ret;
+       memset(get_inkey,0,sizeof(GET_INKEY));
+
+
+       if( handle == NULL )
+               return -1;
+
+       get_inkey->cmd_detail                   =       cmd_detail;
+       memcpy(get_inkey->text_string,textstring,strlen(textstring));
+       get_inkey->coding_scheme                =       coding_scheme;
+       get_inkey->icon_identifier_flag =       icon_identifier_flag;
+       get_inkey->icon_qualifier               =       icon_qualifier;
+       get_inkey->icon_identifier              =       0;
+       get_inkey->immediate_response   =       immediate_response;
+       get_inkey->duration                     =       duration;
+       get_inkey->duration_unit                =       duration_unit;
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_GET_INKEY,
+                       sizeof(GET_INKEY),
+                       get_inkey
+               );
+
+       if(get_inkey)
+               free(get_inkey);
+
+       return ret;
+}
+
+
+int vgsm_sat_get_input(LXT_HANDLE * handle,char cmd_detail,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit )
+{
+       printf("\n vgsm_sat_get_input\n");
+
+       GET_INPUT *get_input;
+       get_input = malloc(sizeof(GET_INPUT));
+       int ret;
+       memset(get_input,0,sizeof(GET_INPUT));
+
+       if( handle == NULL )
+               return -1;
+
+       get_input->cmd_detail                   =       cmd_detail;
+       memcpy(get_input->text_string,textstring,strlen(textstring));
+       get_input->coding_scheme                =       coding_scheme;
+       get_input->icon_identifier_flag =       icon_identifier_flag;
+       get_input->icon_qualifier               =       icon_qualifier;
+       get_input->icon_identifier              =       0;
+       get_input->immediate_response   =       immediate_response;
+       get_input->duration                     =       duration;
+       get_input->duration_unit                =       duration_unit;
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_GET_INPUT,
+                       sizeof(GET_INPUT),
+                       get_input
+               );
+
+       if(get_input)
+               free(get_input);
+
+       return ret;
+}
+
+
+int vgsm_sat_set_up_menu(LXT_HANDLE * handle,unsigned char cmd_detail,int num,void * set_up_item )
+{
+       printf("\n vgsm_sat_set_up_menu \n");
+
+       unsigned char *data;
+       data = malloc(num * sizeof(SET_MENU) + 2);
+//     int i=0;
+       int ret=0;
+       memset(data,0,num *sizeof(SET_MENU) + 2);
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] =(unsigned char)num;
+       data[1] = cmd_detail;
+       memcpy(&data[2],(unsigned char *)set_up_item,num *sizeof(SET_MENU));
+       printf("data num is <%x>\n",data[0]);
+       printf("data cmd_detail is <%x>\n",data[1]);
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_SET_MENU,
+                       (num * sizeof(SET_MENU) + 2),
+                       data
+               );
+
+       if(data)
+               free(data);
+
+       return ret;
+}
+
+
+int vgsm_sat_select_item(LXT_HANDLE * handle, unsigned char cmd_detail, int num, void * set_up_item )
+{
+       printf("\n vgsm_sat_select_item \n");
+
+       unsigned char *data;
+       data = malloc(num * sizeof(SET_MENU) + 2);
+//     int i=0;
+       int ret=0;
+       memset(data,0,num *sizeof(SET_MENU) + 2);
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] =(unsigned char)num;
+       data[1] = cmd_detail;
+       memcpy(&data[2],(unsigned char *)set_up_item,num *sizeof(SET_MENU));
+
+       printf("data num is <%x>\n",data[0]);
+       printf("data cmd_detail is <%x>\n",data[1]);
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_SELECT_ITEM,
+                       (num * sizeof(SET_MENU) + 2),
+                       data
+               );
+
+       if(data)
+               free(data);
+
+       return ret;
+}
+
+
+int vgsm_sat_send_sms(LXT_HANDLE * handle, unsigned char cmd_detail, unsigned char address, char *number, unsigned char* sms_tpdu   )
+{
+       printf("\n vgsm_sat_send_sms \n");
+
+       //unsigned char *data;
+       SEND_SMS *send_sms_packet;
+       int ret=0;
+       send_sms_packet = malloc(sizeof(SEND_SMS));
+       memset(send_sms_packet,0,sizeof(SEND_SMS));
+
+       if( handle == NULL )
+               return -1;
+
+       send_sms_packet->cmd_detail=cmd_detail;
+       send_sms_packet->address=address ;
+       memcpy(send_sms_packet->dial_num,number,strlen(number));
+       //080117 - remove compile warning msg due to sms_tpdu.
+       memcpy(send_sms_packet->tpdu_sms,sms_tpdu,strlen((char*)sms_tpdu));
+
+       printf("\n SMS DIAL NUM is %s",send_sms_packet->dial_num);
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_SEND_SMS,
+                       sizeof(SEND_SMS),
+                       send_sms_packet
+               );
+
+       if(send_sms_packet)
+               free(send_sms_packet);
+
+       return ret;
+}
+
+
+ int vgsm_sat_set_up_call(LXT_HANDLE * handle,unsigned char cmd_detail,char* dial_number,char *alpha_user,/*char *alpha_call ,*/unsigned char address,unsigned char options,char duration_unit)
+{
+       printf("\n vgsm_sat_send_sms \n");
+
+       unsigned char *data = NULL;
+       unsigned char *pdata = NULL;
+       char dial_len;
+       char alpha_user_len;
+//     char alpha_call_len;
+       char size = 0;
+       int ret=0;
+
+       switch(options)
+       {
+               case 0x00 : // not options
+                       dial_len = strlen(dial_number);
+                       size = 1+1+1+dial_len+1;
+                       data = malloc(size); // option(1) +cmd_detail(1)+dial len(1)+dial size+ address(1)
+                       memset(data,0,size);
+
+                       pdata = data;
+                       *pdata++ = options;
+                       *pdata++ =cmd_detail ;
+                       *pdata++ = dial_len;
+                       memcpy(pdata,dial_number,dial_len);
+                       pdata += dial_len;
+                       *pdata++ = address;
+
+                       break;
+
+               case 0x01: // alpha_
+                       dial_len = strlen(dial_number);
+                       alpha_user_len = strlen(alpha_user);
+                       //alpha_call_len = strlen(alpha_call);
+                       size = 1+1+1+dial_len+1+alpha_user_len+1+/*alpha_call_len+*/1;
+                       data = malloc(size); //option(1)+ cmd_detail(1)+dial len(1)+dial size+alpha_user len(1)alpha_user size++alpha_call len(1)+alpha_call size+ address(1)
+                       memset(data,0,size);
+
+                       pdata = data;
+                       *pdata++ = options;
+                       *pdata++ =cmd_detail ;
+
+                       *pdata++ = dial_len;
+                       memcpy(pdata,dial_number,dial_len);
+                       pdata += dial_len;
+
+                       *pdata++ = alpha_user_len;
+                       memcpy(pdata,alpha_user,alpha_user_len);
+                       pdata += alpha_user_len;
+
+/*
+                       *pdata++ = alpha_call_len;
+                       memcpy(pdata,alpha_call,alpha_call_len);
+                       pdata += alpha_call_len;
+*/
+                       *pdata++ = address;
+
+
+                       break;
+               case 0x02: // DURATION
+                       dial_len = strlen(dial_number);
+                       dial_len = strlen(dial_number);
+                       size = 1+1+1+dial_len+1+1;
+                       data = malloc(size); //option(1)+ cmd_detail(1)+dial len(1)+dial size+ address(1)+unit(1)
+                       memset(data,0,size);
+
+                       pdata = data;
+                       *pdata++ = options;
+                       *pdata++ =cmd_detail ;
+                       *pdata++ = dial_len;
+                       memcpy(pdata,dial_number,dial_len);
+                       pdata += dial_len;
+                       *pdata++ = address;
+                       *pdata++ = duration_unit;
+
+
+                       break;
+               case 0x03: //  alpha_ & DURATION
+                       dial_len = strlen(dial_number);
+                       alpha_user_len = strlen(alpha_user);
+                       //alpha_call_len = strlen(alpha_call);
+                       size = 1+1+1+dial_len+1+alpha_user_len+1+/*alpha_call_len+*/1+1;
+                       data = malloc(size); // option(1)+cmd_detail(1)+dial len(1)+dial size+alpha_user len(1)alpha_user size++alpha_call len(1)+alpha_call size+ address(1)+unit(1)
+                       memset(data,0,size);
+
+                       pdata = data;
+                       *pdata++ = options;
+                       *pdata++ =cmd_detail ;
+
+                       *pdata++ = dial_len;
+                       memcpy(pdata,dial_number,dial_len);
+                       pdata += dial_len;
+
+                       *pdata++ = alpha_user_len;
+                       memcpy(pdata,alpha_user,alpha_user_len);
+                       pdata += alpha_user_len;
+/*
+                       *pdata++ = alpha_call_len;
+                       memcpy(pdata,alpha_call,alpha_call_len);
+                       pdata += alpha_call_len;
+*/
+                       *pdata++ = address;
+                       *pdata++ = duration_unit;
+
+                       printf("\n @- dial_number is %s",dial_number);
+                       printf("\n @- alpha_user is %s",alpha_user);
+               //      printf("\n @- alpha_call is %s",alpha_call);
+
+                       break;
+
+       }
+
+       printf("\n vgsm_sat_set_up_call \n");
+
+       if( handle == NULL )
+               return -1;
+
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SAT,
+                       GSM_SAT_PROACTIVE_SET_UP_CALL,
+                       size,
+                       data
+               );
+
+       if(data)
+               free(data);
+
+       return ret;
+}
+
diff --git a/libvmodem/libvgsm_sim.c b/libvmodem/libvgsm_sim.c
new file mode 100644 (file)
index 0000000..d2fccde
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/***************************************************************************************
+ *
+ * Copyright (c) 2008 SAMSUNG Co. Ltd,
+ * All rights reserved.
+ *
+ * File: vgsm_sim.c
+ *
+ * Release:
+ *
+ * Description: libvgsm interface.
+ *
+ * Revision History
+ * JANUARY/17/2008   Kyeongchul Kim  Initial revision
+ *
+****************************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "lxtutil.h"
+#include "vgsm.h"
+
+
+int vgsm_sim_init(LXT_HANDLE * handle)
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_init\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_INIT_REQ,
+                       0,
+                       NULL
+               );
+}
+
+int vgsm_sim_reinit(LXT_HANDLE * handle)
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_reinit\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_REINIT_REQ,
+                       0,
+                       NULL
+               );
+}
+
+int vgsm_sim_savedata(LXT_HANDLE * handle, _SIMD_t *simd_t )
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_savedata\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIMSAVE_REQ,        // 0xD5
+                       sizeof(_SIMD_t),
+                       simd_t
+               );
+}
+
+int vgsm_get_siminfo_db(LXT_HANDLE * handle, int *list )
+{
+       printf("[LIBVGSM-SIM] vgsm_get_siminfo_db\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIMINFO_REQ,        // 0xD1
+                       sizeof(int),
+                       list
+               );
+}
+
+int vgsm_get_simdata_db(LXT_HANDLE * handle, int *list)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_simdata_db\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIMDATA_REQ,        // 0xD2
+                       sizeof(int),
+                       list    
+               );
+}
+
+int vgsm_get_sim_db(LXT_HANDLE * handle)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_sim_db\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_GET_SIM_DB_REQ,
+                       0,
+                       NULL
+               );
+}
+
+int vgsm_make_pb_db(LXT_HANDLE * handle)
+{
+       printf("[LIBVGSM-SIM] vgsm_make_pb_db\n");
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_MAKE_PB_DB_REQ,
+                       0,
+                       NULL
+               );
+}
+
+
+int vgsm_get_all_pb_db(LXT_HANDLE * handle,  gsm_pb_storage_type_e_type storage_type)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_pb_db\n");
+
+       PB_ *pb;
+       pb = malloc(sizeof(PB_));
+       memset(pb,0,sizeof(PB_));
+       int ret;
+       
+       if( handle == NULL ||(int) storage_type < 0 || storage_type > GSM_PB_ST_GAS )
+               return -1;
+
+       pb->db_st_type = storage_type;
+       
+       printf("vgsm_get_all_pb_db : %d ",pb->db_st_type);
+       
+       ret =  lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_GET_ALL_PB_DB_REQ,
+                       sizeof(PB_),
+                       pb
+               );
+
+       if(pb) free(pb);
+       
+       return ret;
+}
+
+
+int vgsm_get_pb_db(LXT_HANDLE * handle, gsm_pb_storage_type_e_type storage_type, char* index_)
+{
+       printf("[LIBVGSM-SIM] vgsm_get_pb_db\n");
+
+       PB_ *pb;
+       pb = malloc(sizeof(PB_));
+       memset(pb,0,sizeof(PB_));
+       int ret;
+       
+       if( handle == NULL ||(int)storage_type < 0 || storage_type > GSM_PB_ST_GAS )
+               return -1;
+       
+       pb->db_st_type  = storage_type;
+       //pb->index             = atoi(index_);
+       memcpy(pb->address,index_,strlen(index_));
+       
+
+       printf("vgsm_get_pb_db : %d , %s ",pb->db_st_type,pb->address);
+       
+       ret =  lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_GET_PB_DB_REQ,
+                       sizeof(PB_),
+                       pb
+               );
+
+       if(pb) free(pb);
+       
+       return ret;
+}
+
+
+int vgsm_add_pb_db(LXT_HANDLE * handle, gsm_pb_storage_type_e_type storage_type, char* name, char* number, char* index_)
+{
+       printf("[LIBVGSM-SIM] vgsm_add_pb_db\n");
+
+       PB_ *pb;
+       pb = malloc(sizeof(PB_));
+       int ret;
+       
+       memset(pb,0,sizeof(PB_));
+
+       if( handle == NULL ||(int)storage_type < 0 || storage_type > GSM_PB_ST_GAS )
+               return -1;
+
+       printf(" \n** 1 **");
+       pb->db_st_type = storage_type;
+       printf(" \n** 2 **");
+       memcpy(pb->number,name,strlen(name));
+       memcpy(pb->address,number,strlen(number));
+       memcpy(pb->name,index_,strlen(index_));
+
+       printf("vgsm_add_pb_db : %d , %s ,%s, %s",pb->db_st_type,pb->name,pb->number,pb->address);
+       
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_ADD_PB_DB_REQ,
+                       sizeof(PB_),
+                       pb
+               );
+
+       if(pb) free(pb);
+       
+       return ret;
+}
+
+
+int vgsm_delete_pb_db(LXT_HANDLE * handle, gsm_pb_storage_type_e_type storage_type, char* index_)
+{
+       printf("[LIBVGSM-SIM] vgsm_delete_pb_db\n");
+
+       PB_ *pb;
+       pb = malloc(sizeof(PB_));
+       int ret;
+       memset(pb,0,sizeof(PB_));
+
+       if( handle == NULL ||(int)storage_type < 0 || storage_type > GSM_PB_ST_GAS )
+               return -1;
+       
+       pb->db_st_type  = storage_type;
+       //pb->index             = atoi(index_);
+       memcpy(pb->name,index_,strlen(index_));
+       
+       printf("vgsm_delete_pb_db : %d , %s ",pb->db_st_type,pb->name);
+       
+       ret = lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_DELETE_PB_DB_REQ,
+                       sizeof(PB_),
+                       pb
+               );
+
+       if(pb) free(pb);
+       
+       return ret;
+}
+
+
+int vgsm_sim_status_set(LXT_HANDLE * handle, gsm_sec_status_type status)
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_status_set\n");
+
+       unsigned char data = (unsigned char )status;
+
+       if( handle == NULL || (int)status < 0 || status > GSM_SEC_STATUS_NO_SIM)
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_STATUS_SET,
+                       1,
+                       &data
+               );
+}
+
+
+int vgsm_sim_change_password(LXT_HANDLE * handle,      gsm_sec_lock_e_type type, char *password, int length)
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_change_password\n");
+
+       //if ( type != GSM_SEC_LOCK_TYPE_SC && type != GSM_SEC_LOCK_TYPE_SC2 )  // original before 090215
+       //090215
+       if ( type != GSM_SEC_LOCK_TYPE_SC && type != GSM_SEC_LOCK_TYPE_SC2 && type != GSM_SEC_LOCL_TYPE_PUK2 && type != GSM_SEC_LOCL_TYPE_PUK)
+               return -1;
+
+       char *new_password=0;
+       new_password = malloc(length + 1); // 1 <= type
+
+       if(!new_password)
+               printf("memory alloc err");
+
+       new_password[0] = (char)type;
+       memcpy(&new_password[1],password,length);
+
+       printf(" [LIBVGSM-SIM]  input password =[%s] \n\n",&new_password[1]);
+
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_CHANGE_PASS_SET,
+                       length+1,
+                       new_password
+               );
+}
+
+
+int vgsm_sim_facility_set(LXT_HANDLE * handle, gsm_sec_lock_e_type type, gsm_sec_lock_mode_e_type flag)
+{
+       printf("[LIBVGSM-SIM] vgsm_sim_facility_set\n");
+
+       unsigned char data[2];
+       data[0]= (unsigned char )type;
+       data[1]= (unsigned char )flag;
+
+       printf("[LIBVGSM-SIM] vgsm_sim_facility_set - type, flag = [%d],[%d]\n", type, flag);
+/*
+       if ( type != GSM_SEC_LOCK_TYPE_SC && type != GSM_SEC_LOCK_TYPE_FD )
+               return -1;
+*/
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message
+               (
+                       handle->fd,
+                       GSM_SIM,
+                       GSM_SIM_FACILITY_SET,
+                       2,
+                       data
+               );
+}
+
diff --git a/libvmodem/libvgsm_sms.c b/libvmodem/libvgsm_sms.c
new file mode 100644 (file)
index 0000000..cecae95
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+
+extern BOOL EncodeCB_GSM(CELLBROADCASTING cb_msg, char *rawdata, int *rawdata_len);
+
+// sms group function +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+/* modified sms msg click by cosmos in 20090213 */
+int vgsm_sms_sendMessage(LXT_HANDLE* handle, SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, BYTE pid)
+{
+
+       char data[500];
+       int len = 0;
+
+       if( handle == NULL )
+               return -1;
+
+       memset( data, 0, 500 );
+
+       /* EncodeSmsDeliverTpdu argument added : pid, dcs */;
+       EncodeSmsDeliverTpdu( SCA, tpdu_deliver, data, &len, pid);
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SMS,
+                                                                       GSM_SMS_SEND_MSG_REQ,
+                                                                       len,
+                                                                       data);
+                                                                       
+}
+
+int vgsm_sms_sendAck(LXT_HANDLE* handle, int error)
+{
+       unsigned char data[2];
+
+       if( handle == NULL )
+               return -1;
+
+       data[0] = (unsigned short)error & 0x00ff;
+       data[1] = ((unsigned short)error >> 8) & 0x00ff;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SMS,
+                                                                       GSM_SMS_SEND_ACK_REQ,
+                                                                       0x02,
+                                                                       &data);
+}
+
+int vgsm_cb_sendMessage(LXT_HANDLE* handle, CELLBROADCASTING cb_msg )
+{
+       char data[500];
+       int len = 0;
+
+       if( handle == NULL )
+               return -1;
+
+       memset( data, 0, 500 );
+
+       // EncodeSmsDeliverTpdu( SCA, tpdu_deliver, data, &len );
+       EncodeCB_GSM(cb_msg, data, &len);
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SMS,
+                                                                       GSM_SMS_INCOMING_CB_MSG_REQ,
+                                                                       len,
+                                                                       data);
+}
+
+
diff --git a/libvmodem/libvgsm_ss.c b/libvmodem/libvgsm_ss.c
new file mode 100644 (file)
index 0000000..813c65e
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm.h"
+
+int vgsm_ss_conference(LXT_HANDLE* handle)  // this is not used, and is not needed.
+{
+       if( handle == NULL )
+               return -1;
+
+    return lxt_msg_send_message(       handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_CONFERENCE,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+int vgsm_ss_hold(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_HOLD,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+int vgsm_ss_unhold(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_UNHOLD,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+// 090215
+int vgsm_ss_getAOC(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_AOC_GET,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+// 090326
+int vgsm_ss_restoreEI(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       0x11,
+                                                                       GSM_SUPS_AOC_GET,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+// 090330, 090403
+int vgsm_ss_setCW(LXT_HANDLE* handle, _setCW_t *setCW, int size)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_CW_SET,
+                                                                       size,
+                                                                       setCW);
+}
+
+int vgsm_ss_setCF(LXT_HANDLE* handle, _setCF_t *setCF, int size)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_CF_SET,
+                                                                       size,
+                                                                       setCF);
+}
+
+int vgsm_ss_setCB(LXT_HANDLE* handle, _setCB_t *setCB, int size)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_CB_SET,
+                                                                       size,
+                                                                       setCB);
+}
+
+// 090213
+int vgsm_ss_getUSSD(LXT_HANDLE* handle)
+{
+       if( handle == NULL )
+               return -1;
+
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_USSD_GET,
+                                                                       0x00,
+                                                                       NULL);
+}
+
+int vgsm_ss_setUSSD(LXT_HANDLE* handle, _USSD_data_t *ussd, int size)
+{
+       if( handle == NULL )
+               return -1;
+
+#if 1
+       printf("************in libvgsm_ss***************\n");
+       printf("time: %s, weather: %s\n",
+       ussd->time, ussd->weather);
+
+       printf("data length : %d\n",sizeof(*ussd));
+       printf("time length : %d\n",sizeof(ussd->time));
+       printf("weather length : %d\n",sizeof(ussd->weather));
+       printf("size : %d\n", size);
+#endif
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_USSD_SET,
+                                                                       size,
+                                                                       ussd);
+}
+
+int vgsm_ss_setAOC(LXT_HANDLE* handle, _AOC_t *aoc, int size)
+{
+       if( handle == NULL )
+               return -1;
+
+#if 1
+       printf("************in libvgsm_ss***************\n");
+       printf("acm: %ld, ccm: %ld, maxacm: %ld, ppu: %ld, chartype: %c\n",
+       aoc->acm, aoc->ccm, aoc->maxacm, aoc->ppu,
+       aoc->chartype);
+
+       printf("data length : %d\n",sizeof(*aoc));
+       printf("acm length : %d\n",sizeof(aoc->acm));
+       printf("type length : %d\n",sizeof(aoc->ccm));
+       printf("type length : %d\n",sizeof(aoc->maxacm));
+       printf("type length : %d\n",sizeof(aoc->ppu));
+       printf("type length : %d\n",sizeof(aoc->chartype));
+       printf("size : %d\n", size);
+#endif
+       return lxt_msg_send_message(    handle->fd,
+                                                                       GSM_SUPS,
+                                                                       GSM_SUPS_AOC_SET,
+                                                                       size,
+                                                                       aoc);
+}
diff --git a/libvmodem/linuxtapi.h b/libvmodem/linuxtapi.h
new file mode 100644 (file)
index 0000000..3f1fdc9
--- /dev/null
@@ -0,0 +1,960 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LINUXTAPI_H_
+#define _LINUXTAPI_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "phoneprotocol.h"
+#include "linuxtapi4type.h"
+#include "tapi4phonebook.h"
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+#define DEF_SMS_MAX_DIGIT_NUMBER                                             32
+#define DEF_SMS_MAX_DATETIME                                                  6
+#define DEF_SMS_MAX_CONTENTS                                                256
+#define DEF_SMS_MAX_ELEMENT                                                  64
+#define DEF_PHONEBOOK_MAX_ALPHA                                              32
+#define DEF_PHONEBOOK_MAX_DIGIT                                              32
+#define DEF_PHONEBOOK_MAX_ELEMENT                                           256
+#define DEF_CABLE_KIND_NONE                                                   0
+#define DEF_CABLE_KIND_TRABAL_CHARGER                                         1
+#define DEF_CABLE_KIND_HW_TEST                                              100
+
+
+    // tapi +++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define of linux tapi message
+    //
+    typedef struct // lxt_message
+    {
+        unsigned short length;
+        unsigned char group;
+        unsigned char action;
+        void *data;
+    }
+    LXT_MESSAGE;
+
+    // define of call back function
+    typedef int (*LXT_CALLBACK)(int group, int action, void* data, int length);
+
+    // define of linux tapi handle
+    typedef struct _lxt_handle
+    {
+        int fd;
+        int clientclass;
+        LXT_CALLBACK cb;
+
+    }
+    LXT_HANDLE;
+
+    // sms ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define of sms header
+    typedef struct
+    {
+
+        // memory index
+        unsigned char memoryIndex;
+
+        // tag
+        unsigned char tag;
+
+        // remaining frame count
+        unsigned char rfr_cnt;
+
+        // pTop or broadcast message
+        unsigned char sms_msg_cat;
+
+        // sms param mask
+        unsigned char sms_param_mask[4];
+
+        // teleservice
+        unsigned char teleservice_id;
+
+        // message type
+        unsigned char message_type;
+
+        // message id
+        unsigned short message_id;
+
+        // bearer reply option
+        unsigned char bearer_reply_option;
+
+        // message center time stamp
+        unsigned char message_center_time_stamp[DEF_SMS_MAX_DATETIME];
+
+        // validity period
+        unsigned char validity_period_absolute[DEF_SMS_MAX_DATETIME];
+
+        // language indicator
+        unsigned char language_indicator;
+
+        // user data encoding
+        unsigned char data_encoding;
+
+        // destination number
+        unsigned char destination_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+        // call back number
+        unsigned char call_back_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+        // number of message(voice)
+        unsigned char number_of_messages;
+
+        // priority indicator
+        unsigned char priority_indicator;
+
+        // priority indicator
+        unsigned char reply_option;
+
+        // message display mode
+        unsigned char message_display_mode[3];
+
+        // size of user data
+        unsigned char size;
+
+    }
+    LXT_SMS_HEADER;
+
+    // define of sms body
+    typedef struct
+    {
+        // user data
+        unsigned char content[DEF_SMS_MAX_CONTENTS];
+
+    }
+    LXT_SMS_BODY;
+
+    // define of sms
+    typedef struct
+    {
+        char isRead;
+        LXT_SMS_HEADER header;
+        LXT_SMS_BODY body;
+
+    }
+    LXT_SMS;
+
+
+    // define sms set
+    typedef struct
+    {
+        int capacityOfRecord;
+        int capacityOfAllField;
+        int countUnread;
+        int countTotal;
+        LXT_SMS smsElement[DEF_SMS_MAX_ELEMENT];
+
+    }
+    LXT_SMS_SET;
+
+
+    typedef enum
+    {
+        LXT_SMS_TAG_SMSI_INVALID                                                = 0x00,
+        LXT_SMS_TAG_SMSI_MT_READ                                                = 0x01,
+        LXT_SMS_TAG_SMSI_MT_NOT_READ                                            = 0x03,
+        LXT_SMS_TAG_SMSI_MO_SENT                                                = 0x05,
+        LXT_SMS_TAG_SMSI_MO_NOT_SENT                                            = 0x07
+
+    } LXT_SMS_TAG;
+
+    typedef enum
+    {
+        LXT_SMS_DELIVERY_STATUS_SUCCESS                                         = 0x00,
+        LXT_SMS_DELIVERY_STATUS_FULL                                            = 0x01
+
+    } LXT_SMS_DELIVERY_STATUS;
+
+
+    // uim phone book +++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        int memoryIndex;
+        int sizeAlpha;
+        char alpha[DEF_PHONEBOOK_MAX_ALPHA];
+        int sizeDigit;
+        char digit[DEF_PHONEBOOK_MAX_DIGIT];
+
+    }
+    LXT_PHONEBOOK_ELEMENT;
+
+    // phone book set
+    typedef struct
+    {
+        int capacityOfRecord;
+        int capacityOfNameField;
+        LXT_PHONEBOOK_ELEMENT phoneBookElement[DEF_PHONEBOOK_MAX_ELEMENT];
+
+    }
+    LXT_PHONEBOOK_SET;
+
+
+
+    // utk ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define of utk header
+    typedef struct
+    {
+        unsigned char count;
+    }
+    LXT_UTK_MENU_HEADER;
+
+    // define of utk body
+    typedef struct
+    {
+        // user data
+        unsigned char *user_data;
+        unsigned char *param_idx;
+    }
+    LXT_UTK_MENU_BODY;
+
+    // define of utk GET input header
+    typedef struct
+    {
+        unsigned char default_text_size;
+        unsigned char item_text_size;
+        unsigned char word_input;
+        unsigned char in_mode;
+        unsigned char min_length;
+        unsigned char max_length;
+        unsigned char hidden_num;
+        unsigned char packed_format;
+        unsigned char itemIndex;
+        unsigned char input_type;
+
+    }
+    LXT_UTK_GETINPUT_HEADER;
+
+    // define of utk get input header
+    typedef struct
+    {
+        unsigned char *default_text;
+        unsigned char *item_text;
+
+    }
+    LXT_UTK_GETINPUT_BODY;
+
+    // define of utk GET Display Text header
+    typedef struct
+    {
+        unsigned char count;
+
+    }
+    LXT_UTK_DISPLAY_TEXT_HEADER;
+
+    // define of utk Display Text header
+    typedef struct
+    {
+        unsigned char *item_text;
+
+    }
+    LXT_UTK_DISPLAY_TEXT_BODY;
+
+    // define of utk get input body
+    typedef struct
+    {
+        unsigned char                           utk_status;
+        LXT_UTK_MENU_HEADER                     menu_header;
+        LXT_UTK_MENU_BODY                       menu_body;
+        LXT_UTK_GETINPUT_HEADER                 input_header;
+        LXT_UTK_GETINPUT_BODY                   input_body;
+        LXT_UTK_DISPLAY_TEXT_HEADER             display_text_header;
+        LXT_UTK_DISPLAY_TEXT_BODY               display_text_body;
+
+    }
+    LXT_UTK;
+
+    // define of utk start state
+    typedef enum
+    {
+        LXT_UTK_START_SUCCESS                                                   = 0x00,
+        LXT_UTK_START_FAIL_GSM_MODE                                             = 0x01,
+        LXT_UTK_START_FAIL_NOT_INITIALIZED                                      = 0x02,
+        LXT_UTK_START_FAIL_INVALID_STATE                                        = 0x03
+
+    } LXT_UTK_START_STATUS;
+
+    // define of utk input mode
+    typedef enum
+    {
+        LXT_UTK_INPUT_MODE_T9                                                   = 0x00,
+        LXT_UTK_INPUT_MODE_YES_NO                                               = 0x01,
+        LXT_UTK_INPUT_MODE_NUMBER_ONLY                                          = 0x02,
+        LXT_UTK_INPUT_MODE_PINYIN                                               = 0x03
+
+    } LXT_UTK_INPUT_MODE;
+
+
+    // gps ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        unsigned char teleservice_id;
+        unsigned char digit_mode;
+        unsigned char num_mode;
+        unsigned char num_type;
+        unsigned char num_plan;
+        unsigned char num_fields;
+        unsigned char data[48];
+        unsigned char data_len;
+        unsigned char encoding;
+        unsigned char number_of_digits;
+        unsigned char version;
+        unsigned char notification_verification_indicator;
+        unsigned char pos_tech_indicator;
+        unsigned char corr_id;
+        unsigned char pde_ip_address[4];
+        unsigned char pde_port_num[2];
+        unsigned char req_id[64];
+        unsigned char padding_bits;
+        unsigned char message_type;
+        unsigned char message_id[2];
+        unsigned char is_tl_ack_request;
+        unsigned char transaction_id[4];
+
+    }
+    LXT_GPS_MT_SMS_DATA;
+
+    typedef struct
+    {
+        unsigned char consent_indicator;
+        unsigned char mpc_address[4];
+        unsigned char mpc_port[4];
+        unsigned char default_or_local;
+        unsigned char default_address[4];
+        unsigned char default_port[4];
+        unsigned char local_address[4];
+        unsigned char local_port[4];
+
+    }
+    LXT_GPS_MO_DATA;
+
+    typedef struct
+    {
+        LXT_GPS_MT_SMS_DATA mt_data;
+        LXT_GPS_MO_DATA     mo_data;
+
+    }
+    LXT_GPS_MO_SMS_DATA;
+
+    typedef struct
+    {
+        unsigned char wap_url_length;
+        unsigned char wap_url[128];
+    }
+    LXT_GPS_URL_DATA;
+
+
+    typedef enum
+    {
+        LXT_GPS_CONSENT_INDICATOR_GIVEN                                     = 0x00,
+        LXT_GPS_CONSENT_INDICATOR_DENY                                      = 0x01,
+        LXT_GPS_CONSENT_INDICATOR_EXPIRED                                   = 0x02,
+        LXT_GPS_CONSENT_INDICATOR_MS_REFUSED                                = 0x03,
+        LXT_GPS_CONSENT_INDICATOR_NOT_NEEDED                                = 0x04,
+        LXT_GPS_CONSENT_INDICATOR_ERROR                                     = 0x05,
+        LXT_GPS_CONSENT_INDICATOR_UNDEFINED                                 = 0xFF
+
+    } LXT_GPS_CONSENT_INDICATOR;
+
+    typedef enum
+    {
+        LXT_GPS_VERIFICATION_NEEDED                                         = 0x00,
+        LXT_GPS_VERIFICATION_NOT_NEEDED                                     = 0x01
+
+    } LXT_GPS_VERIFICATION;
+
+    typedef enum
+    {
+        LXT_GPS_POS_TECH_IS_801                                             = 0x00,
+        LXT_GPS_POS_TECH_CELL_SECTOR                                        = 0x01,
+        LXT_GPS_POS_TECH_DO_NOTHING                                         = 0x02
+
+    } LXT_GPS_POS_TECH;
+
+    typedef enum
+    {
+        LXT_GPS_END_REASON_NONE                                             = 0x00,
+        LXT_GPS_END_REASON_BY_USER                                          = 0x01
+
+    } LXT_GPS_END_REASON;
+
+    typedef enum
+    {
+        LXT_GPS_PDE_SERVER_DEFAULT                                          = 0x00,
+        LXT_GPS_PDE_SERVER_LOCAL                                            = 0x01
+
+    } LXT_GPS_PDE_SERVER;
+
+
+    // about configuration ++++++++++++++++++++++++++++++++++++++
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_PHONE_LOCK_NON_ACTIVE                                 = 0x00,
+        LXT_CONFIGURATION_PHONE_LOCK_ACTIVE                                     = 0x01
+
+    } LXT_CONFIGURATION_PHONE_LOCK;
+
+    typedef enum
+    {
+        LXT_MISSED_ICON_HIDE   = 0x00,
+        LXT_MISSED_ICON_SHOW   = 0x01
+    } LXT_MISSED_ICON;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_RADIO_MODE_DIS_TEST_RC                                = 0x00,
+        LXT_CONFIGURATION_RADIO_MODE_F_RC1R_RC1                                 = 0x01,
+        LXT_CONFIGURATION_RADIO_MODE_F_RC2R_RC2                                 = 0x02,
+        LXT_CONFIGURATION_RADIO_MODE_F_RC3R_RC3                                 = 0x03,
+        LXT_CONFIGURATION_RADIO_MODE_F_RC4R_RC3                                 = 0x04,
+        LXT_CONFIGURATION_RADIO_MODE_F_RC5R_RC4                                 = 0x05
+
+    } LXT_CONFIGURATION_RADIO_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_PREF_MODE_HOME_ONLY                                   = 0x00,
+        LXT_CONFIGURATION_PREF_MODE_ATOMATIC_A                                  = 0x01,
+        LXT_CONFIGURATION_PREF_MODE_ATOMATIC_B                                  = 0x02,
+        LXT_CONFIGURATION_PREF_MODE_STANDARD                                    = 0x03 // don't use
+
+    } LXT_CONFIGURATION_PREF_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_PARA_MODE_IS95A                                       = 0x03,
+        LXT_CONFIGURATION_PARA_MODE_IS95B                                       = 0x04,
+        LXT_CONFIGURATION_PARA_MODE_IS2000                                      = 0x06
+
+    } LXT_CONFIGURATION_PARA_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_PHONE_STATE_ON_LINE                                   = 0x00,
+        LXT_CONFIGURATION_PHONE_STATE_OFF_LINE                                  = 0x01
+
+    } LXT_CONFIGURATION_PHONE_STATE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_SIO_MODE_DIAG                                         = 0x00,
+        LXT_CONFIGURATION_SIO_MODE_HFK                                          = 0x01
+
+    } LXT_CONFIGURATION_SIO_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_SLOT_MODE_ON                                          = 0x00,
+        LXT_CONFIGURATION_SLOT_MODE_OFF                                         = 0x01
+
+    } LXT_CONFIGURATION_SLOT_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_VOCODER_OPTION_EVRC                                   = 0x00,
+        LXT_CONFIGURATION_VOCODER_OPTION_13K                                    = 0x01,
+        LXT_CONFIGURATION_VOCODER_OPTION_8K                                     = 0x02,
+       LXT_CONFIGURATION_VOCODER_OPTION_DEFAULT                                = 0x03
+
+    } LXT_CONFIGURATION_VOCODER_OPTION;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_DEFAULT_MODE_USER_SETTING                             = 0x00,
+        LXT_CONFIGURATION_DEFAULT_MODE_FACTORY                                  = 0x01,
+        LXT_CONFIGURATION_DEFAULT_MODE_REBUILD                                  = 0x02
+
+    } LXT_CONFIGURATION_DEFAULT_MODE;
+
+    typedef enum
+    {
+        LXT_CONFIGURATION_MAC_ADDRESS_MODE_WIFI                                 = 0x00,
+        LXT_CONFIGURATION_MAC_ADDRESS_MODE_BLUETOOTH                            = 0x01
+
+    } LXT_CONFIGURATION_MAC_ADDRESS_MODE;
+
+
+    // about call +++++++++++++++++++++++++++++++++++++++++++++++
+    typedef enum
+    {
+        LXT_CALL_STATUS_IDLE                                                    = 0x00,
+        LXT_CALL_STATUS_WAITING                                                 = 0x01,
+        LXT_CALL_STATUS_CONNECTED                                               = 0x02,
+        LXT_CALL_STATUS_RELEASED                                                = 0x03
+    } LXT_CALL_STATUS;
+
+    typedef enum
+    {
+        LXT_TONE_LENGTH_SHORT                                                   = 0x00,
+        LXT_TONE_LENGTH_LONG                                                    = 0x01
+
+    } LXT_TONE_LENGTH;
+
+    typedef enum
+    {
+        LXT_CALL_RETRY_DISABLE                                                  = 0x00,
+        LXT_CALL_RETRY_ENABLE                                                   = 0x01
+
+    } LXT_CALL_RETRY;
+
+    typedef enum
+    {
+        LXT_CALL_AT_SO_MARKOV_8K                                               = 0x0501,
+        LXT_CALL_AT_SO_MARKOV_13K                                              = 0x0502,
+        LXT_CALL_AT_SO_MARKOV_54                                               = 0x0503,
+        LXT_CALL_AT_SO_LOOPBACK_8K                                             = 0x0401,
+        LXT_CALL_AT_SO_LOOPBACK_13K                                            = 0x0402,
+        LXT_CALL_AT_SO_LOOPBACK_55                                             = 0x0403,
+        LXT_CALL_AT_SO_SIMPLE_TDSO                                             = 0x0404,
+        LXT_CALL_AT_SO_FULL_TDSO                                               = 0x0405
+
+    } LXT_CALL_AT_SO;
+
+    typedef enum
+    {
+        LXT_CALL_VOICE_PRIVACY_STANDARD                                         = 0x00,
+        LXT_CALL_VOICE_PRIVACY_ENHANCED                                         = 0x01
+    }
+    LXT_CALL_VOICE_PRIVACY;
+
+    typedef enum
+    {
+        LXT_CALL_SOS_MODE_CDMA                                                  = 0x00,
+        LXT_CALL_SOS_MODE_GSM                                                   = 0x01
+    }
+    LXT_CALL_SOS_MODE;
+    // about display ++++++++++++++++++++++++++++++++++++++++++++
+
+
+    // define of icon type
+    typedef enum
+    {
+        LXT_ICON_TYPE_MAIN                                                      = 0x00,
+        LXT_ICON_TYPE_SERVICE                                                   = 0x01,
+        LXT_ICON_TYPE_MESSAGE                                                   = 0x02,
+        LXT_ICON_TYPE_RINGER                                                    = 0x03,
+        LXT_ICON_TYPE_ROAM                                                      = 0x04,
+        LXT_ICON_TYPE_DATASERVICE                                               = 0x05,
+        LXT_ICON_TYPE_EOT                                                       = 0x06,
+
+    }
+    LXT_ICON_TYPE;
+
+
+    // define of ringer icon type
+
+
+
+    typedef enum
+    {
+
+        LXT_RING_TYPE_ICON_RING                                                 = 0x00,
+        LXT_RING_TYPE_ICON_INCREASING_RING                                      = 0x01,
+        LXT_RING_TYPE_ICON_VIBRATE                                              = 0x02,
+        LXT_RING_TYPE_ICON_VIBRATE_THEN_RING                                    = 0x03,
+        LXT_RING_TYPE_ICON_LAMP                                                 = 0x04
+
+    } LXT_RING_TYPE_ICON;
+
+    // define of message icon type
+    typedef enum
+    {
+        LXT_MESSAGE_ICON_NO_MESSAGE                                             = 0x00,
+        LXT_MESSAGE_ICON_UNREAD_MESSAGE                                         = 0x01
+
+    } LXT_MESSAGE_ICON;
+
+
+    // about data service +++++++++++++++++++++++++++++++++++++++
+
+    // define of RS232 PIN number
+    typedef enum
+    {
+        LXT_RS232_SIGNAL_TYPE_DCD                                               = 0x01,
+        LXT_RS232_SIGNAL_TYPE_RX                                                = 0x02,
+        LXT_RS232_SIGNAL_TYPE_TX                                                = 0x03,
+        LXT_RS232_SIGNAL_TYPE_DTR                                               = 0x04,
+        LXT_RS232_SIGNAL_TYPE_GND                                               = 0x05,
+        LXT_RS232_SIGNAL_TYPE_DSR                                               = 0x06,
+        LXT_RS232_SIGNAL_TYPE_RTS                                               = 0x07,
+        LXT_RS232_SIGNAL_TYPE_CTS                                               = 0x08,
+        LXT_RS232_SIGNAL_TYPE_RI                                                = 0x09
+
+    } LXT_RS232_SIGNAL_TYPE;
+
+    // define of RS232 PIN status
+    typedef enum
+    {
+        LXT_RS232_SIGNAL_STATUS_DEASSERT                                        = 0x00,
+        LXT_RS232_SIGNAL_STATUS_ASSERT                                          = 0x01,
+
+    } LXT_RS232_SIGNAL_STATUS;
+
+
+    // about uim ++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define of uim connect status
+    typedef enum
+    {
+        LXT_UIM_CONNECT_STATUS_NOT_CONNECTED                                    = 0x00,
+        LXT_UIM_CONNECT_STATUS_CONNECTED                                        = 0x01
+
+    } LXT_UIM_CONNECT_STATUS;
+
+
+    // define of uim chv status
+    typedef enum
+    {
+        LXT_UIM_CHV_BLOCKED_STATUS_BLOCKED                                      = 0x00,
+        LXT_UIM_CHV_BLOCKED_STATUS_NOT_BLOCKED                                  = 0x01,
+        LXT_UIM_CHV_BLOCKED_STATUS_MECHANICAL_PROBLEM                           = 0x02
+    } LXT_UIM_CHV_BLOCKED_STATUS;
+
+
+    // define of uim lock stats
+    typedef enum
+    {
+
+        LXT_UIM_LOCK_STATUS_NON_ACTIVE                                          = 0x00,
+        LXT_UIM_LOCK_STATUS_ACTIVE                                              = 0x01
+
+    } LXT_UIM_LOCK_STATUS;
+
+
+
+
+    // define of uim pin code status
+    typedef enum
+    {
+        LXT_UIM_PIN_CODE_STATUS_DISABLE                                         = 0x00,
+        LXT_UIM_PIN_CODE_STATUS_ENABLE                                          = 0x01
+
+    } LXT_UIM_PIN_CODE_STATUS;
+
+
+    // define of uim lock verify
+    typedef enum
+    {
+        LXT_UIM_LOCK_VERIFY_OK                                                  = 0x00,
+        LXT_UIM_LOCK_VERIFY_FAIL                                                = 0x01
+
+    } LXT_UIM_LOCK_VERIFY;
+
+
+
+
+
+    // define of uim set pin code cause
+    typedef enum
+    {
+        LXT_UIM_SET_PIN_CODE_CAUSE_OK                                           = 0x00,
+        LXT_UIM_SET_PIN_CODE_CAUSE_FAIL                                         = 0x01
+
+    } LXT_UIM_SET_PIN_CODE_CAUSE;
+
+    // define of ICCID cause
+    typedef enum
+    {
+        LXT_UIM_GET_ICCID_OK                                                    = 0x00,
+        LXT_UIM_GET_ICCID_FAIL                                                  = 0x01
+
+    } LXT_UIM_GET_ICCID;
+
+
+    // define of chv unblock cause
+    typedef enum
+
+    {
+        LXT_UIM_CHV_UNBLOCK_OK                                                  = 0x00,
+        LXT_UIM_CHV_UNBLOCK_FAIL                                                = 0x01,
+        LXT_UIM_CHV_UNBLOCK_COMMAND_FAIL                                        = 0x02
+
+    } LXT_UIM_CHV_UNBLOCK;
+
+
+
+
+    // define of uim verify password cause
+    typedef enum
+    {
+
+        LXT_UIM_VERIFY_PIN_CODE_CAUSE_FAIL                                      = 0x00,
+        LXT_UIM_VERIFY_PIN_CODE_CAUSE_PASS                                      = 0x01,
+        LXT_UIM_VERIFY_PIN_CODE_CAUSE_BLOCK                                     = 0x02,
+        LXT_UIM_VERIFY_PIN_CODE_CAUSE_EMPTY                                     = 0x03,
+        LXT_UIM_VERIFY_PIN_CODE_CAUSE_COMMAND_FAIL                              = 0x04
+
+    } LXT_UIM_VERIFY_PIN_CODE_CAUSE;
+
+
+
+    // define of uim permission status
+    typedef enum
+    {
+        LXT_UIM_PERMISSION_STATUS_DISABLE                                       = 0x00,
+        LXT_UIM_PERMISSION_STATUS_ENABLE                                        = 0x01
+
+    } LXT_UIM_PERMISSION_STATUS;
+
+
+    // about sound ++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define speaker phone mode
+
+    typedef enum
+    {
+        LXT_SOUND_SPEAKER_PHONE_MODE_OFF                                        = 0x00,
+        LXT_SOUND_SPEAKER_PHONE_MODE_ON                                         = 0x01,
+
+    } LXT_SOUND_SPEAKER_PHONE_MODE;
+
+    typedef enum
+    {
+        LXT_SOUND_AUDIO_PATH_HAND_SET                                           = 0x00,
+        LXT_SOUND_AUDIO_PATH_HEAD_SET                                           = 0x01,
+        LXT_SOUND_AUDIO_PATH_HANDS_FREE                                         = 0x02,
+        LXT_SOUND_AUDIO_PATH_BT                                                 = 0x03
+
+    } LXT_SOUND_AUDIO_PATH;
+
+    // about power ++++++++++++++++++++++++++++++++++++++++++++++++
+
+    // define of battery status
+
+    typedef enum
+    {
+        LXT_BATTERY_STATUS_NORMAL                                               = 0x01,
+        LXT_BATTERY_STATUS_WARNING                                              = 0x02,
+        LXT_BATTERY_STATUS_POWEROFF                                             = 0x03
+
+    } LXT_BATTERY_STATUS;
+
+
+    typedef enum
+    {
+        LXT_BACKUP_BATTERY_CONTROL_OFF                                          = 0x00,
+        LXT_BACKUP_BATTERY_CONTROL_ON                                           = 0x01
+    } LXT_BACKUP_BATTERY_CONTROL;
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function prototype
+
+
+
+    //LXT_HANDLE* lxt_initialize(LXT_ID_CLIENT clientclass, LXT_CALLBACK cb);
+    int lxt_getDescriptor(LXT_HANDLE* handle);
+    //int lxt_release(LXT_HANDLE* handle);
+    int lxt_requestCurruntState(LXT_HANDLE* handle);
+    int lxt_requestPhoneNumber(LXT_HANDLE* handle);
+    //int lxt_callback(LXT_HANDLE* handle);
+    int lxt_loop_back_request(LXT_HANDLE* handle, LXT_ID_CLIENT klass, char g, char a, char* rawdata, int size);
+    int lxt_sendRawdata(LXT_HANDLE* handle, char g, char a, char* rawdata, int size);
+    int lxt_factoryMode(LXT_HANDLE* handle, unsigned char type);
+    int lxt_requestNotifyPhonebookCompletion(LXT_HANDLE* handle);
+    int lxt_requestPhonebookCompletionStatus(LXT_HANDLE* handle);
+    int lxt_requestBackupBatteryControl(LXT_HANDLE* handle, LXT_BACKUP_BATTERY_CONTROL control);
+    int lxt_requestEarjackStatus(LXT_HANDLE* handle);
+    int lxt_power_on(LXT_HANDLE* handle);
+    int lxt_power_off(LXT_HANDLE* handle);
+    int lxt_power_reset(LXT_HANDLE* handle);
+    int lxt_call_originaton(LXT_HANDLE* handle, char* callnumber);
+    int lxt_call_originaton2(LXT_HANDLE* handle, LXT_CALL_AT_SO so, char* callnumber);
+    int lxt_call_end(LXT_HANDLE* handle);
+    int lxt_call_reject(LXT_HANDLE* handle);
+    int lxt_call_answer(LXT_HANDLE* handle);
+    int lxt_call_sendBurstDTMF(LXT_HANDLE* handle, LXT_TONE_LENGTH toneLength, int digitNum, char *dtmfDigit);
+    int lxt_call_sendContinuousDTMF(LXT_HANDLE* handle, char digit);
+    int lxt_call_stopContinuousDTMF(LXT_HANDLE* handle);
+    int lxt_call_requestCallTime(LXT_HANDLE* handle);
+    int lxt_call_setE911NumberRegistration(LXT_HANDLE* handle, int index, char* digit);
+    int lxt_call_flashInformation(LXT_HANDLE* handle, char* callnumber);
+
+    // removed in 819
+    //int lxt_call_retry(LXT_HANDLE* handle, LXT_CALL_RETRY mode);
+
+    int lxt_call_requestGetVoicePrivacy(LXT_HANDLE* handle);
+    int lxt_call_requestSetVoicePrivacy(LXT_HANDLE* handle, LXT_CALL_VOICE_PRIVACY mode);
+    int lxt_call_requestCurrentVoicePrivacyStatus(LXT_HANDLE* handle);
+    int lxt_call_requestSOSCall(LXT_HANDLE* handle, LXT_CALL_SOS_MODE mode);
+    /*
+    int lxt_configuration_requestCurrentTime(LXT_HANDLE* handle);
+    int lxt_configuration_requestPhoneNumber(LXT_HANDLE* handle);
+    int lxt_configuration_requestPhoneVersion(LXT_HANDLE* handle);
+    int lxt_configuration_requestPhoneLockInfo(LXT_HANDLE* handle);
+    int lxt_configuration_setPhoneLock(LXT_HANDLE* handle, LXT_CONFIGURATION_PHONE_LOCK lock);
+
+    int lxt_configuration_requestRadioConfiguration(LXT_HANDLE* handle);
+    int lxt_configuration_setRadioConfiguration(LXT_HANDLE* handle, LXT_CONFIGURATION_RADIO_MODE mode);
+    int lxt_configuration_requestSystemPreference(LXT_HANDLE* handle);
+    int lxt_configuration_setSystemPreference(LXT_HANDLE* handle, LXT_CONFIGURATION_PREF_MODE mode);
+    int lxt_configuration_requestSystemParameter(LXT_HANDLE* handle);
+    int lxt_configuration_setSystemParameter(LXT_HANDLE* handle, LXT_CONFIGURATION_PARA_MODE mode);
+    int lxt_configuration_requestNAMInformation(LXT_HANDLE* handle);
+    int lxt_configuration_requestNAMData(LXT_HANDLE* handle, int index);
+    int lxt_configuration_requestPhoneState(LXT_HANDLE* handle);
+    int lxt_configuration_setPhoneState(LXT_HANDLE* handle, LXT_CONFIGURATION_PHONE_STATE state);
+    int lxt_configuration_confirmBatteryMediateness(LXT_HANDLE* handle, int value);
+    int lxt_configuration_reqeustPDABattery(LXT_HANDLE* handle);
+    */
+
+    int lxt_configuration2_requestPhoneLockInfo(LXT_HANDLE* handle);
+    int lxt_configuration2_setPhoneLock(LXT_HANDLE* handle, LXT_CONFIGURATION_PHONE_LOCK lock)
+        ;
+    int lxt_configuration2_requestCurrentTime(LXT_HANDLE* handle);
+    int lxt_configuration2_requestPhoneNumber(LXT_HANDLE* handle);
+    int lxt_configuration2_requestPhoneVersion(LXT_HANDLE* handle);
+
+    int lxt_configuration2_requestRadioConfiguration(LXT_HANDLE* handle);
+    int lxt_configuration2_setRadioConfiguration(LXT_HANDLE* handle, LXT_CONFIGURATION_RADIO_MODE mode);
+    int lxt_configuration2_requestSystemPreference(LXT_HANDLE* handle);
+    int lxt_configuration2_setSystemPreference(LXT_HANDLE* handle, LXT_CONFIGURATION_PREF_MODE mode);
+    int lxt_configuration2_requestSystemParameter(LXT_HANDLE* handle);
+    int lxt_configuration2_setSystemParameter(LXT_HANDLE* handle, LXT_CONFIGURATION_PARA_MODE mode);
+    int lxt_configuration2_requestNAMInformation(LXT_HANDLE* handle);
+    int lxt_configuration2_requestNAMData(LXT_HANDLE* handle, int index);
+    int lxt_configuration2_requestPhoneState(LXT_HANDLE* handle);
+    int lxt_configuration2_setPhoneState(LXT_HANDLE* handle, LXT_CONFIGURATION_PHONE_STATE state);
+
+    int lxt_configuration2_requestSIOMode(LXT_HANDLE* handle);
+    int lxt_configuration2_setSIOMode(LXT_HANDLE* handle, LXT_CONFIGURATION_SIO_MODE mode);
+    int lxt_configuration2_requestSlotMode(LXT_HANDLE* handle);
+    int lxt_configuration2_setSlotMode(LXT_HANDLE* handle, LXT_CONFIGURATION_SLOT_MODE mode);
+    int lxt_configuration2_requestVocoderOption(LXT_HANDLE* handle);
+    int lxt_configuration2_setVocoderOption(LXT_HANDLE* handle, LXT_CONFIGURATION_VOCODER_OPTION mode);
+    int lxt_configuration2_setDefaultConfiguration(LXT_HANDLE* handle, LXT_CONFIGURATION_DEFAULT_MODE mode);
+    int lxt_configuration2_get_ESN(LXT_HANDLE* handle);
+    int lxt_configuration2_get_IMEI(LXT_HANDLE* handle);
+    int lxt_configuration2_vefify_pda_reset_done(LXT_HANDLE* handle, unsigned char status);
+    int lxt_configuration2_set_pda_version_request(LXT_HANDLE* handle, char *version);
+
+    /*
+    int lxt_configuration2_confirmBatteryMediateness(LXT_HANDLE* handle, int value);
+    int lxt_configuration2_reqeustPDABattery(LXT_HANDLE* handle);
+    */
+
+    int lxt_display_ringTypeIconChange(LXT_HANDLE* handle, LXT_RING_TYPE_ICON ringTypeIcon);
+    int lxt_display_missedIconChange(LXT_HANDLE* handle, LXT_MISSED_ICON type);
+    int lxt_display_icon(LXT_HANDLE* handle);
+    int lxt_sound_startKeyTone(LXT_HANDLE* handle, LXT_TONE_LENGTH tone_type, int volume, int key_code);
+    int lxt_sound_stopKeyTone(LXT_HANDLE* handle);
+    int lxt_sound_setSpeakerPhone(LXT_HANDLE* handle, LXT_SOUND_SPEAKER_PHONE_MODE mode);
+    int lxt_sound_setAudioPathControl(LXT_HANDLE* handle, LXT_SOUND_AUDIO_PATH path);
+
+    //int lxt_sms_sendMessage(LXT_HANDLE* handle, char* destination, char* callbacknumber, int messagesize, unsigned char *message, char encoding, int memoryIndex, char tag, char priority, char reply_option);
+    //int lxt_sms_sendAck(LXT_HANDLE* handle);
+    int lxt_sms_setLocalCount(LXT_HANDLE* handle, unsigned char total, unsigned char unread, unsigned char spool, unsigned char unread_urgent);
+    int lxt_sms_setLocalStorageSize(LXT_HANDLE* handle, unsigned char size);
+    int lxt_sms_requestLocalStorageSize(LXT_HANDLE* handle);
+
+    int lxt_dataservice_pinControl(LXT_HANDLE* handle, LXT_RS232_SIGNAL_TYPE signal, LXT_RS232_SIGNAL_STATUS status);
+    int lxt_uim_cardStatus(LXT_HANDLE* handle);
+    int lxt_uim_requestPinCodeStatus(LXT_HANDLE* handle);
+    int lxt_uim_setPinCheck(LXT_HANDLE* handle, LXT_UIM_PIN_CODE_STATUS pinCodeStatus, int pinCodeLength, char *pinCode);
+    int lxt_uim_pinVerify(LXT_HANDLE* handle, int codeLength, char *code);
+    int lxt_uim_changePin(LXT_HANDLE* handle, int currentcodeLength, char *currentcode, int newcodeLength, char *newcode);
+    int lxt_uim_getICCID(LXT_HANDLE* handle);
+    int lxt_uim_chvUnlock(LXT_HANDLE* handle, int chvUnblockCodeLength, char *chvUnblockCode, int newPinCodeLength, char *newPinCode);
+    int lxt_uim_getlock(LXT_HANDLE* handle);
+    int lxt_uim_setlock(LXT_HANDLE* handle, LXT_UIM_LOCK_STATUS status);
+    int lxt_uim_lockVerifyIndication(LXT_HANDLE* handle, LXT_UIM_LOCK_VERIFY status);
+    int lxt_uim_smsInformation(LXT_HANDLE* handle);
+    int lxt_uim_smsRead(LXT_HANDLE* handle, int address);
+    int lxt_uim_smsWrite(LXT_HANDLE* handle, int address, int tag, char* parm_mask, char* destination, char* callbacknumber, char* timestemp, char encoding, int messagesize, unsigned char *message);
+    int lxt_uim_smsErase(LXT_HANDLE* handle, int address);
+    int lxt_uim_smsAllList(LXT_HANDLE* handle);
+    int lxt_uim_smsMirroring(LXT_HANDLE* handle);
+    int lxt_uim_smsSetTag(LXT_HANDLE* handle, int address, LXT_SMS_TAG tag);
+    int lxt_uim_phoneBookInformation(LXT_HANDLE* handle);
+    int lxt_uim_phoneBookRead(LXT_HANDLE* handle, int startAddress, int endAddress);
+    int lxt_uim_phoneBookWrite(LXT_HANDLE* handle, int address, int alphaLength, char *alpha, int digitLength, char *digit);
+    int lxt_uim_phoneBookErase(LXT_HANDLE* handle, int address);
+    int lxt_uim_phoneBookClear(LXT_HANDLE* handle);
+    int lxt_uim_smsClear(LXT_HANDLE* handle);
+    int lxt_uim_phoneBookAllList(LXT_HANDLE* handle);
+    int lxt_uim_phoneBookMirroring(LXT_HANDLE* handle);
+    int lxt_uim_dirNameRead(LXT_HANDLE* handle);
+    int lxt_uim_dirNameWrite(LXT_HANDLE* handle, int length, char * data);
+    int lxt_uim_getPermissionStatus(LXT_HANDLE* handle);
+    int lxt_uim_writeUIMLockPassword(LXT_HANDLE* handle, int length, char * data);
+
+
+
+    int lxt_ruimconf_authentication(LXT_HANDLE*, LXT_CARD_AUTHENTICATION*);
+    int lxt_ruimconf_select_network(LXT_HANDLE*, LXT_NETWORK_MODE);
+    int lxt_ruimconf_iccid(LXT_HANDLE*);
+    int lxt_ruimconf_selection_mode(LXT_HANDLE*, LXT_NETWORK_SELECTION_MODE);
+    int lxt_ruimconf_change_authentication(LXT_HANDLE*, LXT_CARD_AUTHENTICATION*);
+    int lxt_ruimconf_current_pin_check_state(LXT_HANDLE*, LXT_RUIM_SLOT);
+    int lxt_ruimconf_change_pin_check_state(LXT_HANDLE*, LXT_CARD_AUTHENTICATION*, LXT_PIN_STATUS);
+    int lxt_ruimconf_runtime_change_network(LXT_HANDLE*, LXT_SELECTED_NETWORK_MODE);
+    int lxt_ruimconf_read_dir_name(LXT_HANDLE*, LXT_RUIM_SLOT);
+    int lxt_ruimconf_write_dir_name(LXT_HANDLE*, char*);
+    int lxt_ruimconf_change_fdn_state(LXT_HANDLE*, LXT_FDN_STATE, char*, LXT_RUIM_SLOT);
+    int lxt_ruimconf_current_fdn_state(LXT_HANDLE*, LXT_RUIM_SLOT);
+    int lxt_ruimconf_check_service_available(LXT_HANDLE*, char, LXT_RUIM_SLOT);
+    int lxt_ruimconf_read_IMSI(LXT_HANDLE*);
+
+
+    int lxt_phonebook_write(LXT_HANDLE* handle, int index, int alpha_size, char* alpha, int number_size, char* number, LXT_PHONEBOOK_PBM id);
+    int lxt_phonebook_erase(LXT_HANDLE* handle, int index, LXT_PHONEBOOK_PBM id);
+    int lxt_phonebook_clear(LXT_HANDLE* handle, LXT_PHONEBOOK_PBM id);
+
+    int lxt_utk_start(LXT_HANDLE* handle);
+    int lxt_utk_get_key(LXT_HANDLE* handle, char key);
+    int lxt_utk_end_input(LXT_HANDLE* handle, unsigned char text_length, char* input_text);
+    int lxt_utk_setup_main_menu(LXT_HANDLE* handle);
+
+    int lxt_gps_mt_sms_request(LXT_HANDLE* handle);
+    int lxt_gps_mo_sms_request(LXT_HANDLE* handle, LXT_GPS_MO_SMS_DATA*);
+    int lxt_gps_spp_request(LXT_HANDLE* handle, unsigned char input_length, char* input_text);
+    int lxt_gps_url_info_request(LXT_HANDLE* handle);
+    int lxt_gps_end_request(LXT_HANDLE* handle, LXT_GPS_END_REASON);
+
+       int lxt_configuration2_pda_curr_batt_adc_cfrm(LXT_HANDLE* handle, int curr_pda_batt);
+    int lxt_configuration2_get_pda_low_batt_adc_req(LXT_HANDLE* handle);
+    int lxt_configuration2_set_pda_low_batt_adc_req(LXT_HANDLE* handle);
+    int lxt_configuration2_mac_address_req(LXT_HANDLE* handle, LXT_CONFIGURATION_MAC_ADDRESS_MODE mode);
+    int lxt_configuration2_pda_password_cfrm(LXT_HANDLE* handle, char mode, char *password);
+    int lxt_configuration2_device_auto_test_confirm(LXT_HANDLE* handle, char mode);
+    int lxt_configuration2_service_led_onoff_confirm(LXT_HANDLE* handle, char mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LINUXTAPI_H_
diff --git a/libvmodem/linuxtapi4gsm.h b/libvmodem/linuxtapi4gsm.h
new file mode 100644 (file)
index 0000000..e62a16b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LINUXTAPI4GSM_H_
+#define _LINUXTAPI4GSM_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "linuxtapi4gsm_type.h"
+#include "phoneprotocol4gsm.h"
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function prototype
+
+// config =====================================================================
+int lxt_gsm_config_get_call_cost(LXT_HANDLE* handle, LXT_CALL_COST_OPTION option);
+int lxt_gsm_config_reset_call_cost(LXT_HANDLE* handle);
+int lxt_gsm_config_set_max_call_cost(LXT_HANDLE* handle, int max_cost);
+int lxt_gsm_config_get_call_unit_price(LXT_HANDLE* handle);
+int lxt_gsm_config_set_call_unit_price(LXT_HANDLE* handle, char unit, char* price);
+int lxt_gsm_config_get_network_selection_mode(LXT_HANDLE* handle);
+int lxt_gsm_config_automatic_network_selection(LXT_HANDLE* handle);
+int lxt_gsm_config_manual_network_seleciton(LXT_HANDLE* handle, char mode);
+int lxt_gsm_config_manual_network_selection_registration(LXT_HANDLE* handle, char *plmn_id, LXT_GSM_CONFIG_RAT rat);
+int lxt_gsm_config_get_caller_id(LXT_HANDLE* handle);
+int lxt_gsm_config_set_caller_id(LXT_HANDLE* handle, LXT_CALLER_ID_OPTION option);
+int lxt_gsm_config_get_active_line(LXT_HANDLE* handle);
+int lxt_gsm_config_set_active_line(LXT_HANDLE* handle, char line);
+int lxt_gsm_config_set_force_gsm_mode(LXT_HANDLE* handle);
+int lxt_gsm_config_get_system_identity(LXT_HANDLE* handle);
+
+// call =======================================================================
+int lxt_gsm_call_originaton(LXT_HANDLE* handle, char* callnumber);
+int lxt_gsm_call_end(LXT_HANDLE* handle, int call_id_num, char* call_id_list);
+int lxt_gsm_call_reject(LXT_HANDLE* handle, int call_id);
+int lxt_gsm_call_answer(LXT_HANDLE* handle, int call_id);
+int lxt_gsm_call_start_dtmf(LXT_HANDLE* handle, char digit, int call_id);
+int lxt_gsm_call_stop_dtmf(LXT_HANDLE* handle, int call_id);
+
+// sups =======================================================================
+int lxt_gsm_sups_originated_sups(LXT_HANDLE* handle, LXT_GSM_SUPS_ORIGINATED *sups_originated);
+int lxt_gsm_sups_network_originated_sups_user_confirm(LXT_HANDLE* handle, LXT_GSM_SUPS_USER_CONFIRM *sups_user_confirm);
+int lxt_gsm_sups_get_sups_network_confirm_data(LXT_HANDLE* handle, char block_id);
+int lxt_gsm_sups_password_registration(LXT_HANDLE* handle, char* old_pw, char* new_pw, char* new_pw_again, char* ss_code);
+//int lxt_gsm_sups_get_barring_password_confirm(LXT_HANDLE* handle, char* barring_pw);
+int lxt_gsm_sups_handle_within_call(LXT_HANDLE*, LXT_GSM_MPTY_OPERATION, LXT_GSM_MPTY_PARAM_ID, char*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LINUXTAPI4GSM_H_
diff --git a/libvmodem/linuxtapi4gsm_type.h b/libvmodem/linuxtapi4gsm_type.h
new file mode 100644 (file)
index 0000000..300530f
--- /dev/null
@@ -0,0 +1,481 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LINUXTAPI4GSM_TYPE_H_
+#define _LINUXTAPI4GSM_TYPE_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function prototype
+
+// sups. Basic Service Group
+#define BS_GROUP_ALL_TELESERVICES                                           "10"
+#define BS_GROUP_TELEPHONY                                                  "11"
+#define BS_GROUP_ALL_DATA_TELESERVICES                                      "12"
+#define BS_GROUP_FACSIMILE_SERVICES                                         "13"
+#define BS_GROUP_SHORT_MESSAGE_SERVICES                                     "16"
+#define BS_GROUP_ALL_TELESERVICES_EXCEPT_SMS                                "19"
+#define BS_GROUP_VOICE_GROUP_CALL_SERVICE                                   "17"
+#define BS_GROUP_VOICE_BROADCAST_SERVICE                                    "18"
+#define BS_GROUP_ALL_BEARER_SERVICES                                        "20"
+#define BS_GROUP_ALL_ASYNC_SERVICES                                         "21"
+#define BS_GROUP_ALL_SYNC_SERVICES                                          "22"
+#define BS_GROUP_ALL_DATA_CIRCUIT_SYNC                                      "24"
+#define BS_GROUP_ALL_DATA_CIRCUIT_ASYNC                                     "25"
+#define BS_GROUP_ALL_DEDICATED_PACKET_ACCESS                                "26"
+#define BS_GROUP_ALL_DEDICATED_PAD_ACCESS                                   "27"
+#define BS_GROUP_ALL_GPRS_BEARER_SERVICES                                   "99"
+
+// sups. Service Code
+#define SS_CODE_02_67_EMLPP                                                 "75"
+#define SS_CODE_02_72_CD                                                    "66"
+#define SS_CODE_02_81_CLIP                                                  "30"
+#define SS_CODE_02_81_CLIR                                                  "31"
+#define SS_CODE_02_81_COLP                                                  "76"
+#define SS_CODE_02_81_COLR                                                  "77"
+#define SS_CODE_02_82_CFU                                                   "21"
+#define SS_CODE_02_82_CF_BUSY                                               "67"
+#define SS_CODE_02_82_CF_NO_REPLY                                           "61"
+#define SS_CODE_02_82_CF_NOT_REACHABLE                                      "62"
+#define SS_CODE_02_82_ALL_CF                                                "002"
+#define SS_CODE_02_82_ALL_CONDITIONAL_CF                                    "004"
+#define SS_CODE_02_83_WAIT                                                  "43"
+#define SS_CODE_02_87_UUS_SERVICE_1                                         "361"
+#define SS_CODE_02_87_UUS_SERVICE_2                                         "362"
+#define SS_CODE_02_87_UUS_SERVICE_3                                         "363"
+#define SS_CODE_02_87_ALL_UUS_SERVICES                                      "360"
+#define SS_CODE_02_88_BAOC                                                  "33"
+#define SS_CODE_02_88_BAOIC                                                 "331"
+#define SS_CODE_02_88_BAOIC_EXC_HOME                                        "332"
+#define SS_CODE_02_88_BAIC                                                  "35"
+#define SS_CODE_02_88_BAIC_ROAMING                                          "351"
+#define SS_CODE_02_88_ALL_BARRING_SERV                                      "330"
+#define SS_CODE_02_88_OUTG_BARR_SERV                                        "333"
+#define SS_CODE_02_88_INC_BARR_SERV                                         "353"
+#define SS_CODE_02_91_ECT                                                   "96"
+#define SS_CODE_02_93_CCBS                                                  "37"
+#define SS_CODE_02_95_SPNP                                                  "07n"
+#define SS_CODE_02_96_CNAP                                                  "300"
+#define SS_CODE_02_97_MSP                                                   "59n"
+
+// sups. param id(for request)
+#define SUPS_PARAM_ID_SS                                                0x00000001
+#define SUPS_PARAM_ID_DN                                                0x00000002
+#define SUPS_PARAM_ID_PW                                                0x00000004
+#define SUPS_PARAM_ID_BS                                                0x00000008
+#define SUPS_PARAM_ID_T                                                 0x00000010
+#define SUPS_PARAM_ID_USSD                                              0x00000020
+
+// sups. user confirm id(for request)
+#define SUPS_USER_CONFIRM_ID_USS_RES_TYPE                               0x00000001
+#define SUPS_USER_CONFIRM_ID_USS_RES_MESG                               0x00000002
+#define SUPS_USER_CONFIRM_ID_USS_GUIDANCE_INFO                          0x00000004
+#define SUPS_USER_CONFIRM_ID_USS_PASSWORD_RES                           0x00000008
+
+// sups. user confirm(for request)
+#define SUPS_CONFIRM_ID_USS_NOTIFY_RES                                  0x00000001
+
+
+// sups. confirm id(for response)
+#define SUPS_CFM_ID_SS                                                  0x00000001
+#define SUPS_CFM_ID_BS                                                  0x00000002
+#define SUPS_CFM_ID_BSG_LIST                                            0x00000004
+#define SUPS_CFM_ID_SS_STATUS                                           0x00000008
+#define SUPS_CFM_ID_FWD_BS_CODE                                         0x00000010
+#define SUPS_CFM_ID_FWD_STATUS                                          0x00000020
+#define SUPS_CFM_ID_FWD_TO_NUM                                          0x00000040
+#define SUPS_CFM_ID_FWD_OPTION                                          0x00000080
+#define SUPS_CFM_ID_NR_TIMER                                            0x00000100
+#define SUPS_CFM_ID_FWD_INFO_SS_CODE                                    0x00000200
+#define SUPS_CFM_ID_CLIR_STATUS                                         0x00000400
+#define SUPS_CFM_ID_CLIR_OPTION                                         0x00000800
+#define SUPS_CFM_ID_CC_CAUSE                                            0x00001000
+#define SUPS_CFM_ID_SS_ERROR                                            0x00002000
+#define SUPS_CFM_ID_BLOCK_IDS                                           0x00004000
+#define SUPS_CFM_ID_BAR_SS_CODE                                         0x00008000
+#define SUPS_CFM_ID_BAR_BS_CODE                                         0x00010000
+#define SUPS_CFM_ID_BAR_STATUS                                          0x00020000
+#define SUPS_CFM_ID_NEW_PW                                              0x00040000
+#define SUPS_CFM_ID_LL_CAUSE                                            0x00080000
+#define SUPS_CFM_ID_USS_DATA                                            0x00100000
+
+
+// sups. network originated indication(for indication)
+#define SUPS_NETWORK_INDICATION_USS_INVOKE_ID                           0x00000001
+#define SUPS_NETWORK_INDICATION_USS_IND_DATA                            0x00000002
+#define SUPS_NETWORK_INDICATION_PWD_INVOKE_ID                           0x00000004
+#define SUPS_NETWORK_INDICATION_GUIDANCE_INFO                           0x00000008
+
+
+    // call. status notification
+    typedef enum
+    {
+        GSM_CALL_STATUS_UNKNOWN                                             =0x00,
+        GSM_CALL_STATUS_WAITING_CONNECTION                                  =0x01,
+        GSM_CALL_STATUS_CONNECTED                                           =0x02,
+        GSM_CALL_STATUS_WAITING_FOR_USER_ANSWER                             =0x03,
+        GSM_CALL_STATUS_RECALL                                              =0x04,
+        GSM_CALL_STATUS_UNAVAILABLE                                         =0x05,
+        GSM_CALL_STATUS_CALL_CLEARED                                        =0x06,
+        GSM_CALL_STATUS_RELEASED_OR_FAIL                                    =0x07,
+        GSM_CALL_STATUS_PROGRESS                                                   =0x08
+    }
+    LXT_GSM_CALL_STATUS;
+
+    // call. alert info
+    typedef enum
+    {
+        GSM_CALL_ALERT_INFO_TYPE_DISPLAY                                    =0x01,
+        GSM_CALL_ALERT_INFO_TYPE_CALLED_PARTY                               =0x02,
+        GSM_CALL_ALERT_INFO_TYPE_CALLING_PARTY                              =0x03,
+        GSM_CALL_ALERT_INFO_TYPE_CONNECTED_NUMBER                           =0x04,
+        GSM_CALL_ALERT_INFO_TYPE_REPLACE_BY_SIGNALING_REPORT                =0x05,
+        GSM_CALL_ALERT_INFO_TYPE_MESSAGE_WAITING                            =0x06,
+        GSM_CALL_ALERT_INFO_TYPE_SERVICE_CONFIGURATION                      =0x07
+    }
+    LXT_GSM_CALL_ALERT_INFO_TYPE;
+
+    // call. presentation indicator
+    typedef enum
+    {
+        GSM_CALL_PI_ALLOWED                                                 =0x00,
+        GSM_CALL_PI_RESTRICTED                                              =0x01,
+        GSM_CALL_PI_NUMBER_NOT_AVAILABLE                                    =0x02,
+        GSM_CALL_PI_RESERVED                                                =0x03
+    }
+    LXT_GSM_CALL_PI;
+
+    // call. sups status
+    typedef enum
+    {
+        GSM_CALL_SUPS_STATUS_CALL_BARRED                                    =0x01,
+        GSM_CALL_SUPS_STATUS_CALL_IS_IN_WAITING                             =0x02,
+        GSM_CALL_SUPS_STATUS_CALL_RESTRICTED                                =0x03,
+        GSM_CALL_SUPS_STATUS_DEFLECTED_CALL                                 =0x04,
+        GSM_CALL_SUPS_STATUS_TRANSFERRED_CALL                               =0x05,
+        GSM_CALL_SUPS_STATUS_CUG_INFO_RECEIVED                              =0x06,
+        GSM_CALL_SUPS_STATUS_ORIG_FWD_STATE                                 =0x07,
+        GSM_CALL_SUPS_STATUS_CALL_FORWARDED                                 =0x08,
+        GSM_CALL_SUPS_STATUS_CALL_BEING_FORWARDED                           =0x09
+    }
+    LXT_GSM_CALL_SUPS_STATUS;
+
+    // mpty. operation
+    typedef enum
+    {
+        ENTERING_NO_OPERATION                                               =0x00,
+        ENTERING_0_SEND                                                     =0x01,
+        ENTERING_1_SEND                                                     =0x02,
+        ENTERING_1_X_SEND                                                   =0x03,
+        ENTERING_2_SEND                                                     =0x04,
+        ENTERING_2_X_SEND                                                   =0x05,
+        ENTERING_3_SEND                                                     =0x06,
+        ENTERING_4_SEND                                                     =0x07,
+        ENTERING_4_DN_SEND                                                  =0x08
+    }
+    LXT_GSM_MPTY_OPERATION;
+
+    // mpty. param id
+    typedef enum
+    {
+        MPTY_PARAM_ID_NONE                                                  =0x00,
+        MPTY_PARAM_ID_X                                                     =0x01,
+        MPTY_PARAM_ID_DN                                                    =0x02
+    }
+    LXT_GSM_MPTY_PARAM_ID;
+
+    // mpty. cfrm id
+    typedef enum
+    {
+        GSM_MPTY_CFM_ID_MPTY_CFRM_DATA_ID_NONE                              =0x00,
+        GSM_MPTY_CFM_ID_ACTIVE_CALL_LIST                                    =0x01,
+        GSM_MPTY_CFM_ID_SS_ERROR                                            =0x02
+    }
+    LXT_GSM_MPTY_CFM_ID;
+
+    // sups. operation
+    typedef enum
+    {
+        NO_OPERATION                                                        =0x00,
+        REGISTRATION                                                        =0x01,
+        ACTIVATION                                                          =0x02,
+        DEACTIVATION                                                        =0x03,
+        ERASURE                                                             =0x04,
+        INTERROGATION                                                       =0x05,
+        USSD                                                                =0x06,
+        USSD_RESPONSE                                                       =0x07,
+        USSD_NOTIFY_RESPONSE                                                =0x08,
+        PASSWORD_REGISTRATION                                               =0x09
+    }
+    LXT_GSM_SUPS_OPERATION;
+
+
+    // sups. network originated indication ooperation
+    typedef enum
+    {
+        USS_INDICATION                                                      =0x01,
+        USS_NOTIFY_INDICATION                                               =0x02,
+        PASSWORD_INDICATION                                                 =0x03
+    }
+    LXT_GSM_SUPS_NETWORK_INDICATION_OPERATION;
+
+
+    // sups. user confirm operation
+    typedef enum
+    {
+        USS_RES                                                             =0x01,
+        USS_NOTIFY_RES                                                      =0x02,
+        USS_EDIT                                                            =0x03,
+        USS_ABORT                                                           =0x04,
+        USS_DISPLAY_TIMEOUT                                                 =0x05,
+        USS_TIMER                                                           =0x06,
+        PASSWORD_RES                                                        =0x07
+    }
+    LXT_GSM_SUPS_USER_CONFIRM_OPERATION;
+
+    // sups. user confirm -- uss res type
+    typedef enum
+    {
+        USS_RES_TYPE_UNKNOWN_ALPHABET                                       =0x00,
+        USS_RES_TYPE_DISPLAY_BUSY                                           =0x01,
+        USS_RES_TYPE_OK                                                     =0x02,
+        USS_RES_TYPE_NONE                                                   =0x03
+    }
+    LXT_GSM_SUPS_USER_CONFIRM_USS_RES_TYPE;
+
+    // sups. user confirm -- uss res type
+    typedef struct
+    {
+        char uss_msg_len;
+        char uss_msg[64];
+    }
+    LXT_GSM_SUPS_USER_CONFIRM_USS_RES_MSG_TYPE;
+
+    // sups. user confirm -- uss guidance info type
+    typedef enum
+    {
+        USS_GUIDANCE_INFO_TYPE_ENTER_PW                                     =0x00,
+        USS_GUIDANCE_INFO_TYPE_ENTER_NEW_PW                                 =0x01,
+        USS_GUIDANCE_INFO_TYPE_ENTER_NEW_PW_AGAIN                           =0x02,
+        USS_GUIDANCE_INFO_TYPE_BAD_PW_TRY_AGAIN                             =0x03,
+        USS_GUIDANCE_INFO_TYPE_BAD_PW_FORMAT_TRY_AGAIN                      =0x04
+    }
+    LXT_GSM_SUPS_USER_CONFIRM_USS_GUIDANCE_INFO_TYPE;
+    // sups. user confirm -- uss password res type
+    typedef struct
+    {
+        char pw_len;
+        char pw[8];
+    }
+    LXT_GSM_SUPS_USER_CONFIRM_USS_PASSWORD_RES_TYPE;
+
+
+    // sups. result
+    typedef enum
+    {
+        FAILURE                                                             =0x00,
+        SUCCESS                                                             =0x01,
+    }
+    LXT_GSM_SUPS_RESULT;
+
+    // sups. error class
+    typedef enum
+    {
+        COMMAND_ERROR                                                       =0x01,
+        USER_DEFINED_ERROR                                                  =0x02
+    }
+    LXT_GSM_SUPS_ERROR_CLASS;
+
+    // sups. error reason(command error)
+    typedef enum
+    {
+        LXT_GSM_SUPS_ERROR_REASON_1_NO_ERROR                                =0x00,
+        LXT_GSM_SUPS_ERROR_REASON_1_INVALID_CLIENT_ID                       =0x01,
+        LXT_GSM_SUPS_ERROR_REASON_1_NULL_PARAM                              =0x02,
+        LXT_GSM_SUPS_ERROR_REASON_1_OFFLINE_STATE                           =0x03,
+        LXT_GSM_SUPS_ERROR_REASON_1_SRV_STATE_INVALID                       =0x04,
+        LXT_GSM_SUPS_ERROR_REASON_1_NO_BUFFER                               =0x05,
+        LXT_GSM_SUPS_ERROR_REASON_1_OTHER                                   =0x06,
+        LXT_GSM_SUPS_ERROR_REASON_1_UNDEFINED_FEATURE                       =0x07
+    }
+    LXT_GSM_SUPS_ERROR_REASON_1;
+
+
+    // sups. error reason(user define error)
+    typedef enum
+    {
+        LXT_GSM_SUPS_ERROR_REASON_2_NO_ERROR                                =0x00,
+        LXT_GSM_SUPS_ERROR_REASON_2_UNKNOWN_ERROR                           =0x01,
+        LXT_GSM_SUPS_ERROR_REASON_2_NULL_AT_COM_PTR                         =0x02,
+        LXT_GSM_SUPS_ERROR_REASON_2_INVALID_PARAM                           =0x03,
+        LXT_GSM_SUPS_ERROR_REASON_2_UNKNOWN_MSG                             =0x04,
+        LXT_GSM_SUPS_ERROR_REASON_2_OPER_TIMEOUT                            =0x05,
+        LXT_GSM_SUPS_ERROR_REASON_2_AUTO_NETSEL_ERROR                       =0x06,
+    }
+    LXT_GSM_SUPS_ERROR_REASON_2;
+
+
+    // sups. structure
+    typedef struct _lxt_gsm_sups_originated
+    {
+        LXT_GSM_SUPS_OPERATION operation;       // operation
+        int mask;                               // mask
+        char ss[4];                             // service code
+        char dn[64];                            // direct number
+        char pw[8];                             // password
+        char bs[4];                             // base group
+        int  t_nr;                              // no reply timer
+        char ussd[256];                         // unstructured ss data
+        int length;                             // data length (for expention)
+        void* data;                             // data (for expention)
+    }
+    LXT_GSM_SUPS_ORIGINATED;
+
+
+    // sups. user confirm
+    typedef struct _lxt_gsm_sups_user_confirm
+    {
+        LXT_GSM_SUPS_USER_CONFIRM_OPERATION operation;
+        int mask;
+        LXT_GSM_SUPS_USER_CONFIRM_USS_RES_TYPE res_type;
+        LXT_GSM_SUPS_USER_CONFIRM_USS_RES_MSG_TYPE res_mesg;
+        LXT_GSM_SUPS_USER_CONFIRM_USS_GUIDANCE_INFO_TYPE guidance_info_type;
+        LXT_GSM_SUPS_USER_CONFIRM_USS_PASSWORD_RES_TYPE password_res_type;
+
+    }
+    LXT_GSM_SUPS_USER_CONFIRM;
+
+    // sups. originated notification
+    typedef struct _lxt_gsm_sups_originated_rx_header_status
+    {
+        char status;                            // 1byte
+        char error_class;                       // 1byte
+        char error_reason;                      // 1byte
+        char operation;                         // 1byte
+    }
+    LXT_GSM_SUPS_ORIGINATED_RX_HEADER_STATUS;
+
+    typedef struct _lxt_gsm_sups_originated_rx_header_data
+    {
+        int id_cfrm_data;                       // 4byte
+        char len_data;                          // 1byte
+    }
+    LXT_GSM_SUPS_ORIGINATED_RX_HEADER_DATA;
+
+
+    typedef enum
+    {
+        LXT_SUPS_CALLERID_DEFAULT                                           =0x00,
+        LXT_SUPS_CALLERID_HIDE                                              =0x01,
+        LXT_SUPS_CALLERID_SEND                                              =0x02
+    }
+    LXT_CALLER_ID_OPTION;
+
+    typedef enum
+    {
+        LXT_SUPS_CCM                                                        =0x01,
+        LXT_SUPS_ACM                                                        =0x02,
+        LXT_SUPS_ACMMAX                                                     =0x03
+    }
+    LXT_CALL_COST_OPTION;
+
+    // for register sups ==================
+    typedef enum
+    {
+        NUMBER_IDENTIFICATION                                               =0x01,
+        CALL_OFFERING                                                       =0x02,
+        CALL_COMPLETION                                                     =0x03,
+        CALL_RESTRICTION                                                    =0x04,
+    }
+    LXT_GSM_SUPS_REG_PARAMS_TYPE;
+
+    typedef enum
+    {
+        FWD_INFO                                                            =0x01,
+        FWD_TO_NUM_INFO                                                     =0x02,
+        FWD_FEATURE_LIST_INFO                                               =0x03,
+        CALL_BARRING_INFO                                                   =0x04,
+        CLI_RESTRICTION_INFO                                                =0x05,
+        CALLED_PARTY_NUM_INFO                                               =0x06,
+        CUG_INFO                                                            =0x07,
+        BSG_LIST_INFO                                                       =0x08,
+        USS_DATA_INFO                                                       =0x09,
+        USSD_DATA_INFO                                                      =0x0A,
+        NEW_PWD_INFO                                                        =0x0B,
+        SS_DATA_INFO                                                        =0x0C,
+        SS_STATUS_INFO                                                      =0x0D,
+        SS_ERROR_INFO                                                       =0x0E,
+        CC_CAUSE_INFO                                                       =0x0F,
+        LL_CAUSE_INFO                                                       =0x10,
+        UNKNOWN_CONF_INFO                                                   =0x11,
+        NO_INFO                                                             =0x12,
+    }
+    LXT_GSM_SUPS_CONF_TYPE;
+
+
+    typedef enum
+    {
+        PERMANENT                                                           =0x01,
+        TEMP_DEFAULT_RESTRICTED                                             =0x02,
+        TEMP_DEFAULT_ALLOWED                                                =0x03,
+    }
+    LXT_GSM_SUPS_CLI_RESTRICTION_OPTION;
+
+
+    typedef enum
+    {
+        GSM_CONFIG_RAT_UNKNOWN                                              =0x00,
+        GSM_CONFIG_RAT_GSM900                                               =0x01,
+        GSM_CONFIG_RAT_DCS1800                                              =0x02,
+        GSM_CONFIG_RAT_PCS1900                                              =0x03,
+        GSM_CONFIG_RAT_GSM_SAT                                              =0x04,
+        GSM_CONFIG_RAT_UMTS                                                 =0x05,
+        GSM_CONFIG_RAT_LIMITED_SRVC                                         =0x06
+    }
+    LXT_GSM_CONFIG_RAT;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LINUXTAPI4GSM_TYPE_H_
+
+
diff --git a/libvmodem/linuxtapi4type.h b/libvmodem/linuxtapi4type.h
new file mode 100644 (file)
index 0000000..7da6a94
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LINUXTAPI4TYPE_H_
+#define _LINUXTAPI4TYPE_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+
+    // selected slot
+    typedef enum
+    {
+        LXT_RUIM_SLOT_1                                                         = 0x00,
+        LXT_RUIM_SLOT_2                                                         = 0x01,
+        LXT_RUIM_SLOT_ALL                                                       = 0x02
+    }
+    LXT_RUIM_SLOT;
+
+    // sim code id
+    typedef enum
+    {
+        LXT_SIM_CODE_ID_PIN1                                                    = 0x00,
+        LXT_SIM_CODE_ID_PIN2                                                    = 0x01,
+        LXT_SIM_CODE_ID_PUK1                                                    = 0x02,
+        LXT_SIM_CODE_ID_PUK2                                                    = 0x03,
+        LXT_SIM_CODE_ID_SIM_LOCK                                                = 0x04,
+        LXT_SIM_CODE_ID_PHONE_LOCK                                              = 0x05
+    }
+    LXT_SIM_CODE_ID;
+
+    // selected network mode
+    typedef enum
+    {
+        LXT_SELECTED_NETWORK_MODE_SLOT1_CDMA                                    = 0x00,
+        LXT_SELECTED_NETWORK_MODE_SLOT1__GSM                                    = 0x01,
+        LXT_SELECTED_NETWORK_MODE_SLOT2_CDMA                                    = 0x02,
+        LXT_SELECTED_NETWORK_MODE_SLOT2__GSM                                    = 0x03
+    }
+    LXT_SELECTED_NETWORK_MODE;
+
+    // network selection method
+    typedef enum
+    {
+        LXT_NETWORK_SELECTION_MODE_DEFAULT                                      = 0x00,
+        LXT_NETWORK_SELECTION_MODE_MENU                                         = 0x01
+    }
+    LXT_NETWORK_SELECTION_MODE;
+
+    // pin check status
+    typedef enum
+    {
+        LXT_PIN_STATUS_DISABLE                                                  = 0x00,
+        LXT_PIN_STATUS_ENABLE                                                   = 0x01
+    }
+    LXT_PIN_STATUS;
+
+    // phone status
+    typedef enum
+    {
+        LXT_CARD_STATUS_CARD1_SEARCHING_START                                   = 0x00,
+        LXT_CARD_STATUS_CARD2_SEARCHING_START                                   = 0x01,
+        LXT_CARD_STATUS_CARD_SEARCHING_END                                      = 0x02,
+        LXT_CARD_STATUS_FORCE_GSM_MODE_RUN                                      = 0x03,
+        LXT_CARD_STATUS_FORCE_CDMA_MODE_RUN                                     = 0x04,
+        LXT_CARD_STATUS_ALL_EMPTY                                               = 0x05,
+        LXT_CARD_STATUS_CARD1_PERM_BLOCKED                                      = 0x06,
+        LXT_CARD_STATUS_CARD2_PERM_BLOCKED                                      = 0x07,
+        LXT_CARD_STATUS_ALL_PERM_BLOCKED                                        = 0x08,
+        LXT_CARD_STATUS_CARD1_BLOCKED                                           = 0x09,
+        LXT_CARD_STATUS_CARD2_BLOCKED                                           = 0x0A,
+        LXT_CARD_STATUS_ALL_BLOCKED                                             = 0x0B,
+        LXT_CARD_STATUS_CARD1_IMSI_ERROR                                        = 0x0C,
+        LXT_CARD_STATUS_CARD2_IMSI_ERROR                                        = 0x0D,
+        LXT_CARD_STATUS_CARD_ENABLED                                            = 0x0E,
+        LXT_CARD_STATUS_CARD_DISABLED                                           = 0x0F,
+        LXT_CARD_STATUS_CARD1_BROKEN                                            = 0x10,
+        LXT_CARD_STATUS_CARD2_BROKEN                                            = 0x11
+    }
+    LXT_CARD_STATUS;
+
+    // current status
+    typedef enum
+    {
+        LXT_PIN_PROCESS_STATUS_NETWORK_LIST                                     = 0x00,
+        LXT_PIN_PROCESS_STATUS_PIN_CHECK                                        = 0x01,
+        LXT_PIN_PROCESS_NETWORK_START                                           = 0x02,
+        LXT_PIN_PROCESS_MENU_SELECTION_PUK1                                     = 0x03,
+        LXT_PIN_PROCESS_PHONE_SETUP                                             = 0x04
+    }
+    LXT_PIN_PROCESS_STATUS;
+
+
+    // slot capability
+    typedef enum
+    {
+        LXT_SLOT_CAPABILITY_UNKNOWN                                             = 0x00,
+        LXT_SLOT_CAPABILITY_USIM                                                = 0x01,
+        LXT_SLOT_CAPABILITY_GSM                                                 = 0x02,
+        LXT_SLOT_CAPABILITY_GSM_USIM                                            = 0x03,
+        LXT_SLOT_CAPABILITY_RUIM                                                = 0x04,
+        LXT_SLOT_CAPABILITY_GSM_RUIM                                            = 0x05,
+        LXT_SLOT_CAPABILITY_EMV                                                 = 0x06
+    }
+    LXT_SLOT_CAPABILITY;
+
+
+    // slot state
+    typedef enum
+    {
+        LXT_SLOT_STATE_NOT_INITIALIZE                                           = 0x00,
+        LXT_SLOT_STATE_DISABLED                                                 = 0x01,
+        LXT_SLOT_STATE_ENABLED                                                  = 0x02,
+        LXT_SLOT_STATE_BLOCKED                                                  = 0x03,
+        LXT_SLOT_STATE_PERM_BLOCKED                                             = 0x04,
+        LXT_SLOT_STATE_UNDEFINE                                                 = 0xff
+    }
+    LXT_SLOT_STATE;
+
+    // dn mode
+    typedef enum
+    {
+        LXT_DN_MODE_ADN                                                         = 0x00,
+        LXT_DN_MODE_FDN                                                         = 0x01
+    }
+    LXT_DN_MODE;
+
+    typedef enum
+    {
+        FDN_STATE_DISABLE                                                       = 0x00,
+        FDN_STATE_ENABLE                                                        = 0x01
+    }
+    LXT_FDN_STATE;
+
+    typedef enum
+    {
+        LXT_GSDI_NONE                     = 0x00,
+        LXT_GSDI_CHV1_DISABLE             = 0x01,   // CHV1 disabled function
+        LXT_GSDI_ADN                      = 0x02,   // GSM Abbreviated Dialling Numbers
+        LXT_GSDI_FDN                      = 0x03,   // Forbidden Dialling Numbers
+        LXT_GSDI_SMS                      = 0x04,   // Short Mesasge Services
+        LXT_GSDI_AOC                      = 0x05,   // Advice of Charge
+        LXT_GSDI_CCP                      = 0x06,   // Configuration Capability Params
+        LXT_GSDI_PLMN_SELECTOR            = 0x07,   // PLMN Selector
+        LXT_GSDI_MSISDN                   = 0x08,   // MSISDN
+        LXT_GSDI_EXT1                     = 0x09,   // Extension 1
+        LXT_GSDI_EXT2                     = 0x0A,   // Extension 2
+        LXT_GSDI_SMSP                     = 0x0B,   // SMS Parameters
+        LXT_GSDI_LND                      = 0x0C,   // Last Number Dialled
+        LXT_GSDI_GID1                     = 0x0D,   // Group Identifier 1
+        LXT_GSDI_GID2                     = 0x0E,   // Group Identifier 2
+        LXT_GSDI_SPN                      = 0x0F,   // Service Provider Name
+        LXT_GSDI_SDN                      = 0x10,   // Service Dialling Numbers
+        LXT_GSDI_EXT3                     = 0x11,   // Enxtension 3
+        LXT_GSDI_VGCS_GID_LIST            = 0x12,   // VGCS Group Identifier List
+        LXT_GSDI_VBS_GID_LIST             = 0x13,   // VBS Gropu Identifier List
+        LXT_GSDI_ENH_ML_SVC               = 0x14,   // Enhnaged Multi Level Precedence and Premption Service
+        LXT_GSDI_AA_EMLPP                 = 0x15,   // Automatic Answer for eMLPP
+        LXT_GSDI_DATA_DL_SMSCB            = 0x16,   // Data download via SMS-CB
+        LXT_GSDI_DATA_DL_SMSPP            = 0x17,   // Data download via SMS-PP
+        LXT_GSDI_MENU_SEL                 = 0x18,   // Menu Selection
+        LXT_GSDI_CALL_CONTROL             = 0x19,   // Call Control
+        LXT_GSDI_MO_SMS_CONTROL           = 0x1A,   // MO SMS control
+        LXT_GSDI_PROACTIVE_SIM            = 0x1B,   // Proactive SIM
+        LXT_GSDI_CBMID_RANGES             = 0x1C,   // Cell Broadcast Message Identifiers
+        LXT_GSDI_BDN                      = 0x1D,   // Barred Dialing Numbers
+        LXT_GSDI_EXT4                     = 0x1E,   // Extension 4
+        LXT_GSDI_DEPERSON_KEYS            = 0x1F,   // Depersonalization Keys
+        LXT_GSDI_COOP_NETWK_LIST          = 0x20,   // Co-operative Network List
+        LXT_GSDI_SMSR                     = 0x21,   // Short Message Status Reports
+        LXT_GSDI_NETWK_ALERTING_MS        = 0x22,   // Network's Indication of Alerting in the MS
+        LXT_GSDI_MO_SMS_BY_SIM            = 0x23,   // Mobile Originated Short Messagse control by SIM
+        LXT_GSDI_GPRS                     = 0x24,   // GPRS
+        LXT_GSDI_IMAGES                   = 0x25,   // Image (IMG)
+        LXT_GSDI_SOLSA                    = 0x26,   // Support of Loca Service Area
+        LXT_GSDI_USSD                     = 0x27,   // USSD String Data object supported in Call Control
+        LXT_GSDI_RUN_AT_CMD               = 0x28,   // RUN AT COMMAND command
+        LXT_GSDI_LOCAL_PHONEBOOK          = 0x29,   // Local Phonebook, UADF/Phonebook/ADN
+        LXT_GSDI_GLOBAL_PHONEBOOK         = 0x2A,   // Global Phonebook on USIM (always present)
+        LXT_GSDI_OCI_OCT                  = 0x2B,   // Outgoing Call information/timer
+        LXT_GSDI_ICI_ICT                  = 0x2C,   // Incoming Call Information/timer
+        LXT_GSDI_CBMID                    = 0x2D,   // Cell Broadcast Message Identifier
+        LXT_GSDI_UPLMN_SEL_WACT           = 0x2E,   // User controlled PLMN Selector with Access Technology
+        LXT_GSDI_GSM_ACCESS_IN_USIM       = 0x2F,   // USIM ADF Access to USIM files for GSM Roaming
+        LXT_GSDI_RPLMN_LACT               = 0x30,   // RPLMN Last used Access Technology
+        LXT_GSDI_SP_DISP_INFO             = 0x31,   // Service Provider Display Information
+        LXT_GSDI_EST                      = 0x32,   // Enable Service Table in USIM
+        LXT_GSDI_ACL                      = 0x33,   // APN Control list
+        LXT_GSDI_GSM_SECURITY_CONTEXT     = 0x34,   // GSM Security Context
+        LXT_GSDI_CPBCCH                   = 0x35,   // CP BCCH
+        LXT_GSDI_INV_SCAN                 = 0x36,   // Investigation Scan
+        LXT_GSDI_MEXE                     = 0x37,   // MExE info
+        LXT_GSDI_OPLMN_SEL_WACT           = 0x38,   // Operator controlled PLMN Selector with Access Technology
+        LXT_GSDI_HPLMN_WACT               = 0x39,   // HPLMN Selector with Access Technology
+        LXT_GSDI_EXT5                     = 0x3A,   // Extention 5
+        LXT_GSDI_PLMN_NTWRK_NAME          = 0x3B,   // PLMN Network Name
+        LXT_GSDI_OPLMN_LIST               = 0x3C,   // Operator PLMN List
+        LXT_GSDI_MAILBOX_DIAL             = 0x3D,   // Mailbox Dialing Numbers
+        LXT_GSDI_MSG_WAIT                 = 0x3E,   // Message Wait Indication
+        LXT_GSDI_CALL_FWD_IND             = 0x3F,   // Call Forward Indication Status
+        LXT_GSDI_MMS                      = 0x40,   // Multimedia Messaging Service
+        LXT_GSDI_EXT8                     = 0x41,   // Extension 8
+        LXT_GSDI_GPRS_USIM                = 0x42,   // Call control on GPRS by USIM
+        LXT_GSDI_MMS_USR_P                = 0x43,   // MMS User Connectivity Parameters
+        LXT_GSDI_EXT_CCP                  = 0x44,   // extended capability configuration param - in GSM
+        LXT_GSDI_MAX_SVR_RSP              = 0x45
+    }
+    LXT_GSDI;   // generic sim driver interface
+
+
+
+    // network mode (internal)
+    typedef enum
+    {
+        LXT_NETWORK_MODE_SLOT1_CDMA                                             = 0x00,
+        LXT_NETWORK_MODE_SLOT1_GSM                                              = 0x01,
+        LXT_NETWORK_MODE_SLOT2_CDMA                                             = 0x02,
+        LXT_NETWORK_MODE_SLOT2_GSM                                              = 0x03,
+        LXT_NETWORK_MODE_UNDEFINED                                              = 0xFF,
+    }
+    LXT_NETWORK_MODE;
+
+    typedef enum
+    {
+        FDN_STATE_SUCCESS                                                       = 0x00,
+        FDN_STATE_PIN2_AUTH_FAIL                                                = 0x01,
+        FDN_STATE_NOT_SUPPORT_FAIL                                              = 0x02,
+        FDN_STATE_ENABLE_FAIL                                                   = 0x03,
+        FDN_STATE_DISABLE_FAIL                                                  = 0x04
+    }
+    LXT_FDN_STATE_FAIL_REASON;
+
+    typedef enum
+    {
+        LXT_PHONE_REBUILD_STATUS_START                                          = 0x01,
+        LXT_PHONE_REBUILD_STATUS_END                                            = 0x02,
+        LXT_PHONE_REBUILD_STATUS_UNDEFINE                                       = 0xFF
+    }
+    LXT_PHONE_REBUILD_STATUS;
+
+    typedef enum
+    {
+        LXT_SIM_COVER_STATUS_CLOSE                                              = 0x01,
+        LXT_SIM_COVER_STATUS_OPEN                                               = 0x02,
+        LXT_SIM_COVER_STATUS_UNDEFINE                                           = 0xFF
+    }
+    LXT_SIM_COVER_STATUS;
+
+    typedef struct _lxt_card
+    {
+        LXT_SLOT_STATE state;           // card status : empty, disable, enable, block, p.block
+        char iccid[16];                 // iccid
+        int provider;                   // provider : mcc, mnc
+        LXT_SLOT_CAPABILITY capability; // capability : cdma only, gsm only, dual
+        LXT_DN_MODE dn_mode;            // dn mode : adn, fdn
+    }
+    LXT_CARD;
+
+    typedef struct _lxt_dual_card
+    {
+        LXT_NETWORK_SELECTION_MODE selection_mode;
+        LXT_NETWORK_MODE booted_network_mode;
+        LXT_CARD card1;
+        LXT_CARD card2;
+    }
+    LXT_DUAL_CARD;
+
+
+
+    typedef struct _lxt_card_authentication
+    {
+        LXT_RUIM_SLOT slot_name;
+        LXT_SIM_CODE_ID sim_code_id;
+        char size_current_code;
+        char current_code[8];
+        char size_new_code;
+        char new_code[8];
+        char is_boot_time;
+    }
+    LXT_CARD_AUTHENTICATION;
+
+
+    typedef struct _lxt_network_information
+    {
+        int mcc;
+        int mnc;
+        char rat;
+        char plmn_id[3];
+    }
+    LXT_NETWORK_INFORMATION;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LINUXTAPI4TYPE_H_
+
+
diff --git a/libvmodem/lxtsms.c b/libvmodem/lxtsms.c
new file mode 100644 (file)
index 0000000..bbd4172
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <string.h>
+// ++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "lxtsmstypedef.h"
+#include "lxtsms.h"
+// ++++++++++++++++++++++++++++++++++++++++++++++define area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++define public function
+
+
+void lxt_sms_init_message(LXT_SMS *s)
+{
+    //    // initalize sms header
+    //    s->header.teleservice_id = 0;
+    //    s->header.message_type = 0;
+    //    s->header.message_id = 0;
+    //    s->header.language_indicator = 0;
+    //    s->header.destination_number[0] = 0;
+    //    s->header.call_back_number[0] = 0;
+    //    s->header.size = 0;
+    //
+    //    // initalize sms body
+    //    memset(s->body.content, 0, 256);
+
+    memset(s,0,sizeof(LXT_SMS));
+}
diff --git a/libvmodem/lxtsms.h b/libvmodem/lxtsms.h
new file mode 100644 (file)
index 0000000..52d4890
--- /dev/null
@@ -0,0 +1,617 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTSMS_H_
+#define _LXTSMS_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "linuxtapi.h"
+#include "lxtsmstypedef.h"
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+#define DEF_INIT_MAGIC_CODE                                                0xFF
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ type define area
+
+    // Global ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    // SMS_TIME_STAMP_RELATIVE
+    // offset value | relative time period                     | validity period | delivery time
+    // =============|==========================================|=================|===============
+    // 0 ~ 143      |  (value + 1) * 5 min                     |        x        |        x
+    // =============|==========================================|=================|===============
+    // 144 ~ 167    |  12 hours + ((value -143) * 30 min)      |        x        |        x
+    // =============|==========================================|=================|===============
+    // 168 ~ 196    |  (value - 166) days                      |        x        |        x
+    // =============|==========================================|=================|===============
+    // 197 ~ 244    |  (value - 192) weeks                     |        x        |        x
+    // =============|==========================================|=================|===============
+    // 245          |  Indefinite                              |        x        |
+    // =============|==========================================|=================|===============
+    // 246          |  Immediate [1]                           |        x        |
+    // =============|==========================================|=================|===============
+    // 247          |  Valid until mobile becomes inactive     |        x        |        x
+    //              |  Deliver when mobile next becomes active |                 |
+    // =============|==========================================|=================|===============
+    // 248          |  Valid until registration area changes,  |        x        |
+    //              |  discard if not registered               |                 |
+    // =============|==========================================|=================|===============
+    // 249 ~ 255    |  reserved                                |                 |
+    // =============|==========================================|=================|===============
+
+
+    // Teleservice Identifier (0x01) +++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of teleservice id
+        unsigned char length;
+
+        // teleservice identifier
+        SMS_TELESERVICE_ID service_id;
+
+    }
+    SMS_TELESERVICE_IDENTIFIER;
+
+
+    // Broadcast Service Category (0x02) +++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of broadcast service category
+        unsigned char length;
+
+        // service category(2byte)
+        SMS_BROADCAST_SERVICE_CATEGORY_CATEGORY category;
+
+    }
+    SMS_BROADCAST_SERVICE_CATEGORY;
+
+
+    // Address (0x03) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length - 5 + num_fields
+        unsigned char length;
+
+        // digit mode indicator - 0x00 : 4BIT_DTMF, 0x01:8BIT_CODE;
+        SMS_ADDRESS_DIGIT_MODE digit_mode;
+
+        // number mode indicator - 0x00 : ANSI TI.607, 0x01 : Data Network
+        SMS_ADDRESS_NUMBER_MODE number_mode;
+
+        // type of number -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) ) then use SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK
+        // if ( DIGIT_MODE == 0 ) then ignore this field
+        SMS_ADDRESS_NUMBER_TYPE number_type;
+
+        // numbering plan -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_PLAN
+        // if ( ( DIGIT_MODE == 0 ) || ( NUMBER_MODE == 1 ) ) then ignore this field
+        SMS_ADDRESS_NUMBER_PLAN number_plan;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // digit number
+        // if ( DIGIT_MODE == 0 ) then ASCII
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then ANSI X3.4(7bit code for american standard, all significant bit '0')
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE == 2 ) ) mail address
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE != 2 ) ) ip address
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+    }
+    SMS_ADDRESS;
+
+
+    // Subaddress (0x04) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+
+        // parameter length - 3 + num_fields
+        unsigned char length;
+
+        // subaddress type - use SMS_SUBADDRESS_TYPE
+        SMS_SUBADDRESS_TYPE type;
+
+        // odd/even indicator
+        // if the last digit_number contains information only in the 4 most sign bit then '1' else '0'
+        unsigned char odd;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // subaddress octet
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+    }
+    SMS_SUBADDRESS;
+
+
+    // Bearer Reply Option (0x05) ++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // length of rearer reply option
+        unsigned char length;
+
+        // reply sequence number
+        // This field shall be set to a value identifying the SMS message for
+        // which acknowledgment is requested. : 0 ~ 63 ( modulo of 8 )
+        unsigned char reply_seq;
+
+    }
+    SMS_BEARER_REPLY_OPTION;
+
+
+    // Cause Codes (0x06) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // reply sequence number
+        // this field shall be set to the reply sequence number in the
+        // Bearer Reply Option parameter of the message being acknowledged.
+        unsigned char reply_seq;
+
+        // error report class - use SMS_CAUSE_CODES_ERROR_CLASS
+        SMS_CAUSE_CODES_ERROR_CLASS error_class;
+
+        // error cause identifier - if ERROR_CLASS is 0, then this field is ignored.
+        // if ERROR_CLASS is 2 or 3, then use SMS_CAUSE_CODE_CAUSE_CODE_NETWORK
+        // if ERROR_CLASS is 4, then use SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL
+        SMS_CAUSE_CODE_CAUSE_CODE cause_code;
+
+    }
+    SMS_CAUSE_CODES;
+
+
+    // Message Identifier (0x07) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // length of message identifier
+        unsigned char length;
+
+        // use SMS_MESSAGE_TYPE
+        SMS_MESSAGE_TYPE message_type;
+
+        // Message ID Number(2 byte)
+        unsigned short message_id;
+
+    }
+    SMS_MESSAGE_IDENTIFIER;
+
+
+    // User Data (0x08) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // user data length
+        unsigned char length;
+
+        // encoding - use SMS_USER_DATA_MSG_ENCODING
+        SMS_USER_DATA_MSG_ENCODING msg_encoding;
+
+        // number of digit_number
+        unsigned char num_fields;
+
+        // user data
+        unsigned char* user_data;
+
+    }
+    SMS_USER_DATA;
+
+
+    // User Response Code (0x09) +++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // length of user response code
+        unsigned char length;
+
+        // this field value depends on the teleservices or the carrier
+        unsigned char response_code;
+
+    }
+    SMS_USER_RESPONSE_CODE;
+
+
+    // Message Center Time Stamp (0x0A) ++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of message center time stamp
+        unsigned char length;
+
+        // time stamp
+        unsigned char time_stamp[6];
+
+    }
+    SMS_MESSAGE_CENTER_TIME_STAMP;
+
+
+    // Validity Period - Absolute (0x0B) +++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // prameter length
+        unsigned char length;
+
+        // time stamp
+        unsigned char validity_period[6];
+
+    }
+    SMS_VALIDITY_PERIOD_ABSOLUTE;
+
+
+    // Validity Period - Relative (0x0C) +++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // relative value
+        unsigned char validity;
+
+
+    }
+    SMS_VALIDITY_PERIOD_RELATIVE;
+
+
+    // Deferred Delivery Time - Absolute (0x0D) ++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // time stamp
+        unsigned char deferred_delivery_time[6];
+
+    }
+    SMS_DEFERRED_DELIVERY_TIME_ABSOLUTE;
+
+
+    // Deferred Delivery Time - Relative (0x0E) ++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // relative value
+        unsigned char deferred_delivery_time;
+
+    }
+    SMS_DEFERRED_DELIVERY_TIME_RELATIVE;
+
+
+    // Priority Indicator (0x0F) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // level of priority
+        SMS_PRIORITY_INDICATOR_PRIORITY priority;
+
+    }
+    SMS_PRIORITY_INDICATOR;
+
+
+    // Privacy Indicator (0x10) ++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // privacy level
+        SMS_PRIVACY_INDICATOR_PRIVACY privacy;
+
+    }
+    SMS_PRIVACY_INDICATOR;
+
+
+    // Reply Option (0x11) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // TRUE if User acknowledgment is requested (0x00 : FALSE, 0x01 : TRUE)
+        unsigned char user_ack_req;
+
+        // TRUE if Delivery acknowledgment is requested (0x00 : FALSE, 0x01 : TRUE)
+        unsigned char dak_req;
+
+    }
+    SMS_REPLY_OPTION;
+
+
+    // Number of Messages (0x12) +++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // number of voice mail (0 ~ 99)
+        unsigned char message_count;
+
+    }
+    SMS_NUMBER_OF_MESSAGES;
+
+
+    // Alert on Message Delivery (0x13) ++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // the type of alerts used to distinguish different priorities of the message
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY alert_priority;
+
+    }
+    SMS_ALERT_ON_MESSAGE_DELIVERY;
+
+
+    // Language Indicator (0x14) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // language indicator
+        SMS_LANGUAGE_INDICATOR_LANGUAGE language;
+
+    }
+    SMS_LANGUAGE_INDICATOR;
+
+
+    // Call Back Number (0x15) +++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+
+        // parameter length - 5 + num_fields
+        unsigned char length;
+
+        // digit mode indicator - 0x00 : 4BIT_DTMF, 0x01:8BIT_CODE;
+        SMS_ADDRESS_DIGIT_MODE digit_mode;
+
+        // type of number -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) ) then use SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK
+        // if ( DIGIT_MODE == 0 ) then ignore this field
+        SMS_ADDRESS_NUMBER_TYPE number_type;
+
+
+        // numbering plan -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_PLAN
+        // if ( ( DIGIT_MODE == 0 ) || ( NUMBER_MODE == 1 ) ) then ignore this field
+        SMS_ADDRESS_NUMBER_PLAN number_plan;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // digit number
+        // if ( DIGIT_MODE == 0 ) then ASCII
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then ANSI X3.4(7bit code for american standard, all significant bit '0')
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE == 2 ) ) mail address
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE != 2 ) ) ip address
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+
+    }
+    SMS_CALL_BACK_NUMBER;
+
+
+    // Display Mode (0x16) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // message display mode
+        SMS_MESSAGE_DISPLAY_MODE msg_display_mode;
+
+        // prl update
+        unsigned char prl_update;
+
+        // encoding
+        unsigned char encoding;
+
+    }
+    SMS_DISPLAY_MODE;
+
+
+    // Multiple Encoding User Data (0x17) ++++++++++++++++++++++++++++++++++++++++++
+    // TBD...
+    typedef struct
+    {
+        // message encoding
+        unsigned char msg_encoding;
+
+        // user data length
+        unsigned char num_fields;
+
+        // user data
+        unsigned char* user_data;
+
+    }
+    SMS_MULTIPLE_ENCODING_USER_DATA_ENDCODING_SPECIFIC_FIELDS;
+
+
+    typedef struct
+    {
+        unsigned char length;
+        SMS_MULTIPLE_ENCODING_USER_DATA_ENDCODING_SPECIFIC_FIELDS *encoding_specific_fields;
+
+    }
+    SMS_MULTIPLE_ENCODING_USER_DATA;
+
+
+    // Memory Index (0x18) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // memory address
+        unsigned short mem_address;
+
+    }
+    SMS_MEMORY_INDEX;
+
+
+    // SMS Message +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // ruim memory index
+        unsigned char uim_memory_index;
+
+        // ruim tag
+        unsigned char uim_tag;
+
+        // Remaining frame count
+        unsigned char rfr_cnt;
+
+        // 0x00 : SMS Point to Point Message, 0x01 : SMS Broadcast Message
+        unsigned char sms_msg_cat;
+
+        // parametr mask
+        unsigned char sms_param_mask[4];
+
+        // One of more occurrences of the following parameter record ------------
+
+        // service id (1 byte) -- 0x01
+        SMS_TELESERVICE_IDENTIFIER teleserviceIdentifier;
+
+        // broadcast service category (2 byte) -- 0x02
+        SMS_BROADCAST_SERVICE_CATEGORY broadcastServiceCategory;
+
+        // Address-Destination Address or Origination Address -- 0x03
+        SMS_ADDRESS address;
+
+        // Subaddress-Destination or Origination -- 0x04
+        SMS_SUBADDRESS subaddress;
+
+        // Bearer reply option - Reply sequence number -- 0x05
+        // This field shall be set to a value identifying the SMS message for
+        // which acknowledgment is requested. : 0 ~ 63 ( modulo of 8 )
+        SMS_BEARER_REPLY_OPTION bearer_reply_option;
+
+        // Cause Codes -- 0x06
+        SMS_CAUSE_CODES cause_codes;
+
+        // message identifier -- 0x07
+        SMS_MESSAGE_IDENTIFIER message_identifier;
+
+        // user data -- 0x08
+        SMS_USER_DATA user_data;
+
+        // user response code -
+        //This field value depends on the teleservices or the carrier-- 0x09
+        SMS_USER_RESPONSE_CODE response_code;
+
+        // Message Center Time Stamp -- 0x0A
+        SMS_MESSAGE_CENTER_TIME_STAMP message_center_time_stamp;
+
+        // Validity Period - Absolute -- 0x0B
+        SMS_VALIDITY_PERIOD_ABSOLUTE validity_period_absolute;
+
+        // Validity Period - Relative -- 0x0C
+        SMS_VALIDITY_PERIOD_RELATIVE validity_period_relative;
+
+        // Deferred Delivery Time - Absolute -- 0x0D
+        SMS_DEFERRED_DELIVERY_TIME_ABSOLUTE deferred_delivery_time_absolute;
+
+        // Deferred Delivery Time - Relative -- 0x0E
+        SMS_DEFERRED_DELIVERY_TIME_RELATIVE deferred_delivery_time_relative;
+
+        // Priority Indicator - use SMS_PRIORITY_INDICATOR 0x0F
+        SMS_PRIORITY_INDICATOR priority_indicator;
+
+        // Privacy Indicator - use SMS_PRIVACY_INDICATOR 0x10
+        SMS_PRIVACY_INDICATOR privacy_indicator;
+
+        // reply option -- 0x11
+        SMS_REPLY_OPTION reply_option;
+
+        // Number of Messages --0x12 (0 ~ 99)
+        // The number of messages element is a 0 to 99 decimal number
+        SMS_NUMBER_OF_MESSAGES number_of_messages;
+
+        // Alert on Message Delivery -- Ox13 - use SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY
+        SMS_ALERT_ON_MESSAGE_DELIVERY alert_message_delivery;
+
+        // language indicator -- 0x14 - use SMS_LANGUAGE_INDICATOR_LANGUAGE
+        SMS_LANGUAGE_INDICATOR language_indicator;
+
+        // call back number -- 0x15
+        SMS_CALL_BACK_NUMBER call_back_number;
+
+        // message display mode -- 0x16 - use SMS_MESSAGE_DISPLAY_MODE
+        SMS_DISPLAY_MODE message_display_mode;
+
+        // multiple encoding user data -- 0x17
+        SMS_MULTIPLE_ENCODING_USER_DATA multiple_encoding_user_data;
+
+        // memory index -- 0x18
+        SMS_MEMORY_INDEX memory_index;
+
+
+    }
+    TSamsungSMS;
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++ function prototype define
+    void lxt_sms_init_message(LXT_SMS *s);
+    int lxt_sms_paramsParser(TSamsungSMS *s, unsigned char *r);
+    void lxt_sms_parser(LXT_SMS *s,unsigned char memoryIndex,unsigned char tag,unsigned char rfr_cnt,unsigned char msg_cat,unsigned char *param_mask,unsigned char *rawdata,unsigned char length);
+    int lxt_sms_paramsDeparser(TSamsungSMS *s, unsigned char param_id, unsigned char *r);
+    unsigned char *lxt_sms_deparser(LXT_SMS *s, unsigned char *length);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LXTSMS_H_
diff --git a/libvmodem/lxtsmstypedef.h b/libvmodem/lxtsmstypedef.h
new file mode 100644 (file)
index 0000000..97b04f2
--- /dev/null
@@ -0,0 +1,340 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTSMSTYPEDEF_H_
+#define _LXTSMSTYPEDEF_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+    typedef enum
+    {
+        SMS_PARAM_ID_TELESERVICE_IDENTIFIER=                                    0x01,
+        SMS_PARAM_ID_BROADCAST_SERVICE_CATEGORY=                                0x02,
+        SMS_PARAM_ID_ADDRESS=                                                   0x03,
+        SMS_PARAM_ID_SUBADDRESS=                                                0x04,
+        SMS_PARAM_ID_BEARER_REPLY_OPTION=                                       0x05,
+        SMS_PARAM_ID_CAUSE_CODES=                                               0x06,
+        SMS_PARAM_ID_MESSAGE_IDENTIFIER=                                        0x07,
+        SMS_PARAM_ID_USER_DATA=                                                 0x08,
+        SMS_PARAM_ID_USER_RESPONSE_CODE=                                        0x09,
+        SMS_PARAM_ID_MESSAGE_CENTER_TIME_STAMP=                                 0x0a,
+        SMS_PARAM_ID_VALIDITY_PERIOD_ABSOLUTE=                                  0x0b,
+        SMS_PARAM_ID_VALIDITY_PERIOD_RELATIVE=                                  0x0c,
+        SMS_PARAM_ID_DEFERRED_DELIVERY_TIME_ABSOLUTE=                           0x0d,
+        SMS_PARAM_ID_DEFERRED_DELIVERY_TIME_RELATIVE=                           0x0e,
+        SMS_PARAM_ID_PRIORITY_INDICATOR=                                        0x0f,
+        SMS_PARAM_ID_PRIVACY_INDICATOR=                                         0x10,
+        SMS_PARAM_ID_REPLY_OPTION=                                              0x11,
+        SMS_PARAM_ID_NUMBER_OF_MESSAGES=                                        0x12,
+        SMS_PARAM_ID_ALERT_ON_MESSAGE_DELIVERY=                                 0x13,
+        SMS_PARAM_ID_LANGUAGE_INDICATOR=                                        0x14,
+        SMS_PARAM_ID_CALL_BACK_NUMBER=                                          0x15,
+        SMS_PARAM_ID_DISPLAY_MODE=                                              0x16,
+        SMS_PARAM_ID_MULTIPLE_ENCODING_USER_DATA=                               0x17,
+        SMS_PARAM_ID_MEMORY_INDEX=                                              0x18
+    }SMS_PARAM_ID;
+
+
+
+    typedef enum
+    {
+        SMS_ADDRESS_DIGIT_MODE_4BIT_DTMF=                                       0x00,
+        SMS_ADDRESS_DIGIT_MODE_8BIT_CODE=                                       0x01
+    }SMS_ADDRESS_DIGIT_MODE;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_MODE_ANSI_TI_DOT_607=                                0x00,
+        SMS_ADDRESS_NUMBER_MODE_DATA_NETWORK=                                   0x01
+    }SMS_ADDRESS_NUMBER_MODE;
+
+    typedef unsigned char SMS_ADDRESS_NUMBER_TYPE;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_UNKNOWN=                        0x00,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_INTERNATIONAL_NUMBER=           0x01,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_NATIONAL_NUMBER=                0x02,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_NETWORK_SPECIFIC_NUMBER=        0x03,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_SUBSCRIBER_NUMBER=              0x04,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_RESERVED=                       0x05,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_ABBREVIATED_NUMBER=             0x06,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_RESERVED_FOR_EXTENSION=         0x07
+    }SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_UNKNOWN=                           0x00,
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_INTERNET_PROTOCOL_RFC791=          0x01,
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_INTERNET_EMAIL_ADDRESS_RFC822=     0x02
+    }SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_PLAN_UNKNOWN=                                                                                                0x00,
+        SMS_ADDRESS_NUMBER_PLAN_ISDN_TELEPHONY_NUMBERING_PLAN=                                                                          0x01,
+        SMS_ADDRESS_NUMBER_PLAN_DATA_NUMBERING_PLAN=                                                                                    0x02,
+        SMS_ADDRESS_NUMBER_PLAN_TELEX_NUMBERING_PLAN=                                                                                   0x03,
+        SMS_ADDRESS_NUMBER_PLAN_PRIVATE_NUMBERING_PLAN=                                                                                 0x09,
+        SMS_ADDRESS_NUMBER_PLAN_RESERVED_FOR_EXTENSION=                                                                                 0x0F
+    }SMS_ADDRESS_NUMBER_PLAN;
+
+
+    typedef enum
+    {
+        SMS_TELESERVICE_ID_TELESRV_CPT_95=                                      0x00,
+        SMS_TELESERVICE_ID_TELESRV_CMT_95=                                      0x01,
+        SMS_TELESERVICE_ID_TELESRV_VMN_95=                                      0x02,
+        SMS_TELESERVICE_ID_TELESRV_CMT_91_CLI=                                  0x03,
+        SMS_TELESERVICE_ID_TELESRV_CMT91_VOICE_MAIL=                            0x04,
+        SMS_TELESERVICE_ID_TELESRV_CMT_91_SHORT_MSG=                            0x05,
+        SMS_TELESERVICE_ID_TELESRV_MSG_WAITING=                                 0x06,
+        SMS_TELESERVICE_ID_TELESRV_WAP=                                         0x07
+    }SMS_TELESERVICE_ID;
+
+    typedef enum
+    {
+        SMS_BROADCAST_SERVICE_CATEGORY_UNKNOWN_OR_UNSPECIFIED=                0x0000,
+        SMS_BROADCAST_SERVICE_CATEGORY_EMERGENCY_BROADCASTS=                  0x0001,
+        SMS_BROADCAST_SERVICE_CATEGORY_ADMINISTRATIVE=                        0x0002,
+        SMS_BROADCAST_SERVICE_CATEGORY_MAINTENANCE=                           0x0003,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_LOCAL=                    0x0004,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_REGIONAL=                 0x0005,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_NATIONAL=                 0x0006,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_INTERNATIONAL=            0x0007,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_LOCAL=         0x0008,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_REGIONAL=      0x0009,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_NATIONAL=      0x000A,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_INTERNATIONAL= 0x000B,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_LOCAL=                     0x000C,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_REGIONAL=                  0x000D,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_NATIONAL=                  0x000E,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_INTERNATIONAL=             0x000F,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_LOCAL=              0x0010,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_REGIONAL=           0x0011,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_NATIONAL=           0x0012,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_INTERNATIONAL=      0x0013,
+        SMS_BROADCAST_SERVICE_CATEGORY_LOCAL_WEATHER=                         0x0014,
+        SMS_BROADCAST_SERVICE_CATEGORY_AREA_TRAFFIC_REPORTS=                  0x0015,
+        SMS_BROADCAST_SERVICE_CATEGORY_LOCAL_AIRPORT_FLIGHT_SCHEDULES=        0x0016,
+        SMS_BROADCAST_SERVICE_CATEGORY_RESTAURANTS=                           0x0017,
+        SMS_BROADCAST_SERVICE_CATEGORY_LODGINGS=                              0x0018,
+        SMS_BROADCAST_SERVICE_CATEGORY_RETAIL_DIRECTORY=                      0x0019,
+        SMS_BROADCAST_SERVICE_CATEGORY_ADVERTISEMENTS=                        0x001A,
+        SMS_BROADCAST_SERVICE_CATEGORY_STOCK_QUOTES=                          0x001B,
+        SMS_BROADCAST_SERVICE_CATEGORY_EMPLOYMENT_OPPORTUNITIES=              0x001C,
+        SMS_BROADCAST_SERVICE_CATEGORY_MEDICAL_HEALTH_HOSPITALS=              0x001D,
+        SMS_BROADCAST_SERVICE_CATEGORY_TECHNOLOGY_NEWS=                       0x001E,
+        SMS_BROADCAST_SERVICE_CATEGORY_MULTI_CATEGORY=                        0x001F
+    }SMS_BROADCAST_SERVICE_CATEGORY_CATEGORY;
+
+
+    typedef enum
+    {
+        SMS_SUBADDRESS_TYPE_NSAP=                                               0x00,
+        SMS_SUBADDRESS_TYPE_USER_SPECIFIED=                                     0x01
+    }SMS_SUBADDRESS_TYPE;
+
+
+    typedef enum
+    {
+        SMS_CAUSE_CODES_ERROR_CLASS_NONE_ERROR=                                 0x00,
+        SMS_CAUSE_CODES_ERROR_CLASS_TEMPORARY_ERROR=                            0x02,
+        SMS_CAUSE_CODES_ERROR_CLASS_PERMANENT_ERROR=                            0x03,
+        SMS_CAUSE_CODES_ERROR_CLASS_PHONE_INTERNAL_STATUS=                      0x04
+    }SMS_CAUSE_CODES_ERROR_CLASS;
+
+    typedef unsigned char SMS_CAUSE_CODE_CAUSE_CODE;
+
+    typedef enum
+    {
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_ADDRESS_VACANT=                          0,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_ADDRESS_TRANSLATION_FAILURE=             1,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NETWORK_RESOURCE_SHORTAGE=               2,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NETWORK_FAILURE=                         3,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_INVALID_TELESERVICE_ID=                  4,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM=                   5,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM_MORE_FIRST=        6,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM_MORE_LAST=        31,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NO_PAGE_RESPONSE=                       32,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_BUSY=                       33,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NO_ACK=                                 34,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_RESOURCE_SHORTAGE=          35,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED=                 36,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_OUT_OF_SERVICE=             37,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_NO_LONGER_AT_THIS_ADDRESS=  38,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM=                 39,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM_MORE_FIRST=      40,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM_MORE_LAST=       47,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED_MORE_FIRST=      48,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED_MORE_LAST=       63,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RADIO_IF_RESOURCE_SHORTAGE=             64,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RADIO_IF_INCOMPATIBLE=                  65,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM=                 66,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM_MORE_FIRST=      67,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM_MORE_LAST=       95,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNEXPECTED_PARM_SIZE_S=                 96,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_ORIGINATION_DENIED=                 97,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_TERMINATION_DENIED=                 98,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SUPPLMENTARY_SERVICE_NOT_SUPPORTED=     99,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_NOT_SUPPORTED=                     100,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RESERVED_101=                          101,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_MISSING_EXPECTED_PARM=                 102,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_MISSING_MANDATORY_PARM=                103,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNRECOGNIZED_PARM_VALUE=               104,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNEXPECTED_PARM_VALUE=                 105,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_USER_DATA_SIZE_ERROR=                  106,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS=                107,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS_MORE_FIRST=     108,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS_MORE_LAST=      255
+    }SMS_CAUSE_CODE_CAUSE_CODE_NETWORK;
+
+    typedef enum
+    {
+        // 0x00 : layer 2 acknowledgment received
+        // 0x02 : SMS transmission failed because a transmission time is expired
+        //        or phone internal error occurred during the SMS transmission
+
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_L2ACK_RCVD=                   0x00,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL=                         0x01,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_NO_SVC=                  0x02,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_PHONE_BUSY=              0x03,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_OTHER=                   0x04
+    }SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL;
+
+
+
+    typedef enum
+    {
+        SMS_MESSAGE_TYPE_RESERVED=                                              0x00,
+        SMS_MESSAGE_TYPE_SMS_DELIVER_MESSAGE=                                   0x01,
+        SMS_MESSAGE_TYPE_SMS_SUBMIT_MESSAGE=                                    0x02,
+        SMS_MESSAGE_TYPE_SMS_CANCELLATION_MESSAGE=                              0x03,
+        SMS_MESSAGE_TYPE_SMS_DELIVERY_ACKNOWLEDGMENT_MESSAGE=                   0x04,
+        SMS_MESSAGE_TYPE_SMS_USER_ACKNOWLEDGMENT_MESSAGE=                       0x05,
+        SMS_MESSAGE_TYPE_ALL_MESSAGE=                                           0x0F
+    }SMS_MESSAGE_TYPE;
+
+
+
+    typedef enum
+    {
+        SMS_USER_DATA_MSG_ENCODING_OCTET=                                       0x00,
+        SMS_USER_DATA_MSG_ENCODING_IS_91_EXTENDED_PROTOCOL=                     0x01,
+        SMS_USER_DATA_MSG_ENCODING_7BIT_ASCII=                                  0x02,
+        SMS_USER_DATA_MSG_ENCODING_IA5=                                         0x03,
+        SMS_USER_DATA_MSG_ENCODING_UNICODE=                                     0x04,
+        SMS_USER_DATA_MSG_ENCODING_SHIFT_JIS=                                   0x05,
+        SMS_USER_DATA_MSG_ENCODING_KSC5601=                                     0x06,
+        SMS_USER_DATA_MSG_ENCODING_ISO_8859_8=                                  0x07,
+        SMS_USER_DATA_MSG_ENCODING_ISO_8859_1=                                  0x08,
+        SMS_USER_DATA_MSG_ENCODING_KSC5601_KOREAN=                              0x10
+    }SMS_USER_DATA_MSG_ENCODING;
+
+
+    typedef enum
+    {
+        SMS_PRIORITY_INDICATOR_NORMAL=                                          0x00,
+        SMS_PRIORITY_INDICATOR_INTERACTIVE=                                     0x01,
+        SMS_PRIORITY_INDICATOR_URGENT=                                          0x02,
+        SMS_PRIORITY_INDICATOR_EMERGENCY=                                       0x03
+    }SMS_PRIORITY_INDICATOR_PRIORITY;
+
+
+
+    typedef enum
+    {
+        SMS_PRIVACY_INDICATOR_NOT_RESTRICTED=                                   0x00,
+        SMS_PRIVACY_INDICATOR_RESTRICTED=                                       0x01,
+        SMS_PRIVACY_INDICATOR_CONFIDENTIAL=                                     0x02,
+        SMS_PRIVACY_INDICATOR_SECRET=                                           0x03
+    }SMS_PRIVACY_INDICATOR_PRIVACY;
+
+
+
+    typedef enum
+    {
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_MOBILE_DEFAULT_ALERT=         0x00,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_LOW_PRIORITY_ALERT=           0x01,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_MEDIUM_PRIORITY_ALERT=        0x02,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_HIGH_PRIORITY_ALERT=          0x03
+    }SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY;
+
+
+
+    typedef enum
+    {
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_UNKNOWN=                                0x00,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_ENGLISH=                                0x01,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_FRENCH=                                 0x02,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_SPANISH=                                0x03,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_JAPANESE=                               0x04,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN=                                 0x05,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_CHINESE=                                0x06,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_HEBREW=                                 0x07,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN_1=                               0x40,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN_SKT=                             0xFE
+    }SMS_LANGUAGE_INDICATOR_LANGUAGE;
+
+
+
+    typedef enum
+    {
+        SMS_MESSAGE_DISPLAY_MODE_IMMEDIATE_DISPLAY=                             0x00,
+        SMS_MESSAGE_DISPLAY_MODE_MOBILE_DEFAULT_SETTING=                        0x01,
+        SMS_MESSAGE_DISPLAY_MODE_USER_INVOKE=                                   0x03,
+        SMS_MESSAGE_DISPLAY_MODE_RESERVED=                                      0x04
+    }SMS_MESSAGE_DISPLAY_MODE;
+
+
+
+
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function prototype
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LXTSMSTYPEDEF_H_
diff --git a/libvmodem/lxtutil.c b/libvmodem/lxtutil.c
new file mode 100644 (file)
index 0000000..70de5dc
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include <string.h>
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "lxtutil.h"
+#include "linuxtapi.h"
+
+#include <errno.h>
+#include <string.h>
+
+#include "libvgsm_debug.h"
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++define public function
+
+// read raw bytes
+int lxt_util_readRawBytes(int fd, void *data, int size)
+{
+    int rc;
+
+    // check
+    if ( (data == 0) || (fd < 0) )
+    {
+#ifndef _NO_ESPRESSO_DEBUG_
+        LIBVGSM_DEBUG("Source Invalid \n");
+#endif // _NO_ESPRESSO_DEBUG_
+
+        return -1;
+    }
+
+    rc = read(fd, data, size);
+
+    if (rc <= 0)
+    {
+#ifndef _NO_ESPRESSO_DEBUG_
+               fprintf(stderr,"File read error:%s\n",strerror(errno));
+               LIBVGSM_DEBUG("Read Fail and size=%d,  rc=%d\n",size,rc);
+#endif // _NO_ESPRESSO_DEBUG_
+
+        return -1;
+    }
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    assert(rc == size);
+#endif
+
+    return rc;
+}
+
+// write raw bytes
+int lxt_util_writeRawBytes(int fd, const void *data, int size)
+{
+    int rc;
+
+       LIBVGSM_DEBUG("%s\n", __FUNCTION__);
+
+    // check
+    if ( (data == 0) || (fd < 0) )
+    {
+#ifndef _NO_ESPRESSO_DEBUG_
+        LIBVGSM_DEBUG("Source Invalid\n");
+#endif // _NO_ESPRESSO_DEBUG_
+
+        return -1;
+    }
+
+    rc = write(fd, data, size);
+
+    if (rc <= 0)
+    {
+#ifndef _NO_ESPRESSO_DEBUG_
+        LIBVGSM_DEBUG("Write Failed\n");
+#endif // _NO_ESPRESSO_DEBUG_
+
+        return -1;
+    }
+
+#ifndef _NO_ESPRESSO_DEBUG_
+    assert(rc == size);
+#endif
+
+    return rc;
+
+}
+
+void lxt_util_rawdataPrint(void *rawdata, int rawdatasize, const char *title)
+{
+       int i;
+       int len;
+       unsigned char *p;
+
+       LIBVGSM_DEBUG("%s\n", __FUNCTION__);
+
+       if ( (rawdatasize > 0) && (rawdata == NULL) )
+       {
+               return;
+       }
+
+       printf(title);
+
+    // save pointer
+    p = (unsigned char *)rawdata;
+
+    // save length
+    len = rawdatasize;
+
+    for (i = 0; i < len; i++)
+    {
+        if (!(i%16))
+            printf("\n");
+        printf("%02x ", p[i]);
+
+    }
+    printf("\n");
+}
+
+// tx data to phone server
+int lxt_msg_send_to_server(int fd, const void *data, int size)
+{
+    int rc = -1;
+
+       LIBVGSM_DEBUG("%s\n", __FUNCTION__);
+
+    // check
+    if ( (data == 0) || (fd < 0) )
+        return rc;
+
+    // tx to phone server
+    rc = lxt_util_writeRawBytes(fd, data, size);
+
+    return rc;
+}
+
+// tx lxt messge to server
+int lxt_msg_send_message(int fd, unsigned char g, unsigned char a, unsigned int len, const void *data)
+{
+    LXT_MESSAGE packet;
+    int rc;
+
+       LIBVGSM_DEBUG("lxt_msg_send_message : fd=%d, total size = 4+%d \n",fd, len);
+
+    // save group
+    packet.group = g;
+
+    // save action
+    packet.action = a;
+
+    // save length
+    packet.length = len;
+
+    // tx to phone server
+    rc = lxt_msg_send_to_server(fd, &packet, 4);
+
+       if(rc != 4 )
+               printf("[ %s ] [WARNING] write fail : rc = %d \n", __FUNCTION__, rc);
+
+    if (len > 0)
+    {
+        // tx to phone server if exists data
+        rc = lxt_msg_send_to_server(fd, data, len);
+               if(rc != len )
+                       printf("[ %s ] [WARNING] write fail : rc = %d \n", __FUNCTION__, rc);
+    }
+
+    return rc;
+}
+
diff --git a/libvmodem/lxtutil.h b/libvmodem/lxtutil.h
new file mode 100644 (file)
index 0000000..cedc990
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTUTIL_H_
+#define _LXTUTIL_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+#include <stdlib.h>
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++define of function prototype
+int lxt_util_readRawBytes(int fd, void *data, int size);
+int lxt_util_writeRawBytes(int fd, const void *data, int size);
+void lxt_util_rawdataPrint(void *rawdata, int rawdatasize, const char *title);
+int lxt_msg_send_to_server(int fd, const void *data, int size);
+// EMTRACE_I878 [
+int lxt_msg_send_message(int fd, unsigned char g, unsigned char a, unsigned int len, const void *data);
+// EMTRACE_I878, civily 20051022 ]
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LXTUTIL_H_
diff --git a/libvmodem/phoneprotocol.h b/libvmodem/phoneprotocol.h
new file mode 100644 (file)
index 0000000..475b268
--- /dev/null
@@ -0,0 +1,754 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _PHONEPROTOCOL_H_
+#define _PHONEPROTOCOL_H_
+
+
+// define of environment+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+// define of phone state+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    LXT_STATE_OFF                                                           = 0x01,
+    LXT_STATE_ON                                                            = 0x02,
+    LXT_STATE_UIM_NOT_READY                                                 = 0x03,
+    LXT_STATE_UIM_READY                                                     = 0x08,
+    LXT_STATE_NO_SERVICE                                                    = 0x10,
+    LXT_STATE_STANDBY                                                       = 0x20,
+    LXT_STATE_WAITING_OUTGOING_CALL                                         = 0x31,
+    LXT_STATE_WAITING_INCOMING_CALL                                         = 0x32,
+    LXT_STATE_WAITING_DATA_SERVICE                                          = 0x33,
+    LXT_STATE_CONVERSATION                                                  = 0x40,
+    LXT_STATE_DATA_SERVICED                                                 = 0x50,
+    LXT_STATE_DIAL_UP_DATA_SERVICED                                         = 0x55,
+    LXT_STATE_RELEASED                                                      = 0x60,
+    LXT_STATE_RESERVED                                                      = 0x1F
+
+} LXT_PHONE_STATE;
+
+
+// define of message cast method++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_MESSAGE_CAST_METHOD
+{
+    LXT_MESSAGE_CAST_METHOD_BY_MYSELF                                       = 0x40,  // ID of by me(comsumption by server)
+    LXT_MESSAGE_CAST_METHOD_BY_OWNER                                        = 0x41,  // ID of by owner(decide by server)
+    LXT_MESSAGE_CAST_METHOD_BROADCAST                                       = 0x42   // ID of all(broadcast by server)
+};
+
+
+// define of id+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    LXT_ID_CLIENT_RESERVED                                                  = 0x00, // ID of Reserved
+    LXT_ID_CLIENT_INDICATOR                                                 = 0x01, // ID of GUI Server
+    LXT_ID_CLIENT_PHONE                                                     = 0x02, // ID of Phone Client
+    LXT_ID_CLIENT_SMS                                                       = 0x03, // ID of SMS Client
+    LXT_ID_CLIENT_RUIM                                                      = 0x04, // ID of RUIM Manager
+    LXT_ID_CLIENT_SERVICEMODE                                               = 0x05, // ID of Service Mode
+    LXT_ID_CLIENT_DATASERVICE                                               = 0x06, // ID of Data service
+    LXT_ID_CLIENT_DIAL_ON_DEMAND                                            = 0x07, // ID of Dial on demand
+    LXT_ID_CLIENT_UTK                                                       = 0x08, // ID of UTK Client
+    LXT_ID_CLIENT_ADDRESS                                                   = 0x09, // ID of Address Book
+    LXT_ID_CLIENT_PHONE_SETUP                                               = 0x0A, // ID of Phone setup
+    LXT_ID_CLIENT_CARD_MANAGER                                              = 0x0B, // ID of CARD Manager
+    LXT_ID_CLIENT_SMS_DAEMON                                                = 0x0C, // ID of SMS Daemon
+    LXT_ID_CLIENT_GPS                                                       = 0x0D, // ID of GPS 
+    LXT_ID_CLIENT_SECURITY_SETUP                                            = 0x0E, // ID of Security Setup 
+    LXT_ID_CLIENT_SAT                                                                  = 0x0F, // ID of sim application toolkit 
+    LXT_ID_CLIENT_DATA_1                                                       = 0x10, // ID of data 1 
+    LXT_ID_CLIENT_DATA_2                                                       = 0x11, // ID of data 2 
+    LXT_ID_CLIENT_DATA_3                                                       = 0x12, // ID of data 3 
+    LXT_ID_CLIENT_DATA_4                                                       = 0x13, // ID of data 4 
+    LXT_ID_CLIENT_DATA_5                                                       = 0x14, // ID of data 5 
+    LXT_ID_CLIENT_DATA_6                                                       = 0x15, // ID of data 6
+    LXT_ID_CLIENT_EVENT_INJECTOR                                           = 0x16, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER_RX                                         = 0x17, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER_TX                                         = 0x18, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER                                            = 0x19, //ID of event manager
+    LXT_ID_CLIENT_INVALID                                                   = 0x39, // ID of invalid
+    LXT_ID_CLIENT_ANY                                                       = 0xff
+}
+LXT_ID_CLIENT;
+
+
+
+
+
+// define of main group+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_GRP
+{
+    LXT_GRP_INTERNAL                                                        = 0x40,  // Internal
+    LXT_GRP_POWER                                                           = 0x51,  // power
+    LXT_GRP_CONFIGURATION                                                   = 0x52,  // configuration
+    LXT_GRP_CALL                                                            = 0x53,  // call
+    LXT_GRP_DISPLAY                                                         = 0x54,  // display
+    LXT_GRP_SMS                                                             = 0x55,  // sms
+    LXT_GRP_SERVICEMODE                                                     = 0x56,  // service mode
+    LXT_GRP_SOUND                                                           = 0x57,  // sound
+    LXT_GRP_UIM                                                             = 0x58,  // UIM
+    LXT_GRP_DATASERVICE                                                     = 0x59,  // Data service
+    LXT_GRP_UTK                                                             = 0x5A,  // UTK
+    LXT_GRP_SIOMODE                                                         = 0x5B,  // SIO Mode
+    LXT_GRP_RESPONSE                                                        = 0x5F,  // response
+    LXT_GRP_PHONE_BOOK                                                      = 0x61,  // phone book
+    LXT_GRP_CARD_SMS                                                        = 0x62,  // card sms
+    LXT_GRP_GPS                                                             = 0x63,  // GPS 
+    LXT_GRP_EOT                                                             = 0x80   // eot
+    
+};
+
+
+// define of ppp status +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    PPP_STATUS_IDLE                         = 0x01,
+    PPP_STATUS_WORKING                      = 0x02,
+    PPP_STATUS_BUSY                         = 0x04,
+    PPP_STATUS_DORMANT                      = 0x05,
+    PPP_STATUS_SUPER                        = 0x06,
+    PPP_EVENT_IP_REASSIGNED                 = 0x10
+
+}
+PPP_STATUS;
+
+// define of action group (client info)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CLIENT_INFO
+{
+    LXT_PDA_INTERNAL_ID_REQUEST                                             = 0x41,   // save id
+    LXT_PDA_INTERNAL_STATE_REQUEST                                          = 0x42,
+    LXT_PDA_INTERNAL_PHONE_NUMBER_REQUEST                                   = 0x43,
+    LXT_PDA_INTERNAL_AUDIO_TO_SPEAKER_REQUEST                               = 0x44,
+    LXT_PDA_INTERNAL_AUDIO_TO_RECEIVER_REQUEST                              = 0x45,
+    LXT_PDA_INTERNAL_FACTORY_MODE_REQUEST                                   = 0x46,
+    LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST                                 = 0x47,
+    LXT_PDA_INTERNAL_SEND_RAWDATA_REQUEST                                   = 0x50,
+    LXT_PDA_INTERNAL_LOOP_BACK_REQEUST                                      = 0x51,
+    LXT_PHN_INTERNAL_NOTIFY_PHONEBOOK_LOADING_COMPLETION_REQUEST            = 0x52,
+    LXT_PHN_INTERNAL_PHONEBOOK_LOADING_COMPLETION_STATUS_REQUEST            = 0x53,
+    LXT_PHN_INTERNAL_BACKUP_BATTERY_CONTROL_REQUEST                         = 0x55,
+    LXT_PHN_INTERNAL_EARJACK_STATUS_REQUEST                                 = 0x56,
+    LXT_PDA_INTERNAL_LAUNCH_SAT_APP_REQUEST                                                                    = 0x57,
+    LXT_PDA_INTERNAL_SETUP_SAT_APP_REQUEST                                                                     = 0x58,
+    LXT_PDA_INTERNAL_PHONE_BATTERY_REQUEST                                                                     = 0x59,
+};
+
+enum LXT_PHN_PHONE_INFO
+{
+    LXT_PHN_INTERNAL_STATE_RESPONSE                                         = 0x42,   // state change
+    LXT_PHN_INTERNAL_STATE_CHANGE_NOTIFICATION                              = 0x43,   // state change
+    LXT_PHN_INTERNAL_PHONE_NUMBER_RESPONSE                                  = 0x44,
+    LXT_PHN_INTERNAL_PDA_SLEEP_NOTIFICATION                                 = 0x45,
+    LXT_PHN_INTERNAL_SERVER_DIE_EMERGENCY                                   = 0x49,
+    LXT_PHN_INTERNAL_SERVER_SIM_COVER_OPENED                                = 0x50,
+    LXT_PHN_INTERNAL_SERVER_SIM_COVER_CLOSED                                = 0x51,
+    LXT_PHN_INTERNAL_SERVER_PHONE_REBUILD_START                             = 0x52,
+    LXT_PHN_INTERNAL_SERVER_PHONE_REBUILD_END                               = 0x53,                
+    LXT_PHN_INTERNAL_SERVER_PHONE_FATAL_ERROR                               = 0x54,
+    LXT_PHN_INTERNAL_SERVER_PHONE_NV_BACKUP_NOTIFICATION                    = 0x55,
+    LXT_PHN_INTERNAL_PHONEBOOK_LOADING_COMPLETION_NOTIFICATION              = 0x56,
+    LXT_PHN_INTERNAL_EARJACK_STATUS_RESPONSE                                = 0x57,
+    LXT_PDA_INTERNAL_LAUNCH_SAT_APP_RESPONSE                                                           = 0x58,
+    LXT_PDA_INTERNAL_SETUP_SAT_APP_RESPONSE                                                                = 0x59,
+};
+
+// define of action group (power)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_POWER
+{
+    LXT_PDA_POWER_ON_REQUEST                                                = 0x41,  // power on
+    LXT_PDA_POWER_RESET_REQUEST                                             = 0x42,  // power reset
+    LXT_PDA_POWER_OFF_REQUEST                                               = 0x43   // power off
+
+};
+
+enum LXT_PHN_POWER
+{
+    LXT_PHN_POWER_BATTERY_STATUS_NOTIFICATION                               = 0x41,
+    LXT_PHN_POWER_PHONE_BOOT_COMPLETED_NOTIFICATION                         = 0x42
+};
+
+
+// define of action group (configuration)+++++++++++++++++++++++++++++++++++++
+/*
+enum LXT_PDA_CONFIGURATION
+{
+    LXT_PDA_CONFIGURATION_SET_DEFAULT_CONFIGURATION_REQUEST                 = 0x41,
+    LXT_PDA_CONFIGURATION_CURRENT_TIME_REQUEST                              = 0x42,  // current time request
+    LXT_PDA_CONFIGURATION_PHONE_NUMBER_REQUEST                              = 0x43,
+    LXT_PDA_CONFIGURATION_PHONE_VERSION_REQUEST                             = 0x44,
+    LXT_PDA_CONFIGURATION_GET_PHONE_LOCK_REQUEST                            = 0x45,
+    LXT_PDA_CONFIGURATION_SET_PHONE_LOCK_REQUEST                            = 0x46,
+    LXT_PDA_CONFIGURATION_GET_RADIO_CONFIGURATION_REQUEST                   = 0x47,
+    LXT_PDA_CONFIGURATION_SET_RADIO_CONFIGURATION_REQUEST                   = 0x48,
+    LXT_PDA_CONFIGURATION_GET_SYSTEM_PREFERENCE_REQUEST                     = 0x49,
+    LXT_PDA_CONFIGURATION_SET_SYSTEM_PREFERENCE_REQUEST                     = 0x4A,
+    LXT_PDA_CONFIGURATION_GET_SYSTEM_PARAMETER_REQUEST                      = 0x4B,
+    LXT_PDA_CONFIGURATION_SET_SYSTEM_PARAMETER_REQUEST                      = 0x4C,
+    LXT_PDA_CONFIGURATION_GET_NAM_INFORMATION_REQUEST                       = 0x4D,
+    LXT_PDA_CONFIGURATION_GET_NAM_DATA_REQUEST                              = 0x4E,
+    LXT_PDA_CONFIGURATION_GET_PHONE_STATE_CHANGING_REQUEST                  = 0x4F,
+    LXT_PDA_CONFIGURATION_SET_PHONE_STATE_CHANGING_REQUEST                  = 0x50,
+    LXT_PDA_CONFIGURATION_BATTERY_MEDIATENESS_CONFIRM                       = 0x51,
+    LXT_PDA_CONFIGURATION_GET_PDA_BATTERY_REQUEST                           = 0x52
+};
+
+enum LXT_PHN_CONFIGURATION
+{
+    LXT_PHN_CONFIGURATION_SET_DEFAULT_CONFIGURATION_RESPONSE                = 0x41,
+    LXT_PHN_CONFIGURATION_CURRENT_TIME_RESPONSE                             = 0x42,
+    LXT_PHN_CONFIGURATION_CURRENT_TIME_NOTIFICATION                         = 0x43,
+    LXT_PHN_CONFIGURATION_PHONE_NUMBER_RESPONSE                             = 0x44,
+    LXT_PHN_CONFIGURATION_PHONE_VERSION_RESPONSE                            = 0x45,
+    LXT_PHN_CONFIGURATION_PHONE_STATE_CHANGE_NOTIFICATION                   = 0x46,
+    LXT_PHN_CONFIGURATION_PHONE_SERVICE_READY_NOTIFICATION                  = 0x47,
+    LXT_PHN_CONFIGURATION_GET_PHONE_LOCK_RESPONSE                           = 0x48,
+    LXT_PHN_CONFIGURATION_PHONE_LOCK_NOTIFICATION                           = 0x49,
+    LXT_PHN_CONFIGURATION_GET_RADIO_CONFIGURATION_RESPONSE                  = 0x4A,
+    LXT_PHN_CONFIGURATION_GET_SYSTEM_PREFERENCE_RESPONSE                    = 0x4B,
+    LXT_PHN_CONFIGURATION_GET_SYSTEM_PARAMETER_RESPONSE                     = 0x4C,
+    LXT_PHN_CONFIGURATION_SYSTEM_PARAMETER_CHANGE_NOTIFICATION              = 0x4D,
+    LXT_PHN_CONFIGURATION_GET_NAM_INFORMATION_RESPONSE                      = 0x4E,
+    LXT_PHN_CONFIGURATION_GET_NAM_DATA_RESPONSE                             = 0x4F,
+    LXT_PHN_CONFIGURATION_GET_PHONE_STATE_CHANGING_RESPONSE                 = 0x50,
+    LXT_PHN_CONFIGURATION_SET_PHONE_STATE_CHANGING_RESPONSE                 = 0x51,
+    LXT_PHN_CONFIGURATION_HFK2_PDA_PASSWORD_INDICATION                      = 0x52,
+    LXT_PHN_CONFIGURATION_BATTERY_MEDIATENESS_INDICATION                    = 0x53,
+    LXT_PHN_CONFIGURATION_GET_PDA_BATTERY_RESPONSE                          = 0x54
+};
+*/
+
+enum LXT_PDA_CONFIGURATION2
+{
+    LXT_PDA_CONFIGURATION2_GET_PHONE_LOCK_REQUEST                           = 0x40,
+    LXT_PDA_CONFIGURATION2_SET_PHONE_LOCK_REQUEST                           = 0x41,
+    LXT_PDA_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_REQUEST                = 0x42,
+    LXT_PDA_CONFIGURATION2_GET_SIO_MODE_REQUEST                             = 0x43,
+    LXT_PDA_CONFIGURATION2_SET_SIO_MODE_REQUEST                             = 0x44,
+    LXT_PDA_CONFIGURATION2_CURRENT_TIME_REQUEST                             = 0x45,
+    LXT_PDA_CONFIGURATION2_PHONE_NUMBER_REQUEST                             = 0x46,
+    LXT_PDA_CONFIGURATION2_PHONE_VERSION_REQUEST                            = 0x47,
+    LXT_PDA_CONFIGURATION2_GET_SYSTEM_PARAMETER_REQUEST                     = 0x48,
+    LXT_PDA_CONFIGURATION2_SET_SYSTEM_PARAMETER_REQUEST                     = 0x49,
+    LXT_PDA_CONFIGURATION2_GET_MODE_PREFERENCE_REQUEST                      = 0x4A,
+    LXT_PDA_CONFIGURATION2_SET_MODE_PREFERENCE_REQUEST                      = 0x4B,
+    LXT_PDA_CONFIGURATION2_GET_SYSTEM_PREFERENCE_REQUEST                    = 0x4C,
+    LXT_PDA_CONFIGURATION2_SET_SYSTEM_PREFERENCE_REQUEST                    = 0x4D,
+    LXT_PDA_CONFIGURATION2_GET_NAM_INFORMATION_REQUEST                      = 0x4E,
+    LXT_PDA_CONFIGURATION2_GET_NAM_DATA_REQUEST                             = 0x4F,
+    LXT_PDA_CONFIGURATION2_GET_PHONE_STATE_CHANGING_REQUEST                 = 0x50,
+    LXT_PDA_CONFIGURATION2_SET_PHONE_STATE_CHANGING_REQUEST                 = 0x51,
+    LXT_PDA_CONFIGURATION2_GET_GPS_MODE_REQUEST                             = 0x52,
+    LXT_PDA_CONFIGURATION2_SET_GPS_MODE_REQUEST                             = 0x53,
+    LXT_PDA_CONFIGURATION2_GET_RADIO_CONFIGURATION_REQUEST                  = 0x54,
+    LXT_PDA_CONFIGURATION2_SET_RADIO_CONFIGURATION_REQUEST                  = 0x55,
+    LXT_PDA_CONFIGURATION2_GET_VOCODER_OPTION_REQUEST                       = 0x56,
+    LXT_PDA_CONFIGURATION2_SET_VOCODER_OPTION_REQUEST                       = 0x57,
+    LXT_PDA_CONFIGURATION2_BATTERY_TYPE_CONFIRM                             = 0x58,
+    LXT_PDA_CONFIGURATION2_BATTERY_CALIBRATION_CONFIRM                      = 0x59,
+    LXT_PDA_CONFIGURATION2_GET_SLOT_MODE_REQUEST                            = 0x5A,
+    LXT_PDA_CONFIGURATION2_SET_SLOT_MODE_REQUEST                            = 0x5B,
+    LXT_PDA_CONFIGURATION2_GET_ESN_REQUEST                                  = 0x5C,
+    LXT_PDA_CONFIGURATION2_PDA_CURR_BATT_ADC_CONFIRM                        = 0x5D,
+    LXT_PDA_CONFIGURATION2_GET_PDA_LOW_BATT_ADC_REQUEST                     = 0x5E,
+    LXT_PDA_CONFIGURATION2_SET_PDA_LOW_BATT_ADC_REQUEST                     = 0x5F,
+    LXT_PDA_CONFIGURATION2_MAC_ADDRESS_REQUEST                              = 0x60,
+    LXT_PDA_CONFIGURATION2_GET_IMEI_REQUEST                                 = 0x61,
+    LXT_PDA_CONFIGURATION2_PDA_VERIFY_RESET_DONE_CONFIRM                    = 0x62,
+    LXT_PHN_CONFIGURATION2_PDA_PASSWORD_CONFIRM                             = 0x63,
+    LXT_PHN_CONFIGURATION2_DEVICE_AUTO_TEST_CONFIRM                             = 0x64,
+    LXT_PHN_CONFIGURATION2_SERVICE_LED_ONOFF_CONFIRM                        = 0x65,
+    LXT_PHN_CONFIGURATION2_SET_PDA_VERSION_REQUEST                          = 0x66
+    /*
+    LXT_PDA_CONFIGURATION2_BATTRY_MEDIATENESS_CONFIRM                      = 0x51,
+    LXT_PDA_CONFIGURATION2_GET_PDA_BATTERY_REQUEST                          = 0x52
+    */
+};
+
+enum LXT_PHN_CONFIGURATION2
+{
+    LXT_PHN_CONFIGURATION2_PHONE_SERVICE_READY_NOTIFICATION                 = 0x40,
+    LXT_PHN_CONFIGURATION2_PHONE_LOCK_RESPONSE                              = 0x41,
+    LXT_PHN_CONFIGURATION2_PHONE_LOCK_NOTIFICATION                          = 0x42,
+    LXT_PHN_CONFIGURATION2_CURRENT_TIME_RESPONSE                            = 0x43,
+    LXT_PHN_CONFIGURATION2_CURRENT_TIME_NOTIFICATION                        = 0x44,
+    LXT_PHN_CONFIGURATION2_PHONE_NUMBER_RESPONSE                            = 0x45,
+    LXT_PHN_CONFIGURATION2_PHONE_VERSION_RESPONSE                           = 0x46,
+    LXT_PHN_CONFIGURATION2_GET_NAM_INFORMATION_RESPONSE                     = 0x47,
+    LXT_PHN_CONFIGURATION2_GET_NAM_DATA_RESPONSE                            = 0x48,
+    LXT_PHN_CONFIGURATION2_PHONE_STATE_CHANGED_RESPONSE                     = 0x49,
+    LXT_PHN_CONFIGURATION2_PHONE_STATE_CHANGED_NOTIFICATION                 = 0x4A,
+    LXT_PHN_CONFIGURATION2_MODE_PREFERENCE_RESPONSE                         = 0x4B,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PREFERENCE_RESPONSE                       = 0x4C,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PARAMETER_RESPONSE                        = 0x4D,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PARAMETER_CHANGE_NOTIFICATION             = 0x4E,
+    LXT_PHN_CONFIGURATION2_SIO_MODE_RESPONSE                                = 0x4F,
+    LXT_PHN_CONFIGURATION2_GET_GPS_MODE_RESPONSE                            = 0x50,
+    LXT_PHN_CONFIGURATION2_GET_RADIO_CONFIGURATION_RESPONSE                 = 0x51,
+    LXT_PHN_CONFIGURATION2_GET_VOCODER_OPTION_RESPONSE                      = 0x52,
+    LXT_PHN_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_RESPONSE               = 0x53,
+    LXT_PHN_CONFIGURATION2_BATTERY_TYPE_INDICATION                          = 0x54,
+    LXT_PHN_CONFIGURATION2_BATTERY_CALIBRATION_INDICATION                   = 0x55,
+    LXT_PHN_CONFIGURATION2_BATTERY_CALIBRATION_NOTIFICATION                 = 0x56,
+    LXT_PHN_CONFIGURATION2_BATTERY_WRITE_CALIBRATION_NOTIFICATION           = 0x57,
+    LXT_PHN_CONFIGURATION2_GET_SLOT_MODE_RESPONSE                           = 0x58,
+    LXT_PDA_CONFIGURATION2_GET_ESN_RESPONSE                                 = 0x59,
+    LXT_PHN_CONFIGURATION2_PDA_CURR_BATT_ADC_INDICATION                     = 0x5A,
+    LXT_PHN_CONFIGURATION2_GET_PDA_LOW_BATT_ADC_RESPONSE                    = 0x5B,
+    LXT_PHN_CONFIGURATION2_PDA_DEVICE_AUT_TEST_INDICATION                   = 0x5C,
+    LXT_PHN_CONFIGURATION2_MAC_ADDRESS_RESPONSE                             = 0x5D,
+    LXT_PHN_CONFIGURATION2_GET_IMEI_RESPONSE                                = 0x5E,
+    LXT_PHN_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_INDICATION             = 0x5F,
+    LXT_PHN_CONFIGURATION2_PDA_PASSWORD_INDICATION                          = 0x60,
+    LXT_PHN_CONFIGURATION2_BT_EQUIPMENT_TEST_ADDRESS_NOTIFICATION           = 0x61
+    /*
+    LXT_PHN_CONFIGURATION2_BATTERY_MEDIATENESS_INDICATION                   = 0x53,
+    LXT_PHN_CONFIGURATION2_GET_PDA_BATTERY_RESPONSE                         = 0x54
+    */
+};
+
+// define of action group (call)++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CALL
+{
+    LXT_PDA_CALL_CALL_ORIGINATION_REQUEST                                   = 0x41, // call originnation
+    LXT_PDA_CALL_END_CALL_REQUEST                                           = 0x42, // end call
+    LXT_PDA_CALL_ANSWER_REQUEST                                             = 0x43, // call answer
+    LXT_PDA_CALL_SEND_BURST_DTMF_REQUEST                                    = 0x44,
+    LXT_PDA_CALL_SEND_CONTINUOUS_DTMF_REQUEST                               = 0x45,
+    LXT_PDA_CALL_STOP_CONTINUOUS_DTMF_REQUEST                               = 0x46,
+    LXT_PDA_CALL_FLASH_INFORMATION_REQUEST                                  = 0x47,
+    LXT_PDA_CALL_GET_CALL_TIME_REQUEST                                      = 0x4E,
+    LXT_PDA_CALL_SET_E911_NUMBER_REGISTRATION_REQUEST                       = 0x4F,
+    LXT_PDA_CALL_RETRY_REQUEST                                              = 0x50,
+    LXT_PDA_CALL_CALL_ORIGINATION2_REQUEST                                  = 0x51,
+    LXT_PDA_CALL_GET_VOICE_PRIVACY_OPTION_REQUEST                           = 0x52,
+    LXT_PDA_CALL_SET_VOICE_PRIVACY_OPTION_REQUEST                           = 0x53,
+    LXT_PDA_CALL_CURRENT_VOICE_PRIVACY_STATUS_REQUEST                       = 0x54,    
+    LXT_PDA_CALL_SOS_CALL_REQUEST                                           = 0x55,
+    LXT_PDA_CALL_REJECT_CALL_REQUEST                                        = 0x56    
+};
+
+enum LXT_PHN_CALL
+{
+    LXT_PHN_CALL_INCOMING_CALL_NOTIFICATION                                 = 0x41,
+    LXT_PHN_CALL_CALL_STATUS_NOTIFICATION                                   = 0x42,
+    LXT_PHN_CALL_SEND_BURST_DTMF_TONE_NOTIFICATION                          = 0x43,
+    LXT_PHN_CALL_START_END_ALERT_INFORMATION_NOTIFICATION                   = 0x44,
+    LXT_PHN_CALL_ALERT_INFORMATION_NOTIFICATION                             = 0x45,
+    LXT_PHN_CALL_SIGNALING_INFORMATION_NOTIFICATION                         = 0x46,
+    LXT_PHN_CALL_OTA_STATE_CHANGE_NOTIFICATION                              = 0x47,
+    LXT_PHN_CALL_IOTA_PROCESSING_RESPONSE                                   = 0x48,
+    LXT_PHN_CALL_VOICE_PRIVACY_OPTION_RESPONSE                              = 0x49,
+    LXT_PHN_CALL_CURRENT_VOICE_PRIVACY_AVAIABLE_STATUS_RESPONSE             = 0x4A,
+    LXT_PHN_CALL_VOICE_PRIVACY_SERVICED_NOTIFICATION                        = 0x4B,
+    LXT_PHN_CALL_CURRENT_CALL_INFORMATION_RESPONSE                          = 0x4C,
+    LXT_PHN_CALL_DIAGNOSTIC_CALL_ORIGINATION_NOTIFICATION                   = 0x4D,
+    LXT_PHN_CALL_GET_CALL_TIME_RESPONSE                                     = 0x4E
+
+
+
+
+
+};
+
+// define of action group (display)+++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_DISPLAY
+{
+    LXT_PDA_DISPLAY_RING_TYPE_ICON_REQUEST                                  = 0x41,
+    LXT_PDA_DISPLAY_ICON_REQUEST                                            = 0x47,
+    LXT_PDA_DISPLAY_MISSED_ICON_CHANGED                                     = 0x48,
+};
+
+enum LXT_PHN_DISPLAY
+{
+
+    LXT_PHN_DISPLAY_RING_TYPE_ICON_NOTIFICATION                             = 0x41,
+    LXT_PHN_DISPLAY_PHONE_ICON_CHANGED_NOTIFICATION                         = 0x42,
+    LXT_PHN_DISPLAY_RSSI_ICON_CHANGED_NOTIFICATION                          = 0x43,
+    LXT_PHN_DISPLAY_ROAM_ICON_CHANGED_NOTIFICATION                          = 0x44,
+    LXT_PHN_DISPLAY_BATTERY_ICON_CHANGED_NOTIFICATION                       = 0x45,
+    LXT_PHN_DISPLAY_MESSAGE_ICON_CHANGED_NOTIFICATION                       = 0x46,
+    LXT_PHN_DISPLAY_ICON_RESPONSE                                           = 0x47,
+    LXT_PHN_DISPLAY_MISSED_ICON_NOTIFICATION                                = 0x48,
+
+};
+
+
+// define of action group (sms)+++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SMS
+{
+    LXT_PDA_SMS_SMS_SEND_MESSAGE_REQUEST                                    = 0x41,
+    LXT_PDA_SMS_SMS_SET_LOCAL_COUNT_INDICATION                              = 0x42,
+    LXT_PDA_SMS_SMS_GET_LOCAL_STORAGE_SIZE_REQUEST                          = 0x43,
+    LXT_PDA_SMS_SMS_SET_LOCAL_STORAGE_SIZE_INDICATION                       = 0x44
+};
+
+enum LXT_PHN_SMS
+{
+    // CDMA
+    LXT_PHN_SMS_PHONE_SMS_INCOMING_NOTIFICATION                             = 0x41,
+    LXT_PHN_SMS_PHONE_UIM_SMS_INCOMING_NOTIFICATION                         = 0x42,
+    LXT_PHN_SMS_PHONE_WAP_SMS_INCOMING_NOTIFICATION                         = 0x43,
+    LXT_PHN_SMS_PHONE_VOICE_SMS_INCOMING_NOTIFICATION                       = 0x44,
+    LXT_PHN_SMS_PHONE_SMS_INCOMING_ALERT_NOTIFICATION                       = 0x45,
+    LXT_PHN_SMS_PHONE_SMS_ACKNOWLEDGMENT_MESSAGE_NOTIFICATON                = 0x46,
+    LXT_PHN_SMS_PHONE_SMS_MESSAGE_COUNT_NOTIFICATON                         = 0x47,
+    LXT_PHN_SMS_PHONE_SMS_LOCAL_STORAGE_SIZE_RESPONSE                       = 0x48,
+    LXT_PHN_SMS_PHONE_SMS_DELIVERY_ACKNOWLEDGMENT_NOTIFICATION              = 0x49,
+    LXT_PHN_SMS_PHONE_SMS_REJECT_NOTIFICATION                               = 0x4A,
+    // GSM
+    LXT_PHN_SMS_PHONE_GSM_SMS_DELIVER_NOTIFICATION                          = 0x51,
+    LXT_PHN_SMS_PHONE_GSM_SMS_STATUS_REPORT_NOTIFICATION                    = 0x52,
+    LXT_PHN_SMS_PHONE_GSM_SMS_SUBMIT_REPORT_NOTIFICATION                    = 0x53,
+    LXT_PHN_SMS_PHONE_GSM_SMS_SMMA_NOTIFICATION                             = 0x54,
+    LXT_PHN_SMS_PHONE_EOT
+};
+
+
+// define of action group (sms)+++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CARD_SMS
+{
+    LXT_PDA_CARD_SMS_EOT
+};
+
+enum LXT_PHN_CARD_SMS
+{
+    // CDMA
+    LXT_PHN_CARD_SMS_INFORMATION_RESPONSE                                   = 0x41,
+    LXT_PHN_CARD_SMS_READ_RESPONSE                                          = 0x42,
+    LXT_PHN_CARD_SMS_WRITE_RESPONSE                                         = 0x43,
+    LXT_PHN_CARD_SMS_DELETE_RESPONSE                                        = 0x44,
+    LXT_PHN_CARD_SMS_SET_TAG_RESPONSE                                       = 0x45,
+    LXT_PHN_CARD_SMS_CLEAR_RESPONSE                                         = 0x46,
+    LXT_PHN_CARD_SMS_MESSAGE_READY_NOTIFICATION                             = 0x47,    
+    LXT_PHN_CARD_SMS_COMPLETE_NOTIFICATION                                  = 0x48,
+
+    // GSM
+    LXT_PHN_CARD_GSM_SMS_INFORMATION_RESPONSE                               = 0x61,
+    LXT_PHN_CARD_GSM_SMS_READ_RESPONSE                                      = 0x62,
+    LXT_PHN_CARD_GSM_SMS_WRITE_RESPONSE                                     = 0x63,
+    LXT_PHN_CARD_GSM_SMS_DELETE_RESPONSE                                    = 0x64,
+    LXT_PHN_CARD_GSM_SMS_SET_TAG_RESPONSE                                   = 0x65,
+    LXT_PHN_CARD_GSM_SMS_CLEAR_RESPONSE                                     = 0x66,
+    LXT_PHN_CARD_GSM_SMS_COMPLETE_NOTIFICATION                              = 0x67,
+    LXT_PHN_CARD_GSM_SMS_PARAMETER_READ_RESPONSE                            = 0x68,
+    LXT_PHN_CARD_GSM_SMS_PARAMETER_WRITE_RESPONSE                           = 0x69,
+    LXT_PHN_CARD_GSM_SMS_MESSAGE_REFERENCE_WRITE_RESPONSE                   = 0x6A,
+};
+
+    
+// define of action group (service mode)++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PDA_SERVICEMODE
+{
+    LXT_PDA_SERVICEMODE_ENTER_SERVICE_MODE_REQUEST                          = 0x41,
+    LXT_PDA_SERVICEMODE_END_SERVICE_MODE_REQUEST                            = 0x42,
+    LXT_PDA_SERVICEMODE_PROCESS_KEY_CODE_REQUEST                            = 0x43,
+    LXT_PDA_SERVICEMODE_FACTORY_MODE_ENABLE_REQUEST                         = 0x44
+};
+
+
+enum LXT_PHN_SERVICEMODE
+{
+    LXT_PHN_SERVICEMODE_END_SERVICE_MODE_NOTIFICATION                       = 0x41,
+    LXT_PHN_SERVICEMODE_DISPLAY_MONITOR_NOTIFICATION                        = 0x42,
+    LXT_PHN_SERVICEMODE_PHONE_LCD_MODE_NOTIFICATION                         = 0x43,
+    LXT_PHN_SERVICEMODE_DISPLAY_PHONE_LCD_NOTIFICATION                      = 0x44,
+    LXT_PHN_SERVICEMODE_DEDICATE_LCD_MODE_NOTIFICATION                      = 0x45,
+
+
+    LXT_PHN_SERVICEMODE_DISPLAY_DEDICATE_LCD_NOTIFICATION                   = 0x46,
+    LXT_PHN_SERVICEMODE_DOWNLOAD_TYPE_NOTIFICATION                          = 0x47,
+    LXT_PDA_SERVICEMODE_FACTORY_MODE_ENABLE_RESPONSE                        = 0x48
+};
+
+// define of action group (sound)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SOUND
+{
+    LXT_PDA_SOUND_START_KEY_TONE_REQUEST                                    = 0x41,
+    LXT_PDA_SOUND_STOP_KEY_TONE_REQUEST                                     = 0x42,
+    LXT_PDA_SOUND_START_NOTIFICATION_TONE_REQUEST                           = 0x43,
+    LXT_PDA_SOUND_START_LAMP_REQUEST                                        = 0x44,
+    LXT_PDA_SOUND_START_VIBRATE_REQUEST                                     = 0x45,
+    LXT_PDA_SOUND_STOP_SOUND_REQUEST                                        = 0x47,
+    LXT_PDA_SOUND_SET_VOLUME_CONTROL_REQUEST                                = 0x48,
+    LXT_PDA_SOUND_SET_MUTE_REQUEST                                          = 0x49,
+    LXT_PDA_SOUND_GET_MUTING_STATUS_REQUEST                                 = 0x4A,
+    LXT_PDA_SOUND_SET_SPEAKER_PHONE_REQUEST                                 = 0x4B,
+    LXT_PDA_SOUND_SET_AUDIO_PATH_CONTROL_REQUEST                            = 0x4C
+};
+
+enum LXT_PHN_SOUND
+{
+    LXT_PHN_SOUND_MUTING_STATUS_RESPONSE                                    = 0x41,
+    LXT_PHN_SOUND_SOUND_PDA_PATH_ON_OFF_NOTIFICATION                        = 0x42
+};
+
+
+
+
+// define of action group (UIM) ++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_UIM
+{
+
+    // i819
+    LXT_PDA_RUIMCONF_AUTHENTICATION_REQUEST                                 = 0x11,
+    LXT_PDA_RUIMCONF_SELECT_NETWORK_REQUEST                                 = 0x12,
+    LXT_PDA_RUIMCONF_ICCID_REQUEST                                          = 0x13,
+    LXT_PDA_RUIMCONF_SELECTION_MODE_REQUEST                                 = 0x14,
+    LXT_PDA_RUIMCONF_CHANGE_AUTHENTICATION_REQUEST                          = 0x15,
+    LXT_PDA_RUIMCONF_CURRENT_PIN_CHECK_STATE_REQUEST                        = 0x16,
+    LXT_PDA_RUIMCONF_CHANGE_PIN_CHECK_STATE_REQUEST                         = 0x17,
+    LXT_PDA_RUIMCONF_RUNTIME_CHANGE_NETWORK_REQUEST                         = 0x18,
+    LXT_PDA_RUIMCONF_DIR_NAME_REQUEST                                       = 0x19,
+    LXT_PDA_RUIMCONF_DIR_NAME_WRITE_REQUEST                                 = 0x1A,
+    LXT_PDA_RUIMCONF_CHANGE_FDN_STATE_REQUEST                               = 0x1B,
+    LXT_PDA_RUIMCONF_CURRENT_FDN_STATE_REQUEST                              = 0x1C,
+    LXT_PDA_RUIMCONF_CHECK_SERVICE_AVAILABLE_REQUEST                        = 0x1D,
+    LXT_PDA_RUIMCONF_IMSI_REQUEST                                           = 0x1E,
+    
+    // i519
+    LXT_PDA_UIM_GET_UIM_LOCK_REQUEST                                        = 0x31,
+    LXT_PDA_UIM_SET_UIM_LOCK_REQUEST                                        = 0x32,
+    LXT_PDA_UIM_UIM_LOCK_VERIFY_INDICATION                                  = 0x33,
+    LXT_PDA_UIM_UIM_LOCK_PASSWORD_WRITE_REQUEST                             = 0x34,
+    LXT_PDA_UIM_CARD_STATUS_REQUEST                                         = 0x41,
+    LXT_PDA_UIM_GET_PIN_CODE_STATUS_REQUEST                                 = 0x42,
+    LXT_PDA_UIM_SET_PIN_CHECK_REQUEST                                       = 0x43,
+    LXT_PDA_UIM_RUIM_PIN_VERIFY_REQUEST                                     = 0x44,
+    LXT_PDA_UIM_CHANGE_PIN_REQUEST                                          = 0x45,
+    LXT_PDA_UIM_GET_ICCID_REQUEST                                           = 0x46,
+    LXT_PDA_UIM_CHV_UNLOCK_REQUEST                                          = 0x47,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_INFORMATION_REQUEST                    = 0x51,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_READ_REQUEST                           = 0x52,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_WRITE_REQUEST                          = 0x53,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_ERASE_REQUEST                          = 0x54,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_CLEAR_REQUEST                          = 0x55,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_ALL_LIST_REQUEST                       = 0x56,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_MIRRORING_REQUEST                      = 0x57,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_SET_TAG_REQUEST                        = 0x58,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_INFORMATION_REQUEST                     = 0x61,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_READ_REQUEST                            = 0x62,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_WRITE_REQUEST                           = 0x63,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_ERASE_REQUEST                           = 0x64,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_CLEAR_REQUEST                           = 0x65,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_ALL_LIST_REQUEST                        = 0x66,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_MIRRORING_REQUEST                       = 0x67,
+    LXT_PDA_UIM_DIR_NAME_READ_REQUEST                                       = 0x68,
+    LXT_PDA_UIM_DIR_NAME_WRITE_REQUEST                                      = 0x69,
+    LXT_PDA_UIM_PDA_CARD_SMS_CLEAR_REQUEST                                  = 0x70,
+    LXT_PDA_UIM_GET_PERMISSION_STATUS_REQUEST                               = 0x80
+};
+
+enum LXT_PHN_UIM
+{
+
+    // i819
+    LXT_PHN_RUIMCONF_STATUS_NOTIFICATION                                    = 0x11,
+    LXT_PHN_RUIMCONF_BLOCK_STATUS_NOTIFICATION                              = 0x12,
+    LXT_PHN_RUIMCONF_AUTHENTICATION_RESPONSE                                = 0x13,
+    LXT_PHN_RUIMCONF_CARD_STATUS_NOTIFICATION                               = 0x14,
+    LXT_PHN_RUIMCONF_SELECT_NETWORK_RESPONSE                                = 0x15,
+    LXT_PHN_RUIMCONF_SELECTION_MODE_NOTIFICATION                            = 0x16,
+    LXT_PHN_RUIMCONF_ICCID_RESPONSE                                         = 0x17,
+    LXT_PHN_RUIMCONF_NETWORK_START_NOTIFICATION                             = 0x18,
+    LXT_PHN_RUIMCONF_SELECTION_MODE_RESPONSE                                = 0x19,
+    LXT_PHN_RUIMCONF_CHANGE_AUTHENTICATION_RESPONSE                         = 0x1A,
+    LXT_PHN_RUIMCONF_CURRENT_PIN_CHECK_STATE_RESPONSE                       = 0x1B,
+    LXT_PHN_RUIMCONF_CHANGE_PIN_CHECK_STATE_RESPONSE                        = 0x1C,
+    LXT_PHN_RUIMCONF_RUNTIME_CHANGE_NETWORK_RESPONSE                        = 0x1D,
+    LXT_PHN_RUIMCONF_DIR_NAME_RESPONSE                                      = 0x1E,
+    LXT_PHN_RUIMCONF_DIR_NAME_WRITE_RESPONSE                                = 0x1F,
+    LXT_PHN_RUIMCONF_CHANGE_FDN_STATE_RESPONSE                              = 0x20,
+    LXT_PHN_RUIMCONF_CURRENT_FDN_STATE_RESPONSE                             = 0x21,
+    LXT_PHN_RUIMCONF_CHECK_SERVICE_AVAILABE_RESPONSE                        = 0x22,
+    LXT_PDA_RUIMCONF_IMSI_RESPONSE                                          = 0x23,
+
+    // i519
+    LXT_PHN_UIM_GET_UIM_LOCK_RESPONSE                                       = 0x31,
+    LXT_PDA_UIM_UIM_LOCK_PASSWORD_WRITE_RESPONSE                            = 0x32,
+    LXT_PHN_UIM_CARD_STATUS_RESPONSE                                        = 0x41,
+    LXT_PHN_UIM_GET_PIN_CODE_STATUS_RESPONSE                                = 0x42,
+    LXT_PHN_UIM_SET_PIN_CHECK_RESPONSE                                      = 0x43,
+    LXT_PHN_UIM_PIN_VERIFY_RESPONSE                                         = 0x44,
+    LXT_PHN_UIM_CHANGE_PIN_RESPONSE                                         = 0x45,
+    LXT_PHN_UIM_GET_ICCID_RESPONSE                                          = 0x46,
+    LXT_PHN_UIM_UIM_LOCK_RESPONSE                                           = 0x47,
+    LXT_PHN_UIM_CHV_UNBLOCK_RESPONSE                                        = 0x48,
+    LXT_PDA_UIM_DIR_NAME_WRITE_RESPONSE                                     = 0x49,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_INFORMATION_RESPONSE                 = 0x51,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_READ_RESPONSE                        = 0x52,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_WRITE_RESPONSE                       = 0x53,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_ERASE_RESPONSE                       = 0x54,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_CLEAR_RESPONSE                       = 0x55,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_ALL_LIST_RESPONSE                    = 0x56,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_MIRRORING_RESPONSE                   = 0x57,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_MIRRORING_DONE_NOTIFICATION          = 0x58,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_INFORMATION_RESPONSE                  = 0x61,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_READ_RESPONSE                         = 0x62,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_WRITE_RESPONSE                        = 0x63,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_ERASE_RESPONSE                        = 0x64,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_CLEAR_RESPONSE                        = 0x65,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_ALL_LIST_RESPONSE                     = 0x66,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_MIRRORING_RESPONSE                    = 0x67,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_MIRRORING_DONE_NOTIFICATION           = 0x68,
+    LXT_PHN_UIM_DIR_NAME_READ_RESPONSE                                      = 0x69,
+    LXT_PHN_UIM_DIR_NAME_WRITE_RESPONSE                                     = 0x70,
+    LXT_PHN_UIM_PHONE_CARD_SMS_CLEAR_RESPONSE                               = 0x71,
+    LXT_PDA_UIM_GET_PERMISSION_STATUS_RESPONSE                              = 0x80
+};
+
+
+enum LXT_PDA_PHONE_BOOK
+{
+    LXT_PDA_PHONE_BOOK_INFORMATION_REQUEST                                  = 0x51,
+    LXT_PDA_PHONE_BOOK_READ_REQUEST                                         = 0x52,
+    LXT_PDA_PHONE_BOOK_READ_ENTRIES_REQUEST                                 = 0x53,
+    LXT_PDA_PHONE_BOOK_WRITE_REQUEST                                        = 0x54,
+    LXT_PDA_PHONE_BOOK_ERASE_REQUEST                                        = 0x55,
+    LXT_PDA_PHONE_BOOK_CLEAR_REQUEST                                        = 0x56,
+    LXT_PDA_PHONE_BOOK_GET_ENTRY_LIST_REQUEST                               = 0x57,
+    LXT_PDA_PHONE_BOOK_GET_CACHED_REQUEST                                   = 0x58
+};
+
+enum LXT_PHN_PHONE_BOOK
+{
+    LXT_PHN_PHONE_BOOK_INFORMATION_RESPONSE                                 = 0x51,
+    LXT_PHN_PHONE_BOOK_READ_RESPONSE                                        = 0x52,
+    LXT_PHN_PHONE_BOOK_READ_ENTRIES_RESPONSE                                = 0x53,
+    LXT_PHN_PHONE_BOOK_GET_ENTRY_LIST_RESPONSE                              = 0x54,
+    LXT_PHN_PHONE_BOOK_ACTION_NOTIFICATION                                  = 0x55,
+    LXT_PHN_PHONE_BOOK_COMPLETE_NOTIFICATION                                = 0x56,
+    LXT_PHN_PHONE_BOOK_GET_CACHED_RESPONSE                                  = 0x57,
+    LXT_PHN_PHONE_BOOK_MIRRORING_START_NOTIFICATION                         = 0xA1,
+    LXT_PHN_PHONE_BOOK_MIRRORING_DONE_NOTIFICATION                          = 0xA2,
+};
+
+// define of action group (UTK) ++++++++++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PDA_UTK
+{
+    LXT_PDA_UTK_START_REQUEST                                               = 0x41,
+    LXT_PDA_UTK_GET_KEY_REQUEST                                             = 0x42,
+    LXT_PDA_UTK_END_INPUT_REQUEST                                           = 0x43,
+    LXT_PDA_UTK_SET_UP_MAIN_MENU_REQUEST                                    = 0x44
+};
+
+
+enum LXT_PHN_UTK
+{
+    LXT_PHN_UTK_MENU_TITLE_NOTIFICATION                                     = 0x41,
+    LXT_PHN_UTK_NENU_ITEM_NOTIFICATION                                      = 0x42,
+    LXT_PHN_UTK_SEND_SMS_NOTIFICATION                                       = 0x43,
+    LXT_PHN_UTK_GET_START_INPUT_NOTIFICATION                                = 0x44,
+    LXT_PHN_UTK_DISPLAY_TEXT_NOTIFICATION                                   = 0x45,
+    LXT_PHN_UTK_END_NOTIFICATION                                            = 0x46,
+    LXT_PHN_UTK_CARD_START_RESPONSE                                         = 0x47
+};
+
+
+// define of action group () ++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GPS
+{
+    LXT_PDA_GPS_MO_SMS_REQUEST                                              = 0x41,
+    LXT_PDA_GPS_MT_SMS_REQUEST                                              = 0x42,
+    LXT_PDA_GPS_SPP_REQUEST                                                 = 0x43,
+    LXT_PDA_GPS_URL_INFO_REQUEST                                            = 0x44,
+    LXT_PDA_GPS_END_REQUEST                                                 = 0x45
+};
+
+enum LXT_PHN_GPS
+{
+    LXT_PHN_GPS_MT_SMS_ARRIVAL_NOTIFICATION                                 = 0x41,
+    LXT_PHN_GPS_MT_SMS_RESPONSE                                             = 0x42,
+    LXT_PHN_GPS_WAP_BASED_SESSION_STATUS_NOTIFICATION                       = 0x43,
+    LXT_PHN_GPS_URL_INFO_RESPONSE                                           = 0x44,
+    LXT_PHN_GPS_SMS_BASED_SESSION_STATUS_NOTIFICATION                       = 0x45
+};
+
+
+// define of action group (Data service) +++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_DATASERVICE
+{
+    LXT_PDA_DATASERVICE_PIN_CONTROL_REQUEST                                 = 0x41
+};
+
+
+enum LXT_PHN_DATASERVICE
+{
+
+    LXT_PHN_DATASERVICE_PIN_CONTROL_NOTIFICATION                            = 0x41,
+    LXT_PHN_DATASERVICE_DS_TE2_DIALING_INDICATION                           = 0x42,
+    LXT_PHN_DATASERVICE_PPP_CONTROL_DISCONNECTING_NOTIFICATION              = 0x43,
+    LXT_PHN_DATASERVICE_PPP_CONTROL_DONE_NOTIFICATION                       = 0x44,
+    LXT_PHN_DATASERVICE_DS_TE2_DATA_RATE_INFO_NOTIFICATION                  = 0x45,
+    LXT_PHN_DATASERVICE_TE2_STATUS_NOTIFICATION                             = 0x46,
+    LXT_PHN_DATASERVICE_DISPLAY_NOTIFICATION                                = 0x47
+};
+
+// define of action group (response)++++++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PHN_RESPONSE
+{
+    LXT_PHN_RESPONSE_GENERAL_RESPONSE                                       = 0x41
+};
+
+
+
+
+// define of action group (SIO Mode)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SIOMODE
+{
+    LXT_PDA_SIOMODE_SIO_BAUDRATE_GET_REQUEST                                 = 0x41,
+    LXT_PDA_SIOMODE_SIO_BAUDRATE_SET_REQUEST                                 = 0x42,
+    LXT_PDA_SIOMODE_SLOT_MODE_GET_REQUEST                                    = 0x43,
+    LXT_PDA_SIOMODE_SLOT_MODE_SET_REQUEST                                    = 0x44,
+    LXT_PDA_SIOMODE_VOICE_OP_GET_REQUEST                                     = 0x45,
+    LXT_PDA_SIOMODE_VOICE_OP_SET_REQUEST                                     = 0x46,
+    LXT_PDA_SIOMODE_SIO_MODE_GET_REQUEST                                     = 0x47,
+    LXT_PDA_SIOMODE_SIO_MODE_SET_REQUEST                                     = 0x48,
+    LXT_PDA_SIOMODE_LIFETIME_CLEAR_REQUEST                                   = 0x49,
+};
+
+// define of action group (SIO Mode)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PHN_SIOMODE
+{
+    LXT_PHN_SIOMODE_SIO_BAUDRATE_GET_RESPONSE                                = 0x41,
+    LXT_PHN_SIOMODE_SLOT_MODE_GET_RESPONSE                                   = 0x42,
+    LXT_PHN_SIOMODE_VOICE_OP_GET_RESPONSE                                    = 0x43,
+    LXT_PHN_SIOMODE_SIO_MODE_GET_RESPONSE                                    = 0x44
+};
+
+
+
+
+
+
+
+
+
+#endif // _PHONEPROTOCOL_H_
diff --git a/libvmodem/phoneprotocol4gsm.h b/libvmodem/phoneprotocol4gsm.h
new file mode 100644 (file)
index 0000000..375558c
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _PHONEPROTOCOL4GSM_H_
+#define _PHONEPROTOCOL4GSM_H_
+
+//  ===========================================================================
+//
+//                          define of main group
+//
+//  ===========================================================================
+enum LXT_GRP_GSM
+{
+    LXT_GRP_GSM_CONFIG                                            = 0xA3,
+    LXT_GRP_GSM_CALL                                              = 0xA4,
+    LXT_GRP_GSM_SUPS                                              = 0xA5,
+    LXT_GRP_GSM_EOT                                               = 0xff
+};
+
+//  ===========================================================================
+//
+//                          define of sub command
+//
+//  ===========================================================================
+
+// define of action group (configuration) +++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_CONFIG
+{
+    LXT_PDA_GSM_CONFIG_GET_CALL_COST_REQUEST                      = 0x41,
+    LXT_PDA_GSM_CONFIG_RESET_CALL_COST_REQUEST                    = 0x42,
+    LXT_PDA_GSM_CONFIG_SET_MAX_CALL_COST_REQUEST                  = 0x43,
+    LXT_PDA_GSM_CONFIG_GET_CALL_UNIT_PRICE_REQUEST                = 0x44,
+    LXT_PDA_GSM_CONFIG_SET_CALL_UNIT_PRICE_REQUEST                = 0x45,
+    LXT_PDA_GSM_CONFIG_GET_NETWORK_SELECTION_MODE_REQUEST         = 0x46,
+    LXT_PDA_GSM_CONFIG_AUTOMATIC_NETWORK_SELECTION_REQUEST        = 0x47,
+    LXT_PDA_GSM_CONFIG_MANUAL_NETWORK_SELECTION_REQUEST           = 0x48,
+    LXT_PDA_GSM_CONFIG_MANUAL_NETWORK_SELECTION_REG_REQUEST       = 0x49,
+    LXT_PDA_GSM_CONFIG_GET_CALLER_ID_REQUEST                      = 0x4A,
+    LXT_PDA_GSM_CONFIG_SET_CALLER_ID_REQUEST                      = 0x4B,
+    LXT_PDA_GSM_CONFIG_GET_ACTIVE_LINE_REQUEST                    = 0x4C,
+    LXT_PDA_GSM_CONFIG_SET_ACTIVE_LINE_REQUEST                    = 0x4D,
+    LXT_PDA_GSM_CONFIG_SET_FORCE_GSM_MODE_REQUEST                 = 0x4E,
+    LXT_PDA_GSM_CONFIG_GET_SYSTEM_IDENTITY                        = 0x4F
+};
+
+enum LXT_PHN_GSM_CONFIG
+{
+    LXT_PHN_GSM_CONFIG_GET_CALL_COST_RESONSE                      = 0x41,
+    LXT_PHN_GSM_CONFIG_RESET_CALL_COST_RESONSE                    = 0x42,
+    LXT_PHN_GSM_CONFIG_SET_MAX_CALL_COST_NOTIFICATION             = 0x43,
+    LXT_PHN_GSM_CONFIG_GET_CALL_UNIT_PRICE_RESONSE                = 0x44,
+    LXT_PHN_GSM_CONFIG_SET_CALL_UNIT_PRICE_RESONSE                = 0x45,
+    LXT_PHN_GSM_CONFIG_GET_NETWORK_SELECTION_MODE_NOTIFICATION    = 0x46,
+    LXT_PHN_GSM_CONFIG_AUTOMATIC_NETWORK_SELECTION_NOTIFICATION   = 0x47,
+    LXT_PHN_GSM_CONFIG_MANUAL_NETWORK_SELECTION_NOTIFICATION      = 0x48,
+    LXT_PHN_GSM_CONFIG_MANUAL_NETWORK_REGISTRATION_NOTIFICATION   = 0x49,
+    LXT_PHN_GSM_CONFIG_GET_CALLER_ID_RESPONSE                     = 0x4A,
+    LXT_PHN_GSM_CONFIG_SET_CALLER_ID_RESPONSE                     = 0x4B,
+    LXT_PHN_GSM_CONFIG_GET_ACTIVE_LINE_RESPONSE                   = 0x4C,
+    LXT_PHN_GSM_CONFIG_SET_ACTIVE_LINE_RESPONSE                   = 0x4D,
+    LXT_PHN_GSM_CONFIG_SERVING_SYSTEM_IDENTITY_INDICATION         = 0x4E
+};
+
+// define of action group (call)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_CALL
+{
+    LXT_PDA_GSM_CALL_CALL_ORIGINATION_REQUEST                     = 0x41,
+    LXT_PDA_GSM_CALL_END_CALL_REQUEST                             = 0x42,
+    LXT_PDA_GSM_CALL_ANSWER_REQUEST                               = 0x43,
+    LXT_PDA_GSM_CALL_START_DTMF_REQUEST                           = 0x44,
+    LXT_PDA_GSM_CALL_STOP_DTMF_REQUEST                            = 0x45,
+    LXT_PDA_GSM_CALL_REJECT_REQUEST                               = 0x46
+};
+
+enum LXT_PHN_GSM_CALL
+{
+    LXT_PHN_GSM_CALL_INCOMING_CALL_NOTIFICATION                   = 0x41,
+    LXT_PHN_GSM_CALL_CALL_STATUS_NOTIFICATION                     = 0x42,
+    LXT_PHN_GSM_CALL_START_DTMF_ACK_RESPONSE                      = 0x43,
+    LXT_PHN_GSM_CALL_STOP_DTMF_ACK_RESPONSE                       = 0x44,
+    LXT_PHN_GSM_CALL_DIAGNOSTIC_CALL_ORIGINATION_NOTIFICATION     = 0x45
+};
+
+// define of action group (supplementary)++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_SUPS
+{
+    LXT_PDA_GSM_SUPS_USER_ORIGINATED_SUPS_REQUEST                 = 0x41,
+    LXT_PDA_GSM_SUPS_NETWORK_ORIGINATED_SUPS_USER_CONFIRM         = 0x42,
+    LXT_PDA_GSM_SUPS_GET_SUPS_NETWORK_CONFIRM_DATA_REQUEST        = 0x43,
+    LXT_PDA_GSM_SUPS_PASSWORD_REGISTRATION_REQUEST                = 0x44,
+    LXT_PDA_GSM_SUPS_CALL_HANDLE_SUPS_WITHIN_CALL_REQUEST         = 0x45
+//    LXT_PDA_GSM_SUPS_GET_BARRING_PASSWORD_CONFIRM                 = 0x45,
+};
+
+enum LXT_PHN_GSM_SUPS
+{
+    LXT_PHN_GSM_SUPS_USER_ORIGINATED_SUPS_NOTIFICATION            = 0x41,
+    LXT_PHN_GSM_SUPS_NETWORK_ORIGINATED_SUPS_INDICATION           = 0x42,
+    LXT_PHN_GSM_SUPS_GET_SUPS_NETWORK_CONFIRM_DATA_RESPONSE       = 0x43,
+    LXT_PHN_GSM_SUPS_PASSWORD_REGISTRATION_NOTIFICATION           = 0x44,
+    LXT_PHN_GSM_SUPS_GET_BARRING_PASSWORD_INDICATION              = 0x45,
+    LXT_PHN_GSM_SUPS_MANAGE_SUPS_WITHIN_CALL_NOTIFICATION         = 0x46,
+    LXT_PHN_GSM_SUPS_STATUS_NOTIFICATION                          = 0x47,
+    LXT_PHN_GSM_SUPS_CALL_PUT_ON_HOLD_BY_REMOTE_INDICATION        = 0x48,
+    LXT_PHN_GSM_SUPS_CALL_RETRIEVED_BY_REMOTE_INDICATION          = 0x49,
+    LXT_PHN_GSM_SUPS_EXPLICIT_CALL_TRANSFER_BY_REMOTE_INDICATION  = 0x4A
+};
+
+
+
+#endif // _PHONEPROTOCOL4GSM_H_
diff --git a/libvmodem/samsungtapi.h b/libvmodem/samsungtapi.h
new file mode 100644 (file)
index 0000000..9b7b1fb
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#if 0
+
+#ifndef _SAMSUNGTAPI_H_
+#define _SAMSUNGTAPI_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++include about qt
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "linuxtapi.h"
+#include "phoneprotocol.h"
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+    
+    typedef enum
+    {
+        SAMSUNG_SERVICE_MODE_MANUAL_TEST                                        = 0x01,
+        SAMSUNG_SERVICE_MODE_NAM_EDITING                                        = 0x02,
+        SAMSUNG_SERVICE_MODE_DEBUG                                              = 0x03,
+        SAMSUNG_SERVICE_MODE_AUTO_TEST                                          = 0x04,
+        SAMSUNG_SERVICE_MODE_BASIC_NAM_EDITING                                  = 0x05,
+        SAMSUNG_SERVICE_MODE_PHONE_TEST                                         = 0x06
+    }
+    SAMSUNG_SERVICE_MODE;
+
+    /*
+    typedef enum
+    {
+        SAMSUNG_DEFAULT_CONFIGURATION_MODE_WARM                                 = 0x00,
+        SAMSUNG_DEFAULT_CONFIGURATION_MODE_COOL                                 = 0x01,
+        SAMSUNG_DEFAULT_CONFIGURATION_MODE_COLD                                 = 0x02
+    }
+    SAMSUNG_DEFAULT_CONFIGURATION_MODE;
+
+
+    typedef enum
+    {
+        SAMSUNG_SIOMODE_BAUDRATE_38400                                          = 0x00,
+        SAMSUNG_SIOMODE_BAUDRATE_57600                                          = 0x01,
+        SAMSUNG_SIOMODE_BAUDRATE_115200                                         = 0x02
+    }
+    SAMSUNG_SIOMODE_BAUDRATE;
+
+    typedef enum
+    {
+        SAMSUNG_SIOMODE_SLOT_MODE_ON                                            = 0x00,
+        SAMSUNG_SIOMODE_SLOT_MODE_NON                                           = 0x01
+
+    } SAMSUNG_SIOMODE_SLOT_MODE;
+
+    typedef enum
+    {
+        SAMSUNG_SIOMODE_VOICE_OP_8K                                             = 0x00,
+        SAMSUNG_SIOMODE_VOICE_OP_EVRC                                           = 0x01,
+        SAMSUNG_SIOMODE_VOICE_OP_13K                                            = 0x02,
+        SAMSUNG_SIOMODE_VOICE_OP_DEFAULT                                        = 0x03
+    }
+    SAMSUNG_SIOMODE_VOICE_OP;
+
+    typedef enum
+    {
+        SAMSUNG_SIOMODE_MODE_HFK                                                = 0x00,
+        SAMSUNG_SIOMODE_MODE_DIAG                                               = 0x01
+
+    } SAMSUNG_SIOMODE_MODE;
+
+    typedef enum
+    {
+        SAMSUNG_FACTORY_MODE_DISABLED                                           = 0x00,
+        SAMSUNG_FACTORY_MODE_ENABLED                                            = 0x01
+    }
+    SAMSUNG_FACTORY_MODE;
+    */
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+    int samsung_servicemode_enterServiceMode(LXT_HANDLE* handle, SAMSUNG_SERVICE_MODE mode);
+    int samsung_servicemode_endServiceMode(LXT_HANDLE* handle);
+    int samsung_servicemode_processKeyCode(LXT_HANDLE* handle, char ascii);
+
+    /*
+    int samsung_servicemode_factoryModeEnable(LXT_HANDLE* handle, SAMSUNG_FACTORY_MODE enable);
+
+    int samsung_configuration_setDefaultConfiguration(LXT_HANDLE* handle, SAMSUNG_DEFAULT_CONFIGURATION_MODE mode);
+    int samsung_siomode_getSIOBaudRate(LXT_HANDLE* handle);
+    int samsung_siomode_setSIOBaudRate(LXT_HANDLE* handle, SAMSUNG_SIOMODE_BAUDRATE baud_rate);
+    int samsung_siomode_getSlotMode(LXT_HANDLE* handle);
+    int samsung_siomode_setSlotMode(LXT_HANDLE* handle, SAMSUNG_SIOMODE_SLOT_MODE slot_mode);
+    int samsung_siomode_getVoiceOp(LXT_HANDLE* handle);
+    int samsung_siomode_setVoiceOp(LXT_HANDLE* handle, SAMSUNG_SIOMODE_VOICE_OP voice_op);
+    int samsung_siomode_getSIOMode(LXT_HANDLE* handle);
+    int samsung_siomode_setSIOMode(LXT_HANDLE* handle, SAMSUNG_SIOMODE_MODE sio_mode);
+    int samsung_siomode_setLifeTimeClear(LXT_HANDLE* handle);
+    */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SAMSUNGTAPI_H_
+
+#endif // if 0
+
diff --git a/libvmodem/sqlite3.h b/libvmodem/sqlite3.h
new file mode 100644 (file)
index 0000000..8c8709e
--- /dev/null
@@ -0,0 +1,1751 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+** 2001 September 15
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This header file defines the interface that the SQLite library
+** presents to client programs.
+**
+** @(#) $Id: sqlite3.h,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+*/
+#ifndef _SQLITE3_H_
+#define _SQLITE3_H_
+#include <stdarg.h>     /* Needed for the definition of va_list */
+
+/*
+** Make sure we can call this stuff from C++.
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** The version of the SQLite library.
+*/
+#ifdef SQLITE_VERSION
+# undef SQLITE_VERSION
+#endif
+#define SQLITE_VERSION         "3.3.7"
+
+/*
+** The format of the version string is "X.Y.Z<trailing string>", where
+** X is the major version number, Y is the minor version number and Z
+** is the release number. The trailing string is often "alpha" or "beta".
+** For example "3.1.1beta".
+**
+** The SQLITE_VERSION_NUMBER is an integer with the value 
+** (X*100000 + Y*1000 + Z). For example, for version "3.1.1beta", 
+** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using 
+** version 3.1.1 or greater at compile time, programs may use the test 
+** (SQLITE_VERSION_NUMBER>=3001001).
+*/
+#ifdef SQLITE_VERSION_NUMBER
+# undef SQLITE_VERSION_NUMBER
+#endif
+#define SQLITE_VERSION_NUMBER 3003007
+
+/*
+** The version string is also compiled into the library so that a program
+** can check to make sure that the lib*.a file and the *.h file are from
+** the same version.  The sqlite3_libversion() function returns a pointer
+** to the sqlite3_version variable - useful in DLLs which cannot access
+** global variables.
+*/
+extern const char sqlite3_version[];
+const char *sqlite3_libversion(void);
+
+/*
+** Return the value of the SQLITE_VERSION_NUMBER macro when the
+** library was compiled.
+*/
+int sqlite3_libversion_number(void);
+
+/*
+** Each open sqlite database is represented by an instance of the
+** following opaque structure.
+*/
+typedef struct sqlite3 sqlite3;
+
+
+/*
+** Some compilers do not support the "long long" datatype.  So we have
+** to do a typedef that for 64-bit integers that depends on what compiler
+** is being used.
+*/
+#ifdef SQLITE_INT64_TYPE
+  typedef SQLITE_INT64_TYPE sqlite_int64;
+  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
+#elif defined(_MSC_VER) || defined(__BORLANDC__)
+  typedef __int64 sqlite_int64;
+  typedef unsigned __int64 sqlite_uint64;
+#else
+  typedef long long int sqlite_int64;
+  typedef unsigned long long int sqlite_uint64;
+#endif
+
+/*
+** If compiling for a processor that lacks floating point support,
+** substitute integer for floating-point
+*/
+#ifdef SQLITE_OMIT_FLOATING_POINT
+# define double sqlite_int64
+#endif
+
+/*
+** A function to close the database.
+**
+** Call this function with a pointer to a structure that was previously
+** returned from sqlite3_open() and the corresponding database will by closed.
+**
+** All SQL statements prepared using sqlite3_prepare() or
+** sqlite3_prepare16() must be deallocated using sqlite3_finalize() before
+** this routine is called. Otherwise, SQLITE_BUSY is returned and the
+** database connection remains open.
+*/
+int sqlite3_close(sqlite3 *);
+
+/*
+** The type for a callback function.
+*/
+typedef int (*sqlite3_callback)(void*,int,char**, char**);
+
+/*
+** A function to executes one or more statements of SQL.
+**
+** If one or more of the SQL statements are queries, then
+** the callback function specified by the 3rd parameter is
+** invoked once for each row of the query result.  This callback
+** should normally return 0.  If the callback returns a non-zero
+** value then the query is aborted, all subsequent SQL statements
+** are skipped and the sqlite3_exec() function returns the SQLITE_ABORT.
+**
+** The 4th parameter is an arbitrary pointer that is passed
+** to the callback function as its first parameter.
+**
+** The 2nd parameter to the callback function is the number of
+** columns in the query result.  The 3rd parameter to the callback
+** is an array of strings holding the values for each column.
+** The 4th parameter to the callback is an array of strings holding
+** the names of each column.
+**
+** The callback function may be NULL, even for queries.  A NULL
+** callback is not an error.  It just means that no callback
+** will be invoked.
+**
+** If an error occurs while parsing or evaluating the SQL (but
+** not while executing the callback) then an appropriate error
+** message is written into memory obtained from malloc() and
+** *errmsg is made to point to that message.  The calling function
+** is responsible for freeing the memory that holds the error
+** message.   Use sqlite3_free() for this.  If errmsg==NULL,
+** then no error message is ever written.
+**
+** The return value is is SQLITE_OK if there are no errors and
+** some other return code if there is an error.  The particular
+** return value depends on the type of error. 
+**
+** If the query could not be executed because a database file is
+** locked or busy, then this function returns SQLITE_BUSY.  (This
+** behavior can be modified somewhat using the sqlite3_busy_handler()
+** and sqlite3_busy_timeout() functions below.)
+*/
+int sqlite3_exec(
+  sqlite3*,                     /* An open database */
+  const char *sql,              /* SQL to be executed */
+  sqlite3_callback,             /* Callback function */
+  void *,                       /* 1st argument to callback function */
+  char **errmsg                 /* Error msg written here */
+);
+
+/*
+** Return values for sqlite3_exec() and sqlite3_step()
+*/
+#define SQLITE_OK           0   /* Successful result */
+/* beginning-of-error-codes */
+#define SQLITE_ERROR        1   /* SQL error or missing database */
+#define SQLITE_INTERNAL     2   /* NOT USED. Internal logic error in SQLite */
+#define SQLITE_PERM         3   /* Access permission denied */
+#define SQLITE_ABORT        4   /* Callback routine requested an abort */
+#define SQLITE_BUSY         5   /* The database file is locked */
+#define SQLITE_LOCKED       6   /* A table in the database is locked */
+#define SQLITE_NOMEM        7   /* A malloc() failed */
+#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
+#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
+#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
+#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
+#define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */
+#define SQLITE_FULL        13   /* Insertion failed because database is full */
+#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
+#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
+#define SQLITE_EMPTY       16   /* Database is empty */
+#define SQLITE_SCHEMA      17   /* The database schema changed */
+#define SQLITE_TOOBIG      18   /* NOT USED. Too much data for one row */
+#define SQLITE_CONSTRAINT  19   /* Abort due to contraint violation */
+#define SQLITE_MISMATCH    20   /* Data type mismatch */
+#define SQLITE_MISUSE      21   /* Library used incorrectly */
+#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
+#define SQLITE_AUTH        23   /* Authorization denied */
+#define SQLITE_FORMAT      24   /* Auxiliary database format error */
+#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
+#define SQLITE_NOTADB      26   /* File opened that is not a database file */
+#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
+#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
+/* end-of-error-codes */
+
+/*
+** Each entry in an SQLite table has a unique integer key.  (The key is
+** the value of the INTEGER PRIMARY KEY column if there is such a column,
+** otherwise the key is generated at random.  The unique key is always
+** available as the ROWID, OID, or _ROWID_ column.)  The following routine
+** returns the integer key of the most recent insert in the database.
+**
+** This function is similar to the mysql_insert_id() function from MySQL.
+*/
+sqlite_int64 sqlite3_last_insert_rowid(sqlite3*);
+
+/*
+** This function returns the number of database rows that were changed
+** (or inserted or deleted) by the most recent called sqlite3_exec().
+**
+** All changes are counted, even if they were later undone by a
+** ROLLBACK or ABORT.  Except, changes associated with creating and
+** dropping tables are not counted.
+**
+** If a callback invokes sqlite3_exec() recursively, then the changes
+** in the inner, recursive call are counted together with the changes
+** in the outer call.
+**
+** SQLite implements the command "DELETE FROM table" without a WHERE clause
+** by dropping and recreating the table.  (This is much faster than going
+** through and deleting individual elements form the table.)  Because of
+** this optimization, the change count for "DELETE FROM table" will be
+** zero regardless of the number of elements that were originally in the
+** table. To get an accurate count of the number of rows deleted, use
+** "DELETE FROM table WHERE 1" instead.
+*/
+int sqlite3_changes(sqlite3*);
+
+/*
+** This function returns the number of database rows that have been
+** modified by INSERT, UPDATE or DELETE statements since the database handle
+** was opened. This includes UPDATE, INSERT and DELETE statements executed
+** as part of trigger programs. All changes are counted as soon as the
+** statement that makes them is completed (when the statement handle is
+** passed to sqlite3_reset() or sqlite_finalise()).
+**
+** SQLite implements the command "DELETE FROM table" without a WHERE clause
+** by dropping and recreating the table.  (This is much faster than going
+** through and deleting individual elements form the table.)  Because of
+** this optimization, the change count for "DELETE FROM table" will be
+** zero regardless of the number of elements that were originally in the
+** table. To get an accurate count of the number of rows deleted, use
+** "DELETE FROM table WHERE 1" instead.
+*/
+int sqlite3_total_changes(sqlite3*);
+
+/* This function causes any pending database operation to abort and
+** return at its earliest opportunity.  This routine is typically
+** called in response to a user action such as pressing "Cancel"
+** or Ctrl-C where the user wants a long query operation to halt
+** immediately.
+*/
+void sqlite3_interrupt(sqlite3*);
+
+
+/* These functions return true if the given input string comprises
+** one or more complete SQL statements. For the sqlite3_complete() call,
+** the parameter must be a nul-terminated UTF-8 string. For
+** sqlite3_complete16(), a nul-terminated machine byte order UTF-16 string
+** is required.
+**
+** The algorithm is simple.  If the last token other than spaces
+** and comments is a semicolon, then return true.  otherwise return
+** false.
+*/
+int sqlite3_complete(const char *sql);
+int sqlite3_complete16(const void *sql);
+
+/*
+** This routine identifies a callback function that is invoked
+** whenever an attempt is made to open a database table that is
+** currently locked by another process or thread.  If the busy callback
+** is NULL, then sqlite3_exec() returns SQLITE_BUSY immediately if
+** it finds a locked table.  If the busy callback is not NULL, then
+** sqlite3_exec() invokes the callback with three arguments.  The
+** second argument is the name of the locked table and the third
+** argument is the number of times the table has been busy.  If the
+** busy callback returns 0, then sqlite3_exec() immediately returns
+** SQLITE_BUSY.  If the callback returns non-zero, then sqlite3_exec()
+** tries to open the table again and the cycle repeats.
+**
+** The default busy callback is NULL.
+**
+** Sqlite is re-entrant, so the busy handler may start a new query. 
+** (It is not clear why anyone would every want to do this, but it
+** is allowed, in theory.)  But the busy handler may not close the
+** database.  Closing the database from a busy handler will delete 
+** data structures out from under the executing query and will 
+** probably result in a coredump.
+*/
+int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
+
+/*
+** This routine sets a busy handler that sleeps for a while when a
+** table is locked.  The handler will sleep multiple times until 
+** at least "ms" milleseconds of sleeping have been done.  After
+** "ms" milleseconds of sleeping, the handler returns 0 which
+** causes sqlite3_exec() to return SQLITE_BUSY.
+**
+** Calling this routine with an argument less than or equal to zero
+** turns off all busy handlers.
+*/
+int sqlite3_busy_timeout(sqlite3*, int ms);
+
+/*
+** This next routine is really just a wrapper around sqlite3_exec().
+** Instead of invoking a user-supplied callback for each row of the
+** result, this routine remembers each row of the result in memory
+** obtained from malloc(), then returns all of the result after the
+** query has finished. 
+**
+** As an example, suppose the query result where this table:
+**
+**        Name        | Age
+**        -----------------------
+**        Alice       | 43
+**        Bob         | 28
+**        Cindy       | 21
+**
+** If the 3rd argument were &azResult then after the function returns
+** azResult will contain the following data:
+**
+**        azResult[0] = "Name";
+**        azResult[1] = "Age";
+**        azResult[2] = "Alice";
+**        azResult[3] = "43";
+**        azResult[4] = "Bob";
+**        azResult[5] = "28";
+**        azResult[6] = "Cindy";
+**        azResult[7] = "21";
+**
+** Notice that there is an extra row of data containing the column
+** headers.  But the *nrow return value is still 3.  *ncolumn is
+** set to 2.  In general, the number of values inserted into azResult
+** will be ((*nrow) + 1)*(*ncolumn).
+**
+** After the calling function has finished using the result, it should 
+** pass the result data pointer to sqlite3_free_table() in order to 
+** release the memory that was malloc-ed.  Because of the way the 
+** malloc() happens, the calling function must not try to call 
+** free() directly.  Only sqlite3_free_table() is able to release 
+** the memory properly and safely.
+**
+** The return value of this routine is the same as from sqlite3_exec().
+*/
+int sqlite3_get_table(
+  sqlite3*,               /* An open database */
+  const char *sql,       /* SQL to be executed */
+  char ***resultp,       /* Result written to a char *[]  that this points to */
+  int *nrow,             /* Number of result rows written here */
+  int *ncolumn,          /* Number of result columns written here */
+  char **errmsg          /* Error msg written here */
+);
+
+/*
+** Call this routine to free the memory that sqlite3_get_table() allocated.
+*/
+void sqlite3_free_table(char **result);
+
+/*
+** The following routines are variants of the "sprintf()" from the
+** standard C library.  The resulting string is written into memory
+** obtained from malloc() so that there is never a possiblity of buffer
+** overflow.  These routines also implement some additional formatting
+** options that are useful for constructing SQL statements.
+**
+** The strings returned by these routines should be freed by calling
+** sqlite3_free().
+**
+** All of the usual printf formatting options apply.  In addition, there
+** is a "%q" option.  %q works like %s in that it substitutes a null-terminated
+** string from the argument list.  But %q also doubles every '\'' character.
+** %q is designed for use inside a string literal.  By doubling each '\''
+** character it escapes that character and allows it to be inserted into
+** the string.
+**
+** For example, so some string variable contains text as follows:
+**
+**      char *zText = "It's a happy day!";
+**
+** We can use this text in an SQL statement as follows:
+**
+**      char *z = sqlite3_mprintf("INSERT INTO TABLES('%q')", zText);
+**      sqlite3_exec(db, z, callback1, 0, 0);
+**      sqlite3_free(z);
+**
+** Because the %q format string is used, the '\'' character in zText
+** is escaped and the SQL generated is as follows:
+**
+**      INSERT INTO table1 VALUES('It''s a happy day!')
+**
+** This is correct.  Had we used %s instead of %q, the generated SQL
+** would have looked like this:
+**
+**      INSERT INTO table1 VALUES('It's a happy day!');
+**
+** This second example is an SQL syntax error.  As a general rule you
+** should always use %q instead of %s when inserting text into a string 
+** literal.
+*/
+char *sqlite3_mprintf(const char*,...);
+char *sqlite3_vmprintf(const char*, va_list);
+char *sqlite3_snprintf(int,char*,const char*, ...);
+
+/*
+** SQLite uses its own memory allocator.  On many installations, this
+** memory allocator is identical to the standard malloc()/realloc()/free()
+** and can be used interchangable.  On others, the implementations are
+** different.  For maximum portability, it is best not to mix calls
+** to the standard malloc/realloc/free with the sqlite versions.
+*/
+void *sqlite3_malloc(int);
+void *sqlite3_realloc(void*, int);
+void sqlite3_free(void*);
+
+#ifndef SQLITE_OMIT_AUTHORIZATION
+/*
+** This routine registers a callback with the SQLite library.  The
+** callback is invoked (at compile-time, not at run-time) for each
+** attempt to access a column of a table in the database.  The callback
+** returns SQLITE_OK if access is allowed, SQLITE_DENY if the entire
+** SQL statement should be aborted with an error and SQLITE_IGNORE
+** if the column should be treated as a NULL value.
+*/
+int sqlite3_set_authorizer(
+  sqlite3*,
+  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
+  void *pUserData
+);
+#endif
+
+/*
+** The second parameter to the access authorization function above will
+** be one of the values below.  These values signify what kind of operation
+** is to be authorized.  The 3rd and 4th parameters to the authorization
+** function will be parameters or NULL depending on which of the following
+** codes is used as the second parameter.  The 5th parameter is the name
+** of the database ("main", "temp", etc.) if applicable.  The 6th parameter
+** is the name of the inner-most trigger or view that is responsible for
+** the access attempt or NULL if this access attempt is directly from 
+** input SQL code.
+**
+**                                          Arg-3           Arg-4
+*/
+#define SQLITE_COPY                  0   /* Table Name      File Name       */
+#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
+#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */
+#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */
+#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */
+#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */
+#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */
+#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */
+#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */
+#define SQLITE_DELETE                9   /* Table Name      NULL            */
+#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */
+#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */
+#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */
+#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */
+#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */
+#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */
+#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */
+#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */
+#define SQLITE_INSERT               18   /* Table Name      NULL            */
+#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */
+#define SQLITE_READ                 20   /* Table Name      Column Name     */
+#define SQLITE_SELECT               21   /* NULL            NULL            */
+#define SQLITE_TRANSACTION          22   /* NULL            NULL            */
+#define SQLITE_UPDATE               23   /* Table Name      Column Name     */
+#define SQLITE_ATTACH               24   /* Filename        NULL            */
+#define SQLITE_DETACH               25   /* Database Name   NULL            */
+#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */
+#define SQLITE_REINDEX              27   /* Index Name      NULL            */
+#define SQLITE_ANALYZE              28   /* Table Name      NULL            */
+#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */
+#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */
+
+/*
+** The return value of the authorization function should be one of the
+** following constants:
+*/
+/* #define SQLITE_OK  0   // Allow access (This is actually defined above) */
+#define SQLITE_DENY   1   /* Abort the SQL statement with an error */
+#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
+
+/*
+** Register a function for tracing SQL command evaluation.  The function
+** registered by sqlite3_trace() is invoked at the first sqlite3_step()
+** for the evaluation of an SQL statement.  The function registered by
+** sqlite3_profile() runs at the end of each SQL statement and includes
+** information on how long that statement ran.
+**
+** The sqlite3_profile() API is currently considered experimental and
+** is subject to change.
+*/
+void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
+void *sqlite3_profile(sqlite3*,
+   void(*xProfile)(void*,const char*,sqlite_uint64), void*);
+
+/*
+** This routine configures a callback function - the progress callback - that
+** is invoked periodically during long running calls to sqlite3_exec(),
+** sqlite3_step() and sqlite3_get_table(). An example use for this API is to 
+** keep a GUI updated during a large query.
+**
+** The progress callback is invoked once for every N virtual machine opcodes,
+** where N is the second argument to this function. The progress callback
+** itself is identified by the third argument to this function. The fourth
+** argument to this function is a void pointer passed to the progress callback
+** function each time it is invoked.
+**
+** If a call to sqlite3_exec(), sqlite3_step() or sqlite3_get_table() results 
+** in less than N opcodes being executed, then the progress callback is not
+** invoked.
+** 
+** To remove the progress callback altogether, pass NULL as the third
+** argument to this function.
+**
+** If the progress callback returns a result other than 0, then the current 
+** query is immediately terminated and any database changes rolled back. If the
+** query was part of a larger transaction, then the transaction is not rolled
+** back and remains active. The sqlite3_exec() call returns SQLITE_ABORT. 
+**
+******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
+*/
+void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
+
+/*
+** Register a callback function to be invoked whenever a new transaction
+** is committed.  The pArg argument is passed through to the callback.
+** callback.  If the callback function returns non-zero, then the commit
+** is converted into a rollback.
+**
+** If another function was previously registered, its pArg value is returned.
+** Otherwise NULL is returned.
+**
+** Registering a NULL function disables the callback.
+**
+******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
+*/
+void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
+
+/*
+** Open the sqlite database file "filename".  The "filename" is UTF-8
+** encoded for sqlite3_open() and UTF-16 encoded in the native byte order
+** for sqlite3_open16().  An sqlite3* handle is returned in *ppDb, even
+** if an error occurs. If the database is opened (or created) successfully,
+** then SQLITE_OK is returned. Otherwise an error code is returned. The
+** sqlite3_errmsg() or sqlite3_errmsg16()  routines can be used to obtain
+** an English language description of the error.
+**
+** If the database file does not exist, then a new database is created.
+** The encoding for the database is UTF-8 if sqlite3_open() is called and
+** UTF-16 if sqlite3_open16 is used.
+**
+** Whether or not an error occurs when it is opened, resources associated
+** with the sqlite3* handle should be released by passing it to
+** sqlite3_close() when it is no longer required.
+*/
+int sqlite3_open(
+  const char *filename,   /* Database filename (UTF-8) */
+  sqlite3 **ppDb          /* OUT: SQLite db handle */
+);
+int sqlite3_open16(
+  const void *filename,   /* Database filename (UTF-16) */
+  sqlite3 **ppDb          /* OUT: SQLite db handle */
+);
+
+/*
+** Return the error code for the most recent sqlite3_* API call associated
+** with sqlite3 handle 'db'. SQLITE_OK is returned if the most recent 
+** API call was successful.
+**
+** Calls to many sqlite3_* functions set the error code and string returned
+** by sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16()
+** (overwriting the previous values). Note that calls to sqlite3_errcode(),
+** sqlite3_errmsg() and sqlite3_errmsg16() themselves do not affect the
+** results of future invocations.
+**
+** Assuming no other intervening sqlite3_* API calls are made, the error
+** code returned by this function is associated with the same error as
+** the strings  returned by sqlite3_errmsg() and sqlite3_errmsg16().
+*/
+int sqlite3_errcode(sqlite3 *db);
+
+/*
+** Return a pointer to a UTF-8 encoded string describing in english the
+** error condition for the most recent sqlite3_* API call. The returned
+** string is always terminated by an 0x00 byte.
+**
+** The string "not an error" is returned when the most recent API call was
+** successful.
+*/
+const char *sqlite3_errmsg(sqlite3*);
+
+/*
+** Return a pointer to a UTF-16 native byte order encoded string describing
+** in english the error condition for the most recent sqlite3_* API call.
+** The returned string is always terminated by a pair of 0x00 bytes.
+**
+** The string "not an error" is returned when the most recent API call was
+** successful.
+*/
+const void *sqlite3_errmsg16(sqlite3*);
+
+/*
+** An instance of the following opaque structure is used to represent
+** a compiled SQL statment.
+*/
+typedef struct sqlite3_stmt sqlite3_stmt;
+
+/*
+** To execute an SQL query, it must first be compiled into a byte-code
+** program using one of the following routines. The only difference between
+** them is that the second argument, specifying the SQL statement to
+** compile, is assumed to be encoded in UTF-8 for the sqlite3_prepare()
+** function and UTF-16 for sqlite3_prepare16().
+**
+** The first parameter "db" is an SQLite database handle. The second
+** parameter "zSql" is the statement to be compiled, encoded as either
+** UTF-8 or UTF-16 (see above). If the next parameter, "nBytes", is less
+** than zero, then zSql is read up to the first nul terminator.  If
+** "nBytes" is not less than zero, then it is the length of the string zSql
+** in bytes (not characters).
+**
+** *pzTail is made to point to the first byte past the end of the first
+** SQL statement in zSql.  This routine only compiles the first statement
+** in zSql, so *pzTail is left pointing to what remains uncompiled.
+**
+** *ppStmt is left pointing to a compiled SQL statement that can be
+** executed using sqlite3_step().  Or if there is an error, *ppStmt may be
+** set to NULL.  If the input text contained no SQL (if the input is and
+** empty string or a comment) then *ppStmt is set to NULL.
+**
+** On success, SQLITE_OK is returned.  Otherwise an error code is returned.
+*/
+int sqlite3_prepare(
+  sqlite3 *db,            /* Database handle */
+  const char *zSql,       /* SQL statement, UTF-8 encoded */
+  int nBytes,             /* Length of zSql in bytes. */
+  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
+  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
+);
+int sqlite3_prepare16(
+  sqlite3 *db,            /* Database handle */
+  const void *zSql,       /* SQL statement, UTF-16 encoded */
+  int nBytes,             /* Length of zSql in bytes. */
+  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
+  const void **pzTail     /* OUT: Pointer to unused portion of zSql */
+);
+
+/*
+** Pointers to the following two opaque structures are used to communicate
+** with the implementations of user-defined functions.
+*/
+typedef struct sqlite3_context sqlite3_context;
+typedef struct Mem sqlite3_value;
+
+/*
+** In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(),
+** one or more literals can be replace by parameters "?" or ":AAA" or
+** "$VVV" where AAA is an identifer and VVV is a variable name according
+** to the syntax rules of the TCL programming language.
+** The value of these parameters (also called "host parameter names") can
+** be set using the routines listed below.
+**
+** In every case, the first parameter is a pointer to the sqlite3_stmt
+** structure returned from sqlite3_prepare().  The second parameter is the
+** index of the parameter.  The first parameter as an index of 1.  For
+** named parameters (":AAA" or "$VVV") you can use 
+** sqlite3_bind_parameter_index() to get the correct index value given
+** the parameters name.  If the same named parameter occurs more than
+** once, it is assigned the same index each time.
+**
+** The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and
+** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
+** text after SQLite has finished with it.  If the fifth argument is the
+** special value SQLITE_STATIC, then the library assumes that the information
+** is in static, unmanaged space and does not need to be freed.  If the
+** fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its
+** own private copy of the data.
+**
+** The sqlite3_bind_* routine must be called before sqlite3_step() after
+** an sqlite3_prepare() or sqlite3_reset().  Unbound parameterss are
+** interpreted as NULL.
+*/
+int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
+int sqlite3_bind_double(sqlite3_stmt*, int, double);
+int sqlite3_bind_int(sqlite3_stmt*, int, int);
+int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite_int64);
+int sqlite3_bind_null(sqlite3_stmt*, int);
+int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
+int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
+int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+
+/*
+** Return the number of parameters in a compiled SQL statement.  This
+** routine was added to support DBD::SQLite.
+*/
+int sqlite3_bind_parameter_count(sqlite3_stmt*);
+
+/*
+** Return the name of the i-th parameter.  Ordinary parameters "?" are
+** nameless and a NULL is returned.  For parameters of the form :AAA or
+** $VVV the complete text of the parameter name is returned, including
+** the initial ":" or "$".  NULL is returned if the index is out of range.
+*/
+const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
+
+/*
+** Return the index of a parameter with the given name.  The name
+** must match exactly.  If no parameter with the given name is found,
+** return 0.
+*/
+int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
+
+/*
+** Set all the parameters in the compiled SQL statement to NULL.
+*/
+int sqlite3_clear_bindings(sqlite3_stmt*);
+
+/*
+** Return the number of columns in the result set returned by the compiled
+** SQL statement. This routine returns 0 if pStmt is an SQL statement
+** that does not return data (for example an UPDATE).
+*/
+int sqlite3_column_count(sqlite3_stmt *pStmt);
+
+/*
+** The first parameter is a compiled SQL statement. This function returns
+** the column heading for the Nth column of that statement, where N is the
+** second function parameter.  The string returned is UTF-8 for
+** sqlite3_column_name() and UTF-16 for sqlite3_column_name16().
+*/
+const char *sqlite3_column_name(sqlite3_stmt*,int);
+const void *sqlite3_column_name16(sqlite3_stmt*,int);
+
+/*
+** The first parameter to the following calls is a compiled SQL statement.
+** These functions return information about the Nth column returned by 
+** the statement, where N is the second function argument.
+**
+** If the Nth column returned by the statement is not a column value,
+** then all of the functions return NULL. Otherwise, the return the 
+** name of the attached database, table and column that the expression
+** extracts a value from.
+**
+** As with all other SQLite APIs, those postfixed with "16" return UTF-16
+** encoded strings, the other functions return UTF-8. The memory containing
+** the returned strings is valid until the statement handle is finalized().
+**
+** These APIs are only available if the library was compiled with the 
+** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
+*/
+const char *sqlite3_column_database_name(sqlite3_stmt*,int);
+const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
+const char *sqlite3_column_table_name(sqlite3_stmt*,int);
+const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
+const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
+const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
+
+/*
+** The first parameter is a compiled SQL statement. If this statement
+** is a SELECT statement, the Nth column of the returned result set 
+** of the SELECT is a table column then the declared type of the table
+** column is returned. If the Nth column of the result set is not at table
+** column, then a NULL pointer is returned. The returned string is always
+** UTF-8 encoded. For example, in the database schema:
+**
+** CREATE TABLE t1(c1 VARIANT);
+**
+** And the following statement compiled:
+**
+** SELECT c1 + 1, c1 FROM t1;
+**
+** Then this routine would return the string "VARIANT" for the second
+** result column (i==1), and a NULL pointer for the first result column
+** (i==0).
+*/
+const char *sqlite3_column_decltype(sqlite3_stmt *, int i);
+
+/*
+** The first parameter is a compiled SQL statement. If this statement
+** is a SELECT statement, the Nth column of the returned result set 
+** of the SELECT is a table column then the declared type of the table
+** column is returned. If the Nth column of the result set is not at table
+** column, then a NULL pointer is returned. The returned string is always
+** UTF-16 encoded. For example, in the database schema:
+**
+** CREATE TABLE t1(c1 INTEGER);
+**
+** And the following statement compiled:
+**
+** SELECT c1 + 1, c1 FROM t1;
+**
+** Then this routine would return the string "INTEGER" for the second
+** result column (i==1), and a NULL pointer for the first result column
+** (i==0).
+*/
+const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
+
+/* 
+** After an SQL query has been compiled with a call to either
+** sqlite3_prepare() or sqlite3_prepare16(), then this function must be
+** called one or more times to execute the statement.
+**
+** The return value will be either SQLITE_BUSY, SQLITE_DONE, 
+** SQLITE_ROW, SQLITE_ERROR, or SQLITE_MISUSE.
+**
+** SQLITE_BUSY means that the database engine attempted to open
+** a locked database and there is no busy callback registered.
+** Call sqlite3_step() again to retry the open.
+**
+** SQLITE_DONE means that the statement has finished executing
+** successfully.  sqlite3_step() should not be called again on this virtual
+** machine.
+**
+** If the SQL statement being executed returns any data, then 
+** SQLITE_ROW is returned each time a new row of data is ready
+** for processing by the caller. The values may be accessed using
+** the sqlite3_column_*() functions described below. sqlite3_step()
+** is called again to retrieve the next row of data.
+** 
+** SQLITE_ERROR means that a run-time error (such as a constraint
+** violation) has occurred.  sqlite3_step() should not be called again on
+** the VM. More information may be found by calling sqlite3_errmsg().
+**
+** SQLITE_MISUSE means that the this routine was called inappropriately.
+** Perhaps it was called on a virtual machine that had already been
+** finalized or on one that had previously returned SQLITE_ERROR or
+** SQLITE_DONE.  Or it could be the case the the same database connection
+** is being used simulataneously by two or more threads.
+*/
+int sqlite3_step(sqlite3_stmt*);
+
+/*
+** Return the number of values in the current row of the result set.
+**
+** After a call to sqlite3_step() that returns SQLITE_ROW, this routine
+** will return the same value as the sqlite3_column_count() function.
+** After sqlite3_step() has returned an SQLITE_DONE, SQLITE_BUSY or
+** error code, or before sqlite3_step() has been called on a 
+** compiled SQL statement, this routine returns zero.
+*/
+int sqlite3_data_count(sqlite3_stmt *pStmt);
+
+/*
+** Values are stored in the database in one of the following fundamental
+** types.
+*/
+#define SQLITE_INTEGER  1
+#define SQLITE_FLOAT    2
+/* #define SQLITE_TEXT  3  // See below */
+#define SQLITE_BLOB     4
+#define SQLITE_NULL     5
+
+/*
+** SQLite version 2 defines SQLITE_TEXT differently.  To allow both
+** version 2 and version 3 to be included, undefine them both if a
+** conflict is seen.  Define SQLITE3_TEXT to be the version 3 value.
+*/
+#ifdef SQLITE_TEXT
+# undef SQLITE_TEXT
+#else
+# define SQLITE_TEXT     3
+#endif
+#define SQLITE3_TEXT     3
+
+/*
+** The next group of routines returns information about the information
+** in a single column of the current result row of a query.  In every
+** case the first parameter is a pointer to the SQL statement that is being
+** executed (the sqlite_stmt* that was returned from sqlite3_prepare()) and
+** the second argument is the index of the column for which information 
+** should be returned.  iCol is zero-indexed.  The left-most column as an
+** index of 0.
+**
+** If the SQL statement is not currently point to a valid row, or if the
+** the colulmn index is out of range, the result is undefined.
+**
+** These routines attempt to convert the value where appropriate.  For
+** example, if the internal representation is FLOAT and a text result
+** is requested, sprintf() is used internally to do the conversion
+** automatically.  The following table details the conversions that
+** are applied:
+**
+**    Internal Type    Requested Type     Conversion
+**    -------------    --------------    --------------------------
+**       NULL             INTEGER         Result is 0
+**       NULL             FLOAT           Result is 0.0
+**       NULL             TEXT            Result is an empty string
+**       NULL             BLOB            Result is a zero-length BLOB
+**       INTEGER          FLOAT           Convert from integer to float
+**       INTEGER          TEXT            ASCII rendering of the integer
+**       INTEGER          BLOB            Same as for INTEGER->TEXT
+**       FLOAT            INTEGER         Convert from float to integer
+**       FLOAT            TEXT            ASCII rendering of the float
+**       FLOAT            BLOB            Same as FLOAT->TEXT
+**       TEXT             INTEGER         Use atoi()
+**       TEXT             FLOAT           Use atof()
+**       TEXT             BLOB            No change
+**       BLOB             INTEGER         Convert to TEXT then use atoi()
+**       BLOB             FLOAT           Convert to TEXT then use atof()
+**       BLOB             TEXT            Add a \000 terminator if needed
+**
+** The following access routines are provided:
+**
+** _type()     Return the datatype of the result.  This is one of
+**             SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB,
+**             or SQLITE_NULL.
+** _blob()     Return the value of a BLOB.
+** _bytes()    Return the number of bytes in a BLOB value or the number
+**             of bytes in a TEXT value represented as UTF-8.  The \000
+**             terminator is included in the byte count for TEXT values.
+** _bytes16()  Return the number of bytes in a BLOB value or the number
+**             of bytes in a TEXT value represented as UTF-16.  The \u0000
+**             terminator is included in the byte count for TEXT values.
+** _double()   Return a FLOAT value.
+** _int()      Return an INTEGER value in the host computer's native
+**             integer representation.  This might be either a 32- or 64-bit
+**             integer depending on the host.
+** _int64()    Return an INTEGER value as a 64-bit signed integer.
+** _text()     Return the value as UTF-8 text.
+** _text16()   Return the value as UTF-16 text.
+*/
+const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
+int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
+int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
+double sqlite3_column_double(sqlite3_stmt*, int iCol);
+int sqlite3_column_int(sqlite3_stmt*, int iCol);
+sqlite_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
+const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
+const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
+int sqlite3_column_type(sqlite3_stmt*, int iCol);
+int sqlite3_column_numeric_type(sqlite3_stmt*, int iCol);
+sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
+
+/*
+** The sqlite3_finalize() function is called to delete a compiled
+** SQL statement obtained by a previous call to sqlite3_prepare()
+** or sqlite3_prepare16(). If the statement was executed successfully, or
+** not executed at all, then SQLITE_OK is returned. If execution of the
+** statement failed then an error code is returned. 
+**
+** This routine can be called at any point during the execution of the
+** virtual machine.  If the virtual machine has not completed execution
+** when this routine is called, that is like encountering an error or
+** an interrupt.  (See sqlite3_interrupt().)  Incomplete updates may be
+** rolled back and transactions cancelled,  depending on the circumstances,
+** and the result code returned will be SQLITE_ABORT.
+*/
+int sqlite3_finalize(sqlite3_stmt *pStmt);
+
+/*
+** The sqlite3_reset() function is called to reset a compiled SQL
+** statement obtained by a previous call to sqlite3_prepare() or
+** sqlite3_prepare16() back to it's initial state, ready to be re-executed.
+** Any SQL statement variables that had values bound to them using
+** the sqlite3_bind_*() API retain their values.
+*/
+int sqlite3_reset(sqlite3_stmt *pStmt);
+
+/*
+** The following two functions are used to add user functions or aggregates
+** implemented in C to the SQL langauge interpreted by SQLite. The
+** difference only between the two is that the second parameter, the
+** name of the (scalar) function or aggregate, is encoded in UTF-8 for
+** sqlite3_create_function() and UTF-16 for sqlite3_create_function16().
+**
+** The first argument is the database handle that the new function or
+** aggregate is to be added to. If a single program uses more than one
+** database handle internally, then user functions or aggregates must 
+** be added individually to each database handle with which they will be
+** used.
+**
+** The third parameter is the number of arguments that the function or
+** aggregate takes. If this parameter is negative, then the function or
+** aggregate may take any number of arguments.
+**
+** The fourth parameter is one of SQLITE_UTF* values defined below,
+** indicating the encoding that the function is most likely to handle
+** values in.  This does not change the behaviour of the programming
+** interface. However, if two versions of the same function are registered
+** with different encoding values, SQLite invokes the version likely to
+** minimize conversions between text encodings.
+**
+** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
+** pointers to user implemented C functions that implement the user
+** function or aggregate. A scalar function requires an implementation of
+** the xFunc callback only, NULL pointers should be passed as the xStep
+** and xFinal parameters. An aggregate function requires an implementation
+** of xStep and xFinal, but NULL should be passed for xFunc. To delete an
+** existing user function or aggregate, pass NULL for all three function
+** callback. Specifying an inconstent set of callback values, such as an
+** xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is
+** returned.
+*/
+int sqlite3_create_function(
+  sqlite3 *,
+  const char *zFunctionName,
+  int nArg,
+  int eTextRep,
+  void*,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
+  void (*xFinal)(sqlite3_context*)
+);
+int sqlite3_create_function16(
+  sqlite3*,
+  const void *zFunctionName,
+  int nArg,
+  int eTextRep,
+  void*,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
+  void (*xFinal)(sqlite3_context*)
+);
+
+/*
+** This function is deprecated.  Do not use it.  It continues to exist
+** so as not to break legacy code.  But new code should avoid using it.
+*/
+int sqlite3_aggregate_count(sqlite3_context*);
+
+/*
+** The next group of routines returns information about parameters to
+** a user-defined function.  Function implementations use these routines
+** to access their parameters.  These routines are the same as the
+** sqlite3_column_* routines except that these routines take a single
+** sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
+** column number.
+*/
+const void *sqlite3_value_blob(sqlite3_value*);
+int sqlite3_value_bytes(sqlite3_value*);
+int sqlite3_value_bytes16(sqlite3_value*);
+double sqlite3_value_double(sqlite3_value*);
+int sqlite3_value_int(sqlite3_value*);
+sqlite_int64 sqlite3_value_int64(sqlite3_value*);
+const unsigned char *sqlite3_value_text(sqlite3_value*);
+const void *sqlite3_value_text16(sqlite3_value*);
+const void *sqlite3_value_text16le(sqlite3_value*);
+const void *sqlite3_value_text16be(sqlite3_value*);
+int sqlite3_value_type(sqlite3_value*);
+int sqlite3_value_numeric_type(sqlite3_value*);
+
+/*
+** Aggregate functions use the following routine to allocate
+** a structure for storing their state.  The first time this routine
+** is called for a particular aggregate, a new structure of size nBytes
+** is allocated, zeroed, and returned.  On subsequent calls (for the
+** same aggregate instance) the same buffer is returned.  The implementation
+** of the aggregate can use the returned buffer to accumulate data.
+**
+** The buffer allocated is freed automatically by SQLite.
+*/
+void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
+
+/*
+** The pUserData parameter to the sqlite3_create_function()
+** routine used to register user functions is available to
+** the implementation of the function using this call.
+*/
+void *sqlite3_user_data(sqlite3_context*);
+
+/*
+** The following two functions may be used by scalar user functions to
+** associate meta-data with argument values. If the same value is passed to
+** multiple invocations of the user-function during query execution, under
+** some circumstances the associated meta-data may be preserved. This may
+** be used, for example, to add a regular-expression matching scalar
+** function. The compiled version of the regular expression is stored as
+** meta-data associated with the SQL value passed as the regular expression
+** pattern.
+**
+** Calling sqlite3_get_auxdata() returns a pointer to the meta data
+** associated with the Nth argument value to the current user function
+** call, where N is the second parameter. If no meta-data has been set for
+** that value, then a NULL pointer is returned.
+**
+** The sqlite3_set_auxdata() is used to associate meta data with a user
+** function argument. The third parameter is a pointer to the meta data
+** to be associated with the Nth user function argument value. The fourth
+** parameter specifies a 'delete function' that will be called on the meta
+** data pointer to release it when it is no longer required. If the delete
+** function pointer is NULL, it is not invoked.
+**
+** In practice, meta-data is preserved between function calls for
+** expressions that are constant at compile time. This includes literal
+** values and SQL variables.
+*/
+void *sqlite3_get_auxdata(sqlite3_context*, int);
+void sqlite3_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));
+
+
+/*
+** These are special value for the destructor that is passed in as the
+** final argument to routines like sqlite3_result_blob().  If the destructor
+** argument is SQLITE_STATIC, it means that the content pointer is constant
+** and will never change.  It does not need to be destroyed.  The 
+** SQLITE_TRANSIENT value means that the content will likely change in
+** the near future and that SQLite should make its own private copy of
+** the content before returning.
+*/
+#define SQLITE_STATIC      ((void(*)(void *))0)
+#define SQLITE_TRANSIENT   ((void(*)(void *))-1)
+
+/*
+** User-defined functions invoke the following routines in order to
+** set their return value.
+*/
+void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
+void sqlite3_result_double(sqlite3_context*, double);
+void sqlite3_result_error(sqlite3_context*, const char*, int);
+void sqlite3_result_error16(sqlite3_context*, const void*, int);
+void sqlite3_result_int(sqlite3_context*, int);
+void sqlite3_result_int64(sqlite3_context*, sqlite_int64);
+void sqlite3_result_null(sqlite3_context*);
+void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
+void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
+void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
+void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
+void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+
+/*
+** These are the allowed values for the eTextRep argument to
+** sqlite3_create_collation and sqlite3_create_function.
+*/
+#define SQLITE_UTF8           1
+#define SQLITE_UTF16LE        2
+#define SQLITE_UTF16BE        3
+#define SQLITE_UTF16          4    /* Use native byte order */
+#define SQLITE_ANY            5    /* sqlite3_create_function only */
+#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
+
+/*
+** These two functions are used to add new collation sequences to the
+** sqlite3 handle specified as the first argument. 
+**
+** The name of the new collation sequence is specified as a UTF-8 string
+** for sqlite3_create_collation() and a UTF-16 string for
+** sqlite3_create_collation16(). In both cases the name is passed as the
+** second function argument.
+**
+** The third argument must be one of the constants SQLITE_UTF8,
+** SQLITE_UTF16LE or SQLITE_UTF16BE, indicating that the user-supplied
+** routine expects to be passed pointers to strings encoded using UTF-8,
+** UTF-16 little-endian or UTF-16 big-endian respectively.
+**
+** A pointer to the user supplied routine must be passed as the fifth
+** argument. If it is NULL, this is the same as deleting the collation
+** sequence (so that SQLite cannot call it anymore). Each time the user
+** supplied function is invoked, it is passed a copy of the void* passed as
+** the fourth argument to sqlite3_create_collation() or
+** sqlite3_create_collation16() as its first parameter.
+**
+** The remaining arguments to the user-supplied routine are two strings,
+** each represented by a [length, data] pair and encoded in the encoding
+** that was passed as the third argument when the collation sequence was
+** registered. The user routine should return negative, zero or positive if
+** the first string is less than, equal to, or greater than the second
+** string. i.e. (STRING1 - STRING2).
+*/
+int sqlite3_create_collation(
+  sqlite3*, 
+  const char *zName, 
+  int eTextRep, 
+  void*,
+  int(*xCompare)(void*,int,const void*,int,const void*)
+);
+int sqlite3_create_collation16(
+  sqlite3*, 
+  const char *zName, 
+  int eTextRep, 
+  void*,
+  int(*xCompare)(void*,int,const void*,int,const void*)
+);
+
+/*
+** To avoid having to register all collation sequences before a database
+** can be used, a single callback function may be registered with the
+** database handle to be called whenever an undefined collation sequence is
+** required.
+**
+** If the function is registered using the sqlite3_collation_needed() API,
+** then it is passed the names of undefined collation sequences as strings
+** encoded in UTF-8. If sqlite3_collation_needed16() is used, the names
+** are passed as UTF-16 in machine native byte order. A call to either
+** function replaces any existing callback.
+**
+** When the user-function is invoked, the first argument passed is a copy
+** of the second argument to sqlite3_collation_needed() or
+** sqlite3_collation_needed16(). The second argument is the database
+** handle. The third argument is one of SQLITE_UTF8, SQLITE_UTF16BE or
+** SQLITE_UTF16LE, indicating the most desirable form of the collation
+** sequence function required. The fourth parameter is the name of the
+** required collation sequence.
+**
+** The collation sequence is returned to SQLite by a collation-needed
+** callback using the sqlite3_create_collation() or
+** sqlite3_create_collation16() APIs, described above.
+*/
+int sqlite3_collation_needed(
+  sqlite3*, 
+  void*, 
+  void(*)(void*,sqlite3*,int eTextRep,const char*)
+);
+int sqlite3_collation_needed16(
+  sqlite3*, 
+  void*,
+  void(*)(void*,sqlite3*,int eTextRep,const void*)
+);
+
+/*
+** Specify the key for an encrypted database.  This routine should be
+** called right after sqlite3_open().
+**
+** The code to implement this API is not available in the public release
+** of SQLite.
+*/
+int sqlite3_key(
+  sqlite3 *db,                   /* Database to be rekeyed */
+  const void *pKey, int nKey     /* The key */
+);
+
+/*
+** Change the key on an open database.  If the current database is not
+** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
+** database is decrypted.
+**
+** The code to implement this API is not available in the public release
+** of SQLite.
+*/
+int sqlite3_rekey(
+  sqlite3 *db,                   /* Database to be rekeyed */
+  const void *pKey, int nKey     /* The new key */
+);
+
+/*
+** Sleep for a little while. The second parameter is the number of
+** miliseconds to sleep for. 
+**
+** If the operating system does not support sleep requests with 
+** milisecond time resolution, then the time will be rounded up to 
+** the nearest second. The number of miliseconds of sleep actually 
+** requested from the operating system is returned.
+*/
+int sqlite3_sleep(int);
+
+/*
+** Return TRUE (non-zero) if the statement supplied as an argument needs
+** to be recompiled.  A statement needs to be recompiled whenever the
+** execution environment changes in a way that would alter the program
+** that sqlite3_prepare() generates.  For example, if new functions or
+** collating sequences are registered or if an authorizer function is
+** added or changed.
+**
+*/
+int sqlite3_expired(sqlite3_stmt*);
+
+/*
+** Move all bindings from the first prepared statement over to the second.
+** This routine is useful, for example, if the first prepared statement
+** fails with an SQLITE_SCHEMA error.  The same SQL can be prepared into
+** the second prepared statement then all of the bindings transfered over
+** to the second statement before the first statement is finalized.
+*/
+int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
+
+/*
+** If the following global variable is made to point to a
+** string which is the name of a directory, then all temporary files
+** created by SQLite will be placed in that directory.  If this variable
+** is NULL pointer, then SQLite does a search for an appropriate temporary
+** file directory.
+**
+** Once sqlite3_open() has been called, changing this variable will invalidate
+** the current temporary database, if any.
+*/
+extern char *sqlite3_temp_directory;
+
+/*
+** This function is called to recover from a malloc() failure that occured
+** within the SQLite library. Normally, after a single malloc() fails the 
+** library refuses to function (all major calls return SQLITE_NOMEM).
+** This function restores the library state so that it can be used again.
+**
+** All existing statements (sqlite3_stmt pointers) must be finalized or
+** reset before this call is made. Otherwise, SQLITE_BUSY is returned.
+** If any in-memory databases are in use, either as a main or TEMP
+** database, SQLITE_ERROR is returned. In either of these cases, the 
+** library is not reset and remains unusable.
+**
+** This function is *not* threadsafe. Calling this from within a threaded
+** application when threads other than the caller have used SQLite is
+** dangerous and will almost certainly result in malfunctions.
+**
+** This functionality can be omitted from a build by defining the 
+** SQLITE_OMIT_GLOBALRECOVER at compile time.
+*/
+int sqlite3_global_recover(void);
+
+/*
+** Test to see whether or not the database connection is in autocommit
+** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
+** by default.  Autocommit is disabled by a BEGIN statement and reenabled
+** by the next COMMIT or ROLLBACK.
+*/
+int sqlite3_get_autocommit(sqlite3*);
+
+/*
+** Return the sqlite3* database handle to which the prepared statement given
+** in the argument belongs.  This is the same database handle that was
+** the first argument to the sqlite3_prepare() that was used to create
+** the statement in the first place.
+*/
+sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
+
+/*
+** Register a callback function with the database connection identified by the 
+** first argument to be invoked whenever a row is updated, inserted or deleted.
+** Any callback set by a previous call to this function for the same 
+** database connection is overridden.
+**
+** The second argument is a pointer to the function to invoke when a 
+** row is updated, inserted or deleted. The first argument to the callback is
+** a copy of the third argument to sqlite3_update_hook. The second callback 
+** argument is one of SQLITE_INSERT, SQLITE_DELETE or SQLITE_UPDATE, depending
+** on the operation that caused the callback to be invoked. The third and 
+** fourth arguments to the callback contain pointers to the database and 
+** table name containing the affected row. The final callback parameter is 
+** the rowid of the row. In the case of an update, this is the rowid after 
+** the update takes place.
+**
+** The update hook is not invoked when internal system tables are
+** modified (i.e. sqlite_master and sqlite_sequence).
+**
+** If another function was previously registered, its pArg value is returned.
+** Otherwise NULL is returned.
+*/
+void *sqlite3_update_hook(
+  sqlite3*, 
+  void(*)(void *,int ,char const *,char const *,sqlite_int64),
+  void*
+);
+
+/*
+** Register a callback to be invoked whenever a transaction is rolled
+** back. 
+**
+** The new callback function overrides any existing rollback-hook
+** callback. If there was an existing callback, then it's pArg value 
+** (the third argument to sqlite3_rollback_hook() when it was registered) 
+** is returned. Otherwise, NULL is returned.
+**
+** For the purposes of this API, a transaction is said to have been 
+** rolled back if an explicit "ROLLBACK" statement is executed, or
+** an error or constraint causes an implicit rollback to occur. The 
+** callback is not invoked if a transaction is automatically rolled
+** back because the database connection is closed.
+*/
+void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
+
+/*
+** This function is only available if the library is compiled without
+** the SQLITE_OMIT_SHARED_CACHE macro defined. It is used to enable or
+** disable (if the argument is true or false, respectively) the 
+** "shared pager" feature.
+*/
+int sqlite3_enable_shared_cache(int);
+
+/*
+** Attempt to free N bytes of heap memory by deallocating non-essential
+** memory allocations held by the database library (example: memory 
+** used to cache database pages to improve performance).
+**
+** This function is not a part of standard builds.  It is only created
+** if SQLite is compiled with the SQLITE_ENABLE_MEMORY_MANAGEMENT macro.
+*/
+int sqlite3_release_memory(int);
+
+/*
+** Place a "soft" limit on the amount of heap memory that may be allocated by
+** SQLite within the current thread. If an internal allocation is requested 
+** that would exceed the specified limit, sqlite3_release_memory() is invoked
+** one or more times to free up some space before the allocation is made.
+**
+** The limit is called "soft", because if sqlite3_release_memory() cannot free
+** sufficient memory to prevent the limit from being exceeded, the memory is
+** allocated anyway and the current operation proceeds.
+**
+** This function is only available if the library was compiled with the 
+** SQLITE_ENABLE_MEMORY_MANAGEMENT option set.
+** memory-management has been enabled.
+*/
+void sqlite3_soft_heap_limit(int);
+
+/*
+** This routine makes sure that all thread-local storage has been
+** deallocated for the current thread.
+**
+** This routine is not technically necessary.  All thread-local storage
+** will be automatically deallocated once memory-management and
+** shared-cache are disabled and the soft heap limit has been set
+** to zero.  This routine is provided as a convenience for users who
+** want to make absolutely sure they have not forgotten something
+** prior to killing off a thread.
+*/
+void sqlite3_thread_cleanup(void);
+
+/*
+** Return meta information about a specific column of a specific database
+** table accessible using the connection handle passed as the first function 
+** argument.
+**
+** The column is identified by the second, third and fourth parameters to 
+** this function. The second parameter is either the name of the database
+** (i.e. "main", "temp" or an attached database) containing the specified
+** table or NULL. If it is NULL, then all attached databases are searched
+** for the table using the same algorithm as the database engine uses to 
+** resolve unqualified table references.
+**
+** The third and fourth parameters to this function are the table and column 
+** name of the desired column, respectively. Neither of these parameters 
+** may be NULL.
+**
+** Meta information is returned by writing to the memory locations passed as
+** the 5th and subsequent parameters to this function. Any of these 
+** arguments may be NULL, in which case the corresponding element of meta 
+** information is ommitted.
+**
+** Parameter     Output Type      Description
+** -----------------------------------
+**
+**   5th         const char*      Data type
+**   6th         const char*      Name of the default collation sequence 
+**   7th         int              True if the column has a NOT NULL constraint
+**   8th         int              True if the column is part of the PRIMARY KEY
+**   9th         int              True if the column is AUTOINCREMENT
+**
+**
+** The memory pointed to by the character pointers returned for the 
+** declaration type and collation sequence is valid only until the next 
+** call to any sqlite API function.
+**
+** If the specified table is actually a view, then an error is returned.
+**
+** If the specified column is "rowid", "oid" or "_rowid_" and an 
+** INTEGER PRIMARY KEY column has been explicitly declared, then the output 
+** parameters are set for the explicitly declared column. If there is no
+** explicitly declared IPK column, then the output parameters are set as 
+** follows:
+**
+**     data type: "INTEGER"
+**     collation sequence: "BINARY"
+**     not null: 0
+**     primary key: 1
+**     auto increment: 0
+**
+** This function may load one or more schemas from database files. If an
+** error occurs during this process, or if the requested table or column
+** cannot be found, an SQLITE error code is returned and an error message
+** left in the database handle (to be retrieved using sqlite3_errmsg()).
+**
+** This API is only available if the library was compiled with the
+** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
+*/
+int sqlite3_table_column_metadata(
+  sqlite3 *db,                /* Connection handle */
+  const char *zDbName,        /* Database name or NULL */
+  const char *zTableName,     /* Table name */
+  const char *zColumnName,    /* Column name */
+  char const **pzDataType,    /* OUTPUT: Declared data type */
+  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
+  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
+  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
+  int *pAutoinc               /* OUTPUT: True if colums is auto-increment */
+);
+
+/*
+****** EXPERIMENTAL - subject to change without notice **************
+**
+** Attempt to load an SQLite extension library contained in the file
+** zFile.  The entry point is zProc.  zProc may be 0 in which case the
+** name of the entry point defaults to "sqlite3_extension_init".
+**
+** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.
+**
+** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with 
+** error message text.  The calling function should free this memory
+** by calling sqlite3_free().
+**
+** Extension loading must be enabled using sqlite3_enable_load_extension()
+** prior to calling this API or an error will be returned.
+**
+****** EXPERIMENTAL - subject to change without notice **************
+*/
+int sqlite3_load_extension(
+  sqlite3 *db,          /* Load the extension into this database connection */
+  const char *zFile,    /* Name of the shared library containing extension */
+  const char *zProc,    /* Entry point.  Derived from zFile if 0 */
+  char **pzErrMsg       /* Put error message here if not 0 */
+);
+
+/*
+** So as not to open security holes in older applications that are
+** unprepared to deal with extension load, and as a means of disabling
+** extension loading while executing user-entered SQL, the following
+** API is provided to turn the extension loading mechanism on and
+** off.  It is off by default.  See ticket #1863.
+**
+** Call this routine with onoff==1 to turn extension loading on
+** and call it with onoff==0 to turn it back off again.
+*/
+int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
+
+/*
+****** EXPERIMENTAL - subject to change without notice **************
+**
+** The interface to the virtual-table mechanism is currently considered
+** to be experimental.  The interface might change in incompatible ways.
+** If this is a problem for you, do not use the interface at this time.
+**
+** When the virtual-table mechanism stablizes, we will declare the
+** interface fixed, support it indefinitely, and remove this comment.
+*/
+
+/*
+** Structures used by the virtual table interface
+*/
+typedef struct sqlite3_vtab sqlite3_vtab;
+typedef struct sqlite3_index_info sqlite3_index_info;
+typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
+typedef struct sqlite3_module sqlite3_module;
+
+/*
+** A module is a class of virtual tables.  Each module is defined
+** by an instance of the following structure.  This structure consists
+** mostly of methods for the module.
+*/
+struct sqlite3_module {
+  int iVersion;
+  int (*xCreate)(sqlite3*, void *pAux,
+               int argc, char **argv,
+               sqlite3_vtab **ppVTab);
+  int (*xConnect)(sqlite3*, void *pAux,
+               int argc, char **argv,
+               sqlite3_vtab **ppVTab);
+  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
+  int (*xDisconnect)(sqlite3_vtab *pVTab);
+  int (*xDestroy)(sqlite3_vtab *pVTab);
+  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
+  int (*xClose)(sqlite3_vtab_cursor*);
+  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
+                int argc, sqlite3_value **argv);
+  int (*xNext)(sqlite3_vtab_cursor*);
+  int (*xEof)(sqlite3_vtab_cursor*);
+  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
+  int (*xRowid)(sqlite3_vtab_cursor*, sqlite_int64 *pRowid);
+  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite_int64 *);
+  int (*xBegin)(sqlite3_vtab *pVTab);
+  int (*xSync)(sqlite3_vtab *pVTab);
+  int (*xCommit)(sqlite3_vtab *pVTab);
+  int (*xRollback)(sqlite3_vtab *pVTab);
+  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
+                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
+                       void **ppArg);
+};
+
+/*
+** The sqlite3_index_info structure and its substructures is used to
+** pass information into and receive the reply from the xBestIndex
+** method of an sqlite3_module.  The fields under **Inputs** are the
+** inputs to xBestIndex and are read-only.  xBestIndex inserts its
+** results into the **Outputs** fields.
+**
+** The aConstraint[] array records WHERE clause constraints of the
+** form:
+**
+**         column OP expr
+**
+** Where OP is =, <, <=, >, or >=.  The particular operator is stored
+** in aConstraint[].op.  The index of the column is stored in 
+** aConstraint[].iColumn.  aConstraint[].usable is TRUE if the
+** expr on the right-hand side can be evaluated (and thus the constraint
+** is usable) and false if it cannot.
+**
+** The optimizer automatically inverts terms of the form "expr OP column"
+** and makes other simplificatinos to the WHERE clause in an attempt to
+** get as many WHERE clause terms into the form shown above as possible.
+** The aConstraint[] array only reports WHERE clause terms in the correct
+** form that refer to the particular virtual table being queried.
+**
+** Information about the ORDER BY clause is stored in aOrderBy[].
+** Each term of aOrderBy records a column of the ORDER BY clause.
+**
+** The xBestIndex method must fill aConstraintUsage[] with information
+** about what parameters to pass to xFilter.  If argvIndex>0 then
+** the right-hand side of the corresponding aConstraint[] is evaluated
+** and becomes the argvIndex-th entry in argv.  If aConstraintUsage[].omit
+** is true, then the constraint is assumed to be fully handled by the
+** virtual table and is not checked again by SQLite.
+**
+** The idxNum and idxPtr values are recorded and passed into xFilter.
+** sqlite3_free() is used to free idxPtr if needToFreeIdxPtr is true.
+**
+** The orderByConsumed means that output from xFilter will occur in
+** the correct order to satisfy the ORDER BY clause so that no separate
+** sorting step is required.
+**
+** The estimatedCost value is an estimate of the cost of doing the
+** particular lookup.  A full scan of a table with N entries should have
+** a cost of N.  A binary search of a table of N entries should have a
+** cost of approximately log(N).
+*/
+struct sqlite3_index_info {
+  /* Inputs */
+  const int nConstraint;     /* Number of entries in aConstraint */
+  const struct sqlite3_index_constraint {
+     int iColumn;              /* Column on left-hand side of constraint */
+     unsigned char op;         /* Constraint operator */
+     unsigned char usable;     /* True if this constraint is usable */
+     int iTermOffset;          /* Used internally - xBestIndex should ignore */
+  } *const aConstraint;      /* Table of WHERE clause constraints */
+  const int nOrderBy;        /* Number of terms in the ORDER BY clause */
+  const struct sqlite3_index_orderby {
+     int iColumn;              /* Column number */
+     unsigned char desc;       /* True for DESC.  False for ASC. */
+  } *const aOrderBy;         /* The ORDER BY clause */
+
+  /* Outputs */
+  struct sqlite3_index_constraint_usage {
+    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
+    unsigned char omit;      /* Do not code a test for this constraint */
+  } *const aConstraintUsage;
+  int idxNum;                /* Number used to identify the index */
+  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
+  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
+  int orderByConsumed;       /* True if output is already ordered */
+  double estimatedCost;      /* Estimated cost of using this index */
+};
+#define SQLITE_INDEX_CONSTRAINT_EQ    2
+#define SQLITE_INDEX_CONSTRAINT_GT    4
+#define SQLITE_INDEX_CONSTRAINT_LE    8
+#define SQLITE_INDEX_CONSTRAINT_LT    16
+#define SQLITE_INDEX_CONSTRAINT_GE    32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+
+/*
+** This routine is used to register a new module name with an SQLite
+** connection.  Module names must be registered before creating new
+** virtual tables on the module, or before using preexisting virtual
+** tables of the module.
+*/
+int sqlite3_create_module(
+  sqlite3 *db,               /* SQLite connection to register module with */
+  const char *zName,         /* Name of the module */
+  const sqlite3_module *,    /* Methods for the module */
+  void *                     /* Client data for xCreate/xConnect */
+);
+
+/*
+** Every module implementation uses a subclass of the following structure
+** to describe a particular instance of the module.  Each subclass will
+** be taylored to the specific needs of the module implementation.   The
+** purpose of this superclass is to define certain fields that are common
+** to all module implementations.
+*/
+struct sqlite3_vtab {
+  const sqlite3_module *pModule;  /* The module for this virtual table */
+  int nRef;                       /* Used internally */
+  /* Virtual table implementations will typically add additional fields */
+};
+
+/* Every module implementation uses a subclass of the following structure
+** to describe cursors that point into the virtual table and are used
+** to loop through the virtual table.  Cursors are created using the
+** xOpen method of the module.  Each module implementation will define
+** the content of a cursor structure to suit its own needs.
+**
+** This superclass exists in order to define fields of the cursor that
+** are common to all implementations.
+*/
+struct sqlite3_vtab_cursor {
+  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
+  /* Virtual table implementations will typically add additional fields */
+};
+
+/*
+** The xCreate and xConnect methods of a module use the following API
+** to declare the format (the names and datatypes of the columns) of
+** the virtual tables they implement.
+*/
+int sqlite3_declare_vtab(sqlite3*, const char *zCreateTable);
+
+/*
+** The interface to the virtual-table mechanism defined above (back up
+** to a comment remarkably similar to this one) is currently considered
+** to be experimental.  The interface might change in incompatible ways.
+** If this is a problem for you, do not use the interface at this time.
+**
+** When the virtual-table mechanism stablizes, we will declare the
+** interface fixed, support it indefinitely, and remove this comment.
+**
+****** EXPERIMENTAL - subject to change without notice **************
+*/
+
+/*
+** Undo the hack that converts floating point types to integer for
+** builds on processors without floating point support.
+*/
+#ifdef SQLITE_OMIT_FLOATING_POINT
+# undef double
+#endif
+
+#ifdef __cplusplus
+}  /* End of the 'extern "C"' block */
+#endif
+#endif
+
+
diff --git a/libvmodem/tapi4phonebook.h b/libvmodem/tapi4phonebook.h
new file mode 100644 (file)
index 0000000..f1c43ba
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _TAPI4PHONEBOOK_H_
+#define _TAPI4PHONEBOOK_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+
+
+
+
+
+
+
+
+
+
+
+#define MAX_ALPHA_SIZE                                                      32
+#define MAX_DIGITS_SIZE                                                     32
+#define MAX_PHONEBOOK_ITEM                                                 256
+
+typedef enum
+{
+    LXT_PHONEBOOK_PBM_DEFAULT   =       0x00,       // do not use
+    LXT_PHONEBOOK_PBM_SLOT1_ADN =       0x01,       // adn of slot1
+    LXT_PHONEBOOK_PBM_SLOT2_ADN =       0x02,       // adn of slot2
+    LXT_PHONEBOOK_PBM_SLOT1_FDN =       0x03,       // fdn of slot1
+    LXT_PHONEBOOK_PBM_SLOT2_FDN =       0x04,       // fdn of slot2
+    LXT_PHONEBOOK_PBM_MAX       =       0x05,       // do not use
+    LXT_PHONEBOOK_PBM_EOT       =       0x0f        // do not use
+}
+LXT_PHONEBOOK_PBM;
+
+
+// card phone book
+typedef struct
+{
+    int index;                          // 4  byte
+    int alpha_size;                     // 4  byte
+    int num_digits;                     // 4  byte
+    char alpha[MAX_ALPHA_SIZE];         // 32 byte
+    char digits[MAX_DIGITS_SIZE];       // 32 byte
+}
+LXT_PHONEBOOK_ONE_ITEM;
+
+// phone book set
+typedef struct
+{
+    int mpb_id;                         // 4  byte
+    int num_total;                      // 4  byte
+    int num_used;                       // 4  byte
+    int max_entry_alpha_size;           // 4  byte
+    LXT_PHONEBOOK_ONE_ITEM phonebook_item[MAX_PHONEBOOK_ITEM];
+}
+LXT_PHONEBOOK_ALL;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _TAPI4PHONEBOOK_H_
+
+
+// ============================================================================ end of file
+
diff --git a/libvmodem/types4cardboot.h b/libvmodem/types4cardboot.h
new file mode 100644 (file)
index 0000000..b248fe4
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _TYPES4CARDBOOT_H_
+#define _TYPES4CARDBOOT_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+    // selected slot
+    typedef enum
+    {
+        LXT_RUIM_SLOT_1                                                         = 0x00,
+        LXT_RUIM_SLOT_2                                                         = 0x01,
+        LXT_RUIM_SLOT_ALL                                                       = 0x02
+    }
+    LXT_RUIM_SLOT;
+
+    // sim code id
+    typedef enum
+    {
+        LXT_SIM_CODE_ID_PIN1                                                    = 0x00,
+        LXT_SIM_CODE_ID_PIN2                                                    = 0x01,
+        LXT_SIM_CODE_ID_PUK1                                                    = 0x02,
+        LXT_SIM_CODE_ID_PUK2                                                    = 0x03,
+        LXT_SIM_CODE_ID_SIM_LOCK                                                = 0x04,
+        LXT_SIM_CODE_ID_PHONE_LOCK                                              = 0x05
+    }
+    LXT_SIM_CODE_ID;
+
+    // selected network mode
+    typedef enum
+    {
+        LXT_SELECTED_NETWORK_MODE_SLOT1_CDMA                                    = 0x00,
+        LXT_SELECTED_NETWORK_MODE_SLOT1__GSM                                    = 0x01,
+        LXT_SELECTED_NETWORK_MODE_SLOT2_CDMA                                    = 0x02,
+        LXT_SELECTED_NETWORK_MODE_SLOT2__GSM                                    = 0x03
+    }
+    LXT_SELECTED_NETWORK_MODE;
+
+    // network selection method
+    typedef enum
+    {
+        LXT_NETWORK_SELECTION_MODE_DEFAULT                                      = 0x00,
+        LXT_NETWORK_SELECTION_MODE_MENU                                         = 0x01
+    }
+    LXT_NETWORK_SELECTION_MODE;
+
+    // pin check status
+    typedef enum
+    {
+        LXT_PIN_STATUS_DISABLE                                                  = 0x00,
+        LXT_PIN_STATUS_ENABLE                                                   = 0x01
+    }
+    LXT_PIN_STATUS;
+
+    // phone status
+    typedef enum
+    {
+        LXT_CARD_STATUS_CARD1_SEARCHING_START                                   = 0x00,
+        LXT_CARD_STATUS_CARD2_SEARCHING_START                                   = 0x01,
+        LXT_CARD_STATUS_CARD_SEARCHING_END                                      = 0x02,
+        LXT_CARD_STATUS_FORCE_GSM_MODE_RUN                                      = 0x03,
+        LXT_CARD_STATUS_FORCE_CDMA_MODE_RUN                                     = 0x04,
+        LXT_CARD_STATUS_ALL_EMPTY                                               = 0x05,
+        LXT_CARD_STATUS_CARD1_PERM_BLOCKED                                      = 0x06,
+        LXT_CARD_STATUS_CARD2_PERM_BLOCKED                                      = 0x07,
+        LXT_CARD_STATUS_ALL_PERM_BLOCKED                                        = 0x08,
+        LXT_CARD_STATUS_CARD1_BLOCKED                                           = 0x09,
+        LXT_CARD_STATUS_CARD2_BLOCKED                                           = 0x0A,
+        LXT_CARD_STATUS_ALL_BLOCKED                                             = 0x0B
+    }
+    LXT_CARD_STATUS;
+
+    // current status
+    typedef enum
+    {
+        LXT_PIN_PROCESS_STATUS_NETWORK_LIST                                     = 0x00,
+        LXT_PIN_PROCESS_STATUS_PIN_CHECK                                        = 0x01
+    }
+    LXT_PIN_PROCESS_STATUS;
+
+
+    // slot capability
+    typedef enum
+    {
+        LXT_SLOT_CAPABILITY_UNKNOWN                                             = 0x00,
+        LXT_SLOT_CAPABILITY_USIM                                                = 0x01
+        LXT_SLOT_CAPABILITY_GSM                                                 = 0x02,
+        LXT_SLOT_CAPABILITY_GSM_USIM                                            = 0x03,
+        LXT_SLOT_CAPABILITY_RUIM                                                = 0x04,
+        LXT_SLOT_CAPABILITY_GSM_RUIM                                            = 0x05,
+        LXT_SLOT_CAPABILITY_EMV                                                 = 0x06
+    }
+    LXT_SLOT_CAPABILITY;
+
+
+    // slot state
+    typedef enum
+    {
+        LXT_SLOT_STATE_NOT_INITIALIZE                                           = 0x00,
+        LXT_SLOT_STATE_DISABLED                                                 = 0x01,
+        LXT_SLOT_STATE_ENABLED                                                  = 0x02,
+        LXT_SLOT_STATE_BLOCKED                                                  = 0x03,
+        LXT_SLOT_STATE_PERM_BLOCKED                                             = 0x04
+    }
+    LXT_SLOT_STATE;
+
+
+    // network mode (internal)
+    typedef enum
+    {
+        LXT_NETWORK_MODE_SLOT1_CDMA                                             = 0x00,
+        LXT_NETWORK_MODE_SLOT1_GSM                                              = 0x01,
+        LXT_NETWORK_MODE_SLOT2_CDMA                                             = 0x02,
+        LXT_NETWORK_MODE_SLOT2_GSM                                              = 0x03,
+        LXT_NETWORK_MODE_UNDEFINED                                              = 0xFF,
+    }
+    LXT_NETWORK_MODE;
+
+    typedef struct _lxt_card_authentication
+    {
+        LXT_RUIM_SLOT slot_name;
+        LXT_SIM_CODE_ID sim_code_id;
+        char size_current_code;
+        char current_code[8];
+        char size_new_code;
+        char new_code[8];
+        char is_boot_time;
+    }
+    LXT_CARD_AUTHENTICATION;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _TYPES4CARDBOOT_H_
+
+
diff --git a/libvmodem/vgsm.h b/libvmodem/vgsm.h
new file mode 100644 (file)
index 0000000..c7f62ea
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _vgsm_h_
+#define _vgsm_h_
+
+#include <time.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "lxtutil.h"
+#include "linuxtapi.h"
+#include "vgsm_phone.h"
+#include "vgsm_call.h"
+#include "vgsm_data.h"
+#include "vgsm_gprs.h"
+#include "vgsm_display.h"
+#include "vgsm_sim.h"
+#include "vgsm_pb.h"
+#include "vgsm_edb.h"
+#include "sms_util.h"
+#include "vgsm_power.h"
+///////////////////////////////090213//
+#include "vgsm_ss.h"
+//////////////////////////////////////////////
+//#include "../vgsm/db_gprs.h"
+//080117
+//#include "../vgsm/sat/sat_values.h"
+
+typedef struct tagTAT {
+    char* atmsg;
+} TAT;
+
+typedef struct _TCallbackInfo {
+    time_t time;
+    int rx;
+    TAT at;
+} TCallbackInfo;
+
+// init
+LXT_HANDLE* vgsm_injector_initialize(LXT_CALLBACK cb);
+LXT_HANDLE* vgsm_manager_rx_initialize(LXT_CALLBACK cb);
+LXT_HANDLE* vgsm_manager_tx_initialize(LXT_CALLBACK cb);
+LXT_HANDLE* vgsm_manager_initialize(LXT_CALLBACK cb);
+int vgsm_injector_release(LXT_HANDLE* handle);
+
+int vgsm_injector_get_fd(LXT_HANDLE *handle);
+int vgsm_socket_read_callback(LXT_HANDLE* handle);
+
+int vgsm_client_release_notify(LXT_HANDLE* handle);
+
+//int vgsm_release(LXT_HANDLE* handle);
+
+int vgsm_convert_callbackinfo( void *data, TCallbackInfo *info );
+int vgsm_get_at_length_callbackinfo( TCallbackInfo info );
+int vgsm_convert_atinfo( void *data, TAT *at );
+int vgsm_get_at_length_atinfo( TAT at );
+
+// SMS
+/* add user option by cosmos in 20090213 */
+int vgsm_sms_sendMessage(LXT_HANDLE* handle, SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, BYTE pid);
+
+int vgsm_sms_sendAck(LXT_HANDLE* handle, int error);
+int vgsm_cb_sendMessage(LXT_HANDLE* handle, CELLBROADCASTING cb_msg); //june
+
+// Call
+int vgsm_call_make(LXT_HANDLE* handle, gsm_call_info_t callinfo);
+int vgsm_call_hangup(LXT_HANDLE* handle, int call_id);
+int vgsm_call_answer(LXT_HANDLE* handle);
+// added by okdear for vodafone
+int vgsm_call_alert(LXT_HANDLE* handle);
+int vgsm_call_disconnect_cause(LXT_HANDLE* handle, int call_error_cause);
+
+// Supplementary Service
+int vgsm_ss_conference(LXT_HANDLE* handle);
+int vgsm_ss_hold(LXT_HANDLE* handle);
+int vgsm_ss_unhold(LXT_HANDLE* handle);
+    // 090213
+int vgsm_ss_setAOC(LXT_HANDLE* handle, _AOC_t *aoc, int size);
+int vgsm_ss_setCB(LXT_HANDLE* handle, _setCB_t *setCB, int size);
+int vgsm_ss_setCF(LXT_HANDLE* handle, _setCF_t *setCF, int size);
+int vgsm_ss_setCW(LXT_HANDLE* handle, _setCW_t *setCW, int size);
+int vgsm_ss_setUSSD(LXT_HANDLE* handle, _USSD_data_t *ussd, int size);
+int vgsm_ss_getUSSD(LXT_HANDLE* handle);
+int vgsm_ss_getAOC(LXT_HANDLE* handle);
+int vgsm_ss_restoreEI(LXT_HANDLE* handle);
+
+// Network
+int vgsm_network_registration(LXT_HANDLE* handle, gsm_network_reg_t reg);
+/* network plmn, nitz information by cosmos in 20090212 */
+int vgsm_network_plmn_information(LXT_HANDLE* handle, gsm_network_plmn_info_t reg);
+int vgsm_network_nitz_information(LXT_HANDLE* handle, gsm_network_nitz_info_t reg);
+int vgsm_network_plmn_list(LXT_HANDLE* handle, gsm_network_plmn_list_t plmn_list);
+int vgsm_network_current_plmn(LXT_HANDLE *handle, gsm_network_plmn_record_t plmn);
+
+// Data
+int vgsm_data_status(LXT_HANDLE* handle, GSM_DataCallStatus status);
+
+// GPRS
+int vgsm_gprs_ip_configuration(LXT_HANDLE* handle, gsm_GprsConfList list);
+
+// Display
+int vgsm_display_icon_information(LXT_HANDLE* handle, disp_icon_info_t info);
+
+// set error cause
+int vgsm_set_call_general_response_error(LXT_HANDLE* handle, int error);
+int vgsm_set_ss_general_response_error(LXT_HANDLE* handle, int error);
+int vgsm_set_call_status_error(LXT_HANDLE* handle, int type, int error);
+
+// Event Manager
+int vgsm_set_hdlc_mode(LXT_HANDLE *handle, int mode);
+int vgsm_send_hdlc(LXT_HANDLE * handle, const char *hdlc, int hdlc_len);
+int vgsm_clear_hdlc(LXT_HANDLE * handle);
+
+
+int vgsm_set_sca(LXT_HANDLE* handle, SmsAddressInfo SCA);
+
+// power
+int vgsm_power_modem_on_req_send(LXT_HANDLE * handle);  // this is temporary code.
+int vgsm_power_battery_status(LXT_HANDLE* handle, battery_status_type_e level);
+
+//sim
+int vgsm_sim_init(LXT_HANDLE * handle);
+int vgsm_get_sim_db(LXT_HANDLE * handle);
+int vgsm_sim_status_set(LXT_HANDLE * handle,gsm_sec_status_type status);
+int vgsm_sim_change_password(LXT_HANDLE * handle,gsm_sec_lock_e_type type,char *password,int length);
+int vgsm_sim_facility_set(LXT_HANDLE * handle,gsm_sec_lock_e_type type,gsm_sec_lock_mode_e_type flag);
+int vgsm_get_siminfo_db(LXT_HANDLE * handle, int *list );
+int vgsm_get_simdata_db(LXT_HANDLE * handle, int *list);
+int vgsm_sim_savedata(LXT_HANDLE * handle, _SIMD_t *simd_t );
+int vgsm_sim_reinit(LXT_HANDLE * handle);
+
+//pb
+int vgsm_make_pb_db(LXT_HANDLE * handle);
+int vgsm_get_all_pb_db(LXT_HANDLE * handle,gsm_pb_storage_type_e_type storage_type);
+int vgsm_get_pb_db(LXT_HANDLE * handle,gsm_pb_storage_type_e_type storage_type,char* index_);
+int vgsm_add_pb_db(LXT_HANDLE * handle,gsm_pb_storage_type_e_type storage_type,char* index_,char* name,char* number);
+int vgsm_delete_pb_db(LXT_HANDLE * handle,gsm_pb_storage_type_e_type storage_type,char* index_);
+
+// SAT
+int vgsm_proactive_cmd_send(LXT_HANDLE * handle,int command);
+int vgsm_sat_display_text(LXT_HANDLE * handle,char priority,char  clear_msg,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit );
+int vgsm_sat_get_inkey(LXT_HANDLE * handle,char cmd_detail,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit );
+int vgsm_sat_get_input(LXT_HANDLE * handle,char cmd_detail,char* textstring,char coding_scheme,char icon_identifier_flag,char icon_qualifier,char* icon_identifier,char immediate_response,char duration,char duration_unit );
+int vgsm_sat_set_up_menu(LXT_HANDLE * handle,unsigned char cmd_detail,int num,void * set_up_item );
+int vgsm_sat_select_item(LXT_HANDLE * handle,unsigned char cmd_detail,int num,void * set_up_item );
+int vgsm_sat_send_sms(LXT_HANDLE * handle,unsigned char cmd_detail,unsigned char address,char *number,unsigned char* sms_tpdu   );
+int vgsm_sat_set_up_call(LXT_HANDLE * handle,unsigned char cmd_detail,char* dial_number,char *alpha_user,/*char *alpha_call ,*/unsigned char address,unsigned char options,char duration_unit);
+
+#endif /* _vgsm_h_ */
+
diff --git a/libvmodem/vgsm_call.h b/libvmodem/vgsm_call.h
new file mode 100644 (file)
index 0000000..0adc9cc
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_call_h
+#define _vgsm_call_h
+
+#define MAX_GSM_CALL_LIST_NUMBER 6 // ±âÁ¸¿¡´Â 6.
+#define MAX_GSM_DIALED_DIGITS_NUMBER 32 //±âÁ¸¿¡´Â 32.
+#define MAX_BUF_LEN 256
+
+/* DIRECTION field */
+typedef enum{
+  GSM_CALL_DIR_MO = 0x01,     /* 0x01 : Mobile Originated Call ( MO Call ) */
+  GSM_CALL_DIR_MT,     /* 0x02 : Mobile Terminated Call ( MT Call ) */
+  GSM_CALL_DIR_MAX
+} gsm_call_direction_e_type;
+
+
+// !! CAUTION: CallState differs from CallStatus !!
+// CallState: from CALL STATUS NOTI
+// CallStatus: from CALL LIST
+
+/* CALL_STATE  field */
+/* Call Processing Status ( or call state ) */
+typedef enum{
+  GSM_CALL_STATE_NONE,                  /* 0x00 : Idle State ( Non-call state ) */
+  GSM_CALL_STATE_OUTGOING,          /* 0x01 : Originating Attempt state */
+  GSM_CALL_STATE_INCOMING,           /* 0x02 : Incoming alert state */
+  GSM_CALL_STATE_CONNECTED,        /* 0x03 : connected state */
+  GSM_CALL_STATE_RELEASED,           /* 0x04 : Release State */
+  GSM_CALL_STATE_MAX
+} gsm_call_state_e_type;
+
+/* CALL_STATUS field */
+typedef enum{
+  GSM_CALL_STATUS_NONE,              /* 0x00 : None Call status */
+  GSM_CALL_STATUS_ACTIVE,           /* 0x01 : current call is active */
+  GSM_CALL_STATUS_HELD,              /* 0x02 : current call is on hold */
+  GSM_CALL_STATUS_DIALING,         /* 0x03 : current call is dialing(MO call) */
+  GSM_CALL_STATUS_ALERT,             /* 0x04 : terminated party is ringing ( MO call ) */
+  GSM_CALL_STATUS_INCOMING,      /* 0x05 : incoming call(MT call) */
+  GSM_CALL_STATUS_WAITING,        /* 0x06 : Another incoming call ( call waiting ) is alerting to the user in conversation ( MT call ) */
+  /* Others are reserved */
+  GSM_CALL_STATUS_MAX
+}  gsm_call_status_e_type;
+
+
+/* CALL_TYPE  field */
+typedef enum {
+  GSM_CALL_TYPE_NONE,     /* 0x00 : None */
+  GSM_CALL_TYPE_VOICE,    /* 0x01 : Voice Call Type */
+  GSM_CALL_TYPE_DATA,     /* 0x02 : Data Call Type */
+  GSM_CALL_TYPE_VIDEO,    /* 0x03 : Video Call Type */
+  GSM_CALL_TYPE_MAX        /* 0x04 : Max */
+} gsm_call_type_e_type;
+#define GSM_CALL_TYPE_FORWARDED 0x33
+
+/* NUMBER_TYPE  field */
+/* NUMBER_TYPE = ( (NUM_TYPE << 4 ) | NUM_PLAN )*/
+typedef enum{
+  GSM_NUM_TYPE_UNKNOWN,                 /* 0x00 : unknown */
+  GSM_NUM_TYPE_INTERNATIONAL,       /* 0x01 : international number */
+  GSM_NUM_TYPE_NATIONAL,                 /* 0x02 : national number */
+  GSM_NUM_TYPE_NETWORK,                  /* 0x03 : network specific number */
+  GSM_NUM_TYPE_DEDICATE,                 /* 0x04 : dedicated access, short code */
+  GSM_NUM_TYPE_MAX
+} gsm_num_type_e_type;
+
+/* CLIR_STATUS  field */
+/* override the CLIR supplementary service subscription default value for this call */
+typedef enum {
+  GSM_CALL_CLIR_STATUS_NOT_CHANGED,     /* 0x00 : previous CLI presentation */
+  GSM_CALL_CLIR_STATUS_INVOCATION,        /* 0x01 : restrict CLI presentation */
+  GSM_CALL_CLIR_STATUS_SUPPRESSION,      /* 0x02 : allow CLI presentation */
+  GSM_CALL_CLIR_STATUS_MAX
+} gsm_clir_status_e_type;
+
+
+typedef struct {
+       gsm_call_type_e_type calltype;
+       gsm_clir_status_e_type clirstatus;
+       unsigned short numlen;
+       gsm_num_type_e_type numtype;
+       unsigned char number[MAX_GSM_DIALED_DIGITS_NUMBER];
+
+#if 0
+       char uus_type[MAX_BUF_LEN];
+       char protocol_type[MAX_BUF_LEN];
+       char user_type[MAX_BUF_LEN];
+       char alerting_pattern[MAX_BUF_LEN];
+#endif
+
+       unsigned char present_ind;
+       unsigned char redirected_num;
+       unsigned char no_cli_cause;
+       unsigned char forwardedstatus;
+
+} gsm_call_info_t;
+
+typedef struct
+{
+       unsigned int      idx;                          // call id.
+       gsm_call_direction_e_type       dir;
+       gsm_call_status_e_type      stat;
+       gsm_call_type_e_type      call_type;
+       unsigned int      mpty;                 //multy party or not
+       char               number[MAX_GSM_DIALED_DIGITS_NUMBER];
+       int                type;                                // not used
+       int                                     num_len;
+       gsm_num_type_e_type     num_type;
+       char               alpha[32];                   // not used
+} gsm_call_list_info_t;
+
+
+typedef struct
+{
+    int CallCount;
+    gsm_call_list_info_t CallInfo[MAX_GSM_CALL_LIST_NUMBER];
+} gsm_call_list_t;
+
+
+/*/ 090314
+ typedef struct
+ {
+     gsm_call_list_info_t    *call_list_info;
+     int                     isIng;              // 01 : Ing
+ } new_call_list_info_t
+*////////////////////////////////////////////
+#endif
diff --git a/libvmodem/vgsm_data.h b/libvmodem/vgsm_data.h
new file mode 100644 (file)
index 0000000..2c3cdb7
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef __vgsm_data_h__
+#define __vgsm_data_h__
+
+typedef enum tagDataSignal {
+  GSM_DATA_SIGNAL_NONE,
+  GSM_DATA_SIGNAL_DCD,                /* 0x01 */
+  GSM_DATA_SIGNAL_RX,                   /* 0x02 */
+  GSM_DATA_SIGNAL_TX,                   /* 0x03 */
+  GSM_DATA_SIGNAL_DTR,                /* 0x04 */
+  GSM_DATA_SIGNAL_GND,                /* 0x05 */
+  GSM_DATA_SIGNAL_DSR,                /* 0x06 */
+  GSM_DATA_SIGNAL_RTS,                /* 0x07 */
+  GSM_DATA_SIGNAL_CTS,                /* 0x08 */
+  GSM_DATA_SIGNAL_RI,                  /* 0x09 */
+  GSM_DATA_SIGNAL_MAX                /* 0x0A */
+} gsm_data_pin_signal_e_type;
+
+typedef enum tagDataSignalStatus {
+    GSM_DATA_SIGNAL_STATUS_DETACH = 0x00,
+    GSM_DATA_SIGNAL_STATUS_ATTACH = 0x01,
+    GSM_DATA_SIGNAL_STATUS_ON = 0x01,
+    GSM_DATA_SIGNAL_STATUS_OFF = 0x00,
+} GSM_DataSignalStatus;
+
+typedef enum{
+  GSM_DATA_TE2_TYPE_UART,   /* 0x00 : UART Interface */
+  GSM_DATA_TE2_TYPE_USB,     /* 0x01 : USB Interface */
+  GSM_DATA_TE2_TYPE_BT,       /* 0x02 : Bluetooth Interface */
+  GSM_DATA_TE2_TYPE_MAX     /* 0x03 : Max */
+} gsm_data_te2_e_type;
+
+typedef enum{
+  GSM_DATA_TE2_STATUS_DETACHED,
+  GSM_DATA_TE2_STATUS_ATTACHED
+} gsm_data_te2_status_e_type; 
+
+typedef struct tagDataBytesCounter {
+    int cur_rx_bytes;
+    int cur_tx_bytes;
+    char total_rx_bytes[8]; // todo : nsclass
+    char total_tx_bytes[8]; // todo : nsclass
+} GSM_DataBytesCounter;
+
+typedef struct tagDataDSTE2DialInfo {
+    unsigned char length;
+    char dial_digit[32];
+} GSM_DataDSTE2DialInfo;
+
+typedef struct tagDataDSTE2RateInfo {
+    int tx_bytes;
+    int rx_bytes;
+    unsigned char report_period;
+    unsigned char num_channel;
+    unsigned char tx_bar_level;
+    unsigned char rx_bar_level;
+} GSM_DataDSTE2RateInfo;
+
+typedef enum {
+  GSM_DATA_TE2_DATA_CALL_RESULT_OK=0x00,               /* 0x00 : OK (maybe not use) */
+  GSM_DATA_TE2_DATA_CALL_RESULT_CONNECT,               /* 0x01 : CONNECT */
+  GSM_DATA_TE2_DATA_CALL_RESULT_RING,                          /* 0x02 : RING (maybe not use) */
+  GSM_DATA_TE2_DATA_CALL_RESULT_NO_CARRIER,    /* 0x03 : NO CARRIER */
+  GSM_DATA_TE2_DATA_CALL_RESULT_ERROR,                 /* 0x04 : ERROR */
+  GSM_DATA_TE2_DATA_CALL_RESULT_NO_DIALTONE,   /* 0x05 : NO DIALTONE (maybe not use) */
+  GSM_DATA_TE2_DATA_CALL_RESULT_BUSY,                          /* 0x06 : BUSY (maybe not use)*/
+  GSM_DATA_TE2_DATA_CALL_RESULT_NO_ANSWER,     /* 0x07 : NO ANSWER */
+  GSM_DATA_TE2_DATA_CALL_RESULT_FDN,           /* 0x08 : FDN */ 
+  GSM_DATA_TE2_DATA_CALL_RESULT_MAX
+} gsm_data_te2_data_call_result_e_type;
+
+typedef enum {
+  GSM_DATA_CALL_REASON_NORMAL=0x00,
+  GSM_DATA_CALL_REASON_REL_BY_USER,
+  GSM_DATA_CALL_REASON_REGULAR_DEACTIVATION,
+  GSM_DATA_CALL_REASON_LLC_SNDCP_FAILURE,
+  GSM_DATA_CALL_REASON_INSUFFICIENT_RESOURCES,
+  GSM_DATA_CALL_REASON_MISSING_OR_UNKNOWN_APN,          
+  GSM_DATA_CALL_REASON_UNKNOWN_PDP_ADDRESS_OR_TYPE,
+  GSM_DATA_CALL_REASON_USER_AUTHENTICATION_FAILED,
+  GSM_DATA_CALL_REASON_ACTIVATION_REJECTED_BY_GGSN,
+  GSM_DATA_CALL_REASON_ACTIVATION_REJECTED_UNSPECIFIED,
+  GSM_DATA_CALL_REASON_SERVICE_OPTION_NOT_SUPPORTED,                           
+  GSM_DATA_CALL_REASON_SERVICE_NOT_SUBSCRIBED, 
+  GSM_DATA_CALL_REASON_SERVICE_OUT_OR_ORDER,
+  GSM_DATA_CALL_REASON_NSAPI_ALREADY_USED,
+  GSM_DATA_CALL_REASON_QOS_NOT_ACCEPTED,
+  GSM_DATA_CALL_REASON_NETWORK_FAILURE,
+  GSM_DATA_CALL_REASON_REACTIVATION_REQUIRED,
+  GSM_DATA_CALL_REASON_FEATURE_NOT_SUPPORTED,
+  GSM_DATA_CALL_REASON_TFT_OR_FILTER_ERR,
+  GSM_DATA_CALL_REASON_UNKNOWN_PDP_CONTEXT,
+  GSM_DATA_CALL_REASON_INVALID_MSG,
+  GSM_DATA_CALL_REASON_PROTOCOL_ERR,
+  GSM_DATA_CALL_REASON_MOBILE_FAILURE_ERR,
+  GSM_DATA_CALL_REASON_TIMEOUT_ERR,
+  GSM_DATA_CALL_REASON_UNKNOWN_ERR
+}gsm_data_call_reason_e_type;
+
+typedef enum tagDataCallExternalPSCall {
+    GSM_DATA_CALL_INTERNAL_PS_CALL = 0x00,
+    GSM_DATA_CALL_EXTERNAL_PS_CALL = 0x01
+} GSM_DataCallExternalPSCall;
+
+typedef enum {
+    GSM_DATA_SERVICE_STATE_EXTERNAL_START = 0x01,      /* 0x01 : external call start */
+    GSM_DATA_SERVICE_STATE_EXTERNAL_CONNECTED,         /* 0x02 : external call connect */
+    GSM_DATA_SERVICE_STATE_EXTERNAL_RELEASE,           /* 0x03 : external call release */
+    GSM_DATA_SERVICE_STATE_GPRS_SUSPEND,                       /* 0x04 : GPRS Suspended (NOT implemented, PDA implemnted dormant status) */
+    GSM_DATA_SERVICE_STATE_GPRS_RESUME,                                /* 0x05 : GRPS RESUMED (NOT implemented, PDA implemnted dormant status) */
+    GSM_DATA_SERVICE_STATE_MAX
+} GSM_DataSvcStateType;
+
+typedef struct tagDataCallStatus {
+    unsigned char cid;
+    gsm_data_call_reason_e_type data_call_state;
+    gsm_data_call_reason_e_type data_call_state_rsn;
+    GSM_DataCallExternalPSCall external_ps_call;
+} GSM_DataCallStatus;
+
+#endif // __vgsm_data_h__
+
diff --git a/libvmodem/vgsm_display.h b/libvmodem/vgsm_display.h
new file mode 100644 (file)
index 0000000..aacc2fc
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __vgsm_display_h__
+#define __vgsm_display_h__
+
+#include "vgsm_network.h"
+
+/* ICON_TYPE  field */
+/* Sets the request value */
+typedef enum {
+       DISP_TYPE_RSSI                  = 0x01,         /* 0000 0001 : signal strength */
+       DISP_TYPE_BATTERY               = 0x02,         /* 0000 0010 : battery level   */
+       DISP_TYPE_ACT                   = 0x04,         /* 0000 0100 : Protocol Standard: GSM,GPRS,UMTS   */
+       DISP_TYPE_REG_STATUS    = 0x08,         /* 0000 1000 : Registration status   */
+       DISP_TYPE_ALL                   = 0xFF          /* 1111 1111 : ALL Values Request */
+} disp_icon_type_e;
+
+/* RSSI  field */
+/* Radio signal strength */
+typedef enum {
+       DISP_RSSI_0     = 0x00,
+       DISP_RSSI_1     = 0x01,
+       DISP_RSSI_2     = 0x02,
+       DISP_RSSI_3     = 0x03,
+       DISP_RSSI_4     = 0x04,
+       DISP_RSSI_5     = 0x05,
+       DISP_RSSI_MAX
+} disp_icon_rssi_type_e;
+
+/* BATTERY  field */
+/* Determines a battery Icon. */
+typedef enum {
+       DISP_BATTERY_LEVEL0     = 0x00, /* 0x00 : blank */
+       DISP_BATTERY_LEVEL1     = 0x01, /* 0x01 */
+       DISP_BATTERY_LEVEL2     = 0x02, /* 0x02 */
+       DISP_BATTERY_LEVEL3     = 0x03, /* 0x03 : full */
+       DISP_BATTERY_LEVEL4     = 0x04, /* 0x04 : full for smart phone*/
+       DISP_BATTERY_MAX
+} disp_icon_batt_type_e;
+
+/* DISPLAY ICON INFO */
+typedef struct {
+    disp_icon_type_e icon_type;
+    disp_icon_rssi_type_e rssi;
+    disp_icon_batt_type_e battery;
+    gsm_net_act_e_type act;
+    gsm_net_regist_status_e_type reg_status;
+} disp_icon_info_t;
+
+#endif // __v_gsm_display_h__
diff --git a/libvmodem/vgsm_edb.h b/libvmodem/vgsm_edb.h
new file mode 100644 (file)
index 0000000..b3684c2
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_edb_h_
+#define _vgsm_edb_h_
+
+typedef struct
+{
+       int cnt;
+       int index;
+       int isend;
+       int id;
+       char fn[10];
+       char mn[10];
+       char sn[10];
+       char path[50];
+       char mobile[30];
+       char email[30];
+       char website[50];
+       char st1[20];
+       char st2[20];
+       char city[20];
+       char zip[20];
+       char country[20];
+} _Pb_edb; // 16+30+50+15+30+30+30+15+30 = 246
+
+typedef struct
+{
+       int cnt;
+       int index;
+       int isend;
+       int id;
+       char fn[10];
+       char mn[10];
+       char sn[10];
+       char mobile[30];
+} _Tmp_edb; // 16 + 30 + 15 = 61
+       
+#endif // __vgsm_edb_h_
diff --git a/libvmodem/vgsm_error.h b/libvmodem/vgsm_error.h
new file mode 100644 (file)
index 0000000..3429e58
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_error_h_
+#define _vgsm_error_h_
+
+/*
+ * ¾Æ·¡ÀÇ ¿¡·¯ÄÚµåÁß ¾îÇø®ÄÉÀ̼Ç(Æù¾îÇø®ÄÉÀ̼Ç)¿¡¼­ Ã¼Å©Çϴ °ÍÀº 
+ * AT command result°¡ OK°¡ ¾Æ´Ñ ´ÙÀ½ÀÇ °æ¿ì 
+ * ERR_CME
+ * ERR_CMS
+ * ERR_UNKNOWN
+ * ERR_UNKNOWNRESPONSE
+ * ÀÌ·¸°Ô ³× °³ÀÇ °æ¿ì¸¸ È®ÀÎÇÑ´Ù.
+ */
+typedef enum {
+    ERR_NONE=1,
+    ERR_CME,
+    ERR_CMS,
+    ERR_UNKNOWN,
+    ERR_UNKNOWNRESPONSE,    // Á¤ÀǵÇÁö ¾ÊÀº response
+    ERR_DEVICEOPENERROR,    // device open ¿¡·¯
+    ERR_DEVICELOCKED,       // device lock ¿¡·¯
+    ERR_DEVICENOTEXIST,
+    ERR_DEVICEBUSY,
+    ERR_DEVICENOPERMISSION,
+    ERR_DEVICENODRIVER,
+    ERR_DEVICENOTWORK,
+    ERR_DEVICEDTRRTSERROR,
+    ERR_DEVICECHANGESPEEDERROR,
+    ERR_DEVICEWRITEERROR,
+    ERR_DEVICEREADERROR,
+    ERR_DEVICEPARITYERROR,
+    ERR_TIMEOUT,            // at command timeout ¿¡·¯
+    ERR_FRAMENOTREQUESTED,
+    ERR_UNKNOWNFRAME,       // À§ÀÇ °æ¿ì¿Í À¯»ç
+    ERR_UNKNOWNCONNECTIONTYPESTRING,
+    ERR_UNKNOWNMODELSTRING,
+    ERR_SOURCENOTAVAILABLE,
+    ERR_NOTSUPPORTED,
+    ERR_EMPTY,
+    ERR_SECURITYERROR,
+    ERR_INVALIDLOCATION,
+    ERR_NOTIMPLEMENTED,
+    ERR_FULL,
+    ERR_CANTOPENFILE,
+    ERR_MOREMEMORY,
+    ERR_PERMISSION,
+    ERR_EMPTYSMSC,
+    ERR_INSIDEPHONEMENU,
+    ERR_NOTCONNECTED,
+    ERR_WORKINPROGRESS,
+    ERR_PHONEOFF,
+    ERR_FILENOTSUPPORTED,
+    ERR_BUG,
+    ERR_CANCELED,
+    ERR_NEEDANOTHERANSWER,
+    ERR_OTHERCONNECTIONREQUIRED,
+    ERR_WRONGCRC,
+    ERR_INVALIDDATETIME,
+    ERR_MEMORY,
+    ERR_INVALIDDATA,
+    ERR_FILEALREADYEXIST,
+    ERR_FILENOTEXIST
+} GSM_Error;
+
+#define CME_SIM_NOT_INSERTED            10
+#define CME_SIM_PIN_REQUIRED            11
+#define CME_SIM_PUK_REQUIRED            12
+#define CME_SIM_BUSY                    14
+#define CME_INCORRECT_PASSWORD          16
+#define CME_SIM_PUK2_REQUIRED           18
+// nsclass {
+#define CME_SIM_PIN2_REQUIRED           19
+#define CME_SIM_PIN1_BLOCKED                   20
+#define CME_SIM_PIN2_BLOCKED                   21
+// }
+
+#endif
diff --git a/libvmodem/vgsm_gprs.h b/libvmodem/vgsm_gprs.h
new file mode 100644 (file)
index 0000000..3b4c941
--- /dev/null
@@ -0,0 +1,478 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+
+
+#ifndef __vgsm_gprs_h__
+#define __vgsm_gprs_h__
+
+typedef enum{
+GSM_GPRS_DEFINE_PDP_MODE_ADD=0x01,     /* 0x01 : Add PDP information */
+GSM_GPRS_DEFINE_PDP_MODE_DELETE,               /* 0x02 : Delete PDP information */
+GSM_GPRS_DEFINE_PDP_MODE_MAX
+} gsm_gprs_define_pdp_mode_e_type;
+
+typedef enum{
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_UNKNOWN=0x00,     /* 0x00 : Unknown */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_X25,                      /* 0x01 : ITU-T/CCITT X.25 Layer 4 */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IP,                       /* 0x02 : Internet Protocol (IETF STD 5) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IHOST,            /* 0x03 : Internet Hosted Octet Stream Protocol */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_PPP,                      /* 0x04 : Point-to-Point Protocol */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IPV6,             /* 0x05 : Internet Protocol, version 6(IETF RFC 2460)-Maybe not use */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_MAX
+} gsm_gprs_define_pdp_context_p_e_type;
+
+typedef enum{
+  GSM_GPRS_DEFINE_PDP_CONTEXT_D_COMP_OFF=0x00,         /* 0x00 : Compression off (Default) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_D_COMP_ON,                       /* 0x01 : Compression on */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_D_COMP_V42BIS,           /* 0x02 : V42BIS (maybe not use) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_D_COMP_V44,              /* 0x03 : V44 (maybe not use) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_D_COMP_MAX
+} gsm_gprs_define_pdp_context_d_comp_e_type;
+
+/* PDP Header Compression Type (H_COMP) */
+typedef enum{
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_OFF=0x00,         /* 0x00 : Compression off (Default) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_ON,                       /* 0x01 : Compression on */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_RFC1144,          /* 0x02 : RFC1144 (maybe not use) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_RFC2507,          /* 0x03 : RFC2507 (maybe not use) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_RFC3095,          /* 0x04 : RFC3095 (maybe not use) */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_H_COMP_MAX
+} gsm_gprs_define_pdp_context_h_comp_e_type;
+
+/* PDP Authentication Type */
+typedef enum{
+  GSM_GPRS_DEFINE_PDP_CONTEXT_AUTHTYPE_NONE=0x00,      /* 0x00 : NONE */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_AUTHTYPE_PAP=0x01,       /* 0x01 : PAP */
+  GSM_GPRS_DEFINE_PDP_CONTEXT_AUTHTYPE_CHAP=0x02,      /* 0x02 : CHAP */
+}gsm_gprs_define_pdp_context_authtype_e_type;
+
+typedef enum {
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_IP_ADDR = 0x0001,             /* 0x0001 : IP Address */
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_PRIMARY_DNS = 0x0002, /* 0x0002 : Primary DNS */
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_SECONDARY_DNS = 0x0004,       /* 0x0004 : Secondary DNS */
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_DEFAULT_GATEWAY = 0x0008,     /* 0x0004 : Default Gateway */
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_SUBNET_MASK = 0x0010, /* 0x0010 : Subnet Mask */
+  GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_PCSCF=0x0020,                /* 0x0020 : P-CSCF Address */
+    GSM_GPRS_IP_CONFIGURATION_FIELD_FLAG_MAX = 0xFFFF
+} gsm_gprs_ip_configuration_field_flag_e_type;
+
+typedef struct tagIPConfiguration {
+       unsigned char cid;
+       gsm_gprs_ip_configuration_field_flag_e_type fieldflag;
+       unsigned char ip_addr[4];
+       unsigned char primary_dns[4];
+       unsigned char secondary_dns[4];
+       unsigned char default_gateway[4];
+       unsigned char subnet_mask[4];
+} GSM_GprsIPConfiguration;
+
+typedef enum tagGprsHSDPAState {
+    GSM_GPRS_HSDPA_STATE_INACTIVE = 0x00,
+    GSM_GPRS_HSDPA_STATE_ACTIVE = 0x01
+} GSM_GprsHSDPAState;
+
+typedef struct tagSetPDPContext {
+    gsm_gprs_define_pdp_mode_e_type mode;
+    char cid;
+    gsm_gprs_define_pdp_context_p_e_type pdp_type;
+    char apn[102];
+    char pdp_addr[20];
+    gsm_gprs_define_pdp_context_d_comp_e_type d_comp;
+    gsm_gprs_define_pdp_context_h_comp_e_type h_comp;
+    gsm_gprs_define_pdp_context_authtype_e_type auth;
+} GSM_SetPDPContext;
+
+typedef struct tagPDPContextInfo {
+       char cid;
+       char apn[102];
+       char pdp_addr[20];
+       char d_comp;
+       char h_comp;
+} GSM_PDPContextInfo;
+
+typedef struct tagResPDPContext {
+       char num_pdp; // max 3
+       GSM_PDPContextInfo info[3];
+} GSM_ResPDPContext;
+
+typedef enum{
+  GSM_GPRS_QOS_TYPE_REQ=0x01,          /* 0x01 : Quality of Service Profile Type Request (+CGQREQ) */
+  GSM_GPRS_QOS_TYPE_MIN,                       /* 0x02 : Quality of Service Profile Type Minimum Acceptable (+CGQMIN) */
+  GSM_GPRS_QOS_TYPE_MAX
+} gsm_gprs_qos_e_type;
+
+typedef enum{
+  GSM_GPRS_QOS_PREC_SUBSCRIBED=0x00,   /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_QOS_PREC_HIGH,                              /* 0x01 : Service commitments shall be maintained ahead of precedence classes 2 and 3 */
+  GSM_GPRS_QOS_PREC_NORMAL,                    /* 0x02 : Service commitments shall be maintained ahead of precedence class 3 */
+  GSM_GPRS_QOS_PREC_LOW,                               /* 0x03 : Service commitments shall be maintained ahead of precedence classes 1 and 2 */
+  GSM_GPRS_QOS_PREC_MAX
+} gsm_gprs_qos_prec_e_type;
+
+typedef enum{
+  GSM_GPRS_QOS_DELAY_SUBSCRIBED=0x00,          /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_QOS_DELAY_PRED1,                    /* 0x01 : Predictive 1 */
+  GSM_GPRS_QOS_DELAY_PRED2,                    /* 0x02 : Predictive 2 */
+  GSM_GPRS_QOS_DELAY_PRED3,                    /* 0x03 : Predictive 3 */
+  GSM_GPRS_QOS_DELAY_PRED4,                    /* 0x04 : Predictive 4 */
+  GSM_GPRS_QOS_DELAY_MAX
+} gsm_gprs_qos_delay_e_type;
+
+typedef enum{
+  GSM_GPRS_QOS_RELI_SUBSCRIBED=0x00,   /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_QOS_RELI_CLASS1,                    /* 0x01 : Reliability class 1 */
+  GSM_GPRS_QOS_RELI_CLASS2,                    /* 0x02 : Reliability class 2 */
+  GSM_GPRS_QOS_RELI_CLASS3,                    /* 0x03 : Reliability class 3 */
+  GSM_GPRS_QOS_RELI_CLASS4,                    /* 0x04 : Reliability class 4 */
+  GSM_GPRS_QOS_RELI_CLASS5,                    /* 0x05 : Reliability class 5 */
+  GSM_GPRS_QOS_RELI_MAX
+} gsm_gprs_qos_reli_e_type;
+
+typedef enum{
+  GSM_GPRS_QOS_PEAK_SUBSCRIBED=0x00,   /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_QOS_PEAK_8K,                                /* 0x01 : 8,000 bit per second */
+  GSM_GPRS_QOS_PEAK_16K,                               /* 0x02 : 16,000 bit per second */
+  GSM_GPRS_QOS_PEAK_32K,                               /* 0x03 : 32,000 bit per second */
+  GSM_GPRS_QOS_PEAK_64K,                               /* 0x04 : 64,000 bit per second */
+  GSM_GPRS_QOS_PEAK_128K,                              /* 0x05 : 128,000 bit per second */
+  GSM_GPRS_QOS_PEAK_256K,                              /* 0x06 : 256,000 bit per second */
+  GSM_GPRS_QOS_PEAK_512K,                              /* 0x07 : 512,000 bit per second */
+  GSM_GPRS_QOS_PEAK_1024K,                             /* 0x08 : 1,024,000 bit per second */
+  GSM_GPRS_QOS_PEAK_2048K,                             /* 0x09 : 2,048,000 bit per second */
+  GSM_GPRS_QOS_PEAK_MAX
+} gsm_gprs_qos_peak_e_type;
+
+/* Quality of Service Mean (MEAN) */
+typedef enum{
+  GSM_GPRS_QOS_MEAN_SUBSCRIBED=0x00,   /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_QOS_MEAN_1,                                 /* 0x01 : 0.22 bits per second */
+  GSM_GPRS_QOS_MEAN_2,                                 /* 0x02 : 0.44 bit per second */
+  GSM_GPRS_QOS_MEAN_3,                                 /* 0x03 : 1.11 bit per second */
+  GSM_GPRS_QOS_MEAN_4,                                         /* 0x04 : 2.2 bit per second */
+  GSM_GPRS_QOS_MEAN_5,                                         /* 0x05 : 4.4 bit per second */
+  GSM_GPRS_QOS_MEAN_6,                                         /* 0x06 : 11.1 bit per second */
+  GSM_GPRS_QOS_MEAN_7,                                         /* 0x07 : 22 bit per second */
+  GSM_GPRS_QOS_MEAN_8,                                         /* 0x08 : 44 bit per second */
+  GSM_GPRS_QOS_MEAN_9,                                         /* 0x09 : 111 bit per second */
+  GSM_GPRS_QOS_MEAN_10,                                        /* 0x10 : 220 bit per second */
+  GSM_GPRS_QOS_MEAN_11,                                        /* 0x11 : 440 bit per second */
+  GSM_GPRS_QOS_MEAN_12,                                        /* 0x12 : 1,110 bit per second */
+  GSM_GPRS_QOS_MEAN_13,                                        /* 0x13 : 2,200 bit per second */
+  GSM_GPRS_QOS_MEAN_14,                                        /* 0x14 : 4,400 bit per second */
+  GSM_GPRS_QOS_MEAN_15,                                        /* 0x15 : 11,100 bit per second */
+  GSM_GPRS_QOS_MEAN_16,                                        /* 0x16 : 22,000 bit per second */
+  GSM_GPRS_QOS_MEAN_17,                                        /* 0x17 : 44,000 bit per second */
+  GSM_GPRS_QOS_MEAN_18,                                        /* 0x18 : 111,000 bit per second */
+  GSM_GPRS_QOS_MEAN_31=0x31,                                   /* 0x31 : Best effort */
+  GSM_GPRS_QOS_MEAN_MAX
+} gsm_gprs_qos_mean_e_type;
+
+typedef struct tagSetQOSType {
+       gsm_gprs_define_pdp_mode_e_type mode;
+       gsm_gprs_qos_e_type qos_type;
+       char cid;
+       gsm_gprs_qos_prec_e_type qos_precedence;
+       gsm_gprs_qos_delay_e_type qos_delay;
+       gsm_gprs_qos_reli_e_type qos_reliability;
+       gsm_gprs_qos_peak_e_type qos_peak;
+       gsm_gprs_qos_mean_e_type qos_mean;
+} GSM_SetQOSType;
+
+typedef struct tagQOSTypeInfo {
+       char cid;
+       gsm_gprs_qos_prec_e_type qos_prece;
+       gsm_gprs_qos_delay_e_type qos_delay;
+       gsm_gprs_qos_reli_e_type qos_reli;
+       gsm_gprs_qos_peak_e_type qos_peak;
+       gsm_gprs_qos_mean_e_type qos_mean;
+} GSM_QOSTypeInfo;
+
+typedef struct tagResQOSType {
+       gsm_gprs_qos_e_type qos_type;
+       char num_qos;
+       GSM_QOSTypeInfo info[3]; // max 3
+} GSM_ResQOSType;
+
+typedef enum{
+  GSM_GPRS_PS_STATE_DETACHED=0x00,     /* 0x00 : Detached */
+  GSM_GPRS_PS_STATE_ATTACHED,                          /* 0x01 : Attached */
+  GSM_GPRS_PS_STATE_MAX
+} gsm_gprs_ps_state_e_type;
+
+typedef enum{
+  GSM_GPRS_PS_SUSPEND =0x00,           /* 0x00 : Packet Data Transfer Status is Suspend */
+  GSM_GPRS_PS_ACTIVE,                          /* 0x01 : Packet Data Transfer Status is Active(Resume) */
+  GSM_GPRS_PS_TRANSFER_STATUS_MAX
+} gsm_gprs_ps_transfer_e_type;
+
+typedef enum tagGPRS_Attachment_State {
+       GSM_GPRS_ATTACHMENT_STATE_DEACTIVATED = 0x00,
+       GSM_GPRS_ATTACHMENT_STATE_ACTIVATED = 0x01,
+} GSM_GPRS_Attachment_Status;
+
+typedef enum {
+  GSM_GPRS_PDP_CONTEXT_STATE_DETACHED=0x00,    /* 0x00 : Detached */
+  GSM_GPRS_PDP_CONTEXT_STATE_ATTACHED,                 /* 0x01 : Attached */
+  GSM_GPRS_PDP_CONTEXT_STATE_CANCEL,            /* 0x02 : Cancel   */
+  GSM_GPRS_PDP_CONTEXT_STATE_MAX
+} gsm_gprs_pdp_context_state_e_type;
+
+typedef struct tagPDPStateInfo {
+       char cid;
+       gsm_gprs_pdp_context_state_e_type state;
+} GSM_PDPStateInfo;
+
+typedef struct tagResPDPState {
+       char num_act; // max 3
+       GSM_PDPStateInfo info[3];
+} GSM_ResPDPState;
+
+typedef struct tagResPDPAddress {
+       char address[20];
+} GSM_ResPDPAddress;
+
+typedef enum {
+  GSM_GPRS_MS_CLASS_GSMANDGPRS=0x00,                           /* 0x00 : "A" : Simultaneous voice and GPRS data */
+  GSM_GPRS_MS_CLASS_GSMORGPRS,                                 /* 0x01 : "B" : Simultaneous voice and GPRS traffic channel, one or other data */
+  GSM_GPRS_MS_CLASS_GSMORGPRS_EXCLUSIVE,               /* 0x02 : "C" : Either all voice or all GPRS, both traffic channels unmonitored */
+  GSM_GPRS_MS_CLASS_GPRSONLY,                                          /* 0x03 : "CC" : Only GPRS */
+  GSM_GPRS_MS_CLASS_GSMONLY,                                   /* 0x04 : "CG" : Only circuit switched voice and data */
+  GSM_GPRS_MS_CLASS_MAX
+} gsm_gprs_ms_class_e_type;
+
+typedef enum tagGPRS_MO_SMS_Service {
+       GSM_GPRS_MO_SMS_SVC_CIRCUIT = 0x00,
+       GSM_GPRS_MO_SMS_SVC_GPRS = 0x01,
+       GSM_GPRS_MO_SMS_SVC_CIRCUITPREFERRED = 0x02,
+       GSM_GPRS_MO_SMS_SVC_GPRSPREFERRED = 0x03,
+} GSM_GPRS_MO_SMS_Service;
+
+typedef enum {
+  GSM_GPRS_3G_QOS_TYPE_REQUESTED=0x01,                 /* 0x00 : Requested(+CGEQREQ) */
+  GSM_GPRS_3G_QOS_TYPE_MINIMUM_ACCEPTABLE,     /* 0x01 : Minimum Acceptable(+CGEQMIN) */
+  GSM_GPRS_3G_QOS_TYPE_NEGOTIATED,                     /* 0x02 : Negotiated(+CGEQNEG) */
+  GSM_GPRS_3G_QOS_TYPE_MAX
+} gsm_gprs_3g_qos_type_e_type;
+
+typedef enum {
+  GSM_GPRS_3G_QOS_TRAFFIC_CONVERSATIONAL=0x00,         /* 0x00 : Conversational */
+  GSM_GPRS_3G_QOS_TRAFFIC_STREAMING,                   /* 0x01 : Streaming */
+  GSM_GPRS_3G_QOS_TRAFFIC_INTERACTIVE,                 /* 0x02 : Interactive */
+  GSM_GPRS_3G_QOS_TRAFFIC_BACKGROUND,                          /* 0x03 : Background */
+  GSM_GPRS_3G_QOS_TRAFFIC_SUBSCRIVED_VALUE,    /* 0x04 : Subscrived_value */
+  GSM_GPRS_3G_QOS_TRAFFIC_MAX
+} gsm_gprs_3g_qos_traffic_e_type;
+
+/* 3G_QOS_MAX_BITRATE_UL / 3G_QOS_MAX_BITRATE_DL / 3G_QOS_GUARANTEED_BITRATE_UL / 3G_QOS_GUARANTEED_BITRATE_DL */
+typedef enum {
+  GSM_GPRS_3G_QOS_BITRATE_SUBSCRIBED=0x00,     /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_3G_QOS_BITRATE_8K,                                  /* 0x01 : 8,000 bits per second (bps) */
+  GSM_GPRS_3G_QOS_BITRATE_16K,                         /* 0x02 : 16,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_32K,                         /* 0x03 : 32,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_64K,                         /* 0x04 : 64,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_128K,                        /* 0x05 : 128,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_256K,                        /* 0x06 : 256,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_512K,                        /* 0x07 : 512,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_1024K,                       /* 0x08 : 1,024,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_2048K,                       /* 0x09 : 2,048,000 bps */
+  GSM_GPRS_3G_QOS_BITRATE_MAX
+} gsm_gprs_3g_qos_bitrate_e_type;
+
+/* 3G_QOS_SDU_ERROR */
+typedef enum {
+  GSM_GPRS_3G_QOS_SDU_ERROR=0x00,      /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E1,       /* 0x01 : 10^(-1) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E2,       /* 0x02 : 10^(-2) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_7E3,       /* 0x03 : 7*(10^(-3)) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E3,       /* 0x04 : 10^(-3) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E4,       /* 0x05 : 10^(-4) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E5,       /* 0x06 : 10^(-5) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_1E6,       /* 0x07 : 10^(-6) */
+  GSM_GPRS_3G_QOS_SDU_ERROR_MAX
+} gsm_gprs_3g_qos_sdu_error_e_type;
+
+/* 3G_QOS_RESIDUAL_BIT_ERROR */
+typedef enum {
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR=0x00,     /* 0x00 : Subscribed by the Network / default if value is omitted */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_5E2,      /* 0x01 : 5*(10^(-2)) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_1E2,      /* 0x02 : 10^(-2) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_5E3,      /* 0x03 : 5*(10^(-3)) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_4E3,      /* 0x04 : 4*(10^(-3)) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_1E4,      /* 0x05 : 10^(-4) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_1E5,      /* 0x06 : 10^(-5) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_1E6,      /* 0x07 : 10^(-6) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_6E8,      /* 0x08 : 6*(10^(-8)) */
+  GSM_GPRS_3G_QOS_RESIDUAL_BIT_ERROR_MAX
+} gsm_gprs_3g_qos_residual_bit_error_e_type;
+
+typedef enum{
+  GSM_GPRS_3G_QOS_MODE_ADD=0x01,               /* 0x01 : Add Quality of Service Profile */
+  GSM_GPRS_3G_QOS_MODE_DELETE,                 /* 0x02 : Delete Quality of Service Profile */
+  GSM_GPRS_3G_QOS_MODE_MAX
+} gsm_gprs_3g_qos_mode_e_type;
+
+typedef enum tagGprs3GQosDeliError {
+       GSM_GPRS_3G_QOS_DELI_ERROR_NO = 0x00,
+       GSM_GPRS_3G_QOS_DELI_ERROR_YES = 0x01,
+       GSM_GPRS_3G_QOS_DELI_ERROR_NO_DETECT = 0x02,
+       GSM_GPRS_3G_QOS_DELI_ERROR_SUBSCRIBE = 0x03,
+} GSM_Gprs3GQosDeliError;
+
+typedef enum tagGprs3GQosDeliOrder {
+       GSM_GPRS_3G_QOS_DELI_ORDER_NO = 0x00,
+       GSM_GPRS_3G_QOS_DELI_ORDER_YES = 0x01,
+       GSM_GPRS_3G_QOS_DELI_ORDER_SUBSCRIBE = 0x02,
+} GSM_Gprs3GQosDeliOrder;
+
+typedef struct tagSet3GQOSType {
+       gsm_gprs_define_pdp_mode_e_type mode;
+       gsm_gprs_qos_e_type type;
+       char cid;
+       gsm_gprs_3g_qos_traffic_e_type traffic;
+       char max_bitrate_ul;
+       char max_bitrate_dl;
+       char guarante_bitrate_ul;
+       char guarante_bitrate_dl;
+       GSM_Gprs3GQosDeliOrder delivery_order;
+       short max_sdu_size;
+       gsm_gprs_3g_qos_sdu_error_e_type sdu_error;
+       gsm_gprs_3g_qos_residual_bit_error_e_type residual_bit_error;
+       GSM_Gprs3GQosDeliError delivery_erroreous_sdu;
+       char transfer_delay;
+       char traffic_handling_priority;
+       gsm_gprs_define_pdp_context_p_e_type pdp_type;
+} GSM_Set3GQOSType;
+
+
+typedef struct tag3GQOSTypeInfo {
+       gsm_gprs_3g_qos_traffic_e_type traffic;
+       char max_bitrate_ul;
+       char max_bitrate_dl;
+       char guarante_bitrate_ul;
+       char guarante_bitrate_dl;
+       GSM_Gprs3GQosDeliOrder delivery_order;
+       short max_sdu_size;
+       gsm_gprs_3g_qos_sdu_error_e_type sdu_error;
+       gsm_gprs_3g_qos_residual_bit_error_e_type residual_bit_error;
+       GSM_Gprs3GQosDeliError delivery_errorous_sdu;
+       char transfer_delay;
+       char traffic_handling_priority;
+       gsm_gprs_define_pdp_context_p_e_type pdp_type;
+} GSM_3GQOSTypeInfo;
+
+typedef struct tagRes3GQOSType {
+       gsm_gprs_qos_e_type type;
+       char num_type;
+       GSM_3GQOSTypeInfo info[3]; // max 3
+} GSM_Res3GQOSType;
+
+
+typedef enum {
+       DSTATE_OK = 0x00,
+       DSTATE_CONNECT,
+       DSTATE_RING,
+       DSTATE_NO_CARRIER,
+       DSTATE_ERROR,
+       DSTATE_NO_DIALTONE,
+       DSTATE_BUSY,
+       DSTATE_NO_ANSWER,
+       DSTATE_MAX,
+} GSM_GprsDataStatus;
+
+typedef enum {
+       DATA_REASON_NORMAL = 0x00,
+       DATA_REASON_REL_BY_USER,
+       DATA_REASON_REL_BY_NET,
+       DATA_REASON_REL_NET_BUSY,
+       DATA_REASON_SIGNAL_LOSS,
+       DATA_REASON_ORIG_FAIL_SIGNAL_LOSS,
+       DATA_REASON_ORIG_REJECTED_NO_FUNDS,
+       DATA_REASON_ORIG_SILENT_REDIA,
+       DATA_REASON_CALL_REASON_NO_SVC,
+       DATA_REASON_OTHERS,
+       DATA_REASON_BARRED,
+       DATA_REASON_MAX,
+} GSM_GprsDStatusReason;
+
+
+////////////////////////////////////////////////////////////////////
+typedef struct {
+       unsigned char cid;
+       unsigned char ip_addr[4];
+       unsigned char gateway_addr[4];
+       unsigned char dns_first[4];
+       unsigned char dns_second[4];
+       char eth_name[16];
+} GSM_GprsConnectionInfo;
+
+typedef struct {
+       unsigned char cid;
+       GSM_GprsDataStatus status;
+       GSM_GprsDStatusReason reason;
+       unsigned char external;
+} GSM_GprsPdpStatus;
+
+typedef enum{
+  GSM_GPRS_DEFINE_PDP_CONTEXT=0x01,    /* 0x01 : Define PDP Context */
+  GSM_GPRS_QOS,                                                /* 0x02 : Quality of Service Profile */
+  GSM_GPRS_PS,                                                 /* 0x03 : PS attach or detach */
+  GSM_GPRS_PDP_CONTEXT,                                /* 0x04 : PDP context activate or deactivate */
+  GSM_GPRS_ENTER_DATA,                                 /* 0x05 : Enter data */
+  GSM_GPRS_SHOW_PDP_ADDR,                      /* 0x06 : Show PDP address*/
+  GSM_GPRS_MS_CLASS,                                   /* 0x07 : GPRS mobile station class*/
+  GSM_GPRS_3G_QUAL_SRVC_PROFILE,               /* 0x08 : 3G Quality of service profile */
+  GSM_GPRS_IP_CONFIGURATION,                   /* 0x09 : Multiple PDP context IP configuration */
+  GSM_GPRS_DEFINE_SEC_PDP_CONTEXT,     /*0X0A : AT+CGDSCONT    05.10.07 ky.doo EDIT */
+  GSM_GPRS_TFT,                                                /*0X0B : AT+CGTFT       05.10.07 ky.doo EDIT */
+  GSM_GPRS_HSDPA_STATUS,                       /* 0x0C : HSDPA status */
+  GSM_GPRS_CURRENT_SESSION_DATA_COUNTER,             /* 0x0D : Current data session tx/rx total bytes */
+  GSM_GPRS_DATA_DORMANT,                     /* 0x0E : Force to set Dormant */
+  GSM_GPRS_DUN_PIN_CTRL ,                /* 0x0F : Dial up Networking Pin Control Message */
+  GSM_GPRS_CALL_STATUS,                             /* 0x10 : DS TE2 Data Call result(Multiple PDP) */
+  GSM_GPRS_MAX
+} gsm_sub_gprs_cmd_type;
+
+
+////////////////
+
+typedef struct gsm_GprsDbEntry {
+       char apn[255];
+       char intf[10];
+       GSM_GprsIPConfiguration ipconf;
+} gsm_GprsDbEntry;
+
+typedef struct gsm_GprsConfList {
+       int num;
+       gsm_GprsDbEntry *pentry;
+} gsm_GprsConfList;
+
+#endif // __vgsm_gprs_h__
+
+
+
diff --git a/libvmodem/vgsm_hdlc.h b/libvmodem/vgsm_hdlc.h
new file mode 100644 (file)
index 0000000..4c8c0f8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// vgsm_hdlc.h
+
+#ifndef _vgsm_hdlc_h_
+#define _vgsm_hdlc_h_
+
+#include "vgsm.h"
+
+// nsclass 
+typedef struct tagHDLCFrame {
+    unsigned char      m_StartMagicCode;
+    unsigned short     m_Length;
+    unsigned char      m_CtrlInfo;             // control information id
+    void*              m_pValue;
+    unsigned char      m_EndMagicCode;
+} HDLCFrame_t;
+
+// Last sent HDLC frame info
+void SetLastSentHDLCFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* GetLastSentHDLCFrameInfo();
+
+// Last receive HDLC frame info
+void SetLastRecvHDLCFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* GetLastRecvHDLCFrameInfo();
+
+void PushHDLCMultiFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* GetLastRecvHDLCMultiFrameInfo();
+TAT* ConvertHDLCMultiFrameToAT();
+void FreeAllMultiNodeList();
+
+#endif // _vgsm_hdlc_h_
+
+
diff --git a/libvmodem/vgsm_network.h b/libvmodem/vgsm_network.h
new file mode 100644 (file)
index 0000000..f8c785e
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __vgsm_net_h
+#define __vgsm_net_h
+/* MODE_SELECT field : Network Selection Mode */
+typedef enum{
+  GSM_NET_SEL_AUTO = 0x00,                /* 0x00 */
+  GSM_NET_SEL_MANU = 0x01,                /* 0x01 : Automatic */
+  GSM_NET_SEL_MANU_AUTO = 0x04,        /* 0x03 : Manual-Automatic */
+} gsm_net_sel_e_type;
+#if 0
+typedef enum{
+  GSM_NET_SEL_NONE = 0x00,             /* 0x00 */
+  GSM_NET_SEL_GLOBAL,                /* 0x01 : Automatic */    
+  GSM_NET_SEL_GSM_AUTO,                /* 0x02 : GSM Automatic selection*/
+  GSM_NET_SEL_GSM_MANU,                /* 0x03 : GSM Manual selection*/
+  GSM_NET_SEL_CDMA ,                   /* 0x04 : CDMA selection*/
+  GSM_NET_SEL_MAX = 0x04
+} gsm_net_sel_e_type;
+#endif
+/* MODE_SELECT field : NITZ Information Mode by cosmos in 20090213 */
+typedef enum{
+  GSM_TEXT_ENC_ASCII = 0x01,                   /* 0x01 : ASCII   */
+  GSM_TEXT_ENC_GSM7BIT,                                        /* 0x02 : GSM7BIT */
+  GSM_TEXT_ENC_UCS2,                                   /* 0x03 : UCS2 */
+  GSM_TEXT_ENC_HEX,                                     /* 0x04 : HEX */
+  GSM_TEXT_ENC_MAX
+} gsm_text_enc_e_type;
+
+/* ACT field */
+/* Access technology selected */
+typedef enum{
+  GSM_NET_ACT_GSM = 0x00,            /* 0x00 : GSM */
+  GSM_NET_ACT_GSM_COMPACT,      /* 0x01 : GSM Compact */
+  GSM_NET_ACT_UTRAN,                   /* 0x02 : UMTS */
+  GSM_NET_ACT_EGPRS,                 /* 0x03 : EGPRS */
+  GSM_NET_ACT_GPRS,                     /* 0x04 : GPRS */
+  GSM_NET_ACT_NOTSPECIFIED=0xFF,     /* 0xFF : Not Specified*/
+  GSM_NET_ACT_MAX
+} gsm_net_act_e_type;
+
+/* SERVICE_DOMAIN field */
+typedef enum {
+  GSM_NET_SERVICE_DOMAIN_COMBINED =0x01,     /* 0x01 : Combined(CS + PS) Mode */
+  GSM_NET_SERVICE_DOMAIN_CIRCUIT,            /* 0x02 : Circuit Only Mode */
+  GSM_NET_SERVICE_DOMAIN_PACKET,                /* 0x03 : Packet service Only Mode */
+  GSM_NET_SERVICE_DOMAIN_MODE_MAX
+} gsm_net_svc_domain_e_type;
+
+/* BAND_MODE field */
+typedef enum {
+  GSM_NET_BAND_MODE_PREF =0x01,     /* 0x01 : Band Preferred Mode */
+  GSM_NET_BAND_MODE_ONLY,               /* 0x02 : Band Only Mode */
+  GSM_NET_BAND_MODE_MAX
+} gsm_net_band_mode_e_type;
+
+/* REGIST_STATUS  field */
+/* Registration status */
+typedef enum{
+  GSM_NET_REG_STAT_NOT_REG=0x00,   /* 0x00 : not registered, ME is not currently searching a new
+                                                                                      PLMN to register to */
+  GSM_NET_REG_STAT_REG_HOME,          /* 0x01 : Registered, home network */
+  GSM_NET_REG_STAT_SEARCHING,         /* 0x02 : not registered, but ME is currently searching a new
+                                                                                  SPLMN to register to */
+  GSM_NET_REG_STAT_REG_DENIED,       /* 0x03 : registration denied */
+  GSM_NET_REG_STAT_UNKNOWN,           /* 0x04 : unknown */
+  GSM_NET_REG_STAT_REG_ROAM,          /* 0x05 : registered, roaming */
+  GSM_NET_REG_STAT_MAX
+} gsm_net_regist_status_e_type;
+
+/* EDGE_SUPPORT filed */
+typedef enum{
+  GSM_NET_EDGE_NOTSUPPORT=0x00,
+  GSM_NET_EDGE_SUPPORT=0x01
+}gsm_net_edge_support_e_type;
+
+/* PLMN_STATUS  field */
+typedef enum{
+  GSM_NET_PLMN_STATUS_UNKNOWN = 0x00,        /* 0x00 : Unknown or unavailable */
+  GSM_NET_PLMN_STATUS_AVAIL,               /* 0x01 : Available */
+  GSM_NET_PLMN_STATUS_CURRENT,          /* 0x02 : Current */
+  GSM_NET_PLMN_STATUS_FORBIDDEN,      /* 0x03 : Forbidden */
+  GSM_NET_PLMN_STATUS_MAX
+} gsm_net_plmn_status_e_type;
+
+typedef enum{
+  GSM_NET_PLMN_FORMAT_LONGALPHANUMERIC = 0x00,
+  GSM_NET_PLMN_FORMAT_SHORTALPHANUMERIC,
+  GSM_NET_PLMN_FORMAT_NUMERIC
+} gsm_net_plmn_format_e_type;
+typedef enum{
+  GSM_NET_NITZ_MMINFO_CS = 0x00,        /* 0x00 : CS*/
+  GSM_NET_NITZ_MMINFO_PS = 0x01,        /* 0x01 : PS*/
+  GSM_NET_NITZ_MMINFO_MAX
+}gsm_net_identity_mm_info_e_type;
+
+typedef enum{
+  GSM_NET_NITZ_SHORT_NAME_MASK = 0x01,        /* 0x01: short name active mask*/
+  GSM_NET_NITZ_FULL_NAME_MASK  = 0x02,        /* 0x02: full name active mask*/
+  GSM_NET_NITZ_ALL_NAME_MASK   = 0xff,        /* 0xff All names active mask*/
+  GSM_NET_NITZ_NAME_MAX
+}gsm_net_identity_active_mask_e_type;
+
+typedef enum{
+  GSM_NET_NITZ_DCS_ASCII       = 0x01,
+   GSM_NET_NITZ_DCS_GSM7BIT  = 0x02,
+   GSM_NET_NITZ_DCS_UCS2       = 0x03,
+   GSM_NET_NITZ_DCS_HEX         = 0x04,
+    GSM_NET_NITZ_DCS_MAX
+}gsm_net_identity_data_coding_scheme;
+typedef struct {
+    gsm_net_plmn_status_e_type status;
+    char plmn[6]; /* PLMN: MCC(3byte)+MNC(3byte) MNC°¡ 2ÀÚ¸®ÀΠ°æ¿ì ¸¶Áö¸· ºóÀÚ¸®¿¡ '#'À» Ã¤¿ö 6ÀÚ¸®·Î ¸¸µé¾î ÁÜ */
+    gsm_net_act_e_type act;
+} gsm_network_plmn_record_t;// GSM_NetPLMNRecord;
+
+typedef struct {
+    char num_record;
+    gsm_network_plmn_record_t* precord;
+} gsm_network_plmn_list_t; // GSM_NetResPLMNList;
+
+typedef struct {
+    gsm_net_act_e_type act;
+    gsm_net_svc_domain_e_type service_domain;
+    gsm_net_regist_status_e_type reg_status;
+    gsm_net_edge_support_e_type edge_support;
+    unsigned char lac[2];
+    unsigned char cell_id[4];
+    unsigned char rej_cause;
+} gsm_network_reg_t; //GSM_NetworkRegistration
+
+/* GSM_PLMN Information by cosmos in 20090212 */
+typedef struct {
+    gsm_net_act_e_type act;
+    gsm_network_plmn_record_t statusplmn;
+       gsm_net_sel_e_type mode;
+} gsm_network_plmn_info_t;
+
+/* GSM_NITZ Information by cosmos in 20090212 */
+typedef struct {
+       gsm_net_identity_mm_info_e_type mm_info_type;
+       gsm_net_identity_active_mask_e_type mask;
+       char    shortname_ci ; // 00 : disable, 01 : enable
+       char    shortname_len ; // max 16
+       gsm_net_identity_data_coding_scheme     shortname_dcs ; //
+       char shortname[16];
+       char longname_ci ; // 00 : disable, 01 : enable
+       char    longname_len ; // max 32
+       gsm_net_identity_data_coding_scheme     longname_dcs ; //
+       char longname[32];
+} gsm_network_nitz_info_t;
+
+#endif
diff --git a/libvmodem/vgsm_pb.h b/libvmodem/vgsm_pb.h
new file mode 100644 (file)
index 0000000..71c1153
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_pb_h_
+#define _vgsm_pb_h_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+typedef enum{
+  GSM_PB_ST_DC=0x01,   /* 0x01 : ME dialed calls list */
+  GSM_PB_ST_EN,                /* 0x02 : SIM ( or ME ) emergency number */
+  GSM_PB_ST_FD,                /* 0x03 : SIM fixed-dialing phonebook EF[FDN] */
+  GSM_PB_ST_LD,                /* 0x04 : SIM last-dialing phonebook */
+  GSM_PB_ST_MC,                /* 0x05 : ME missed calls list */
+  GSM_PB_ST_ME,                /* 0x06 : ME phonebook */
+  GSM_PB_ST_MT,                /* 0x07 : Combined ME and SIM phonebook */
+  GSM_PB_ST_ON,                /* 0x08 : SIM ( or ME ) own numbers ( MSISDNs ) list EF[MSISDN], */
+  GSM_PB_ST_RC,                /* 0x09 : ME received calls list */
+  GSM_PB_ST_SIM,               /* 0x0A : SIM phonebook EF[ADN], DF[PHONEBOOK] */
+  GSM_PB_ST_SDN,        /* 0x0B : Service Dialing Number */
+  GSM_PB_ST_3GSIM,             /*0x0C : 3G SIM Phonebook EF[ADN]*/
+  GSM_PB_ST_ICI,                       /*0x0D : Incoming Call Information*/
+  GSM_PB_ST_OCI,               /*0x0E : Outgoing Call Information*/
+  GSM_PB_ST_AAS,               /*0x0F : Additional Number Alpha String*/
+  GSM_PB_ST_GAS,               /*0x10 : Grouping Information String*/
+  GSM_PB_ST_MAX
+} gsm_pb_storage_type_e_type;
+
+
+/* MODE  field */
+typedef enum{
+       GSM_PB_MODE_READ        = 0x00, /* 0x00 */
+       GSM_PB_MODE_ADD,                        /* 0x01 */
+       GSM_PB_MODE_DEL,                        /* 0x02 */
+       GSM_PB_MODE_EDIT,                       /* 0x03 */
+       GSM_PB_MODE_DELETE_ALL, /* 0x04 */
+       GSM_PB_MODE_MAX
+} gsm_pb_acc_mode_e_type;
+
+
+typedef struct m_PB PB_;
+struct m_PB {
+       gsm_pb_storage_type_e_type db_st_type;
+       char name[30];
+       char number[20];
+       char address[30];
+};
+
+/*********************************************************************************
+
+                                            Sub Command
+
+**********************************************************************************/
+typedef enum{
+  GSM_PB_ACCESS=0x01,     /* 0x01 : PhoneBook Access Message */
+  GSM_PB_STORAGE,            /* 0x02 : PhoneBook Storage Message */
+  GSM_PB_STORAGE_LIST,  /* 0x03 : PhoneBook Storage List Message */
+  GSM_PB_ENTRY_INFO,      /* 0x04 : PhoneBook Entry Information Message */
+  GSM_PB_CAPABILITY_INFO,      /* 0x05 : PhoneBook Grouping List Message */
+  GSM_PB_MAX
+} gsm_pb_sub_cmd_type;
+
+
+#if 0 
+/*
+typedef struct tagPB2G {
+       unsigned char num_type;
+       unsigned char num_len;
+       unsigned char txt_len;
+       char number[256];
+       char text[256];
+} GSM_PhoneBook2G;
+
+typedef struct tagPB3GGrp {
+       GSM_PB_GRP_TYPE grp_type;
+       unsigned char grp_len;
+       unsigned char num_type;
+       char data[256];
+} GSM_PhoneBook3GGrp;
+
+typedef struct tagPB3G {
+       unsigned char hidden_entry;
+       unsigned char num_pb_grp;
+       GSM_PhoneBook3GGrp pb_grp[10];
+} GSM_PhoneBook3G;
+
+typedef struct tagPBdata {
+       GSM_PB_ACCESS_MODE mode;
+       unsigned short index;
+       GSM_PB_CARD pb_type;
+       union {
+               GSM_PhoneBook2G* ptr_pb2g;
+               GSM_PhoneBook3G* ptr_pb3g;
+       } pb;
+} GSM_PhoneBookData;
+*/
+
+typedef struct {
+       GSM_PB_ACCESS_MODE mode;
+       unsigned short index;
+       unsigned short next_idx; 
+       GSM_PB_CARD pb_type;
+       unsigned char len_number;
+       unsigned char record_type;
+       char number[256];
+       unsigned char len_text;
+       unsigned char text_encode;
+       char text[256];
+} GSM_PhoneBookData2G;
+
+typedef struct tagPBStorageInfo {
+       PB_STORAGE_TYPE storage_type;
+       unsigned short total_count;
+       unsigned short used_count;
+} GSM_PhoneBookStorageInfo;
+
+typedef struct tagPBEntryInfo {
+       unsigned short pb_index_min;
+       unsigned short pb_index_max;
+       unsigned short pb_num_max;
+       unsigned short pb_text_max;
+} GSM_PhoneBookEntryInfo;
+
+typedef struct tagPBGrpName {
+       unsigned char grp_name_len;
+       char grp_name[256];
+} GSM_PhoneBookGroupName;
+
+typedef struct tagPBGrpNameList {
+       unsigned char num_grp;
+
+       GSM_PhoneBookGroupName* grp_name_list;
+} GSM_PhoneBookGroupNameList;
+
+#endif 
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __vgsm_pb_h_
diff --git a/libvmodem/vgsm_phone.h b/libvmodem/vgsm_phone.h
new file mode 100644 (file)
index 0000000..c148cca
--- /dev/null
@@ -0,0 +1,1484 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_phone_h_
+#define _vgsm_phone_h_
+
+/* 
+ * I858 TAPI ºÎ°¡ ¼³¸í
+ *
+ * I858 TAPI API´Â I519/I819¿Í Å©°Ô ´Ù¸£Áö ¾Ê´Ù. ¶ÇÇÑ 
+ * 1. ÇÁ·ÎÁ§Æ®ÀÇ µ¿½Ã ÁøÇàÀ¸·Î ÀÎÇÑ ±¸ºÐ ÇÊ¿ä.
+ * 2. GSM Only Mode¸¸¿¡¼­¸¸ ÇÊ¿äÇÑ ³»¿ëµéÀ» À§ÇÑ ½Å±Ô ³»¿ë
+ * À» À§Çؼ­ µð·ºÅ丮´Â ºÐ¸®ÇÏ¿´½¿.
+ *
+ * - TAPI 
+ * Dialer, PhoneBookµîÀÇ phone client¿Í phone server¿ÍÀÇ µ¥ÀÌŸ ±³È­¿¡
+ * ÇÊ¿äÇÑ ÆÐŶÀÇ ±âº» ±¸Á¶´Â µ¿ÀÏÇϸ砰¢°¢¿¡ ´ëÇÑ ³»¿ëÀº ¾Æ·¡ÀÇ ÁÖ¼®À»
+ * Âü°í ¹Ù¶÷.
+ *
+ * - TAPI packet ±âº» ±¸Á¶. TAPI packetÀÇ RX, TX´Â ¾Æ·¡¿Í °°ÀÌ µ¿ÀÏÇÑ ÇüÅÂ
+ * +--------+--------+-------------+---------------------------------------+
+ * |MAIN CMD|SUB CMD | Data Length |  DATA                                 |
+ * | 1byte  | 1byte  |  2bytes     |   Data Length's Byte(s)               |
+ * +--------+--------+-------------+---------------------------------------+
+ *
+  * Data Length´Â DATAÀÇ ±æÀ̸¸À» ÀǹÌÇÑ´Ù. Áï µ¥ÀÌŸ°¡ ¾ø´Â °æ¿ì¿¡´Â Length´Â
+ * 0ÀÌ µÈ´Ù.
+ *
+ */
+
+/* 
+ * Main command group
+ */
+#define GSM_CALL                             0x01
+#define GSM_NETWORK                          0x02
+#define GSM_SUPS                             0x03
+#define GSM_SMS                              0x04
+#define GSM_MISC                             0x05
+#define GSM_DISPLAY                          0x06
+#define GSM_SIM                              0x07
+#define GSM_DATA                             0x08
+#define GSM_SAT                                0x09
+#define GSM_SOUND                                                      0x0A
+#define GSM_EXT                              0x0B
+#define GSM_SERVICEMODE                                                0x0C
+#define GSM_EMULATOR                         0x0D
+#define GSM_GPRS                             0x0E
+#define GSM_POWER                             0x0F
+#define GSM_CLIENT             0x10
+#define RESTORE_EI_DATA                                                0x11
+#define FUNC_EDB                                                       0x12
+#define FUNC_EDB_IND                                           0x01
+#define FUNC_SINGLEDB_IND                                              0x02
+
+/* --------------------------------------------------------------------------
+   GSM_CLIENT : 
+   --------------------------------------------------------------------------*/
+#define GSM_CLIENT_RELEASE_NOTI                0x01
+#define GSM_CLIENT_RELEASE_NOTI_ACK            0x02
+/* --------------------------------------------------------------------------
+   GSM_CALL : Call Control Functions
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : Caller ID ±æÀÌ(VAR) 
+ * Data   : 
+ * - Caller ID 
+ */
+#define GSM_CALL_MAKE_REQ                     0x21
+/*
+ * Length : 2bytes
+ * Data   : 
+ * - NUM Calls (1byte) 
+ * - Call ID   (1byte)
+ */
+#define GSM_CALL_HANGUP_REQ                   0x22
+/*
+ * Length : 1byte
+ * Data   :
+ * - Call ID   (1byte)
+ */
+#define GSM_CALL_ANSWER_REQ                   0x23
+
+/*
+ * Length : None
+ */
+#define GSM_CALL_LIST_REQ                     0x24
+
+/*
+ * Length : 1byte
+ * Data   :
+ * - Call ID   (1byte)
+ */
+#define GSM_CALL_WAITING_STATUS_CFRM           0x25
+
+/*
+ * Length : VAR
+ * Data   :
+ * - GSM_MPTY_OPERATION : 1byte (mzgsmcall.h ÂüÁ¶)
+ * - GSM_MPTY_PARAM_ID  : 1byte
+ * - parameter length   : 1byte
+ * - param              : VAR
+ */
+#define GSM_CALL_CONTROL_REQ                  0x26
+
+/*
+ * Length : 1byte
+ * Data   :
+ * - digit : 1 byte
+ */
+#define GSM_CALL_GENERATE_DTMF_REQ            0x27
+
+// EMTRACE_I878 [ 
+// Testing purpose
+#define GSM_CALL_GET_FAKE_CALLLIST_REQ         0x28
+// EMTRACE_I878, civily 20051014 ]
+/*
+ * Length : 0
+ * Data   :
+ * - None
+ */
+#define GSM_CALL_GET_AUTOREDIAL_REQ           0x29
+
+/*
+ * Length : 1
+ * Data   :
+ * - Enable or Disable
+ */
+#define GSM_CALL_SET_AUTOREDIAL_REQ           0x2A
+#define GSM_CALL_LIST_CFRM                    0x2B
+
+/*
+ * Length : Caller ID ±æÀÌ (VAR) 
+ * Data   : 
+ * - Caller ID 
+ */
+#define GSM_CALL_MAKE_TO_DEVICE_REQ           0x2C
+#define GSM_CALL_TO_DEVICE_CFRM               0x2D
+
+/* --------------------------------------------------------------------------
+   GSM_CALL : Notification or Response
+   --------------------------------------------------------------------------*/
+
+#define GSM_CALL_ID                           0x20
+
+/*
+ * Length : (VAR)
+ * Data   :
+ * - Call ID       (1byte)
+ * - Forwared flag (1byte)
+ * - Call ID Length(1byte)
+ * - Call ID       (VAR)
+ *
+ * ÁÖÀÇ : CLIR_CAUSE´Â »èÁ¦
+ */
+
+#define GSM_CALL_INCOMING_NOTI                0x21
+/*
+ * Length : 3bytes
+ * Data   :
+ * - Call ID      (1byte)
+ * - Forwared     (1byte)
+ * - Status       (1byte)  mzgsmcall.h ¿¡ Àִ °ª°ú ¼³¸íÀ» ÂüÁ¶
+ * ÁÖÀÇ : CAUSE, NUM_CALLS_IN_USE´Â »èÁ¦
+ */
+#define GSM_CALL_STATUS_NOTI                  0x22
+/*
+ * Length : VAR 1byte(Reserved1) + 1byte(Reserved2) + 
+ * 1byte(Call Count) + (Call Count) * 5 (Call Data)
+ * DATA   :
+ * - Reserved1      (1byte)
+ * - Reserved2      (1byte)
+ *
+ * - Call Count     (1byte)
+ *
+ *   ÀÌÇÏ 5¹ÙÀÌÆ®´Â Call Count ¸¸Å­ ¹Ýº¹.
+ * - Call ID        (1byte)
+ * - GSM_Call_Dir   (1byte) mzgsmcall.h ÂüÁ¶
+ * - GSM_Call_Stat  (1byte) mzgsmcall.h ÂüÁ¶
+ * - GSM_Call_Mode  (1byte) mzgsmcall.h ÂüÁ¶(Voice¸¸ Ãë±ÞÇÒ°Í)
+ * - MPTY           (1byte) 0x01 mpty, 0x00 single
+ */
+#define GSM_CALL_LIST_RES                     0x23
+
+/*
+ * Length : VAR 1byte(result) + 1byte(Operation) + 1byte(call Id) + 
+ * (Call Count) + VAR(Call Count * 1)
+ * DATA   :
+ * - result (1byte) 
+ * - GSM_MPTY_OPERATION (1byte) mzgsmcall.h ÂüÁ¶
+ * - GSM_MPTY_PARAM_ID  (1byte) mzgsmcall.h ÂüÁ¶
+ * - active call count  (1byte)
+ * - active call list   (VAR)
+ */
+#define GSM_CALL_CONTROL_RES                  0x24
+
+/*
+ * Length : 2
+ * Data   :
+ * - call id (1byte)
+ * - status  (1byte) 
+ * 0x01 : waiting »óÅ GSM_Call_Dialing, GSM_Call_Alerting, GSM_Call_Incoming
+ * 0x00 : not waiting »óÅ GSM_Call_Active, GSM_Call_Release
+ */
+#define GSM_CALL_WAITING_STATUS_IND           0x25
+
+
+/*
+ * Length : (VAR)
+ * Data   :
+ * - Call ID          Length (1byte)
+ * - Connected Line          (VAR)
+ */
+
+#define GSM_CALL_CONNECTED_LINE_NOTI          0x26
+
+/*
+ * Length : 1
+ * Data   :
+ * - the reason of redialing mode
+ */
+#define GSM_CALL_AUTOREDIAL_NOTI              0x27
+
+/*
+ * Length : 2
+ * - Result    : 1 byte 
+ * - ALS value : 1 byte 
+ */
+#define GSM_CALL_GET_AUTO_REDIAL_RES          0x28
+
+/*
+ * Length : 0
+ */
+#define GSM_CALL_CALL_LIST_IND                0x29
+
+/*
+ *
+ */
+#define GSM_CALL_WAITING_STATUS_TO_DEVICE_IND 0x2A
+
+/*
+ * Length : 0
+ */
+#define GSM_CALL_CONNECTION_TONE_NOTI         0x2B
+
+/*
+ * Length : 1
+ */
+#define GSM_CALL_SMASO_NOTI                   0x2C
+
+/*
+ * Length : 1
+ * result : 1 byte
+ */
+#define GSM_CALL_MAKE_RES                     0x2D
+
+/*
+ * Length : 1
+ * result : 1 byte
+ */
+#define GSM_CALL_ANSWER_RES                   0x2E
+
+/*
+ * Length : 1
+ * result : 1 byte
+ */
+#define GSM_CALL_HANGUP_RES                   0x2F
+
+// sunnyfan 2006.01.17
+#define GSM_CALL_GET_ALS_MV_REQ                                0x41
+#define GSM_CALL_GET_ALS_MV_RES                                0x42
+#define GSM_CALL_SET_ALS_MV_REQ                                0x43
+#define GSM_CALL_SET_ALS_MV_RES                                0x44
+// sunnyfan ]
+
+// sunnyfan, 2005.11.17 [
+#define GSM_CALL_GENERATE_DTMF_RES            0x50
+
+#define GSM_CALL_GENRES_DTMF                                    0x51
+// sunnyfan ]
+
+#define GSM_CALL_STATE                                 0x61
+#define GSM_CALL_ALERT_IND                             0x62 
+
+/* --------------------------------------------------------------------------
+   GSM_NETWORK : Network Functions
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_CURRENT_MODE_REQ          0x31
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_SET_AUTOMATIC_MODE_REQ    0x32
+
+/*
+ * Length : Zero
+ * Data   :
+ * - operator name (5byte)
+ */
+#define GSM_NETWORK_SET_MANUAL_MODE_REQ       0x33
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_INQUIRY_OPERATOR_REQ      0x34
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_GPRS_STATE_REQ            0x35
+
+/*
+ * Length : None
+ */
+#define GSM_NETWORK_GET_BAND_REQ              0x36
+
+/*
+ * Length : 1
+ * - Band value : 1 byte 
+ */
+#define GSM_NETWORK_SET_BAND_REQ              0x37
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_GET_SIGNAL_REQ            0x38
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_GET_NETWORK_INFO_REQ      0x39
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_CANCEL_OPERATOR_REQ       0x3A
+
+/*
+ * Length : Zero
+ * Data   :
+ * - None
+ */
+#define GSM_NETWORK_GET_INDICATOR_REQ         0x3B
+
+// EMTRACE_I878 [
+#define GSM_NETWORK_SET_SVCDOMAIN_REQ          0x3C
+#define GSM_NETWORK_SET_POWERONATTACH_REQ      0x3D
+#define GSM_NETWORK_GET_SVCDOMAIN_REQ          0x3E
+#define GSM_NETWORK_GET_POWERONATTACH_REQ      0x3F
+// EMTRACE_I878, civily 2005.10.13 ]
+/* --------------------------------------------------------------------------
+   GSM_NETWORK : Notification or Response
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : 1 + 1 + VAR(Network Name)
+ * - State        (1byte) mzgsmnet.h ¿¡ Àִ °ª°ú ¼³¸íÀ» ÂüÁ¶
+ * - Length       (1byte) Network Name Length
+ * - Network Name (VAR)
+ */
+#define GSM_NETWORK_REG_NOTI                  0x31
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ *
+ */
+// CAUTION : ÇâÈÄ ¹®ÀÚ¿­ÀÌ ¾Æ´Ñ À妽º°ª¸¸ Àü´ÞµÇ´Â °ÍÀ¸·Î ¼öÁ¤
+#define GSM_NETWORK_SMNT_NOTI                 0x32
+
+/*
+ * Length : 1 + 1 + VAR
+ * GSM_OperMode    : 1byte
+ * Length MCC+MNC  : 1byte
+ * operator name   : VAR
+ */
+#define GSM_NETWORK_CURRENT_MODE_RES          0x33
+
+/*
+ * Length : NONE
+ */
+#define GSM_NETWORK_SET_AUTOMATIC_MODE_RES    0x34
+
+/*
+ * Length : NONE
+ */
+#define GSM_NETWORK_SET_MANUAL_MODE_RES       0x35
+
+/*
+ * Length : 1 + (item count * 6)
+ * Data   :
+ * - count    : 1byte
+ * - mode     : 1byte
+ * - operator : 5byte
+ */
+#define GSM_NETWORK_INQUIRY_OPERATOR_RES      0x36
+
+/*
+ * Length : 2
+ * - Result    : 1 byte 
+ * - Band value: 1 byte 
+ */
+#define GSM_NETWORK_GET_BAND_RES              0x37
+
+/*
+ * Length : 2
+ * - Result    : 1 byte 
+ * - Band value: 1 byte 
+ */
+#define GSM_NETWORK_SET_BAND_RES               0x38
+
+/*
+ * Length : 2
+ * Data   :
+ * - result : 0x00 (ok) or 0x01 (failed)
+ * - mode : refer mzgsmnet.h
+ */
+#define GSM_NETWORK_GET_NETWORK_INFO_RES       0x39
+
+// EMTRACE_I878 [
+#define GSM_NETWORK_POWERONATTACH_RES                  0x3A
+#define GSM_NETWORK_SVCDOMAIN_RES                              0x3B
+// EMTRACE_I878, civily 2005.10.13 ]
+
+#define GSM_NETWORK_PLMN_LIST          0x3C
+
+
+#define GSM_NETWORK_CURRENT_PLMN_NOTI          0x3D
+
+/* gsm_network_current_plmn_info, nitz info by cosmos in 20090213 */
+#define GSM_NETWORK_CURRENT_PLMN_INFO          0x3E
+#define GSM_NETWORK_CURRENT_NITZ_INFO          0x3F
+
+/* --------------------------------------------------------------------------
+   GSM_SUPS : Sups Service TX function
+   --------------------------------------------------------------------------*/
+/*
+ * Length : MMI String ±æÀÌ(VAR) 
+ * Data   : 
+ * - MMI String
+ */
+#define GSM_SUPS_MMI_REQ                      0x41
+
+/*
+ * Length : 1(fac value) + 1(class)
+ * Data   :
+ * - fac value (1byte) mzgsmsups.h ÂüÁ¶
+ * - class     (1byte) mzgsmmisc.h ÂüÁ¶
+ */
+#define GSM_SUPS_GET_FAC_LOCK_STATUS_REQ      0x42
+
+/*
+ * Length : 1(fac value) + 1(class) + 1(mode) + 1(pw length) + VAR(passwd)
+ * Data   :
+ * - fac value (1byte) mzgsmsups.h ÂüÁ¶
+ * - class     (1byte) mzgsmmisc.h ÂüÁ¶
+ * - mode      (1byte) mzgsmsups.h ÂüÁ¶
+ * - pw length (1byte)
+ * - passwd    (pw length bytes)
+ */
+#define GSM_SUPS_SET_FAC_LOCK_STATUS_REQ      0x43
+
+/*
+ * Length : 1(the reason)
+ * Data   :
+ * - GSM_CF_Reason    (1byte) mzgsmsups.h ÂüÁ¶
+ */
+#define GSM_SUPS_GET_CCFC_REQ                 0x44
+
+/*
+ * Length : sizeof (struct GSM_CF_Data)
+ * Data   :
+ * - GSM_CF_Data    (1byte) mzgsmsups.h ÂüÁ¶
+ */
+#define GSM_SUPS_SET_CCFC_REQ                 0x45
+
+/*
+ * Length : 0
+ */
+#define GSM_SUPS_GET_CLIR_REQ                 0x46
+
+/*
+ * Length : 1 (CLIR Setting Value)
+ * Data   :
+ * - CLIR_Activation_Status : (1byte)
+ */
+#define GSM_SUPS_SET_CLIR_REQ                 0x47
+
+/*
+ * Length : 1(CW_Notify) + 1(GSM_CW_Mode) + 1(GSM_ClassX)
+ * Data   :
+ * - CW_Notify : (1byte) 
+ * - CW_Mode   : (1byte)
+ * - GSM_ClassX  (1byte)
+ */
+#define GSM_SUPS_GET_CW_REQ                   0x48
+
+/*
+ * Length : 1(CW_Notify) + 1(GSM_CW_Mode) + 1(GSM_ClassX)
+ * Data   :
+ * - CW_Notify : (1byte) 
+ * - CW_Mode   : (1byte)
+ * - GSM_ClassX  (1byte)
+ */
+#define GSM_SUPS_SET_CW_REQ                   0x49
+
+/*
+ * Length : 1(GSM_AOC_Value)
+ * Data   :
+ * - None
+ */
+#define GSM_SUPS_AOC_REQ                      0x4A
+
+/*
+ * Length : None
+ * Data   :
+ * - None
+ */
+#define GSM_SUPS_AOC_RESET_REQ                0x4B
+
+/*
+ * Length : 11
+ * Data   :
+ * - acm max value (6bytes) // Hexadecimal value
+ * - pin2 length   (1byte)
+ * - pin2          (4byte)
+ */
+#define GSM_SUPS_SET_ACM_MAX_REQ              0x4C
+
+/*
+ * Length : 
+ * Data   :
+ * - AOC_CURRENCY_Code (1byte)
+ * - length            (1byte)
+ * - price             (VAR)
+ */
+#define GSM_SUPS_AOC_SET_PPU_REQ              0x4D
+
+/*
+ * Length : USSD String ±æÀÌ(VAR) 
+ * Data   : 
+ * - USSD String
+ */
+#define GSM_SUPS_USSD_SEND_REQ                0x4E             
+
+/*
+ * Length : 0
+ * Data   : 
+ * - None
+ */
+#define GSM_SUPS_USSD_CANCEL_REQ              0x4F
+// sunnyfan, 2005.11.09 [
+#define GSM_SUPS_PWDSET_CB_REQ                          0x50
+#define GSM_SUPS_SET_CB_REQ                                     0x51
+#define GSM_SUPS_GET_CB_REQ                                     0x52
+#define GSM_SUPS_USSD_SEND_CONFIRM            0x53
+#define GSM_SUPS_NOTI_FEEDBACK                          0x54
+#define GSM_SUPS_MESSAGE_FEEDBACK                       0x55
+// sunnyfan ]
+
+
+/*
+ * Length : 1
+ * Data   : 
+ * - Barring Facility
+ */
+#define GSM_SUPS_CB_STATUS_REQ                0x56
+
+/*
+ * Length : 0
+ * Data   : 
+ * - None
+ */
+#define GSM_SUPS_GET_PPU_REQ                  0x57
+
+/* --------------------------------------------------------------------------
+   GSM_SUPS : Notification or Response
+   --------------------------------------------------------------------------*/
+// sunnyfan, 2006.01.19 [
+#define GSM_SUPS_NETWORK_POPUP_MESSAGE         0x40
+// sunnyfan ]
+/*
+ * Length : 1(status) + 1(fac value) + 1(class)
+ * Data   :
+ * - status      (1byte) 0x00 : not active, 0x01 : active  
+ * - fac   value (1byte) mzgsmsups.h ÂüÁ¶
+ * - class value (1byte) mzgsmsups.h ÂüÁ¶
+ */
+#define GSM_SUPS_GET_FAC_LOCK_STATUS_RES      0x41
+
+/*
+ * Length : 1(fac value) + 1(class) + 1(mode)
+ * Data   :
+ * - result (1byte) 
+ * - fac    (1byte) mzgsmsups.h ÂüÁ¶
+ * - remain (1byte)
+ */
+#define GSM_SUPS_SET_FAC_LOCK_STATUS_RES      0x42
+
+/*
+ * Length : 1(status) + 1(class) + 1(number_length) + VAR(number) +
+ *          1(time)
+ * Data   :
+ * - GSM_CF_Status   (1byte) mzgsmsups.h ÂüÁ¶
+ * - GSM_ClassX      (1byte)
+ * - length          (1byte)
+ * - DN              (VAR)
+ * - time            (1byte) only 'no reply' case
+ */
+#define GSM_SUPS_GET_CCFC_RES                 0x43
+
+/*
+ * Length : 1(Activation Status) + 1(Network Provisioning Status)
+ * Data   :
+ * - CLIR_Activation_Status (1byte) mzgsmsups.h ÂüÁ¶
+ * - CLIR_Provision_Status  (1byte) mzgsmsups.h ÂüÁ¶
+ */
+#define GSM_SUPS_GET_CLIR_RES                 0x44
+
+/*
+ * Length : 1(status) + 1(class)
+ * Data   :
+ * - GSM_CW_Status   (1byte) mzgsmsups.h
+ * - GSM_ClassX      (1byte) mzgsmsups.h
+ */
+#define GSM_SUPS_GET_CW_RES                   0x45
+
+/*
+ * Length : 1(notify code) + 2(USSD str length) + VAR(USSD string) + 1(dcs)
+ * Data   :
+ * - USSD_Notify        (1byte) mzgsmsups.h
+ * - USSD string length (2byte)
+ * - USSD String        (VAR)
+ * - Decoding Scheme    (1byte)
+ */
+#define GSM_SUPS_USSD_NOTI                    0x46
+
+#define GSM_SUPS_CW_NOTI                      0x47
+
+/*
+ * Length : 2(code) + 1(Call id)
+ * Data
+ * CSSU code 2 value (2bytes)
+ * Call id           (1byte)
+ */
+#define GSM_SUPS_CSSU_NOTI                    0x48
+
+/*
+ * Length : 2(code)
+ * Data
+ * CSSI code 2 value (2bytes)
+ */
+#define GSM_SUPS_CSSI_NOTI                    0x49
+
+/*
+ * Length : 2(code)
+ * Data
+ * CSSI code 2 value (2bytes)
+ */
+#define GSM_SUPS_CSSI_NOTI                    0x49
+
+/*
+ * Length : 4(code)
+ * Data
+ * CCCM code 4 value (4bytes)
+ */
+#define GSM_SUPS_CCCM_NOTI                    0x4A
+
+/*
+ * Length : 18
+ * Data
+ * - CCM  : 6bytes  // String type hexdecimal e.g : "00001E" indicates decimal
+ *                  // value 30
+ * - CACM : 6bytes  // type same as CCM
+ * - CAMM : 6bytes  // type same as CCM
+ */
+#define GSM_SUPS_AOC_RES                      0x4B
+
+/*
+ * Length : 0
+ * Data   :
+ * - None
+ */
+#define GSM_SUPS_AOC_RESET_RES                0x4C
+
+/*
+ * Length : 0
+ * Data   :
+ * - None
+ */
+#define GSM_SUPS_SET_ACM_MAX_RES              0x4D
+
+/*
+ * Length : 0
+ * Data   :
+ * - None
+ */
+#define GSM_SUPS_AOC_SET_PPU_RES              0x4E
+
+/*
+ * Length : 1
+ * Data   :
+ * - Result
+ */
+#define GSM_SUPS_MMI_RES                      0x4F
+
+#define GSM_SUPS_GET_CB_RES                                     0x50
+#define GSM_SUPS_CB_NOTI                                                0x51
+#define GSM_SUPS_CB_PW_INDI                                     0x52
+
+/*
+ * Length : 1
+ * Data   :
+ * - Result
+ */
+#define GSM_SUPS_GET_CCFC_FAILED_RES          0x53
+
+/*
+ * Length : 1
+ * Data   :
+ * - Result
+ */
+#define GSM_SUPS_CB_STATUS_RES                0x54
+
+/*
+ * Length : VAR
+ * Data   :
+ * - Result
+ */
+#define GSM_SUPS_GET_PPU_RES                  0x55
+
+#define GSM_SUPS_STATE                 0x56 
+#define GSM_SUPS_CONFERENCE                    0x57 
+#define GSM_SUPS_HOLD                  0x58 
+#define GSM_SUPS_UNHOLD                        0x59 
+#define GSM_SUPS_AOC_SET        0x5a 
+#define GSM_SUPS_AOC_GET        0x5b 
+#define GSM_SUPS_CW_SET                        0xe0 
+#define GSM_SUPS_CW_GET                        0xe1 
+#define GSM_SUPS_CF_SET                        0xe2 
+#define GSM_SUPS_CF_GET                        0xe3 
+#define GSM_SUPS_CB_SET                        0xe4 
+#define GSM_SUPS_CB_GET                        0xe5 
+#define GSM_SUPS_USSD_GET       0xe6 
+#define GSM_SUPS_USSD_SET       0xe7 
+
+/* --------------------------------------------------------------------------
+   GSM_MISC : misc Functions
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : 2
+ * - CMD ID       (2bytes) Debug command ID
+ */
+#define GSM_MISC_DEBUG_REQ                    0x61
+
+/*
+ * Length : 4
+ * - CMD ID       (2bytes) Debug command ID
+ * - param1       (1byte)  H/W ¼³Á¤À» À§ÇÑ parameter1
+ * - param2       (1byte)  H/W ¼³Á¤À» À§ÇÑ parameter2
+ */
+#define GSM_MISC_DEBUG_HW_REQ                 0x62
+
+/*
+ * Length : 1
+ * - RAMDUMP Trace (1byte) RAMDUMP¸¦ acceptÇÒ°ÍÀÎÁöÀÇ ¿©ºÎ
+ */
+#define GSM_MISC_RAMDUMP_REQ                  0x63
+
+/*
+ * Length : 0
+ * - IMEI Á¶È¸
+ */
+#define GSM_MISC_IMEI_REQ                     0x64
+
+/*
+ * Length : 0
+ * - IMSI Á¶È¸
+ */
+#define GSM_MISC_IMSI_REQ                     0x65
+
+/*
+ * Length : 0
+ * - Phone Version Á¶È¸
+ */
+#define GSM_MISC_VERSION_INFO_REQ             0x66
+
+/*
+ * Length : 0
+ * - SIMÀÇ »óÅ¿͠¸Á»óŸ¦ Á¶È¸ÇÑ´Ù.
+ */
+#define GSM_MISC_INTERNAL_MODE_REQ            0x67
+
+/* --------------------------------------------------------------------------
+   GSM_DISPLAY : Notification or Response
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ */
+#define GSM_MISC_DEBUG_NOTI                   0x61
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ */
+#define GSM_MISC_RESET_NOTI                   0x62
+
+/*
+ * Length : (1) + (2)
+ * - Error type : (1byte) mzgsmerror.h ÂüÁ¶
+ * - CME or CMS : (2bytes)CME È¤Àº CMS ¿¡·¯ÄÚµå
+ */
+#define GSM_MISC_ERROR_RESPONSE               0x63
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ */
+#define GSM_MISC_IMEI_RES                     0x64
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ */
+#define GSM_MISC_IMSI_RES                     0x65
+
+/*
+ * Length : (1) + VAR
+ * - String Length 1byte
+ * - String        VAR
+ */
+#define GSM_MISC_RESET_RES                    0x66
+
+/*
+ * Length : 32 + 32
+ * - Phone Version
+ */
+#define GSM_MISC_VERSION_INFO_RES                      0x67
+
+// sunnyfan, 2006.02.07 [
+#define GSM_MISC_SLEEP_BY_PHONE_NOTI                   0x68
+#define GSM_MISC_DIAG_KEYCODE_NOTI                             0x69
+#define GSM_MISC_BT_TEST_MODE_NOTI                             0x70    // sunnyfanbt
+// sunnyfan ]
+
+/* --------------------------------------------------------------------------
+   GSM_DISPLAY : Functions for Indicator
+   --------------------------------------------------------------------------*/
+
+/*
+ * Declare Display Functions constant.
+ */
+
+/* --------------------------------------------------------------------------
+   GSM_DISPLAY : Notification or Response
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : 2bytes
+ * Data   :
+ * - Indicator (1byte) mzgsmmisc.h¿¡ Àִ °ª°ú ¼³¸íÀ» ÂüÁ¶
+ * - Value     (1byte) 
+ */
+#define GSM_DISPLAY_INDICATOR_NOTI            0x71
+
+/* --------------------------------------------------------------------------
+   GSM_SIM : SIM card Functions
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : VAR
+ * Data   :
+ * - PIN2 (VAR)
+ */
+
+//#define GSM_SIM_PIN2_REQ                      0x81
+#define GSM_SIM_SELECT_PB_STORAGE_REQ         0x82
+#define GSM_SIM_PB_READ_REQ                   0x83
+#define GSM_SIM_PB_WRITE_REQ                  0x84
+#define GSM_SIM_PB_ERASE_REQ                  0x85
+#define GSM_SIM_PB_CLEAR_REQ                  0x86
+#define GSM_SIM_WRITE_VOICE_MAIL_REQ          0x87
+#define GSM_SIM_READ_VOICE_MAIL_REQ           0x88
+
+
+#define GSM_SIM_PIN_REQ                       0x89  //GVSM does not uesd this
+#define GSM_SIM_PUK_REQ                       0x8A //state
+#define GSM_SIM_CHANGE_PW_REQ                 0x8B
+#define GSM_SIM_CRSM_GET_REQ                  0x8C
+#define GSM_SIM_PUK2_REQ                      0x8D
+#define GSM_SIM_PB_READY_REQ                  0x8E
+#define GSM_SIM_CRSM_READ_BIN_REQ             0x8F
+#define GSM_SIM_CRSM_READ_RECORD_REQ          0x90
+#define GSM_SIM_GET_ALS_REQ                   0x91
+#define GSM_SIM_SET_ALS_REQ                   0x92
+#define GSM_SIM_CRSM_UPDATE_RECORD_REQ        0x93
+#define GSM_SIM_CRSM_UPDATE_BIN_REQ           0x94
+#define GSM_SIM_SELECT_SM_STORAGE_REQ         0x95
+#define GSM_SIM_SM_ERASE_REQ                  0x96
+#define GSM_SIM_SEC_STATUS_REQ                0x97
+
+#define GSM_SIM_PB_CAPACITY_REQ               0x98
+#define GSM_PB_ACCESS_REQ                                      0x99
+#define GSM_PB_STORAGE_REQ                                     0x9A
+#define GSM_SIM_PHONELOCK_STATUS_REQ                   0x9B
+#define GSM_SIM_SET_PHONELOCK_REQ                      0x9C
+#define GSM_PB_RECORD_ADD_REQ                          0x9D
+#define GSM_PB_RECORD_DEL_REQ                          0x9E
+#define GSM_PB_RECORD_EDIT_REQ                         0x9F
+#define GSM_SIM_LOCK_INFO_REQ                          0xA0
+#define GSM_PB_SET_STORAGE_TYPE_REQ                    0xA1
+#define GSM_SIM_SECURITY_STATUS_REQ                    0xA2
+#define GSM_PB_ENTRY_INFO_REQ                          0xA3
+#define GSM_SIM_LOCK_PASSWORD_REQ             0xA4
+#define GSM_SIM_CARD_READY_REQ                0xA5
+#define GSM_SIM_PIN2_RES                      0x81
+#define GSM_SIM_SECURITY_STATUS_RES           0x82
+#define GSM_SIM_SELECT_PB_STORAGE_RES         0x83
+#define GSM_SIM_PB_READ_RES                   0x84
+#define GSM_SIM_PB_ACTION_RES                 0x85
+#define GSM_SIM_AUTH_RES                      0x86
+#define GSM_SIM_CHANGE_PW_RES                 0x87
+#define GSM_SIM_PB_READY_RES                  0x88
+#define GSM_SIM_CRSM_GET_RES                  0x89
+#define GSM_SIM_CRSM_READ_BIN_RES             0x8A
+#define GSM_SIM_CRSM_READ_RECORD_RES          0x8B
+#define GSM_SIM_GET_ALS_RES                   0x8C
+#define GSM_SIM_SET_ALS_RES                   0x8D
+#define GSM_SIM_CRSM_UPDATE_RECORD_RES        0x8E
+#define GSM_SIM_SELECT_SM_STORAGE_RES         0x8F
+#define GSM_SIM_SM_ACTION_RES                 0x90
+#define GSM_SIM_AUTH_PIN2_RES                 0x91
+#define GSM_SIM_CDCI_NOTI                     0x92
+#define GSM_SIM_SEC_STATUS_RES                0x93
+#define GSM_SIM_PB_CAPACITY_RES               0x94
+#define GSM_PB_ACCESS_RES                                      0x95
+#define GSM_PB_STORAGE_RES                                     0x96
+#define GSM_SIM_PHONELOCK_STATUS_RES                   0x97
+#define GSM_SIM_SET_PHONELOCK_RES                      0x98
+#define GSM_SIM_CHANGE_LOCKING_PW_RES          0x99
+#define GSM_PB_ACCESS_ERROR_RES                                0x9A
+#define GSM_SIM_PUK_RES                                                0x9B
+#define GSM_SIM_PUK2_RES                                               0x9C
+#define GSM_SIM_LOCK_INFO_RES                          0x9D
+#define GSM_PB_ENTRY_INFO_RES                          0x9E
+#define GSM_SIM_LOCK_PASSWORD_RES             0x9F
+// sunnyfan, 2005.12.16, for CPHS [
+#define GSM_SIM_SET_CFL_REQ                                    0xB1
+#define GSM_SIM_SET_CFL_RES                                    0xB2
+#define GSM_SIM_SET_VMW_REQ                                    0xB3
+#define GSM_SIM_SET_VMW_RES                                    0xB4
+// 2006.01.02
+#define GSM_SIM_EF_SELECT_REQ                          0xB5
+#define GSM_SIM_EF_SELECT_RES                          0xB6
+#define GSM_SIM_PIN_RES                                                0xB7
+//
+#define GSM_SIM_INIT_REQ                                               0xB8//state
+#define GSM_SIM_FRIZEN                                         0xb9//state
+#define GSM_SIM_PIN2_REQ                                               0xba
+#define GSM_SIM_READY                                          0xbb//state
+#define GSM_SIM_WRONG_STATUS_TYPE                        0xbc
+#define GSM_SIM_STATUS_SET                                       0xbd
+#define GSM_SIM_CHANGE_PASS_SET                                  0xbe
+#define GSM_SIM_FACILITY_SET                                    0xbf
+#define GSM_SIM_NO_SIM                                                  0xa0 //state
+#define GSM_SIM_PIN_REQ_STATE                          0xa1
+#define GSM_SIM_FDN_STATE                                      0xa2
+#define GSM_SIM_FACILITY_PIN                                   0xa3
+#define GSM_SIM_FACILITY_FDN                                   0xa4
+#define GSM_SIM_PIN2_OK                                                0xa5
+#define GSM_SIM_FACILITY_RES                                   0xa6
+#define GSM_SIM_GET_SIM_DB_REQ                         0xa7
+#define GSM_SIM_GET_SIM_DB_RES                         0xa8
+#define GSM_SIM_MAKE_PB_DB_REQ                         0xa9
+#define GSM_SIM_ADD_PB_DB_REQ                          0xaa
+#define GSM_SIM_GET_PB_DB_REQ                          0xab
+#define GSM_SIM_DELETE_PB_DB_REQ                               0xac
+#define GSM_SIM_GET_PB_ST_INFO_RES                     0xad
+#define GSM_SIM_SET_PB_STORAGE_REQ                     0xae
+#define GSM_SIM_GET_ALL_PB_DB_REQ                          0xaf
+#define GSM_SIM_ADD_EVENT_PB_DB_REQ                    0xb0
+#define GSM_SIM_DELETE_EVENT_PB_DB_REQ                          0xb1
+#define GSM_SIM_PROTECT_SIM_DB                          0xc0
+#define GSM_SIM_PUKSET_REQ                       0xc1 //set
+#define GSM_SIM_PUK2SET_REQ                       0xc2 //set
+   
+#define        GSM_SIMINFO_REQ                                                 0xD1    //get SIMINFO
+#define        GSM_SIMDATA_REQ                                                 0xD2    //get SIMDATA
+#define        GSM_SIMINFO_RES                                                 0xD3    //get SIMINFO
+#define        GSM_SIMDATA_RES                                                 0xD4    //get SIMDATA
+#define GSM_SIMSAVE_REQ                                                        0xD5    //get SIMSAVE
+#define GSM_SIM_REINIT_REQ                                                     0xD6    //get SIMSAVE
+#define GSM_SIM_ERR_ADD_NOTI                                   0xD7
+#define GSM_SIM_ERR_DEL_NOTI                                   0xD8
+
+//
+//SAT
+#define GSM_SAT_CMD_MENU_SELECTION                             0xd3
+
+#define GSM_SAT_CMD_DISPLAY_TEXT                               0x01
+#define GSM_SAT_CMD_GET_INKEY                                  0x02
+#define GSM_SAT_CMD_GET_INPUT                                  0x03
+#define GSM_SAT_CMD_SET_UP_MENU                        0x04
+#define GSM_SAT_CMD_SELECT_ITEM                                0x05
+#define GSM_SAT_CMD_SEND_SMS                           0x06
+#define GSM_SAT_CMD_SET_UP_CALL                                0x07
+
+// 090908 for FUNC_EDB
+#define FUNC_GET_PB_DB_REQ                             0x01
+#define FUNC_DEL_PB_DB_REQ                             0x02
+#define FUNC_ADD_PB_DB_REQ                             0x03
+#define FUNC_GET_ONE_PB_DB_REQ                         0x04
+
+
+
+
+
+
+
+
+
+
+
+
+
+    
+    
+     
+/* --------------------------------------------------------------------------
+   GSM_DATA : Data Service Functions
+   --------------------------------------------------------------------------*/
+/*
+ * Length : VAR
+ * Data   :
+ * - APN Name (VAR)
+ */
+#define GSM_DATA_GPRS_REQ                     0xA1
+
+/*
+ * Length : VAR
+ * Data   :
+ * - Dial Number (VAR)
+ */
+#define GSM_DATA_GSM_REQ                      0xA2
+
+// EMTRACE_I878 [
+/*
+ * Length : VAR
+ * Data   :
+ * nsclass : for multiple PDP
+ */
+#define GSM_DATA_IP_ADDR_REQ                                           0xA3
+
+/*
+ * Length : VAR
+ * Data   :
+ * nsclass : for multiple PDP
+ */
+#define GSM_DATA_CLOSE_REQ                                             0xA4
+// EMTRACE_I878, civily YK11 ]
+
+// nsclass
+#define GSM_DATA_EXTERNAL_HANGUP_REQ                           0xA5
+
+/*
+ * Length : 0
+ */
+#define GSM_DATA_HANGUP_REQ                   0xA6
+
+/* --------------------------------------------------------------------------
+   GSM_DATA : Notification or Response
+   --------------------------------------------------------------------------*/
+/*
+ * Length : 1
+ * - State        (1byte) mzgsmnet.h¿¡ Àִ °ª°ú ¼³¸íÀ» ÂüÁ¶
+ * GPRS state¿Í Network Registration state´Â À¯»çÇϹǷΠ°°ÀÌ »ç¿ëÇÑ´Ù.
+ */
+#define GSM_DATA_GPRS_REG_NOTI                0xA1
+
+/*
+ * Length : NONE
+ */
+#define GSM_DATA_GPRS_RES                     0xA2
+
+/*
+ * Length : NONE
+ */
+#define GSM_DATA_GSM_RES                      0xA3
+
+/*
+ * Length : 1
+ * dummy 1 byte (»ç¿ëÇÏÁö ¾ÊÀ½)
+ */
+#define GSM_DATA_CSD_CONNECT_NOTI             0xA4
+
+/*
+ * Length : 0
+ */
+#define GSM_DATA_CSD_FAILED_NOTI              0xA5
+
+// nsclass : multiple PDP
+#define GSM_DATA_IP_ADDR_RES                                           0xA6
+
+// nsclass : multiple PDP status
+#define GSM_DATA_STATUS_RES                                            0xA7
+
+// nsclass : for data relase noti
+#define GSM_DATA_PDP_CONNECT_NOTI                              0xA8
+
+// nsclass : for data relase noti
+#define GSM_DATA_PDP_DISCONNECT_NOTI                           0xA9
+
+// nsclass : for data svc noti
+#define GSM_DATA_EXTERNAL_SVC_NOTI                             0xAA
+
+/*
+ * Length : 2
+ * GSM_DataService 1 byte (mzgsmnet.h)
+ * GSM_DataStatus  1 byte (mzgsmnet.h)
+ */
+#define GSM_DATA_SERVICE_STATUS_RES           0xAB
+
+/*
+ * Length : 1
+ */
+#define GSM_DATA_HANGUP_RES            0xAC
+
+/*
+ * Length : 4
+ * rx : 2byte
+ * tx : 2byte
+ */
+#define GSM_DATA_SMPCTR_NOTI           0xAD
+
+/*
+ * Length : 1
+ * 0: stop, 1: start
+ */
+#define GSM_DATA_STATE                         0xAE
+
+/*
+ * Length : 1
+ * 0: stop, 1: start
+ */
+#define GSM_DATA_STATUS                        0xAE
+
+// add by mckim: for informing evt injector with the initial data restored from DB
+#define GSM_DATA_GPRS_INIT_REQ 0xAF
+
+/* --------------------------------------------------------------------------
+   GSM_EXT : °øÁ¤ ¸ðµå 
+   --------------------------------------------------------------------------*/
+/*
+ * Length : IMEI ±æÀÌ (VAR) 
+ * Data   : 
+ * - IMEI Value
+ */
+#define GSM_EXT_SET_IMEI_REQ                  0xB1
+
+/*
+ * Length : BTMAC ±æÀÌ (VAR) 
+ * Data   : 
+ * - BTMAC Value
+ */
+#define GSM_EXT_SET_BTMAC_REQ                 0xB2
+
+/*
+ * Length : 0
+ * Data   : 
+ * - None
+ */
+#define GSM_EXT_GET_BTMAC_REQ                 0xB3
+
+/*
+ * Length : 1
+ * Data   : 
+ * - mode : up Or down
+ */
+#define GSM_EXT_SET_VOICE_VOL_REQ             0xB4
+
+/*
+ * Length : 1
+ * Data   : 
+ * - path : Audio path
+ */
+#define GSM_EXT_SET_AUDIO_PATH_REQ            0xB5
+
+/*
+ * Length : 1
+ * Data   : 
+ * - path : Phone State
+ */
+#define GSM_EXT_SET_INTERNAL_STATE_REQ        0xB6
+/* --------------------------------------------------------------------------
+   GSM_EXT : Notification or Response
+   --------------------------------------------------------------------------*/
+/*
+ * Length : 1
+ * Data   : 
+ * - result
+ */
+#define GSM_EXT_SET_IMEI_RES                  0xB1
+
+/*
+ * Length : 1
+ * Data   : 
+ * - result
+ */
+#define GSM_EXT_SET_BTMAC_RES                 0xB2
+
+/*
+ * Length : 1 + VAR
+ * Data   : 
+ * - mac length
+ * - mac value
+ */
+#define GSM_EXT_GET_IMEI_RES                  0xB3
+
+/*
+ * Length : 1
+ * Data   : 
+ * - result
+ */
+#define GSM_EXT_BATT_INFO_NOTI                0xB4
+
+/*
+ * Length : 1
+ * Data   : 
+ * - result
+ */
+#define GSM_EXT_PHONE_POWER_ON_RES            0xB5
+
+// sunnyfan, 2005.09.26 [
+#define GSM_SUPS_GENRES_CW                                      0xA0
+#define GSM_SUPS_GENRES_CLI                                     0xA1
+#define GSM_SUPS_GENRES_CB                                      0xA2
+#define GSM_SUPS_GENRES_CBPW                                    0xA3
+#define GSM_SUPS_GENRES_CF                                      0xA4
+#define GSM_SUPS_GENRES_MANAGE                          0xA5
+#define GSM_SUPS_GENRES_USSD                                    0xA6
+#define GSM_SUPS_GENRES_SSINFO                          0xA7
+#define GSM_SUPS_GENRES_SSMAX                           0xA8
+#define GSM_SUPS_GENRES_UNKNOWN                                 0xAA
+#define GSM_SUPS_INFORMATION                                    0xB0
+// sunnyfan ]
+
+
+// sunnyfan, 2005.11.04 [ for SAT Response
+#define GSM_GENRES_CALLOUTGOING                                         0xB6
+// sunnyfan ]
+
+
+/* --------------------------------------------------------------------------
+   GSM_SMS : SMS Functions
+   --------------------------------------------------------------------------*/
+#define GSM_SMS_SEND_MSG_REQ                                   0x01
+#define GSM_SMS_READ_MSG_REQ                                   0x02
+#define GSM_SMS_SAVE_MSG_REQ                                   0x03
+#define GSM_SMS_DEL_MSG_REQ                                    0x04
+#define GSM_SMS_SEND_ACK_REQ                                   0x05
+#define GSM_SMS_GET_SEL_MEM_REQ                                0x06
+#define GSM_SMS_SET_SEL_MEM_REQ                                0x07
+#define GSM_SMS_STORED_MSG_CNT_REQ                     0x08
+#define GSM_SMS_GET_MSG_CONFIG_REQ                     0x09
+#define GSM_SMS_SET_MSG_CONFIG_REQ                     0x0A
+#define GSM_SMS_GET_SVC_OPTION_REQ                     0x0B
+#define GSM_SMS_SET_SVC_OPTION_REQ                     0x0C
+#define GSM_SMS_MEM_FULL_REQ                                   0x0D
+// by luxmea, 2005.11.16 [
+#define GSM_SMS_GET_CB_CONFIG_REQ        0x0E
+#define GSM_SMS_SET_CB_CONFIG_REQ        0x0F
+#define GSM_SMS_SET_MSG_STATUS_REQ       0x10
+#define GSM_SMS_SET_BLK_LIST_REQ         0x11
+// by luxmea ]
+#define GSM_SMS_INCOMING_CB_MSG_REQ            0x12
+  
+/* --------------------------------------------------------------------------
+   GSM_SMS : Notification or Response
+   --------------------------------------------------------------------------*/
+#define GSM_SMS_INCOMING_MSG_NOTI                      0x01
+#define GSM_SMS_READ_MSG_RES                                   0x02
+#define GSM_SMS_RECEIVE_ACK_NOTI                               0x03
+#define GSM_SMS_SEL_MEM_RES                                    0x04
+#define GSM_SMS_STORED_MSG_CNT_RES                     0x05
+#define GSM_SMS_MSG_CONFIG_RES                         0x06
+#define GSM_SMS_SVC_OPTION_RES                         0x07
+#define GSM_SMS_MEM_FULL_NOTI                          0x08
+#define GSM_SMS_ACTION_STATUS_NOTI                     0x09
+// by luxmea, 2005.11.16 [
+#define GSM_SMS_CB_CONFIG_RES        0x0A
+// by luxmea ]
+#define GSM_SMS_STORED_MSG_CNT_NOTI           0x0B        // by luxmea
+
+
+
+/* --------------------------------------------------------------------------
+   GSM_SAT : SAT functions
+   --------------------------------------------------------------------------*/
+#define GSM_SAT_PROFILE_DOWNLOAD_SET               0x01
+#define GSM_SAT_ENVELOPE_COMMAND_REQ               0x02
+#define GSM_SAT_PROACTIVE_COMMAND_GET              0x03
+#define GSM_SAT_PROVIDE_LOCAL_INFOMATION_GET       0x04
+#define GSM_SAT_POLLING_GET                        0x05
+#define GSM_SAT_REFRESH_GET                        0x06
+#define GSM_SAT_SETUP_EVENT_LIST_GET               0x07
+#define GSM_SAT_TERMINATE_SESSION_SET              0x08
+#define GSM_SAT_PROACTIVE_COMMAND_SEND              0x09
+//////////////////////////////////////////////////////////////////////////
+#define GSM_SAT_PROACTIVE_DISPLAY_TEXT              0xa0
+#define GSM_SAT_PROACTIVE_GET_INKEY                   0xa1
+#define GSM_SAT_PROACTIVE_GET_INPUT                   0xa2
+#define GSM_SAT_PROACTIVE_SET_MENU                    0xa3
+#define GSM_SAT_PROACTIVE_SELECT_ITEM                 0xa4
+#define GSM_SAT_PROACTIVE_SEND_SMS                    0xa5
+#define GSM_SAT_PROACTIVE_SET_UP_CALL                 0xa6
+
+
+
+/* --------------------------------------------------------------------------
+   GSM_SAT : Notification or Response
+   --------------------------------------------------------------------------*/
+#define GSM_SAT_PROACTIVE_COMMAND_INDICATION       0x01
+#define GSM_SAT_PROACTIVE_COMMAND_RESPONSE         0x02
+#define GSM_SAT_ENVELOPE_COMMAND_NOTIFICATION      0x03
+#define GSM_SAT_PROVIDE_LOCAL_INFOMATION_RESPONSE  0x04
+#define GSM_SAT_POLLING_RESPONSE                   0x05
+#define GSM_SAT_REFRESH_RESPONSE                   0x06
+#define GSM_SAT_REFRESH_NOTIFICATION               0x07
+#define GSM_SAT_SETUP_EVENT_LIST_RESPONSE          0x08
+///////////////////////////////////////////////////////////////////////////
+
+
+
+/* --------------------------------------------------------------------------
+   GSM_SOUND : Sound functions
+   --------------------------------------------------------------------------*/
+
+#define GSM_SND_KEY_TONE_REQ                                           0x01
+#define GSM_SND_NOTI_TONE_REQ                                  0x02
+#define GSM_SND_LED_CTRL_REQ                                           0x03
+#define GSM_SND_VIB_CTRL_REQ                                           0x04
+#define GSM_SND_GET_SPKR_VOLUME_CTRL_REQ                       0x05
+#define GSM_SND_SET_SPKR_VOLUME_CTRL_REQ                       0x06
+#define GSM_SND_GET_MIC_GAIN_CTRL_REQ                  0x07
+#define GSM_SND_SET_MIC_GAIN_CTRL_REQ                  0x08
+#define GSM_SND_GET_MIC_MUTE_CTRL_REQ                  0x09
+#define GSM_SND_SET_MIC_MUTE_CTRL_REQ                  0x0A
+#define GSM_SND_SPKR_PHONE_CTRL_REQ                            0x0B
+#define GSM_SND_HFK_AUDIO_STARTSTOP_REQ                        0x0C
+#define GSM_SND_VOICECALL_RECORD_REPORT_REQ            0x0D
+#define GSM_SND_AUDIO_PATH_CTRL_REQ                            0x0E
+#define GSM_SND_SET_USER_CONFIG                                        0x0F
+#define GSM_SND_GET_GAIN_CTRL_REQ                              0x10
+#define GSM_SND_SET_GAIN_CTRL_REQ                              0x11
+
+/* --------------------------------------------------------------------------
+   GSM_SOUND : Notification or Response
+   --------------------------------------------------------------------------*/
+#define GSM_SND_SPKR_VOLUME_CTRL_RES                           0x01
+#define GSM_SND_MIC_GAIN_CTRL_RES                              0x02
+#define GSM_SND_SET_MIC_MUTE_CTRL_RES                  0x03
+#define GSM_SND_AUDIO_SOURCE_CTRL_NOTI                 0x04
+#define GSM_SND_GAIN_CTRL_RES                                  0x05
+#define GSM_SND_GAIN_CTRL_NOTI                                 0x06
+
+/* --------------------------------------------------------------------------
+   GSM_SERVICEMODE : Service Mode functions
+   --------------------------------------------------------------------------*/
+#define GSM_SVCMODE_ENTER_REQ                          0x01
+#define GSM_SVCMODE_END_REQ                                    0x02
+#define GSM_SVCMODE_PROCESS_KEY_REQ                    0x03
+//#define GSM_SVCMODE_GET_HW_SOUND_CONFIG_REQ  0x04
+//#define GSM_SVCMODE_SET_HW_SOUND_CONFIG_REQ  0x05
+
+/* --------------------------------------------------------------------------
+   GSM_SERVICEMODE : Notifications or Responses
+   --------------------------------------------------------------------------*/
+#define GSM_SVCMODE_ENTER_NOTI                         0x01
+#define GSM_SVCMODE_END_NOTI                                   0x02
+#define GSM_SVCMODE_SCREEN_CONFIG_NOTI         0x03
+#define GSM_SVCMODE_DISPLAY_NOTI                               0x04
+//#define GSM_SVCMODE_HW_SOUND_CONFIG_RES              0x05
+//#define GSM_SVCMODE_HW_SOUND_CONFIG_NOTI             0x06
+
+/* --------------------------------------------------------------------------
+   GSM_EMULATOR
+   --------------------------------------------------------------------------*/
+
+/*
+ * Length : HDLC ±æÀÌ
+ * Data   : HDLC
+ * - Caller ID
+ */
+#define GSM_EMULATOR_HDLC_REQ                          0x01
+#define GSM_EMULATOR_HDLC_MODE                         0x02
+#define GSM_EMULATOR_HDLC_CLEAR                                0x03
+#define GSM_EMULATOR_SET_CALL_GENERAL_RESPONSE_ERROR           0x04
+#define GSM_EMULATOR_SET_CALL_STATUS_ERROR                     0x05
+#define GSM_EMULATOR_SET_SCA                                   0x06
+#define GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR             0x07
+#define GSM_EMULATOR_CLIENT_RELEASE_NOTI       0X08
+#define GSM_EMULATOR_SET_SS_HOLD_RESPONSE_ERROR 0x09
+#define GSM_EMULATOR_SET_SS_RETRIEVE_RESPONSE_ERROR 0x0a
+#define GSM_EMULATOR_SET_SS_JOIN_RESPONSE_ERROR                0x0b
+#define  GSM_EMULATOR_SET_SS_SPLIT_RESPONSE_ERROR              0x0c
+#define  GSM_EMULATOR_SET_SS_TRANSFER_RESPONSE_ERROR   0x0d
+
+
+
+/* --------------------------------------------------------------------------
+   GSM_POWER
+   --------------------------------------------------------------------------*/
+
+#define GSM_POWER_MODEM_ON_REQ                         0x01
+#define GSM_POWER_MODEM_OFF_REQ                                0x02
+#define GSM_POWER_BATTERY_STATUS_NOTI                          0x02
+
+
+/* --------------------------------------------------------------------------
+   GSM_GPRS
+   --------------------------------------------------------------------------*/
+/*
+ * Length          : 23 bytes
+ * cid             : 1 byte
+ * field_flag      : 2 bytes
+ * ip_address      : 4 bytes
+ * primary_dns     : 4 bytes
+ * secondary_dns    : 4 bytes
+ * default_gateway  : 4 bytes
+ * subnet_mask     : 4 bytes
+ */
+//#define GSM_GPRS_IP_CONFIGURATION    0x01
+
+#endif // _vgsm_phone_h_
diff --git a/libvmodem/vgsm_power.h b/libvmodem/vgsm_power.h
new file mode 100644 (file)
index 0000000..b14338a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __vgsm_power_h__
+#define __vgsm_power_h__
+
+
+/////////////////////////////////////////////
+typedef enum {
+  BATT_STATUS_PWR_OFF = 0x01,    /* Power-Off Battery Level */
+  BATT_STATUS_CRITICAL_LOW,      /*Critical low battery Level*/
+  BATT_STATUS_LOW,                       /* Low Battery Level */
+  BATT_STATUS_NORMAL,                 /* Normal Battery Level */
+  BATT_STATUS_MAX
+} battery_status_type_e;
+
+#endif
diff --git a/libvmodem/vgsm_sat.h b/libvmodem/vgsm_sat.h
new file mode 100644 (file)
index 0000000..e7cd823
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// 
+
+#ifndef __vgsm_sat_h__
+#define __vgsm_sat_h__
+
+#define PROVIDE_LOCAL_INFO_DATA_LEN 53
+#define POLLING_GET_TYPE_LEN  4
+#define POLLING_RESP_TYPE_LEN 5
+
+
+typedef struct tagSatProfileDown {
+    unsigned char result_code;
+    unsigned char usat_profile[20];
+} GSM_SatProfileDown;
+
+typedef struct tagSatEnvelopeCmd {
+    unsigned char length;
+    unsigned char *cmd;
+} GSM_SatEnvelopeCmd;
+
+typedef struct tagSatProactiveCmd {
+       unsigned char length;
+       unsigned char *cmd;
+} GSM_SatProactiveCmd;
+
+typedef struct tagSatEventDown {
+       unsigned char length;
+       unsigned char *event_resp;
+} GSM_SatEventDown;
+
+typedef struct tagSatProvideLocalInfo {
+       unsigned char infoType;
+       unsigned char infoData[PROVIDE_LOCAL_INFO_DATA_LEN];
+} GSM_SatProvideLocalInfo;
+
+typedef struct tagSatPollingGetType {
+       unsigned char pollReqType;
+       unsigned char present;
+       unsigned char units;
+       unsigned char value;
+} GSM_SatPollingGetType;
+
+typedef struct tagSatPollingRespType {
+       unsigned char pollConfType;
+       unsigned char pollingResult;
+       unsigned char present;
+       unsigned char units;
+       unsigned char value;
+} GSM_SatPollingRespType;
+
+typedef struct tagSatRefreshGetType {
+       unsigned char refreshMode;
+       unsigned char numOfFile;
+       unsigned char filePathLength;
+       unsigned char fullFilePath[256];
+       unsigned char aidPresent;
+       unsigned char aid[16];
+} GSM_SatRefreshGetType;
+
+typedef struct tagSatSetupEventListGetType {
+       unsigned char length;
+       unsigned char eventList[17];
+} GSM_SatEventListGetType;
+
+typedef struct tagSatSetupInternalType {
+       unsigned char length;
+       unsigned char isSet;
+       unsigned char title[256];
+} GSM_SatSetupInternalType;
+
+#endif // __vgsm_sat_h__
diff --git a/libvmodem/vgsm_sim.h b/libvmodem/vgsm_sim.h
new file mode 100644 (file)
index 0000000..287c0b8
--- /dev/null
@@ -0,0 +1,473 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __VGSM_SIM_H__
+#define __VGSM_SIM_H__
+
+/* ICC TYPE field */
+typedef enum{
+       GSM_SEC_SIM_UNKNOWN     =0x00,  /* 0x00 : UNKNOWN       */
+       GSM_SEC_SIM_2GGSM,              /* 0x01 : 2G GSM                */
+       GSM_SEC_SIM_3G,                 /* 0x02 : 3G                    */
+       GSM_SEC_SIM_MAX
+} gsm_sec_sim_icc_e_type;
+
+
+/* SIM SECURITY STATUS */
+typedef enum{
+       GSM_SEC_STATUS_PIN_READY,               /* 0x00 : Not necessary */
+       GSM_SEC_STATUS_PIN_REQ,                         /* 0x01 : PIN required as a password */
+       GSM_SEC_STATUS_PUK_REQ,                         /* 0x02 : PUK required as a password */
+       GSM_SEC_STATUS_PIN2_REQ,                /* 0x03 : PIN2 required as a password */
+       GSM_SEC_STATUS_PUK2_REQ,                /* 0x04 : PUK2 required as a password */
+       GSM_SEC_STATUS_PERM_BLOCKED,    /* 0x05 : PIN Permanent Blocked */   // JBG 2005.05.18
+       GSM_SEC_STATUS_PIN2_READY,              /* 0x06 : PIN2 Lock Disabled*/
+       GSM_SEC_STATUS_NO_SIM,                  /* 0x07 : SIM isn`t inserted    */
+       GSM_SEC_STATUS_MAX
+} gsm_sec_status_type;
+
+
+/* LOCK_TYPE  field */
+typedef enum{
+       GSM_SEC_LOCK_TYPE_READY,                        /* 0x00 : ME is not locked */
+       GSM_SEC_LOCK_TYPE_PS,                           /* 0x01 : PH-SIM, Lock Phone to SIM/UICC card 
+                                                                               ( MT asks password when other than current SIM/UICC card inserted; 
+                                                                                MT may remember certain amount of previously used cards thus not 
+                                                                                requiring password when they are inserted ) */ 
+       GSM_SEC_LOCK_TYPE_PF,                           /* 0x02 : PH-FSIM, Lock Phone to the very First inserted SIM/UICC card
+                                                                                       ( MT asks password when other than the first SIM/UICC card is inserted ) */
+       GSM_SEC_LOCK_TYPE_SC,                           /* 0x03 : Lock SIM/UICC card ( SIM asks password in ME power-up and when this command is issued ) */
+       GSM_SEC_LOCK_TYPE_FD,                   /* 0x04 : SIM card or active application in the UICC (GSM or USIM) fixed dialing memory feature */
+       GSM_SEC_LOCK_TYPE_PN,                   /* 0x05 : Network Personalization */
+       GSM_SEC_LOCK_TYPE_PU,                   /* 0x06 : Network subset Personalization */
+       GSM_SEC_LOCK_TYPE_PP,                           /* 0x07 : Service Provider Personalization */
+       GSM_SEC_LOCK_TYPE_PC,                           /* 0x08 : Corporate Personalization */
+       GSM_SEC_LOCK_TYPE_SC2,                  /* 0x09 : Lock PIN2 ( ... ) */
+       GSM_SEC_LOCL_TYPE_PUK2,                 /* 0x0A : Lock PUK2 (... ) */
+       GSM_SEC_LOCK_TYPE_ACL,                  /* 0x0B: ACL */
+       GSM_SEC_LOCL_TYPE_PUK,                  /* 0x0C : Lock PUK (... ) 090215*/
+  
+       /* 0x0a - 0x7F are Reserved */
+  
+       /* SIM Status Information which are used only in GSM_SEC_PIN_STATUS Noti */
+       GSM_SEC_LOCK_TYPE_NO_SIM=0x80,  /* 0x80 : SIM is not inserted */
+       GSM_SEC_LOCK_TYPE_UNAVAIL,              /* 0x81 : SIM is inserted but can not communicate with SIM ( SIM interface error ) */
+       GSM_SEC_SIM_INIT_COMPLETED,             /* 0x082 : SIM Initialize Completed */  // JBG 2005.05.18
+       GSM_SEC_PB_INIT_COMPLETED,              /* 0x83 : Phonebook Initialize Completed*/
+  
+       GSM_SEC_LOCK_TYPE_MAX
+}gsm_sec_lock_e_type;
+
+
+/* LOCK_MODE  field */
+/* The enable or disable of facility */
+typedef enum{
+       GSM_SEC_LOCK_MODE_UNLOCK,       /* 0x00 : Disable       */
+       GSM_SEC_LOCK_MODE_LOCK,         /* 0x01 : Enable        */
+       GSM_SEC_LOCK_MODE_MAX
+} gsm_sec_lock_mode_e_type;
+
+
+/* LOCK_KEY */
+typedef enum{
+       GSM_SEC_LOCK_KEY_UNLOCKED,              /* 0x00 : Not necessary */
+       GSM_SEC_LOCK_KEY_PIN,                           /* 0x01 : PIN required as a password */
+       GSM_SEC_LOCK_KEY_PUK,                   /* 0x02 : PUK required as a password */
+       GSM_SEC_LOCK_KEY_PIN2,                  /* 0x03 : PIN2 required as a password */
+       GSM_SEC_LOCK_KEY_PUK2,                  /* 0x04 : PUK2 required as a password */
+       GSM_SEC_LOCK_KEY_PERM_BLOCKED,  /* 0x05 : PIN Permanent Blocked */   // JBG 2005.05.18
+       GSM_SEC_LOCK_KEY_PIN2_DISABLE,  /* 0x06 : PIN2 Lock Disabled*/
+       GSM_SEC_LOCK_KEY_MAX
+} gsm_sec_lock_key_e_type;
+
+
+/* ACCESS_CMD  Field : see  3GPP TS11.11, TS27.07 */
+typedef enum {
+       GSM_SEC_SIM_ACC_READ_BINARY             =       0xB0,   /*Reads a string of bytes from the current transparent EF.*/
+       GSM_SEC_SIM_ACC_READ_RECORD     =       0xB2,   /*Reads one complete record in the current linear fixed or cyclic EF.*/
+       GSM_SEC_SIM_ACC_GET_RESPONSE    =       0xC0,   /*The response data depends on the preceding command.*/
+       GSM_SEC_SIM_ACC_UPDATE_BINARY   =       0xD6,   /*Updates the current transparent EF with a string of bytes.*/
+       GSM_SEC_SIM_ACC_UPDATE_RECORD   =       0xDC,   /*Updates one complete record in the current linear fixed or cyclic EF.*/
+       GSM_SEC_SIM_ACC_STATUS                  =       0xF2,   /*Information concerning the current directory.*/
+       GSM_SEC_SIM_ACC_MAX
+} gsm_sec_sim_access_e_type;
+
+
+typedef enum
+{
+    /* common Elementary files */
+       GSM_SEC_EFILE_DIR                       = 0x2F00,               /**<  for the USIM                                      */
+       GSM_SEC_EFILE_ICCID             = 0x2FE2,               /**< the ICC Identification file                */
+       GSM_SEC_EFILE_ADN                       = 0x6F3A,               /**< the Abbrv. Dialing Num file                */
+       GSM_SEC_EFILE_FDN                       = 0x6F3B,               /**< the Fixed Dialing Num file         */
+       GSM_SEC_EFILE_SMS                       = 0x6F3C,               /**< the Short Messages file            */
+       GSM_SEC_EFILE_CCP                       = 0x6F3D,               /**< the Capab. Config Param file       */
+       GSM_SEC_EFILE_IMSI              = 0x6F07,               /**< the IMSI file                              */
+       GSM_SEC_EFILE_SST                       = 0x6F38,               /**< the SIM Service Table file                 */
+       GSM_SEC_EFILE_EST                       = 0x6F56,       
+       GSM_SEC_EFILE_ACM                       = 0x6F39,               /**< the Accumul. Call Meter file               */
+       GSM_SEC_EFILE_MBDN              = 0x6FC7,               /** < SIM Mail Box Dailing Number file */
+
+       GSM_SEC_EFILE_GID1              = 0x6F3E,               /**< the Group Identifier Level 1               */
+       GSM_SEC_EFILE_GID2              = 0x6F3F,               /**< the Group Identifier Level 2               */
+
+       /* For PHASE 2 only */
+       GSM_SEC_EFILE_MSISDN            = 0x6F40,               /**< the MSISDN file                            */
+       GSM_SEC_EFILE_SMSP              = 0x6F42,               /**< the Short Msg Srv. Param file      */
+       GSM_SEC_EFILE_SMSS              = 0x6F43,               /**< the SMS Status                             */
+       GSM_SEC_EFILE_EXT1              = 0x6F4A,               /**< the Extension 1 file                       */
+       GSM_SEC_EFILE_EXT2              = 0x6F4B,               /**< the Extension 2 file                       */
+       GSM_SEC_EFILE_LP                        = 0x2F05,               /**< the Language Preference file       */
+       GSM_SEC_EFILE_ACM_MAX   = 0x6F37,               /**< the ACM maximum value file */
+       GSM_SEC_EFILE_PUCT              = 0x6F41,               /**< the Price per Unit and. file               */
+       GSM_SEC_EFILE_CBMI              = 0x6F45,               /**< the Cell Brd msg Id sel file               */
+       GSM_SEC_EFILE_PHASE             = 0x6FAE,               /**< the PHASE identification file              */
+
+       /* For Phase 2+ */
+       GSM_SEC_EFILE_SDN                       = 0x6F49,               /**< the Service Dialing Numbers        */
+       GSM_SEC_EFILE_EXT3              = 0x6F4C,               /**< the Extension 3 file                       */
+       GSM_SEC_EFILE_BDN                       = 0x6F4D,               /**< the BDN file                               */
+       GSM_SEC_EFILE_EXT4              = 0x6F4E,               /**< the Extension 4 file                       */
+       GSM_SEC_EFILE_ECC                       = 0x6FB7,               /**< the Emergency Call Codes           */
+       GSM_SEC_EFILE_SPN                       = 0x6F46,               /**< the Service Provider Name          */
+       GSM_SEC_EFILE_PNN                       = 0x6FC5,               /**< the Service Provider Name          */
+    GSM_SEC_EFILE_OPL           = 0x6FC6,
+    GSM_SEC_EFILE_SPDI          = 0x6FCD,
+
+       /* Contents of files at the DF GRAPHICS level */
+       GSM_SEC_EFILE_IMG                       = 0x4F20,               /**< image */
+
+       /* 4.2 Contents of files at the USIM ADF (Application DF) level */
+       GSM_SEC_EFILE_USIM_LI           = 0x6F05,               /**< Language Indication */
+
+#if 1  
+       GSM_SEC_EFILE_USIM_IMSI                 = 0x6A07,                       /**< IMSI */
+       GSM_SEC_EFILE_USIM_ACM_MAX              = 0x6A37,                       /**< ACM maximum value */
+       GSM_SEC_EFILE_USIM_UST                  = 0x6A38,                       /**< USIM Service Table */
+       GSM_SEC_EFILE_USIM_ACM                  = 0x6A39,                       /**< Accumulated Call Meter */
+       GSM_SEC_EFILE_USIM_SPN                  = 0x6A46,                       /**< Service Provider Name */
+       GSM_SEC_EFILE_USIM_PUCT                 = 0x6A41,                       /**< Price per Unit and Currency Table */
+       GSM_SEC_EFILE_USIM_CBMI                 = 0x6A45,                       /**< Cell Broadcaster Message Identifier selection */
+       GSM_SEC_EFILE_USIM_ECC                  = 0x6AB7,                       /**< Emergency Call Codes */
+       GSM_SEC_EFILE_USIM_FDN                  = 0x6A3B,
+       GSM_SEC_EFILE_USIM_SMS                  = 0x6A3C,                       /** < My own number */
+       GSM_SEC_EFILE_USIM_MSISDN               = 0x6A40,
+       GSM_SEC_EFILE_USIM_SMSP                 = 0x6A42,                       /** < SMS parameter */
+       GSM_SEC_EFILE_USIM_SMSS                 = 0x6A43,                       /** < SMS status */
+       GSM_SEC_EFILE_USIM_SDN                  = 0x6A49,                       /** < Service dialing number */
+       GSM_SEC_EFILE_USIM_EXT1                 = 0X6A4A,                       /** < EXT1 record file */
+       GSM_SEC_EFILE_USIM_EXT2                 = 0x6A4B,                       /** < EXT2 record file */
+       GSM_SEC_EFILE_USIM_EXT3                 = 0x6A4C,                       /** < EXT3 record file */
+       GSM_SEC_EFILE_USIM_EXT4                 = 0x6A55,                       /** < EXT4 record file */
+       GSM_SEC_EFILE_USIM_EXT5                 = 0x6A4E,                       /**< Extension 5 */
+#endif 
+       GSM_SEC_EFILE_USIM_EXT6                 = 0x6FC8,                       /** < EXT6 record file */
+       GSM_SEC_EFILE_USIM_CCP2                 = 0x6A4F,                       /**< Capability Configuration Parameters 2 */
+       GSM_SEC_EFILE_USIM_HIDDEN_KEY   = 0x6FC3,                       /**< Key for hidden phonebook entries */
+       GSM_SEC_EFILE_USIM_BDN                  = 0x6A4D,                       /**< Barred Dialing Numbers */
+       GSM_SEC_EFILE_USIM_MBDN                 = 0x6FC7,                       /** < USIM Mail box dialing number */
+       GSM_SEC_EFILE_USIM_MBI                  = 0x6FC9,                       /** < Mailbox Identifier */
+       
+       GSM_SEC_EFILE_USIM_APN_ACL              = 0x6F57,                       /** < Access point name control list */
+       
+       /* Contents of files at USIM ADF PHONEBOOK level */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_PBR        = 0x4FF0,               /**< Phonebook Reference File */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_CCP1       = 0x4FFE,               /**< Capability Configuration Parameters 1 */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_UID        = 0x4FF8,               /**< unique identifier */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_PSC        = 0x4FFF,               /**< phonebook synchronization counter */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_CC = 0x4FEF,               /**< change counter */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_PUID       = 0x4FEE,               /**< previous unique identifier */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ADN        = 0x4FF1,               /**< Abbreviated Dialing Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_IAP        = 0x4FF2,               /**< Index Administration Phonebook */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_PBC        = 0x4FF3,               /**< Phonebook Control */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_EXT1       = 0x4FFB,               /**< Extension 1 */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_GRP        = 0x4FF7,               /**< Grouping File */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_AAS        = 0x4FFC,               /**< Additional number Alpha String */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_AAS1       = 0x4FFD,               /**< Additional number Alpha String */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_GAS        = 0x4F0E,               /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_GAS1       = 0x4F0F,               /**< Second Name Entry */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANR        = 0x4FF4,               /**< Additional Number */ 
+       GSM_SEC_EFILE_USIM_PHONEBOOK_SNE        = 0x4FF9,               /**< Second Name Entry */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_EMAIL      = 0x4FFA,               /**< e-mail address */
+#if 1
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRA       = 0x4F13,               /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRB       = 0x4F14,               /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRC       = 0x4F15,               /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANR1       = 0x4F16,               /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRA1      = 0x4F17,       /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRB1      = 0x4F18,       /**< Additional Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ANRC1      = 0x4F21,       /**< Additional Number */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_ADN1       = 0x4F1A,               /**< Abbreviated Dialing Number */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_PBC1       = 0x4F1B,               /**< Phonebook Control */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_GRP1       = 0x4F1C,               /**< Grouping File */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_SNE1       = 0x4F1D,               /**< Second Name Entry */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_UID1       = 0x4F1E,               /**< unique identifier */
+
+       GSM_SEC_EFILE_USIM_PHONEBOOK_EMAIL1     = 0x4F1F,       /**< e-mail address */
+       GSM_SEC_EFILE_USIM_PHONEBOOK_IAP1       = 0x4FF5,               /**< Index Administration Phonebook */
+#endif
+       /* Contents of files at TELECOM DF PHONEBOOK level */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PBR             = 0x4F30,       /**< Phonebook Reference File */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PBR1            = 0x4F29,       /**< Phonebook Reference File 1 */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PBR2            = 0x4F28,       /**< Phonebook Reference File 1 */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_CCP1            = 0x4F3D,       /**< Capability Configuration Parameters 1 */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_UID             = 0x4F00,       /**< unique identifier */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PSC             = 0x4F22,       /**< Phonebook synchronization counter */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_CC                      = 0x4F23,               /**< change counter */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PUID            = 0x4F24,       /**< previous unique identifier */
+
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ADN             = 0x4F3A,       /**< Abbreviated Dialing Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_IAP             = 0x4F25,       /**< Index Administration Phonebook */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PBC             = 0x4F09,       /**< Phonebook Control */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_EXT1            = 0x4F4A,       /**< Extension 1 */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_GRP             = 0x4F26,       /**< Grouping File */
+
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_AAS             = 0x4F4B,       /**< Additional number Alpha String */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_GAS             = 0x4F4C,       /**< Additional Number */
+
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANR             = 0x4F11,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_SNE             = 0x4F19,       /**< Second Name Entry */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_EMAIL           = 0x4F50,       /**< e-mail address */
+#if 1
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANRA            = 0x4F31,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANRB            = 0x4F32,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANRC            = 0x4F40,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANR1            = 0x4F33,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANRA1           = 0x4F34,       /**< Additional Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ANRB1           = 0x4F35,       /**< Additional Number */
+
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_ADN1            = 0x4F36,       /**< Abbreviated Dilling Number */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_PBC1            = 0x4F37,       /**< Phonebook Control */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_GRP1            = 0x4F38,       /**< Grouping File */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_SNE1            = 0x4F39,       /**< Second Name Entry */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_UID1            = 0x4F3B,       /**< unique identifier */
+
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_EMAIL1  = 0x4F3C,       /**< e-mail address */
+       GSM_SEC_EFILE_TELECOM_PHONEBOOK_IAP1            = 0x4F3E,       /**< Index Administration Phonebook */
+#endif
+       GSM_SEC_EFILE_MSG_WAITING_INDICATION_STATUS                     =0x6FCA,                /** < MSG waiting indication  */
+       
+       /* CPHS FILE ID */
+       GSM_SEC_EFILE_CPHS_VOICE_MSG_WAITING                                    = 0x6F11,       /** < voice MSG waiting indication  */
+       GSM_SEC_EFILE_CPHS_SERVICE_STRING_TABLE                         = 0x6F12,       /** < CPHS service string table  */
+       GSM_SEC_EFILE_CPHS_CALL_FORWARD_FLAGS                                   = 0x6F13,       /** < CPHS call forward flags  */
+       GSM_SEC_EFILE_CPHS_OPERATOR_NAME_STRING                         = 0x6F14,       /** < CPHS operator name string  */
+       GSM_SEC_EFILE_CPHS_CUSTOMER_SERVICE_PROFILE                     = 0x6F15,       /** < CPHS custormer service profile  */
+       GSM_SEC_EFILE_CPHS_CPHS_INFO                                                    = 0x6F16,       /** < CPHS informatoin  */
+       GSM_SEC_EFILE_CPHS_MAILBOX_NUMBERS                                              = 0x6F17,       /** < CPHS mail box numbers  */
+       GSM_SEC_EFILE_CPHS_OPERATOR_NAME_SHORT_FORM_STRING      = 0x6F18,       /** < CPHS operator name short form string  */
+       GSM_SEC_EFILE_CPHS_INFORMATION_NUMBERS                          = 0x6F19,       /** < CPHS information numbers  */
+       
+
+       GSM_SEC_EFILE_CPHS_CFIS                                                                 = 0x6FCB,       /** < call forward indication status  */
+       GSM_SEC_EFILE_EXT7                                                                              = 0x6FCC,       /** < Ext 7 file   */
+       /*  CPHS ALS FILE ID */
+       GSM_SEC_CPHS_DYNAMICFLAGS                                                               = 0x6F9F,       /** < CPHS Dynamics flags  */
+       GSM_SEC_CPHS_DYNAMIC2FLAG                                                               = 0x6F92,       /** < CPHS Dynamics2 flags  */
+       GSM_SEC_CPHS_CUSTOMER_SERVICE_PROFILE_LINE2                     = 0x6F98,       /** < CPHS CSP2  */
+
+       /* ISIM files */
+       GSM_SEC_EFILE_ISIM_IMPI                 = 0x6F02,               /** < IMS private user identiry   */
+       GSM_SEC_EFILE_ISIM_DOMAIN       = 0x6F03,               /** < IMS Home Network Domain Name   */
+       GSM_SEC_EFILE_ISIM_IMPU         = 0x6F04,               /** < IMS public user identity    */
+       GSM_SEC_EFILE_ISIM_AD           = 0x6FAD,               /** < Administrative data     */  /* NOT implemented */
+       GSM_SEC_EFILE_ISIM_ARR          = 0x6F06,               /** < Access control file     */  /* NOT implemented */
+
+       /* ID clashes with IMSI file Id so changed to  6FFF - actuall Id is 0x6F07 */ /* modem no support ?*/
+       GSM_SEC_EFILE_ISIM_IST          = 0x6FFF,               /** <ISIM keys     */
+       GSM_SEC_EFILE_ISIM_KEYS         = 0x6F08,               /** < Access control file     */
+       GSM_SEC_EFILE_ISIM_PCSCF                = 0x6F09,               /** < PCSCF address     */
+       GSM_SEC_EFILE_ISIM_GBABP                = 0x6FD5,               /* NO RSIM access */
+
+       /* Invalid File ID, All the file ID are less than this Value*/
+       GSM_SEC_EFILE_INVALID                   =0xFFFF
+
+} gsm_sec_sim_file_id_t;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+//     SIM FILE TYPE
+///////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @enum tapi_sim_file_struct_type_t
+ * This enumeration defines the file type.
+ * @since 2.0
+ */
+typedef enum
+{
+       GSM_SEC_FTYPE_DEDICATED         = 0x00,                 /**< Dedicated */
+       GSM_SEC_FTYPE_TRANSPARENT       = 0x01,                 /**< Transparent */
+       GSM_SEC_FTYPE_LINEAR_FIXED      = 0x02,                 /**< Linear fixed */
+       GSM_SEC_FTYPE_CYCLIC                    = 0x04,                 /**< Cyclic */
+       GSM_SEC_FTYPE_INVALID_TYPE      = 0xFF                  /**< Invalid type */
+
+} gsm_sec_sim_file_struct_type_t;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+//     SIM LINEAR FIXED/ CYCLIC FILES RECORD TYPE
+///////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @enum tapi_sim_record_mode_t
+ * This enumeration defines the record mode.
+ */
+typedef enum
+{
+       GSM_SEC_RECORD_NONE                             = 0x00,         /**< N/A, meaning the target file isn't a record type */
+       GSM_SEC_RECORD_ABSOLUTE                 = 0x01,         /**< The specified record will be read or updated */
+       GSM_SEC_RECORD_CURRENT                  = 0x02,         /**< The current record will be read or updated */
+       GSM_SEC_RECORD_NEXT                             = 0x03,         /**< The next record will be read or updated */
+       GSM_SEC_RECORD_PREVIOUS                 = 0x04,         /**< The previous record will be read or updated */
+       /**< All records from the record specified by record_index to the last one will be read */
+/*     GSM_SEC_RECORD_TO_THE_LAST              = 0x05, */ /**< To the last */
+       /**< All records from the first record to the one specified by record_index will be read */
+/*     GSM_SEC_RECORD_FROM_THE_FIRST   = 0x06  */      /**< From the first */
+
+} gsm_sec_sim_record_mode_t;
+
+
+/* for EI <-> VGSM - DB        */
+typedef struct _SimSecurity SimSecurity;
+
+struct _SimSecurity {
+       char pin_value[9];
+       char pin2_value[9];
+       char puk_value[9];
+       char puk2_value[9];
+       
+       int pin_cnt;
+       int pin2_cnt;
+       int puk_cnt;
+       int puk2_cnt;
+       int sim_state;
+       int facility_pin;
+       int facility_fdn;
+       int lock_sc2_state;
+};
+
+
+// 090601
+typedef struct
+{
+       int type1;                              // info : 0, data : 1
+       int type2;                              
+       //      info -> 0:usim_li, 1:ecc, 2:sst, 3:est, 4:cphs, 5:spn, 6:imsi 
+       //      data -> 0:iccid, 1:usim_li, 2:ecc, 3:sst, 4:est, 5:spn, 6:imsi 
+       int size;
+       unsigned char tmp[50];
+}_SIMD_t;
+
+#if 0
+/*********************************************************************************
+
+                                                            Main Command
+
+*********************************************************************************/
+typedef enum {
+       GSM_PWR_CMD=0x01,               /* 0x01 : Power Control Commands */
+       GSM_CALL_CMD,                   /* 0x02 : Call Control Commands */
+       GSM_DATA_CMD,                   /* 0x03 : Data Control Commands */
+       GSM_SMS_CMD,                    /* 0x04 : Short Message Service Commands */
+       GSM_SEC_CMD,                    /* 0x05 : Security - SIM control Commands */
+       GSM_PB_CMD,                     /* 0x06 : Phonebook Control Commands */
+       GSM_DISP_CMD,                   /* 0x07 : Display Control Commands */
+       GSM_NET_CMD,                    /* 0x08 : Network Commands */
+       GSM_SND_CMD,                    /* 0x09 : Sound Control Commands */
+       GSM_MISC_CMD,                   /* 0x0A : Miscellaneous Control Commands */
+       GSM_SVC_CMD,                    /* 0x0B : Service Mode Control Commands - Factory Test or Debug Screen Control */
+       GSM_SS_CMD,                     /* 0x0C : Supplementary Service Control Command */
+       GSM_GPRS_CMD,                   /* 0x0D : GPRS Commands */  // joonook 20041011 create
+       GSM_SAT_CMD,                    /* 0x0E : SIM Toolkit Commands */
+       GSM_CFG_CMD,                    /* 0x0F : Configuration Commands */
+       GSM_IMEI_CMD,                   /* 0x10 : IMEI Tool Commands */
+       GSM_GPS_CMD,                    /* 0x11 : GPSl Commands */
+       GSM_SAP_CMD,                    /* 0x12 : SIM Access Profile Commands */
+       GSM_GEN_CMD=0x80,               /* 0x80 : General Response Command */
+       GSM_CMD_MAX
+}gsm_main_cmd_type;
+
+/*********************************************************************************/
+
+
+/*********************************************************************************
+
+                                                         Command Type( PDA -> PHONE )
+
+*********************************************************************************/
+typedef enum {
+       GSM_CMD_EXEC    =       0x01,   /* 0x01 : Execute - Request the action to phone */
+       GSM_CMD_GET,                            /* 0x02 : Read the data from phone */
+       GSM_CMD_SET,                            /* 0x03 : Write the data to phone, Response must be GENERAL_RESPONSE */
+       GSM_CMD_CFRM,                           /* 0x04 : Response of the INDICATION */
+       GSM_CMD_EVENT,                  /* 0x05 : Notify the status of PDA */
+       GSM_PDA_MAX
+} gsm_pda_cmd_e_type; 
+
+/*********************************************************************************/
+
+
+/*********************************************************************************
+
+                                                         Command Type( PHONE -> PDA )
+
+**********************************************************************************/
+typedef enum {
+       GSM_CMD_INDI    =       0x01,   /* 0x01 : Indication - Request the action or data to PDA */
+       GSM_CMD_RESP,                           /* 0x02 : Response - Response of the GET */
+       GSM_CMD_NOTI,                           /* 0x03 : Notification - Notify the status of phone */
+       GSM_PHONE_MAX
+} gsm_phone_cmd_e_type;
+
+/*********************************************************************************/
+
+
+/*********************************************************************************
+
+                                            Sub Command
+
+**********************************************************************************/
+typedef enum{
+       GSM_SEC_PIN_STATUS                      =0x01,    /* 0x01 : PIN Status Message */
+       GSM_SEC_PHONE_LOCK,                                     /* 0x02 : Phone Lock Message */
+       GSM_SEC_CHANGE_LOCKING_PW,                      /* 0x03 : Change Locking Password Message */
+       GSM_SEC_SIM_LANG,                                               /* 0x04 : SIM Language Message */
+       GSM_SEC_RSIM_ACCESS,                                    /* 0x05 : +CRSM, Restricted SIM Access Message */
+       GSM_SEC_GSIM_ACCESS,                                    /* 0x06 : +CSIM, General SIM Access Message */             
+       GSM_SEC_SIM_ICC_TYPE,                                   /* 0x07 : SIM ICC Type Message*/
+       GSM_SEC_LOCK_INFO,                                      /* 0x08 : Lock Information Message*/
+       GSM_SEC_ISIM_AUTH,                                      /* 0x9 : ISIM Authentication Message */
+       GSM_SEC_MAX
+} gsm_sec_sub_cmd_type; 
+
+/*********************************************************************************/
+#endif
+
+#endif /*      __VGSM_SIM_H__  */
+
diff --git a/libvmodem/vgsm_sms.h b/libvmodem/vgsm_sms.h
new file mode 100644 (file)
index 0000000..a6bd71e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _vgsm_sms_h_
+#define _vgsm_sms_h_
+
+
+#endif // _vgsm_sms_h_
diff --git a/libvmodem/vgsm_ss.h b/libvmodem/vgsm_ss.h
new file mode 100644 (file)
index 0000000..e268626
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*********************************************************************
+*     vgsm_ss.h
+*********************************************************************/
+#ifndef _vgsm_ss_h_
+#define _vgsm_ss_h_
+
+#include <vgsm_call.h> // for MAX_GSM_DIALED_DIGITS_NUMBER
+
+       
+
+typedef enum {
+       SS_NONE = 0x01,
+       SS_TX_HOLD = 0X02,                      /* requested HOLD by EI */
+       SS_TX_ACTIVATE = 0x03,          /* requested ACTIVATE by EI */
+       SS_RX_HOLD = 0x04,                      /* requested HOLD by Simulator */
+       SS_RX_ACTIVATE = 0X05           /* requested ACTIVATE by Simulator */
+} ss_hold_act_state_e_type;
+
+typedef enum {
+    SS_STATE_HOLD = 0x01,
+    SS_STATE_UNHOLD = 0x02,
+    SS_STATE_CONFERENCE = 0x03,
+    SS_STATE_SWAP = 0x04,
+    SS_STATE_SPLIT = 0x05,
+    SS_STATE_DROP = 0x06
+} ss_state_e_type; //SS_State_Type;
+
+typedef enum {
+       SS_MODE_REG = 1,                /**< SS Mode registration. */
+       SS_MODE_DEREG = 2,              /**< SS Mode Deregistration. */
+       SS_MODE_ACT = 3,                        /**< SS Mode Activation. */
+       SS_MODE_DEACT = 4               /**< SS Mode Deactivation. */
+}ss_mode_e_type;
+
+/* CF_TYPE  field */
+typedef enum{
+  SS_CF_TYPE_CFU = 0x01,               /* 0x01 : Call Forwarding Unconditional */
+  SS_CF_TYPE_CFB,               /* 0x02 : Call Forwarding Mobile Busy */
+  SS_CF_TYPE_CFNRy,          /* 0x03 : Call Forwarding No Reply */
+  SS_CF_TYPE_CFNRc,          /* 0x04 : Call Forwarding Not Reachable */
+  SS_CF_TYPE_CF_ALL,        /* 0x05 : All Call Forwarding */
+  SS_CF_TYPE_CFC,              /* 0x06 : All Conditional Call Forwarding */
+  SS_CF_TYPE_MAX               /* 0x07 : Max */
+} ss_cf_e_type;
+
+/* CB_TYPE field */
+typedef enum {
+  SS_CB_TYPE_NONE,
+  SS_CB_TYPE_BAOC,                /* 0x01 : Barring All Outgoing Calls */
+  SS_CB_TYPE_BOIC,                /* 0x02 : Barring Outgoing International Calls */
+  SS_CB_TYPE_BOIC_NOT_HC, /* 0x03 : Barring Outgoing International Calls except to Home Country */
+  SS_CB_TYPE_BAIC,                /* 0x04 : Barring All Incoming Calls */
+  SS_CB_TYPE_BIC_ROAM,       /* 0x05 : Barring Incoming Calls when roam, outside of the Home Country */
+  SS_CB_TYPE_AB,                   /* 0x06 : All Barring Services */
+  SS_CB_TYPE_AOB,                 /* 0x07 : All Outgoing Barring Services */
+  SS_CB_TYPE_AIB,                  /* 0x08 : All Incoming Barring Services */
+  SS_CB_TYPE_BIC_NOT_SIM, /* 0x09 : Barring Incoming Calls which is not stored in the SIM memory */
+  SS_CB_TYPE_MAX
+} ss_cb_e_type;
+
+// actually, this data structures is used at db.
+typedef enum {
+       SS_CMD_CW = 1, 
+       SS_CMD_CB,
+       SS_CMD_CF
+} ss_cmd_e_type;
+
+typedef struct {
+       int             tel_class;
+       int             ss_mode; // reg(1) / dereg / act / deact
+       int             count;
+       char            number[MAX_GSM_DIALED_DIGITS_NUMBER];
+} call_waiting_entry_t;
+
+typedef struct {
+       int             tel_class;
+       int             type; //cb_type
+       int             ss_mode;
+       int             count;
+//     char            passwd[4];
+} call_barring_entry_t;
+
+typedef struct {
+       int             tel_class;  // gsm_ss_class_e_type
+       int             type; // gsm_ss_cf_e_type
+       char    number[MAX_GSM_DIALED_DIGITS_NUMBER];
+       char    subaddr[MAX_GSM_DIALED_DIGITS_NUMBER];
+       int             number_type;
+       int             replyTime;
+       int             ss_mode; // gsm_ss_mode_e_type
+       int             satype;
+       int             count;
+} call_forwarding_entry_t;
+
+typedef enum
+{
+       TAPI_SS_AOC_TYPE_RESET  = 0x00, /**< Specifies the Reset MAXACM Value. */
+       TAPI_SS_AOC_TYPE_ACM    = 0x01, /**< Specifies the Accumulated call meter. */
+       TAPI_SS_AOC_TYPE_CCM    = 0x02, /**< Specifies theCurrent call meter. */
+       TAPI_SS_AOC_TYPE_MAXACM = 0x04, /**< Specifies theMax accumulated call meter. */
+       TAPI_SS_AOC_TYPE_PUC    = 0x08  /**< Specifies thePrice per unit and currency.*/
+}TelSsAocType_t;
+
+#if 0
+typedef struct
+{
+       TelSsAocType_t AocType;         /**< Specifies the AOC type. */
+       UINT32  ACM;                                    /**< Specifies the accumulated call meter value. */
+       UINT32  MaxAcm;                                 /**< Specifies the maximum value of acm . */
+       float   CCM;                                    /**< Specifies the Current call meter value. */
+       float   PPM;                                    /**< Specifies the Price per unit value. */
+       unsigned char CharTypeOfCurrency;                       /**< Specifies the Char type of currency. */
+       unsigned char szCurrency[TAPI_SS_AOC_CURRENCY_LEN_MAX]; /**< Specifies the Currency characters. */
+} TelCallAocInfo_t;
+#endif 
+ // 090213 090330//////////////////////////////////////////////
+typedef struct
+{
+       long acm;
+       long ccm;
+       long maxacm;
+       long ppu;
+       char   chartype;
+       char currency[3];
+//     char *hdr;
+       //gsm_hdr_type *hdr;
+} _AOC_t;
+
+typedef struct
+{
+       int cwclass;
+       int status;
+} _setCW_t;
+
+typedef struct
+{
+       int code;
+       int number;
+       int bc;
+       int timer;
+       int status;
+} _setCF_t;
+
+typedef struct
+{
+       int code;
+       int passwd;
+       int status;
+} _setCB_t;
+
+typedef struct
+{
+       char time[50];
+       char weather[50];
+} _USSD_data_t;
+
+ // 090213 090330//////////////////////////////////////////////
+
+#endif // _vgsm_ss_h_
+
diff --git a/packaging/vmodemd-emul.spec b/packaging/vmodemd-emul.spec
new file mode 100644 (file)
index 0000000..28c21b1
--- /dev/null
@@ -0,0 +1,45 @@
+#git:slp/pkgs/v/vmodem-daemon-emulator
+Name: vmodemd-emul
+Version: 0.2.10
+Release: 1
+Summary: Modem Emulator
+Group: System/ModemEmulator
+License: GNU
+Source0: %{name}-%{version}.tar.gz
+ExclusiveArch: %{ix86}
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(sqlite3)
+
+%description
+Virtual modem emulator
+
+%prep
+%setup -q
+
+%build
+autoconf
+%configure
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/bin
+make install prefix=%{buildroot}
+
+%clean
+make clean
+rm -f build
+
+%post
+
+%postun
+
+%files
+%defattr(-,root,root,-)
+%attr(755,-,-) %{_bindir}/vmodem_x86
+
+%changelog
+
+
diff --git a/vmodem/DO_NO_MERGE b/vmodem/DO_NO_MERGE
new file mode 100644 (file)
index 0000000..90b45ba
--- /dev/null
@@ -0,0 +1 @@
+STOP!! DO NOT MERGE THIS FILE!!! THIS IS IPC 3.0 for the N-Project!
diff --git a/vmodem/Makefile.in b/vmodem/Makefile.in
new file mode 100644 (file)
index 0000000..c6ec169
--- /dev/null
@@ -0,0 +1,174 @@
+BINDIR = $(prefix)/usr/bin
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+
+DEFINES += __arm__
+DEFINES += _VGSM_DEBUG
+
+CFLAGS = @CFLAGS@
+CFLAGS += $(INCDIRS:%=-I%) $(DEFINES:%=-D%)
+CFLAGS += $(GLIB_CFLAGS)
+CFLAGS += -Wstrict-prototypes
+CFLAGS += -Wmissing-prototypes
+CFLAGS += -Wuninitialized
+CFLAGS += -Wpointer-arith
+CFLAGS += -Wp,-MD,$(dir $@).$(notdir $@).d -Wp,-MT,$@
+# for bypass __stack_chk_fail
+CFLAGS +=-fno-stack-protector 
+
+CC = @CC@
+LD = @LD@
+
+INCDIRS = \
+       ../libvmodem \
+       include \
+       include/server \
+       include/db \
+       include/oem \
+       include/at \
+       include/transport \
+       include/sat \
+       ../lib/libsms \
+       ../lib/libcommon
+
+LIB =  -lsqlite3 \
+       -lvconf \
+       ../lib/libcommon/libcommon.a \
+       ../lib/libsms/libsms.a \
+       $(GLIB_LIBS)
+
+SOURCES = \
+       transport/gsmstate.c \
+       sat/sat_util.c \
+       sat/apdu_tool.c \
+       at/at_tx_power.c \
+       at/at_rx_power.c \
+       at/at_tx_security.c \
+       at/at_rx_security.c \
+       at/at_tx_display.c \
+       at/at_rx_display.c \
+       at/at_tx_network.c \
+       at/at_rx_network.c \
+       at/at_tx_misc.c \
+       at/at_rx_misc.c \
+       at/at_gen_resp.c \
+       at/at_tx_sms.c \
+       at/at_rx_sms.c \
+       at/at_tx_emulator.c \
+       at/at_msg.c \
+       at/at_recv.c \
+       at/at_tx_ss.c \
+       at/at_rx_ss.c \
+       at/at_tx_snd.c \
+       at/at_rx_snd.c \
+       at/at_tx_gprs.c \
+       at/at_rx_gprs.c \
+       at/at_rx_gps.c \
+       at/at_rx_sap.c \
+       at/at_tx_sat.c \
+       at/at_rx_sat.c \
+       at/at_tx_phonebook.c \
+       at/at_rx_phonebook.c \
+       at/at_tx_call.c \
+       at/at_rx_call.c \
+       at/at_tx_data.c \
+       at/at_rx_data.c \
+       at/at_func.c \
+       at/at_send.c \
+       server/main.c \
+       server/gsm.c \
+       server/phoneserver.c \
+       server/eloop.c \
+       server/server.c \
+       server/client.c \
+       server/func_ps.c \
+       server/misc.c \
+       server/flight.c \
+       db/db_network.c \
+       db/db_ss.c \
+       db/db_security.c \
+       db/db_phonebook.c \
+       db/db_gprs.c \
+       server/server_tx_call.c \
+       server/server_rx_call.c \
+       server/server_common_call.c \
+       server/server_tx_ss.c \
+       server/server_rx_ss.c \
+       server/server_common_ss.c \
+       server/server_tx_power.c \
+       server/server_rx_power.c \
+       server/server_tx_network.c \
+       server/server_rx_network.c \
+       server/server_common_network.c \
+       server/server_tx_display.c \
+       server/server_rx_display.c \
+       server/server_tx_sms.c \
+       server/server_rx_sms.c \
+       server/server_tx_data.c \
+       server/server_rx_data.c \
+       server/server_tx_gprs.c \
+       server/server_rx_gprs.c \
+       server/server_tx_security.c \
+       server/server_rx_security.c \
+       server/server_tx_phonebook.c \
+       server/server_rx_phonebook.c \
+       server/server_rx_misc.c \
+       server/server_common_gprs.c \
+       server/state.c \
+       server/server_common_security.c \
+       server/server_common.c \
+       server/server_dpram.c \
+       server/server_client.c \
+       oem/oem_tx_call.c \
+       oem/oem_rx_call.c \
+       oem/oem_tx_ss.c \
+       oem/oem_rx_ss.c \
+       oem/oem_tx_power.c \
+       oem/oem_rx_power.c \
+       oem/oem_tx_network.c \
+       oem/oem_rx_network.c \
+       oem/oem_tx_display.c \
+       oem/oem_rx_display.c \
+       oem/oem_tx_sms.c \
+       oem/oem_rx_sms.c \
+       oem/oem_tx_data.c \
+       oem/oem_rx_data.c \
+       oem/oem_tx_gprs.c \
+       oem/oem_rx_gprs.c \
+       oem/oem_tx_security.c \
+       oem/oem_rx_security.c \
+       oem/oem_tx_phonebook.c \
+       oem/oem_rx_phonebook.c \
+       oem/oem_rx_misc.c \
+       oem/oem_tx_misc.c \
+       server/logmsg.c
+
+OBJ_COMMON = $(SOURCES:%.c=%.o)
+
+OBJ_X86 += transport/transport_dpram.o
+
+OBJ_ARM += transport/transport_onedram.o
+
+DEPFILES += $(foreach object,$(OBJ),$(dir $(object)).$(notdir $(object)).d)
+
+TARGET_X86 = vmodem_x86
+TARGET_ARM = vmodem_arm
+
+all: $(TARGET_X86) $(TARGET_ARM)
+
+-include $(DEPFILES)
+
+$(TARGET_X86): $(OBJ_X86) $(OBJ_COMMON)
+       $(CC) $(OBJ_X86) $(OBJ_COMMON) -o $@ $(LIB)
+
+$(TARGET_ARM): $(OBJ_ARM) $(OBJ_COMMON)
+       $(CC) $(OBJ_ARM) $(OBJ_COMMON) -o $@ $(LIB)
+
+
+clean:
+       rm -f $(OBJ_COMMON) $(OBJ_ARM) $(OBJ_X86) $(TARGET_ARM) $(TARGET_X86)
+       rm -f $(DEPFILES)
+       find . -name "*.o.d" | xargs rm -f
+
+install:
+       cp -f $(TARGET_X86) $(BINDIR)
diff --git a/vmodem/at/at_func.c b/vmodem/at/at_func.c
new file mode 100644 (file)
index 0000000..a6aadb7
--- /dev/null
@@ -0,0 +1,393 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunGoo Kang <hyungoo1.kang@samsung.com>
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_func.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include "state.h"
+#include <phoneserver.h>
+#include <misc.h>
+#include "at_recv.h"
+#include "at_msg.h"
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_tx_func.h"
+#include "at_func.h"
+
+#define MAX_HDLC_FRAME_SIZE            2048
+#define MAX_DATA_RESPONSE              2048
+
+extern GSM_StateMachine GlobalS;
+static char s_at_data[MAX_DATA_RESPONSE+1];
+static char *s_at_data_ptr = s_at_data;
+static int s_dpram_fd = -255;
+static int sms_data_len = 0;
+/************************************************/
+
+char* find_new_line(char* ptr, bool sms)
+{
+       if(sms)
+       {
+               // find new line
+               while(*ptr != '\0')
+               {
+                       ptr++;
+               }
+       }
+       else
+       {
+               // find new line
+               while (*ptr != '\0' && *ptr != '\r' && *ptr != '\n') 
+               {
+                       ptr++;
+               }
+       }
+
+       return ptr;
+}
+
+char* read_cmd_line(void)
+{
+    char s_TmpBuffer[MAX_DATA_RESPONSE+1];
+    int cnt;
+    char* data_read = NULL;
+    char* data_eol = NULL;
+    char* ret;
+    bool sms = false;
+    char* data = NULL;
+    char token[] = "\r";
+    char* length = NULL;
+    int pdu_length = 0, sca_length = 0, total_data_length = 0;
+    int start_pduIndex = 0;
+
+    // empty data
+    if (*s_at_data_ptr == '\0') 
+    {
+       s_at_data_ptr = s_at_data;
+       *s_at_data_ptr = '\0';
+       data_read = s_at_data;
+    } 
+    else 
+    {   
+        while(*s_at_data_ptr == '\r' || *s_at_data_ptr == '\n')
+        {
+               s_at_data_ptr++;
+       }
+
+       data_eol = find_new_line(s_at_data_ptr, sms);
+
+        if (data_eol == NULL) 
+       {
+               unsigned int data_len;
+               data_len = strlen(s_at_data_ptr);
+               memcpy(s_at_data, s_at_data_ptr, data_len + 1);
+               data_read = s_at_data + data_len;
+               s_at_data_ptr = s_at_data;
+        }
+    }
+
+    while (data_eol == NULL) 
+    {
+           int data_size = MAX_DATA_RESPONSE - (data_read - s_at_data);
+           
+           if(data_size == 0) 
+           {
+               s_at_data_ptr = s_at_data;
+               *s_at_data_ptr = '\0';
+               data_read = s_at_data;
+            }
+            
+           while(1)
+           {
+               cnt = read(s_dpram_fd, data_read, data_size);
+               if(errno != EINTR || cnt >= 0)
+                       break;
+            }
+           
+            if (cnt > 0) {
+               if( !strncmp(s_at_data_ptr, ATCMGS, strlen(ATCMGS)) )
+                {
+                        TRACE(MSGL_VGSM_INFO, "sms true\n");
+                       sms = true;
+                       memset(s_TmpBuffer, '\0', MAX_DATA_RESPONSE+1);
+                       memcpy(s_TmpBuffer, s_at_data_ptr, MAX_DATA_RESPONSE+1);
+                       sms_data_len = 0;
+               
+                       data = strchr(s_TmpBuffer, '=');
+                       length = strtok(data+1, token);
+                       if(length)
+                        {
+                               pdu_length = atoi(length);
+                       }
+
+                       start_pduIndex = (strlen(ATCMGS) + strlen(length) + strlen(token) + 1);
+                       sca_length = hexCharToInt(data_read[start_pduIndex]);
+                       total_data_length = (pdu_length + sca_length + 1) * 2;  // 1: byte of sca length 
+                       sms_data_len = start_pduIndex + total_data_length;
+               
+                       TRACE(MSGL_VGSM_INFO, "sca_length:%d, total_data_length: %d, cnt: %d\n", sca_length, total_data_length, cnt);
+                       TRACE(MSGL_VGSM_INFO, "(strlen(ATCMGS) + strlen(length) + strlen(token)): %d, sms_data_len:%d\n", (strlen(ATCMGS) + strlen(length) + strlen(token)), sms_data_len);
+                       
+                       while(cnt < sms_data_len + 1)
+                       {
+                               cnt += read(s_dpram_fd, data_read + cnt, MAX_DATA_RESPONSE - (data_read - s_at_data) - cnt);
+                       }
+
+                       data_read[cnt - 2] = '\0';
+                       data_read[cnt - 1] = '\0';
+               }
+               
+                data_read[cnt] = '\0';
+               
+               while (*s_at_data_ptr == '\r' || *s_at_data_ptr == '\n')
+                       s_at_data_ptr++;
+       
+               data_eol = find_new_line(s_at_data_ptr, sms);
+                data_read += cnt;
+            } else if (cnt <= 0) {
+               if(cnt == 0) {
+                       TRACE(MSGL_VGSM_INFO, "read cnt = 0");
+               } else {
+                       TRACE(MSGL_VGSM_INFO, "read error %s", strerror(errno));
+               }
+
+               return NULL;
+            }
+    }
+    
+    ret = s_at_data_ptr;
+    *data_eol = '\0';
+    s_at_data_ptr = data_eol + 1;
+                                
+    TRACE(MSGL_VGSM_INFO, "AT< %s\n", ret);
+
+    return ret;
+}
+
+int GSM_ATDispatchDpramData(GSM_StateMachine* pstate)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       HDLCFrame_t frame = {0,};
+       char* atmsg = (char*)malloc(MAX_HDLC_FRAME_SIZE);
+       const char* scmd;
+       int found = 0, nn = 0;
+       
+       GSM_Device_DPRAMData *d = &pstate->Device.Data.DPRAM;
+       struct timeval      timeout2;
+        fd_set              readfds;
+
+        FD_ZERO(&readfds);
+        FD_SET(d->hPhone, &readfds);
+
+        timeout2.tv_sec     = 0;
+        timeout2.tv_usec    = 1;
+       s_dpram_fd = d->hPhone;
+
+        if  (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2))
+        {
+               memset(atmsg, '\0', MAX_HDLC_FRAME_SIZE);
+               atmsg = read_cmd_line();
+               if(atmsg == NULL) {
+                       return -1;
+               }
+        }
+       TRACE(MSGL_VGSM_INFO, "atmsg length: %d\n", strlen(atmsg));     
+
+       // set default value 
+       frame.m_StartMagicCode = 0x7F;
+       frame.m_EndMagicCode = 0x7E;
+       frame.m_CtrlInfo = 0x7F;
+       frame.m_Length = strlen(atmsg);
+       if (frame.m_Length <= 0) {
+               TRACE(MSGL_WARN, "================================\n");
+               TRACE(MSGL_WARN, "Warning !!! Invalid HDLC Frame Packet : Length 0 \n");
+               TRACE(MSGL_WARN, "================================\n");
+               return -1;
+       }
+
+       if (frame.m_Length > 0) {
+               // allocate memory by data size
+               frame.m_pValue = malloc(frame.m_Length);
+               memcpy(frame.m_pValue, atmsg, strlen(atmsg));
+       }
+       // have no data
+       else
+       {
+               // init
+               frame.m_pValue = NULL;
+               TRACE(MSGL_VGSM_INFO, "HDLC Frame RX << No data\n");
+       }
+
+       // set last recv HDLC frame
+       ATSetLastRecvHDLCFrameInfo(&frame);
+       // make lxt message
+       if (frame.m_pValue) {
+               // everything that doesn't start with 'AT' is not a command.
+               if(atmsg[0] != 'A' || atmsg[1] != 'T' || atmsg[2] == 0) {
+                       TRACE(MSGL_VGSM_INFO, "Unsupported Command %s\n", atmsg);
+                       memset(frame.m_pValue, '\0', frame.m_Length);
+                       free(frame.m_pValue);
+                       return -1;
+               }
+               atmsg += 2;
+               
+               {
+                       for (nn = 0; ; nn++) {
+                               scmd = sDefaultResponses[nn].cmd;
+                               if (!scmd) // end of list
+                                       break;
+
+                               if (scmd[0] == '!') { // prefix match
+                                       int  len = strlen(++scmd);
+
+                                       if ( !memcmp( scmd, atmsg, len ) ) {
+                                               found = 1;
+                                               break;
+                                       }
+                               } else { // full match
+                                       if ( !strcmp( scmd, atmsg ) ) {
+                                               found = 1;
+                                               break;
+                                               }
+                               }
+                       }
+                       
+                       if ( !found )
+                       {
+                               TRACE(MSGL_VGSM_INFO, "Unsupported Command %s\n", atmsg);
+                               return -1;
+                       }
+                       else
+                       {
+                               SetLastRecvAT(atmsg);
+
+                               if( get_hdlc_mode() == 1 )
+                               {
+                                       return 0;
+                               }
+
+                               change_state_machine(sDefaultResponses[nn].main_cmd);
+
+                               at_set_recv_cmd(sDefaultResponses[nn].cmd);
+                               ResponseHandler handler = sDefaultResponses[nn].handler;
+                               handler(sDefaultResponses[nn].cmd, atmsg);
+                       }
+               }
+               // release memory
+               memset(frame.m_pValue, '\0', frame.m_Length);
+               free(frame.m_pValue);
+       }
+       
+       return 1;
+}
+
+void prv_byte_to_char(unsigned char aByte, char* hexaCharP)
+{
+    if (aByte < 0x0a)
+        *hexaCharP = (char) (aByte + '0');
+    else
+        *hexaCharP = (char) (aByte + 0x57);
+}
+
+void prv_bytes_to_hexadecimal_string(unsigned char* bytesP, int bytesSize, char* hexaStringP, int* hexaStringSize)
+{
+    int i;
+    int hexaLen;
+
+    if( !hexaStringP || !hexaStringSize)
+    {
+        TRACE(MSGL_VGSM_INFO, " INVALID_PARAMETER:  !hexaStringP || !hexaStringSize");
+        return;
+    }
+
+    hexaLen = *hexaStringSize;
+    *hexaStringSize = 0;
+    for ( i = 0 ; i < bytesSize ; i++ )
+    {
+        if( hexaLen > 2 )
+        {
+            prv_byte_to_char((unsigned char) (*bytesP >> 4), (char*) (hexaStringP++));
+            prv_byte_to_char((unsigned char) (*bytesP & 0xF), (char*) (hexaStringP++));
+
+            hexaLen -= 2;
+        }
+
+        *hexaStringSize += 2;
+        bytesP++;
+    }
+}
+
+uint8_t hexCharToInt(char c)
+{
+    if (c >= '0' && c <= '9')
+    {
+        return (c - '0');
+    }
+    else if (c >= 'A' && c <= 'F')
+    {
+        return (c - 'A' + 10);
+    }
+    else if (c >= 'a' && c <= 'f')
+    {
+        return (c - 'a' + 10);
+    }
+    else
+    {
+        TRACE(MSGL_VGSM_INFO, "invalid charater!! %02x\n", c);
+        return 0;
+    }
+}
+
+int hexStringToBytes(char* d, char * s)
+{
+    char* ret;
+    int i;
+    int sz;
+
+    if(s == NULL)
+        return 0;
+
+       sz = strlen(s);
+
+    ret = malloc(sz /2);
+
+
+    for(i = 0; i < sz; i += 2)
+    {
+        d[i/2] = (char)((hexCharToInt(s[i]) << 4) | hexCharToInt(s[i + 1]));
+    }
+
+    return i/2;
+}
diff --git a/vmodem/at/at_gen_resp.c b/vmodem/at/at_gen_resp.c
new file mode 100644 (file)
index 0000000..0ac440e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  at_gen_resp.c */
+
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+static char* g_recv_atmsg;
+static int g_msgseq ;
+
+void at_set_recv_cmd(char* atmsg)
+{
+       g_recv_atmsg = atmsg;
+}
+
+int get_at_msgseq(void)
+{
+       return g_msgseq;
+}
+
+int at_gen_resp_send(char* gen_resp_err)
+{
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       sprintf(sndbuf, "%s%s", gen_resp_err, CRLF);
+
+       TRACE(MSGL_VGSM_INFO, "gen_resp_send = %s", sndbuf);
+       return at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+}
+
diff --git a/vmodem/at/at_msg.c b/vmodem/at/at_msg.c
new file mode 100644 (file)
index 0000000..8c6a9c4
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_msg.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "at_msg.h"
+
+static HDLCFrame_t s_FrameSentInfo;
+static HDLCFrame_t s_FrameRecvInfo;
+
+// Last sent HDLC frame info
+void ATSetLastSentHDLCFrameInfo(HDLCFrame_t const* pframe)
+{
+       s_FrameSentInfo.m_CtrlInfo = pframe->m_CtrlInfo;
+       s_FrameSentInfo.m_Length = pframe->m_Length;
+}
+
+HDLCFrame_t const* ATGetLastSentHDLCFrameInfo(void)
+{
+       return &s_FrameSentInfo;
+}
+
+// Last receive HDLC frame info
+void ATSetLastRecvHDLCFrameInfo(HDLCFrame_t const* pframe)
+{
+//     TRACE(MSGL_VGSM_INFO, "\n");
+       s_FrameRecvInfo.m_CtrlInfo = pframe->m_CtrlInfo;
+       s_FrameRecvInfo.m_Length = pframe->m_Length;
+}
+
+HDLCFrame_t const* ATGetLastRecvHDLCFrameInfo(void)
+{
+       return &s_FrameRecvInfo;
+}
+
+static char* s_ATSentInfo;
+static char* s_ATRecvInfo;
+
+// Last sent AT frame info
+void SetLastSentAT(char* atmsg)
+{
+       s_ATSentInfo = atmsg;
+}
+
+char* GetLastSentAT(void)
+{
+       return s_ATSentInfo;
+}
+
+// Last recv AT info
+void SetLastRecvAT(char* atmsg)
+{
+       s_ATRecvInfo = atmsg;
+}
+
+char* GetLastRecvAT(void)
+{
+       return s_ATRecvInfo;
+}
+
+// For multi HDLC frame.
+typedef struct tagHDLCNode {
+       struct tagHDLCNode* m_pNext;
+       HDLCFrame_t m_HDLCNode;
+} HDLCNode;
+
+HDLCNode* g_ATpHead = NULL;
+HDLCNode* g_ATpTail = NULL;
+
+void ATFreeAllMultiNodeList(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       HDLCNode* pnode_tmp;
+       HDLCNode* pnode = g_ATpHead;
+       while (pnode) {
+               pnode_tmp = pnode;
+               pnode = pnode->m_pNext;
+
+               // free data
+               if (pnode_tmp->m_HDLCNode.m_pValue)
+                       free(pnode_tmp->m_HDLCNode.m_pValue);
+               free(pnode_tmp);
+       }
+
+       g_ATpHead = g_ATpTail = NULL;
+}
+
+/*     ++ 2008-09-29.
+       ++ Name : PushHDLCMultiFrameInfo
+       ++ Args : HDLCFrame_t const* pframe
+       ++ Multi frame ÀÏ ¶§, ID¸¦ check Çϴ ºÎºÐÀÌ ¾ø´Ù.
+       ++ ID ºñ±³Çؼ­ ÀÌ°ÍÀÌ single messageÀÎÁö multiple messageÀÎÁö ÆÇ´ÜÇϴ ºÎºÐÀÌ ÇÊ¿äÇÏ´Ù.
+*/
+void ATPushHDLCMultiFrameInfo(HDLCFrame_t const* pframe)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       HDLCNode* pnode = malloc(sizeof(HDLCNode));
+
+       if (!pframe)
+               return;
+
+       memset(pnode, 0, sizeof(HDLCNode));
+
+       pnode->m_HDLCNode.m_Length = pframe->m_Length;
+       pnode->m_HDLCNode.m_CtrlInfo = pframe->m_CtrlInfo;
+
+       if (pframe->m_Length - 3 > 0) {
+               pnode->m_HDLCNode.m_pValue = malloc(pframe->m_Length - 3);
+               memcpy(pnode->m_HDLCNode.m_pValue, pframe->m_pValue, pframe->m_Length - 3);
+       }
+
+       if (!g_ATpHead) {
+               g_ATpHead = pnode;
+       } else {
+               if (g_ATpTail)
+                       g_ATpTail->m_pNext = pnode;
+       }
+
+       g_ATpTail = pnode;
+}
+
+HDLCFrame_t const* ATGetLastRecvHDLCMultiFrameInfo(void)
+{
+//     TRACE(MSGL_VGSM_INFO, "\n");
+
+       if (g_ATpTail)
+               return &(g_ATpTail->m_HDLCNode);
+
+       return NULL;
+}
+
+char* ConvertHDLCMultiFrameToAT(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       unsigned char* atmsg_data = NULL;
+       unsigned char* ptr = NULL;
+       int at_size = 0;
+       HDLCNode* pnode = g_ATpHead;
+
+       while (pnode) {
+               at_size += pnode->m_HDLCNode.m_Length - 3;
+               pnode = pnode->m_pNext;
+       }
+
+       if (at_size > 0) {
+               atmsg_data = malloc(at_size);
+               ptr = atmsg_data;
+               pnode = g_ATpHead;
+               while (pnode) {
+                       memcpy(ptr, pnode->m_HDLCNode.m_pValue, pnode->m_HDLCNode.m_Length - 3);
+                       ptr += pnode->m_HDLCNode.m_Length - 3;
+
+                       pnode = pnode->m_pNext;
+               }
+       }
+
+       ATFreeAllMultiNodeList();
+
+       return (char*)atmsg_data;
+}
+
diff --git a/vmodem/at/at_recv.c b/vmodem/at/at_recv.c
new file mode 100644 (file)
index 0000000..e93b4a8
--- /dev/null
@@ -0,0 +1,425 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_recv.c
+ */
+
+#include <assert.h>
+
+#include "at_tx_func.h"
+#include "at_recv.h"
+#include "at_rx_data.h"
+#include "at_rx_sms.h"
+#include "at_rx_gprs.h"
+#include "at_gen_resp.h"
+#include "at_rx_call.h"
+#include "at_rx_ss.h"
+#include "at_rx_network.h"
+#include "at_rx_display.h"
+#include "at_rx_security.h"
+#include "at_rx_phonebook.h"
+#include "at_rx_snd.h"
+#include "at_rx_sap.h"
+#include "at_rx_sat.h"
+#include "at_rx_misc.h"
+#include "at_rx_gps.h"
+#include "at_rx_func.h"
+#include "at_func.h"
+#include "server_tx_gprs.h"
+#include "at_tx_call.h"
+
+void NOT_SUPPORTED_AT(char* atmsg)
+{
+       TRACE(MSGL_WARN," THIS AT IS NOT SUPPROTED..\n");
+}
+
+void at_unimplemented(const char* api)
+{
+       TRACE(MSGL_WARN,"%s is unsupported\n",api);
+}
+
+#define unimplemented_case(X) case X: \
+       TRACE(MSGL_WARN, #X " is unimplemented\n"); \
+break;
+
+int at_recv_misc(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       if( !strcmp( cmd, "+CGMR") )
+       {
+               return at_rx_misc_me_version(atmsg);
+       }
+       else if( !strcmp( cmd, "+CGSN") )
+       {
+               return at_rx_misc_me_serial(atmsg);
+       }
+       else if( !strcmp( cmd, "+CIMI") )
+       {
+               return at_rx_sim_sec_imsi(atmsg);
+       }
+       // return at_rx_misc_time_info_get(atmsg);
+
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_power(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "cmd:%s\n", cmd);
+       if ( !strcmp( cmd, "+CPAS" ))
+       {
+               return at_rx_power_up_exec(atmsg);
+       }
+       else if ( !strcmp( cmd, "!+CFUN=" ))
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+               return at_rx_online_exec(atmsg);
+       }
+       NOT_SUPPORTED_AT(cmd);
+       return 1;
+}
+
+int at_recv_call(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       if( !strcmp( cmd, "!D") )       // outgoing
+       {
+               return at_rx_call_originate_exec(atmsg);
+       }
+       else if( !strcmp( cmd, "A") )   // answer
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+               at_rx_call_answer_exec(atmsg);
+               return at_tx_call_connect_noti(atmsg, strlen(atmsg));
+       }
+       else if( !strcmp( cmd, "+CLCC") )       // get list
+       {
+               return at_rx_call_list_get(atmsg);
+       }
+       else if( !strcmp( cmd, "!H") )
+       {       
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                return at_rx_call_release_exec(atmsg);
+       }
+       // return at_rx_call_line_id_set(atmsg);
+       // return at_rx_call_line_id_get(atmsg);
+       // return at_rx_call_burst_dtmf_exec(atmsg);
+
+       NOT_SUPPORTED_AT(atmsg);        
+       return 1;
+}
+
+int at_recv_data(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_sms(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "%s\n", atmsg);
+       if( !strcmp(cmd, "!+CMMS=") )
+       {
+               return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+       }
+       else if( !strcmp(cmd, "!+CMGS=") )
+       {
+                return at_rx_sms_SendMsg(atmsg);
+       }
+       else if( !strcmp(cmd, "!+CPMS") )
+       {
+               return at_rx_sms_stored_msg_count_get(atmsg);
+       }
+       else if( !strcmp(cmd, "!+CNMA=") )      // deliver report
+       {
+                return at_rx_sms_deliver_report_exec(atmsg);
+       }
+       // return at_rx_sms_param_count_get(atmsg);
+       // return at_rx_sms_param_set(atmsg);
+       // return at_rx_sms_param_get(atmsg);
+       // return at_rx_sms_svc_option_set(atmsg);
+       // return at_rx_sms_mem_status_set(atmsg);
+       // return at_rx_sms_cbconfig(atmsg);
+
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_security(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       if( !strcmp(cmd, "!+CRSM=") )
+       {
+               return at_rx_sim_sec_rsim_access(atmsg);        
+       }
+       else if( !strcmp(cmd, "!+CLCK=") )
+       {
+               return at_rx_sim_sec_phone_lock_get(atmsg);
+       }
+       else if( !strcmp(cmd, "!%SCCT") )
+       {
+               return at_rx_sim_sec_card_type(atmsg);
+       }
+       else if( !strcmp(cmd, "!CPINR=") )
+       {
+               return at_rx_sim_sec_lock_info(atmsg);
+       }
+       else if( !strcmp(cmd, "!+CPIN=") )
+       {
+               return at_rx_sim_sec_change_password(atmsg);
+       }
+       // return at_rx_sim_sec_pin_status(atmsg);
+
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_phonebook(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_display(char*cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       // return at_rx_display_icon_info_get(atmsg);
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_network(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "%s\n", cmd);
+       if( !strcmp(cmd, "+CNUM") )
+       {
+               return at_rx_net_subscriber_num_get(atmsg);
+       }
+       else if( !strcmp(cmd, "+COPS?") )       // plmn sel or current plmn get or plmn selection get
+       {
+               return at_rx_net_current_plmn_get();
+       }
+       else if( !strcmp(cmd, "+COPS=?") )
+       {
+               return at_rx_net_plmn_list_get();
+       }
+       else if( !strcmp(cmd, "!+COPS=") )
+       {
+               return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+       }
+       else if( !strcmp(cmd, "+CREG?") )
+       {
+               return at_rx_net_reg_get();
+       }
+       else if( !strcmp(cmd, "!+CREG=") )
+       {
+               return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+       }
+       // return at_rx_net_band_get(atmsg);
+       // return at_rx_net_band_set(atmsg);
+       // return at_rx_net_service_domain_get(atmsg);
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_ss(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "%s\n", atmsg);
+       char data[48];
+        strcpy(data, atmsg);
+       char* tdata = strchr(atmsg, '=');
+        char* ret = NULL;
+
+       if( !strcmp(cmd, "!+CCWA=") )   // call waiting set
+       {
+               // mode check
+                ret = strtok(tdata+1, TOKEN);
+                ret = strtok(NULL, TOKEN);
+                if(atoi(ret) == 2)              // get
+                {
+                       return at_rx_ss_cw_get(data);
+               }
+               else                            // set
+               {
+                       at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                       return at_rx_ss_cw_set(data);
+               }
+       }
+       else if( !strcmp(cmd, "+CCWA=?") )      // call waiting list get
+       {
+               return at_rx_ss_cw_get(atmsg);
+       }
+       else if( !strcmp(cmd, "!+CHLD=") )      // call hold
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                return at_rx_ss_manage_call_set(atmsg);        
+       }
+       else if( !strcmp(cmd, "!+CCFC=") )
+       {
+               ret = strtok(tdata+1, TOKEN);
+               ret = strtok(NULL, TOKEN);
+               TRACE(MSGL_VGSM_INFO, "FW MODE:%s\n", ret);
+
+               if(atoi(ret) == AT_CALL_FW_MODE_QUERY)          // query status
+               {
+                       return at_rx_ss_cf_get(data);
+               }
+               else                                            // mode set
+               {
+                       at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                        return at_rx_ss_cf_set(data);
+               }
+       }
+       else if( !strcmp(cmd, "!+CLCK=") )
+       {
+               char token[] = "\"";
+                ret = strtok(tdata+1, token);
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               
+               if( !strcmp(ret, "PS") || !strcmp(ret, "SC") || !strcmp(ret, "FD") )    // for security
+               {
+                       return at_recv_security(cmd, data);
+               }
+               else
+               {
+                       ret = strtok(NULL, TOKEN);
+                       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+                       if(atoi(ret) == 0 || atoi(ret) == 1)              // set
+                       {
+                                       return at_rx_ss_cb_set(data);
+                       }
+                       else if(atoi(ret) == 2)         // get
+                       {
+                                       return at_rx_ss_cb_get(data);
+                       }
+                       else            
+                       {       
+                               NOT_SUPPORTED_AT(atmsg);
+                               return -1;
+                       }
+               }
+       }
+
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+//GSM_GPRS_CMD GPRS(General Packet Radio Service)
+int at_recv_gprs(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       if( !strcmp(cmd, "!+CGDCONT=") )
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+               return at_rx_gprs_SetPDPContext(atmsg);
+       }
+       else if( !strcmp (cmd, "+CGDCONT?") )
+       {
+                server_tx_gprs_IPConfigurationNotify(0);
+               return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+       }
+       else if( !strcmp(cmd, "!+CGACT=") )
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+               return at_rx_gprs_SetPSActDeact(atmsg);
+       }
+       else if( !strcmp(cmd, "!D*99***1#") )
+       {
+               at_gen_resp_send(AT_GEN_ERR_CONNECT);
+               return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+       }
+       
+       return at_rx_gprs_DefaultGPRS(atmsg);
+}
+
+int at_recv_sat(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_snd(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "..\n");
+       if( !strcmp(cmd, "!%SCMUT=") )          // set SND MIC MUTE CTRL
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                return at_rx_snd_mute_control_set(atmsg);
+       }
+       else if( !strcmp(cmd, "%SCMUT?") )      // get SND AUDIO PATH CTRL
+       {
+               return at_rx_snd_mute_control_get(atmsg);
+       }
+       else if( !strcmp(cmd, "!%SCAUD=") )     // set SND AUDIO PATH CTRL
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                return at_rx_snd_audio_path_set(atmsg);
+       }
+       else if( !strcmp(cmd, "!%SCCLK=") )     // exec SND CLOCK CTRL
+       {
+               at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+                return at_rx_snd_clock_ctrl_exec(atmsg);
+       }
+
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_sap(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_svc(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_cfg(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
+int at_recv_gps(char* cmd, char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       NOT_SUPPORTED_AT(atmsg);
+       return 1;
+}
+
diff --git a/vmodem/at/at_rx_call.c b/vmodem/at/at_rx_call.c
new file mode 100644 (file)
index 0000000..1ae27fb
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*     at_rx_call.c    */
+
+#include <assert.h>
+#include "oem_rx_call.h"
+#include "at_msg.h"
+#include "at_recv.h"
+#include "at_rx_call.h"
+
+int at_rx_call_originate_exec(char* atmsg)
+{
+       return oem_rx_call_originate_exec(atmsg, strlen(atmsg));
+}
+
+int at_rx_call_list_get(char* atmsg)
+{
+       return oem_rx_call_list_get();
+}
+
+int at_rx_call_release_exec(char* atmsg)
+{
+       return oem_rx_call_release_exec();
+}
+
+int at_rx_call_answer_exec(char* atmsg)
+{
+       return oem_rx_call_answer_exec();
+}
+
+int at_rx_call_burst_dtmf_exec(char* atmsg)
+{
+       return oem_rx_call_burst_dtmf_exec();
+}
+
+int at_rx_call_line_id_set(char* atmsg)
+{
+       return oem_rx_call_line_id_set(atmsg, strlen(atmsg));
+}
+
+int at_rx_call_line_id_get(char* atmsg)
+{
+       return oem_rx_call_line_id_get( );
+}
+
+
diff --git a/vmodem/at/at_rx_data.c b/vmodem/at/at_rx_data.c
new file mode 100644 (file)
index 0000000..e79596c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_msg.h"
+#include "oem_rx_data.h"
+#include "at_rx_data.h"
+
+int at_rx_data_GetDataCallStatus(char* atmsg)
+{
+       return oem_rx_data_GetDataCallStatus(atmsg, strlen(atmsg));
+}
+
+int at_rx_data_DefaultData(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
diff --git a/vmodem/at/at_rx_display.c b/vmodem/at/at_rx_display.c
new file mode 100644 (file)
index 0000000..971adb7
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_rx_display.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "at_rx_display.h"
+#include "oem_rx_display.h"
+
+int at_rx_display_default(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+    return 1;
+}
+
+int at_rx_display_icon_info_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       // we always response it to request type(0xff)
+
+       return oem_rx_display_icon_info_get();
+}
+
diff --git a/vmodem/at/at_rx_gprs.c b/vmodem/at/at_rx_gprs.c
new file mode 100644 (file)
index 0000000..2811637
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_msg.h"
+#include "oem_rx_gprs.h"
+#include "at_rx_gprs.h"
+
+int at_rx_gprs_SetPDPContext(char* atmsg)
+{
+       return oem_rx_gprs_SetPDPContext(atmsg, strlen(atmsg));
+}
+
+int at_rx_gprs_SetPSActDeact(char* atmsg)
+{
+       return oem_rx_gprs_SetPSActDeact(atmsg, strlen(atmsg));
+}
+
+int at_rx_gprs_DefaultGPRS(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
diff --git a/vmodem/at/at_rx_gps.c b/vmodem/at/at_rx_gps.c
new file mode 100644 (file)
index 0000000..2a717dc
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <vgsm_phone.h>
+
+#include "phoneserver.h"
+#include "at_rx_func.h"
+#include "at_send.h"
+#include "at_recv.h"
+#include "at_rx_gps.h"
+
+static unsigned char g_gps_use_ssl;
+static unsigned char g_gps_agps_mode;
+
+int at_gps_rx_open(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_gps_rx_close(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_gps_rx_start(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_gps_xtra_set_xtra_enable(char* atmsg)
+{
+//     const unsigned char *p;
+
+//     p = atmsg[0];
+
+//     TRACE(MSGL_VGSM_INFO, "enabled = %d\n", p[0]);
+
+       return 1;
+}
+
+static int at_gps_agps_set_ssl_get(char* atmsg)
+{
+       unsigned char data[1];
+       int n = 0;
+
+       /* build the response */
+       data[n++] = g_gps_use_ssl;
+
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+       return 0;
+}
+
+static int at_gps_agps_set_ssl_set(char* atmsg)
+{
+/*     const unsigned char *p = atmsg;
+
+       if (strlen(atmsg) < 2)
+               TRACE(MSGL_WARN, "doc says this message should have 2 bytes\n");
+
+       g_gps_use_ssl = p[0];
+
+       TRACE(MSGL_VGSM_INFO, "use_ssl = %d\n", g_gps_use_ssl);
+
+       return at_gps_agps_set_ssl_get(atmsg);
+*/     return 1;
+}
+
+int at_gps_agps_set_ssl(char* atmsg)
+{
+/*
+       // set
+       return at_gps_agps_set_ssl_set(atmsg);
+       // get  
+       return at_gps_agps_set_ssl_get(atmsg);
+*/
+       return 0;
+}
+
+static int at_gps_agps_mode_get(char* atmsg)
+{
+       unsigned char data[1];
+       int n = 0;
+
+       /* build the response */
+       data[n++] = g_gps_agps_mode;
+
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+       return 0;
+}
+
+static int at_gps_agps_mode_set(char* atmsg)
+{
+//     const unsigned char *p = atmsg[0];
+
+//     g_gps_agps_mode = p[0];
+
+//     return at_gps_agps_mode_get(atmsg);
+       return 1;
+}
+
+int at_gps_agps_mode(char* atmsg)
+{
+/*
+       // set
+       return at_gps_agps_mode_set(atmsg);
+       // get
+       return at_gps_agps_mode_get(atmsg);
+*/     
+       return 0;
+}
diff --git a/vmodem/at/at_rx_misc.c b/vmodem/at/at_rx_misc.c
new file mode 100644 (file)
index 0000000..692a4de
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+
+#include <vgsm_phone.h>
+
+#include "phoneserver.h"
+#include "at_rx_func.h"
+#include "at_send.h"
+#include "at_recv.h"
+#include "oem_rx_misc.h"
+#include "at_rx_misc.h"
+#include "at_tx_misc.h"
+
+extern GSM_StateMachine GlobalS;
+
+int at_rx_misc_me_version(char* atmsg)
+{
+       unsigned char flags = 0x01;
+       return oem_rx_misc_me_version(flags);
+}
+
+int at_rx_misc_time_info_get(char* atmsg)
+{
+       struct timeval tv;
+       struct timezone tz;
+       struct tm tm;
+
+       gettimeofday(&tv, &tz);
+       gmtime_r(&tv.tv_sec, &tm);
+
+       return at_tx_misc_time_info(atmsg, &tm);
+}
+
+int at_RxMISC_DefaultMisc(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_rx_misc_me_serial(char* atmsg)
+{
+       int serial_num_index = 0;
+       const char *serial_num_data;
+       int serial_num_len;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       // IMEI
+       serial_num_data = "3520990017614823\r\n";
+       serial_num_len = strlen(serial_num_data);
+
+       return at_tx_misc_me_serial( serial_num_index, serial_num_data, serial_num_len );
+}
+
diff --git a/vmodem/at/at_rx_network.c b/vmodem/at/at_rx_network.c
new file mode 100644 (file)
index 0000000..840ffec
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_rx_network.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "vgsm_phone.h"
+#include "vgsm_network.h"
+#include "oem_rx_network.h"
+#include "at_rx_network.h"
+#include "linuxtapi.h"
+#include "phoneserver.h"
+#include "misc.h"
+#include "server_common_network.h"
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+int at_rx_net_default(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_rx_net_plmn_list_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return oem_rx_net_plmn_list_get();
+}
+
+int at_rx_net_current_plmn_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return oem_rx_net_current_plmn_get( );
+}
+
+int at_rx_net_reg_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return oem_rx_net_reg_get();
+}
+
+int at_rx_net_plmn_selection_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return oem_rx_net_plmn_selection_get();
+}
+
+int at_rx_net_plmn_selection_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+//     return oem_rx_net_plmn_selection_set(atmsg, strlen(atmsg));
+       return 0;
+}
+
+void at_cast_network_band_set(  unsigned char band_mode,  int net_band)
+{
+       LXT_MESSAGE packet;
+
+    TAPIMessageInit(&packet);
+
+       unsigned char data[5];
+       packet.data = data ;
+       packet.group  = GSM_NETWORK;
+       packet.action  = GSM_NETWORK_SET_BAND_REQ;
+       packet.length  = sizeof data;
+       data[0] = band_mode; //gsm_net_band_mode_e_type
+       data[1] = (net_band & 0xFF);
+       data[2] = ((net_band >> 8) & 0xFF);
+       data[3] = ((net_band >> 16) & 0xFF);
+       data[4] = ((net_band >> 24) & 0xFF);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+}
+
+int at_rx_net_band_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+//     return oem_rx_net_band_set(atmsg, strlen(atmsg));
+       return 0;
+}
+
+int at_rx_net_service_domain_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+//     set_network_service_domain(*(gsm_net_svc_domain_e_type*)atmsg[0] );
+       return 1;
+}
+
+int at_rx_net_mode_sel_set(char* atmsg)
+{
+       return oem_rx_net_mode_sel_set("TelTapiNwSetNetworkMode");
+}
+
+int at_rx_net_mode_sel_get(char* atmsg)
+{
+       return oem_rx_net_mode_sel_get("TelTapiNwGetNetworkMode");
+}
+
+int at_rx_net_pref_plmn_set(char* atmsg)
+{
+       return oem_rx_net_pref_plmn_set("TelTapiNwSetPreferredPlmn");
+}
+
+int at_rx_net_pref_plmn_get(char* atmsg)
+{
+       return oem_rx_net_pref_plmn_get("TelTapiNwGetPreferredPlmn");
+}
+
+int at_rx_net_service_domain_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       return oem_rx_net_service_domain_get();
+}
+
+int at_rx_net_band_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       return oem_rx_net_band_get( );
+}
+
+static const int max_net_subs_num_len = 40;
+static const int max_net_subs_alpha_len = 16;
+
+static int at_rx_add_subscriber_number( unsigned char *data, const char *number, const char *alpha)
+{
+       int len;
+       int n = 0;
+
+       len = strlen(number);
+       assert(len <= max_net_subs_num_len);
+       data[n++] = len;                // NUMBER_LEN
+       data[n++] = 0;                  // NUMBER_TYPE
+       memset(&data[n], 0, max_net_subs_num_len);
+       memcpy(&data[n], number, len);
+       n += max_net_subs_num_len;
+
+       len = strlen(alpha);
+       assert(len <= max_net_subs_alpha_len);
+       data[n++] = len;                        // ALPHA_LEN
+       memset(&data[n], 0, max_net_subs_alpha_len);
+       memcpy(&data[n], alpha, len);
+       n += max_net_subs_alpha_len;
+
+       return n;
+}
+
+int at_rx_net_subscriber_num_get(char* atmsg)
+{
+       const int number_count = 1;
+       unsigned char data[1 + (3 + max_net_subs_num_len + max_net_subs_alpha_len)*number_count];
+       unsigned char *p = data;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       char* number = SUBSCRIBER_NUM;
+       int n = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       p[n++] = 1;     // one number
+       n += at_rx_add_subscriber_number( &p[n], number, "");
+
+       sprintf(sndbuf, "%s,\"%s\",%d,,4%s", CNUM, number, p[2], CRLF); // p[2] = number type, 4 = voice service
+       assert(n <= sizeof data);
+
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
diff --git a/vmodem/at/at_rx_phonebook.c b/vmodem/at/at_rx_phonebook.c
new file mode 100644 (file)
index 0000000..5d9dc54
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "oem_rx_phonebook.h"
+#include "at_rx_phonebook.h"
+#include "at_recv.h"
+
+
+int at_rx_sim_pb_default(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+
+/*
+¿©·¯°³ÀÇ entry¸¦ get ÇϰԴ ¾ÈÇÏ°í ÇϳªÀÇ entry¸¸ get ÇÏ°Ô.. Áö±Ý ÇöÀ砸𵩠Äڵ尡 ±×·¡¼­..
+Phonebookµµ 2G feature ·Î ±¸Çö.. Áö±Ý ÇöÀ砸𵩠Äڵ尡 ±×·¡¼­..
+*/
+int at_rx_sim_pb_access(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 1;
+}
+
+
+int at_rx_sim_pb_get_storage_cnt(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return  1;
+}
+
+
+int at_rx_sim_pb_get_entry_info(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 0;
+}
+
+
+int at_rx_sim_pb_get_storage_list(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 0;
+}
+
+int at_rx_sim_pb_get_capability_info(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       return oem_rx_sim_pb_get_capability_info(atmsg, strlen(atmsg));
+}
+
diff --git a/vmodem/at/at_rx_power.c b/vmodem/at/at_rx_power.c
new file mode 100644 (file)
index 0000000..6837d79
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+
+// start here
+#include <string.h>
+#include "oem_rx_power.h"
+#include "at_rx_func.h"
+
+int at_RxPWR_DefaultPower(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_rx_power_up_exec(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "=== MODEM POWER ON REQUEST is Recevied ===\n");
+
+       return oem_rx_power_up_exec();
+}
+
+int at_rx_online_exec(char* atmsg)
+{
+       char* data = strchr(atmsg, '=');
+       int value = atoi(data+1);
+       TRACE(MSGL_VGSM_INFO, "=== MODEM ONLINE REQUEST is Recevied ===\n");
+       if( value == 0 ){
+               TRACE(MSGL_VGSM_INFO, "=== MODEM ONLINE OFF ===\n");
+       }else if( value == 1 ){
+               TRACE(MSGL_VGSM_INFO, "=== MODEM ONLINE ON ===\n");
+       }else if( value == 2 ){
+               TRACE(MSGL_VGSM_INFO, "=== MODEM ONLINE MAX ===\n");
+       }else{
+               TRACE(MSGL_VGSM_INFO, "=== MODEM ONLINE BUG ===\n");
+       }
+
+       return oem_rx_online_exec(value);
+}
+
+
diff --git a/vmodem/at/at_rx_sap.c b/vmodem/at/at_rx_sap.c
new file mode 100644 (file)
index 0000000..095aae7
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_msg.h"
+#include "oem_rx_gprs.h"
+#include "at_rx_sap.h"
+#include "at_recv.h"
+
+int at_rx_sap_Connect(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapConnectReq");
+
+       return 1;
+}
+
+
+int at_rx_sap_Status(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapConnectStatusReq");
+
+       return 1;
+}
+
+int at_rx_sap_transfer_atr(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapTransferAtrRequest");
+
+       return 1;
+}
+
+int at_rx_sap_transfer_apdu(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapTransferApdu");
+
+       return 1;
+}
+
+int at_rx_sap_transport_protocol(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapSetTransportProtocol");
+
+       return 1;
+}
+
+int at_rx_sap_sim_power(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapSetPower");
+
+       return 1;
+}
+
+int at_rx_sap_transfer_card_reader_status(char* atmsg)
+{
+       at_unimplemented("TelTapiSimSapCardReaderStatus");
+
+       return 1;
+}
+
+int at_rx_sap_DefaultSAP(char* atmsg)
+{
+       at_unimplemented("at_rx_sap_DefaultSAP");
+
+       return 1;
+}
diff --git a/vmodem/at/at_rx_sat.c b/vmodem/at/at_rx_sat.c
new file mode 100644 (file)
index 0000000..de011b2
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// at_rx_sat.c
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <vgsm_phone.h>
+
+#include "phoneserver.h"
+#include "at_send.h"
+#include "at_rx_func.h"
+#include "at_rx_sat.h"
+#include "at_tx_func.h"
+#include "at_recv.h"
+
+//! Proactive Commands Id
+#define SAT_CMD_REFRESH                                        0x01
+#define SAT_CMD_SETUP_EVENTLIST                        0x05
+#define SAT_CMD_SETUP_CALL                             0x10
+#define SAT_CMD_SEND_SS                                        0x11
+#define SAT_CMD_SEND_USSD                                      0x12
+#define SAT_CMD_SEND_SHORT_MESSAGE             0x13
+#define SAT_CMD_SEND_DTMF                                      0x14
+#define SAT_CMD_LAUNCH_BROWSER                 0x15
+#define SAT_CMD_PLAY_TONE                                      0x20
+#define SAT_CMD_DISPLAY_TEXT                           0x21
+#define SAT_CMD_GET_INKEY                                      0x22
+#define SAT_CMD_GET_INPUT                                      0x23
+#define SAT_CMD_SELECT_ITEM                            0x24
+#define SAT_CMD_SETUP_MENU                             0x25
+#define SAT_CMD_SETUP_IDLE_MODE_TEXT           0x28
+#define SAT_CMD_RUN_AT_COMMAND                 0x34
+#define SAT_CMD_OPEN_CHANNEL                           0x40
+#define SAT_CMD_CLOSE_CHANNEL                          0x41
+#define SAT_CMD_RECEIVE_DATA                           0x42
+#define SAT_CMD_SEND_DATA                                      0x43
+
+//envelope
+#define SAT_CMD_MENU_SELECTION                 0xd3
+
+int at_rx_sat_envelope_cmd(char* atmsg)
+{
+       at_unimplemented("TelTapiSatMenuSelectionEnvelope or TelTapiSatEventDownloadEnvelope");
+       return 1;
+}
+
+int at_rx_sat_proactive_cmd(char* atmsg)
+{
+       at_unimplemented("TelTapiSatGetSendUiDispalyStatus or TelTapiSatGetSendUiUserConfirm or TelTapiSatSendAppEcecutionResult");
+       return 1;
+}
+
+int at_RxSAT_DefaultSAT(char* atmsg)
+{
+       return -1;
+}
+
+
+int at_RxSAT_TerminalResponse(char* atmsg)
+{
+       unsigned char *p_rcv= 0;
+       unsigned char *tmp      = 0;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+       char CmdId;
+       int data_size;
+       unsigned char *pdata = 0;
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 1;
+}
+
+
+//RxSAT_TerminalResponse
+int at_RxSAT_EnvelopeResponse(char* atmsg)
+{
+       unsigned char *p_rcv_term = 0;
+       unsigned char *tmp = 0;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       unsigned char CmdId;
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 1;
+}
+
+
+int at_RxSAT_ResProfileDownload(char* atmsg)
+{
+//     TxGCMD_SendGeneralResponse(atmsg);
+       return 1;
+
+}
+
diff --git a/vmodem/at/at_rx_security.c b/vmodem/at/at_rx_security.c
new file mode 100644 (file)
index 0000000..88eb6a0
--- /dev/null
@@ -0,0 +1,626 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "oem_rx_security.h"
+#include "oem_tx_security.h"
+#include "at_rx_security.h"
+#include "at_tx_security.h"
+#include "server_rx_security.h"
+#include "at_gen_resp.h"
+#include "vgsm_sim.h"
+#include "at_func.h"
+#include "server_common.h"
+
+int at_rx_sim_sec_imsi(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+
+       return oem_rx_sim_sec_get_imsi_req(atmsg, strlen(atmsg));
+}
+
+
+int at_rx_sim_sec_pin_status(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+       return -1;
+}
+
+
+int at_rx_sim_sec_lock_info(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+
+       return oem_rx_sim_sec_get_lock_info_req(atmsg, strlen(atmsg));
+}
+
+
+int at_rx_sim_sec_change_password(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+
+       return oem_rx_sim_sec_change_password_req(atmsg, strlen(atmsg));
+}
+
+
+static int at_rx_sim_sec_set_phone_lock_req(void* ptr_data, int data_len)
+{
+       unsigned char *p = ptr_data;
+       int pb_mode = p[0];
+
+       TRACE(MSGL_VGSM_INFO, "%d\n", pb_mode);
+       switch (pb_mode)
+       {
+               case 0x00:      //TAPI_SIM_LOCK_MODE_UNLOCK:
+                       TRACE(MSGL_WARN, "TAPI_SIM_LOCK_MODE_UNLOCK not implemented\n");
+                       assert(0);
+                       break;
+
+               case 0x01:      //TAPI_SIM_LOCK_MODE_LOCK:
+                       TRACE(MSGL_WARN, "TAPI_SIM_LOCK_MODE_LOCK not implemented\n");
+                       assert(0);
+                       break;
+
+               default:
+                       return server_rx_sim_sec_set_phone_lock_req(ptr_data, data_len);
+       }
+
+       return -1;
+}
+
+
+int at_rx_sim_sec_phone_lock(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+/*
+       // get
+       oem_rx_sim_sec_get_phone_lock_req(atmsg, strlen(atmsg));
+       // set
+       at_rx_sim_sec_set_phone_lock_req(atmsg, strlen(atmsg));
+*/
+       return -1;
+}
+
+int at_rx_sim_sec_phone_lock_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+       unsigned char lock_type;
+       char* origPwd = get_callbarring_pwd();
+       lock_type = 0;  // 0: not active, 1: active
+
+       char* data = strchr(atmsg, '=');
+        char* ret = NULL;
+
+        ret = strtok(data+1, TOKEN);
+       
+       char token[] = "\"";
+        ret = strtok(NULL, token);
+       ret = strtok(NULL, token);
+       TRACE(MSGL_VGSM_SIM, "input pw:%s, orig pw:%s\n", ret, origPwd);
+       if(ret)
+       {
+               if( !strcmp(ret, origPwd) )
+                       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+               else 
+                       return at_gen_resp_send(AT_CME_ERR_INCORRECT_PWD);
+       }
+       else
+               return at_tx_sim_sec_phone_lock_resp(lock_type);
+}
+
+const unsigned char at_g_gsm_efile_usim_li_info[] = {
+        //0x90, 0x00, 0x1e,     // SW1, SW2, LENGTH
+        0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83, 0x02,
+        0x6f, 0x05, 0xa5, 0x03, 0xda, 0x01, 0x06, 0x8a,
+        0x01, 0x05, 0x8b, 0x03, 0x6f, 0x06, 0x05, 0x80,
+        0x02, 0x00, 0x08, 0x88, 0x01, 0x10,
+};
+
+const unsigned char at_g_gsm_efile_ecc_info[] = {
+        //0x90, 0x00, 0x21,     //SW1, SW2, LENGTH
+        0x62, 0x1f, 0x82, 0x05, 0x42, 0x21, 0x00, 0x14,
+        0x05, 0x83, 0x02, 0x6f, 0xb7, 0xa5, 0x03, 0xda,
+        0x01, 0x04, 0x8a, 0x01, 0x05, 0x8b, 0x03, 0x6f,
+        0x06, 0x0d, 0x80, 0x02, 0x00, 0x64, 0x88, 0x01,
+        0x08,
+};
+
+const unsigned char at_g_gsm_efile_sst_info[] = {
+       //0x90, 0x00, 0x1e,
+       0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83, 0x02,
+       0x6f, 0x38, 0xa5, 0x03, 0xda, 0x01, 0x04, 0x8a,
+       0x01, 0x05, 0x8b, 0x03, 0x6f, 0x06, 0x08, 0x80,
+       0x02, 0x00, 0x07, 0x88, 0x01, 0x20,
+};
+
+const unsigned char at_g_gsm_efile_est_info[] = {
+       //0x90, 0x00, 0x1e,
+       0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83, 0x02,
+       0x6f, 0x56, 0xa5, 0x03, 0xda, 0x01, 0x04, 0x8a,
+       0x01, 0x05, 0x8b, 0x03, 0x6f, 0x06, 0x07, 0x80,
+       0x02, 0x00, 0x01, 0x88, 0x01, 0x28,
+};
+
+const unsigned char at_g_gsm_efile_spn_info[] = {
+       //0x90, 0x00, 0x27,
+       0x62, 0x25, 0x82, 0x02, 0x41, 0x21, 0x83, 0x02,
+       0x6f, 0x46, 0xa5, 0x06, 0x80, 0x01, 0x31, 0xc0,
+       0x01, 0x00, 0x8a, 0x01, 0x05, 0x8b, 0x06, 0x6f,
+       0x06, 0x01, 0x06, 0x00, 0x06, 0x80, 0x02, 0x00, 
+       0x11, 0x81, 0x02, 0x00, 0x25, 0x88, 0x00 
+};
+
+const unsigned char at_g_gsm_efile_imsi_info[] = {
+        //0x90, 0x00, 0x28,
+        0x62, 0x26, 0x82, 0x02, 0x41, 0x21, 0x83, 0x02,
+        0x6f, 0x07, 0xa5, 0x06, 0x80, 0x01, 0x31, 0xc0,
+        0x01, 0x00, 0x8a, 0x01, 0x05, 0x8b, 0x06, 0x6f,
+        0x06, 0x01, 0x04, 0x00, 0x04, 0x80, 0x02, 0x00,
+        0x09, 0x81, 0x02, 0x00, 0x1d, 0x88, 0x01, 0x38,
+};
+
+const unsigned char at_g_gsm_efile_spdi_info[] = {
+       0x62, 0x26, 0x82, 0x02, 0x01, 0x21, 0x83, 0x02,
+       0x6f, 0xcd, 0xa5, 0x06, 0x80, 0x01, 0x31, 0xc0,
+       0x01, 0x00, 0x8a, 0x01, 0x05, 0x8b, 0x06, 0x6f,
+       0x06, 0x01, 0x04, 0x00, 0x04, 0x80, 0x02, 0x00,
+       0x40, 0x81, 0x02, 0x00, 0x54, 0x88, 0x01, 0xd8,
+};
+
+const unsigned char at_g_gsm_efile_opl_info[] = {
+       0x62, 0x29, 0x82, 0x05, 0x02, 0x21, 0x00, 0x08,
+       0x14, 0x83, 0x02, 0x6f, 0xc6, 0xa5, 0x06, 0x80,
+       0x01, 0x31, 0xc0, 0x01, 0x00, 0x8a, 0x01, 0x05,
+       0x8b, 0x06, 0x6f, 0x06, 0x01, 0x06, 0x00, 0x06,
+       0x80, 0x02, 0x00, 0xa0, 0x81, 0x02, 0x00, 0xb4,
+       0x88, 0x01, 0xd0,
+};
+
+const unsigned char at_g_gsm_efile_cfis_info[] = {
+       0x62, 0x28, 0x82, 0x05, 0x02, 0x21, 0x00, 0x10,
+       0x01, 0x83, 0x02, 0x6f, 0xcb, 0xa5, 0x06, 0x80,
+       0x01, 0x31, 0xc0, 0x01, 0x00, 0x8a, 0x01, 0x05,
+       0x8b, 0x06, 0x6f, 0x06, 0x01, 0x03, 0x00, 0x03,
+       0x80, 0x02, 0x00, 0x10, 0x81, 0x02, 0x00, 0x24,
+       0x88, 0x00,
+};
+
+const unsigned char at_g_gsm_efile_pnn_info[] = {
+       0x62, 0x29, 0x82, 0x05, 0x02, 0x21, 0x00, 0x22,
+       0x02, 0x83, 0x02, 0x6f, 0xc5, 0xa5, 0x06, 0x80,
+       0x01, 0x31, 0xc0, 0x01, 0x00, 0x8a, 0x01, 0x05,
+       0x8b, 0x06, 0x6f, 0x06, 0x01, 0x06, 0x00, 0x06,
+       0x80, 0x02, 0x00, 0x44, 0x81, 0x02, 0x00, 0x58,
+       0x88, 0x01, 0xc8,
+};
+
+const unsigned char at_g_gsm_efile_smsp_info[] = {
+       0x62, 0x19, 0x82, 0x05, 0x42, 0x21, 0x00, 0x28,
+       0x02, 0x83, 0x02, 0x6f, 0x42, 0x8a, 0x01, 0x05,
+       0x8b, 0x03, 0x6f, 0x06, 0x03, 0x80, 0x02, 0x00,
+       0x50, 0x88, 0x00,
+};
+
+static const char* get_sim_filename(gsm_sec_sim_file_id_t file_id)
+{
+       switch (file_id)
+       {
+#define X(id) case GSM_SEC_EFILE_##id: return #id;
+               X(USIM_LI)
+                       X(ECC)
+                       X(SST)
+                       X(EST)
+                       X(CPHS_CPHS_INFO)
+                       X(SPN)
+                       X(IMSI)
+                       X(ICCID)
+                       X(SPDI)
+                       X(CPHS_CFIS)
+                       X(OPL)
+                       X(PNN)
+#undef X
+               default:
+                       return "unknown";
+       }
+}
+
+static const unsigned char* sim_get_file_info(gsm_sec_sim_file_id_t file_id, unsigned char *file_info_len)
+{
+       const unsigned char *data;
+       unsigned char len;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       switch (file_id)
+       {
+               case GSM_SEC_EFILE_USIM_LI :
+                       data = at_g_gsm_efile_usim_li_info;
+                       len = sizeof at_g_gsm_efile_usim_li_info;
+                       break;
+
+               case GSM_SEC_EFILE_ECC :
+                       data = at_g_gsm_efile_ecc_info;
+                       len = sizeof at_g_gsm_efile_ecc_info;
+                       break;
+
+               case GSM_SEC_EFILE_SST :
+                       data = at_g_gsm_efile_sst_info;
+                       len = sizeof at_g_gsm_efile_sst_info;
+                       break;
+
+               case GSM_SEC_EFILE_EST :
+                       data = at_g_gsm_efile_est_info;
+                       len = sizeof at_g_gsm_efile_est_info;
+                       break;
+
+               case GSM_SEC_EFILE_SPN :
+                       data = at_g_gsm_efile_spn_info;
+                       len = sizeof at_g_gsm_efile_spn_info;
+                       break;
+
+               case GSM_SEC_EFILE_IMSI :
+                       data = at_g_gsm_efile_imsi_info;
+                       len = sizeof at_g_gsm_efile_imsi_info;
+                       break;
+
+               case GSM_SEC_EFILE_SPDI :
+                       data = at_g_gsm_efile_spdi_info;
+                       len = sizeof at_g_gsm_efile_spdi_info;
+                       break;
+
+               case GSM_SEC_EFILE_OPL :
+                       data = at_g_gsm_efile_opl_info;
+                       len = sizeof at_g_gsm_efile_opl_info;
+                       break;
+
+               case GSM_SEC_EFILE_CPHS_CFIS :
+                       data = at_g_gsm_efile_cfis_info;
+                       len = sizeof at_g_gsm_efile_cfis_info;
+                       break;
+
+               case GSM_SEC_EFILE_PNN :
+                       data = at_g_gsm_efile_pnn_info;
+                       len = sizeof at_g_gsm_efile_pnn_info;
+                       break;
+
+               case GSM_SEC_EFILE_SMSP :
+                       data = at_g_gsm_efile_smsp_info;
+                       len = sizeof at_g_gsm_efile_smsp_info;
+                       break;
+
+               case GSM_SEC_EFILE_CPHS_CPHS_INFO :
+               case GSM_SEC_EFILE_ICCID :
+               default:
+                       TRACE(MSGL_VGSM_INFO, "Not handled file id =[%x] \n", file_id);
+                       len = 0;
+                       return 0;
+       }
+
+       *file_info_len = len;
+
+       return data;
+}
+
+const unsigned char at_g_gsm_efile_icd_data[] = {
+       //0x90, 0x00, 0x0a,
+       0x98, 0x94, 0x22, 0x06, 0x45, 0x61, 0x53, 0x49,
+       0x38, 0xf6,
+};
+
+const unsigned char at_g_gsm_efile_usim_li_data[] = {
+       //0x90, 0x00, 0x08,
+       0x65, 0x6e, 0x65, 0x6e, 0x65, 0x6e, 0x64, 0x65
+};
+
+const unsigned char at_g_gsm_efile_ecc_data[] = {
+       //0x90, 0x00, 0x14,
+       0x11, 0xf2, 0xff, 0x4e, 0x6f, 0x74, 0x72, 0x75,
+       0x66, 0x20, 0x46, 0x65, 0x75, 0x65, 0x72, 0x77,
+       0x65, 0x68, 0x72, 0x00
+};
+
+const unsigned char at_g_gsm_efile_sst_data[] = {
+       //0x90, 0x00, 0x07,
+       0x9e, 0xdf, 0xb7, 0x1d, 0xe7, 0xfe, 0x07
+};
+
+const unsigned char at_g_gsm_efile_est_data[] = {
+       //0x90, 0x00, 0x01,
+       0x00
+};
+
+const unsigned char at_g_gsm_efile_spn_data[] = {
+       //0x90, 0x00, 0x11,
+       0x01, 0x54, 0x49, 0x5a, 0x45, 0x4e, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff
+};
+/*
+const unsigned char at_g_gsm_efile_imsi_data[] = {
+       //0x90, 0x00, 0x09,
+       0x08, 0x19, 0x11, 0x11, 0x30, 0x00, 0x61, 0x56,
+       0x26
+};
+*/
+
+const unsigned char at_g_gsm_efile_imsi_data[] = {
+        //0x90, 0x00, 0x09,
+        0x08, 0x19, 0x11, 0x11, 0x30, 0x01, 0x61, 0x56,
+        0x26
+};
+
+const unsigned char at_g_gsm_efile_spdi_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+const unsigned char at_g_gsm_efile_opl_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+const unsigned char at_g_gsm_efile_cfis_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+const unsigned char at_g_gsm_efile_pnn_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff,
+};
+
+const unsigned char at_g_gsm_efile_smsp1_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xe9, 0xff, 0xff, 0xff,
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       0xff, 0x07, 0x91, 0x44, 0x97, 0x37, 0x01, 0x90,
+       0x37, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+};
+
+const unsigned char at_g_gsm_efile_smsp2_data[] = {
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
+
+static const unsigned char* sim_get_file_data(gsm_sec_sim_file_id_t file_id, unsigned char* file_data_len)
+{
+       const unsigned char *data;
+       unsigned char len;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       switch (file_id)
+       {
+               case GSM_SEC_EFILE_ICCID :
+                       data = at_g_gsm_efile_icd_data;
+                       len = sizeof at_g_gsm_efile_icd_data;
+                       break;
+
+               case GSM_SEC_EFILE_USIM_LI :
+                       data = at_g_gsm_efile_usim_li_data;
+                       len = sizeof at_g_gsm_efile_usim_li_data;
+                       break;
+
+               case GSM_SEC_EFILE_ECC :
+                       data = at_g_gsm_efile_ecc_data;
+                       len = sizeof at_g_gsm_efile_ecc_data;
+                       break;
+
+               case GSM_SEC_EFILE_SST :
+                       data = at_g_gsm_efile_sst_data;
+                       len = sizeof at_g_gsm_efile_sst_data;
+                       break;
+
+               case GSM_SEC_EFILE_EST :
+                       data = at_g_gsm_efile_est_data;
+                       len = sizeof at_g_gsm_efile_est_data;
+                       break;
+
+               case GSM_SEC_EFILE_SPN :
+                       data = at_g_gsm_efile_spn_data;
+                       len = sizeof at_g_gsm_efile_spn_data;
+                       break;
+
+               case GSM_SEC_EFILE_IMSI :
+                       data = at_g_gsm_efile_imsi_data;
+                       len = sizeof at_g_gsm_efile_imsi_data;
+                       break;
+
+               case GSM_SEC_EFILE_SPDI :
+                       data = at_g_gsm_efile_spdi_data;
+                       len = sizeof at_g_gsm_efile_spdi_data;
+                       break;
+
+               case GSM_SEC_EFILE_OPL :
+                       data = at_g_gsm_efile_opl_data;
+                       len = sizeof at_g_gsm_efile_opl_data;
+                       break;
+
+               case GSM_SEC_EFILE_CPHS_CFIS :
+                       data = at_g_gsm_efile_cfis_data;
+                       len = sizeof at_g_gsm_efile_cfis_data;
+                       break;
+
+               case GSM_SEC_EFILE_PNN :
+                       data = at_g_gsm_efile_pnn_data;
+                       len = sizeof at_g_gsm_efile_pnn_data;
+                       break;
+
+               case GSM_SEC_EFILE_CPHS_CPHS_INFO :
+               default:
+                       TRACE(MSGL_VGSM_INFO, "unhandled file id =[%x] \n", file_id);
+                       len = 0;
+                       return 0;
+       }
+
+       *file_data_len = len;
+
+       return data;
+}
+
+static int at_rx_sim_sec_get_rsim_access_req(char* atmsg)
+{
+       unsigned char len = 0;
+       unsigned char access_cmd = 0x00;
+       unsigned short file_id = 0;
+       unsigned char data[0x103];
+       char cdata[SEND_BUF_SIZE];
+       memset(cdata, '\0', sizeof(cdata));
+       const unsigned char *ptr = 0;
+        strcpy(cdata, atmsg);
+       char* tdata = strchr(cdata, '=');
+        char* ret = NULL;
+       int n = 0, p1 = 0;
+
+        ret = strtok(tdata+1, TOKEN);
+        if(ret)
+               access_cmd = atoi(ret);
+
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+               file_id = atoi(ret);
+
+       ret = strtok(NULL, TOKEN);
+       if(ret)
+       {
+               p1 = atoi(ret);
+               if(p1 == 1)
+               {
+                       ptr = at_rx_sms_param_get(&len);
+                       TRACE(MSGL_VGSM_INFO, "len:%02x\n", len);
+               }
+               else if(p1 == 2)
+               {
+                       ptr = at_g_gsm_efile_smsp2_data;
+                        len = sizeof at_g_gsm_efile_smsp2_data; 
+               }
+       }
+       else 
+       {
+               TRACE(MSGL_VGSM_INFO, "access type [%02x] file id [%x] (%s)\n", access_cmd, file_id, get_sim_filename(file_id));
+
+               switch (access_cmd)
+               {
+               case GSM_SEC_SIM_ACC_GET_RESPONSE:
+                       ptr = sim_get_file_info(file_id, &len);
+                       break;
+
+               case GSM_SEC_SIM_ACC_READ_BINARY:
+               case GSM_SEC_SIM_ACC_READ_RECORD:
+                       ptr = sim_get_file_data(file_id, &len);
+                       break;
+
+               case GSM_SEC_SIM_ACC_UPDATE_RECORD:
+               case GSM_SEC_SIM_ACC_STATUS:
+                       return at_gen_resp_send( AT_GEN_ERR_OPER_NOT_SUPPORTED);
+
+               default:
+                       TRACE(MSGL_VGSM_INFO, "Not handled access_type [%02x]\n", access_cmd);
+                       assert(0);
+                       break;
+               }
+       }
+       memset(data, '\0', sizeof(data));
+
+       if (ptr)
+       {
+               // found
+               data[n++] = 0x90;
+               data[n++] = 0;
+       
+               int hexaStringSize = (len * 2) + 1;     
+               char* hexaStringP = malloc(hexaStringSize);
+
+               TRACE(MSGL_VGSM_INFO, "hexaStringSize:%d\n", hexaStringSize);
+
+               memset(hexaStringP, '\0', hexaStringSize);
+       
+               prv_bytes_to_hexadecimal_string(ptr, len, hexaStringP, &hexaStringSize);
+       
+               strcat((char*)&data[n], hexaStringP);
+               
+               len = hexaStringSize;
+               n += len;
+
+               if(hexaStringP)
+                       free(hexaStringP);
+       }
+       else
+       {
+               // not found
+               data[n++] = 0x6a;
+               data[n++] = 0x82;
+               data[n++] = len;
+
+               TRACE(MSGL_WARN, "file not found [%04x]\n", file_id);
+       }
+
+       assert(n <= sizeof data);
+
+       at_tx_sim_sec_get_rsim_access_res(data, len);
+
+       if ( file_id == GSM_SEC_EFILE_USIM_LI &&
+                       (access_cmd == GSM_SEC_SIM_ACC_READ_BINARY || access_cmd == GSM_SEC_SIM_ACC_READ_RECORD) )
+       {
+               TRACE(MSGL_VGSM_INFO, "LI read case!\n");
+
+               char pdata[2];
+               pdata[0]        =       GSM_SEC_SIM_INIT_COMPLETED;
+               pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+
+               oem_tx_sim_sec_pin_status_noti(pdata, 2);
+
+               server_common_after_sim_init();
+       }
+
+       return 1;
+}
+
+int at_rx_sim_sec_rsim_access(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+       return at_rx_sim_sec_get_rsim_access_req(atmsg);
+}
+
+int at_rx_sim_sec_card_type(char* atmsg)
+{
+       TRACE(MSGL_VGSM_SIM, "\n");
+       return at_tx_sim_sec_card_type_resp(GSM_SEC_USIM);
+}
+
diff --git a/vmodem/at/at_rx_sms.c b/vmodem/at/at_rx_sms.c
new file mode 100644 (file)
index 0000000..b2bc0cc
--- /dev/null
@@ -0,0 +1,613 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "at_msg.h"
+#include "oem_rx_sms.h"
+#include "at_rx_sms.h"
+#include "at_tx_sms.h"
+#include "at_tx_func.h"
+#include "at_func.h"
+
+/* temporarily vconf setup */
+//#define SMS_PARAM_SET_VCONF 
+#ifdef SMS_PARAM_SET_VCONF
+#include <vconf/vconf.h>
+#include <vconf/vconf-keys.h>
+int sms_param_set_vconf();
+#endif
+
+#define SMS_ERROR_OK   0x0000
+
+#define PARAM_RECORD_COUNT     1
+/* Maximum number of bytes SMSP Record size (Y + 28), y : 0 ~ 128 */
+/* #define MAX_GSM_SMS_PARAM_RECORD_SIZE       156  */
+#define PARAM_RECORD_LEN_MAX   156
+static unsigned char g_record_len = 0;
+static unsigned char g_record[PARAM_RECORD_LEN_MAX];
+
+#define CB_MAX_SELECTED_IDS 0xff
+static unsigned char g_cb_enabled = 1;      /* enabled */
+static unsigned char g_cb_selected_id = 1;  /* all selected */
+static unsigned char g_cb_selected_count = 0;  /* number of selected ids */
+static const unsigned char g_cb_max_selected_ids = CB_MAX_SELECTED_IDS;
+static unsigned short g_cb_selected_list[CB_MAX_SELECTED_IDS];  /* number of selected ids */
+
+int at_rx_sms_SendMsg(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "%s\n", atmsg);
+       char smsdata[8 * 1024];
+       char tmpmsg[8 * 1024];
+
+       memset(tmpmsg, '\0', 8 * 1024);
+       memcpy(tmpmsg, atmsg, strlen(atmsg));
+       
+       char* tdata = strchr(tmpmsg, '=');
+       char token[] = "\r";
+        char* ret = NULL;
+       int data_len = 0;
+       int start_index = 0;
+       int pdu_len = 0;        
+       ret = strtok(tdata+1, token);
+        if(ret)
+               pdu_len = atoi(ret); 
+        else
+                return 0;
+       
+       start_index = strlen(CMGS) + strlen(ret) + strlen(token);
+
+       smsdata[0] = 0x02;              // network type gsm
+       smsdata[1] = 0x02;              // MORETOSEND field     
+       
+       char byteStringBuf[SEND_BUF_SIZE];
+       memset(byteStringBuf, '\0', SEND_BUF_SIZE);
+
+       int byteStrLen = hexStringToBytes(byteStringBuf, &atmsg[start_index]);  
+       smsdata[2] = (char)byteStrLen;     // pdu length
+       data_len = byteStrLen + pdu_len;
+
+       TRACE(MSGL_VGSM_INFO, "byteStrLen:%d\n", byteStrLen);
+       memcpy(&smsdata[3], byteStringBuf, byteStrLen);
+       
+       return oem_rx_sms_SendMsg(smsdata, data_len);
+}
+
+int at_rx_sms_deliver_report_exec(char* atmsg)
+{
+       return at_tx_sms_deliver_report_noti(SMS_ERROR_OK);
+}
+
+int at_rx_sms_DR(char* atmsg)
+{
+//     return oem_rx_sms_DR(atmsg, strlen(atmsg));
+       return 0;
+}
+
+int at_rx_sms_SCA(char* atmsg)
+{
+
+/*     
+       // set
+       oem_rx_sms_SCA_set("TelTapiSmsSetSCA");
+       
+       // get
+       oem_rx_sms_SCA(atmsg, strlen(atmsg));
+
+*/     return -1;
+}
+
+int at_rx_sms_DefaultSms(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       return -1;
+}
+
+static int at_rx_sms_cbconfig_get(char* atmsg)
+{
+       return at_tx_sms_cbconfig_resp(g_cb_enabled, g_cb_selected_id
+                       , g_cb_max_selected_ids, g_cb_selected_count, g_cb_selected_list);
+}
+
+static int at_rx_sms_cbconfig_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 0;
+}
+
+int at_rx_sms_cbconfig(char* atmsg)
+{
+/*
+       // set
+       at_rx_sms_cbconfig_set(atmsg);
+       
+       // get
+       at_rx_sms_cbconfig_get(atmsg);
+*/
+       return -1;
+}
+
+unsigned char at_g_sms_service_option= 0x02; // CS_ONLY
+
+int at_rx_sms_param(char* atmsg)
+{
+       return -1;
+}
+
+int at_rx_sms_stored_msg_status(char* atmsg)
+{
+       return oem_rx_sms_stored_msg_status("TelTapiSmsSetMessageStatus");
+}
+
+int at_rx_sms_mem_status_set(char* atmsg)
+{
+       return 1;
+}
+
+static void at_rx_sms_param_init()
+{
+       int i, n = 0;
+
+       //Alpha-Id
+       g_record[n++] = '1';
+       g_record[n++] = '2';
+       g_record[n++] = '3';        
+       g_record[n++] = '4';
+       g_record[n++] = '5';
+       for(i=0; i<(24-5);i++){   
+               g_record[n++] = 0x00;   
+       }   
+
+       // parameter indicator
+       g_record[n++] = 0xe9;  
+
+       // TP-Destination Addr.
+       for(i=0; i<12;i++){   
+               g_record[n++] = 0xff;   
+       }   
+
+       //TP-SC addr. // this is raw g_record. +8210911111
+       g_record[n++] = 0x06;   
+       g_record[n++] = 0x91;   
+       g_record[n++] = 0x28;    
+       g_record[n++] = 0x01;    
+       g_record[n++] = 0x19;
+       g_record[n++] = 0x11;
+       g_record[n++] = 0x11;
+       g_record[n++] = 0xff;
+       g_record[n++] = 0xff;
+       g_record[n++] = 0xff;
+       g_record[n++] = 0xff;
+       g_record[n++] = 0xff;
+
+       //PID
+       g_record[n++] = 0x01;
+
+       //DCS
+       g_record[n++] = 0xff;
+
+       //VP
+       g_record[n++] = 0x00;
+
+       /* init end */
+       /* 52 = (24+1+12+12+3), (=apha id + TP DA+...) */
+       g_record_len = 52;
+
+       return;
+}
+
+int at_rx_sms_param_count_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 0;
+}
+
+int at_rx_sms_param_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 1;
+}
+
+unsigned char* at_rx_sms_param_get(unsigned char* len)
+{
+       TRACE(MSGL_VGSM_INFO, "g_record_len:0x%02x\n", g_record_len);
+
+       if(g_record_len == 0)
+       {
+               at_rx_sms_param_init();
+       }
+       
+       *len = g_record_len;
+
+       return g_record;
+}
+
+int at_rx_sms_stored_msg_count_get(char* atmsg)
+{
+       return at_tx_sms_stored_msg_count_resp();
+}
+
+int at_rx_sms_svc_option_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented!\n");
+       return 1;
+}
+
+
+#ifdef SMS_PARAM_SET_VCONF
+
+/* reference */
+/* - libslp-tapi/include/common/TelNetText.h */
+/* - msg-service/plugin/sms_plugin/SmsPluginSetting.cpp */
+
+#define SMSC_NAME_MAX                                          127
+#define TAPI_NETTEXT_SMSP_PARAMS_MAX_LEN       28
+#define TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX         128
+
+#define SMSPValidDestAddr                              0x01
+#define SMSPValidSvcAddr                               0x02
+#define SMSPValidPID                                   0x04
+#define SMSPValidDCS                                   0x08
+#define SMSPValidVP                                    0x10
+
+#define nDestAddrOffset                                1
+#define nSCAAddrOffset                                 13
+#define nPIDOffset                                     25
+#define nDCSOffset                                     26
+#define nVPOffset                                      27
+
+#define TAPI_SIM_SMSP_ADDRESS_LEN                      20
+#define MAX_GSM_SMS_PARAM_RECORD_SIZE       156 
+
+
+/* msg-service/include/common/MsgSettingTypes.h */
+enum  _MSG_SMS_PID_E
+{
+       MSG_PID_NONE,       /**< None */
+       MSG_PID_TEXT,       /**< Text */
+       MSG_PID_VOICE,      /**< Voice */
+       MSG_PID_FAX,        /**< Fax */
+       MSG_PID_X400,       /**< X400 */
+       MSG_PID_ERMES,      /**< Ermes */
+       MSG_PID_EMAIL,      /**< Email */
+       MSG_PID_MAX     /**< Default */
+};          
+
+/* msg-service/plugin/sms_plugin/include/SmsPluginTypes.h */
+enum _SMS_TON_E
+{ 
+       SMS_TON_UNKNOWN = 0,        /* unknown */
+       SMS_TON_INTERNATIONAL,  /* international */
+       SMS_TON_NATIONAL,           /* national */
+       SMS_TON_NETWORK,            /* network */
+       SMS_TON_SUBSCRIBER,     /* subscriber */
+       SMS_TON_ALPHANUMERIC,       /* alpha numberic */
+       SMS_TON_ABBREVIATED,        /* abbreviated */
+       SMS_TON_RESERVE,            /* reserve */
+};
+
+/* msg-service/plugin/sms_plugin/include/SmsPluginTypes.h */
+enum _SMS_PID_E
+{
+       SMS_PID_NORMAL = 0x00,
+
+       SMS_PID_TELEX = 0x21,       
+       SMS_PID_GROUP3_TELEX = 0x22,
+       SMS_PID_GROUP4_TELEX = 0x23,
+       SMS_PID_VOICE = 0x24,
+       SMS_PID_ERMES = 0x25,
+       SMS_PID_NPS = 0x26,
+       SMS_PID_VIDEO = 0x27, 
+       SMS_PID_TELETEX_UNSPEC = 0x28,
+       SMS_PID_TELETEX_PSPDN = 0x29,
+       SMS_PID_TELETEX_CSPDN = 0x2A,
+       SMS_PID_TELETEX_PSTN = 0x2B,
+       SMS_PID_TELETEX_ISDN = 0x2C,
+       SMS_PID_UCI = 0x2D,
+       SMS_PID_x400 = 0x31,
+       SMS_PID_EMAIL = 0x32,
+
+       SMS_PID_TYPE0 = 0x40,
+       SMS_PID_REPLACE_TYPE1 = 0x41,
+       SMS_PID_REPLACE_TYPE2 = 0x42,
+       SMS_PID_REPLACE_TYPE3 = 0x43,
+       SMS_PID_REPLACE_TYPE4 = 0x44,
+       SMS_PID_REPLACE_TYPE5 = 0x45,
+       SMS_PID_REPLACE_TYPE6 = 0x46,
+       SMS_PID_REPLACE_TYPE7 = 0x47,
+
+       SMS_PID_RETURN_CALL = 0x5F,
+};
+
+typedef unsigned char SMS_PID_T;
+typedef unsigned char MSG_SMS_PID_T;
+
+/* msg-service/include/common/MsgInternalTypes.h */
+#define DEFAULT_SETTING_PATH        "db/msg"
+#define DEFAULT_SMSC_INFO_PATH      DEFAULT_SETTING_PATH"/smsc"
+
+#define SMSC_NAME                   DEFAULT_SMSC_INFO_PATH"/name"
+#define SMSC_ADDRESS                DEFAULT_SMSC_INFO_PATH"/address"
+#define SMSC_TON                    DEFAULT_SMSC_INFO_PATH"/ton"
+#define SMSC_NPI                    DEFAULT_SMSC_INFO_PATH"/npi"
+#define SMSC_PID                    DEFAULT_SMSC_INFO_PATH"/pid"
+#define SMSC_VAL_PERIOD             DEFAULT_SMSC_INFO_PATH"/val_period"
+
+static MSG_SMS_PID_T convertPid(SMS_PID_T pid)
+{
+       MSG_SMS_PID_T retPid;
+
+       switch (pid) {   
+               case SMS_PID_NORMAL:
+                       retPid = MSG_PID_TEXT;
+                       break;  
+               case SMS_PID_VOICE:
+                       retPid = MSG_PID_VOICE;
+                       break;  
+               case SMS_PID_TELEX:
+                       retPid = MSG_PID_FAX;
+                       break;  
+               case SMS_PID_x400:
+                       retPid = MSG_PID_X400;
+                       break;  
+               case SMS_PID_ERMES:
+                       retPid = MSG_PID_ERMES;
+                       break;  
+               case SMS_PID_EMAIL:
+                       retPid = MSG_PID_EMAIL;
+                       break;  
+               default:
+                       retPid = MSG_PID_TEXT;
+                       break;  
+       } 
+
+       return retPid;
+}
+
+
+static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
+{
+       int i, offset = 0;
+       unsigned char temp;
+
+       for (i = 0; i < BcdLen; i++)
+       {   
+               temp = pBcd[i] & 0x0F;
+
+               if (temp == 0x0A)
+                       pDigit[offset++] = '*';
+               else if (temp == 0x0B)
+                       pDigit[offset++] = '#';
+               else if (temp == 0x0C)
+                       pDigit[offset++] = 'P';
+               else
+                       pDigit[offset++] = temp + '0';
+
+               temp = (pBcd[i] & 0xF0) >> 4;
+
+               if (temp == 0x0F)
+               {   
+                       pDigit[offset] = '\0';
+                       return offset;
+               }   
+
+               if (temp == 0x0A)
+                       pDigit[offset++] = '*';
+               else if (temp == 0x0B)
+                       pDigit[offset++] = '#';
+               else if (temp == 0x0C)
+                       pDigit[offset++] = 'P';
+               else
+                       pDigit[offset++] = temp + '0';
+       }   
+
+       pDigit[offset] = '\0';
+
+       return offset;
+}
+
+static void decodeSMSC(unsigned char* pAddress, int AddrLen, int ton, char *pDecodeAddr)
+{
+       if (pAddress == NULL || AddrLen == 0)
+               return;
+
+       if (ton == SMS_TON_INTERNATIONAL)
+       {
+               pDecodeAddr[0] = '+';
+               convertBcdToDigit(pAddress, AddrLen, &(pDecodeAddr[1]));
+       }
+       else
+       {
+               convertBcdToDigit(pAddress, AddrLen, pDecodeAddr);
+       }
+}
+
+int sms_param_set_vconf()
+{
+       int i, alpha_id_len = 0,nOffset = 0;
+       unsigned long AlphaIdLen; 
+       char szAlphaId[TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX + 1];
+       char smscAddr[TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX*2 + 1];
+       unsigned char ParamIndicator;
+       unsigned int DialNumLen; 
+       unsigned char szDiallingNum[TAPI_SIM_SMSP_ADDRESS_LEN + 1];
+       int Ton=0,  Npi=0; 
+       unsigned short TpProtocolId = 0; 
+       unsigned short TpDataCodingScheme = 0;
+       unsigned short TpValidityPeriod = 0; 
+       const unsigned char *p = NULL;
+
+       p = &g_record[0];
+
+       alpha_id_len = g_record_len - TAPI_NETTEXT_SMSP_PARAMS_MAX_LEN;
+       if ( alpha_id_len > 0 ) {
+
+               if(alpha_id_len > TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX) {
+                       alpha_id_len = TAPI_SIM_SMSP_ALPHA_ID_LEN_MAX;
+               }
+
+               for( i=0 ; i < alpha_id_len ; i++) {
+                       if( 0x00 == p[i]) { /* 0xff check */
+                               TRACE(MSGL_VGSM_INFO, " found \n");
+                               break;
+                       }
+               }
+
+               memcpy(&szAlphaId, p, i);
+               AlphaIdLen = i;
+               TRACE(MSGL_VGSM_INFO, "Alpha id length = %d \n", i);
+
+       } else {
+               AlphaIdLen = 0;
+               TRACE(MSGL_VGSM_INFO, "Alpha id length is zero \n");
+       }
+
+       ParamIndicator = p[alpha_id_len];
+       TRACE(MSGL_VGSM_INFO, "Param Indicator = %02x \n", ParamIndicator);
+
+       if((ParamIndicator & SMSPValidDestAddr) == 0) {
+
+               nOffset = nDestAddrOffset;
+
+               if( 0x00 == p[alpha_id_len + nOffset] || 0xff == p[alpha_id_len + nOffset] ){
+                       TRACE(MSGL_VGSM_INFO, "DestAddr Length is 0 \n");
+               }else{
+                       /* check */
+                       TRACE(MSGL_VGSM_INFO, "Can't set this feild by setting app(DestAddr) \n");
+               }
+       }
+
+       if( (ParamIndicator & SMSPValidSvcAddr) == 0) {
+
+               nOffset = nSCAAddrOffset;
+
+               if( 0x00 == p[alpha_id_len + nOffset] || 0xff == p[alpha_id_len + nOffset] ){
+
+                       TRACE(MSGL_VGSM_INFO, "SCAAddr Length is 0 \n");
+
+               } else {
+
+                       TRACE(MSGL_VGSM_INFO, "SCAAddr \n");
+
+                       if ( 0 < (int)p[alpha_id_len + nOffset]  ) {
+
+                               DialNumLen = (int)(p[alpha_id_len + nOffset] - 1);
+
+                               TRACE(MSGL_VGSM_INFO, "DialNumLen Len(%d) \n", DialNumLen);
+
+                               if(DialNumLen > TAPI_SIM_SMSP_ADDRESS_LEN)
+                                       DialNumLen = TAPI_SIM_SMSP_ADDRESS_LEN;
+
+                               Npi = p[alpha_id_len + (++nOffset)] & 0x0f ;
+                               Ton = (p[alpha_id_len + nOffset] & 0x70) >>4 ;
+
+                               memcpy( szDiallingNum, &p[alpha_id_len + (++nOffset)], DialNumLen);
+
+                               TRACE(MSGL_VGSM_INFO, "SCAddr Length = %d \n", DialNumLen);
+
+                               /* libslp-tapi/include/common/TelSim.h */
+                               /* 1: international number */
+                               TRACE(MSGL_VGSM_INFO, "SCAddr TON is %d \n", Ton);
+                               /* 1: ISDN/Telephone numbering plan  */
+                               TRACE(MSGL_VGSM_INFO, "SCAddr NPI is %d \n", Npi);
+
+                               memset(smscAddr, 0x00, sizeof(smscAddr));
+                               decodeSMSC(szDiallingNum, DialNumLen, Ton, smscAddr);
+                               TRACE(MSGL_VGSM_INFO, "smacAddr(%s) \n", smscAddr);
+
+                               //for( i = 0 ; i < DialNumLen ; i ++)
+                               //      TRACE(MSGL_VGSM_INFO, "SCAddr = %d [%02x] \n", i, szDiallingNum[i]);
+
+                       } else{
+                               /* */
+                               TRACE(MSGL_VGSM_INFO, "No SCAAddr\n");
+                       }
+               }
+
+       }else{
+               /* */
+       }
+
+       /* msg-service/include/common/MsgSettingTypes.h */
+
+       /* TEXT(0), VOICE(36), FAX(33), Email(34) */
+       if( (ParamIndicator & SMSPValidPID) == 0 &&
+                       (alpha_id_len + nPIDOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE)
+       {
+               TpProtocolId = p[alpha_id_len + nPIDOffset];
+       }
+
+       if( (ParamIndicator & SMSPValidDCS) == 0 &&
+                       (alpha_id_len + nDCSOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE)
+       {
+               TpDataCodingScheme = p[alpha_id_len + nDCSOffset];
+       }
+
+       /*  1DAY = 167, 2DAYS = 168,1WEEK = 173,2WEEKS = 180, MAXIMUM = 255 */
+       if( (ParamIndicator & SMSPValidVP) == 0 &&
+                       (alpha_id_len + nVPOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE)
+       {
+               TpValidityPeriod = p[alpha_id_len + nVPOffset];
+       }
+
+       TRACE(MSGL_VGSM_INFO, " Alpha Id(Len) = %d \n",(int)AlphaIdLen);
+       TRACE(MSGL_VGSM_INFO, " Alpha Id = [%s] \n", szAlphaId);
+
+       TRACE(MSGL_VGSM_INFO, " PID = %d \n",TpProtocolId);
+       TRACE(MSGL_VGSM_INFO, " DCS = %d \n",TpDataCodingScheme);
+       TRACE(MSGL_VGSM_INFO, " VP = %d \n",TpValidityPeriod);
+
+       if (vconf_set_str(SMSC_NAME"/0", szAlphaId) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s] => [%s]" 
+                               , SMSC_NAME"/0", szAlphaId);
+       }
+       if (vconf_set_str(SMSC_ADDRESS"/0", smscAddr) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s]=> [%s]" 
+                               , SMSC_ADDRESS"/0", smscAddr);
+       }
+       if (vconf_set_int(SMSC_TON"/0", Ton) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s] => [%d]" 
+                               , SMSC_TON"/0", Ton);
+       }
+       if (vconf_set_int(SMSC_NPI"/0", Npi) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s] => [%d]" 
+                               , SMSC_NPI"/0", Npi);
+       }
+       if (vconf_set_int(SMSC_PID"/0", (int)convertPid(TpProtocolId)) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s] => [%d]" 
+                               , SMSC_PID"/0", (int)convertPid(TpProtocolId));
+       }
+       if (vconf_set_int(SMSC_VAL_PERIOD"/0", TpValidityPeriod) != 0 ){
+               TRACE(MSGL_VGSM_INFO, "[FAIL] vconf error: [%s] => [%d]" 
+                               , SMSC_VAL_PERIOD"/0", TpValidityPeriod);
+       }
+
+       return 1;
+}
+
+#endif
diff --git a/vmodem/at/at_rx_snd.c b/vmodem/at/at_rx_snd.c
new file mode 100644 (file)
index 0000000..3c16200
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "oem_rx_ss.h"
+#include "at_msg.h"
+#include "state.h"
+#include "at_recv.h"
+
+#include "at_tx_func.h"
+#include "at_rx_snd.h"
+#include "at_tx_snd.h"
+
+
+static unsigned char g_bmute;
+static unsigned char g_audio_path = 1;
+static unsigned char g_clock_status; //0:Clock End, 1:Clock Start
+
+int at_rx_snd_mute_control_get(char* atmsg)
+{
+       unsigned char data[1];
+       int len = 0;
+
+       data[len++] = g_bmute;
+       
+       return at_tx_snd_mute_control_resp(data, len);
+}
+
+int at_rx_snd_mute_control_set(char* atmsg)
+{
+/*     
+       unsigned char bmute;
+
+       bmute = atmsg[0];
+
+       TRACE(MSGL_VGSM_INFO, "bmute = %d \n", bmute);
+
+       g_bmute = bmute;
+*/
+       return 1;
+}
+
+int at_rx_snd_audio_path_set(char* atmsg)
+{
+/*     
+       unsigned char audio_path;
+
+       audio_path = atmsg[0];
+
+       TRACE(MSGL_VGSM_INFO, "audio_path = %d \n", audio_path);
+
+       g_audio_path = audio_path;
+*/     
+       return 1;
+}
+
+int at_rx_snd_clock_ctrl_exec(char* atmsg)
+{
+/*     
+       unsigned char clock_status;
+
+       clock_status = atmsg[0];
+
+       TRACE(MSGL_VGSM_INFO, "clock_status = %d \n", clock_status);
+
+       g_clock_status = clock_status;
+*/     
+       return 1;
+}
+
+
+
diff --git a/vmodem/at/at_rx_ss.c b/vmodem/at/at_rx_ss.c
new file mode 100644 (file)
index 0000000..7526e0c
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/* at_rx_ss.c */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "oem_rx_ss.h"
+#include "at_rx_ss.h"
+#include "at_msg.h"
+#include "at_recv.h"
+#include "at_func.h"
+
+#include "state.h"
+#include "at_tx_func.h"
+#include "at_tx_ss.h"
+
+#include "db_ss.h"
+#include "vgsm_phone.h"
+#include "server_rx_ss.h"
+#include "server_common_ss.h"
+
+#define AO 
+
+int at_rx_ss_default(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 1;
+}
+
+int at_rx_ss_manage_call_set(char* atmsg)
+{
+       return oem_rx_ss_manage_call_set(atmsg, strlen(atmsg));
+}
+
+int at_rx_ss_cw_get(char* atmsg)
+{
+       int tel_class = 1;      // voice
+
+       TRACE(MSGL_VGSM_INFO, "tel_class = %d \n", tel_class);
+
+       oem_rx_ss_cw_get(tel_class);
+       return 1;
+}
+
+int at_rx_ss_cw_set(char* atmsg)
+{
+       char* ret = NULL;
+       char* tdata = strchr(atmsg, '=');
+       int tel_class = 0, ss_mode = 0;
+
+       TRACE(MSGL_VGSM_INFO, "%s\n", atmsg);
+       ret = strtok(tdata+1, TOKEN);
+        if(ret)
+       {
+               // first param is ignored.
+       }
+
+       ret = strtok(NULL, TOKEN);
+       if(ret)
+       {
+               if(atoi(ret) == AT_SS_STATUS_ACTIVE)
+                       ss_mode = SS_MODE_ACT;
+               else
+                       ss_mode = SS_MODE_DEACT;
+       }
+       
+       tel_class = AT_CALL_CLASS_VOICE;        // vmodem support only voice call
+       
+       return oem_rx_ss_cw_set(tel_class, ss_mode);
+}
+
+// Call Forwarding
+int at_rx_ss_cf_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       int tel_class = 1;
+       int cf_type = 1;
+       char* tdata = strchr(atmsg, '=');
+        char* ret = NULL;
+        ret = strtok(tdata+1, TOKEN);
+        if(ret)
+                cf_type = atoi(ret) + 1;       // for at spec
+       
+       ret = strtok(NULL, TOKEN);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+       ret = strtok(NULL, TOKEN);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+       if(ret)
+               tel_class = atoi(ret);  
+
+       TRACE(MSGL_VGSM_INFO, "CCFC tel_class:%d\n", tel_class);
+       oem_rx_ss_cf_get(tel_class, cf_type);
+       return 1;
+}
+
+int at_rx_ss_cf_set(char* atmsg)
+{
+       int     ss_mode, tel_class, type, replyTime, num_len, num_type, satype;
+       char number[MAX_GSM_DIALED_DIGITS_NUMBER], subaddr[MAX_GSM_DIALED_DIGITS_NUMBER];
+       memset(subaddr, '\0', MAX_GSM_DIALED_DIGITS_NUMBER);
+       char* tdata = strchr(atmsg, '=');
+       char token[] = "\"";
+        char* ret = NULL;
+        ret = strtok(tdata+1, TOKEN);
+       if(ret)
+       {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               type = atoi(ret) + 1;
+       }
+       else
+               type = 1;
+       
+        ret = strtok(NULL, TOKEN);
+       if(ret)
+       {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               switch(atoi(ret))
+               {
+               case AT_CALL_FW_MODE_DISABLE:
+                       ss_mode = SS_MODE_DEACT;
+                       break; 
+               case AT_CALL_FW_MODE_ENABLE:
+                       ss_mode = SS_MODE_ACT;
+                       break;
+               case AT_CALL_FW_MODE_QUERY:
+                       ss_mode = GSM_SS_MODE_QUERY;
+                       break;
+               case AT_CALL_FW_MODE_REG:
+                       ss_mode = SS_MODE_REG;
+                       break;
+               case AT_CALL_FW_MODE_ERASURE:
+                       ss_mode = SS_MODE_DEREG;
+                       break;
+               default:
+                       ss_mode = GSM_SS_MODE_DEACTIVATE;
+                       break;
+               }
+       }
+       else
+               ss_mode = GSM_SS_MODE_DEACTIVATE;
+
+       ret = strtok(NULL, token);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               strcpy(number, ret);
+       }
+       
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               num_type = atoi(ret);
+       }
+       else
+               num_type = 129; // default
+               
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               strcpy(subaddr, ret);
+       }
+
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               satype = atoi(ret);
+       }
+       else
+               satype = 128;   // default
+
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               tel_class = atoi(ret);
+       }
+       else
+               tel_class = AT_CALL_SS_CLASS_VOICE;     // default
+
+       ret = strtok(NULL, TOKEN);
+        if(ret)
+        {
+               TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+               replyTime = atoi(ret);
+       }
+       else
+               replyTime = 20; // default
+
+       num_len = strlen(number);
+
+       oem_rx_ss_cf_set(ss_mode, type, tel_class, replyTime, num_len, number, num_type);
+//     oem_rx_ss_cf_set(ss_mode, type, tel_class, replyTime, num_len, number, num_type, satype, subaddr);
+       return 1;
+}
+
+int at_rx_ss_cb_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       int     tel_class = AT_CALL_SS_CLASS_ALL;       // all
+       const char* scmd;
+        int nn = 0, found = 0;
+        int cb_type = 0;
+
+       char* tdata = strchr(atmsg, '=');
+        char token[] = "\"";
+        char* ret = NULL;
+        
+        ret = strtok(tdata+1, token);
+
+        if(ret)
+        {
+               for (nn = 0; ; nn++) {
+                       scmd = sDefaultFac[nn].fac;
+                        if (!scmd) // end of list
+                               break;
+                        
+                        if ( !strcmp( scmd, ret ) ) {
+                               found = 1;
+                                break;
+                        }
+                 }
+        
+                 if(found)
+                       cb_type = sDefaultFac[nn].cb_e_type;
+                 else 
+                        cb_type = SS_CB_TYPE_NONE;
+       }
+       
+       ret = strtok(NULL, TOKEN);
+       ret = strtok(NULL, TOKEN);
+       if(ret)
+       {
+               tel_class = atoi(ret);
+       }
+
+       oem_rx_ss_cb_get(tel_class, cb_type);
+       return 1;
+}
+
+int at_rx_ss_cb_set(char* atmsg)
+{
+       int cb_type = 0, ss_mode = 0, tel_class;
+       char passwd[32];
+       memset(passwd, '\0', sizeof(passwd));
+       const char* scmd;
+       int nn = 0, found = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       char* tdata = strchr(atmsg, '=');
+        char token[] = "\"";
+        char* ret = NULL;
+       
+       ret = strtok(tdata+1, token);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+        if(ret)
+       {
+               for (nn = 0; ; nn++) {
+                       scmd = sDefaultFac[nn].fac;
+                        if (!scmd) // end of list
+                               break;
+                       
+                       if ( !strcmp( scmd, ret ) ) {
+                               found = 1;
+                                break;
+                        }
+               }
+
+               if(found)
+                       cb_type = sDefaultFac[nn].cb_e_type;
+               else
+                       cb_type = SS_CB_TYPE_NONE;
+       }
+       
+       ret = strtok(NULL, TOKEN);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+       if(ret)
+       {
+               switch(atoi(ret))
+               {
+               case 0:
+                       ss_mode = SS_MODE_DEACT;
+                       break;
+               case 1:
+                       ss_mode = SS_MODE_ACT;
+                       break;
+               }
+       }
+       TRACE(MSGL_VGSM_INFO, "set ss_mode:%d\n", ss_mode);
+
+       ret = strtok(NULL, token);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+       if(ret)
+               strcpy(passwd, ret);    
+
+       ret = strtok(NULL, TOKEN);
+       TRACE(MSGL_VGSM_INFO, "%s\n", ret);
+       if(ret)
+               tel_class = atoi(ret);
+       else
+               tel_class = 17; // suport voice only    
+
+       return oem_rx_ss_cb_set(cb_type, ss_mode, tel_class, passwd);
+}
+
+int at_rx_ss_cb_passwd_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented\n");
+/*     
+       char curr_passwd[4];
+       char new_passwd[4];
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       memcpy(curr_passwd, &atmsg[0], 4);
+       memcpy(new_passwd, &atmsg[1], 4);
+
+       oem_rx_ss_cb_passwd_set(curr_passwd, new_passwd);
+*/
+       return 1;
+}
+
+int at_rx_ss_aoc_get(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented\n");
+/*     TelSsAocType_t *aoc_type ;
+       _AOC_t current_aoc ;
+       _AOC_t *pcurrent_aoc ;
+       ss_aoc_res_data_type res_type;
+
+       aoc_type =( TelSsAocType_t*) atmsg[0] ;
+
+       pcurrent_aoc = &current_aoc;
+
+       get_aoc_data(  &current_aoc);
+
+       switch ( *aoc_type )
+       {
+       case TAPI_SS_AOC_TYPE_ACM :
+               res_type.type = TAPI_SS_AOC_TYPE_ACM ;
+               memcpy(&res_type.acm, &current_aoc.acm, sizeof(res_type.acm));
+               at_tx_ss_aoc_resp(&res_type,sizeof (ss_aoc_res_data_type ));
+               break;
+       case TAPI_SS_AOC_TYPE_CCM:
+               res_type.type = TAPI_SS_AOC_TYPE_CCM ;
+               memcpy(&res_type.ccm, &current_aoc.ccm, sizeof(res_type.ccm));
+
+               at_tx_ss_aoc_resp(&res_type,sizeof (ss_aoc_res_data_type ));
+               break;
+       case TAPI_SS_AOC_TYPE_MAXACM:
+               res_type.type = TAPI_SS_AOC_TYPE_MAXACM ;
+               memcpy(&res_type.maxacm, &current_aoc.maxacm, sizeof(res_type.maxacm));
+
+               at_tx_ss_aoc_resp(&res_type,sizeof (ss_aoc_res_data_type ));
+               break;
+       case TAPI_SS_AOC_TYPE_PUC:
+               res_type.type = TAPI_SS_AOC_TYPE_PUC ;
+               memcpy(&res_type.ppu, &current_aoc.ppu, sizeof(res_type.ppu));
+               memcpy(&res_type.chartype, &current_aoc.chartype, sizeof(res_type.chartype));
+               memcpy(&res_type.currency, &current_aoc.currency, sizeof(res_type.currency));
+
+               at_tx_ss_aoc_resp(&res_type,sizeof (ss_aoc_res_data_type ));
+               break;
+       case TAPI_SS_AOC_TYPE_RESET:
+               res_type.type = TAPI_SS_AOC_TYPE_RESET ;
+               memcpy(&res_type.acm, &current_aoc.acm, sizeof(res_type.acm));
+               memcpy(&res_type.ccm, &current_aoc.ccm, sizeof(res_type.ccm));
+
+               at_tx_ss_aoc_resp(&res_type,sizeof (ss_aoc_res_data_type ));
+               break;
+       default:
+               TRACE(MSGL_WARN, "Unknown AOC TYPE from telephony server( %x )\n", *aoc_type);
+               break;
+       }
+*/
+       return 0;
+}
+
+int at_rx_ss_aoc_set(char* atmsg)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented\n");
+/*     TelSsAocType_t *aoc_type ;
+       aoc_type = (TelSsAocType_t*) atmsg[0] ;
+
+       _AOC_t current_aoc ;
+       _AOC_t *aoc_set_data ;
+
+       get_aoc_data( &current_aoc);
+
+       aoc_set_data = (_AOC_t*)atmsg ;
+
+       switch (*aoc_type )
+       {
+       case TAPI_SS_AOC_TYPE_ACM :
+               memcpy(&current_aoc.acm, &aoc_set_data->acm, sizeof(current_aoc.acm));
+               break;
+       case TAPI_SS_AOC_TYPE_CCM:
+               memcpy( &current_aoc.ccm, &aoc_set_data->ccm , sizeof(current_aoc.ccm));
+               break;
+       case TAPI_SS_AOC_TYPE_MAXACM:
+               memcpy( &current_aoc.maxacm, &aoc_set_data->maxacm , sizeof(current_aoc.maxacm));
+               break;
+       case TAPI_SS_AOC_TYPE_PUC:
+               memcpy( &current_aoc.ppu, &aoc_set_data->ppu, sizeof(current_aoc.ppu));
+               memcpy( &current_aoc.chartype, &aoc_set_data->chartype, sizeof(current_aoc.chartype));
+               memcpy( &current_aoc.currency, aoc_set_data->currency , sizeof(current_aoc.currency));
+               break;
+       case TAPI_SS_AOC_TYPE_RESET:
+               memcpy( &current_aoc.acm, &aoc_set_data->acm,  sizeof(current_aoc.acm));
+               memcpy(&current_aoc.ccm, &aoc_set_data->ccm ,sizeof(current_aoc.ccm));
+               break;
+       default:
+               TRACE(MSGL_WARN, "Unknown AOC TYPE from telephony server %x\n", *aoc_type );
+               break;
+       }
+*/
+       return 0;
+}
+
+int at_rx_ss_cli(void)
+{
+       oem_rx_ss_cli("TelTapiSsQueryCliServiceStatus");
+       return 0;
+}
+
diff --git a/vmodem/at/at_send.c b/vmodem/at/at_send.c
new file mode 100644 (file)
index 0000000..baf606e
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_send.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "state.h"
+#include <misc.h>
+#include <phoneserver.h>
+#include "gsmstate.h"
+#include "at_msg.h"
+#include "at_send.h"
+
+extern GSM_StateMachine GlobalS;
+static unsigned char get_control_infoid(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       static unsigned char s_infoid = 0;
+
+       if (s_infoid >= 128)
+               s_infoid = 0;
+       ++s_infoid;
+
+       return s_infoid;
+}
+
+static unsigned char get_msg_sequence(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       static unsigned char s_msg_seq = 0;
+       // message-sequence is 0 - 0xFE
+
+       if(s_msg_seq >= 0xFE)
+               s_msg_seq = 0;
+       else
+               s_msg_seq++;
+       /***
+       static unsigned char s_msg_seq = 0;
+       if (s_msg_seq >= 255)
+               s_msg_seq = 0;
+       ++s_msg_seq;
+       ***/
+       return s_msg_seq;
+}
+
+#define HDLC_FRAME_HEADER_SIZE 3
+#define MAX_HDLC_FRAME_SIZE 2048
+
+// make at message with element
+static int make_single_at(void *data, int datasize, void *target)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       HDLCFrame_t frame_message = {0,};
+
+       frame_message.m_Length = (unsigned short)(datasize);
+       frame_message.m_CtrlInfo = get_control_infoid();
+
+       // save target
+       memcpy(target, data, datasize + 1);
+
+       // update last sent HDLC frame
+       ATSetLastSentHDLCFrameInfo(&frame_message);
+
+       // update last sent at
+       SetLastSentAT(data);
+
+       return datasize + 1;
+}
+
+int at_msg_send(unsigned char ack, void *data, int datasize)
+{
+       _ENTER();
+       int rc = 0;
+       unsigned char *rawdata;
+       if (datasize <= MAX_HDLC_FRAME_SIZE) {
+           // allocate memory
+           rawdata = malloc(datasize + 1);
+
+           // make at rawdata
+           rc = make_single_at(data, datasize, rawdata);
+           TRACE(MSGL_VGSM_INFO, "rc:%d\n", rc);
+           TRACE(MSGL_VGSM_INFO, "data:%s\n", (char*)data);
+           TRACE(MSGL_VGSM_INFO, "rawdata:%s\n", rawdata);     
+           if (rawdata != NULL) {
+               // tx to phone
+               rc = GlobalS.Device.Functions->WriteDevice(&GlobalS, rawdata, rc - 1);
+               TRACE(MSGL_VGSM_INFO, "rc:%d\n", rc);
+               TRACE(MSGL_VGSM_INFO, "rawdata:%s\n", rawdata);
+           }
+
+           // release memory
+           free(rawdata);
+       } else {
+               TRACE(MSGL_VGSM_INFO, "datasize:%d\n", datasize);
+               TRACE(MSGL_VGSM_INFO, "data:%s\n", (char*)data);
+               return -1;
+       }
+    
+    return rc;
+}
+
diff --git a/vmodem/at/at_tx_call.c b/vmodem/at/at_tx_call.c
new file mode 100644 (file)
index 0000000..dc0693b
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  at_tx_call.c */
+
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_tx_call.h"
+#include "at_func.h"
+#include "server_tx_call.h"
+
+int at_tx_call_incoming_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "RING noti\n");
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s%s", RING, CRLF);    
+       at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+       return at_tx_call_status_noti(data, strlen((char*)data));
+}
+
+int at_tx_call_connect_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "CONNECT noti\n");
+       return server_tx_call_list_noti();
+}
+
+int at_tx_call_waiting_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CCWA noti\n");
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+        sprintf(sndbuf, "%s%s%s", CCWA, (char*)data, CRLF);
+        return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_call_list_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CLCC noti\n");
+       return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_call_list_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CLCC resp\n");
+       return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_call_status_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "%%SCLCC noti\n");
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s%s%s", SCLCC, (char*)data, CRLF);
+       TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_call_burst_dtmf_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_call_line_id_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_call_gen_resp(char* resp)
+{
+       TRACE(MSGL_VGSM_INFO, "call gen resp\n");
+       return at_gen_resp_send(resp);
+}
+
diff --git a/vmodem/at/at_tx_data.c b/vmodem/at/at_tx_data.c
new file mode 100644 (file)
index 0000000..170e538
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_gen_resp.h"
+#include "at_tx_data.h"
+
+int at_tx_data_CallStatus(void *data, int len)
+{
+       return 1;
+}
+
+int at_tx_data_DataCallStatus(void *data, int len)
+{
+       return 1;       
+}
diff --git a/vmodem/at/at_tx_display.c b/vmodem/at/at_tx_display.c
new file mode 100644 (file)
index 0000000..c92d225
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*    at_tx_display.c      */
+
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_tx_display.h"
+#include "at_func.h"
+
+int at_tx_display_icon_info_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "%s noti\n", CIEV);
+       char* buf = (char*)data;
+       char sndbuf1[SEND_BUF_SIZE], sndbuf2[SEND_BUF_SIZE];
+       memset(sndbuf1, '\0', sizeof(sndbuf1));
+       memset(sndbuf2, '\0', sizeof(sndbuf2));
+
+       sprintf(sndbuf1, "%s%d,%d%s", CIEV, SIGNAL, buf[1], CRLF);      // rssi
+       at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf1, strlen(sndbuf1));
+
+       sprintf(sndbuf2, "%s%d,%d%s", CIEV, BATTCHG, buf[3]/20, CRLF);  // battery
+       TRACE(MSGL_VGSM_INFO, "%s, %s", sndbuf1, sndbuf2);
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf2, strlen(sndbuf2));
+}
+
+int at_tx_display_icon_info_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
diff --git a/vmodem/at/at_tx_emulator.c b/vmodem/at/at_tx_emulator.c
new file mode 100644 (file)
index 0000000..5a61f53
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_tx_emulator.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <vgsm_phone.h>
+#include <misc.h>
+#include "state.h"
+#include "gsmstate.h"
+#include "at_send.h"
+#include "at_tx_func.h"
+#include "at_func.h"
+
+extern GSM_StateMachine GlobalS;
+extern SmsAddressInfo g_sca;
+
+int ATTxEmulator_HDLC_Req(LXT_MESSAGE const* packet)
+{
+    TRACE(MSGL_VGSM_INFO, "\n");
+
+    // HDLC->AT
+    if( get_hdlc_mode() == 1 )
+               GlobalS.Device.Functions->WriteDevice(&GlobalS, packet->data, packet->length);
+
+    return 1;
+}
+
+int ATTxEmulator_HDLC_Mode(LXT_MESSAGE const* packet)
+{
+    char *data = (char *)packet->data;
+
+    set_hdlc_mode(data[0]);
+
+    return 1;
+}
+
+int ATTxEmulator_HDLC_Clear()
+{
+    ATFreeAllMultiNodeList();
+
+    return 1;
+}
+
+int ATTxEmulator_Set_General_Response_Error(LXT_MESSAGE const* packet)
+{
+    char *data = (char *)packet->data;
+
+    int error = (data[1] & 0xFF);
+    error <<= 8;
+    error |= (data[0] & 0xFF);
+
+
+    set_general_response_error(error);
+
+    return 1;
+}
+
+
+int ATTxEmulator_Set_SS_Response_Error(LXT_MESSAGE const* packet, int ss_error_type)
+{
+    char *data = (char *)packet->data;
+    int error = (data[1] & 0xFF);
+    error <<= 8;
+    error |= (data[0] & 0xFF);
+    TRACE(MSGL_VGSM_INFO,"type = %d\n", ss_error_type );
+
+    set_ss_transfer_response_error(error, ss_error_type );
+   return 1;
+}
+
+int ATTxEmulator_Set_SS_General_Response_Error(LXT_MESSAGE const* packet)
+{
+    char *data = (char *)packet->data;
+    int error = (data[1] & 0xFF);
+    error <<= 8;
+    error |= (data[0] & 0xFF);
+       set_ss_general_response_error(error);
+
+
+    return 1;
+}
+
+int ATTxEmulator_Set_Call_Status_Error(LXT_MESSAGE const* packet)
+{
+    char *data = (char *)packet->data;
+    int error = (data[0] & 0xFF);
+
+    set_call_status_error(error);
+
+    return 1;
+}
+
+void ATset_sca( SmsAddressInfo SCA )
+{
+    memcpy( &g_sca, &SCA, sizeof( SmsAddressInfo ) );
+}
+
+int ATTxEmulator_Set_SCA(LXT_MESSAGE const* packet)
+{
+    SmsAddressInfo SCA;
+
+    memcpy(&SCA, (char *)packet->data, sizeof(SmsAddressInfo));
+
+    ATset_sca(SCA);
+
+    return 1;
+}
diff --git a/vmodem/at/at_tx_gprs.c b/vmodem/at/at_tx_gprs.c
new file mode 100644 (file)
index 0000000..2b7256d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_send.h"
+#include "at_tx_gprs.h"
+
+int at_tx_gprs_IPConfigurationNotify(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CGDCONT resp\n");
+       TRACE(MSGL_VGSM_INFO, "%s", (char*)data);
+       return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
diff --git a/vmodem/at/at_tx_misc.c b/vmodem/at/at_tx_misc.c
new file mode 100644 (file)
index 0000000..026c88c
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "at_tx_func.h"
+#include "at_tx_misc.h"
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_tx_misc.h"
+#include "at_func.h"
+
+int at_tx_misc_version(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CGMR resp %s\n", (char*)data);
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+static const int at_tx_max_serial_number_data = 0x20;
+
+int at_tx_misc_me_serial(int sn_index, const void *sn, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CGSN resp %s\n", (char*)sn);
+       at_msg_send(ACK_SEQ_RESPONSE, (void*)sn, strlen(sn));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_misc_time_info(char* atmsg, const struct tm *tm)
+{
+       unsigned char data[11];
+       int n = 0;
+
+       data[n++] = 0x01;       // time info from network
+       data[n++] = 0x00;       // daylight time invalid
+       data[n++] = tm->tm_year + 1900 - 2000;
+       data[n++] = tm->tm_mon + 1;
+       data[n++] = tm->tm_mday;
+       data[n++] = tm->tm_hour;
+       data[n++] = tm->tm_min;
+       data[n++] = tm->tm_sec;
+       data[n++] = 0;          // timezone offset ...
+       data[n++] = 0;          // daylight adjust
+       data[n++] = tm->tm_wday;
+
+       assert(n <= sizeof data);
+
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s%d,0,%d/%d/%d,%d:%d:%d%s", CTZR, data[0], data[2], data[3], data[4], data[5], data[6], data[7], CRLF);
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
diff --git a/vmodem/at/at_tx_network.c b/vmodem/at/at_tx_network.c
new file mode 100644 (file)
index 0000000..f3216dc
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*    at_tx_network.c      */
+
+#include <string.h>
+#include "at_send.h"
+#include "at_gen_resp.h"
+#include "at_tx_network.h"
+#include "at_func.h"
+
+int at_tx_net_plmn_list_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_net_plmn_list_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+COPS list resp\n");
+       TRACE(MSGL_VGSM_INFO, "%s", (char*)data);
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_net_reg_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CREG noti\n");
+       unsigned char* buf = (unsigned char*)data;
+        char sndbuf[SEND_BUF_SIZE];
+        memset(sndbuf, '\0', sizeof(sndbuf));
+
+        sprintf(sndbuf, "%s%d,%x%x,%x%x%x%x,%d%s", CREG, buf[2], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[0], CRLF);
+        TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+        at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+        
+        memset(sndbuf, '\0', sizeof(sndbuf));
+        sprintf(sndbuf, "%s%d,%x%x,%x%x%x%x,%d%s", CGREG, buf[2], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[0], CRLF);
+        TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_net_reg_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CREG resp\n");
+       unsigned char* buf = (unsigned char*)data;
+        char sndbuf[len];
+        sprintf(sndbuf, "%s%d,%x%x,%x%x%x%x,%d%s", CREG, buf[2], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[0], CRLF);
+        TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+        return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_net_current_plmn_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti\n");
+        return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_net_current_plmn_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+COPS? resp\n");
+
+        at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_gen_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CFUN resp\n");
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_net_plmn_selection_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+        return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_net_svc_domain_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+        return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_net_current_nitz_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "current nitz noti\n");
+       unsigned char* buf = (unsigned char*)data;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       char formatbuf[8];
+       int data_index = 0;
+       
+       sprintf(sndbuf, "%s", CNITZ);
+       for(data_index = 0; data_index < len; data_index++)
+       {
+               sprintf(formatbuf, "%x", buf[data_index]);
+               strcat(sndbuf, formatbuf);
+               if(data_index + 1 == len)
+                       break;
+
+               strcat(sndbuf, TOKEN);
+       }
+       strcat(sndbuf, CRLF);
+
+       TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_net_band_get_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+        return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
diff --git a/vmodem/at/at_tx_phonebook.c b/vmodem/at/at_tx_phonebook.c
new file mode 100644 (file)
index 0000000..3ce6e69
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "at_send.h"
+#include "at_tx_phonebook.h"
+#include "at_gen_resp.h"
+
+
+int at_tx_sim_pb_get_storage_cnt_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+       return 0;
+
+//     return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+}
+
+
+int at_tx_sim_pb_get_entry_info_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+       return 0;
+
+//     return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+}
+
+
+int at_tx_sim_pb_get_storage_list_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+       return 0;
+
+//     return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+}
+
+
+int at_tx_sim_pb_set_access_res(int error)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+       return 0;
+/*
+       char data[4];
+
+       data[0] = AT_GSM_PB_CMD;
+       data[1] = AT_GSM_PB_ACCESS;
+       data[2] = (error & 0xFF);
+       data[3] = ((error >> 8) & 0xFF);
+
+       return at_msg_send(ACK_SEQ_RESPONSE, data, 4);
+*/
+}
+
+
+int at_tx_sim_pb_get_access_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+}
+
diff --git a/vmodem/at/at_tx_power.c b/vmodem/at/at_tx_power.c
new file mode 100644 (file)
index 0000000..52b7633
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// at_tx_power.c
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "at_send.h"
+#include "at_tx_power.h"
+#include "logmsg.h"
+#include "at_func.h"
+#include "at_gen_resp.h"
+#include "flight.h"
+
+int at_tx_power_up_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CPAS resp\n");
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_power_online_noti(void *data, int len)
+{      
+       TRACE(MSGL_VGSM_INFO, "%s noti\n", SCFUN);
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       bool status = is_flight_mode();
+       int value = 0;
+       
+       if(status)
+               value = FLIGHT_MODE_ON;
+       else
+               value = FLIGHT_MODE_OFF;
+
+       sprintf(sndbuf, "%s%d%s", SCFUN, value, CRLF);
+       
+       TRACE(MSGL_VGSM_INFO, "%s\n", sndbuf);
+
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_battery_status_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti");
+       return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
diff --git a/vmodem/at/at_tx_sat.c b/vmodem/at/at_tx_sat.c
new file mode 100644 (file)
index 0000000..5035217
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// at_tx_sat.c
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "at_send.h"
+#include "at_tx_func.h"
+
+static const int max_proactive_command_length = 0x100;
+
+int TxSAT_ATGetProactiveCommand(GSM_SatProactiveCmd const* pProactiveCmd)
+{
+       unsigned char data[2 + max_proactive_command_length];
+       int n = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       assert(!(pProactiveCmd->length&0xff00));
+
+       data[n++] = (pProactiveCmd->length)&0xff;
+       data[n++] = (pProactiveCmd->length >> 8)&0xff;
+       memcpy(&data[n], pProactiveCmd->cmd, pProactiveCmd->length);
+       n += pProactiveCmd->length;
+
+       assert(n <= sizeof data);
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+}
+
diff --git a/vmodem/at/at_tx_security.c b/vmodem/at/at_tx_security.c
new file mode 100644 (file)
index 0000000..c48dc1e
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_send.h"
+#include "at_tx_security.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+int at_tx_sim_sec_get_imsi_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "+CIMI res get\n");
+
+       at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+
+int at_tx_sim_sec_set_pin_status_res(int error)
+{
+       TRACE(MSGL_VGSM_SIM, "res set\n");
+
+/*     char data[4];
+
+       data[0] = AT_GSM_SEC_CMD;
+       data[1] = AT_GSM_SEC_PIN_STATUS;
+       data[2] = (error & 0xFF);
+       data[3] = ((error >> 8) & 0xFF);
+
+       return at_msg_send(ACK_SEQ_RESPONSE, data, 4);
+*/
+       return 0;
+}
+
+
+int at_tx_sim_sec_get_pin_status_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "res get\n");
+/*
+       return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+*/
+       return 0;
+}
+
+
+int at_tx_sim_sec_get_lock_info_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "+CPINR res unimplemented\n");
+
+       //return at_msg_send(ACK_SEQ_RESPONSE, ptr_data, data_len);
+       return -1;
+}
+
+
+int at_tx_sim_sec_change_password_res(void* ptr_data)
+{
+       TRACE(MSGL_VGSM_SIM, "res\n");
+
+       return at_gen_resp_send((char*)ptr_data);
+}
+
+
+int at_tx_sim_sec_set_phone_lock_res(int error)
+{
+       TRACE(MSGL_VGSM_SIM, "res set\n");
+/*
+       char data[4];
+
+       data[0] = AT_GSM_SEC_CMD;
+       data[1] = AT_GSM_SEC_PHONE_LOCK;
+       data[2] = (error & 0xFF);
+       data[3] = ((error >> 8) & 0xFF);
+
+       return at_msg_send(ACK_SEQ_RESPONSE, data, 4);
+*/
+       return 0;
+}
+
+
+int at_tx_sim_sec_get_phone_lock_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "+CLCK res get\n");
+       return 0;
+}
+
+int at_tx_sim_sec_set_rsim_access_res(int error)
+{
+       TRACE(MSGL_VGSM_SIM, "+CRSM res set\n");
+/*
+       char data[4];
+
+       data[0] = AT_GSM_SEC_CMD;
+       data[1] = AT_GSM_SEC_RSIM_ACCESS;
+       data[2] = (error & 0xFF);
+       data[3] = ((error >> 8) & 0xFF);
+
+       return at_msg_send(ACK_SEQ_RESPONSE, data, 4);
+*/
+       return 0;
+}
+
+int at_tx_sim_sec_get_rsim_access_res(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "+CRSM resp\n");
+       unsigned char* data = (unsigned char*)ptr_data;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       int snd_len = 0;
+
+       sprintf(sndbuf, "%s%d,%d", CRSM, data[0], data[1]);
+
+       if(data_len > 0)
+       {
+               strcat(sndbuf, TOKEN);
+               snd_len = strlen(sndbuf);
+               memcpy(&sndbuf[strlen(sndbuf)], &data[2], data_len);
+               snd_len += data_len;
+       }
+       else
+               snd_len = strlen(sndbuf);
+
+       strcpy(&sndbuf[snd_len], CRLF);
+       snd_len += strlen(CRLF); 
+       
+       TRACE(MSGL_VGSM_SIM, "%s , len:%d", sndbuf, snd_len);
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, snd_len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_sim_sec_card_type_noti(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "card type noti\n");
+       return 0;
+}
+
+
+int at_tx_sim_sec_pin_status_noti(void* ptr_data, int data_len)
+{
+       TRACE(MSGL_VGSM_SIM, "pin status noti\n");
+       char* buf = (char*)ptr_data;
+        char sndbuf[SEND_BUF_SIZE];
+        memset(sndbuf, '\0', sizeof(sndbuf));
+
+        gsm_sec_lock_e_type pindata = buf[0];
+        TRACE(MSGL_VGSM_SIM, "TYPE: %d, KEY: %d\n", buf[0], buf[1]);
+        sprintf(sndbuf, "%s", CPIN);
+
+        switch(pindata)
+        {
+        case GSM_SEC_LOCK_TYPE_SC:
+                strcat(sndbuf, STSC);
+                break;
+        case GSM_SEC_LOCK_TYPE_NO_SIM:
+                strcat(sndbuf, STNOSIM);
+                break;
+        case GSM_SEC_SIM_INIT_COMPLETED:
+                strcat(sndbuf, STINIT_COMPL);
+                break;
+        case GSM_SEC_LOCK_TYPE_READY:
+        default:
+                strcat(sndbuf, STREADY);
+                break;
+        }
+
+        strcat(sndbuf, TOKEN);
+        pindata = buf[1];
+        switch(pindata)
+        {
+        case GSM_SEC_LOCK_KEY_PIN:
+                strcat(sndbuf, SKPIN);
+                break;
+        case GSM_SEC_LOCK_KEY_PUK:
+                strcat(sndbuf, SKPUK);
+                break;
+        case GSM_SEC_LOCK_KEY_PERM_BLOCKED:
+                strcat(sndbuf, SKPERM_BLOCK);
+                break;
+        case GSM_SEC_LOCK_KEY_UNLOCKED:
+        default:
+                strcat(sndbuf, SKUNLOCK);
+                break;
+        }
+        strcat(sndbuf, CRLF);
+       
+       TRACE(MSGL_VGSM_SIM, "%s", sndbuf);
+
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+
+
+int at_tx_sim_sec_phone_lock_resp(unsigned char lock_type)
+{
+       TRACE(MSGL_VGSM_SIM, "+CLCK resp\n");
+
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s%d%s", CLCK, lock_type, CRLF);
+
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+
+int at_tx_sim_sec_card_type_resp(int card_type)
+{
+       TRACE(MSGL_VGSM_SIM, "%%SCCT resp\n");
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+        sprintf(sndbuf, "%s%d%s", SCCT, card_type, CRLF);
+
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
diff --git a/vmodem/at/at_tx_sms.c b/vmodem/at/at_tx_sms.c
new file mode 100644 (file)
index 0000000..8ac5187
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "at_send.h"
+#include "logmsg.h"
+#include "at_gen_resp.h"
+#include "at_tx_sms.h"
+#include "at_func.h"
+#include <stdio.h>
+
+int at_tx_sms_deviceReady(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "%%SCDEV noti\n");
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%sREADY%s", CDEV, CRLF);
+       log_msg(MSGL_VGSM_INFO,"GSM_SMS_DEVICE_READY sent!!!\n");
+       
+       return at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_sms_NotiIncomingMsg(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CMT noti\n");
+       TRACE(MSGL_VGSM_INFO, "%s", (char*)data);
+       return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_sms_sendDeliverReport(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "%%SCSDR noti unimplement\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_sms_sendMsg(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CMGS resp\n");
+       TRACE(MSGL_VGSM_INFO, "%s", (char*)data);
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_sms_sendCBSMsg(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_sms_SCA(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+
+int at_tx_sms_cbconfig_resp(unsigned char enabled, unsigned char selected_id,
+               unsigned char list_max, unsigned char list_count, unsigned short *list)
+{
+       unsigned char data[4 + 0x100*2];
+       int n = 0;
+
+       assert(n <= sizeof data);
+
+       data[n++] = enabled;
+       data[n++] = selected_id;
+       data[n++] = list_max;
+       data[n++] = list_count;
+
+       memcpy(&data[n], list, list_count*2);
+       n += list_count * 2;
+
+       TRACE(MSGL_VGSM_INFO, "enabled(%d), selected_id(%d), list max(%d), list count(%d) \n"
+               , enabled, selected_id, list_max, list_count);
+
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+}
+
+int at_tx_sms_stored_msg_count_resp(void)
+{
+       TRACE(MSGL_VGSM_INFO, "+CPMS resp\n");
+       
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s0,0%s", CPMS, CRLF);
+
+       TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+       
+       at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_sms_deliver_report_noti(int result_status)
+{
+       TRACE(MSGL_VGSM_INFO, "+CNMA noti\n");
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_sms_param_count_resp(unsigned char mem_store, unsigned char record_count)
+{
+       unsigned char data[2];
+       int n = 0;
+
+       data[n++] = mem_store;
+       data[n++] = record_count;
+
+       TRACE(MSGL_VGSM_INFO, "mem_store(%d) record_count(%d) \n", mem_store, record_count);
+
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+}
+
+int at_tx_sms_param_resp(unsigned char mem_store, unsigned char record_index, unsigned char record_len, unsigned char *record)
+{
+       unsigned char data[256];
+       int n = 0;
+
+       data[n++] = mem_store;
+       data[n++] = record_index;
+       data[n++] = record_len;
+
+       memcpy(&data[n], record, record_len);
+       n += record_len;
+
+       TRACE(MSGL_VGSM_INFO, "mem_store(%d) record_index(%d), record_len(%d), record(%p) \n"
+               , mem_store, record_index, record_len, record);
+
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, n);
+}
+
diff --git a/vmodem/at/at_tx_snd.c b/vmodem/at/at_tx_snd.c
new file mode 100644 (file)
index 0000000..02f20be
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "at_tx_func.h"
+#include "at_tx_snd.h"
+#include "at_send.h"
+#include "at_gen_resp.h"
+
+int at_tx_snd_mute_control_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+
diff --git a/vmodem/at/at_tx_ss.c b/vmodem/at/at_tx_ss.c
new file mode 100644 (file)
index 0000000..daa91f9
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// at_tx_ss.c
+
+#include "at_send.h"
+#include "at_tx_ss.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+//#define      ENCODE_TYPE_GSM                 0x0F     /**< the value of the GSM encoding fromat for ussd */
+
+int at_tx_ss_ssinfo_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "unimplemented\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_ss_cw_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "+CCWA resp\n");
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_ss_cb_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "CLCK resp\n");
+       char* cdata = (char*)data;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       sprintf(sndbuf, "%s%d,%d%s", CLCK, cdata[3], cdata[2], CRLF);
+       TRACE(MSGL_VGSM_INFO, "%s", sndbuf);
+       return at_msg_send(ACK_SEQ_RESPONSE, sndbuf, strlen(sndbuf));
+}
+
+int at_tx_ss_cf_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "CCFC resp\n");
+       TRACE(MSGL_VGSM_INFO, "%s", (char*)data);
+       at_msg_send(ACK_SEQ_RESPONSE, data, len);
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int at_tx_ss_aoc_resp (void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_RESPONSE, data, len);
+}
+
+int at_tx_ss_aoc_noti (void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "noti\n");
+       return 0;
+//     return at_msg_send(ACK_SEQ_NOTIFICATION, data, len);
+}
+
+int at_tx_ss_gen_resp(void *data)
+{
+       TRACE(MSGL_VGSM_INFO, "resp\n");
+       return at_gen_resp_send((char*)data);
+}
diff --git a/vmodem/db/db/gprs.db b/vmodem/db/db/gprs.db
new file mode 100644 (file)
index 0000000..f214fb5
Binary files /dev/null and b/vmodem/db/db/gprs.db differ
diff --git a/vmodem/db/db/network.db b/vmodem/db/db/network.db
new file mode 100644 (file)
index 0000000..679a2a3
Binary files /dev/null and b/vmodem/db/db/network.db differ
diff --git a/vmodem/db/db/sim.db b/vmodem/db/db/sim.db
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/vmodem/db/db/ss.db b/vmodem/db/db/ss.db
new file mode 100644 (file)
index 0000000..05f2efd
Binary files /dev/null and b/vmodem/db/db/ss.db differ
diff --git a/vmodem/db/db_gprs.c b/vmodem/db/db_gprs.c
new file mode 100644 (file)
index 0000000..f3a401c
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <vgsm_network.h>
+#include "state.h"
+#include <sqlite3.h>
+#include "db_gprs.h"
+#include "logmsg.h"
+#include "fileio.h"
+
+#ifndef ALP_NOTIFY_DATABASE_DIR 
+#define ALP_NOTIFY_DATABASE_DIR  "./db"
+#endif // P_NOTIFY_DATABASE_DIR
+
+#ifndef ALP_NOTIFY_DATABASE_MODE
+#define ALP_NOTIFY_DATABASE_MODE (S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG)
+#endif // ALP_NOTIFY_DATABASE_MODE
+
+#define ALP_NOTIFY_GPRS_DATABASE_FILE "gprs.db"
+
+
+GprsDbEntry g_gprs_tmp_ipconf = {"", "", {0xFF, 0, {0,}, {0,}, {0,}, {0,}, {0,}}};
+GprsConfList g_gprs_tmp_conflist = {0, 0};
+
+
+
+// initialize the database
+// create the gprs table
+static int vgsm_gprs_sqlite_init(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_init\n");
+
+
+       char directory[256];
+       char dbname[256];
+
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_GPRS_DATABASE_FILE);   
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR)) {
+               log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_init: "
+                               "directory %s does not exit or is not directory\n",
+                               directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS)) {
+                       if (g_remove (directory) < 0) {
+
+                               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_init: unable to remove %s: %d %s\n",
+                                               directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0) {
+                       /* unable to create directory */
+                       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_init: unable to create %s: %d %s\n",
+                                       directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_init: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the table
+       err = sqlite3_exec(db,
+                       "CREATE TABLE gprs (apn TEXT, interface TEXT, cid INT, field INT, ip INT, pdns INT, sdns INT, gateway INT, subnet INT)",
+                       0, 0, &mesg);
+
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"sqlite3_exec: %s\n",mesg);
+                       sqlite3_exec(db,"TRUNCATE TABLE gprs",0,0,&mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE: err;
+}
+
+
+// initialize the database
+int vgsm_gprs_database_init(void)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_init\n");
+
+       // initialize the database
+       return vgsm_gprs_sqlite_init();
+}
+
+
+// add a new registration to the database
+// insert a row into the database which contains the registration information
+static int vgsm_gprs_sqlite_add(char *apn, char *intf, char cid, short fieldflag, unsigned int ip, unsigned int pdns,
+               unsigned int sdns, unsigned int gateway, unsigned int subnet)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_add\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_GPRS_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_add: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the sql string
+       sprintf(str,"INSERT INTO gprs VALUES ('%s', '%s', %d, %d, %d, %d, %d, %d, %d)",
+                       apn, intf, cid, fieldflag, ip, pdns, sdns, gateway, subnet);
+
+       log_msg(MSGL_VGSM_ERR," SQL statement : %s\n", str);
+
+       // add a row 
+       err = sqlite3_exec(db, str, 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_add: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_add: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+
+// add a registration
+int vgsm_gprs_database_add(GprsDbEntry *entry)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_add\n");
+
+       struct in_addr tmp_addr;
+       unsigned int ip, pdns, sdns, gateway, subnet;
+
+       memcpy(&ip, (entry->ipconf.ip_addr), 4);
+       memcpy(&pdns, (entry->ipconf.primary_dns), 4);
+       memcpy(&sdns, (entry->ipconf.secondary_dns), 4);
+       memcpy(&gateway, &(entry->ipconf.default_gateway), 4);
+       memcpy(&subnet, &(entry->ipconf.subnet_mask), 4);
+
+       tmp_addr.s_addr = ip;
+       log_msg(MSGL_VGSM_INFO,"ip(%u:%s) \n" , ip, inet_ntoa(tmp_addr));
+       tmp_addr.s_addr = pdns;
+       log_msg(MSGL_VGSM_INFO,"pdns(%u:%s) \n" , pdns, inet_ntoa(tmp_addr));
+       tmp_addr.s_addr = sdns;
+       log_msg(MSGL_VGSM_INFO,"sdns(%u:%s) \n" , sdns, inet_ntoa(tmp_addr));
+       tmp_addr.s_addr = gateway;
+       log_msg(MSGL_VGSM_INFO,"gateway(%u:%s) \n" , gateway, inet_ntoa(tmp_addr));
+       tmp_addr.s_addr = subnet;
+       log_msg(MSGL_VGSM_INFO,"subnet(%u:%s) \n" , subnet, inet_ntoa(tmp_addr));
+
+       // add the registration to the database
+       return vgsm_gprs_sqlite_add(entry->apn, entry->intf, entry->ipconf.cid, entry->ipconf.fieldflag,
+                       ip, pdns, sdns, gateway, subnet);
+}
+
+static int vgsm_gprs_sqlite_remove(char *apn)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_remove\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_GPRS_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_remove: sqlite3_open err=%d\n", err);
+
+               goto Done;
+       }
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_remove: APN: %s\n", apn);
+
+       // create the sql string
+       sprintf(str, "DELETE FROM gprs WHERE (apn == '%s')", apn);
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_remove SQL statememt: %s\n", str);
+
+       // remove the row
+       err = sqlite3_exec(db, str, 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_remove: sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_sqlite_remove: sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+
+// remove a registration
+int vgsm_gprs_database_remove(GprsDbEntry *entry)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_remove\n");
+
+       // remove the registration from the database
+       return vgsm_gprs_sqlite_remove(entry->apn);
+}
+
+
+// callback to handle each row from "SELECT ALL * FROM gprs"
+// where each row is a persistent registration
+static int vgsm_gprs_sqlite_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       int temp, num;
+       struct in_addr tmp_addr;
+       GprsDbEntry *pentry;
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_restore callback apn=%s intf=%s cid=%u,\nfield=%u, ip=%u pdns=%u\nsdns=%u gateway=%u subnetmask=%u\n",
+                       *cols, *(cols+1), atoi(*(cols+2)), atoi(*(cols+3)),
+                       atoi(*(cols+4)), atoi(*(cols+5)), atoi(*(cols+6)), atoi(*(cols+7)), atoi(*(cols+8)));
+
+       g_gprs_tmp_conflist.num++;
+       num = g_gprs_tmp_conflist.num;
+
+       g_gprs_tmp_conflist.pentry = realloc(g_gprs_tmp_conflist.pentry, num * sizeof(GprsDbEntry));
+
+       if (g_gprs_tmp_conflist.pentry == NULL) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_sqlite_restore callback error\n");
+               return -1;
+       }
+
+       pentry = &(g_gprs_tmp_conflist.pentry[num - 1]);
+
+       strcpy(pentry->apn, *cols);
+       strcpy(pentry->intf, *(cols + 1));
+       pentry->ipconf.cid = atoi(*(cols + 2));
+       pentry->ipconf.fieldflag = atoi(*(cols + 3));
+
+       temp = atoi(*(cols + 4));
+       memcpy(pentry->ipconf.ip_addr, &temp, 4);
+       tmp_addr.s_addr = temp;
+       log_msg(MSGL_VGSM_INFO,"ip(%u:%s) \n" , temp, inet_ntoa(tmp_addr));
+
+       temp = atoi(*(cols + 5));
+       memcpy(pentry->ipconf.primary_dns, &temp, 4);
+       tmp_addr.s_addr = temp;
+       log_msg(MSGL_VGSM_INFO,"pdns(%u:%s) \n" , temp, inet_ntoa(tmp_addr));
+
+       temp = atoi(*(cols + 6));
+       memcpy(pentry->ipconf.secondary_dns, &temp, 4);
+       tmp_addr.s_addr = temp;
+       log_msg(MSGL_VGSM_INFO,"sdns(%u:%s) \n" , temp, inet_ntoa(tmp_addr));
+
+       temp = atoi(*(cols + 7));
+       memcpy(pentry->ipconf.default_gateway, &temp, 4);
+       tmp_addr.s_addr = temp;
+       log_msg(MSGL_VGSM_INFO,"gateway(%u:%s) \n" , temp, inet_ntoa(tmp_addr));
+
+       temp = atoi(*(cols + 8));
+       memcpy(pentry->ipconf.subnet_mask, &temp, 4);
+       tmp_addr.s_addr = temp;
+       log_msg(MSGL_VGSM_INFO,"subnet(%u:%s) \n" , temp, inet_ntoa(tmp_addr));
+
+       // should always return zero from the callback
+       return 0;
+
+}
+
+
+// restore all previously save registrations
+int vgsm_gprs_database_restore(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       int num, i;
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_restore\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_GPRS_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       if (g_gprs_tmp_conflist.pentry) {
+               free(g_gprs_tmp_conflist.pentry);
+               g_gprs_tmp_conflist.pentry = NULL;
+               g_gprs_tmp_conflist.num = 0;
+       }
+
+       // open the database
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_database_restore: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // dump all the rows
+       err = sqlite3_exec(db, "SELECT ALL * FROM gprs", vgsm_gprs_sqlite_restore_callback, 0, &mesg);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_gprs_database_restore: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_gprs_database_restore: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+
+               goto Done;
+       }
+
+       if (g_gprs_conflist.pentry) {
+               free(g_gprs_conflist.pentry);
+               g_gprs_conflist.pentry = NULL;
+               g_gprs_conflist.num = 0;
+       }
+
+       num = g_gprs_tmp_conflist.num;
+       g_gprs_conflist.num = num;
+
+       if ((g_gprs_conflist.pentry = (GprsDbEntry *)malloc(num * sizeof(GprsDbEntry))) == 0)
+               return -1;
+
+       for (i = 0; i < num; i++) {
+               memcpy(&(g_gprs_conflist.pentry[i]), &(g_gprs_tmp_conflist.pentry[i]), sizeof(GprsDbEntry));
+       }
+
+Done:
+
+       if (g_gprs_tmp_conflist.pentry) {
+               free(g_gprs_tmp_conflist.pentry);
+               g_gprs_tmp_conflist.pentry = 0;
+               g_gprs_tmp_conflist.num = 0;
+       }
+
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+
+// end of file
+
diff --git a/vmodem/db/db_network.c b/vmodem/db/db_network.c
new file mode 100644 (file)
index 0000000..51ec48f
--- /dev/null
@@ -0,0 +1,428 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ * HyunGoo Kang <hyungoo1.kang@samsung.com>
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "vgsm_network.h"
+#include "state.h"
+#include "db_network.h"
+#include "server_common_network.h"
+#include "logmsg.h"
+#include "fileio.h"
+
+#define ALP_NOTIFY_DATABASE_DIR  "./db"
+#define ALP_NOTIFY_DATABASE_FILE "network.db"
+#define ALP_NOTIFY_DATABASE_MODE (S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG)
+
+
+// ----------------------------------------------------------------------------
+// sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+#include <sqlite3.h>
+
+
+gsm_network_plmn_list_t g_tmp_plmn_list = {0, NULL};
+extern gsm_network_plmn_list_t g_plmn_list;
+
+
+
+// callback to handle each row from "SELECT ALL * FROM network"
+// where each row is a persistent registration
+static int vgsm_network_sqlite_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       gsm_network_plmn_record_t *rec;
+       int num_rec;
+               
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_restore callback PLMN_status=%i PLMN_id=%s ACT=%d\n",
+                                                    atoi(*cols),*(cols+1), atoi(*(cols+2)));
+
+       g_tmp_plmn_list.num_record++;
+       num_rec = g_tmp_plmn_list.num_record;
+       
+       g_tmp_plmn_list.precord = realloc(g_tmp_plmn_list.precord, num_rec * sizeof(gsm_network_plmn_record_t));
+
+       if (g_tmp_plmn_list.precord == NULL) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_restore callback error\n");
+               return -1;
+       }
+
+       rec = (g_tmp_plmn_list.precord + (num_rec - 1));
+
+       rec->status = atoi(*cols);
+       memcpy(rec->plmn, *(cols+1), sizeof(rec->plmn));
+       rec->act = atoi(*(cols+2));
+       
+       // should always return zero from the callback
+       return 0;
+}
+
+// initialize the database
+// create the network table
+static int vgsm_network_sqlite_init(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char directory[256];
+       char dbname[256];
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_init\n");
+
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+       
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR)) {
+               log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_init: "
+                       "directory %s does not exit or is not directory\n",
+                       directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS)) {
+                       if (g_remove (directory) < 0) {
+                               log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_init: "
+                                       "unable to remove %s: %d %s\n",
+                                       directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+        /* create directory */
+        if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0) {
+            /* unable to create directory */
+            log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_init: "
+                   "unable to create %s: %d %s\n",
+                   directory, errno, strerror(errno));
+
+            err = errno;
+            goto Done;
+        }
+    }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_init: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the table
+       err = sqlite3_exec(db,"CREATE TABLE network (PLMN_status INT, PLMN_id TEXT, ACT INT)",0,0,&mesg);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"sqlite3_exec: %s\n",mesg);
+                       sqlite3_exec(db,"TRUNCATE TABLE network",0,0,&mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE: err;
+}
+
+// add a new registration to the database
+// insert a row into the database which contains the registration information
+static int vgsm_network_sqlite_add(int  id, int  PLMN_status, char *number_PLMN, int ACT)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+       char temp[100];
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_add\n");
+
+       char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if(err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_add: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       memcpy(temp, number_PLMN, 6);
+       temp[6] = 0;
+       
+       // create the sql string
+       sprintf(str,"INSERT INTO network VALUES (%d,'%s',%d)", PLMN_status, temp, ACT);
+
+       log_msg(MSGL_VGSM_INFO," SQL statement : %s\n", str);
+
+       // add a row 
+       err = sqlite3_exec(db, str, 0, 0, &mesg);
+       if(err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_add: sqlite3_exec err=%d\n",err);
+
+               if(mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_add: sqlite3_exec: %s\n",mesg);
+                       
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+// remove a registration from the database
+// delete a row from the database which contains the registration information
+static int vgsm_network_sqlite_remove(int id, char *number_PLMN)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+       char temp[100];
+
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_remove\n");
+
+       char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_remove: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       memcpy(temp, number_PLMN, 6);
+       temp[6] = 0;
+
+       // create the sql string
+       sprintf(str, "DELETE FROM network WHERE (PLMN_id == '%s')", temp);
+
+       // remove the row
+       err = sqlite3_exec(db, str, 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_remove: sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_remove: sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       
+Done:
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+// restore all previously save registrations
+// select all rows and process each one in the callback
+static int vgsm_network_sqlite_restore(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       int num_rec;
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_restore\n");
+
+       char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+
+       if (g_tmp_plmn_list.precord) {
+               free(g_tmp_plmn_list.precord);
+               g_tmp_plmn_list.precord = NULL;
+               g_tmp_plmn_list.num_record = 0;
+       }
+       
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_restore: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // dump all the rows
+       err = sqlite3_exec(db, "SELECT ALL * FROM network", vgsm_network_sqlite_restore_callback, 0, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_ERR,"vgsm_network_sqlite_restore: sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_network_sqlite_restore: sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               
+               goto Done;
+       }
+
+       if (g_plmn_list.num_record > 0) {
+               free(g_plmn_list.precord);
+
+               g_plmn_list.precord = NULL;
+               g_plmn_list.num_record = 0;
+       }
+
+       num_rec = g_tmp_plmn_list.num_record;
+       g_plmn_list.num_record = num_rec;
+       g_plmn_list.precord = malloc(num_rec * sizeof(gsm_network_plmn_record_t));
+       memcpy(g_plmn_list.precord, g_tmp_plmn_list.precord, sizeof(gsm_network_plmn_record_t) * num_rec);
+       
+Done:
+
+       if (g_tmp_plmn_list.precord) {
+               free(g_tmp_plmn_list.precord);
+               
+               g_tmp_plmn_list.precord = NULL;
+               g_tmp_plmn_list.num_record = 0;
+       }
+               
+       // close the database
+       if (db)
+               sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+}
+
+// ----------------------------------------------------------------------------
+// end of sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+// initialize the database
+int vgsm_network_database_init(void)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_database_init\n");
+
+       // initialize the database
+       return vgsm_network_sqlite_init();
+}
+
+// add a registration
+int vgsm_network_database_add(NetworkEntry * entry)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_database_add\n");
+
+/*
+       // don't save server registrations
+       if (entry->callback) {
+               log_msg(MSGL_VGSM_INFO," there is NO callback function, do NOTHING !!!!|n");
+               return TRUE;
+               }
+*/
+       // add the registration to the database
+       return vgsm_network_sqlite_add(entry->id, entry->PLMN_status, entry->number_PLMN, entry->ACT);
+}
+
+// remove a registration
+int vgsm_network_database_remove(NetworkEntry * entry)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_database_remove\n");
+
+       // remove the registration from the database
+       return vgsm_network_sqlite_remove(entry->id, entry->number_PLMN);
+}
+
+// restore all previously save registrations
+int vgsm_network_database_restore(void)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_network_database_restore\n");
+       return vgsm_network_sqlite_restore();
+}
+
+#if 0
+void main(){
+
+       NetworkEntry  entry;
+       char  act[10]="CDMA";
+       
+       
+       
+
+       vgsm_network_sqlite_init();
+
+
+       entry.id=9;
+       entry.number_PLMN=8888;
+       entry.PLMN_status=5;
+       entry.ACT=act;
+       entry.callback=NULL;
+
+
+
+       vgsm_network_database_add(&entry);
+
+       vgsm_network_database_restore();
+       
+       vgsm_network_database_remove(&entry);
+
+       vgsm_network_database_restore();
+
+
+}
+#endif
+
diff --git a/vmodem/db/db_phonebook.c b/vmodem/db/db_phonebook.c
new file mode 100644 (file)
index 0000000..510e8a8
--- /dev/null
@@ -0,0 +1,1378 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*****************************************************************************/
+/*
+   Developed by: lucky29.park
+  Last update : 2007.02.13
+ */
+/*****************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "vgsm_phone.h"
+#include "vgsm_pb.h"
+#include "server_common_security.h"
+#include "db/db_phonebook.h"
+#include "server_tx_phonebook.h"
+#include "fileio.h"
+#define ALP_NOTIFY_DATABASE_DIR  "./db"
+#define ALP_NOTIFY_DATABASE_FILE "pb.db"
+#define ALP_NOTIFY_DATABASE_MODE (S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG)
+
+
+// ----------------------------------------------------------------------------
+// sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+int g_cnt=-1;
+int g_setted_storage=-1;
+int ii_cnt=0;
+PB *g_pb=NULL;
+//090724
+int isdata=0;                                  // 0 : There isn't data, 1 : There is data
+
+//080117 -for synch both of libvgsm and vgsm db part.
+PB_ST_type _convert_pbtype_to_dbtype(gsm_pb_storage_type_e_type storage_type);
+
+int db_sim_pb_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       SIM_DEBUG("ncol : %d \n", ncol);
+
+       if(ii_cnt==0)
+       {
+               g_pb = malloc(sizeof(PB) * g_cnt);
+               memset(g_pb,0,sizeof(PB) * g_cnt);
+       }
+
+       //g_pb[ii_cnt].index = atoi(*(cols));
+       memcpy(g_pb[ii_cnt].name, *(cols), strlen(*(cols)));
+       memcpy(g_pb[ii_cnt].number, *(cols+1), strlen(*(cols+1)));
+       memcpy(g_pb[ii_cnt].address, *(cols+2), strlen(*(cols+2)));
+       SIM_DEBUG("1.\n");
+
+       ii_cnt++;
+
+       return 0;
+}
+
+
+int db_sim_pb_get_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       SIM_DEBUG(" \n");
+
+       int *storage = (int *)ref;
+
+       PB *pb;
+       pb = malloc(sizeof(PB));
+
+       memset(pb,0,sizeof(PB));
+
+       SIM_DEBUG("ncol : %d \n", ncol);
+
+       pb->db_st_type = *storage;
+       //pb->index= atoi(*(cols));
+       memcpy(pb->name, *(cols), strlen(*(cols)));
+       memcpy(pb->number, *(cols+1), strlen(*(cols+1)));
+       memcpy(pb->address, *(cols+2), strlen(*(cols+2)));
+
+       //tx, ui shoot
+       server_tx_sim_pb_get_access_RX_UI(pb,0);
+
+       free( pb);
+
+       return 0;
+}
+
+//090723
+static int db_sim_pb_get_callback_check(void * ref, int ncol, char ** cols, char ** name)
+{
+       int cmp=1;
+
+       SIM_DEBUG("col : %s \n", *cols);
+
+       isdata=1;               // 1 : There is data.
+
+       return cmp;
+}
+
+int db_sim_pb_cnt_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       g_cnt = atoi(*(cols));
+       return 0;
+}
+
+
+int db_sim_pb_setted_storage_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+
+       g_setted_storage = atoi(*(cols));
+       return 0;
+}
+
+
+// initialize the database
+// create the phonebook table
+int db_sim_pb_create(void)
+{
+       sqlite3 * db = 0;
+       int err,err2,err3,err4,err5,err6,err7,err8,err9,err10,err11,err12,err13;
+       char * mesg;
+       char str[1000];
+
+       err=err2=err3=err4=err5=err6=err7=err8=err9=err10=err11=err12=err13=SQLITE_OK;
+
+       SIM_DEBUG("\n");
+
+       char directory[256];
+       char dbname[256];
+
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR))
+       {
+               SIM_DEBUG("directory %s does not exit or is not directory\n", directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS))
+               {
+                       if (g_remove (directory) < 0)
+                       {
+                               SIM_DEBUG("unable to remove %s: %d %s\n", directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0)
+               {
+                       /* unable to create directory */
+                       SIM_DEBUG("unable to create %s: %d %s\n", directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       //create set st table
+       err = sqlite3_exec(db,"CREATE TABLE setted_st (setted_storage INT)",0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_setted_st create err=%d\n",err);
+               goto Done;
+       }
+
+       sprintf(str,"INSERT INTO setted_st VALUES (%d)",0);
+
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       memset(str,0,1000);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_setted_st INSERT err=%d\n",err);
+
+               goto Done;
+       }
+
+
+       // create the table
+       err = sqlite3_exec(db,"CREATE TABLE st_fdn (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err == SQLITE_OK)
+               err2 = sqlite3_exec(db,"CREATE TABLE st_ldn (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err2 == SQLITE_OK)
+               err3 = sqlite3_exec(db,"CREATE TABLE st_own (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err3 == SQLITE_OK)
+               err4 = sqlite3_exec(db,"CREATE TABLE st_adn (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err4 == SQLITE_OK)
+               err5 = sqlite3_exec(db,"CREATE TABLE st_sdn (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       ///////////////////////////////////////
+       if (err5 == SQLITE_OK)
+               err6 = sqlite3_exec(db,"CREATE TABLE st_dc (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err6 == SQLITE_OK)
+               err7 = sqlite3_exec(db,"CREATE TABLE st_en (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err7 == SQLITE_OK)
+               err8 = sqlite3_exec(db,"CREATE TABLE st_mc (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err8 == SQLITE_OK)
+               err9 = sqlite3_exec(db,"CREATE TABLE st_me (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err9 == SQLITE_OK)
+               err10 = sqlite3_exec(db,"CREATE TABLE st_mt (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+
+       if (err10 == SQLITE_OK)
+               err11 = sqlite3_exec(db,"CREATE TABLE st_rc (name VARCHAR(30) , number VARCHAR(20),Address VARCHAR(30))",0,0,&mesg);
+       ///////////////////////////////////////
+
+       if (err11 == SQLITE_OK)
+       {
+               err12 = sqlite3_exec(db,"CREATE TABLE count_ (st_fdn INT, st_ldn INT, st_own INT, st_adn INT, st_sdn INT, st_dc INT, st_en INT,st_mc INT,st_me INT,st_mt INT,st_rc INT )",0,0,&mesg);
+
+               sprintf(str,"INSERT INTO count_ VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",0,0,0,0,0,0,0,0,0,0,0);
+               err13 = sqlite3_exec(db,str,0,0,&mesg);
+       }
+
+
+       if (    err != SQLITE_OK ||err2!= SQLITE_OK ||err3 != SQLITE_OK ||err4 != SQLITE_OK ||err5 != SQLITE_OK ||
+               err6 != SQLITE_OK ||err7 != SQLITE_OK || err8 != SQLITE_OK|| err9 != SQLITE_OK|| err10 != SQLITE_OK||
+               err11 != SQLITE_OK ||err12 != SQLITE_OK ||err13 != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err\n");
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+}
+
+// add a new registration to the database
+// insert a row into the database which contains the registration information
+int db_sim_pb_add(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+
+       SIM_DEBUG("\n  db_sim_pb_add : %d , %s ,%s, %s",pb->db_st_type,pb->name,pb->number,pb->address);
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       SIM_DEBUG("name, strlen : %s, %d", pb->name,strlen(pb->name));
+       db_sim_pb_get_check(pb);
+
+       if(isdata == 1)
+       {
+               SIM_DEBUG("\nThere is same data in Phonebook\n");
+               // callback
+               callback_pb_action(pb);
+               isdata=0;
+               SIM_DEBUG("\ncalling callback_pb_action is succeeded\n");
+               return 0;
+       }
+       isdata=0;
+
+       SIM_DEBUG("\n");
+       SIM_DEBUG("\nThere isn't same data in Phonebook\n");
+
+
+       //get setted Storage
+       if(pb->db_st_type == DB_REQ)
+               pb->db_st_type =db_sim_pb_set_mgr(0,0);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       //
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       db_sim_pb_cnt_mgr(db,DB_FDN,1);
+                       sprintf(str,"INSERT INTO st_fdn VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_LDN:
+                       db_sim_pb_cnt_mgr(db,DB_LDN,1);
+                       sprintf(str,"INSERT INTO st_ldn VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                               break;
+
+               case DB_OWN:
+                       db_sim_pb_cnt_mgr(db,DB_OWN,1);
+                       sprintf(str,"INSERT INTO st_own VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_ADN:
+                       db_sim_pb_cnt_mgr(db,DB_ADN,1);
+                       sprintf(str,"INSERT INTO st_adn VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_SDN:
+                       db_sim_pb_cnt_mgr(db,DB_SDN,1);
+                       sprintf(str,"INSERT INTO st_sdn VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_DC:
+                       db_sim_pb_cnt_mgr(db,DB_DC,1);
+                       sprintf(str,"INSERT INTO st_dc VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_EN:
+                       db_sim_pb_cnt_mgr(db,DB_EN,1);
+                       sprintf(str,"INSERT INTO st_en VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_MC:
+                       db_sim_pb_cnt_mgr(db,DB_MC,1);
+                       sprintf(str,"INSERT INTO st_mc VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_ME:
+                       db_sim_pb_cnt_mgr(db,DB_ME,1);
+                       sprintf(str,"INSERT INTO st_me VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_MT:
+                       db_sim_pb_cnt_mgr(db,DB_MT,1);
+                       sprintf(str,"INSERT INTO st_mt VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               case DB_RC:
+                       db_sim_pb_cnt_mgr(db,DB_RC,1);
+                       sprintf(str,"INSERT INTO st_rc VALUES ('%s','%s','%s')",pb->name,pb->number,pb->address);
+                       break;
+
+               default:
+                       break;
+
+       }
+
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       // add a row
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       else
+       {
+               server_tx_sim_pb_get_access_RX_UI(pb,1);
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+}
+
+
+#if 0
+// update using selected index value.
+int db_sim_pb_edit(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       //get setted Storage
+       if(pb->db_st_type == DB_REQ)
+               pb->db_st_type =db_sim_pb_set_mgr(0,0);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       //
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       db_sim_pb_cnt_mgr(db,DB_FDN,1);
+                       sprintf(str,"UPDATE st_fdn SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_fdn SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_LDN:
+                       db_sim_pb_cnt_mgr(db,DB_LDN,1);
+                       sprintf(str,"UPDATE st_ldn SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_ldn SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_OWN:
+                       db_sim_pb_cnt_mgr(db,DB_OWN,1);
+                       sprintf(str,"UPDATE st_own SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_own SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_ADN:
+                       db_sim_pb_cnt_mgr(db,DB_ADN,1);
+                       sprintf(str,"UPDATE st_adn SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_adn SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_SDN:
+                       db_sim_pb_cnt_mgr(db,DB_SDN,1);
+                       sprintf(str,"UPDATE st_sdn SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_sdn SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_DC:
+                       db_sim_pb_cnt_mgr(db,DB_DC,1);
+                       sprintf(str,"UPDATE st_dc SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_dc SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_EN:
+                       db_sim_pb_cnt_mgr(db,DB_EN,1);
+                       sprintf(str,"UPDATE st_en SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_en SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_MC:
+                       db_sim_pb_cnt_mgr(db,DB_MC,1);
+                       sprintf(str,"UPDATE st_mc SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_mc SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_ME:
+                       db_sim_pb_cnt_mgr(db,DB_ME,1);
+                       sprintf(str,"UPDATE st_me SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_me SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_MT:
+                       db_sim_pb_cnt_mgr(db,DB_MT,1);
+                       sprintf(str,"UPDATE st_mt SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_mt SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               case DB_RC:
+                       db_sim_pb_cnt_mgr(db,DB_RC,1);
+                       sprintf(str,"UPDATE st_rc SET name = '%s', number = '%s', address = '%s' WHERE name = '%s'",pb->name,pb->number,pb->address,pb->name);
+                       //sprintf(str,"UPDATE st_rc SET name = '%s', number = '%s' WHERE index_ = %d",pb->name,pb->number,pb->index);
+                       break;
+
+               default:
+                       break;
+
+       }
+
+       // update a row
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       else
+       {
+               server_tx_sim_pb_get_access_RX_UI(pb,1);
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+}
+#endif
+
+
+// remove a registration from the database
+// delete a row from the database which contains the registration information
+ int db_sim_pb_remove(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /////////////////////
+       //090723
+       SIM_DEBUG("name, strlen : %s, %d", pb->name,strlen(pb->name));
+       db_sim_pb_get_check(pb);
+
+       if(isdata != 1)
+       {
+               SIM_DEBUG("\nThere isn't same data in Phonebook\n");
+               SIM_DEBUG("\n1. isdata : %d\n", isdata);
+               // callback
+               //callback_pb_action(pb);
+               isdata=0;
+               return 0;
+       }
+
+       SIM_DEBUG("\nThere is same data in Phonebook\n");
+       SIM_DEBUG("\n2. isdata : %d\n", isdata);
+       isdata=0;
+       SIM_DEBUG("\n3. isdata(after init) : %d\n", isdata);
+       ////////////////////
+
+       //get setted Storage
+       if(pb->db_st_type == DB_REQ)
+               pb->db_st_type  =       db_sim_pb_set_mgr(0,0);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       //
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       db_sim_pb_cnt_mgr(db,DB_FDN,2);
+                       sprintf(str,"DELETE FROM st_fdn WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_fdn WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_LDN:
+                       db_sim_pb_cnt_mgr(db,DB_LDN,2);
+                       sprintf(str,"DELETE FROM st_ldn WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_ldn WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_OWN:
+                       db_sim_pb_cnt_mgr(db,DB_OWN,2);
+                       sprintf(str,"DELETE FROM st_own WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_own WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_ADN:
+                       db_sim_pb_cnt_mgr(db,DB_ADN,2);
+                       sprintf(str,"DELETE FROM st_adn WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_adn WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_SDN:
+                       db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       sprintf(str,"DELETE FROM st_sdn WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_sdn WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_DC:
+                       db_sim_pb_cnt_mgr(db,DB_DC,1);
+                       sprintf(str,"DELETE FROM st_dc WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_dc WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_EN:
+                       db_sim_pb_cnt_mgr(db,DB_EN,1);
+                       sprintf(str,"DELETE FROM st_en WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_en WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_MC:
+                       db_sim_pb_cnt_mgr(db,DB_MC,1);
+                       sprintf(str,"DELETE FROM st_mc WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_mc WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_ME:
+                       db_sim_pb_cnt_mgr(db,DB_ME,1);
+                       sprintf(str,"DELETE FROM st_me WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_me WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_MT:
+                       db_sim_pb_cnt_mgr(db,DB_MT,1);
+                       sprintf(str,"DELETE FROM st_mt WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_mt WHERE index_ = %d",pb->index);
+                       break;
+
+               case DB_RC:
+                       db_sim_pb_cnt_mgr(db,DB_RC,1);
+                       sprintf(str,"DELETE FROM st_rc WHERE name = '%s'",pb->name);
+                       //sprintf(str,"DELETE FROM st_rc WHERE index_ = %d",pb->index);
+                       break;
+
+               default:
+                       break;
+
+       }
+
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       // add a row
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       //if(pb)
+               //free(pb);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       else
+       {
+               server_tx_sim_pb_get_access_RX_UI(pb,2);
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+
+}
+
+
+int db_sim_pb_cnt_mgr(sqlite3 * db, int pb_type, int action)
+{
+       int err;
+       char str[1000];
+       char str2[1000];
+       char * mesg;
+       char tb_name[6];
+       int flag=0;
+
+       SIM_DEBUG("\n");
+
+       if(db == NULL)
+       {
+               char dbname[256];
+
+               char *bin_path = get_bin_path();
+               sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+               if (bin_path)
+                       g_free(bin_path);
+
+               // open the database
+               err = sqlite3_open(dbname,&db);
+
+               if (err != SQLITE_OK)
+               {
+                       SIM_DEBUG("sqlite3_open err=%d\n",err);
+                       return -1;
+               }
+
+               flag =1;  //if called db poiter is NULL
+       }
+
+       //set table name for query
+       switch(pb_type)
+       {
+               case DB_FDN:
+                       sprintf(tb_name,"st_fdn");
+                       break;
+
+               case DB_LDN:
+                       sprintf(tb_name,"st_ldn");
+                       break;
+
+               case DB_OWN:
+                       sprintf(tb_name,"st_own");
+                       break;
+
+               case DB_ADN:
+                       sprintf(tb_name,"st_adn");
+                       break;
+
+               case DB_SDN:
+                       sprintf(tb_name,"st_sdn");
+                       break;
+
+               case DB_DC:
+                       sprintf(tb_name,"st_dc");
+                       break;
+
+               case DB_EN:
+                       sprintf(tb_name,"st_en");
+                       break;
+
+               case DB_MC:
+                       sprintf(tb_name,"st_mc");
+                       break;
+
+               case DB_ME:
+                       sprintf(tb_name,"st_me");
+                       break;
+
+               case DB_MT:
+                       sprintf(tb_name,"st_mt");
+                       break;
+
+               case DB_RC:
+                       sprintf(tb_name,"st_rc");
+                       break;
+
+               default:
+                       break;
+       }
+
+
+       sprintf(str2,"SELECT %s FROM count_", tb_name);
+       err = sqlite3_exec(db,str2,db_sim_pb_cnt_callback,0,&mesg);
+       SIM_DEBUG("SQL statement : %s\n", str2);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec SELECT  err=%d\n",err);
+               return -1;
+       }
+       else
+       {
+               // actions
+               if(action == GSM_PB_MODE_READ || action == GSM_PB_MODE_EDIT)
+                       return g_cnt;
+               else if(action == GSM_PB_MODE_ADD)
+                       g_cnt++;
+               else if(action == GSM_PB_MODE_DEL)
+               {
+                       if(g_cnt!=0)
+                               g_cnt--;
+               }
+
+               sprintf(str,"UPDATE count_ SET %s = %d",tb_name, g_cnt);
+               SIM_DEBUG("SQL statement : %s\n", str);
+               err = sqlite3_exec(db,str,0,0,&mesg);
+
+               if (err != SQLITE_OK)
+               {
+                       SIM_DEBUG("sqlite3_exec err=%d\n",err);
+                       return -1;
+               }
+       }
+
+        // free db
+       if(flag ==1)
+       {
+               if (db)sqlite3_close(db);
+       }
+
+       return g_cnt;
+}
+
+
+int db_sim_pb_set_mgr(int pb_type,int action)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("db_sim_pb_set_mgr: sqlite3_open err=%d\n",err);
+
+               return -1;
+       }
+
+       // action  =>   0 is get ,   1 is  set
+       if(action == 0) //get
+       {
+               err = sqlite3_exec(db,"SELECT setted_storage  FROM setted_st", db_sim_pb_setted_storage_callback, 0, &mesg);
+
+               if (err != SQLITE_OK)
+                       SIM_DEBUG("sqlite3_exec SELECT  err=%d\n",err);
+
+               //close db
+               if (db) sqlite3_close(db);
+
+               if(g_setted_storage == -1)
+               {
+                       SIM_DEBUG("ERROR.  g_setted_storage \n");
+                       return -1;
+               }
+
+               return g_setted_storage;
+       }
+       else if(action == 1)    //set
+       {
+               sprintf(str,"UPDATE setted_st SET setted_storage = %d", pb_type);
+               err = sqlite3_exec(db, str, 0, 0, &mesg);
+
+               SIM_DEBUG("SQL statement : %s\n", str);
+
+               if (err != SQLITE_OK)
+                       SIM_DEBUG("sqlite3_exec err=%d\n",err);
+       }
+
+       // close the database
+       if (db) sqlite3_close(db);
+
+       return 1;
+}
+
+
+// restore all previously save registrations
+// select all rows and process each one in the callback
+int db_sim_pb_restore(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       db_sim_pb_cnt_mgr(db,DB_FDN,0);
+                       sprintf(str,"SELECT ALL * FROM st_fdn ");
+                       break;
+
+               case DB_LDN:
+                       db_sim_pb_cnt_mgr(db,DB_LDN,0);
+                       sprintf(str,"SELECT ALL * FROM st_ldn ");
+                       break;
+
+               case DB_OWN:
+                       db_sim_pb_cnt_mgr(db,DB_OWN,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_own ");
+                       break;
+
+               case DB_ADN:
+                       db_sim_pb_cnt_mgr(db,DB_ADN,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_adn ");
+                       break;
+
+               case DB_SDN:
+                       db_sim_pb_cnt_mgr(db,DB_SDN,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_sdn ");
+                       break;
+
+               case DB_DC:
+                       db_sim_pb_cnt_mgr(db,DB_DC,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_dc ");
+                       break;
+
+               case DB_EN:
+                       db_sim_pb_cnt_mgr(db,DB_EN,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_en ");
+                       break;
+
+               case DB_MC:
+                       db_sim_pb_cnt_mgr(db,DB_MC,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_MC ");
+                       break;
+
+               case DB_ME:
+                       db_sim_pb_cnt_mgr(db,DB_ME,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_me ");
+                       break;
+
+               case DB_MT:
+                       db_sim_pb_cnt_mgr(db,DB_MT,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_mt ");
+                       break;
+
+               case DB_RC:
+                       db_sim_pb_cnt_mgr(db,DB_RC,0);
+                       // create the sql string
+                       sprintf(str,"SELECT ALL * FROM st_rc ");
+                       break;
+
+               default :
+                       SIM_DEBUG("\n*DEFAULT*\n");
+                       break;
+       }
+
+       // dump all the rows
+
+       if(g_pb)
+       {
+               free(g_pb);
+               g_pb=NULL;
+       }
+
+       SIM_DEBUG(" SQL statement : %s\n", str);
+       err = sqlite3_exec(db,str,db_sim_pb_restore_callback,0,&mesg);
+
+       if(g_pb)
+       {
+               g_pb[0].db_st_type = pb->db_st_type;
+               g_pb[0].cnt =g_cnt;
+               ii_cnt=0;
+
+               server_tx_sim_pb_get_all_db(g_pb,g_cnt);
+       }
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+}
+
+////////////////////////////////////
+
+int db_sim_pb_get_check(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       //get setted Storage
+       if(pb->db_st_type == DB_REQ)
+               pb->db_st_type =db_sim_pb_set_mgr(0,0);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       sprintf(str,"SELECT * FROM st_fdn WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_LDN:
+                       sprintf(str,"SELECT * FROM st_ldn WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_OWN:
+                       sprintf(str,"SELECT * FROM st_own WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_ADN:
+                       sprintf(str,"SELECT * FROM st_adn WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_SDN:
+                       sprintf(str,"SELECT * FROM st_sdn WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_DC:
+                       sprintf(str,"SELECT * FROM st_dc WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_EN:
+                       sprintf(str,"SELECT * FROM st_en WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_MC:
+                       sprintf(str,"SELECT * FROM st_mc WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_ME:
+                       sprintf(str,"SELECT * FROM st_me WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_MT:
+                       sprintf(str,"SELECT * FROM st_mt WHERE (name = '%s')",pb->name);
+                       break;
+
+               case DB_RC:
+                       sprintf(str,"SELECT * FROM st_rc WHERE (name = '%s')",pb->name);
+                       break;
+
+               default :
+                       break;
+
+       }
+
+       //get row
+       SIM_DEBUG(" \n 1.SQL statement : %s\n", str);
+       err = sqlite3_exec(db,str,db_sim_pb_get_callback_check,&pb->db_st_type,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       SIM_DEBUG(" \n 2.SQL statement : %s\n", str);
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+
+}
+////////////////////////////////////
+
+int db_sim_pb_get(PB *pb)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       //get setted Storage
+       if(pb->db_st_type == DB_REQ)
+               pb->db_st_type =db_sim_pb_set_mgr(0,0);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       switch(pb->db_st_type)
+       {
+               case DB_FDN:
+                       //db_sim_pb_cnt_mgr(db,DB_FDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_fdn WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_fdn WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_LDN:
+                       //db_sim_pb_cnt_mgr(db,DB_LDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_ldn WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_ldn WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_OWN:
+                       //db_sim_pb_cnt_mgr(db,DB_OWN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_own WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_own WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_ADN:
+                       //db_sim_pb_cnt_mgr(db,DB_ADN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_adn WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_adn WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_SDN:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_sdn WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_sdn WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_DC:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_dc WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_dc WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_EN:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_en WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_en WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_MC:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_mc WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_mc WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_ME:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_me WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_me WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_MT:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_mt WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_mt WHERE (index_ == %d)",pb->index);
+                       break;
+
+               case DB_RC:
+                       //db_sim_pb_cnt_mgr(db,DB_SDN,2);
+                       // create the sql string
+                       sprintf(str,"SELECT * FROM st_rc WHERE (name = '%s')",pb->name);
+                       //sprintf(str,"SELECT * FROM st_rc WHERE (index_ == %d)",pb->index);
+                       break;
+
+               default :
+                       break;
+
+       }
+
+       //get row
+       SIM_DEBUG(" SQL statement : %s\n", str);
+       err = sqlite3_exec(db,str,db_sim_pb_get_callback,&pb->db_st_type,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? PB_SUCCESS : err;
+
+}
+
+
+//080117 - converting enum type from gsm_pb_storage_type_e_type in libvgsmSim.h to PB_ST_type inDb_pb.h
+PB_ST_type
+_convert_pbtype_to_dbtype(gsm_pb_storage_type_e_type storage_type)
+{
+       PB_ST_type      phonebook;
+       switch(storage_type)
+       {
+               case GSM_PB_ST_FD :
+                       phonebook       =        DB_FDN;
+                       break;
+               case GSM_PB_ST_LD :
+                       phonebook       =        DB_LDN;
+                       break;
+               case GSM_PB_ST_ON :
+                       phonebook       =        DB_OWN;
+                       break;
+               case GSM_PB_ST_SIM :
+                       phonebook       =        DB_ADN;
+                       break;
+               case GSM_PB_ST_SDN :
+                       phonebook       =        DB_SDN;
+                       break;
+               case GSM_PB_ST_DC :
+                       phonebook       =        DB_DC;
+                       break;
+               case GSM_PB_ST_EN :
+                       phonebook       =        DB_EN;
+                       break;
+               case GSM_PB_ST_MC :
+                       phonebook       =        DB_MC;
+                       break;
+               case GSM_PB_ST_ME :
+                       phonebook       =        DB_ME;
+                       break;
+               case GSM_PB_ST_MT :
+                       phonebook       =        DB_MT;
+                       break;
+               case GSM_PB_ST_RC :
+                       phonebook       =        DB_RC;
+                       break;
+               default :
+                       phonebook       =       DB_REQ;
+                       SIM_DEBUG("ERROR - not handled storage type=[%x] in PhoneBook DB\n", storage_type);
+                       break;
+       }
+
+       return phonebook;
+}
+
+// ----------------------------------------------------------------------------
+// end of sqlite3 specific code
+// ----------------------------------------------------------------------------
+
diff --git a/vmodem/db/db_security.c b/vmodem/db/db_security.c
new file mode 100644 (file)
index 0000000..1e3e402
--- /dev/null
@@ -0,0 +1,1380 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "state.h"
+#include "server_common_security.h"
+#include "vgsm_sim.h"
+#include "server_tx_security.h"
+#include "db_security.h"
+#include "fileio.h"
+
+#define ALP_NOTIFY_DATABASE_DIR  "./db"
+#define ALP_NOTIFY_DATABASE_FILE "sim.db"
+#define ALP_NOTIFY_DATABASE_FILE_INFO "sim_info.db"
+#define ALP_NOTIFY_DATABASE_FILE_DATA "sim_data.db"
+#define ALP_NOTIFY_DATABASE_MODE (S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG)
+
+// ----------------------------------------------------------------------------
+// sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+#include <sqlite3.h>
+
+
+struct db_sim_sql_callback_info
+{
+       unsigned char *data;
+       int len;
+};
+
+// for boot
+static int db_sim_info_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       struct db_sim_sql_callback_info *info = ref;
+       int i;
+
+       info->len = atoi(cols[0]);
+
+       SIM_DEBUG("db_sim_info_restore_callback ncol = %d len = %d \n", ncol, info->len);
+       for(i=1;i<ncol;i++)
+       {
+               //SIM_DEBUG("%s, %x\n", name[i], atoi(cols[i]));
+               info->data[i-1] = atoi(cols[i]);
+               //SIM_DEBUG(" @@@%x\n", info->data[i-1]);
+       }
+
+       return 0;
+}
+
+static const char *db_table_from_fileid(gsm_sec_sim_file_id_t file_id)
+{
+       switch(file_id)
+       {
+       case GSM_SEC_EFILE_ICCID : return "Ticcid";
+       case GSM_SEC_EFILE_USIM_LI : return "Tusim_li";
+       case GSM_SEC_EFILE_ECC : return "Tecc";
+       case GSM_SEC_EFILE_SST : return "Tsst";
+       case GSM_SEC_EFILE_EST : return "Test";
+       case GSM_SEC_EFILE_CPHS_CPHS_INFO : return "Tcphs";
+       case GSM_SEC_EFILE_SPN : return "Tspn";
+       case GSM_SEC_EFILE_IMSI : return "Timsi";
+       default:
+               return NULL;
+       }
+}
+
+static int db_read_from_database(
+               const char *filename, gsm_sec_sim_file_id_t file_id,
+               unsigned char* data, int *len)
+{
+    sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char dbname[256];
+       char query[256];
+       char *bin_path = get_bin_path();
+       struct db_sim_sql_callback_info info;
+       const char *table;
+
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, filename);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       SIM_DEBUG("\n");
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+           goto Done;
+       }
+
+       info.data = data;
+       info.len = 0;
+
+       // dump all the rows
+
+       table = db_table_from_fileid(file_id);
+       if (!table)
+               goto Done;
+
+       sprintf(query, "SELECT ALL * FROM %s", table);
+
+       SIM_DEBUG("file_id = %04x  query = %s\n", file_id, query);
+
+       err = sqlite3_exec(db, query, db_sim_info_restore_callback, &info, &mesg);
+
+       *len = info.len;
+
+    if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+    if (db)
+               sqlite3_close(db);
+
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+int _sim_get_file_info_tmp(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_info, /* out */ int *file_info_len/* out */)
+{
+       return db_read_from_database( ALP_NOTIFY_DATABASE_FILE_INFO, file_id, pfile_info, file_info_len);
+}
+
+int _sim_get_file_data_tmp(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_data, /* out */ int* file_data_len/* out */)
+{
+       return db_read_from_database( ALP_NOTIFY_DATABASE_FILE_DATA, file_id, pfile_data, file_data_len);
+}
+
+static int db_sim_info_callback(void * ref, int ncol, char ** cols, char ** name)              //called do_sim()
+{
+       int i, len;
+       unsigned char *sim_info;
+
+       SIM_DEBUG("\n\n1. in db_sim_info__callback \n\n");
+
+       len = atoi(*(cols));
+
+       sim_info = malloc(sizeof(unsigned char)*len);
+       memset(sim_info, 0, len);
+
+       SIM_DEBUG("ncol : %d \n", ncol);
+       SIM_DEBUG("len : %d \n", len);
+       for(i=1;i<ncol;i++)
+       {
+               SIM_DEBUG(" %s, %x\n", name[i], atoi(cols[i]));
+               sim_info[i-1] = (char)atoi(cols[i]);
+               SIM_DEBUG(" @@@%x\n", sim_info[i-1]);
+       }
+
+       server_tx_sim_info_get_db(sim_info, len);
+
+       return 0;
+}
+///////////////////////////////////////////////////////////////////////////////////
+
+
+// after 'select' sql statement,  put sec info(db info) into SimSecurity.
+int db_sim_sec_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       VGSM_SIMType * type = (VGSM_SIMType*)ref;
+
+       SimSecurity *sim_sec;
+
+       SIM_DEBUG("\n");
+
+       sim_sec = malloc(sizeof(SimSecurity));
+       memset(sim_sec,0,sizeof(SimSecurity));
+
+       SIM_DEBUG("ncol : %d \n", ncol);
+       SIM_DEBUG("pin_val =%s, puk_val = %s, pin2_val = %s, puk2_val = %s,pin_cnt = %d,pin2_cnt = %d,puk_cnt = %d,puk2_cnt = %d,sim_state = %d,facility_pin = %d,facility_fdn = %d lock_sc2_state = %d \n",
+                             *cols,*(cols+1), *(cols+2),*(cols+3),atoi(*(cols+4)),atoi(*(cols+5)),atoi(*(cols+6)),atoi(*(cols+7)),atoi(*(cols+8)),atoi(*(cols+9)),atoi(*(cols+10)),atoi(*(cols+11)));
+
+       memcpy(sim_sec->pin_value, *(cols), strlen(*(cols)));
+       memcpy(sim_sec->puk_value, *(cols+1), strlen(*(cols+1)));
+       memcpy(sim_sec->pin2_value, *(cols+2), strlen(*(cols+2)));
+       memcpy(sim_sec->puk2_value, *(cols+3), strlen(*(cols+3)));
+
+       sim_sec->pin_cnt                        =atoi(*(cols+4));
+       sim_sec->pin2_cnt                       =atoi(*(cols+5));
+       sim_sec->puk_cnt                        =atoi(*(cols+6));
+       sim_sec->puk2_cnt                       =atoi(*(cols+7));
+       sim_sec->sim_state                      =atoi(*(cols+8));
+       sim_sec->facility_pin           =atoi(*(cols+9));
+       sim_sec->facility_fdn           =atoi(*(cols+10));
+       sim_sec->lock_sc2_state         =atoi(*(cols+11));
+
+       /*
+       mem free is done in each case func
+       */
+       switch(*type)
+       {
+               case VGSM_SIMTypeLoad:
+                       server_sec_set_sec_db_info(sim_sec, ncol);
+                       break;
+
+               // it`s called by EI
+               case VGSM_SIMTypeget:
+                       server_tx_sim_sec_get_db(sim_sec);
+                       break;
+       }
+
+       return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+//090502
+// create the SIM info TABLE
+int db_sim_info_create(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       char directory[256];
+       char dbname[256];
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_INFO);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR))
+       {
+               SIM_DEBUG("directory %s does not exit or is not directory\n", directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS))
+               {
+                       if (g_remove (directory) < 0)
+                       {
+                               SIM_DEBUG("unable to remove %s: %d %s\n",directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0)
+               {
+                       /* unable to create directory */
+                       SIM_DEBUG("unable to create %s: %d %s\n", directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("db_sim_sec_create: sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       // create the table
+       err = sqlite3_exec(db,"CREATE TABLE Tusim_li ( len INT, usim_li1 INT, usim_li2 INT, usim_li3 INT, usim_li4 INT, usim_li5 INT, usim_li6 INT, usim_li7 INT, usim_li8 INT, usim_li9 INT, usim_li10 INT, usim_li11 INT, usim_li12 INT, usim_li13 INT, usim_li14 INT, usim_li15 INT, usim_li16 INT, usim_li17 INT, usim_li18 INT, usim_li19 INT, usim_li20 INT, usim_li21 INT, usim_li22 INT, usim_li23 INT, usim_li24 INT, usim_li25 INT, usim_li26 INT, usim_li27 INT, usim_li28 INT, usim_li29 INT, usim_li30 INT, usim_li31 INT, usim_li32 INT, usim_li33 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tecc ( len INT, ecc1 INT, ecc2 INT, ecc3 INT, ecc4 INT, ecc5 INT, ecc6 INT, ecc7 INT, ecc8 INT, ecc9 INT, ecc10 INT, ecc11 INT, ecc12 INT, ecc13 INT, ecc14 INT, ecc15 INT, ecc16 INT, ecc17 INT, ecc18 INT, ecc19 INT, ecc20 INT, ecc21 INT, ecc22 INT, ecc23 INT, ecc24 INT, ecc25 INT, ecc26 INT, ecc27 INT, ecc28 INT, ecc29 INT, ecc30 INT, ecc31 INT, ecc32 INT, ecc33 INT, ecc34 INT, ecc35 INT, ecc36 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tsst ( len INT,     sst1 INT, sst2 INT, sst3 INT, sst4 INT, sst5 INT, sst6 INT, sst7 INT, sst8 INT, sst9 INT, sst10 INT, sst11 INT, sst12 INT, sst13 INT, sst14 INT, sst15 INT, sst16 INT, sst17 INT, sst18 INT, sst19 INT, sst20 INT, sst21 INT, sst22 INT, sst23 INT, sst24 INT, sst25 INT, sst26 INT, sst27 INT, sst28 INT, sst29 INT, sst30 INT, sst31 INT, sst32 INT, sst33 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Test ( len INT, est1 INT, est2 INT, est3 INT, est4 INT, est5 INT, est6 INT, est7 INT, est8 INT, est9 INT, est10 INT, est11 INT, est12 INT, est13 INT, est14 INT, est15 INT, est16 INT, est17 INT, est18 INT, est19 INT, est20 INT, est21 INT, est22 INT, est23 INT, est24 INT, est25 INT, est26 INT, est27 INT, est28 INT, est29 INT, est30 INT, est31 INT, est32 INT, est33 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tcphs ( len INT, cphs_info1 INT, cphs_info2 INT, cphs_info3 INT)",0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tspn ( len INT,     spn1 INT, spn2 INT, spn3 INT, spn4 INT, spn5 INT, spn6 INT, spn7 INT, spn8 INT, spn9 INT, spn10 INT, spn11 INT, spn12 INT, spn13 INT, spn14 INT, spn15 INT, spn16 INT, spn17 INT, spn18 INT, spn19 INT, spn20 INT, spn21 INT, spn22 INT, spn23 INT, spn24 INT, spn25 INT, spn26 INT, spn27 INT, spn28 INT, spn29 INT, spn30 INT, spn31 INT, spn32 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Timsi ( len INT, imsi1 INT, imsi2 INT, imsi3 INT, imsi4 INT, imsi5 INT, imsi6 INT, imsi7 INT, imsi8 INT, imsi9 INT, imsi10 INT, imsi11 INT, imsi12 INT, imsi13 INT, imsi14 INT, imsi15 INT, imsi16 INT, imsi17 INT, imsi18 INT, imsi19 INT, imsi20 INT, imsi21 INT, imsi22 INT, imsi23 INT, imsi24 INT, imsi25 INT, imsi26 INT, imsi27 INT, imsi28 INT, imsi29 INT, imsi30 INT, imsi31 INT, imsi32 INT, imsi33 INT, imsi34 INT, imsi35 INT, imsi36 INT, imsi37 INT, imsi38 INT, imsi39 INT, imsi40 INT, imsi41 INT, imsi42 INT, imsi43 INT)"
+                       ,0,0,&mesg);
+
+       //err = sqlite3_exec(db,"CREATE TABLE sim_info ( usim_li VARCHAR(33), ecc VARCHAR(36), sst VARCHAR(33),est VARCHAR(33),cphs_cphs_info VARCHAR(3), spn VARCHAR(32), imsi VARCHAR(43))",0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               TRACE(MSGL_VGSM_ERR, "sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       TRACE(MSGL_VGSM_ERR, "sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS: err;
+}
+
+//090502
+// create the SIM data TABLE
+int db_sim_data_create(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       char directory[256];
+       char dbname[256];
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_DATA);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR))
+       {
+               SIM_DEBUG("directory %s does not exit or is not directory\n", directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS))
+               {
+                       if (g_remove (directory) < 0)
+                       {
+                               SIM_DEBUG("unable to remove %s: %d %s\n",directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0)
+               {
+                       /* unable to create directory */
+                       SIM_DEBUG("unable to create %s: %d %s\n", directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("db_sim_sec_create: sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       // create the table
+       err = sqlite3_exec(db,"CREATE TABLE Ticcid ( len INT, iccid1 INT, iccid2 INT, iccid3 INT, iccid4 INT, iccid5 INT, iccid6 INT, iccid7 INT, iccid8 INT, iccid9 INT, iccid10 INT, iccid11 INT, iccid12 INT, iccid13 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tusim_li ( len INT, usim_li1 INT, usim_li2 INT, usim_li3 INT, usim_li4 INT, usim_li5 INT, usim_li6 INT, usim_li7 INT, usim_li8 INT, usim_li9 INT, usim_li10 INT, usim_li11)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tecc ( len INT, ecc1 INT, ecc2 INT, ecc3 INT, ecc4 INT, ecc5 INT, ecc6 INT, ecc7 INT, ecc8 INT, ecc9 INT, ecc10 INT, ecc11 INT, ecc12 INT, ecc13 INT, ecc14 INT, ecc15 INT, ecc16 INT, ecc17 INT, ecc18 INT, ecc19 INT, ecc20 INT, ecc21 INT, ecc22 INT, ecc23 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tsst ( len INT, sst1 INT, sst2 INT, sst3 INT, sst4 INT, sst5 INT, sst6 INT, sst7 INT, sst8 INT, sst9 INT, sst10 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Test ( len INT, est1 INT, est2 INT, est3 INT, est4 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Tspn ( len INT, spn1 INT, spn2 INT, spn3 INT, spn4 INT, spn5 INT, spn6 INT, spn7 INT, spn8 INT, spn9 INT, spn10 INT, spn11 INT, spn12 INT, spn13 INT, spn14 INT, spn15 INT, spn16 INT, spn17 INT, spn18 INT, spn19 INT)"
+                       ,0,0,&mesg);
+
+       err = sqlite3_exec(db,"CREATE TABLE Timsi ( len INT, imsi1 INT, imsi2 INT, imsi3 INT, imsi4 INT, imsi5 INT, imsi6 INT, imsi7 INT, imsi8 INT, imsi9 INT, imsi10 INT, imsi11 INT, imsi12 INT)"
+                       ,0,0,&mesg);
+
+       //err = sqlite3_exec(db,"CREATE TABLE sim_data ( iccid VARCHAR(13), usim_li VARCHAR(11), ecc VARCHAR(23),sst VARCHAR(10),est VARCHAR(4), spn VARCHAR(19), imsi VARCHAR(12))",0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               TRACE(MSGL_VGSM_ERR, "sqlite3_exec err=%d\n", err);
+
+               if (mesg)
+               {
+                       TRACE(MSGL_VGSM_ERR, "sqlite3_exec: %s\n", mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS: err;
+}
+
+
+//090502
+// set up SIMinfo init
+int db_sim_info_add(int index, _SIMD_t *simd_t)
+{
+       int err;
+       sqlite3 * db = 0;
+       char * mesg;
+       char str[1000];
+       char str1[1000];
+       int count, i;
+
+       unsigned char usim_li[33]=
+       {   0x90, 0x00, 0x1e, 0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83,
+           0x02, 0x6f, 0x05, 0xa5, 0x03, 0xda, 0x01, 0x06, 0x8a, 0x01,
+           0x05, 0x8b, 0x03, 0x6f, 0x06, 0x05, 0x80, 0x02, 0x00, 0x08,
+           0x88, 0x01, 0x10};
+       unsigned char ecc[36]  =
+    {   0x90, 0x00, 0x21, 0x62, 0x1f, 0x82, 0x05, 0x42, 0x21, 0x00,
+           0x14, 0x05, 0x83, 0x02, 0x6f, 0xb7, 0xa5, 0x03, 0xda, 0x01,
+           0x04, 0x8a, 0x01, 0x05, 0x8b, 0x03, 0x6f, 0x06, 0x0d, 0x80,
+               0x02, 0x00, 0x64, 0x88, 0x01, 0x08};
+       unsigned char sst[33]  =
+       {   0x90, 0x00, 0x1e, 0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83,
+               0x02, 0x6f, 0x38, 0xa5, 0x03, 0xda, 0x01, 0x04, 0x8a, 0x01,
+               0x05, 0x8b, 0x03, 0x6f, 0x06, 0x08, 0x80, 0x02, 0x00, 0x07,
+           0x88, 0x01, 0x20};
+       unsigned char est[33]  =
+       {   0x90, 0x00, 0x1e, 0x62, 0x1c, 0x82, 0x02, 0x41, 0x21, 0x83,
+               0x02, 0x6f, 0x56, 0xa5, 0x03, 0xda, 0x01, 0x04, 0x8a, 0x01,
+               0x05, 0x8b, 0x03, 0x6f, 0x06, 0x07, 0x80, 0x02, 0x00, 0x01,
+               0x88, 0x01, 0x28 };
+       unsigned char cphs_cphs_info[3]   = {   0x6a, 0x82, 0x00};
+       unsigned char spn[32]  =
+       {   0x90, 0x00, 0x1d, 0x62, 0x1b, 0x82, 0x02, 0x41, 0x21, 0x83,
+        0x02, 0x6f, 0x46, 0xa5, 0x03, 0xda, 0x01, 0x06, 0x8a, 0x01,
+        0x05, 0x8b, 0x03, 0x6f, 0x06, 0x0d, 0x80, 0x02, 0x00, 0x11,
+        0x88, 0x00};
+       unsigned char imsi[43]  =
+       {   0x90, 0x00, 0x28, 0x62, 0x26, 0x82, 0x02, 0x41, 0x21, 0x83,
+        0x02, 0x6f, 0x07, 0xa5, 0x06, 0x80, 0x01, 0x31, 0xc0, 0x01,
+        0x00, 0x8a, 0x01, 0x05, 0x8b, 0x06, 0x6f, 0x06, 0x01, 0x04,
+        0x00, 0x04, 0x80, 0x02, 0x00, 0x09, 0x81, 0x02, 0x00, 0x1d,
+        0x88, 0x01, 0x38
+       };
+
+       if(simd_t != NULL)
+       {
+
+               switch(simd_t->type2)
+               {
+                       case 0:
+                               for(i=0;i<33;i++)
+                                       usim_li[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 1:
+                               for(i=0;i<36;i++)
+                                       ecc[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 2:
+                               for(i=0;i<33;i++)
+                                       sst[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 3:
+                               for(i=0;i<33;i++)
+                                       est[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 4:
+                               for(i=0;i<3;i++)
+                                       cphs_cphs_info[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 5:
+                               for(i=0;i<32;i++)
+                                       spn[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 6:
+                               for(i=0;i<43;i++)
+                                       imsi[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+
+               }
+       }
+                                                       
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+       char *bin_path = get_bin_path();
+
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_INFO);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+
+
+       // create the sql string
+       switch(index)
+       {
+               case    0:
+                       sprintf(str1,"DELETE FROM Tusim_li");
+                       count = sizeof(usim_li);
+                       sprintf(str,"INSERT INTO Tusim_li VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       33,
+                                                                                                       usim_li[0],usim_li[1],usim_li[2],usim_li[3],usim_li[4],
+                                                                                                       usim_li[5],usim_li[6],usim_li[7],usim_li[8],usim_li[9],
+                                                                                                       usim_li[10],usim_li[11],usim_li[12],usim_li[13],usim_li[14],
+                                                                                                       usim_li[15],usim_li[16],usim_li[17],usim_li[18],usim_li[19],
+                                                                                                       usim_li[20],usim_li[21],usim_li[22],usim_li[23],usim_li[24],
+                                                                                                       usim_li[25],usim_li[26],usim_li[27],usim_li[28],usim_li[29],
+                                                                                                       usim_li[30],usim_li[31],usim_li[32]);
+               break;
+               case    1:
+                       sprintf(str1,"DELETE FROM Tecc");
+                       count = sizeof(ecc);
+                       sprintf(str,"INSERT INTO Tecc VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                               36,
+                                                                                               ecc[0],ecc[1],ecc[2],ecc[3],ecc[4],
+                                                                                               ecc[5],ecc[6],ecc[7],ecc[8],ecc[9],
+                                                                                               ecc[10],ecc[11],ecc[12],ecc[13],ecc[14],
+                                                                                               ecc[15],ecc[16],ecc[17],ecc[18],ecc[19],
+                                                                                               ecc[20],ecc[21],ecc[22],ecc[23],ecc[24],
+                                                                                               ecc[25],ecc[26],ecc[27],ecc[28],ecc[29],
+                                                                                               ecc[30],ecc[31],ecc[32],ecc[33],ecc[34],ecc[35]);
+               break;
+               case    2:
+                       sprintf(str1,"DELETE FROM Tsst");
+                       count = sizeof(sst);
+                       sprintf(str,"INSERT INTO Tsst VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                               33,
+                                                                                               sst[0],sst[1],sst[2],sst[3],sst[4],
+                                                                                               sst[5],sst[6],sst[7],sst[8],sst[9],
+                                                                                               sst[10],sst[11],sst[12],sst[13],sst[14],
+                                                                                               sst[15],sst[16],sst[17],sst[18],sst[19],
+                                                                                               sst[20],sst[21],sst[22],sst[23],sst[24],
+                                                                                               sst[25],sst[26],sst[27],sst[28],sst[29],
+                                                                                               sst[30],sst[31],sst[32]);
+               break;
+               case    3:
+                       sprintf(str1,"DELETE FROM Test");
+                       count = sizeof(est);
+                       sprintf(str,"INSERT INTO Test VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                               33,
+                                                                                               est[0],est[1],est[2],est[3],est[4],
+                                                                                               est[5],est[6],est[7],est[8],est[9],
+                                                                                               est[10],est[11],est[12],est[13],est[14],
+                                                                                               est[15],est[16],est[17],est[18],est[19],
+                                                                                               est[20],est[21],est[22],est[23],est[24],
+                                                                                               est[25],est[26],est[27],est[28],est[29],
+                                                                                               est[30],est[31],est[32]);
+               break;
+               case    4:
+                       sprintf(str1,"DELETE FROM Tcphs");
+                       count = sizeof(cphs_cphs_info);
+                       sprintf(str,"INSERT INTO Tcphs VALUES (%d,%d,%d,%d)",
+                                                                                               3,
+                                                                                               cphs_cphs_info[0], cphs_cphs_info[1], cphs_cphs_info[2]);
+               break;
+               case    5:
+                       sprintf(str1,"DELETE FROM Tspn");
+                       count = sizeof(spn);
+                       sprintf(str,"INSERT INTO Tspn VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                               32,
+                                                                                               spn[0],spn[1],spn[2],spn[3],spn[4],
+                                                                                               spn[5],spn[6],spn[7],spn[8],spn[9],
+                                                                                               spn[10],spn[11],spn[12],spn[13],spn[14],
+                                                                                               spn[15],spn[16],spn[17],spn[18],spn[19],
+                                                                                               spn[20],spn[21],spn[22],spn[23],spn[24],
+                                                                                               spn[25],spn[26],spn[27],spn[28],spn[29],
+                                                                                               spn[30],spn[31]);
+               break;
+               case    6:
+                       sprintf(str1,"DELETE FROM Timsi");
+                       count = sizeof(imsi);
+                       sprintf(str,"INSERT INTO Timsi VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                               43,
+                                                                                               imsi[0],imsi[1],imsi[2],imsi[3],imsi[4],
+                                                                                               imsi[5],imsi[6],imsi[7],imsi[8],imsi[9],
+                                                                                               imsi[10],imsi[11],imsi[12],imsi[13],imsi[14],
+                                                                                               imsi[15],imsi[16],imsi[17],imsi[18],imsi[19],
+                                                                                               imsi[20],imsi[21],imsi[22],imsi[23],imsi[24],
+                                                                                               imsi[25],imsi[26],imsi[27],imsi[28],imsi[29],
+                                                                                               imsi[30],imsi[31],imsi[32],imsi[33],imsi[34],
+                                                                                               imsi[35],imsi[36],imsi[37],imsi[38],imsi[39],
+                                                                                               imsi[40],imsi[41],imsi[42]);
+               break;
+       }
+/*
+       sprintf(str,"INSERT INTO sim_info VALUES ('%s','%s','%s','%s','%s','%s','%s')",
+                               usim_li,
+                               ecc,
+                               sst,
+                               est,
+                               cphs_cphs_info,
+                               spn,
+                               imsi);
+*/
+
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       // add a row
+       err = sqlite3_exec(db,str1,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+//090502
+// set up SIMdata init
+int db_sim_data_add(int index, _SIMD_t *simd_t)
+{
+       int err;
+       sqlite3 * db = 0;
+       char * mesg;
+       char str[1000];
+       char str1[1000];
+       int count,i;
+
+       unsigned char iccid[13]  =
+    { 0x90, 0x00, 0x0a, 0x98, 0x94, 0x22, 0x06, 0x45, 0x61, 0x53,
+         0x49, 0x38, 0xf6 };
+       unsigned char usim_li[11]  =
+       { 0x90, 0x00, 0x08, 0x65, 0x6e, 0x65, 0x6e, 0x65, 0x6e, 0x64,
+         0x65 };
+       unsigned char ecc[23]  =
+       { 0x90, 0x00, 0x14, 0x11, 0xf2, 0xff, 0x4e, 0x6f, 0x74, 0x72,
+         0x75, 0x66, 0x20, 0x46, 0x65, 0x75, 0x65, 0x72, 0x77, 0x65,
+         0x68, 0x72, 0x00    };
+       unsigned char sst[10]  =
+       { 0x90, 0x00, 0x07, 0x9e, 0xdf, 0xb7, 0x1d, 0xe7, 0xfe, 0x07  };
+       unsigned char est[4]   =
+       { 0x90, 0x00, 0x01, 0x00  };
+       unsigned char spn[19]  =
+       { 0x90, 0x00, 0x10, 0x6f, 0x32, 0x20, 0x2d, 0x20, 0x64, 0x65,
+      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff    };
+       unsigned char imsi[12]  =
+       { 0x90, 0x00, 0x09, 0x08, 0x49, 0x05, 0x10, 0x30, 0x00, 0x61,
+         0x66, 0x31};
+
+       if(simd_t != NULL)
+       {
+
+               switch(simd_t->type2)
+               {
+                       case 0:
+                               for(i=0;i<13;i++)
+                                       iccid[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 1:
+                               for(i=0;i<11;i++)
+                                       usim_li[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 2:
+                               for(i=0;i<23;i++)
+                                       ecc[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 3:
+                               for(i=0;i<10;i++)
+                                       sst[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 4:
+                               for(i=0;i<4;i++)
+                                       est[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 5:
+                               for(i=0;i<19;i++)
+                                       spn[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+                       case 6:
+                               for(i=0;i<12;i++)
+                                       imsi[i] = simd_t->tmp[i];
+                               count = simd_t->size;
+                       break;
+
+               }
+
+       }
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_DATA);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       // create the sql string
+       switch(index)
+       {
+               case 0:
+                       sprintf(str1,"DELETE FROM Ticcid");
+                       sprintf(str,"INSERT INTO Ticcid VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       13,
+                                                                                                       iccid[0],iccid[1],iccid[2],iccid[3],iccid[4],
+                                                                                                       iccid[5],iccid[6],iccid[7],iccid[8],iccid[9],
+                                                                                                       iccid[10],iccid[11],iccid[12]
+                                                                                                       );
+               break;
+               case 1:
+                       sprintf(str1,"DELETE FROM Tusim_li");
+                       sprintf(str,"INSERT INTO Tusim_li VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       11,
+                                                                                                       usim_li[0],usim_li[1],usim_li[2],usim_li[3],usim_li[4],
+                                                                                                       usim_li[5],usim_li[6],usim_li[7],usim_li[8],usim_li[9],
+                                                                                                       usim_li[10]
+                                                                                                       );
+               break;
+               case 2:
+                       sprintf(str1,"DELETE FROM Tecc");
+                       sprintf(str,"INSERT INTO Tecc VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       23,
+                                                                                                       ecc[0],ecc[1],ecc[2],ecc[3],ecc[4],
+                                                                                                       ecc[5],ecc[6],ecc[7],ecc[8],ecc[9],
+                                                                                                       ecc[10],ecc[11],ecc[12],ecc[13],ecc[14],
+                                                                                                       ecc[15],ecc[16],ecc[17],ecc[18],ecc[19],
+                                                                                                       ecc[20],ecc[21],ecc[22]
+                                                                                                       );
+               break;
+               case 3:
+                       sprintf(str1,"DELETE FROM Tsst");
+                       sprintf(str,"INSERT INTO Tsst VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       10,
+                                                                                                       sst[0],sst[1],sst[2],sst[3],sst[4],
+                                                                                                       sst[5],sst[6],sst[7],sst[8],sst[9]
+                                                                                                       );
+               break;
+               case 4:
+                       sprintf(str1,"DELETE FROM Test");
+                       sprintf(str,"INSERT INTO Test VALUES (%d,%d,%d,%d,%d)",
+                                                                                                       4,
+                                                                                                       est[0],est[1],est[2],est[3]
+                                                                                                       );
+               break;
+               case 5:
+                       sprintf(str1,"DELETE FROM Tspn");
+                       sprintf(str,"INSERT INTO Tspn VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       19,
+                                                                                                       spn[0],spn[1],spn[2],spn[3],spn[4],
+                                                                                                       spn[5],spn[6],spn[7],spn[8],spn[9],
+                                                                                                       spn[10],spn[11],spn[12],spn[13],spn[14],
+                                                                                                       spn[15],spn[16],spn[17],spn[18]
+                                                                                                       );
+               break;
+               case 6:
+                       sprintf(str1,"DELETE FROM Timsi");
+                       sprintf(str,"INSERT INTO Timsi VALUES (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
+                                                                                                       12,
+                                                                                                       imsi[0],imsi[1],imsi[2],imsi[3],imsi[4],
+                                                                                                       imsi[5],imsi[6],imsi[7],imsi[8],imsi[9],
+                                                                                                       imsi[10],imsi[11]
+                                                                                                       );
+               break;
+       }
+/*
+       sprintf(str,"INSERT INTO sim_data VALUES ('%s','%s','%s','%s','%s','%s','%s')",
+                               iccid,
+                               usim_li,
+                               ecc,
+                               sst,
+                               est,
+                               spn,
+                               imsi);
+*/
+
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       err = sqlite3_exec(db,str1,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       // add a row
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+///////090502/////////////////////////////////////////////////////////////////////
+
+// create the SIM SECURITY TABLE
+int db_sim_sec_create(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       SIM_DEBUG("\n");
+
+       char directory[256];
+       char dbname[256];
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR))
+       {
+               SIM_DEBUG("directory %s does not exit or is not directory\n", directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS))
+               {
+                       if (g_remove (directory) < 0)
+                       {
+                               SIM_DEBUG("unable to remove %s: %d %s\n",directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0)
+               {
+                       /* unable to create directory */
+                       SIM_DEBUG("unable to create %s: %d %s\n", directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("db_sim_sec_create: sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       // create the table
+       err = sqlite3_exec(db,"CREATE TABLE security ( pin_value VARCHAR(8), puk_value VARCHAR(8),pin2_value VARCHAR(8),puk2_value VARCHAR(8),pin_cnt INT,pin2_cnt INT,puk_cnt INT,puk2_cnt INT,sim_state INT,facility_pin INT,facility_fdn INT,lock_sc2_state INT)",0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("db_sim_sec_create: sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("db_sim_sec_create: sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS: err;
+}
+
+
+
+// set up SIM init data (default security data)
+int db_sim_sec_add(void)
+{
+       int err;
+       sqlite3 * db = 0;
+       char * mesg;
+       char str[1000];
+
+       char *pin       ="1234";
+       char *pin2      ="5678";
+       char *puk       ="11111111";
+       char *puk2      ="22222222";
+
+       SimSecurity *sim_sec;
+       SIM_DEBUG("\n");
+
+       sim_sec = malloc(sizeof(SimSecurity));
+
+       memset(sim_sec,0,sizeof(sim_sec));
+
+       memcpy(sim_sec->pin_value,pin,strlen(pin)+1);
+       memcpy(sim_sec->pin2_value,pin2,strlen(pin2)+1);
+       memcpy(sim_sec->puk_value,puk,strlen(puk)+1);
+       memcpy(sim_sec->puk2_value,puk2,strlen(puk2)+1);
+
+       sim_sec->pin_cnt                =       3;
+       sim_sec->pin2_cnt               =       3;
+       sim_sec->puk_cnt                =       10;
+       sim_sec->puk2_cnt       =       10;
+       sim_sec->sim_state      =       SIM_STATE_READY;
+       sim_sec->facility_pin   =       GSM_SEC_LOCK_MODE_UNLOCK;       // 0x00;
+       sim_sec->facility_fdn   =       GSM_SEC_LOCK_MODE_UNLOCK;
+       sim_sec->lock_sc2_state = SIM_STATE_PIN2_REQ;
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       SIM_DEBUG("puk %s len %d\n\n\n",        puk, strlen(puk));
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+               goto Done;
+       }
+
+       // create the sql string
+       sprintf(str,"INSERT INTO security VALUES ('%s','%s','%s','%s',%d,%d,%d,%d,%d,%d,%d,%d)",
+                               sim_sec->pin_value,
+                               sim_sec->puk_value,
+                               sim_sec->pin2_value,
+                               sim_sec->puk2_value,
+                               sim_sec->pin_cnt,
+                               sim_sec->pin2_cnt,
+                               sim_sec->puk_cnt,
+                               sim_sec->puk2_cnt,
+                               sim_sec->sim_state,
+                               sim_sec->facility_pin,
+                               sim_sec->facility_fdn,
+                               sim_sec->lock_sc2_state);
+
+       SIM_DEBUG("SQL statement : %s\n", str);
+
+       if(sim_sec)
+               free(sim_sec);
+
+       // add a row
+       err = sqlite3_exec(db,str,0,0,&mesg);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+
+// remove a registration from the database
+// delete a row from the database which contains the registration information
+int db_sim_sec_remove(void)
+{
+/*
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+
+               TRACE(MSGL_VGSM_ERR, "sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the sql string
+       sprintf(str,"DELETE FROM network WHERE (number_PLMN == %d)",number_PLMN);
+
+       // remove the row
+       err = sqlite3_exec(db,str,0,0,&mesg);
+       if (err != SQLITE_OK) {
+
+               TRACE(MSGL_VGSM_ERR, "sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+
+                       TRACE(MSGL_VGSM_ERR, "sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE : err;
+*/
+return 0;
+}
+
+//////////////////////////////////////////////////////////////////////////
+int db_sim_info_restore(char* table)
+{
+       sqlite3 * db = 0;
+    int err;
+    char * mesg;
+    char dbname[256];
+    char str[1000];
+
+    char *bin_path = get_bin_path();
+    sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_INFO);
+
+    if (bin_path)
+           g_free(bin_path);
+
+    SIM_DEBUG("\n");
+
+    // open the database
+    err = sqlite3_open(dbname,&db);
+    if (err != SQLITE_OK) {
+           SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+    goto Done;
+    }
+
+    sprintf(str,"SELECT ALL * FROM %s",table);
+
+    // dump all the rows
+    err = sqlite3_exec(db, str, db_sim_info_callback, 0, &mesg);
+    if (err != SQLITE_OK) {
+           SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+           if (mesg) {
+                   SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                   sqlite3_free(mesg);
+       }
+    goto Done;
+    }
+Done:
+       // close the database
+    if (db) sqlite3_close(db);
+
+    // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+
+int db_sim_data_restore(char* table)
+{
+       sqlite3 * db = 0;
+    int err;
+    char * mesg;
+    char dbname[256];
+    char str[1000];
+
+    char *bin_path = get_bin_path();
+    sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE_DATA);
+
+    if (bin_path)
+           g_free(bin_path);
+
+    SIM_DEBUG("\n");
+
+    // open the database
+    err = sqlite3_open(dbname,&db);
+    if (err != SQLITE_OK) {
+           SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+    goto Done;
+    }
+
+    sprintf(str,"SELECT ALL * FROM %s",table);
+
+    // dump all the rows
+    err = sqlite3_exec(db, str, db_sim_info_callback, 0, &mesg);
+    if (err != SQLITE_OK) {
+           SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+           if (mesg) {
+                   SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                   sqlite3_free(mesg);
+       }
+    goto Done;
+    }
+Done:
+       // close the database
+    if (db) sqlite3_close(db);
+
+    // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+//////////////////////////////////////////////////////////////////////////
+
+
+// restore all previously save registrations
+// select all rows and process each one in the callback
+int db_sim_sec_restore(VGSM_SIMType type)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       SIM_DEBUG("\n");
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // dump all the rows
+       err = sqlite3_exec(db,"SELECT ALL * FROM security",db_sim_sec_restore_callback,&type,&mesg);
+       if (err != SQLITE_OK) {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+       Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+int db_sim_sec_edit(int db_type,char *data,int data2)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+       SIM_DEBUG("\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the sql string
+       switch(db_type)
+       {
+               case DB_PIN:
+                       sprintf(str,"UPDATE security SET pin_value = %s",data);
+                       break;
+               case DB_PIN2:
+                       sprintf(str,"UPDATE security SET pin2_value = %s",data);
+                       break;
+               case DB_PUK:
+                       sprintf(str,"UPDATE security SET puk_value = %s",data);
+                       break;
+               case DB_PUK2:
+                       sprintf(str,"UPDATE security SET puk2_value = %s",data);
+                       break;
+               case DB_PIN_CNT:
+                       sprintf(str,"UPDATE security SET pin_cnt = %d",data2);
+                       break;
+               case DB_PIN2_CNT:
+                       sprintf(str,"UPDATE security SET pin2_cnt = %d",data2);
+                       break;
+               case DB_PUK_CNT:
+                       sprintf(str,"UPDATE security SET puk_cnt = %d",data2);
+                       break;
+               case DB_PUK2_CNT:
+                       sprintf(str,"UPDATE security SET puk2_cnt = %d",data2);
+                       break;
+               case DB_SIM_STATE:
+                       sprintf(str,"UPDATE security SET sim_state = %d",data2);
+                       break;
+               case DB_F_PIN:
+                       sprintf(str,"UPDATE security SET facility_pin = %d",data2);
+                       break;
+               case DB_F_FDN:
+                       sprintf(str,"UPDATE security SET facility_fdn = %d",data2);
+                       break;
+               case DB_LOCK_SC2_STATE:
+                       sprintf(str,"UPDATE security SET lock_sc2_state = %d",data2);
+                       break;
+       }
+
+
+       // dump all the rows
+       err = sqlite3_exec(db,str,0,0,&mesg);
+       if (err != SQLITE_OK)
+       {
+               SIM_DEBUG("sqlite3_exec err=%d\n",err);
+
+               if (mesg)
+               {
+                       SIM_DEBUG("sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? SIM_SUCCESS : err;
+}
+
+// ----------------------------------------------------------------------------
+// end of sqlite3 specific code
+// ----------------------------------------------------------------------------
+
diff --git a/vmodem/db/db_ss.c b/vmodem/db/db_ss.c
new file mode 100644 (file)
index 0000000..ee77c78
--- /dev/null
@@ -0,0 +1,1379 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "vgsm_call.h"
+#include "vgsm_ss.h"
+#include "db_ss.h"
+#include "logmsg.h"
+#include "fileio.h"
+//#include "state.h"
+#include "at_func.h"
+
+#define ALP_NOTIFY_DATABASE_DIR  "./db"
+#define ALP_NOTIFY_DATABASE_FILE "ss.db"
+#define ALP_NOTIFY_DATABASE_MODE (S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG)
+
+// ----------------------------------------------------------------------------
+// sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+#include <sqlite3.h>
+
+//090225
+static int cw_count=0;
+
+unsigned int   g_cw_entry_count;
+unsigned int   g_cf_entry_count;
+unsigned int   g_cb_entry_count;
+
+#ifndef        TRUE
+#define TRUE   1
+#endif /* TRUE */
+
+#ifndef FALSE
+#define FALSE  0
+#endif /* FALSE */
+
+call_waiting_entry_t           g_cw_entry[20];
+call_barring_entry_t           g_cb_entry[20];
+call_forwarding_entry_t                g_cf_entry[20];
+int                            g_mo_voice_is_barred = FALSE;
+int                            g_mt_voice_is_barred = FALSE;
+int                             g_mo_video_is_barred = FALSE;
+int                             g_mt_video_is_barred = FALSE;
+int                            g_cf_is_activated = FALSE;
+char* g_cb_pwd="1111";
+static int g_cb_pwd_fail_count = 0;
+
+// end
+
+// callback to handle each row from "SELECT ALL * FROM ss"
+// where each row is a persistent registration
+static int vgsm_ss_sqlite_restore_callback(void * ref, int ncol, char ** cols, char ** name)
+{
+       ss_cmd_e_type * type = (ss_cmd_e_type*)ref;
+
+       log_msg(MSGL_VGSM_INFO,"ncol : %d \n", ncol);
+       switch(*type)
+       {
+               case SS_CMD_CF:
+                       {
+                               call_forwarding_entry_t         entry;
+                               memset(entry.number, 0, sizeof(entry.number));
+
+                               log_msg(MSGL_VGSM_INFO,"class = %d, type = %d, number = %s(%d), reply time = %d, ss_mode = %d \n", atoi(*cols), atoi(*(cols+1)), *(cols+2), strlen(*(cols+2)), atoi(*(cols+3)), atoi(*(cols+4)));
+                               entry.tel_class = atoi(*cols);
+                               entry.type = atoi(*(cols+1));
+                               memcpy(&entry.number, *(cols+2), strlen(*(cols+2)));
+                               entry.replyTime = atoi(*(cols+3));
+                               entry.ss_mode = atoi(*(cols+4));
+                               g_cf_entry_count++;
+
+                               set_call_forwarding_entry(&entry, g_cf_entry_count);
+                       }
+                       break;
+               case SS_CMD_CB:
+                       {
+                               call_barring_entry_t    entry;
+
+                               log_msg(MSGL_VGSM_INFO,"class = %d, type = %d, ss_mode = %d \n", atoi(*cols), atoi(*(cols+1)), atoi(*(cols+2)));
+                               entry.tel_class = atoi(*cols);
+                               entry.type = atoi(*(cols+1));
+                               entry.ss_mode = atoi(*(cols+2));
+
+                               g_cb_entry_count++;
+                               set_call_barring_entry(&entry, g_cb_entry_count);
+                               
+                               if(entry.tel_class == AT_CALL_SS_CLASS_VIDEO)   // video call
+                                {
+                                        if(entry.type == SS_CB_TYPE_AB)
+                                        {
+                                                set_outgoing_video_call_barring_state(entry.ss_mode);
+                                                set_incoming_video_call_barring_state(entry.ss_mode);
+                                        }
+                                        else if(entry.type == SS_CB_TYPE_BAOC)
+                                        {
+                                                set_outgoing_video_call_barring_state(entry.ss_mode);
+                                        }
+                                        else if(entry.type == SS_CB_TYPE_BAIC)
+                                        {
+                                                set_incoming_video_call_barring_state(entry.ss_mode);
+                                        }
+                                }
+                               else            // voice call
+                               {
+                                       if(entry.type == SS_CB_TYPE_AB)
+                                       {
+                                               set_outgoing_voice_call_barring_state(entry.ss_mode);
+                                               set_incoming_voice_call_barring_state(entry.ss_mode);
+                                       }
+                                       else if(entry.type == SS_CB_TYPE_BAOC)
+                                       {
+                                               set_outgoing_voice_call_barring_state(entry.ss_mode);
+                                       }
+                                       else if(entry.type == SS_CB_TYPE_BAIC)
+                                       {
+                                               set_incoming_voice_call_barring_state(entry.ss_mode);
+                                       }
+                               }
+                       }
+                       break;
+               case SS_CMD_CW:
+                       {
+                               call_waiting_entry_t    entry;
+                               memset(entry.number, 0, sizeof(entry.number));
+
+                               entry.tel_class = atoi(*cols);
+                               entry.ss_mode = atoi(*(cols+1));
+                               memcpy(&entry.number, *(cols+2), strlen(*(cols+2)));
+                               log_msg(MSGL_VGSM_INFO,"class = %d, ss_mode = %d\n", entry.tel_class, entry.ss_mode);
+                               g_cw_entry_count++;
+
+                               set_call_waiting_entry(&entry, g_cw_entry_count);
+                       }
+                       break;
+       }
+
+       // should always return zero from the callback
+       return 0;
+
+}
+
+// initialize the database
+// create the ss table
+static int vgsm_ss_sqlite_init(void)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init\n");
+
+       char directory[256];
+       char dbname[256];
+
+       //char *dbname = ALP_NOTIFY_DATABASE_DIR "/" ALP_NOTIFY_DATABASE_FILE;
+       //char *directory = ALP_NOTIFY_DATABASE_DIR;
+       char *bin_path = get_bin_path();
+       sprintf(directory,"%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR);
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       /* make sure database directory exists */
+       if (!g_file_test (directory, G_FILE_TEST_IS_DIR)) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: directory %s does not exit or is not directory\n", directory);
+
+               /* check if exists and if so, attempt to remove non-directory */
+               if (g_file_test (directory, G_FILE_TEST_EXISTS)) {
+                       if (g_remove (directory) < 0) {
+
+                               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: "
+                                               "unable to remove %s: %d %s\n",
+                                               directory, errno, strerror(errno));
+
+                               err = errno;
+                               goto Done;
+                       }
+               }
+
+               /* create directory */
+               if (g_mkdir_with_parents (directory, ALP_NOTIFY_DATABASE_MODE) < 0) {
+                       /* unable to create directory */
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: "
+                                       "unable to create %s: %d %s\n",
+                                       directory, errno, strerror(errno));
+
+                       err = errno;
+                       goto Done;
+               }
+       }
+
+       // open the database
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the call forwarding  table
+       err = sqlite3_exec(db,"CREATE TABLE forwarding ( class INT , type INT, number TEXT, replytime  INT, ss_mode INT)", 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+               //log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init(forwarding): sqlite3_exec err=%d\n",err);
+               sqlite3_exec(db,"DELETE FROM forwarding",0,0,&mesg);
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               //goto Done; //Á¸Àç ÇÑ´Ù¸é, ±× ÀÌÈÄ tableÀº ¸ø¸¸µç´Ù. ÀÌ ºÎºÐ »èÁ¦°ËÅä.
+       }
+
+       // create the call barring  table
+       err = sqlite3_exec(db,"CREATE TABLE barring ( class INT , type INT, ss_mode INT)", 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+               //log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init(barring): sqlite3_exec err=%d\n",err);
+               sqlite3_exec(db,"DELETE FROM barring",0,0,&mesg);
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               //goto Done;
+       }
+
+       // create the call waiting  table
+       err = sqlite3_exec(db,"CREATE TABLE waiting ( class INT , ss_mode INT, number TEXT)", 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+               //log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init(waiting): sqlite3_exec err=%d\n",err);
+               sqlite3_exec(db,"DELETE FROM waiting",0,0,&mesg);
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_init: sqlite3_exec: %s\n",mesg);
+                       sqlite3_free(mesg);
+               }
+               //goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err == SQLITE_OK ? TRUE: err;
+}
+
+static int count_callback(void *some_entry, int ncol, char **cols, char **azColName)
+{
+       unsigned char * count;
+
+       count = (unsigned char *)(some_entry);
+
+       *count += 1;
+       //090225
+       cw_count = *count;
+
+       return 0;
+}
+
+int  vgsm_ss_sqlite_cw_check_exist (int tel_class)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cw_check_exist\n");
+
+       char str[512];
+       unsigned char counter = 0;
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cw_check_exist: sqlite3_open err=%d\n", err);
+
+               goto Done;
+       }
+
+       sprintf(str, "SELECT * FROM waiting WHERE class = '%d'", tel_class);
+
+       log_msg(MSGL_VGSM_INFO,"count sql = <%s> \n", str);
+
+       err = sqlite3_exec(db, str, count_callback, &counter, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cw_check_exist: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cw_check_exist: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       if(counter > 0)
+               return TRUE;
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       return FALSE;
+}
+
+static int  vgsm_ss_sqlite_cb_check_exist (int tel_class, int type)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cb_check_exist\n");
+
+       char str[512];
+       unsigned char counter = 0;
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cb_check_exist: sqlite3_open err=%d\n", err);
+
+               goto Done;
+       }
+
+       sprintf(str, "SELECT * FROM barring WHERE (class = '%d' AND type = '%d')", tel_class, type);
+
+       log_msg(MSGL_VGSM_INFO,"count sql = <%s> \n", str);
+
+       err = sqlite3_exec(db, str, count_callback, &counter, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cb_check_exist: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cb_check_exist: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       if(counter > 0)
+               return TRUE;
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       return FALSE;
+}
+
+static int  vgsm_ss_sqlite_cf_check_exist (int tel_class, int type)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cf_check_exist\n");
+
+       char str[512];
+       unsigned char counter = 0;
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       log_msg(MSGL_VGSM_INFO,"check 1 in vgsm_ss_sqlite_cf_check_exist\n");
+       err = sqlite3_open(dbname, &db);
+       log_msg(MSGL_VGSM_INFO,"check 2 in vgsm_ss_sqlite_cf_check_exist\n");
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cf_check_exist: sqlite3_open err=%d\n", err);
+
+               goto Done;
+       }
+
+       sprintf(str, "SELECT * FROM forwarding WHERE (class = '%d' AND type = '%d')", tel_class, type);
+
+       log_msg(MSGL_VGSM_INFO,"count sql = <%s> \n", str);
+
+       err = sqlite3_exec(db, str, count_callback, &counter, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cf_check_exist: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_cf_check_exist: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       if(counter > 0)
+               return TRUE;
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       return FALSE;
+}
+
+// add a new registration to the database
+// insert a row into the database which contains the registration information
+static int vgsm_ss_sqlite_add(char * sqlString)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       char str[512];
+       //      char str[1000];
+       //
+#if 0                                                  // - this is for checking sqlString
+       int fd;
+
+       if(fd = open("/root/sql_tmp",O_WRONLY|O_CREAT) == -1)
+       {
+               log_msg(MSGL_VGSM_INFO,"err=%d\n","Error opening the file");
+               log_msg(MSGL_VGSM_INFO,"err=%d\n","Error opening the file");
+               log_msg(MSGL_VGSM_INFO,"err=%d\n","Error opening the file");
+       }
+       else
+       {
+               write(fd, sqlString, strlen(*sqlString));
+       }
+#endif
+
+#if 1
+       sprintf(str, "<ADD>SELECT * FROM waiting WHERE class = '%s'", sqlString);
+       log_msg(MSGL_VGSM_INFO,"count sql = <%s> \n", str);
+#endif
+
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_add\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_add: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the sql string
+       //      sprintf(str,"INSERT INTO ss VALUES (%d,%d,%d,'%s')",id, PLMN_status, number_PLMN, ACT);
+
+       if(sqlString == NULL)
+               goto Done;
+
+       log_msg(MSGL_VGSM_INFO," SQL statement : %s\n", sqlString);
+
+       // add a row
+       err = sqlite3_exec(db, sqlString, 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_add: sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_add: sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       //return err == SQLITE_OK ? TRUE: err;
+       return err;
+}
+
+// restore all previously save registrations
+// select all rows and process each one in the callback
+static int vgsm_ss_sqlite_restore(ss_cmd_e_type type)
+{
+       char str[128];
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname, &db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_restore: sqlite3_open err=%d\n", err);
+
+               goto Done;
+       }
+
+       switch(type)
+       {
+               case SS_CMD_CF:
+                       sprintf(str, "SELECT * FROM %s", "forwarding");
+                       break;
+               case SS_CMD_CB:
+                       sprintf(str, "SELECT * FROM %s", "barring");
+                       break;
+               case SS_CMD_CW:
+                       sprintf(str, "SELECT * FROM %s", "waiting");
+                       break;
+       }
+
+       g_cw_entry_count = 0;
+       g_cf_entry_count = 0;
+       g_cb_entry_count = 0;
+
+       log_msg(MSGL_VGSM_INFO, "%s\n", str);
+       err = sqlite3_exec(db,str, vgsm_ss_sqlite_restore_callback, &type, &mesg);
+       if(err)
+       {
+       }
+
+       log_msg(MSGL_VGSM_INFO,"<<<<>>>>>cw(%d) cf(%d) cb(%d)\n", g_cw_entry_count, g_cf_entry_count, g_cb_entry_count);
+       if(type == SS_CMD_CW && g_cw_entry_count == 0)
+               set_call_waiting_entry(NULL, 0);
+       if(type ==  SS_CMD_CF && g_cf_entry_count == 0)
+               set_call_forwarding_entry(NULL, 0);
+       if(type == SS_CMD_CB && g_cb_entry_count == 0)
+               set_call_barring_entry(NULL, 0);
+
+       if (err != SQLITE_OK) {
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_restore: sqlite3_exec err=%d\n", err);
+
+               if (mesg) {
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_restore: sqlite3_exec: %s\n", mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err;
+}
+
+// remove a registration from the database
+// delete a row from the database which contains the registration information
+static int vgsm_ss_sqlite_remove(ss_cmd_e_type type, int tel_class, int ss_type)
+{
+       sqlite3 * db = 0;
+       int err;
+       char * mesg;
+       char str[1000];
+
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_remove\n");
+
+       char dbname[256];
+
+       char *bin_path = get_bin_path();
+       sprintf(dbname,"%s/%s/%s", bin_path, ALP_NOTIFY_DATABASE_DIR, ALP_NOTIFY_DATABASE_FILE);
+
+       if (bin_path)
+               g_free(bin_path);
+
+       // open the database
+       err = sqlite3_open(dbname,&db);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_remove: sqlite3_open err=%d\n",err);
+
+               goto Done;
+       }
+
+       // create the sql string
+       switch(type)
+       {
+               case SS_CMD_CF:
+                       //090325
+                       //sprintf(str,"DELETE FROM forwarding WHERE (class = '%d' AND type = '%d')", tel_class, ss_type);
+                       if(ss_type == SS_CF_TYPE_CF_ALL) // SS_CF_TYPE_CF_ALL
+                               sprintf(str,"DELETE FROM forwarding");                          // for defect X200001252, set Cancel all in Simulator
+                       else if(tel_class == -1 || tel_class == 0x10) // All teleservices
+                               sprintf(str,"DELETE FROM forwarding WHERE type = '%d'", ss_type);
+                       else
+                               //      sprintf(str,"DELETE FROM forwarding WHERE type = '%d'", ss_type);
+                               sprintf(str,"DELETE FROM forwarding WHERE (class = '%d' AND type = '%d')", tel_class, ss_type);
+
+                       break;
+               case SS_CMD_CB:
+                       //090325
+                       //sprintf(str,"DELETE FROM barring WHERE (class = '%d' AND type = '%d')", tel_class, ss_type);
+                       sprintf(str,"DELETE FROM barring WHERE type = '%d'", ss_type);
+                       break;
+               case SS_CMD_CW:
+                       sprintf(str,"DELETE FROM waiting WHERE (class = '%d')", tel_class);
+                       break;
+       }
+
+       log_msg(MSGL_VGSM_INFO,"delete sql = <%s> \n", str);
+
+       // remove the row
+       err = sqlite3_exec(db, str, 0, 0, &mesg);
+       if (err != SQLITE_OK) {
+
+               log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_remove: sqlite3_exec err=%d\n",err);
+
+               if (mesg) {
+
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_sqlite_remove: sqlite3_exec: %s\n",mesg);
+
+                       sqlite3_free(mesg);
+               }
+               goto Done;
+       }
+
+       return vgsm_ss_sqlite_restore(type);
+
+Done:
+       // close the database
+       if (db) sqlite3_close(db);
+
+       // return status
+       return err;
+}
+
+
+static int vgsm_ss_sqlite_make_sql(ss_cmd_e_type type, void * entry)
+{
+       char     str[1024];
+       int err = 0;
+
+       switch(type)
+       {
+               case SS_CMD_CF:
+                       {
+                               call_forwarding_entry_t * cf_entry = (call_forwarding_entry_t*)entry;
+                               log_msg(MSGL_VGSM_INFO, "ss_mode = %d\n", cf_entry->ss_mode);
+                               if(vgsm_ss_sqlite_cf_check_exist(cf_entry->tel_class, cf_entry->type))
+                               {
+                                       if(cf_entry->ss_mode == SS_MODE_DEREG) // GSM_SS_MODE_DEREG
+                                       {
+                                               if(cf_entry->type == SS_CF_TYPE_CFU)
+                                               {
+                                                       log_msg(MSGL_VGSM_INFO, "g_cf_is_activated = FALSE\n");
+                                                       g_cf_is_activated = FALSE;
+                                               }
+
+                                               return vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, cf_entry->type);
+                                       }
+                                       else if(cf_entry->ss_mode == SS_MODE_REG && cf_entry->type == SS_CF_TYPE_CFU)
+                                       {
+                                               log_msg(MSGL_VGSM_INFO, "g_cf_is_activated = TRUE\n");
+                                               g_cf_is_activated = TRUE;
+                                               vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFB);
+                                               vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRy);
+                                               vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRc);
+                                               
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE forwarding SET number = '%s', replytime = '%d', ss_mode  = '%d' "
+                                                                "WHERE (class = '%d' AND type = '%d')", cf_entry->number, cf_entry->replyTime, cf_entry->ss_mode, cf_entry->tel_class, cf_entry->type);
+                                               log_msg(MSGL_VGSM_INFO, "\n");
+                                       }
+                                       else
+                                       {
+                                               if(g_cf_is_activated == TRUE)
+                                               {
+                                                       vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFB);
+                                                       vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRy);
+                                                       vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRc);
+
+                                                       return vgsm_ss_sqlite_restore(type);
+                                               }
+
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE forwarding SET number = '%s', replytime = '%d', ss_mode  = '%d' "
+                                                               "WHERE (class = '%d' AND type = '%d')", cf_entry->number, cf_entry->replyTime, cf_entry->ss_mode, cf_entry->tel_class, cf_entry->type);
+                                               log_msg(MSGL_VGSM_INFO, "\n");
+                                       }
+                               }
+                               else if(cf_entry->ss_mode == SS_MODE_DEREG)
+                               {
+                                       if(cf_entry->type == SS_CF_TYPE_CFU)
+                                       {
+                                               log_msg(MSGL_VGSM_INFO, "g_cf_is_activated = FALSE\n");
+                                               g_cf_is_activated = FALSE;
+                                       }
+
+                                       log_msg(MSGL_VGSM_INFO,"###%d, %d, '%s',%d, %d\n",cf_entry->tel_class, cf_entry->type, cf_entry->number, cf_entry->replyTime, cf_entry->ss_mode);
+                                       vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, cf_entry->type);
+                               }
+                               else
+                               {
+                                       if(cf_entry->ss_mode == SS_MODE_REG && cf_entry->type == SS_CF_TYPE_CFU)
+                                       {
+                                               log_msg(MSGL_VGSM_INFO, "g_cf_is_activated = TRUE\n");
+                                               g_cf_is_activated = TRUE;
+                                               vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFB);
+                                                vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRy);
+                                                vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRc);
+                                       }
+                                       else if(g_cf_is_activated == TRUE)
+                                       {
+                                               vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFB);
+                                                vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRy);
+                                                vgsm_ss_sqlite_remove(SS_CMD_CF, cf_entry->tel_class, SS_CF_TYPE_CFNRc);
+
+                                               return vgsm_ss_sqlite_restore(type);
+                                       }
+                                       
+                                       memset(str, '\0', sizeof(str));
+                                       sprintf(str,"INSERT INTO forwarding VALUES (%d, %d, '%s',%d, %d)", cf_entry->tel_class, cf_entry->type, cf_entry->number, cf_entry->replyTime, cf_entry->ss_mode);
+                                       log_msg(MSGL_VGSM_INFO,"####%d, %d, '%s',%d, %d\n",cf_entry->tel_class, cf_entry->type, cf_entry->number, cf_entry->replyTime, cf_entry->ss_mode);
+                               }
+                       }
+                       break;
+               case SS_CMD_CB:
+                       {
+                               call_barring_entry_t * cb_entry = (call_barring_entry_t*)entry;
+                               log_msg(MSGL_VGSM_INFO,"tel_class : %x, ssmode : %x, sstype : %x\n",cb_entry->tel_class, cb_entry->ss_mode, cb_entry->type);
+                               if(vgsm_ss_sqlite_cb_check_exist(cb_entry->tel_class, cb_entry->type))
+                               {
+                                       if(cb_entry->ss_mode == SS_MODE_DEREG) // GSM_SS_MODE_DEREG
+                                               return vgsm_ss_sqlite_remove(SS_CMD_CB, cb_entry->tel_class, cb_entry->type);
+                                       else
+                                       {
+                                               if(cb_entry->type == SS_CB_TYPE_BAOC && cb_entry->ss_mode == SS_MODE_ACT)
+                                               {
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, SS_CB_TYPE_BAOC);
+                                                       if(vgsm_ss_sqlite_add((char*)&str))
+                                                               return err;
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, SS_CB_TYPE_BOIC);
+                                                       if(vgsm_ss_sqlite_add((char*)&str))
+                                                                return err;
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, SS_CB_TYPE_BOIC_NOT_HC);
+                                               }
+                                               else if(cb_entry->type == SS_CB_TYPE_BAIC && cb_entry->ss_mode == SS_MODE_ACT)
+                                               {
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, SS_CB_TYPE_BAIC);
+                                                       if(vgsm_ss_sqlite_add((char*)&str))
+                                                                return err;
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, SS_CB_TYPE_BIC_ROAM);
+                                               }
+                                               else
+                                               {       
+                                                       memset(str, '\0', sizeof(str));
+                                                       sprintf(str, "UPDATE barring SET ss_mode  = '%d' WHERE (class = '%d' AND type = '%d')", cb_entry->ss_mode, cb_entry->tel_class, cb_entry->type);
+                                               }
+                                       }
+                               }
+                               //090327        // this is point of preventing deregisteration data in cb
+                               else if(cb_entry->ss_mode != SS_MODE_DEACT)     // GSM_SS_MODE_DEACTIVATE
+                               {
+                                       if(cb_entry->type == SS_CB_TYPE_BAOC && cb_entry->ss_mode == SS_MODE_ACT)
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, SS_CB_TYPE_BAOC, cb_entry->ss_mode);
+                                               log_msg(MSGL_VGSM_INFO, "%s\n", str);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, SS_CB_TYPE_BOIC, cb_entry->ss_mode);        
+                                               log_msg(MSGL_VGSM_INFO, "%s\n", str);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, SS_CB_TYPE_BOIC_NOT_HC, cb_entry->ss_mode);
+                                               log_msg(MSGL_VGSM_INFO, "%s\n", str);
+                                       }
+                                       else if(cb_entry->type == SS_CB_TYPE_BAIC && cb_entry->ss_mode == SS_MODE_ACT)
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, SS_CB_TYPE_BAIC, cb_entry->ss_mode);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, SS_CB_TYPE_BIC_ROAM, cb_entry->ss_mode);
+                                       }
+                                       else
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO barring VALUES (%d, %d, %d)", cb_entry->tel_class, cb_entry->type, cb_entry->ss_mode);
+                                       }
+                               }
+                       }
+                       break;
+               case SS_CMD_CW:
+                       {
+                               call_waiting_entry_t * cw_entry = (call_waiting_entry_t*)entry;
+                               /*******090225*****************************************************************************************************/
+                               if(cw_entry->tel_class == -1 || cw_entry->tel_class == 0x10)            // for defect X200001045, inconsistency problem
+                               {
+                                       if(cw_entry->ss_mode == SS_MODE_DEREG || cw_entry->ss_mode == SS_MODE_DEACT) // GSM_SS_MODE_DEREG or GSM_SS_MODE_DEACTIVATE
+                                               //                                              return vgsm_ss_sqlite_remove(SS_CMD_CW, cw_entry->tel_class, 0);
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 1);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 4);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 8);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 32);
+                                       }
+                                       else
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 1);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 4);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 8);
+                                               if(vgsm_ss_sqlite_add((char*)&str))
+                                                       return err;
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 32);
+                                       }
+                               }
+                               else
+                               {
+                                       if(vgsm_ss_sqlite_cw_check_exist(cw_entry->tel_class))
+                                       {
+                                       /*      if(cw_entry->ss_mode == SS_MODE_DEREG || cw_entry->ss_mode == SS_MODE_DEACT) // GSM_SS_MODE_DEREG or GSM_SS_MODE_DEACT
+                                                       return  vgsm_ss_sqlite_remove(SS_CMD_CW, cw_entry->tel_class, 0);
+                                               else*/
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 1);
+                                                if(vgsm_ss_sqlite_add((char*)&str))
+                                                        return err;
+                                               memset(str, '\0', sizeof(str));
+                                                sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 4);
+                                                if(vgsm_ss_sqlite_add((char*)&str))
+                                                        return err;
+                                               memset(str, '\0', sizeof(str));
+                                                sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 8);
+                                                if(vgsm_ss_sqlite_add((char*)&str))
+                                                        return err;
+                                               memset(str, '\0', sizeof(str));
+                                                sprintf(str, "UPDATE waiting SET number = '%s', ss_mode  = '%d' WHERE class = '%d'", cw_entry->number, cw_entry->ss_mode, 32);
+                                       }
+                                       else
+                                       {
+                                               memset(str, '\0', sizeof(str));
+                                               sprintf(str,"INSERT INTO waiting VALUES (%d, %d, '%s')", cw_entry->tel_class, cw_entry->ss_mode, cw_entry->number);
+                                               log_msg(MSGL_VGSM_INFO, "%s\n", str);
+                                       }
+                               }
+                       }
+                       break;
+       }
+
+       if(vgsm_ss_sqlite_add((char*)&str))
+               return err;
+
+       return vgsm_ss_sqlite_restore(type);
+
+}
+
+// ----------------------------------------------------------------------------
+// end of sqlite3 specific code
+// ----------------------------------------------------------------------------
+
+// initialize the database
+int vgsm_ss_database_init()
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_init\n");
+
+       // initialize the database
+       return vgsm_ss_sqlite_init();
+}
+
+// add a registration
+int vgsm_ss_database_add(ss_cmd_e_type type, void * entry)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_add\n");
+
+       return vgsm_ss_sqlite_make_sql(type, entry);
+}
+
+// remove a registration
+int vgsm_ss_database_remove(ss_cmd_e_type type, int tel_class, int ss_type)
+{
+
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_remove\n");
+
+       if(ss_type == SS_CF_TYPE_CFU)
+       {
+               log_msg(MSGL_VGSM_INFO, "g_cf_is_activated = FALSE\n");
+               g_cf_is_activated = FALSE;
+       }
+       // remove the registration from the database
+       return vgsm_ss_sqlite_remove(type, tel_class, ss_type);
+}
+
+// restore all previously save registrations
+int vgsm_ss_database_restore(ss_cmd_e_type type)
+{
+       log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_restore : ss_cmd=%d \n", type);
+
+       return vgsm_ss_sqlite_restore(type);
+}
+
+/*========== voice =================*/
+
+int get_outgoing_voice_call_barring_state(void)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", g_mo_voice_is_barred);
+       return g_mo_voice_is_barred;
+}
+
+int get_incoming_voice_call_barring_state(void)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", g_mt_voice_is_barred);
+        return g_mt_voice_is_barred;
+}
+
+void set_outgoing_voice_call_barring_state(int state)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", state);
+       g_mo_voice_is_barred = state == 0x03 ? TRUE : FALSE;
+}
+
+void set_incoming_voice_call_barring_state(int state)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", state);
+        g_mt_voice_is_barred = state == 0x03 ? TRUE : FALSE;
+}
+
+/*========== video =================*/
+
+int get_outgoing_video_call_barring_state(void)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", g_mo_video_is_barred);
+        return g_mo_video_is_barred;
+}
+
+int get_incoming_video_call_barring_state(void)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", g_mt_video_is_barred);
+        return g_mt_video_is_barred;
+}
+
+void set_outgoing_video_call_barring_state(int state)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", state);
+        g_mo_video_is_barred = state == 0x03 ? TRUE : FALSE;
+}
+
+void set_incoming_video_call_barring_state(int state)
+{
+       log_msg(MSGL_VGSM_INFO,"%d\n", state);
+        g_mt_video_is_barred = state == 0x03 ? TRUE : FALSE;
+}
+
+void set_call_waiting_entry(call_waiting_entry_t * entry, int num)
+{
+       if(num == 0)
+               memset(g_cw_entry, 0, sizeof(g_cw_entry));
+       else
+       {
+               g_cw_entry[num-1].tel_class = entry->tel_class;
+               g_cw_entry[num-1].ss_mode = entry->ss_mode;
+               g_cw_entry[0].count = num;
+               memset(&g_cw_entry[num-1].number, 0, MAX_GSM_DIALED_DIGITS_NUMBER);
+                memcpy(&g_cw_entry[num-1].number, &entry->number, strlen((char*)&entry->number));
+       }
+       log_msg(MSGL_VGSM_INFO,"[set_call_waiting_entry]--------class : %d, ss_mode : %d, num : %d\n", g_cw_entry[num-1].tel_class, g_cw_entry[num-1].ss_mode, num);
+}
+
+call_waiting_entry_t * get_call_waiting_entry()
+{
+       return (call_waiting_entry_t *)&g_cw_entry;
+}
+
+call_waiting_entry_t g_cw_entry_tmp;
+
+call_waiting_entry_t * find_call_waiting_entry(int tel_class)
+{
+       int i, status=4;
+       call_waiting_entry_t * entry ;
+
+       for(i = 0; i<g_cw_entry[0].count; i++)
+       {
+               log_msg(MSGL_VGSM_INFO,"%d. [%s] class : %d, ss_mode : %d with matching telclass : %d\n"
+                       , i, __FUNCTION__, g_cw_entry[i].tel_class, g_cw_entry[i].ss_mode, tel_class);
+
+               if(g_cw_entry[i].tel_class == tel_class){
+                       log_msg(MSGL_VGSM_INFO,"Found:  class : %d, ss_mode : %d\n"
+                               , g_cw_entry[i].tel_class, g_cw_entry[i].ss_mode);
+
+                       return &g_cw_entry[i];
+               }
+       }
+       
+       log_msg(MSGL_VGSM_INFO,"Not Found:  Fake return class : %d, ss_mode : %d\n"
+               , tel_class, status);
+
+       entry = &g_cw_entry_tmp ;
+
+       memset(entry, 0, sizeof(call_waiting_entry_t));
+       entry->tel_class = tel_class;
+       entry->ss_mode = status;
+       entry->count = 1;
+       strcpy(entry->number, SUBSCRIBER_NUM);
+       return entry;
+}
+
+void set_call_barring_entry(call_barring_entry_t * entry, int num)
+{
+       if(num == 0)
+       {
+               memset(g_cb_entry, 0, sizeof(call_barring_entry_t)*20);
+               g_cb_entry[0].count = 0;
+       }
+       else
+       {
+               g_cb_entry[num-1].tel_class = entry->tel_class;
+               g_cb_entry[num-1].type = entry->type;
+               g_cb_entry[num-1].ss_mode = entry->ss_mode;
+               g_cb_entry[0].count = num;
+       }
+       //      log_msg(MSGL_VGSM_INFO,"[set_call_barring_entry]--------class : %d, type : %d, ss_mode : %d, num : %d\n", g_cb_entry[num-1].tel_class, g_cb_entry[num-1].type, g_cb_entry[num-1].ss_mode, num);
+}
+
+call_barring_entry_t * get_call_barring_entry()
+{
+       return (call_barring_entry_t *)&g_cb_entry;
+}
+
+//class¿Í type°ªÀº ´Ù½Ã ¸®ÅÏÇØÁÙ ÇÊ¿ä°¡ ¾ø´Ù. -> status¸¸ ¾Ë·ÁÁָ頵Ê
+
+call_barring_entry_t g_cb_entry_tmp;
+
+int send_call_barring_entry(call_barring_entry_t* entry)
+{
+       unsigned char * data = 0;
+        int data_len =4 ;
+        int ss_status, ret;
+
+        log_msg(MSGL_VGSM_INFO,"entry->count = %d \n", entry->count);
+       if(entry->ss_mode == SS_MODE_REG || entry->ss_mode == SS_MODE_ACT)
+               ss_status = AT_SS_STATUS_ACTIVE;
+        else
+               ss_status = AT_SS_STATUS_NOT_ACTIVE;
+        
+        data_len =4;
+        data = malloc(sizeof(unsigned char) * data_len);
+        data[0] = entry->type;
+        data[1] = 1;    // entry->count 
+        data[2] = entry->tel_class;
+        data[3] = ss_status;
+
+        log_msg(MSGL_VGSM_INFO,"data[0] : %x\ndata[1] : %x\ndata[2] : %x\ndata[3] : %x\nss_mode : %x\n", data[0], data[1], data[2], data[3], entry->ss_mode);
+
+        ret = oem_tx_ss_cb_resp(data, data_len);
+        free(data);
+        
+       return 0;
+}
+
+call_barring_entry_t *  find_call_barring_entry(int tel_class, int type)
+{
+       int i, status = SS_MODE_DEACT, found = 0;
+       call_barring_entry_t * entry = (call_barring_entry_t*)malloc(sizeof(call_barring_entry_t));
+
+       log_msg(MSGL_VGSM_INFO,"1. [find_call_barring_entry]--------telclass : %d, type : %d\n", tel_class, type );
+       for(i = 0; i<g_cb_entry[0].count; i++)
+       {
+               log_msg(MSGL_VGSM_INFO,"2. [find_call_barring_entry]--------class : %d, ss_mode : %d, type : %d\n", g_cb_entry[i].tel_class, g_cb_entry[i].ss_mode, g_cb_entry[i].type);
+               
+               if((tel_class == AT_CALL_SS_CLASS_ALL) ? (g_cb_entry[i].type == type) : (g_cb_entry[i].tel_class == tel_class) && (g_cb_entry[i].type == type))
+               {
+                       log_msg(MSGL_VGSM_INFO,"entry: count %d \n", g_cb_entry[i].count);
+
+                       entry = &g_cb_entry_tmp;
+
+                       memset(entry, 0, sizeof(call_barring_entry_t));
+                       entry->tel_class = g_cb_entry[i].tel_class;
+                       //entry->tel_class = class;
+                       entry->type = g_cb_entry[i].type;
+                       if(entry->tel_class == AT_CALL_SS_CLASS_VIDEO)          // video call
+                       {
+                               if(g_cb_entry[i].type == SS_CB_TYPE_BOIC || g_cb_entry[i].type == SS_CB_TYPE_BOIC_NOT_HC)
+                               {
+                                       if(get_outgoing_video_call_barring_state())
+                                               entry->ss_mode = SS_MODE_ACT;
+                                       else
+                                               entry->ss_mode = g_cb_entry[i].ss_mode;
+                               }
+                               else if(g_cb_entry[i].type == SS_CB_TYPE_BIC_ROAM)
+                               {
+                                       if(get_incoming_video_call_barring_state())
+                                               entry->ss_mode = SS_MODE_ACT;
+                                       else
+                                               entry->ss_mode = g_cb_entry[i].ss_mode;
+                               }
+                               else
+                                       entry->ss_mode = g_cb_entry[i].ss_mode;
+                       }
+                       else                                    // voice call
+                       {
+                               if(g_cb_entry[i].type == SS_CB_TYPE_BOIC || g_cb_entry[i].type == SS_CB_TYPE_BOIC_NOT_HC)
+                                {
+                                        if(get_outgoing_voice_call_barring_state())
+                                                entry->ss_mode = SS_MODE_ACT;
+                                        else
+                                                entry->ss_mode = g_cb_entry[i].ss_mode;
+                                }
+                                else if(g_cb_entry[i].type == SS_CB_TYPE_BIC_ROAM)
+                                {
+                                        if(get_incoming_voice_call_barring_state())
+                                                entry->ss_mode = SS_MODE_ACT;
+                                        else
+                                                entry->ss_mode = g_cb_entry[i].ss_mode;
+                                }
+                                else
+                                        entry->ss_mode = g_cb_entry[i].ss_mode;
+                       }
+                       entry->count = g_cb_entry[i].count;     // it should be 0 ??? check plz...
+                       
+                       send_call_barring_entry(entry);
+                       found++;
+               }
+       }
+       if(found > 0)
+               return entry;
+
+       log_msg(MSGL_VGSM_INFO,"not found \n");
+
+       if(tel_class == AT_CALL_SS_CLASS_VIDEO)                 // video call
+       {       
+               if(type == SS_CB_TYPE_BAIC || type == SS_CB_TYPE_BIC_ROAM)      // incoming
+               {
+                       log_msg(MSGL_VGSM_INFO,"class: %d, type: %d \n", tel_class, type);
+                       if(get_incoming_video_call_barring_state())
+                               status = SS_MODE_ACT;
+                       else
+                               status = SS_MODE_DEACT;
+               }
+               else                                                    // outgoing
+               {
+                       log_msg(MSGL_VGSM_INFO,"class: %d, type: %d \n", tel_class, type);
+                       if(get_outgoing_video_call_barring_state())
+                               status = SS_MODE_ACT;
+                       else
+                               status = SS_MODE_DEACT;
+               }
+       }
+       else                                            // voice call
+       {
+               if(type == SS_CB_TYPE_BAIC || type == SS_CB_TYPE_BIC_ROAM)      // incoming
+                {
+                       log_msg(MSGL_VGSM_INFO,"class: %d, type: %d \n", tel_class, type);
+                        if(get_incoming_voice_call_barring_state())
+                                status = SS_MODE_ACT;
+                        else
+                                status = SS_MODE_DEACT;
+                }
+                else                                                    // outgoing
+                {
+                       log_msg(MSGL_VGSM_INFO,"class: %d, type: %d \n", tel_class, type);
+                        if(get_outgoing_voice_call_barring_state())
+                                status = SS_MODE_ACT;
+                        else
+                                status = SS_MODE_DEACT;
+                }
+       }
+       // À̺κРȮÀÎÇÏÀÚ. db¿¡ ¾ø´Â°ÍÀ» µ¥ÀÌŸ¸¦ ¾î\89F°Ô ÁÙÁö »ý°¢....
+       entry = &g_cb_entry_tmp ;
+
+       memset(entry, 0, sizeof(call_barring_entry_t));
+       entry->type = type;
+        entry->ss_mode = status;
+        entry->count = 1;
+
+       if(tel_class == AT_CALL_SS_CLASS_ALL)
+       {
+               entry->tel_class = AT_CALL_SS_CLASS_VOICE;
+               send_call_barring_entry(entry);
+               
+               entry->tel_class = AT_CALL_SS_CLASS_VIDEO;
+               send_call_barring_entry(entry);
+       }
+       else
+       {
+               entry->tel_class = tel_class;
+               send_call_barring_entry(entry);
+       }
+       
+       return entry;
+}
+
+void set_call_forwarding_entry(call_forwarding_entry_t * entry, int num)
+{
+       log_msg(MSGL_VGSM_INFO, "num: %d\n", num);
+       if(num == 0)
+               memset(g_cf_entry, 0, sizeof(call_forwarding_entry_t) * 20);
+       else
+       {
+               g_cf_entry[num-1].tel_class = entry->tel_class;
+               g_cf_entry[num-1].type = entry->type;
+               memset(&g_cf_entry[num-1].number, 0, MAX_GSM_DIALED_DIGITS_NUMBER);
+               memcpy(&g_cf_entry[num-1].number, &entry->number, strlen((char*)&entry->number));
+               g_cf_entry[num-1].replyTime = entry->replyTime;
+               g_cf_entry[num-1].ss_mode = entry->ss_mode;
+       }
+       g_cf_entry[0].count = num;
+       //      log_msg(MSGL_VGSM_INFO,"[set_call_forwarding_entry]--------[%s] -> <%s>\n", entry->number, g_cf_entry[num-1].number);
+}
+
+call_forwarding_entry_t * get_call_forwarding_entry()
+{
+       return (call_forwarding_entry_t *)&g_cf_entry;
+}
+
+call_forwarding_entry_t g_cf_entry_tmp;
+
+call_forwarding_entry_t * find_call_forwarding_entry(int tel_class, int type)
+{
+       int i, class;
+       call_forwarding_entry_t * entry ;
+
+       log_msg(MSGL_VGSM_INFO,"tel_class=0x%x  type=%d\n", tel_class,type);
+
+       for(i = 0; i<g_cf_entry[0].count; i++)
+       {
+               log_msg(MSGL_VGSM_INFO,"tel_class=0x%x  type=%d\n", g_cf_entry[i].tel_class,g_cf_entry[i].type);
+               // 090221 090418
+               if(g_cf_entry[i].tel_class == -1)
+                       class = 1;      // voice
+               if((class == tel_class) && (g_cf_entry[i].type == type))
+               {
+                       log_msg(MSGL_VGSM_INFO,"entry: count %d \n", g_cf_entry[i].count);
+
+                       entry = &g_cf_entry_tmp;
+
+                       memset(entry, 0, sizeof(call_forwarding_entry_t));
+                       //entry->tel_class = g_cf_entry[i].tel_class;
+                       entry->tel_class = class;
+                       entry->type = g_cf_entry[i].type;
+                       entry->ss_mode = g_cf_entry[i].ss_mode;
+                       entry->count = g_cf_entry[i].count;     // it should be 0 ??? check plz...
+                       strcpy(entry->number, g_cf_entry[i].number);
+                       entry->replyTime = g_cf_entry[i].replyTime;
+                       //entry->number[0] = '\0';
+                       //entry->replyTime = 0;
+
+                       return entry;
+                       //return &g_cf_entry[i];
+               }
+       }
+       log_msg(MSGL_VGSM_INFO,"entry is not found !!! \n");
+
+       // À̺κРȮÀÎÇÏÀÚ. db¿¡ ¾ø´Â°ÍÀ» µ¥ÀÌŸ¸¦ ¾î\89F°Ô ÁÙÁö »ý°¢....
+       //entry = (call_forwarding_entry_t *)malloc(sizeof(call_forwarding_entry_t));
+       entry = &g_cf_entry_tmp;
+
+       memset(entry, 0, sizeof(call_forwarding_entry_t));
+       entry->tel_class = tel_class;
+       entry->type = type;
+       entry->ss_mode = SS_MODE_DEACT;
+       entry->count = 1;       // it should be 0 ??? check plz...
+       entry->number[0] = '\0';
+       entry->replyTime = 0;
+
+       return entry;
+
+}
+
+///////////////////////////////////////////////////////////
+
+char* get_callbarring_pwd(void)
+{
+       return g_cb_pwd;
+}
+
+void set_callbarring_pwd(char* cb_pwd)
+{
+       strcpy(g_cb_pwd,cb_pwd);
+}
+
+int increase_callbarring_pwd_fail_count(void)
+{
+       g_cb_pwd_fail_count++;
+       return g_cb_pwd_fail_count;
+
+}
+
+void clear_callbarring_pwd_fail_count(void)
+{
+       g_cb_pwd_fail_count = 0;
+}
+
diff --git a/vmodem/db/gprs.db b/vmodem/db/gprs.db
new file mode 100644 (file)
index 0000000..f214fb5
Binary files /dev/null and b/vmodem/db/gprs.db differ
diff --git a/vmodem/db/network.db b/vmodem/db/network.db
new file mode 100644 (file)
index 0000000..a84071a
Binary files /dev/null and b/vmodem/db/network.db differ
diff --git a/vmodem/db/pb.db b/vmodem/db/pb.db
new file mode 100644 (file)
index 0000000..867eb29
Binary files /dev/null and b/vmodem/db/pb.db differ
diff --git a/vmodem/db/sim.db b/vmodem/db/sim.db
new file mode 100644 (file)
index 0000000..07b2d23
Binary files /dev/null and b/vmodem/db/sim.db differ
diff --git a/vmodem/db/ss.db b/vmodem/db/ss.db
new file mode 100644 (file)
index 0000000..bf81e73
Binary files /dev/null and b/vmodem/db/ss.db differ
diff --git a/vmodem/db/tmp/gprs.db b/vmodem/db/tmp/gprs.db
new file mode 100644 (file)
index 0000000..f214fb5
Binary files /dev/null and b/vmodem/db/tmp/gprs.db differ
diff --git a/vmodem/db/tmp/network.db b/vmodem/db/tmp/network.db
new file mode 100644 (file)
index 0000000..679a2a3
Binary files /dev/null and b/vmodem/db/tmp/network.db differ
diff --git a/vmodem/db/tmp/pb.db b/vmodem/db/tmp/pb.db
new file mode 100644 (file)
index 0000000..867eb29
Binary files /dev/null and b/vmodem/db/tmp/pb.db differ
diff --git a/vmodem/db/tmp/sim.db b/vmodem/db/tmp/sim.db
new file mode 100644 (file)
index 0000000..2a5839b
Binary files /dev/null and b/vmodem/db/tmp/sim.db differ
diff --git a/vmodem/db/tmp/ss.db b/vmodem/db/tmp/ss.db
new file mode 100644 (file)
index 0000000..05f2efd
Binary files /dev/null and b/vmodem/db/tmp/ss.db differ
diff --git a/vmodem/include/at/at_func.h b/vmodem/include/at/at_func.h
new file mode 100644 (file)
index 0000000..8f9658f
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_func.h
+*/
+
+#ifndef __AT_H__
+#define __AT_H__
+
+#include <stdint.h>
+#include "gsmstate.h"
+#include "at_recv.h"
+#include "state.h"
+
+/************************************* Defines ****************************************/
+/* common */
+#define TOKEN ","                      /* AT command token */
+#define CRLF "\r\n"
+#define SEND_BUF_SIZE 512
+
+/* display */
+#define CIEV "+CIEV:"                   /* DISP ICON INFO */
+#define SIGNAL 10
+#define BATTCHG 15
+
+/* security */
+#define STREADY "NO_LOCK"               /* PIN(sim) TYPE */
+#define STSC "LOCK_SC"
+#define STNOSIM "NO_SIM"
+#define SKUNLOCK "UNLOCKED"             /* PIN(sim) KEY */
+#define SKPIN "PIN"
+#define SKPUK "PUK"
+#define SKPERM_BLOCK "BLOCKED"
+#define STINIT_COMPL "INIT_COMP"
+#define CPIN "%SCSIM:"                 /* PIN STATUS */
+#define CRSM "+CRSM:"                  /* SEC RSIM ACCESS */
+#define SCCT "%SCCT:"
+#define CLCK "+CLCK:"                  /* PHONE LOCK */
+#define IMSI_NUM "262073997619483"      /* International Mobile Station Identity */
+
+/* call */
+#define RING "RING"                     /* CALL INCOMING */
+#define SCLCC "%SCLCC:"                 /* CALL LIST NOTI */
+#define CCWA "+CCWA:"                  /* CALL WAITING */
+#define CCFC "+CCFC:"                  /* CALL FORWARDING */
+#define CLCC "+CLCC:"                  /* CALL LIST */
+
+/* network */
+#define CREG "+CREG:"                  /* NET REGIST */
+#define CGREG "+CGREG:"
+#define COPS "+COPS:"                  /* NET PLMN */
+#define CNUM "+CNUM:"                  /* NET SUBSCRIBER NUM */
+#define CNITZ "%SCNITZ:"               /* NET IDENTITY */
+#define SUBSCRIBER_NUM "821010101010"
+
+/* misc */
+#define CGMR "+CGMR:"                  /* MISC ME VERSION */
+#define CTZR "+CTZR:"                  /* MISC V4 TIME INFO */
+
+/* gprs */
+#define CGDCONT "+CGDCONT:"            /* GPRS IP CONFIGURATION */
+#define EMUL_IP "10.0.2.16"            /* for gprs */
+#define IP "\"IP\""
+#define PPP "\"PPP\""
+#define IPV6 "\"IPV6\""
+#define UNKNOWN "\"UNKNOWN\""
+
+/* power */
+#define CPAS "+CPAS:"                  /* PWR PHONE PWR UP */
+#define SCFUN "%SCFUN:"                        /* FLIGHT MODE */
+#define FLIGHT_MODE_ON 0
+#define FLIGHT_MODE_OFF 1
+
+/* sms */
+#define CDEV "%SCDEV:"                 /* SMS DEVICE READY */
+#define CMT "+CMT:"                    /* SMS INCOMING */
+#define ATCMGS "AT+CMGS="              /* SMS OUTGOING */
+#define CMGS "+CMGS:"
+#define CPMS "+CPMS:"                  /* SMS STORED MSG COUNT */
+
+/************************************************************************************/
+
+/********************************* Type enum ****************************************/
+/* CALL SS CLASS field */
+typedef enum{
+  AT_CALL_SS_CLASS_VOICE = 1,
+  AT_CALL_SS_CLASS_DATA = 2,
+  AT_CALL_SS_CLASS_FAX = 4,
+  AT_CALL_SS_CLASS_ALL = 7,
+  AT_CALL_SS_CLASS_VIDEO = 16
+} at_call_ss_class_e_type;
+
+/* CALL CLASS field */
+typedef enum{
+  AT_CALL_CLASS_VOICE = 1,
+  AT_CALL_CLASS_FAX = 4,
+  AT_CALL_CLASS_SMS = 8,
+  AT_CALL_CLASS_DATA = 32
+} at_call_class_e_type;
+
+/* CALL DIRECTION field */
+typedef enum{
+  AT_CALL_DIR_MO = 0x00,       /* 0x00 : Mobile Originated Call ( MO Call ) */
+  AT_CALL_DIR_MT,              /* 0x01 : Mobile Terminated Call ( MT Call ) */
+} at_call_direction_e_type;
+
+/* CALL STAT field */
+typedef enum{
+  AT_CALL_STAT_ACTIVE = 0x00,  /* 0x00 : ACTIVE */
+  AT_CALL_STAT_HELD,
+  AT_CALL_STAT_DIALING,
+  AT_CALL_STAT_ALERTING,
+  AT_CALL_STAT_INCOMING,
+  AT_CALL_STAT_WAITING,
+  AT_CALL_STAT_CONNECTED,
+  AT_CALL_STAT_RELEASED,
+  AT_CALL_STAT_NONE
+} at_call_stat_e_type;
+
+/* CALL MODE field */
+typedef enum{
+  AT_CALL_MODE_VOICE = 0x00,   /* 0x00 : VOICE */
+  AT_CALL_MODE_DATA
+} at_call_mode_e_type;
+
+/* MODE  field */
+typedef enum {
+  GSM_SS_MODE_REG=0x01,         /* 0x01 : Registration */
+  GSM_SS_MODE_DEREG,            /* 0x02 : De-registration( erase ) */
+  GSM_SS_MODE_ACTIVATE,                /* 0x03 : Activation */
+  GSM_SS_MODE_DEACTIVATE,      /* 0x04 : De-activation */
+  GSM_SS_MODE_MAX,
+  GSM_SS_MODE_QUERY
+} gsm_ss_mode_e_type;
+
+typedef enum{
+  AT_CALL_FW_MODE_DISABLE = 0x00,
+  AT_CALL_FW_MODE_ENABLE,
+  AT_CALL_FW_MODE_QUERY,
+  AT_CALL_FW_MODE_REG,
+  AT_CALL_FW_MODE_ERASURE
+} at_call_fw_mode_e_type;
+
+typedef enum {
+  AT_SS_STATUS_NOT_ACTIVE = 0,    /* Service is not Active */
+  AT_SS_STATUS_ACTIVE = 1         /* Service is Active */
+}ss_status_e_type;
+
+/* SS CM_MODE field : Call Manage Mode */
+typedef enum {
+  AT_GSM_SS_CM_0_SEND = 0x00,  /* 0x00 : Releases all held calls or sets User Determined
+                                               User Busy (UDUB) for a waiting call*/
+  AT_GSM_SS_CM_1_SEND,          /* 0x01 : Releases all active calls (if any exist) and
+                                               accepts the other (held or waiting) call.*/
+  AT_GSM_SS_CM_2_SEND,          /* 0x02 : Places all active calls (if any exist) on hold
+                                               and accepts the other (held or waiting) call.*/
+  AT_GSM_SS_CM_3_SEND,          /* 0x03 : Adds a held call to the conversation.*/  
+  AT_GSM_SS_CM_4_SEND,          /* 0x04 : Connects the two calls and disconnects
+                                               the subscriber from both calls (ECT).*/
+  AT_GSM_SS_CM_1X_SEND,         /* 0x05 : Releases a specific active call X.
+                                               (also <INDEX> present)*/
+  AT_GSM_SS_CM_2X_SEND,         /* 0x06 : Places all active calls on hold except call X
+                                               with which communication shall be supported.
+                                               (also <INDEX> present)*/
+  AT_GSM_SS_CM_4DN_SEND,        /* 0x07 : Redirect an incoming or a waiting call
+                                               to the specified followed by SEND directory
+                                               number.(also <NUMBER> present)*/
+  AT_GSM_SS_CM_5_SEND,          /* 0x08 : Activates the Completion of Calls to
+                                               Busy Subscriber Request.*/
+  AT_GSM_SS_CM_6_SEND,          /* 0x0a : Release a held conference call.
+                                               (This is a special-case to enable us to pass
+                                               FTA case GSM 51.010 31.4.4.1.2.4) */
+  AT_GSM_SS_CM_MAX
+} at_gsm_ss_cm_mode_e_type;
+
+/* CALL MPTY field */
+typedef enum{
+  AT_CALL_MPTY_FALSE = 0x00,   /* 0x00 : FALSE */
+  AT_CALL_MPTY_TRUE
+} at_call_mpty_e_type;
+
+/* ICC TYPE field */
+typedef enum{
+  GSM_SEC_UNKNOWN,             /* 0x00 : UNKNOWN */
+  GSM_SEC_SIM,          
+  GSM_SEC_USIM,         
+  GSM_SEC_RSIM
+} gsm_sec_sim_e_type;
+
+typedef enum {
+  AT_GSM_PWR_UP_READY = 0x00,
+  AT_GSM_PWR_UP_UNAVAILABLE,
+  AT_GSM_PWR_UP_UNKNOWN,
+  AT_GSM_PWR_UP_RINGING,
+  AT_GSM_PWR_UP_CALLINPROGRESS,
+  AT_GSM_PWR_UP_ASLEEP
+} at_gsm_pwr_up_e_type;
+
+typedef enum {  
+  AT_GSM_PWR_PHONE_ONLINE_OFF = 0x00,          /* ONLINE OFF*/
+  AT_GSM_PWR_PHONE_ONLINE_ON,                  /* ONLINE ON */
+  AT_GSM_PWR_PHONE_ONLINE_MAX
+} at_gsm_pwr_phone_online_e_type;
+
+typedef enum {
+  AT_GSM_PWR_PHONE_RSN_ONLINE_OFF = 0x00,      /* LPM IN*/
+  AT_GSM_PWR_PHONE_RSN_ONLINE_ON,              /* LPM OUT,ONLINEl */
+  AT_GSM_PWR_PHONE_RSN_ONLINE_MAX,
+  AT_GSM_PWR_PHONE_RSN_ONLINE_FAIL,            /* EXCUTE FAIL*/
+} at_gsm_pwr_phone_online_noti_e_type;
+
+typedef enum{
+  AT_GSM_DISP_ICON_TYPE_RSSI           = 0x01, /* 0000 0001 : signal strength */
+  AT_GSM_DISP_ICON_TYPE_BAT            = 0x02, /* 0000 0010 : battery level   */
+  AT_GSM_DISP_ICON_TYPE_ACT            = 0x04, /* 0000 0100 : Protocol Standard: GSM,GPRS,UMTS   */
+  AT_GSM_DISP_ICON_TYPE_REGIST_STATUS  = 0x08, /* 0000 1000 : Registration status   */
+  AT_GSM_DISP_ICON_TYPE_ALL           = 0xFF,  /* 1111 1111 : ALL Values Request */
+} at_gsm_disp_icon_e_type;
+/************************************************************************************/
+
+/********************************* Functions ****************************************/
+char *readline(void);
+void prv_byte_to_char(unsigned char aByte, char* hexaCharP);
+void prv_bytes_to_hexadecimal_string(unsigned char* bytesP, int bytesSize, char* hexaStringP, int* hexaStringSize);
+
+uint8_t hexCharToInt(char c);
+int hexStringToBytes(char* d, char *s);
+
+int GSM_ATDispatchDpramData(GSM_StateMachine* pstate);
+int convert_hdlc_to_at(char* atmsg, char *data, int data_len);
+
+/* a function used to deal with a non-trivial request */
+typedef int  (*ResponseHandler)(char*  cmd, char* atmsg);
+/**********************************************************************************/
+
+/********************************* Structs ****************************************/
+static const struct {
+    char*                   cmd;                               /* if first character is '!', then the rest is a prefix only */
+    int             main_cmd;  
+    ResponseHandler  handler;                          /* specific handler, ignored if 'answer' is not NULL,
+                                                               NULL if OK is good enough */
+} sDefaultResponses[] =
+{
+    { "!+CGDCONT=", GSM_GPRS_CMD, at_recv_gprs },
+    { "+CGDCONT?", GSM_GPRS_CMD, at_recv_gprs },
+    { "!+CGACT=", GSM_GPRS_CMD, at_recv_gprs },
+    { "!D*99***1#", GSM_GPRS_CMD, at_recv_gprs },
+
+    /* see requestSendSMS() */
+    { "!+CMMS=", GSM_SMS_CMD, at_recv_sms },
+    { "!+CMGS=", GSM_SMS_CMD, at_recv_sms },
+    { "!+CPMS", GSM_SMS_CMD, at_recv_sms },
+    { "!+CNMA=", GSM_SMS_CMD, at_recv_sms },
+
+    { "!%SCMUT=", GSM_SND_CMD, at_recv_snd },          /* set SND MIC MUTE CTRL */
+    { "%SCMUT?", GSM_SND_CMD, at_recv_snd },           /* get SND AUDIO PATH CTRL */
+    { "!%SCAUD=", GSM_SND_CMD, at_recv_snd },          /* set SND AUDIO PATH CTRL */
+    { "!%SCCLK=", GSM_SND_CMD, at_recv_snd },          /* exec SND CLOCK CTRL */
+
+    /* see requestSIM_IO() */
+    { "!+CRSM=", GSM_SEC_CMD, at_recv_security },
+    { "!%SCCT", GSM_SEC_CMD, at_recv_security },        /* ICC type */
+    { "!+CPIN=", GSM_SEC_CMD, at_recv_security },
+        
+    { "!+CLCK=", GSM_SS_CMD, at_recv_ss },             /* call barring */
+    { "+CCWA=?", GSM_SS_CMD, at_recv_ss },             /* call waiting get */
+    { "!+CCWA=", GSM_SS_CMD, at_recv_ss },             /* call waiting set */
+    { "!+CHLD=", GSM_SS_CMD, at_recv_ss },             /* call hold */
+    { "!+CCFC=", GSM_SS_CMD, at_recv_ss },             /* call fowarding */
+    /* see requestQueryNetworkSelectionMode() */
+    { "+COPS?", GSM_NET_CMD, at_recv_network },
+    { "+COPS=?", GSM_NET_CMD, at_recv_network },
+    { "!+COPS=", GSM_NET_CMD, at_recv_network },
+    { "+CNUM", GSM_NET_CMD, at_recv_network },         /* get subscriber num */
+    { "+CREG?", GSM_NET_CMD, at_recv_network },                /* get network registration */
+    { "!+CREG=", GSM_NET_CMD, at_recv_network },       /* set unsolicited result */
+
+    { "+CGMR", GSM_MISC_CMD, at_recv_misc },           /* get me version */
+    { "+CGSN", GSM_MISC_CMD, at_recv_misc },                   /* request model version */
+    { "+CIMI", GSM_MISC_CMD, at_recv_misc },           /* request internation subscriber identification number */
+
+    { "+CLCC", GSM_CALL_CMD, at_recv_call },           /* get current call list */
+    { "A", GSM_CALL_CMD, at_recv_call },               /* answer */
+    { "!D", GSM_CALL_CMD, at_recv_call },              /* outgoing call */
+    { "!H", GSM_CALL_CMD, at_recv_call },              /* release the first call */
+
+    /* see requestRadioPower() */
+    { "!+CFUN=", GSM_PWR_CMD, at_recv_power },                 /* power online */
+    { "+CPAS", GSM_PWR_CMD, at_recv_power },                   /* power up noti */
+
+    /* end of list */
+    {NULL, 0, NULL}
+};
+
+static const struct {
+    const char*      fac;     
+    ss_cb_e_type     cb_e_type;
+} sDefaultFac[] =
+{
+    { "AO", SS_CB_TYPE_BAOC},          /* Barr All Outgoing Calls */   
+    { "OI", SS_CB_TYPE_BOIC},          /* Barr Outgoing International Calls */
+    { "OX", SS_CB_TYPE_BOIC_NOT_HC},   /* Barr Outgoing International Calls except to Home Country */
+    { "AI", SS_CB_TYPE_BAIC},          /* Barr All Incoming Calls */
+    { "IR", SS_CB_TYPE_BIC_ROAM},      /* Barr Incoming Calls when Roaming outside the home country */
+    { "AB", SS_CB_TYPE_AB},            /* All Barring services */
+    { "AG", SS_CB_TYPE_AOB},           /* All outGoing barring services */
+    { "AC", SS_CB_TYPE_AIB},           /* All inComing barring services */
+    { "NA", SS_CB_TYPE_BIC_NOT_SIM},   /* barr incoming calls from numbers Not stored in Any memory */
+
+    /* end of list */
+    {NULL, 0x00}
+};
+
+static const struct {
+    const char*                code;
+    gsm_sec_lock_e_type        lock_e_type;
+} sDefaultLock[] =
+{
+    { "READY", GSM_SEC_LOCK_TYPE_READY},       /* 0x00 : ME is not locked */
+    { "SIM PIN", GSM_SEC_LOCK_TYPE_SC},                /* 0x03 : Lock SIM/UICC card 
+                                                       ( SIM asks password in ME power-up and when this command is issued ) */
+    { "SIM PUK", GSM_SEC_LOCL_TYPE_PUK},       /* 0x0C : Lock PUK (... ) */
+    { "SIM PIN2", GSM_SEC_LOCK_TYPE_SC2},      /* 0x09 : Lock PIN2 ( ... ) */
+    { "SIM PUK2", GSM_SEC_LOCL_TYPE_PUK2},     /* 0x0A : Lock PUK2 (... ) */
+    /* end of list */
+    {NULL, 0x00}
+};
+/****************************************************************************************************************/
+
+#endif /* __AT_H__ */
+
diff --git a/vmodem/include/at/at_gen_resp.h b/vmodem/include/at/at_gen_resp.h
new file mode 100644 (file)
index 0000000..8352ce5
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_GEN_RESP_
+#define _At_GEN_RESP_
+
+#define AT_GEN_ERR_NO_ERROR            "OK"
+#define AT_GEN_ERR_OPER_NOT_SUPPORTED  "NOT SUPPORTED"
+#define AT_GEN_ERR_CONNECT             "CONNECT"
+#define AT_GEN_ERR_RELEASE             "NO CARRIER"
+
+#define AT_CME_ERR_INCORRECT_PWD       "+CME ERROR: 16"
+#define AT_CME_ERR_OPER_NOT_ALLOWED    "+CME ERROR: 3"
+#define AT_CMS_ERR_UNKNOWN_ERR         "+CMS ERROR: 500"
+
+#include "logmsg.h"
+
+void at_set_recv_cmd(char* atmsg);
+int get_at_msgseq(void);
+int at_gen_resp_send(char* call_gen_resp_err);
+
+#endif
diff --git a/vmodem/include/at/at_msg.h b/vmodem/include/at/at_msg.h
new file mode 100644 (file)
index 0000000..92a847e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_msg.h
+*/
+
+#ifndef __AT_TYPE_H__
+#define __AT_TYPE_H__
+#include "logmsg.h"
+
+// nsclass
+typedef struct attagHDLCFrame {
+       unsigned char   m_StartMagicCode;
+       unsigned short  m_Length;
+       unsigned char   m_CtrlInfo;             // control information id
+       void*                   m_pValue;
+       unsigned char   m_EndMagicCode;
+} HDLCFrame_t;
+
+// Last sent HDLC frame info
+void ATSetLastSentHDLCFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* ATGetLastSentHDLCFrameInfo(void);
+
+// Last receive HDLC frame info
+void ATSetLastRecvHDLCFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* ATGetLastRecvHDLCFrameInfo(void);
+
+void ATPushHDLCMultiFrameInfo(HDLCFrame_t const* pframe);
+HDLCFrame_t const* ATGetLastRecvHDLCMultiFrameInfo(void);
+char* ConvertHDLCMultiFrameToAT(void);
+void ATFreeAllMultiNodeList(void);
+
+// Last sent AT frame info
+void SetLastSentAT(char* atmsg);
+char* GetLastSentAT(void);
+
+// Last recv AT info
+void SetLastRecvAT(char* atmsg);
+char* GetLastRecvAT(void);
+
+int at_send_to_event_manager( int tx, int id, unsigned char *rawdata, int rawdatasize );
+int at_send_to_client( int tx, int id, char* atmsg );
+
+#endif /* __AT_TYPE_H__ */
+
diff --git a/vmodem/include/at/at_recv.h b/vmodem/include/at/at_recv.h
new file mode 100644 (file)
index 0000000..25689ad
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_recv.h
+*/
+
+#ifndef __AT_RECV_H__
+#define __AT_RECV_H__
+
+#include "at_msg.h"
+
+
+void NOT_SUPPORTED_AT(char* atmsg);
+
+void at_unimplemented(const char* api);
+
+int at_recv_power(char* cmd, char* atmsg);
+
+int at_recv_call(char* cmd, char* atmsg);
+
+int at_recv_data(char* cmd, char* atmsg);
+
+int at_recv_sms(char* cmd, char* atmsg);
+
+int at_recv_security(char* cmd, char* atmsg);
+
+int at_recv_phonebook(char* cmd, char* atmsg);
+
+int at_recv_display(char* cmd, char* atmsg);
+
+int at_recv_network(char* cmd, char* atmsg);
+
+int at_recv_sound(char* cmd, char* atmsg);
+
+int at_recv_misc(char* cmd, char* atmsg);
+
+int at_recv_svcmode(char* cmd, char* atmsg);
+
+int at_recv_ss(char* cmd, char* atmsg);
+
+int at_recv_gprs(char* cmd, char* atmsg);
+
+int at_recv_sat(char* cmd, char* atmsg);
+
+int at_recv_cfg(char* cmd, char* atmsg);
+
+int at_recv_sat(char* cmd, char* atmsg);
+int at_recv_generalcmd(char* cmd, char* atmsg);
+
+int at_recv_snd(char* cmd, char* atmsg);
+
+int at_recv_sap(char* cmd, char* atmsg);
+
+int at_recv_svc(char* cmd, char* atmsg);
+int at_recv_gps(char* cmd, char* atmsg);
+
+static inline void copy_unsigned_short(unsigned char *p, unsigned short val)
+{
+       p[0] = val & 0xff;
+       p[1] = (val >> 8)&0xff;
+}
+
+extern int AT_VERSION;
+
+#endif /* __AT_RECV_H__ */
diff --git a/vmodem/include/at/at_rx_call.h b/vmodem/include/at/at_rx_call.h
new file mode 100644 (file)
index 0000000..5b2f86b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_RX_CALL_H_
+#define _AT_RX_CALL_H_
+
+int at_rx_call_originate_exec(char* atmsg);
+int at_rx_call_list_get(char* atmsg);
+int at_rx_call_release_exec(char* atmsg);
+int at_rx_call_answer_exec(char* atmsg);
+int at_rx_call_line_id_set(char* atmsg);
+int at_rx_call_line_id_get(char* atmsg);
+int at_rx_call_burst_dtmf_exec(char* atmsg);
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_data.h b/vmodem/include/at/at_rx_data.h
new file mode 100644 (file)
index 0000000..c3c75e4
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int at_rx_data_GetDataCallStatus(char* atmsg);
+
+int at_rx_data_DefaultData(char* atmsg);
diff --git a/vmodem/include/at/at_rx_display.h b/vmodem/include/at/at_rx_display.h
new file mode 100644 (file)
index 0000000..24eca0a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_RX_DISPLAY_H_
+#define _AT_RX_DISPLAY_H_
+
+#include "at_msg.h"
+
+int at_rx_display_default(char* atmsg);
+int at_rx_display_icon_info_get(char* atmsg);
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_func.h b/vmodem/include/at/at_rx_func.h
new file mode 100644 (file)
index 0000000..436ad34
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_rx_func.h
+*/
+
+#ifndef __AT_RX_FUNC_H__
+#define __AT_RX_FUNC_H__
+
+#include <stdlib.h>
+
+#include "state.h"
+#include "at_msg.h"
+#include "gsmstate.h"
+#include "misc.h"
+
+/////////////////////////////////////////////////////////////////////
+int RxPWR_DefaultPower(char* atmsg);
+int at_rx_power_up_exec(char* atmsg);
+int at_rx_online_exec(char* atmsg);
+
+#endif /* __AT_RX_FUNC_H__ */
+
diff --git a/vmodem/include/at/at_rx_gprs.h b/vmodem/include/at/at_rx_gprs.h
new file mode 100644 (file)
index 0000000..75dfe1f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int at_rx_gprs_SetPDPContext(char* atmsg);
+
+int at_rx_gprs_SetPSActDeact(char* atmsg);
+
+int at_rx_gprs_DefaultGPRS(char* atmsg);
diff --git a/vmodem/include/at/at_rx_gps.h b/vmodem/include/at/at_rx_gps.h
new file mode 100644 (file)
index 0000000..94d2635
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_RX_GPS_
+#define _AT_RX_GPS_
+
+int at_gps_rx_open(char* atmsg);
+int at_gps_rx_close(char* atmsg);
+int at_gps_rx_start(char* atmsg);
+int at_gps_xtra_set_xtra_enable(char* atmsg);
+int at_gps_agps_set_ssl(char* atmsg);
+int at_gps_agps_mode(char* atmsg);
+
+#endif /* _AT_RX_GPS_ */
diff --git a/vmodem/include/at/at_rx_misc.h b/vmodem/include/at/at_rx_misc.h
new file mode 100644 (file)
index 0000000..6790b62
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_RX_MISC__
+#define __AT_RX_MISC__
+
+#include <time.h>
+
+int at_rx_misc_me_version(char* atmsg);
+int at_rx_misc_me_serial(char* atmsg);
+int at_rx_misc_time_info_get(char* atmsg);
+int at_RxMISC_DefaultMisc(char* atmsg);
+
+#endif /* __AT_RX_MISC__ */
diff --git a/vmodem/include/at/at_rx_network.h b/vmodem/include/at/at_rx_network.h
new file mode 100644 (file)
index 0000000..943ec86
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_RX_NETWORK_H_
+#define _AT_RX_NETWORK_H_
+
+#include "at_msg.h"
+
+int at_rx_net_default(char* atmsg);
+int at_rx_net_plmn_list_get(void);
+int at_rx_net_current_plmn_get(void);
+int at_rx_net_reg_get(void);
+int at_rx_net_plmn_selection_get(void);
+
+int at_rx_net_plmn_selection_set(char* atmsg);
+
+int at_rx_net_band_set(char* atmsg);
+int at_rx_net_band_get(char* atmsg);
+int at_rx_net_service_domain_set(char* atmsg);
+int at_rx_net_service_domain_get(char* atmsg);
+int at_rx_net_mode_sel_set(char* atmsg);
+int at_rx_net_mode_sel_get(char* atmsg);
+int at_rx_net_pref_plmn_set(char* atmsg);
+int at_rx_net_pref_plmn_get(char* atmsg);
+int at_rx_net_subscriber_num_get(char* atmsg);
+
+void at_cast_network_band_set(unsigned char band_mode, int band);
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_phonebook.h b/vmodem/include/at/at_rx_phonebook.h
new file mode 100644 (file)
index 0000000..cce30fd
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _AT_RX_PHONEBOOK_H_
+#define        _AT_RX_PHONEBOOK_H_
+
+int at_rx_sim_pb_default(char* atmsg);
+
+int at_rx_sim_pb_access(char* atmsg);
+
+int at_rx_sim_pb_get_storage_cnt(char* atmsg);
+
+int at_rx_sim_pb_get_entry_info(char* atmsg);
+
+int at_rx_sim_pb_get_storage_list(char* atmsg);
+
+int at_rx_sim_pb_get_capability_info(char* atmsg);
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_sap.h b/vmodem/include/at/at_rx_sap.h
new file mode 100644 (file)
index 0000000..572c7f6
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+#include "at_msg.h"
+
+int at_rx_sap_Connect(char* atmsg);
+int at_pc_rx_sap_Status(char* atmsg);
+int at_rx_sap_transfer_atr(char* atmsg);
+int at_rx_sap_transfer_apdu(char* atmsg);
+int at_rx_sap_transport_protocol(char* atmsg);
+int at_rx_sap_sim_power(char* atmsg);
+int at_rx_sap_transfer_card_reader_status(char* atmsg);
+int at_rx_sap_DefaultSAP(char* atmsg);
+int at_rx_sap_Status(char* atmsg);
+
diff --git a/vmodem/include/at/at_rx_sat.h b/vmodem/include/at/at_rx_sat.h
new file mode 100644 (file)
index 0000000..6fed5cf
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_RX_SAT__
+#define __AT_RX_SAT__
+
+#include "at_msg.h"
+
+int at_rx_sat_envelope_cmd(char* atmsg);
+int at_rx_sat_proactive_cmd(char* atmsg);
+int at_RxSAT_DefaultSAT(char* atmsg);
+int at_RxSAT_TerminalResponse(char* atmsg);
+int at_RxSAT_EnvelopeResponse(char* atmsg);
+int at_RxSAT_ResProfileDownload(char* atmsg);
+
+#endif /* __AT_RX_SAT__ */
diff --git a/vmodem/include/at/at_rx_security.h b/vmodem/include/at/at_rx_security.h
new file mode 100644 (file)
index 0000000..d31052a
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _AT_RX_SECURITY_H_
+#define        _AT_RX_SECURITY_H_
+
+int at_rx_sim_sec_default(char* atmsg);
+
+int at_rx_sim_sec_imsi(char* atmsg);
+
+int at_rx_sim_sec_pin_status(char* atmsg);
+
+int at_rx_sim_sec_lock_info(char* atmsg);
+
+int at_rx_sim_sec_change_password(char* atmsg);
+
+int at_rx_sim_sec_phone_lock(char* atmsg);
+int at_rx_sim_sec_phone_lock_get(char* atmsg);
+
+int at_rx_sim_sec_rsim_access(char* atmsg);
+
+int at_rx_sim_sec_card_type(char* atmsg);
+
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_sms.h b/vmodem/include/at/at_rx_sms.h
new file mode 100644 (file)
index 0000000..4b71386
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int at_rx_sms_SendMsg(char* atmsg);
+int at_rx_sms_deliver_report_exec(char* atmsg);
+
+int at_rx_sms_SCA(char* atmsg);
+
+int at_rx_sms_DefaultSms(char* atmsg);
+
+
+// 090310
+int at_rx_sms_DR(char* atmsg);
+
+int at_rx_sms_param(char* atmsg);
+int at_rx_sms_stored_msg_status(char* atmsg);
+int at_rx_sms_param_count_get(char* atmsg);
+
+
+int at_rx_sms_mem_status_set(char* atmsg);
+
+int at_rx_sms_cbconfig(char* atmsg);
+int at_rx_sms_stored_msg_count_get(char* atmsg);
+int at_rx_sms_svc_option_set(char* atmsg);
+
+unsigned char* at_rx_sms_param_get(unsigned char* len);
+int at_rx_sms_param_set(char* atmsg);
+static void at_rx_sms_param_init(void);
+int sms_param_set_vconf(void);
diff --git a/vmodem/include/at/at_rx_snd.h b/vmodem/include/at/at_rx_snd.h
new file mode 100644 (file)
index 0000000..ab3cbe0
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_RX_SND__
+#define __AT_RX_SND__
+
+
+#include "at_msg.h"
+
+int at_rx_snd_mute_control_get(char* atmsg);
+
+int at_rx_snd_mute_control_set(char* atmsg);
+
+int at_rx_snd_audio_path_set(char* atmsg);
+
+int at_rx_snd_clock_ctrl_exec(char* atmsg);
+
+#endif
+
diff --git a/vmodem/include/at/at_rx_ss.h b/vmodem/include/at/at_rx_ss.h
new file mode 100644 (file)
index 0000000..fa75f95
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_RX_SS_H_
+#define _AT_RX_SS_H_
+
+#include "at_msg.h"
+
+int at_rx_ss_default(char* atmsg);
+int at_rx_ss_manage_call_set(char* atmsg);
+
+int at_rx_ss_cw_get(char* atmsg);                      // response
+int at_rx_ss_cw_set(char* atmsg);
+int at_rx_ss_cf_get(char* atmsg);
+int at_rx_ss_cf_set(char* atmsg);
+int at_rx_ss_cb_get(char* atmsg);
+int at_rx_ss_cb_set(char* atmsg);
+int at_rx_ss_cb_passwd_set(char* atmsg);
+int at_rx_ss_aoc_set(char* atmsg);
+int at_rx_ss_aoc_get(char* atmsg);
+int at_rx_ss_cli(void);
+
+#endif
+
diff --git a/vmodem/include/at/at_send.h b/vmodem/include/at/at_send.h
new file mode 100644 (file)
index 0000000..fdd0eb4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_send.h
+*/
+
+#ifndef __AT_SEND_H__
+#define __AT_SEND_H__
+
+#define ACK_SEQ_NOTIFICATION 0xff
+#define ACK_SEQ_RESPONSE 0x00
+
+int at_msg_send(unsigned char ack, void *data, int datasize);
+
+#endif /* __AT_SEND_H__ */
+
diff --git a/vmodem/include/at/at_tx_call.h b/vmodem/include/at/at_tx_call.h
new file mode 100644 (file)
index 0000000..517404c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_TX_CALL_
+#define _AT_TX_CALL_
+
+int at_tx_call_connect_noti(void *data, int len);
+int at_tx_call_incoming_noti(void *data, int len);
+int at_tx_call_waiting_noti(void *data, int len);
+int at_tx_call_list_noti(void *data, int len);
+int at_tx_call_list_resp(void *data, int len);
+int at_tx_call_status_noti(void *data, int len);
+int at_tx_call_burst_dtmf_noti(void *data, int len);
+int at_tx_call_line_id_resp(void *data, int len);
+int at_tx_call_gen_resp(char* resp);
+
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_data.h b/vmodem/include/at/at_tx_data.h
new file mode 100644 (file)
index 0000000..4b8c1f4
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int at_tx_data_CallStatus(void *data, int len);
+
+int at_tx_data_DataCallStatus(void *data, int len);
diff --git a/vmodem/include/at/at_tx_display.h b/vmodem/include/at/at_tx_display.h
new file mode 100644 (file)
index 0000000..31e3d37
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_TX_DISPLAY_
+#define _AT_TX_DISPLAY_
+#include "logmsg.h"
+
+int at_tx_display_icon_info_noti(void *data, int len);
+int at_tx_display_icon_info_resp(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_func.h b/vmodem/include/at/at_tx_func.h
new file mode 100644 (file)
index 0000000..efa1bc2
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_tx_func.h
+*/
+
+#ifndef __AT_TX_FUNC_H__
+#define __AT_TX_FUNC_H__
+
+#include <vgsm_network.h>
+//#include <vgsm_sim.h>
+//#include <mzgsmpb.h>
+#include <vgsm_sat.h>
+#include <vgsm_ss.h>
+#include <vgsm_gprs.h>
+#include <vgsm_call.h>
+#include <vgsm_display.h>
+#include <vgsm_data.h>
+#include <linuxtapi.h>
+
+#include "state.h"
+#include "logmsg.h"
+#include "at_msg.h"
+//#include "db_phonebook.h"
+
+// 14. GSM_SAT_CMD
+int TxSAT_ATGetProactiveCommand(GSM_SatProactiveCmd const* cmd);
+int TxGCMD_SendGeneralResponse(char* atmsg);
+
+// EMULATOR
+int ATTxEmulator_HDLC_Req(LXT_MESSAGE const* packet);
+int ATTxEmulator_HDLC_Mode(LXT_MESSAGE const* packet);
+int ATTxEmulator_HDLC_Clear(void);
+int ATTxEmulator_Set_General_Response_Error(LXT_MESSAGE const* packet);
+int ATTxEmulator_Set_SS_General_Response_Error(LXT_MESSAGE const* packet);
+int ATTxEmulator_Set_Call_Status_Error(LXT_MESSAGE const* packet);
+int ATTxEmulator_Set_SCA(LXT_MESSAGE const* packet);
+int ATTxEmulator_Set_SS_Response_Error(LXT_MESSAGE const* packet, int ss_error_type);
+void ATset_sca( SmsAddressInfo SCA );
+
+#endif /* __AT_TX_FUNC_H__ */
+
diff --git a/vmodem/include/at/at_tx_gprs.h b/vmodem/include/at/at_tx_gprs.h
new file mode 100644 (file)
index 0000000..2aba397
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "logmsg.h"
+
+int at_tx_gprs_IPConfigurationNotify(void *data, int len);
+
diff --git a/vmodem/include/at/at_tx_misc.h b/vmodem/include/at/at_tx_misc.h
new file mode 100644 (file)
index 0000000..17dd328
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_TX_MISC__
+#define __At_TX_MISC__
+
+#include <time.h>
+//#include "at_msg.h"
+#include "logmsg.h"
+
+int at_tx_misc_version(void *data, int len);
+int at_tx_misc_me_serial(int sn_index, const void *data, int len);
+int at_tx_misc_time_info(char* atmsg, const struct tm *tm);
+
+#endif /* __AT_TX_MISC__ */
diff --git a/vmodem/include/at/at_tx_network.h b/vmodem/include/at/at_tx_network.h
new file mode 100644 (file)
index 0000000..7fc58cb
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_TX_NETWORK_
+#define _AT_TX_NETWORK_
+#include "logmsg.h"
+
+int at_tx_net_plmn_list_noti(void *data, int len);
+int at_tx_net_plmn_list_resp(void *data, int len);
+int at_tx_net_reg_noti(void *data, int len);
+int at_tx_net_reg_resp(void *data, int len);
+int at_tx_net_current_plmn_noti(void *data, int len);
+int at_tx_net_current_plmn_resp(void *data, int len);
+int at_tx_net_plmn_selection_resp(void *data, int len);
+int at_tx_gen_resp(void *data, int len);
+int at_tx_net_current_nitz_noti(void *data, int len);
+int at_tx_net_svc_domain_resp(void *data, int len);
+int at_tx_net_band_get_resp(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_phonebook.h b/vmodem/include/at/at_tx_phonebook.h
new file mode 100644 (file)
index 0000000..e3c34b3
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _AT_TX_PHONEBOOK_H_
+#define        _AT_TX_PHONEBOOK_H_
+
+int at_tx_sim_pb_get_storage_cnt_res(void* ptr_data, int data_len);
+
+int at_tx_sim_pb_get_entry_info_res(void* ptr_data, int data_len);
+
+int at_tx_sim_pb_get_storage_list_res(void* ptr_data, int data_len);
+
+int at_tx_sim_pb_set_access_res(int error);
+
+int at_tx_sim_pb_get_access_res(void* ptr_data, int data_len);
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_power.h b/vmodem/include/at/at_tx_power.h
new file mode 100644 (file)
index 0000000..dfb0e68
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_TX_POWER_
+#define _AT_TX_POWER_
+
+int at_tx_power_up_resp(void *data, int len);
+int at_tx_power_online_noti(void *data, int len);
+int at_tx_battery_status_noti(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_security.h b/vmodem/include/at/at_tx_security.h
new file mode 100644 (file)
index 0000000..6d2448f
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _AT_TX_SECURITY_H_
+#define        _AT_TX_SECURITY_H_
+
+#include "logmsg.h"
+
+int at_tx_sim_sec_get_imsi_res(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_set_pin_status_res(int error);
+
+int at_tx_sim_sec_get_pin_status_res(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_get_lock_info_res(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_change_password_res(void* ptr_data);
+
+int at_tx_sim_sec_set_phone_lock_res(int error);
+
+int at_tx_sim_sec_get_phone_lock_res(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_set_rsim_access_res(int error);
+
+int at_tx_sim_sec_get_rsim_access_res(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_card_type_noti(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_pin_status_noti(void* ptr_data, int data_len);
+
+int at_tx_sim_sec_phone_lock_resp(unsigned char lock_type);
+
+int at_tx_sim_sec_card_type_resp(int card_type);
+
+#endif
+
diff --git a/vmodem/include/at/at_tx_sms.h b/vmodem/include/at/at_tx_sms.h
new file mode 100644 (file)
index 0000000..665a169
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_TX_SMS_H__
+#define __AT_TX_SMS_H__
+
+#include "at_msg.h"
+#include "logmsg.h"
+
+int at_tx_sms_deviceReady(void *data, int len);
+
+int at_tx_sms_NotiIncomingMsg(void *data, int len);
+
+int at_tx_sms_sendDeliverReport(void *data, int len);
+
+int at_tx_sms_sendMsg(void *data, int len);
+
+int at_tx_sms_sendCBSMsg(void *data, int len);
+
+int at_tx_sms_SCA(void *data, int len);
+
+int at_tx_sms_cbconfig_resp(unsigned char enabled, unsigned char selected_id, unsigned char list_max, unsigned char list_count, unsigned short *list);
+
+int at_tx_sms_stored_msg_count_resp(void);
+int at_tx_sms_deliver_report_noti(int result_status);
+
+int at_tx_sms_param_count_resp(unsigned char mem_store, unsigned char record_count);
+int at_tx_sms_param_resp(unsigned char mem_store, unsigned char record_index, unsigned char record_len, unsigned char *record);
+
+
+#endif /* __AT_TX_SMS_H__ */
diff --git a/vmodem/include/at/at_tx_snd.h b/vmodem/include/at/at_tx_snd.h
new file mode 100644 (file)
index 0000000..93f2730
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __AT_TX_SND__
+#define __At_TX_SND__
+
+int at_tx_snd_mute_control_resp(void *data, int len);
+
+#endif /* __AT_TX_SND__ */
diff --git a/vmodem/include/at/at_tx_ss.h b/vmodem/include/at/at_tx_ss.h
new file mode 100644 (file)
index 0000000..fccaf30
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _AT_TX_SS_
+#define _AT_TX_SS_
+
+int at_tx_ss_ssinfo_noti(void *data, int len);
+int at_tx_ss_cw_resp(void *data, int len);
+int at_tx_ss_cb_resp(void *data, int len);
+int at_tx_ss_cf_resp(void *data, int len);
+
+int at_tx_ss_gen_resp(void *data);
+
+int at_tx_ss_aoc_resp(void *data, int len);
+
+int at_tx_ss_aoc_noti(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/db/db_gprs.h b/vmodem/include/db/db_gprs.h
new file mode 100644 (file)
index 0000000..6952836
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __DB_GPRS_H__
+#define __DB_GPRS_H__
+
+#include "vgsm_gprs.h"
+
+
+typedef struct _GprsDbEntry {
+       char apn[255];
+       char intf[10];
+       GSM_GprsIPConfiguration ipconf;
+} GprsDbEntry;
+
+
+typedef struct _GprsConfList {
+       int num;
+       GprsDbEntry *pentry;
+} GprsConfList;
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+// initialize the database
+int vgsm_gprs_database_init(void);
+
+// add a registration
+int vgsm_gprs_database_add(GprsDbEntry *entry);
+
+// remove a registration
+int vgsm_gprs_database_remove(GprsDbEntry *entry);
+
+// restore all previously save registrations
+int vgsm_gprs_database_restore(void);
+
+#ifdef __cplusplus
+};
+#endif
+
+
+extern GprsDbEntry g_gprs_ipconf;
+extern GprsConfList g_gprs_conflist;
+
+#endif // __DB_GPRS_H__
+
diff --git a/vmodem/include/db/db_network.h b/vmodem/include/db/db_network.h
new file mode 100644 (file)
index 0000000..b4275ba
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __DB_NETWORK_H__
+#define __DB_NETWORK_H__
+
+
+typedef struct _NetworkEntry {
+       int id;
+       int PLMN_status;
+//     int number_PLMN;
+       char number_PLMN[6];
+       int ACT;
+       void * callback;
+       struct _NetworkEntry * next;
+} NetworkEntry;
+
+
+// initialize the database
+int vgsm_network_database_init(void);
+
+// add a registration
+int vgsm_network_database_add(NetworkEntry * entry);
+
+// remove a registration
+int vgsm_network_database_remove(NetworkEntry * entry);
+
+// restore all previously save registrations
+int vgsm_network_database_restore(void);
+
+
+#endif // __DB_NETWORK_H__
+
diff --git a/vmodem/include/db/db_phonebook.h b/vmodem/include/db/db_phonebook.h
new file mode 100644 (file)
index 0000000..ea810fe
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+
+#ifndef __DB_PHONEBOOK_H__
+#define __DB_PHONEBOOK_H__
+
+#include <sqlite3.h>
+
+#define PB_SUCCESS     100
+#define PB_FAIL        0
+
+typedef struct _PB PB;
+struct _PB {
+       int db_st_type;
+//     int index;
+       char name[30];
+       char number[20];
+       char address[30];
+       int cnt;
+};
+       
+typedef enum {
+       DB_REQ=0,       
+       DB_DC =1,
+       DB_EN =2,
+       DB_FDN,
+       DB_LDN,
+       DB_MC,
+       DB_ME,
+       DB_MT,
+       DB_OWN,
+       DB_RC,
+       DB_ADN,
+       DB_SDN
+}PB_ST_type;
+
+
+
+int db_sim_pb_restore_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_cnt_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_get_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_setted_storage_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_pb_create(void);
+
+
+int db_sim_pb_add(PB *pb);
+
+
+int db_sim_pb_remove(PB *pb);
+
+
+int db_sim_pb_cnt_mgr(sqlite3 * db,int pb_type,int action);
+
+
+int db_sim_pb_restore(PB *pb);
+
+
+int db_sim_pb_get(PB *pb);
+
+
+int db_sim_pb_set_mgr(int pb_type,int action);
+
+
+int db_sim_pb_get_check(PB *pb);
+
+
+#endif
+
diff --git a/vmodem/include/db/db_security.h b/vmodem/include/db/db_security.h
new file mode 100644 (file)
index 0000000..f99560d
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __DB_SECURITY_H__
+#define __DB_SECURITY_H__
+
+#define        SIM_SUCCESS     100
+#define        SIM_FAIL                0
+
+/* move to vgsm_sim.h
+typedef struct _SimSecurity SimSecurity;
+
+struct _SimSecurity {
+       char pin_value[9];
+       char pin2_value[9];
+       char puk_value[9];
+       char puk2_value[9];
+       
+       int pin_cnt;
+       int pin2_cnt;
+       int puk_cnt;
+       int puk2_cnt;
+       int sim_state;
+       int facility_pin;
+       int facility_fdn;
+       int lock_sc2_state;
+};
+*/
+typedef enum {
+       DB_PIN =0,
+       DB_PIN2 =1,
+       DB_PUK,
+       DB_PUK2,
+       DB_PIN_CNT,
+       DB_PIN2_CNT,
+       DB_PUK_CNT,
+       DB_PUK2_CNT,
+       DB_SIM_STATE,
+       DB_F_PIN,
+       DB_F_FDN,
+       DB_LOCK_SC2_STATE
+}Db_table_type;
+
+typedef enum
+{
+       VGSM_SIMTypeLoad = 1,
+       VGSM_SIMTypeget
+}VGSM_SIMType;
+
+
+int db_sim_sec_restore_callback(void * ref, int ncol, char ** cols, char ** name);
+
+
+int db_sim_sec_create(void);
+
+
+int db_sim_sec_add(void);
+
+
+int db_sim_sec_remove(void);
+
+
+int db_sim_sec_restore(VGSM_SIMType type);
+
+
+int db_sim_sec_edit(int db_type,char *data,int data2);
+
+
+int db_sim_info_create(void);
+
+
+int db_sim_data_create(void);
+
+
+int db_sim_info_add(int index, _SIMD_t *simd_t);
+
+
+int db_sim_data_add(int index, _SIMD_t *simd_t);
+
+
+int db_sim_info_restore(char* table);
+
+
+int db_sim_data_restore(char* table);
+
+
+int _sim_get_file_info(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_info, /* out */ int* file_info_len/* out */);
+int _sim_get_file_data(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_data, /* out */ int* file_data_len/* out */);
+int _sim_get_file_info_tmp(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_info, /* out */ int *file_info_len/* out */);
+int _sim_get_file_data_tmp(gsm_sec_sim_file_id_t file_id,/* in */ unsigned char* pfile_data, /* out */ int* file_data_len/* out */);
+
+#endif /* __DB_SECURITY_H__ */
+
diff --git a/vmodem/include/db/db_ss.h b/vmodem/include/db/db_ss.h
new file mode 100644 (file)
index 0000000..291c116
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __DB_SS_H__
+#define __DB_SS_H__
+
+
+#include "vgsm_ss.h"
+
+
+int vgsm_ss_database_init(void);
+int vgsm_ss_database_add(ss_cmd_e_type type, void * entry);
+int vgsm_ss_database_remove(ss_cmd_e_type type, int tel_class, int ss_type);
+int vgsm_ss_database_restore(ss_cmd_e_type type);
+
+void set_call_waiting_entry(call_waiting_entry_t * entry, int num);
+call_waiting_entry_t * get_call_waiting_entry(void);
+call_waiting_entry_t * find_call_waiting_entry(int tel_class);
+
+void set_call_barring_entry(call_barring_entry_t * entry, int num);
+call_barring_entry_t * get_call_barring_entry(void);
+call_barring_entry_t *  find_call_barring_entry(int tel_class, int type);
+
+void set_call_forwarding_entry(call_forwarding_entry_t * entry, int num);
+call_forwarding_entry_t * get_call_forwarding_entry(void);
+call_forwarding_entry_t * find_call_forwarding_entry(int tel_class, int type);
+
+void set_outgoing_call_barring_state(int state);
+int get_outgoing_call_barring_state(void);
+
+/////////////////////
+char* get_callbarring_pwd(void);
+void set_callbarring_pwd(char* cb_pwd);
+int increase_callbarring_pwd_fail_count(void);
+void clear_callbarring_pwd_fail_count(void);
+
+//090225
+int  vgsm_ss_sqlite_cw_check_exist (int);
+
+#endif
+
diff --git a/vmodem/include/logmsg.h b/vmodem/include/logmsg.h
new file mode 100644 (file)
index 0000000..52ed5a2
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+ * Copyright (C) 2007 All rights reserved.
+ *
+ * @file logmsg.h
+ * @brief - header file
+ *
+ * @defgroup
+ *
+ * $Id: logmsg.h,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+ *
+ * <Revision History>
+ *             0000-00-00:
+ */
+#ifndef LOGMSG_H
+#define LOGMSG_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <time.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#define log_msg(level, fmt, args...)   real_log_msg(level, "%s:%d [%s] " fmt , __FILE__, __LINE__, __FUNCTION__, ##args)
+
+#define MODNAME_MAX    64
+#define MSGSIZE_MAX    2048
+
+#define MSGL_DEFAULT   1
+#define MSGL_FATAL     0       /* system reboot, rmmod  */
+#define MSGL_VGSM_ERR   1       /* exit/terminate/abort */
+#define MSGL_WARN      2       /* continue but problems */
+#define MSGL_VGSM_INFO  3       /* hint, system status */
+#define MSGL_VGSM_CALL  4       /* information for vgsm */
+#define MSGL_VGSM_SMS  5       /* information for vgsm */
+#define MSGL_VGSM_SIM  6       /* information for vgsm */
+#define MSGL_VGSM_SS   7       /* information for vgsm */
+#define MSGL_VGSM_NET  8       /* information for vgsm */
+#define MSGL_VGSM_GPRS  9       /* information for vgsm */
+#define MSGL_VGSM_DISP  10      /* information for vgsm */
+#define MSGL_VGSM_AT   11      /* error for vgsm */
+#define MSGL_FILE       12      /* save all above info as file */
+
+void real_log_msg(int level, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+void ge_log_msg_init(char *mod);
+
+#define TRACE(level, fmt, args...) log_msg(level, fmt, ## args)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ifndef LOGMSG_H */
+/**
+ * vim:set tabstop=4 shiftwidth=4 foldmethod=marker wrap:
+ *
+ */
+
diff --git a/vmodem/include/oem/oem_rx_call.h b/vmodem/include/oem/oem_rx_call.h
new file mode 100644 (file)
index 0000000..9e1b98b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_RX_CALL_
+#define _OEM_RX_CALL_
+
+int oem_rx_call_list_get(void);
+int oem_rx_call_answer_exec(void);
+int oem_rx_call_originate_exec(void * ptr_data, int data_len);
+int oem_rx_call_release_exec(void);
+int oem_rx_call_burst_dtmf_exec(void);
+int oem_rx_call_line_id_set(void * ptr_data, int data_len);
+int oem_rx_call_line_id_get(void);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_rx_data.h b/vmodem/include/oem/oem_rx_data.h
new file mode 100644 (file)
index 0000000..7719a60
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_rx_data_GetDataCallStatus(void * ptr_data, int data_len);
diff --git a/vmodem/include/oem/oem_rx_display.h b/vmodem/include/oem/oem_rx_display.h
new file mode 100644 (file)
index 0000000..9a31029
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_RX_DISPLAY_
+#define _OEM_RX_DISPLAY_
+
+int  oem_rx_display_icon_info_get(void);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_rx_gprs.h b/vmodem/include/oem/oem_rx_gprs.h
new file mode 100644 (file)
index 0000000..df14306
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_rx_gprs_SetPDPContext(void * ptr_data, int data_len);
+
+int oem_rx_gprs_SetPSActDeact(void * ptr_data, int data_len);
diff --git a/vmodem/include/oem/oem_rx_misc.h b/vmodem/include/oem/oem_rx_misc.h
new file mode 100644 (file)
index 0000000..eb2c234
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __OEM_RX_MISC__
+#define __OEM_RX_MISC__
+
+int oem_rx_misc_me_version(unsigned char flags);
+
+#endif /* __OEM_RX_MISC__ */
diff --git a/vmodem/include/oem/oem_rx_network.h b/vmodem/include/oem/oem_rx_network.h
new file mode 100644 (file)
index 0000000..58bf028
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_RX_NETWORK_
+#define _OEM_RX_NETWORK_
+
+int  oem_rx_net_plmn_list_get(void);
+int  oem_rx_net_reg_get(void);
+int  oem_rx_net_current_plmn_get(void);
+int  oem_rx_net_plmn_selection_get(void);
+int  oem_rx_net_plmn_selection_set(void * ptr_data, int data_len);
+int  oem_rx_net_band_get(void);
+int  oem_rx_net_band_set(void * ptr_data, int data_len);
+int  oem_rx_net_mode_sel_set(char * api);
+int  oem_rx_net_mode_sel_get(char * api);
+int  oem_rx_net_pref_plmn_set(char * api);
+int  oem_rx_net_pref_plmn_get(char * api);
+int  oem_rx_net_service_domain_get(void);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_rx_phonebook.h b/vmodem/include/oem/oem_rx_phonebook.h
new file mode 100644 (file)
index 0000000..7e7202b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _OEM_RX_PHONEBOOK_H_
+#define        _OEM_RX_PHONEBOOK_H_
+
+int oem_rx_sim_pb_get_access_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_set_access_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_get_storage_cnt_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_get_entry_info_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_get_storage_list_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_exec_access_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_pb_get_capability_info(void* ptr_data, int data_len);
+
+#endif
diff --git a/vmodem/include/oem/oem_rx_power.h b/vmodem/include/oem/oem_rx_power.h
new file mode 100644 (file)
index 0000000..4e89c7f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_RX_POWER_
+#define _OEM_RX_POWER_
+
+int oem_rx_power_up_exec(void);
+int oem_rx_online_exec(unsigned char status);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_rx_security.h b/vmodem/include/oem/oem_rx_security.h
new file mode 100644 (file)
index 0000000..e06f8ab
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _OEM_RX_SECURITY_H_
+#define        _OEM_RX_SECURITY_H_
+
+
+int oem_rx_sim_sec_get_imsi_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_sec_set_pin_status_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_sec_get_pin_status_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_sec_get_lock_info_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_sec_change_password_req(void* ptr_data, int data_len);
+
+int oem_rx_sim_sec_get_phone_lock_req(void* ptr_data, int data_len);
+
+#endif
diff --git a/vmodem/include/oem/oem_rx_sms.h b/vmodem/include/oem/oem_rx_sms.h
new file mode 100644 (file)
index 0000000..b06cf9a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_rx_sms_SendMsg(void * ptr_data, int data_len);
+
+int oem_rx_sms_SCA(void * ptr_data, int data_len);
+
+int oem_rx_sms_DR(void * ptr_data, int data_len);
+
+int oem_rx_sms_cbsetconfig(char *api);
+
+int oem_rx_sms_ressvcoption(char *api);
+
+int oem_rx_sms_param_set(char *api);
+int oem_rx_sms_param_get(char *api);
+
+int oem_rx_sms_memstatus(char *api);
+
+int oem_rx_sms_stored_msg_status(char *api);
+
+int oem_rx_sms_param_count(char *api);
+
+int oem_rx_sms_mem_status(char *api);
+
+int oem_rx_sms_SCA_set(char* api);
diff --git a/vmodem/include/oem/oem_rx_ss.h b/vmodem/include/oem/oem_rx_ss.h
new file mode 100644 (file)
index 0000000..9da1602
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_RX_SS_
+#define _OEM_RX_SS_
+
+int oem_rx_ss_manage_call_set(char* ptr_data, int data_len);
+int oem_rx_ss_cw_get(int tel_class);
+int oem_rx_ss_cb_get(int tel_class, int cb_type);
+int oem_rx_ss_cf_get(int tel_class, int cf_type);
+
+int oem_rx_ss_cw_set(int tel_class, int ss_mode);
+//int oem_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);
+int oem_rx_ss_cf_set(int ss_mode, int type, int tel_class,  int replyTime, int num_len, char *number, int num_type);
+int oem_rx_ss_cb_set(int cb_type, int ss_mode, int tel_class, char *passwd);
+
+int oem_rx_ss_cb_passwd_set(char* curr_passwd, char* new_passwd);
+
+int oem_rx_ss_cli(char * api);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_call.h b/vmodem/include/oem/oem_tx_call.h
new file mode 100644 (file)
index 0000000..7bcf00f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_TX_CALL_
+#define _OEM_TX_CALL_
+
+int oem_tx_call_incoming_noti(void *data, int len);
+int oem_tx_call_waiting_noti(void *data, int len);
+int oem_tx_call_list_noti(void *data, int len);
+int oem_tx_call_list_resp(void *data, int len);
+int oem_tx_call_status_noti(void *data, int len);
+int oem_tx_call_burst_dtmf_noti(void *data, int len);
+int oem_tx_call_line_id_resp(void *data, int len);
+int oem_tx_call_gen_resp(char* resp);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_data.h b/vmodem/include/oem/oem_tx_data.h
new file mode 100644 (file)
index 0000000..a472831
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_tx_data_CallStatus(void *data, int len);
+
+int oem_tx_data_DataCallStatus(void *data, int len);
diff --git a/vmodem/include/oem/oem_tx_display.h b/vmodem/include/oem/oem_tx_display.h
new file mode 100644 (file)
index 0000000..bc389d0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_TX_DISPLAY_
+#define _OEM_TX_DISPLAY_
+
+int oem_tx_display_icon_info_noti(void *data, int len);
+int oem_tx_display_icon_info_resp(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_gprs.h b/vmodem/include/oem/oem_tx_gprs.h
new file mode 100644 (file)
index 0000000..3bb9f2d
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_tx_gprs_IPConfigurationNotify(void *data, int len);
diff --git a/vmodem/include/oem/oem_tx_misc.h b/vmodem/include/oem/oem_tx_misc.h
new file mode 100644 (file)
index 0000000..5371e90
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_tx_misc_version(void *data, int len);
diff --git a/vmodem/include/oem/oem_tx_network.h b/vmodem/include/oem/oem_tx_network.h
new file mode 100644 (file)
index 0000000..b07addf
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_TX_NETWORK_
+#define _OEM_TX_NETWORK_
+
+int oem_tx_net_plmn_list_noti(void *data, int len);
+
+
+int oem_tx_net_plmn_list_resp(void *data, int len);
+
+
+int oem_tx_net_reg_noti(void *data, int len);
+
+
+int oem_tx_net_reg_resp(void *data, int len);
+
+
+int oem_tx_net_current_plmn_noti(void *data, int len);
+
+
+int oem_tx_net_current_plmn_resp(void *data, int len);
+
+
+int oem_tx_net_plmn_selection_resp(void *data, int len);
+
+int oem_tx_net_current_nitz_noti(void *data, int len);
+
+int oem_tx_net_gen_phone_resp(void *data, int len);
+
+int oem_tx_net_band_get_resp(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_phonebook.h b/vmodem/include/oem/oem_tx_phonebook.h
new file mode 100644 (file)
index 0000000..4a2e8fe
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _OEM_TX_PHONEBOOK_H_
+#define        _OEM_TX_PHONEBOOK_H_
+
+int oem_tx_sim_pb_get_storage_cnt_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_pb_get_entry_info_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_pb_get_storage_list_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_pb_set_access_res(int error);
+
+int oem_tx_sim_pb_get_access_res(void* ptr_data, int data_len);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_power.h b/vmodem/include/oem/oem_tx_power.h
new file mode 100644 (file)
index 0000000..554518c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_TX_POWER_
+#define _OEM_TX_POWER_
+
+int oem_tx_power_up_noti(void *data, int len);
+int oem_tx_power_online_noti(void *data, int len);
+int oem_tx_battery_status_noti(void *data, int len);
+int oem_tx_power_up_resp(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_security.h b/vmodem/include/oem/oem_tx_security.h
new file mode 100644 (file)
index 0000000..9fff841
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _OEM_TX_SECURITY_H_
+#define        _OEM_TX_SECURITY_H_
+
+
+int oem_tx_sim_sec_get_imsi_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_sec_set_pin_status_res(int error);
+
+int oem_tx_sim_sec_get_pin_status_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_sec_get_lock_info_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_sec_change_password_res(void* ptr_data);
+
+int oem_tx_sim_sec_set_phone_lock_res(int error);
+
+int oem_tx_sim_sec_get_phone_lock_res(void* ptr_data, int data_len);
+
+int oem_tx_sim_sec_set_rsim_access_res(int error);
+
+int oem_tx_sim_sec_card_type_noti(void* ptr_data, int data_len);
+
+int oem_tx_sim_sec_pin_status_noti(void* ptr_data, int data_len);
+
+#endif
+
diff --git a/vmodem/include/oem/oem_tx_sms.h b/vmodem/include/oem/oem_tx_sms.h
new file mode 100644 (file)
index 0000000..7254f06
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int oem_tx_sms_deviceReady(void *data, int len);
+
+int oem_tx_sms_NotiIncomingMsg(void *data, int len);
+
+int oem_tx_sms_sendDeliverReport(void *data, int len);
+
+int oem_tx_sms_sendMsg(void *data, int len);
+
+int oem_tx_sms_sendCBSMsg(void *data, int len);
+
+int oem_tx_sms_SCA(void *data, int len);
diff --git a/vmodem/include/oem/oem_tx_ss.h b/vmodem/include/oem/oem_tx_ss.h
new file mode 100644 (file)
index 0000000..89fdaca
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _OEM_TX_SS_
+#define _OEM_TX_SS_
+
+int oem_tx_ss_ssinfo_noti(void *data, int len);
+
+int oem_tx_ss_cw_resp(void *data, int len);
+int oem_tx_ss_cb_resp(void *data, int len);
+int oem_tx_ss_cf_resp(void *data, int len);
+
+int oem_tx_ss_gen_resp(void *data);
+
+int oem_tx_ss_aoc_noti(void *data, int len);
+
+#endif
+
diff --git a/vmodem/include/sat/sat_util.h b/vmodem/include/sat/sat_util.h
new file mode 100644 (file)
index 0000000..7d7a0bd
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SAT_UTIL_H_
+#define _SAT_UTIL_H_
+
+#include "sat_values.h"
+
+//#include <linuxtapi.h>
+
+#define        SIM_TON_UNKNOWN                                 0 //unknown
+#define        SIM_TON_INTERNATIONAL                           1 //international number
+#define        SIM_TON_NATIONAL                                        2 //national number
+#define        SIM_TON_NETWORK_SPECIFIC                        3 //natwork specific number
+#define        SIM_TON_DEDICATED_ACCESS                        4 //subscriber number
+#define        SIM_TON_ALPHA_NUMERIC                           5//alphanumeric, GSM 7-bit default alphabet)
+#define        SIM_TON_ABBREVIATED_NUMBER              6 //abbreviated number
+#define        SIM_TON_RESERVED_FOR_EXT                        7 //reserved for extension
+
+
+#define MAX_UDH_LEN            137 
+#define UDH_MAX                                7
+#define SMDATA_SIZE_MAX        160
+
+
+#define FAIL                   0x00
+#define SUCCESS                0x01
+
+
+
+
+
+//////////////////////////////////TPDU type////////////////////////////////
+#if 0
+typedef enum 
+{
+       SMS_TPDU_DELIVER                                = 0x00, // sc -> ms
+       SMS_TPDU_DELIVER_REPORT         = 0x00, // ms -> sc
+       SMS_TPDU_SUBMIT                         = 0x01, // ms -> sc
+       SMS_TPDU_SUBMIT_REPORT          = 0x01, // sc -> ms
+       SMS_TPDU_STATUS_REPORT          = 0x02, // sc -> ms
+       SMS_TPDU_COMMAND                                = 0x02, // ms -> sc
+       SMS_PDU_INVALID_TYPE
+       
+} SmsTPDUType;
+
+typedef struct
+{
+       int             year;
+       int             month;
+       int             day;
+       int             hour;
+       int             minute;
+       int             second;
+       
+} TmDateTime;
+#endif
+
+#define BASE_YEAR              70L                                     /* 1970 is the base year */
+#define MAX_YEAR                       130L                                    /* 2030 is the max year */
+
+
+#define        SIM_SMSP_ADDRESS_LEN                                    20      // digit length
+
+#define SET_TON_NPI(dest, ton, npi) {  \
+       dest = 0x80;                                            \
+       dest |= (ton & 0x07) << 4;                      \
+       dest |= npi & 0x0F;                                     \
+}
+
+
+int   Display_Text( DP_TEXT* dp_text);
+int   Get_Inkey( GET_INKEY* get_inkey);
+int   Get_Input( GET_INPUT* get_input);
+int   Set_Menu(void *data);
+int   Select_Item(void *data);
+int   Send_SMS(void *data);
+int   Set_Up_Call(void *data);
+
+int sat_apdu_encode(unsigned char tag, SatApduEncoderCallback getDataF, void* HLDataP, char** stringPP);
+
+
+#if 0
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType ;   //bit 0 ,1
+
+       // reject duplicates [M]
+       BOOL rd ;  // bit 2
+
+       // validity period format [M]
+       TapiNetTextVPType vpf ; //  bits 3, 4
+
+       // reply path [M]
+       BOOL rp ; //bit 7
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       // status report request
+       BOOL  srr ;  // bit 5
+
+       /************BODY************/
+
+       //message reference [M]
+       UINT mr;
+
+       // destination address [M]
+       SmsAddressInfo desAddr;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme [M]
+       TapiNetTextCodingScheme dcs;
+
+       // validity period
+       TapiNetTextVP vp;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT;
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType;  //bit 0 ,1
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       /************BODY************/
+
+       // failure Cause [M]
+        UINT   fcs;
+
+       // parameter indicator [M]
+       BYTE paraInd;
+
+       // service centre time stamp [M]
+       TmDateTime scts;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme 
+       TapiNetTextCodingScheme dcs;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT_REPORT;
+
+
+typedef struct
+{      
+       /************HEADER************/
+       SmsTPDUType msgType;   //bit 0 ,1
+       
+       BOOL mms; // bit 2 
+       
+       BOOL rp; // bit 7 
+       
+       BOOL udhi;  //bit 6
+       
+       BOOL sri; // bit , 5status_report_indication
+       
+       /************BODY************/
+
+       SmsAddressInfo orgAddr;
+
+       BYTE  pId;
+
+       TmDateTime scts;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE  * userData;
+       
+}TPDU_SMS_DELIVER;
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ;  //bit 6
+       
+       /************BODY************/
+
+       UINT fcs;
+
+       BYTE paraInd;
+
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_DELIVER_REPORT;
+
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ; //bit 6
+
+       BOOL srr; //bit 5, status_report_request
+
+       /************BODY************/
+
+       UINT  mr; //message_ref
+
+       BYTE pId;
+
+       BYTE cmdType;
+
+       BYTE msgNum;
+
+       SmsAddressInfo destAddr;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_COMMAND;
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL  udhi ; //bit 6
+
+       BOOL mms ; //bit 2
+
+       BOOL srq; //bit 5, status_report_qualifier
+
+       /************BODY************/
+       
+       UINT  mr;
+
+       SmsAddressInfo rcpAddr; //recipient_addr
+
+       TmDateTime scts;
+
+       TmDateTime dt; //discharge_time
+
+        BYTE  status;
+       
+        BYTE paraInd;
+               
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_STATUS_REPORT;
+
+#endif
+
+/**************************************************************************************
+*** (main.c) function header****************************************************************
+***************************************************************************************
+***************************************************************************************/
+#if 0
+BOOL EncodeSmsDeliverTpdu(SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, char *rawdata, int *rawdata_len);
+//BOOL EncodeSmsDeliverTpdu(char *rawdata, int *rawdata_len, char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+BOOL EncodeSmsSubmitReportTpdu(char *rawdata, int *rawdata_len);
+BOOL DecodeSmsSubmitTpdu(TPDU_SMS_SUBMIT *tpdu_submit, int pdu_len , char * pPDU);
+#endif
+/*
+int SendMessage();
+int ReadMessage();
+int DeleteMessage();
+int ReceiveMessage(int pdu_len, char * pPDU);
+int GetInformation();
+int Setting();
+
+BOOL DecodeCellBroadcastMsg(int length,char * pPDU);
+BOOL EncodeSmsSubmitTpdu(char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+//BOOL DecodeSmsSubmitTpdu(int pdu_len , char * pPDU);
+int  DecodeSmsDeliverTpdu(int pdu_len , char * pPDU);
+BOOL EncodeSmsDeliverReportTpdu();
+BOOL DecodeSmsSubmitReportTpdu(int length , char *data);
+BOOL DecodeSmsStatusReportTpdu(int pdu_len, char * pPDU);
+*/
+
+/***************************************************************************************/
+#if 0
+void reverse(char* x, int len);
+char* AcItoa(int n, char* str, int b) ;
+int AcToupper(int ch);
+
+char* SmsUtilUnpackGSMCode( char* szData, const BYTE* pIn, int in_len );
+int SmsUtilPackGSMCode( BYTE* pOut, const char* szData, int in_len );
+
+void SmsUtilConvertBCD2Digit( char* pDigits, char* pBCD, int digitLen );
+void SmsUtilConvertDigit2BCD( char* pBCD, char* pDigits, int digitLen );
+
+TmDateTime* SmsUtilDecodeTimeStamp( unsigned char* pTimeStamp, TmDateTime *tmDateTime );
+unsigned char* SmsUtilEncodeTimeStamp( TmDateTime* tmDateTime, unsigned char* pTimeStamp );
+
+
+void  SmsUtilDecodeAddrField(char *diallingNum, unsigned char * pAddrField, int *result_ton, int *result_npi );
+int SmsUtilEncodeAddrField( unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi );
+
+int SmsUtilDecodeScAddrField( SmsAddressInfo* pSmsAddrField, BYTE* pAddrField );
+int SmsUtilEncodeScAddrField( BYTE* pAddrField, SmsAddressInfo * pSmsAddrField );
+void SmsUtilDecodeDCS( TapiNetTextCodingScheme* pCodingScheme,   unsigned char dcs );
+void SmsUtilEncodeDCS( BYTE* pDCS, TapiNetTextCodingScheme* pCodingScheme);
+
+UINT8 SmsUtilEncodeValidity( BYTE* pValidity, TapiNetTextVP* pVP );
+#endif
+
+#endif /* _SAT_UTIL_H_ */
diff --git a/vmodem/include/sat/sat_values.h b/vmodem/include/sat/sat_values.h
new file mode 100644 (file)
index 0000000..d047b4b
--- /dev/null
@@ -0,0 +1,1111 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef SAT_VALUES_H
+#define SAT_VALUES_H
+
+#undef FALSE
+#undef TRUE
+#define TRUE 1
+#define FALSE 0
+
+#define VGSM_CHARSET_UTF8              1//"UTF-8"
+#define VGSM_CHARSET_UCS2              2//"UCS-2"
+#define VGSM_CHARSET_GSM               3//"GSM-7"
+
+#define ALP_STATUS_OK  0
+
+// maximu size of a string in an apdu
+#define VGSM_APDU_CONVERTION_BUFFER_SIZE       256
+
+
+typedef struct _SatApduDecoder SatApduDecoder;
+
+// Apdu decoder/encoder callbacks
+typedef int    (*SatApduEncoderCallback)               (unsigned long request, char* bufferP, int* bufferSize, void* HLData);
+typedef int    (*SatApduDecoderCallback)               (char tag, SatApduDecoder* decoderP, char* objectP);
+
+///
+#define MAX_STRING     255;
+
+typedef struct _DISPLAY_TEXT  DP_TEXT;
+struct _DISPLAY_TEXT {
+       char priority;
+       char clear_msg;
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+
+};
+
+///
+typedef struct _GET_INKEY  GET_INKEY;
+struct _GET_INKEY {
+       unsigned char cmd_detail;
+
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+//     char duration_interval;
+//     char  text_len;
+};
+
+///
+typedef struct _GET_INKEY  GET_INPUT;
+struct _GET_INPUT {
+       unsigned char cmd_detail;
+
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+};
+
+
+typedef struct _SET_MENU  SET_MENU;
+struct _SET_MENU {
+       //unsigned char cmd_detail;
+       char id_num;
+       char alpah_string[255];
+       char item_string[255];
+};
+
+///
+typedef struct _SEND_SMS  SEND_SMS;
+struct _SEND_SMS {
+       unsigned char cmd_detail;
+       unsigned char address;
+       char dial_num[25];
+       char  tpdu_sms[255];
+};
+
+///
+struct _SatApduDecoder
+{
+       SatApduDecoderCallback  HLSetDataF;
+       void*                   HLDataP;
+       unsigned char*  formatP;
+       unsigned char*  apduP;
+       int                             apduSizeInBytes;
+       unsigned char*  apduReadP;
+       unsigned char           currentObjectTag;
+       unsigned char           currentObjectLength;
+};
+
+typedef struct _SatCmdResponseInternal SatCmdResponseInternal;
+struct _SatCmdResponseInternal
+{
+       char cmdId;             //!< Command Identifier
+       char resCode;   //!< Result codes applicable to command iCmdId, see ALP_TEL_CAT_RES_XXX
+       char infoType;  // type for local information
+       int infoLen;            // length for local information
+       char *infoData;
+};
+
+
+
+#define HEX_DIGIT(b) ((b) >= '0' && (b) <= '9' ? (b) - '0' : (b) - 'A' + 10)
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+
+
+
+#define CAT_CONFIG_STRING_MAX_SIZE     48                      //!< Cat config max size
+
+#define        alp_prv_mbiz_param_to_buffer(bufferP, paramP, paramSize)        \
+{                                                                                                                              \
+       unsigned char* bufferOffset = (unsigned char*) (bufferP);                       \
+       memmove((bufferP), (paramP), (paramSize));                                      \
+       bufferOffset += (paramSize);                                                                    \
+       (bufferP) = (void*) bufferOffset;                                                                       \
+}
+
+// STK config
+#define                DEFAULT_PROFIL_SIZE     17
+
+// Structure and coding of TERMINAL PROFILE
+//     First byte (Download)
+#define        PROFILE_DOWNLOAD_FACILITY               0x01
+#define        SMS_PP_DATA_DOWNLOAD_FACILITY   0x02
+#define        CELL_BROADCAST_FACILITY                 0x04
+#define        MENU_SELECTION_FACILITY                 0x08
+#define        NIEEXX_RESPONSE_CODE_FACILITY   0x10
+#define        TIMER_EXPIRATION_FACILITY                       0x20
+#define        USSD_STRING_FACILITY                            0x40
+#define        AUTOMATIC_REDIAL_FACILITY               0x80
+
+//     Second byte (Other)
+#define        COMMAND_RESULT_FACILITY                                 0x01
+#define        CALL_CONTROL_BY_SIM_FACILITY                            0x02
+#define        CC_WITH_CELL_IDENTITY_FACILITY                  0x04
+#define        SHORT_MESSAGE_CONTROL_BY_SIM_FACILITY   0x08
+#define        ALPHA_IDENTIFIER_HANDLING_FACILITY              0x10
+#define        UCS2_ENTRY_FACILITY                                             0x20
+#define        UCS2_DISPLAY_FACILITY                                           0x40
+#define        DISPLAY_EXTENSION_TEXT_FACILITY                 0x80
+
+//     Third byte (Proactive SIM)
+#define        PROSIM_DISPLAY_TEXT_FACILITY            0x01
+#define        PROSIM_GET_INKEY_FACILITY               0x02
+#define        PROSIM_GET_INPUT_FACILITY               0x04
+#define        PROSIM_MORE_TIME_FACILITY               0x08
+#define        PROSIM_PLAY_TONE_FACILITY               0x10
+#define        PROSIM_POLL_INTERVAL_FACILITY   0x20
+#define        PROSIM_POLLING_OFF_FACILITY             0x40
+#define        PROSIM_REFRESH_FACILITY                 0x80
+
+//     Fourth byte (Proactive SIM)
+#define        PROSIM_SELECT_ITEM_FACILITY             0x01
+#define        PROSIM_SEND_SHORT_MESG_FACILITY 0x02
+#define        PROSIM_SEND_SS_FACILITY                 0x04
+#define        PROSIM_SEND_USSD_FACILITY                       0x08
+#define        PROSIM_SETUP_CALL_FACILITY                      0x10
+#define        PROSIM_SETUP_MENU_FACILITY              0x20
+#define        PROSIM_LOCAL_INFO1_FACILITY             0x40
+#define        PROSIM_LOCAL_INFO2_FACILITY             0x80
+
+//     Fifth byte (Event driven information)
+#define        PROSIM_SETUP_EVENT_LIST_FACILITY                0x01
+#define        EVENT_MT_CALL_FACILITY                                  0x02
+#define        EVENT_CALL_CONNECTED_FACILITY                   0x04
+#define        EVENT_CALL_DISCONNECT_FACILITY          0x08
+#define        EVENT_LOCATION_STATUS_FACILITY          0x10
+#define        EVENT_USER_ACTIVITY_FACILITY                    0x20
+#define        EVENT_IDLE_SCREEN_FACILITY                              0x40
+#define        EVENT_CARD_READER_STATUS_FACILITY       0x80
+
+//     Sixth byte (Event driven information extensions)
+#define        EVENT_LANGUAGE_SELECTION_FACILITY               0x01
+#define        EVENT_BROWSER_TERMINATION_FACILITY      0x02
+#define        EVENT_DATA_AVAILABLE_FACILITY                   0x04
+#define        EVENT_CHANNEL_STATUS_FACILITY                   0x08
+
+//     Seventh byte (Multiple card proactive commands) for class "a"
+#define        PROSIM_POWER_ON_CARD_FACILITY                   0x01
+#define        PROSIM_POWER_OFF_CARD_FACILITY                  0x02
+#define        PROSIM_PERFORM_CARD_APDU_FACILITY               0x04
+#define        PROSIM_GET_READER_STATUS_FACILITY               0x08
+#define        PROSIM_GET_READER_IDENTIFIER_FACILITY           0x10
+
+//     Eighth byte (Proactive SIM)
+#define        PROSIM_TIMER_MANAGEMENT_FACILITY                        0x01
+#define        PROSIM_GET_TIMER_VALUE_FACILITY                 0x02
+#define        PROSIM_PROVIDE_LOCAL_INFO3_FACILITY             0x04
+#define        BINARY_GET_KEY_FACILITY                                 0x08
+#define        SETUP_IDLE_MODE_TEXT_FACILITY                           0x10
+#define        RUN_AT_COMMAND_FACILITY                                 0x20
+#define        SETUP_CALL_2ND_ALPHA_ID_FACILITY                        0x40
+#define        SECOND_CAPABILITY_CONFIG_PARAM_FACILITY         0x80
+
+//     Ninth byte
+#define        SUSTAINED_DISPLAY_TEXT_FACILITY                 0x01
+#define        SEND_DTMF_COMMAND_FACILITY                              0x02
+#define        PROSIM_PROVIDE_BCCH_INFO_FACILITY               0x04
+#define        PROSIM_PROVIDE_LANGUAGE_INFO_FACILITY   0x08
+#define        PROSIM_PROVIDE_TIMING_INFO_FACILITY             0x10
+#define        PROSIM_LANGUAGE_NOTIFICATION_FACILITY   0x20
+#define        PROSIM_LAUNCH_BROWSER_FACILITY                  0x40
+
+//     Tenth byte (Soft keys support)
+#define        SOFTKEY_FOR_SELECT_ITEM_FACILITY                0x01
+#define        SOFTKEY_FOR_SETUP_MENU_FACILITY                 0x02
+
+//     Eleventh byte (Soft keys information)
+#define        MAXIMUM_NUMBER_OF_SOFTKEYS                              0x00
+
+//     Twelfth byte (Bearer Independent protocol proactive commands (class "e")
+#define        PROSIM_OPEN_CHANNEL_FACILITY                            0x01
+#define        PROSIM_CLOSE_CHANNEL_FACILITY                           0x02
+#define        PROSIM_RECEIVE_DATA_FACILITY                            0x04
+#define        PROSIM_SEND_DATA_FACILITY                                       0x08
+#define        PROSIM_GET_CHANNEL_STATUS_FACILITY              0x10
+
+//     Thirteenth byte (Bearer Independent protocol supported bearers (class "e")
+#define        CSD_SUPPORTED_FACILITY                                          0x01
+#define        GPRS_SUPPORTED_FACILITY                                 0x02
+#define        NUMBER_OF_CHANNELS_SUPPORTED_BY_ME(X)   (((char)X) << 5)
+
+//     Fourteenth byte (Screen height)
+#define        NUMBER_OF_CHARACTERS_DOWN_TE_DISPLAY(X) (((char)X) & 0x1F)
+#define        SCREEN_SIZING_PARAMETERS_FACILITY                               0x80
+
+//     Fifteenth byte (Screen width)
+#define        NUMBER_OF_CHARACTERS_ACROSS_TE_DISPLAY(X)       (((char)X) & 0x7F)
+#define        VARIABLE_SIZE_FONTS_FACILITY                                    0x80
+
+//     Sixteenth byte (Screen effects)
+#define        DISPLAY_CAN_BE_RESIZED                          0x01
+#define        TEXT_WRAPPING_SUPPORTED                 0x02
+#define        TEXT_SCROLLING_SUPPPORTED                       0x04
+#define        MENU_WIDTH_REDUCTION(X)                 (((char)X) << 5)
+
+//     Seventeenth byte: (Bearer independent protocol supported transport interface) for class "e"
+#define        TCP_SUPPORTED                                           0x01
+#define        UDP_SUPPPORTED                                          0x02
+
+
+#define SELECT_BY_PATH_REFERENCING                             0x08
+#define SELECT_BY_FILE_IDENTIFIER                              0x00
+#define RETURN_FCP_TEMPLATE                                            0x04
+
+#define SEND_LINE_MAX_BUFFER                                   500 // as alp_pdrv_comm_send_line takes into account up to 512 bytes in the arglist
+#define SEND_LINE_MAX_BUFFER                                   500 // as alp_pdrv_comm_send_line takes into account up to 512 bytes in the arglist
+// the data buffer to send with the AT command should not exceed: 512 bytes - (max command AT header size)
+
+#define COMMAND_QUALIFIER                                              objectP[2]      
+#define TYPE_OF_COMMAND                                                        objectP[1]
+
+#define NON_EXPLICIT_ICON                                              0x01
+
+#define GETINPUT_DETAILS_HIDE_INPUT                            0x04
+#define GETINPUT_DETAILS_PACKED_BIT                    0x08
+
+#define GETINKEY_DETAILS_YES_NO                                        0x04
+#define GETINKEY_DETAILS_DCS_MASK                              0x03
+
+#define DISPLAY_TEXT_DETAILS_CLEAR_AFTER_DELAY 0x80
+#define DISPLAY_TEXT_DETAILS_PRIORITY                  0x01
+
+#define SETUP_MENU_DETAILS_SOFTKEY                             0x01
+#define SELECT_ITEM_DETAILS_SOFTKEY                            0x04
+
+#define GET_DETAILS_HELP_INFO                                  0x80
+
+#define READ_RECORD_MODE_ABSOLUTE                              0x04
+
+#define SELECT_BY_PATH_REFERENCING                             0x08
+#define SELECT_BY_FILE_IDENTIFIER                              0x00
+
+#define RETURN_FCP_TEMPLATE                                            0x04
+
+#define CAT_CONFIG_STRING_MAX_SIZE                             48              //!< Cat config max size
+
+
+
+/**
+ * @addtogroup ALP_TELEPHONY_SERVICES_CAT
+ * @{
+ */
+typedef struct _SatConfig SatConfig;
+struct _SatConfig
+{
+       char*   profileP;                               //!< Terminal Profile standard parameters
+       int             profileSize;                    //!< Profile data size, in bytes
+       char            lanCode[2];                     //!< ISO 639 language code
+       char            mode;                                   //!< Result code presentation enable/disable
+};
+
+typedef struct _SatFile SatFile;
+struct _SatFile
+{
+       int*    pathP;                  //!< Absolute path of the file to read in the SIM.
+                                                                                               //!< Example: { 0x3F00, 0x7F20, 0x6F21 }
+                                                                                               //!< Consists of file identifiers from the Master File
+                                                                                               //!< to the Elementary File to be accessed
+       char*   bufP;                   //!< Buffer to be filled in with requested file body bytes.
+       int     bufSize;                //!< Buffer size in bytes
+       int     byteCount;              //!< Amount of applicable bytes in ioBufP
+
+       int     partOffset;             //!< Offset of requested file body part
+       int     partSize;               //!< Size of requested file body part
+
+       int     fileSize;               //!< EF size
+       char    fileStruct;             //!< EF structure (transparent, linear fixed or cyclic)
+       char    mode;                   //!< Access mode (see EF access mode)
+
+       char    pathCount;              //!< File identifiers count in iPathP
+       char    recId;                  //!< Identifier of the record to be read. Range 1..254
+       char    recSize;                //!< Size of a record, in bytes.
+                                                                                               //!< 0 if the file is not a Linear Fixed or a Cyclic EF
+};
+
+typedef struct _SatCmdParams SatCmdParams;
+struct _SatCmdParams
+{
+       void*   cmdParamP;                              //!< Structure associated to the command (according to iCmdId)
+       int     cmdParamSize;                   //!< Size of the specific command parameter buffer
+                                                                                                               //!< Common parameter for all (almost) commands
+       char*   textP;                                  //!< Text to display
+       char    iconId;                                 //!< Icon identifier
+       char    cmdId;                                  //!< See the Proactive Commands Id for more details
+       char    explicitIcon;                   //!< Icon is explicit
+       char    noResponse;                             //!< true if the command does not need a response       
+       int     textSize;                               //!< The size of the encoded text
+};
+
+typedef struct _SatCmdResponse SatCmdResponse;
+struct _SatCmdResponse
+{
+       char*   respP;                                  //!< Associated text response
+       unsigned char   itemIdentifier;                 //!< Item identifier  
+       int     respSize;                               //!< Associated text response size in bytes
+       char    cmdId;                                  //!< Command Identifier
+       char    respType;                               //!< Expected response type, see ALP_TEL_CAT_RESP_TYPE_XXX
+       char    resCode;                                //!< Result codes applicable to command iCmdId, see ALP_TEL_CAT_RES_XXX
+       char    addInfo;                                //!< Additional information code
+};
+
+typedef struct _SatMenuSelection SatMenuSelection;
+struct _SatMenuSelection
+{
+       char    evtCode;                                //!< Menu Selection event code, see ALP_TEL_CAT_MENU_SELECTION_XXX
+       char    appId;                                  //!< Associated application identifier
+};
+
+typedef struct _SatEventToCard SatEventToCard;
+struct _SatEventToCard
+{
+       char    evtCode;                                        //!< Event Download code, see ALP_TEL_CAT_EVENT_XXX
+       char    lanCode[2];                                     //!< ISO 639 language code
+       char    browserTerminationCause;        //!< Browser Termination cause code, see ALP_TEL_CAT_BROWSER_XXX
+};
+
+
+typedef struct _SatRefreshFileList     SatRefreshFileList;
+struct _SatRefreshFileList
+{
+       unsigned short* filePathP;                      //!< Concatenated absolute paths of the modified EF
+                                                                                                       //!< or NULL if no specific file has been mentioned.
+       unsigned char   filePathCount;          //!< Number of paths in the file list
+       unsigned char   fileIdCount;            //!< Number of files described in the file list
+       unsigned char   opCode;                         //!< Operation code (see above the refresh command qualifier )
+       unsigned char*  AID;                            //!< Application identifier (only used for 3G platform)
+};
+
+typedef struct _SatSetUpEventList SatSetUpEventList;
+struct _SatSetUpEventList
+{
+       char*   eventP;                         //!< Events to be monitored, see ALP_TEL_CAT_EVENT_XXX
+       char    eventCount;                     //!< Events number in eventP or 0 to stop monitoring
+};
+
+typedef struct _SatSetUpCall SatSetUpCall;
+struct _SatSetUpCall
+{
+       char*   bearerCapP;                             //!< Bearer capability configuration params (GSM 04.08 5.3.0 section 10.5.4.5)
+       char*   numberP;                                //!< Dialing number
+       char*   userConfTextP;                  //!< Text to display. NULL if not provided
+       char*   callEstaTextP;                  //!< Text to display, NULL if not provided
+       char*   subAddressP;                    //!< called party subaddress
+       int     userConfTextSize;               //!< Text buffer size in bytes
+       int     numberSize;                             //!< Number buffer size in bytes
+       int     callEstaTextSize;               //!< Call establishment text buffer size in bytes
+       int     subAddressSize;                 //!< subaddress size in bytes
+       char    bearerCapSize;                  //!< Bearer capability size, in bytes
+       
+       unsigned long   duration;                               //!< if the time elapsed since the first call set-up attempt has exceeded the duration request, the redial mechanism shall be terminated 
+       char    condition;                              //!< Set up call commmand qualifier, see ALP_TEL_CAT_SETUP_CALL_XXX
+       
+       char    userConfIconId;                 //!< Icon id. 0 if no icon
+       char    userConfExplicitIcon;   //!< Icon is explicit
+       char    callEstaIconId;                 //!< Icon id. 0 if no icon
+       char    callEstaExplicitIcon;   //!< Icon is explicit
+};
+
+typedef struct _SatLaunchBrowser SatLaunchBrowser;
+struct _SatLaunchBrowser
+{
+       char*   urlP;                           //!< The URL
+       int     urlSize;
+       char*   gatewayP;                       //!< Gateway name, Proxy identity to be used
+       int     gatewaySize;
+       int*    filePathP;                      //!< Concatenated absolute paths of provisioning EF
+                                                                                                       //!< or NULL if no specific file has been mentioned.
+       char*   prefBearersP;           //!< Prioritized list of ALP_TEL_CAT_BEARER_XXX bearer codes
+       char    fileIdCount;            //!< File identifiers count in filePathP
+       char    prefBearerCount;        //!< Number of bearer codes in prefBearersP.
+       char    condition;                      //!< Launch browser conditions, see ALP_TEL_CAT_LAUNCH_BROWSER_XXX
+       char    browserId;                      //!< Browser Identity
+};
+
+typedef struct _SatPlayTone SatPlayTone;
+struct _SatPlayTone
+{
+       int     sndDuration;            //!< Sound duration in ms. 0 for default or 100..15300000
+       char    sndCode;                        //!< One of the ALP_TEL_CAT_PLAY_TONE_XXX codes
+       unsigned char   vibrateAlert;           //!< One of the ALP_TEL_CAT_VIBRATE_XXX codes
+};
+
+typedef struct _SatDisplayText SatDisplayText;
+struct _SatDisplayText
+{
+       char    priority;                       //!< Priority level
+       char    clearAfterDelay;        //!< Wait for user's action
+       char    immediateResponse;      //!< Send a response to the SIM ASAP
+       unsigned long   duration;                       //!< the terminal shall continue to dsiplay the text until the expiration of this variable display timeout      
+};
+
+typedef struct _SatGetInkey SatGetInkey;
+struct _SatGetInkey
+{
+       char    helpInfo;                       //!< Help information is provided by the SIM
+       char    respType;                       //!< Expected response type. See ALP_TEL_CAT_RESP_TYPE_XXX
+       unsigned long   duration;                       //!> the terminal shall wait until either the user enters a single characters or the timeout expires.
+};
+
+typedef struct _SatGetInput SatGetInput;
+struct _SatGetInput
+{
+       char*   defRespP;                       //!< Default response text to propose
+       int     defRespSize;            //!< Default response text size in bytes
+       char    hideUserInput;          //!< Mask entered data
+       char    helpInfo;                       //!< Help information is provided by the SIM
+       char    minRespLength;          //!< Minimum response length, in characters
+       char    maxRespLength;          //!< Maximum response length, in characters
+       char    respType;                       //!< Expected response type, see ALP_TEL_CAT_RESP_TYPE_XXX
+};
+
+typedef struct _SatItem SatItem;
+struct _SatItem
+{
+       char*   nameP;                          //!< Item name
+       int     nameSize;                       //!< Item name size in bytes
+       char    id;                                     //!< Item identifier
+       char    iconId;                         //!< Icon Identifier
+       char    expIcon;                        //!< Icon is explicit
+       char    nextActionInd;          //!< Identifier of the next command for this item
+       SatItem*        nextItemP;                      //!> @ of the next item (if any)
+};
+
+typedef struct _SatItemList SatItemList;
+struct _SatItemList
+{
+       SatItem*        firstItemP;                     //!< The first Item
+       int     itemCount;                      //!< Number of items 
+       char    softKey;                        //!< Item can be selected by tapping on its icon
+       char    helpInfo;                       //!< Help information is provided by the SIM
+       char    defItemId;                      //!< Identifier of the item that should be pre-selected.
+};
+
+typedef struct _SatSendShortMessage SatSendShortMessage;
+struct _SatSendShortMessage
+{
+       char*   addressP;                       //!< RP_Destination_Address (optional)
+       int     addressSize;
+       char*   TPDUP;                          //!< SMS TPDU
+       int     TPDUSize;
+       char    packingRequired;
+};
+
+typedef struct _SatBuffer SatBuffer;
+struct _SatBuffer              //!< used in: SendData, SendDTMF, Send USSD, Send SS
+{
+       char*   bufferP;                                //!< the data buffer
+       int     bufferSize;                             //!< the data buffer size
+       char    other;                                  //!< other parameter specific to the command (if any)
+};
+
+typedef struct _SatOpenChannel SatOpenChannel;
+struct _SatOpenChannel
+{
+       char*   addressP;
+       char*   subAddressP;
+       char*   otherAddressP;
+       char*   destinationAddressP;
+       char*   loginP;
+       char*   passwordP;
+       char*   bearerParamsP;
+       char*   accessPointP;
+       int     duration1;                              //!< duration1 in ms
+       int     duration2;                              //!< duration2 in ms
+       int     bufferSize;
+       int     transportPort;
+       char    onDemand;                               //!< Is link established immediately
+       char    bearerCode;                     //!< Bearer code, see ALP_TEL_CAT_BEARER_XXX
+       char    otherAddressType;               //!< see ALP_TEL_CAT_ADDRESS_XXX
+       char    destinationAddressType; //!< see ALP_TEL_CAT_ADDRESS_XXX
+       char    transportType;                  //!< see ALP_TEL_CAT_TRANSPORT_XXX
+       char    addressSize;
+       char    subAddressSize;
+       char    otherAddressSize;
+       char    bearerParamsSize;
+       char    loginSize;
+       char    passwordSize;
+       char    destinationAddressSize;
+       char    accessPointSize;
+};
+
+//! answer made by the phone module directly to the SIM 
+typedef struct _SatMEanswer SatMEanswer;
+struct _SatMEanswer    
+{
+       char    cmdId;                                  //!< Command Identifier
+       char    resCode;                                //!< Result codes applicable to command iCmdId 
+       char    addInfo;                                //!< Additional information code
+};
+
+//! answer made by the SIM to the phone module CALL CONTROL or MO Short Message CONTROL command 
+typedef struct _SatSIManswer SatSIManswer;
+struct _SatSIManswer   
+{
+       char    result;                         //!< call control or MO Short Message control result, see ALP_TEL_CAT_RESULT_CONTROL_XXX
+       
+       char*   textP;                          //!< Text to display
+       int     textSize;                       //!< The size of the encoded text
+       
+       char*   addressP1;                      //!> if it's a call control answer adressP1= dialling number, if the address data is not present, the terminal shall assume the dialling number is not to be modified 
+                                                                                               //!> if it's a MO short message control answer addressP1= RP_Destination_Address, if the address data object 1 is not present, then the ME shall assume the RP_Destination_Address of the Service Centre is not to be modified.
+       char    addressSize1;           //!> address size
+       
+       char*   addressP2;                      //!> apply only if it's a a MO short message control answer addressP2= TP_Destination_Address, if the address data object 2 is not present, then the ME shall assume the TP_Destination_Address is not to be modified.
+       char    addressSize2;           //!> address size
+       
+                                                                                               
+       char*   subAddressP;            //!> subaddress
+       char    subAddressSize;         //!> subaddress buffer size
+       
+       char    BCrepeatIndicator;      //!> BC repeat indicator
+       
+       char*   capabilityConfP1;       //!< Capability configuration parameters1
+       char    capabilityConfSize1;//!< the capability configuration parameters1 size
+       
+       char*   capabilityConfP2;       //!< Capability configuration parameters2 
+       char    capabilityConfSize2;//!< the capability configuration parameters2 size
+};
+
+// Card command
+#define SAT_CARD_COMMAND_INS_READ_BINARY                               0xB0
+#define SAT_CARD_COMMAND_INS_READ_RECORD                               0xB2
+#define SAT_CARD_COMMAND_INS_GET_RESPONSE                              0xC0
+#define SAT_CARD_COMMAND_INS_UPDATE_BINARY                             0xD6
+#define SAT_CARD_COMMAND_INS_UPDATE_RECORD                             0xDC
+#define SAT_CARD_COMMAND_INS_STATUS                                    0xF2
+
+
+// Card response
+#define SAT_CARD_RESPONSE_NORMAL_ENDING                                        0x90
+#define SAT_CARD_RESPONSE_NORMAL_ENDING_WITH_EXTRA_INFO        0x91
+#define SAT_CARD_RESPONSE_DATA_LEN_WITH_DOWNLOAD_ERROR         0x9E
+#define SAT_CARD_RESPONSE_DATA_LEN                                                     0x9F
+#define SAT_CARD_RESPONSE_SIM_TOOLKIT_BUSY                                     0x93
+#define SAT_CARD_RESPONSE_MEMORY_ERROR                                         0x92
+#define SAT_CARD_RESPONSE_REFERENCING_ERROR                            0x94
+#define SAT_CARD_RESPONSE_SECURITY_ERROR                                       0x98
+#define SAT_CARD_RESPONSE_INCORRECT_PARAM3                                     0x67
+#define SAT_CARD_RESPONSE_INCORRECT_PARAM1OR2                          0x6B
+#define SAT_CARD_RESPONSE_UNKNOW_INS                                           0x6D
+#define SAT_CARD_RESPONSE_WRONG_INS                                            0x6E
+#define SAT_CARD_RESPONSE_TECHNICAL_PROBLEM                            0x6F
+
+
+// APDU encoder/decoder
+
+// Call control or MO SMS conrol
+#define SAT_ALLOWED                                                            0x00
+#define        SAT_NOT_ALLOWED                                                 0x01
+#define        SAT_ALLOWED_WITH_MODIFICATION                           0x02
+
+
+// BER-tags
+#define SAT_RESPONSE                                                           0x00
+#define SAT_PROACTIVE_SIM_COMMAND                                      0xD0
+#define        SAT_SMS_PP_DOWNLOAD                                             0xD1
+#define        SAT_CELL_BRAOADCAST_DOWNLOAD                            0xD2
+#define        SAT_MENU_SELECTION                                                      0xD3
+#define        SAT_CALL_CONTROL                                                        0xD4
+#define        SAT_MO_SHORT_MESSAGE_CONTROL                            0xD5
+#define        SAT_EVENT_DOWNLOAD                                                      0xD6
+#define        SAT_TIMER_EXPIRATION                                            0xD7
+
+
+// SIMPLE-TLV data objects tags 
+#define SAT_COMMAND_DETAILS                                            0x01 //!> Command details tag
+#define SAT_DEVICE_IDENTITIES                                          0x02 //!> Device identity tag
+#define SAT_RESULT                                                                     0x03 //!> Result tag
+#define SAT_DURATION                                                           0x04 //!> Duration tag 
+#define SAT_ALPHA_IDENTIFIER                                           0x05 //!> Alpha identifier tag
+#define SAT_ADDRESS                                                            0x06 //!> Address tag
+#define SAT_CAPABILILITY_CONFIGURATION_PARAMETERS      0x07 //!> Capability configuration parameters tag
+#define SAT_SUBADDRESS                                                         0x08 //!> Subaddress tag
+#define SAT_SS_STRING                                                          0x09 //!> SS string tag
+#define SAT_USSD_STRING                                                        0x0A //!> USSD string tag
+#define SAT_SMS_TPDU                                                           0x0B //!> SMS TPDU tag
+#define SAT_CELL_BROADCAST_PAGE                                        0x0C //!> Cell Broadcast page tag
+#define SAT_TEXT_STRING                                                        0x0D //!> Text string tag 
+#define SAT_TONE                                                                       0x0E //!> Tone tag
+#define SAT_ITEM                                                                       0x0F //!> Item tag
+#define SAT_ITEM_IDENTIFIER                                            0x10 //!> Item identifier tag 
+#define SAT_RESPONSE_LENGTH                                            0x11 //!> Response length tag 
+#define SAT_FILE_LIST                                                          0x12 //!> File List tag
+#define SAT_LOCATION_INFORMATION                                       0x13 //!> Location Information tag
+#define SAT_IMEI                                                                       0x14 //!> IMEI tag 
+#define SAT_HELP_REQUEST                                                       0x15 //!> Help request tag 
+#define SAT_NETWORK_MEASUREMENT_RESULTS                        0x16 //!> Network Measurement Results tag 
+#define SAT_DEFAULT_TEXT                                                       0x17 //!> Default Text tag
+#define SAT_ITEMS_NEXT_ACTION_INDICATOR                        0x18 //!> Items Next Action Indicator tag
+#define SAT_EVENT_LIST                                                         0x19 //!> Event list tag
+#define SAT_CAUSE                                                                      0x1A //!> Cause tag
+#define SAT_LOCATION_STATUS                                            0x1B //!> Location status tag 
+#define SAT_TRANSACTION_IDENTIFIER                                     0x1C //!> Transaction identifier tag
+#define SAT_BCCH_CHANNEL_LIST                                          0x1D //!> BCCH channel list tag
+#define SAT_ICON_IDENTIFIER                                            0x1E //!> Icon identifier tag
+#define SAT_ITEM_ICON_IDENTIFIER_LIST                          0x1F //!> Item Icon identifier list tag
+//#define SAT_CARD_READER_STATUS                                               0x20 //!> Card reader status tag
+#define SAT_CARD_ATR                                                           0x21 //!> Card ATR tag
+#define SAT_C_ADPU                                                                     0x22 //!> C-APDU tag 
+#define SAT_R_ADPU                                                                     0x23 //!> R-APDU tag
+#define SAT_TIMER_IDENTIFIER                                           0x24 //!> Timer identifier tag
+#define SAT_TIMER_VALUE                                                        0x25 //!> Timer value tag
+#define SAT_DATE_TIME_AND_TIME_ZONE                            0x26 //!> Date-Time and Time zone tag
+#define SAT_CALL_CONTROL_REQUESTED_ACTION                      0x27 //!> Call control requested action tag
+#define SAT_AT_COMMAND                                                         0x28 //!> AT Command tag
+#define SAT_AT_RESPONSE                                                        0x29 //!> AT Response tag
+#define SAT_BC_REPEAT_INDICATOR                                        0x2A //!> BC Repeat Indicator tag
+#define SAT_IMMEDIATE_RESPONSE                                         0x2B //!> Immediate response tag
+#define SAT_DTMF_STRING                                                        0x2C //!> DTMF string tag
+#define SAT_LANGUAGE                                                           0x2D //!> Language tag
+#define SAT_TIMING_ADVANCE                                                     0x2E //!> Timing Advance tag
+#define SAT_AID                                                                        0x2F //!> AID tag 
+#define SAT_BROWSER_IDENTITY                                           0x30 //!> Browser Identity tag 
+#define SAT_URL                                                                        0x31 //!> URL tag
+#define SAT_BEARER                                                                     0x32 //!> Bearer tag
+#define SAT_PROVISIONING_FILE_REFERENCE                        0x33 //!> Provisioning Reference File tag
+#define SAT_BROWSER_TERMINATION_CAUSE                          0x34 //!> Browser Termination Cause tag
+#define SAT_BEARER_DESCRIPTION                                         0x35 //!> Bearer description tag
+#define SAT_CHANNEL_DATA                                                       0x36 //!> Channel data tag
+#define SAT_CHANNEL_DATA_LENGTH                                        0x37 //!> Channel data length tag
+#define SAT_CHANNEL_STATUS                                                     0x38 //!> Channel status tag
+#define SAT_BUFFER_SIZE                                                        0x39 //!> Buffer size tag
+//#define SAT_CARD_READER_IDENTIFIER                                   0x3A //!> Card reader identifier tag
+#define SAT_FILE_UPDATE_INFORMATION                            0x3B //!> File Update Information tag
+#define SAT_SIM_ME_INTERFACE_TRANSPORT_LEVEL           0x3C //!> UICC/terminal interface transport level tag
+// 0x3D Not used                                                           
+#define SAT_OTHER_ADDRESS                                                      0x3E //!> Other address (data destination address) tag
+
+
+// 
+//Access Technology tag                                             0x3F
+//Display parameters tag                                            0x40
+//Service Record tag                                                0x41
+//Device Filter tag                                                 0x42
+//Service Search tag                                                0x43
+//Attribute information tag                                         0x44
+//Service Availability tag                                          0x45
+//Reserved for 3GPP2 (ESN tag)                                      0x46
+//Network Access Name tag                                           0x47
+//Reserved for 3GPP2 (CDMA-SMS-TPDU tag)                            0x48
+//Remote Entity Address tag                                         0x49
+//Reserved for 3GPP (I-WLAN Identifier tag)                         0x4A
+//Reserved for 3GPP (I-WLAN Access Status tag)                      0x4B
+//RFU                                                                  0x4C to 0x4F
+//Text attribute tag                                                   '50'
+//Item text attribute list tag                                         '51'
+//Reserved for 3GPP (PDP context Activation parameter tag)             '52'
+//RFU                                                                                          '53' to '61'
+//IMEISV tag                                                                           '62'
+//Battery state tag                                                                    '63'
+//Browsing status tag                                                                  '64'
+//Network Search Mode tag                                                              '65'
+//Frame Layout tag                                                                     '66'
+//Frames Information tag                                                               '67'
+//Frame identifier tag                                                                 '68'
+//Reserved for 3GPP (UTRAN Measurement Qualifier tag)                  '69'
+//Multimedia Message Reference tag                                                 '6A'
+//Multimedia Message Identifier tag                                            '6B'
+//Reserved for 3GPP (Multimedia Message Transfer Status tag) 1         '6C'
+//MEID tag                                                                                                                     '6D' 
+//Multimedia Message Content Identifier tag                                                    '6E' 
+//Multimedia Message Notification tag                                                          '6F' 
+
+
+// admissible values for kGetDataDeviceIdentities param
+#define SAT_DEVICE_KEYPAD                                              0x01
+#define SAT_DEVICE_DISPLAY                                             0x02
+#define SAT_DEVICE_EARPIECE                                    0x03
+#define SAT_DEVICE_SIM                                                 0x81
+#define SAT_DEVICE_ME                                                  0x82
+#define SAT_DEVICE_NETWORK                                             0x83
+
+#define SAT_GET_DATA_FORMAT                                            0
+
+
+/**
+ * @addtogroup ALP_TELEPHONY_SERVICES_CAT
+ * @{
+ */
+
+//! Proactive Commands Id
+#define SAT_CMD_REFRESH                                                                        0x01
+#define SAT_CMD_SETUP_EVENTLIST                                                        0x05
+#define SAT_CMD_SETUP_CALL                                                             0x10
+#define SAT_CMD_SEND_SS                                                                        0x11
+#define SAT_CMD_SEND_USSD                                                              0x12
+#define SAT_CMD_SEND_SHORT_MESSAGE                                             0x13
+#define SAT_CMD_SEND_DTMF                                                              0x14
+#define SAT_CMD_LAUNCH_BROWSER                                                 0x15
+#define SAT_CMD_PLAY_TONE                                                              0x20
+#define SAT_CMD_DISPLAY_TEXT                                                           0x21
+#define SAT_CMD_GET_INKEY                                                              0x22
+#define SAT_CMD_GET_INPUT                                                              0x23
+#define SAT_CMD_SELECT_ITEM                                                            0x24
+#define SAT_CMD_SETUP_MENU                                                             0x25
+#define SAT_CMD_SETUP_IDLE_MODE_TEXT                                   0x28
+#define SAT_CMD_RUN_AT_COMMAND                                                 0x34
+#define SAT_CMD_OPEN_CHANNEL                                                   0x40
+#define SAT_CMD_CLOSE_CHANNEL                                                  0x41
+#define SAT_CMD_RECEIVE_DATA                                                   0x42
+#define SAT_CMD_SEND_DATA                                                              0x43
+
+
+/******************************************************************************************************************************************************/
+//! read file parameters
+
+//! Card EF access mode
+#define        SAT_CARD_MODE_GET_INFO                                                          0x00    //!<  Get EF information
+#define        SAT_CARD_MODE_READ_FILE                                                         0x01    //!<  Read EF body 
+#define        SAT_CARD_MODE_READ_PART                                                         0x02    //!<  Read EF part 
+#define        SAT_CARD_MODE_READ_REC                                                          0x03    //!<  Read EF record
+
+//! Card EF structure
+#define SAT_CARD_FILE_STRUCT_TRANSPARENT                                       0x00    //!< Transparent EF file: binary files
+#define SAT_CARD_FILE_STRUCT_LINEAR_FIXED                                      0x01    //!< Linear Fixed File: file divided into several equal-length records
+#define SAT_CARD_FILE_STRUCT_CYCLIC                                                    0x03    //!< Cyclic File: used to keep track of data in chronological order
+
+/******************************************************************************************************************************************************/
+
+//! SetUpEventList parameters: each byte in the event list shall be coded with one of the values below: 
+#define SAT_EVENT_USER_ACTIVITY                                                                0x04    //!< User activity
+#define SAT_EVENT_IDLE_SCREEN_AVAILABLE                                                0x05    //!< Idle screen available
+#define SAT_EVENT_LANGUAGE_SELECTION                                           0x07    //!< Language selection
+#define SAT_EVENT_BROWSER_TERMINATION                                          0x08    //!< Browser termination
+#define SAT_EVENT_DATA_AVAILABLE                                                       0x09    //!< Data available
+#define SAT_EVENT_CHANNEL_STATUS                                                       0x0A    //!< Channel status
+#define SAT_EVENT_ACCES_TECH_CHANGE                                                    0x0B    //!< Access Technology Change
+#define SAT_EVENT_DISPLAY_PARAMETERS_CHANGED                           0x0C    //!< Display parameters changed
+#define SAT_EVENT_LOCAL_CONNECTION                                                     0x0D    //!< Local connection
+#define SAT_EVENT_BROWSING_STATUS                                                      0x0F    //!< Browsing status
+#define SAT_EVENT_FRAMES_INFORMATION_CHANGE                                    0x10    //!< Frames Information Change
+#define SAT_EVENT_IWLAN_ACCESS_STATUS                                          0x11    //!< I-WLAN Access Status
+
+/******************************************************************************************************************************************************/
+//! PLAY TONE command parameters
+
+#define SAT_PLAY_TONE_DIAL_TONE                                                                        0x01    //!< Dial tone
+#define SAT_PLAY_TONE_CALLER_BUSY                                                              0x02    //!< Called subscriber busy
+#define SAT_PLAY_TONE_CONGESTION                                                               0x03    //!< Congestion
+#define SAT_PLAY_TONE_RADIO_PATH_ACKNOWLEDGE                                   0x04    //!< Radio path acknowledge
+#define SAT_PLAY_TONE_CALL_DROPPED                                                             0x05    //!< Radio path not available/Call dropped
+#define SAT_PLAY_TONE_SPECIAL_INFORMATION_OR_ERROR                             0x06    //!< Error/Special information
+#define SAT_PLAY_TONE_CALL_WAITING_TONE                                                        0x07    //!< Call waiting tone
+#define SAT_PLAY_TONE_RINGING_TONE                                                             0x08    //!< Ringing tone
+  
+//! Terminal proprietary tones:
+#define SAT_GENERAL_BEEP                                                                               0x10    //!< General beep       
+#define SAT_POSITIVE_ACKNOWLEDGE_TONE                                                  0x11    //!< Positive acknowledgement tone
+#define SAT_NEGATIVE_ACKNOWLEDGE_TONE                                                  0x12    //!< Negative acknowledgement or error tone
+#define SAT_USER_RINGING_TONE                                                                  0x13    //!< Ringing tone as selected by the user for incoming speech call
+#define SAT_USER_SMS_TONE                                                                              0x14    //!< Alert tone as selected by the user for incoming SMS
+#define SAT_CRITICAL_ALERET                                                                            0x15    //!< Critical Alert - This tone is to be used in critical situations.        terminal;
+  
+//! Themed tones:
+#define SAT_VIBRATE_ONLY                                                                               0x20    //!< vibrate only, if available
+#define SAT_HAPPY_TONE                                                                                 0x30    //!< happy tone
+#define SAT_SAD_TONE                                                                                   0x31    //!< sad tone
+#define SAT_URGENT_ACTION_TONE                                                                 0x32    //!< urgent action tone
+#define SAT_QUESTION_TONE                                                                              0x33    //!< question tone
+#define SAT_MESSAGE_RECEIVED_TONE                                                              0x34    //!< message received tone
+
+//! Melody tones:
+#define SAT_MELODY1_TONE                                                                               0x40    //!< Melody 1
+#define SAT_MELODY2_TONE                                                                               0x41    //!< Melody 2
+#define SAT_MELODY3_TONE                                                                               0x42    //!< Melody 3
+#define SAT_MELODY4_TONE                                                                               0x43    //!< Melody 4
+#define SAT_MELODY5_TONE                                                                               0x44    //!< Melody 5
+#define SAT_MELODY6_TONE                                                                               0x45    //!< Melody 6
+#define SAT_MELODY7_TONE                                                                               0x46    //!< Melody 7
+#define SAT_MELODY8_TONE                                                                               0x47    //!< Melody 8
+
+
+/**********************************************************************************************************************************************************************
+*     
+*              Command qualifier     
+*     
+**********************************************************************************************************************************************************************/
+
+//! Refresh command qualifier
+#define SAT_REFRESH_SIM_INIT_AND_FULL_FILE_CHANGE_NOTIFICATION 0x00    //!< NAA Initialization and Full File Change Notification
+#define SAT_REFRESH_FILE_CHANGE_NOTIFICATION                                   0x01    //!< File Change Notification
+#define SAT_REFRESH_SIM_INIT_AND_FILE_CHANGE_NOTIFICATION              0x02    //!< NAA Initialization and File Change Notification
+#define SAT_REFRESH_SIM_INIT                                                                   0x03    //!< NAA Initialization
+#define SAT_REFRESH_SIM_RESET                                                                  0x04    //!< UICC Reset
+#define SAT_REFRESH_USIM_INIT                                                                  0x05    //!< NAA Application Reset, only applicable for a 3G platform
+#define SAT_REFRESH_USIM_RESET                                                                 0x06    //!< NAA Session Reset, only applicable for a 3G platform;
+
+/******************************************************************************************************************************************************/
+
+//! SetUpCall command qualifier 
+#define SAT_SETUP_CALL_ONLY_IF_NOT_BUSY                                                                        0x00    //!< Set up call, but only if not currently busy on another call
+#define SAT_SETUP_CALL_ONLY_IF_NOT_BUSY_WITH_REDIAL                                            0x01    //!< Set up call, but only if not currently busy on another call, with redial
+#define SAT_SETUP_CALL_AND_PUT_ALL_OTHER_CALLS_ON_HOLD                                 0x02    //!< Set up call, putting all other calls (if any) on hold
+#define SAT_SETUP_CALL_AND_PUT_ALL_OTHER_CALLS_ON_HOLD_WITH_REDIAL             0x03    //!< Set up call, putting all other calls (if any) on hold, with redial
+#define SAT_SETUP_CALL_AND_DISCONNECT_ALL_OTHER_CALLS                                  0x04    //!< Set up call, disconnecting all other calls (if any)
+#define SAT_SETUP_CALL_AND_DISCONNECT_ALL_OTHER_CALLS_WITH_REDIAL              0x05    //!< Set up call, disconnecting all other calls (if any), with redial
+
+/******************************************************************************************************************************************************/
+
+//! SEND SHORT MESSAGE command qualifier
+#define  SAT_SEND_SMS_PACKING_NOT_REQUIRED                     0x00 //!< bit 1: 0 = packing not required;
+#define  SAT_SEND_SMS_PACKING_REQUIRED                         0x01 //!< bit 1: 1 = SMS packing by the ME required.
+
+/******************************************************************************************************************************************************/
+
+//! Play Tone command qualifier
+#define SAT_VIBRATE_ALERT_UP_TO_TERMINAL                       0x00    //!< use of vibrate alert is up to the terminal
+#define SAT_VIBRATE_ALERT_WITH_TONE                                    0x01    //!< vibrate alert, if available, with the tone
+
+/******************************************************************************************************************************************************/
+
+//! DISPLAY MULTIMEDIA MESSAGE / DISPLAY TEXT command qualifier 
+
+// priority
+#define        SAT_NORMAL_PRIORITY                                                     0x00    //!<normal priority
+#define        SAT_HIGH_PRIORITY                                                       0x01    //!<high priority
+
+//clearAfterDelay      
+#define        SAT_USER_CLEAR                                                          0x00    //!<wait for user to clear message
+#define        SAT_CLEAR_AFTER_DELAY                                           0x01    //!<clear after delay
+
+/******************************************************************************************************************************************************/
+
+//! GET INKEY / GET INPUT command qualifier (common part)
+
+//respType
+#define         SAT_RESP_TYPE_YES_NO_OPTION                            0x01    // Character sets disabled and the "Yes/No" response is requested, applies to GetInkey
+#define  SAT_RESP_TYPE_UNPACKED_DIGITS_ONLY                    0x02    // unpacked digits (0 to 9, *, #, and +) only, applies to GetInkey, GetInput
+#define  SAT_RESP_TYPE_PACKED_DIGITS_ONLY                      0x03    // packed digits (0 to 9, *, #, and +) only, applies to GetInput
+#define  SAT_RESP_TYPE_UCS2_DIGITS_ONLY                                0x04    // UCS2 digits (0 to 9, *, #, and +) only, applies to GetInkey, GetInput
+#define  SAT_RESP_TYPE_UNPACKED_SMS_ALPHABET           0x05    // SMS default alphabet 8 bits data, applies to GetInkey, GetInput 
+#define  SAT_RESP_TYPE_PACKED_SMS_ALPHABET                     0x06    // SMS default alphabet 7 bits packed, applies to GetInput
+#define  SAT_RESP_TYPE_UCS2_ALPHABET                           0x07    // 16 bits UCS2 alphabet, applies to GetInkey, GetInput
+                                                                                                                                        
+/******************************************************************************************************************************************************/
+
+//! GET INPUT command qualifier dispatched on the field hideUserInput
+
+//hideUserInput
+#define  SAT_GET_INPUT_NO_ECHO                                         0x00    //!< user input shall not be revealed in any way
+#define  SAT_GET_INPUT_WITH_ECHO                                       0x01    //!< terminal may echo user input on the display
+
+/******************************************************************************************************************************************************/
+
+//! SELECT ITEM command qualifier
+
+// specific to SELECT ITEM command
+#define SAT_DEFAULT_STYLE                                                      0x00    //!< presentation type is not specified
+#define SAT_PRESENT_AS_DATA_VALUES                                     0x01    //!< presentation as a choice of data values
+#define SAT_PRESENT_AS_NAVIGATION_OPTIONS                      0x02    //!< presentation as a choice of navigation options
+
+
+/******************************************************************************************************************************************************/
+//! Setup menu command qualifier dispatched on the softkey and helpInfo fields         
+
+//softKey
+#define  SAT_NO_SOFT_KEY                                                       0x00    //!< no selection preference
+#define  SAT_SOFT_KEY_PREFERRED                                                0x01    //!< selection using softkey preferred
+   
+/******************************************************************************************************************************************************/
+           
+//! Language Notification command qualifier
+#define SAT_LANGUAGE_NON_SPECIFIC_NOTIFICATION         0x00    //!< non-specific language notification
+#define SAT_LANGUAGE_SPECIFIC_NOTIFICATION                     0x01    //!< specific language notification
+
+/******************************************************************************************************************************************************/
+
+//! LaunchBrowser command qualifier 
+#define SAT_LAUNCH_BROWSER_IF_NOT_ALREADY_LAUNCHED                             0x00    //!< launch browser if not already launched
+#define SAT_LAUNCH_BROWSER_USE_EXISTING                                                        0x02    //!< use the existing browser (the browser shall not use the active existing secured session)
+#define SAT_LAUNCH_BROWSER_CLOSE_EXISTING_AND_LAUNCH_NEW               0x03    //!< close the existing browser session and launch new browser session
+
+/******************************************************************************************************************************************************/
+
+//! Open Channel command qualifier
+#define SAT_ON_DEMAND_LINK_ESTABLISHMENT                                               0x00    //!< on demand link establishment
+#define SAT_IMMEDIATE_LINK_ESTABLISHMENT                                               0x01    //!< immediate link establishment
+
+/******************************************************************************************************************************************************/
+//! common to Setup Menu/Get input / Get inkey
+
+//helpInfo
+#define  SAT_NO_HELP                                                                                   0x00    //!< no help available
+#define  SAT_HELP_AVAILABLE                                                                            0x01    //!< help available
+
+
+
+//!********************************************************************************
+//!* TLV data objects parameters                                                  *
+//!*                                                                                                                                                     *
+//!********************************************************************************
+
+//!Bearer codes used in the LAUNCH BROWSER command within the bearer list
+//!the terminal shall use the list of bearers associated with the Launch Broser command to choose which bearers are allowed in order of priority.
+#define SAT_BEARER_SMS                                                                                 0x00    //!< short message
+#define SAT_BEARER_CSD                                                                                 0x01    //!< circuit switched data
+#define SAT_BEARER_USSD                                                                                        0x02    //!<
+#define SAT_BEARER_GPRS                                                                                        0x03    //!< 
+
+/******************************************************************************************************************************************************/
+//! Command OPEN CHANNEL parameters or response to OPEN CHANNEL: 
+
+//type of adress in the TLV object "Other adress"
+#define        SAT_ADDRESS_IPV4                                                                                0x21
+#define        SAT_ADDRESS_IPV6                                                                                0x97
+
+//!Transport protocol type in the TLV object "UICC/ME interface transport level"
+#define        SAT_TRANSPORT_UDP                                                                               0x01    //!< UDP, UICC in client mode (as defined in RFC 768 [9])
+#define        SAT_TRANSPORT_TCP_CLIENT_MODE                                                   0x02    //!< TCP, UICC in client mode (as defined in RFC 793 [10])
+#define        SAT_TRANSPORT_TCP_SERVER_MODE                                                   0x03    //!< TCP, UICC in server mode (as defined in RFC 793 [10])
+
+//! Bearer type in the bearer description parameter 
+#define SAT_CSD                                                                                                        0x01    //!< circuit switched data
+#define SAT_GPRS_3G_PACKET_SERVICE                                                             0x02    //!< GPRS / 3G packet service
+#define SAT_DEFAULT_BEARER                                                                             0x03    //!< default bearer for requested transport layer
+#define SAT_TECHNOLOGY_INDEPENDANT                                                             0x04    //!< local link technology independent
+#define SAT_BLUETOOTH                                                                                  0x05    //!< Bluetooth
+#define SAT_IRDA                                                                                               0x06    //!< IrDA
+#define SAT_RS232                                                                                              0x07    //!< RS232
+#define SAT_PACKET_DATA_SERVICE                                                                        0x08    //!< TIA/EIA/IS-820 packet data service 
+#define SAT_UTRAN                                                                                              0x09    //!< UTRAN packet service with extended parameters
+#define SAT_USB                                                                                                        0x10    //!< USB
+
+/******************************************************************************************************************************************************/
+
+//! Icon qualifier (indicates to the terminal how the icon is to be used)
+#define SAT_SHOW_ICON_WITHOUT_TEXT                                                             0x00 //!< icon is self-explanatory, i.e. if displayed, it replaces the alpha identifier or text string
+#define SAT_SHOW_ICON_WITH_TEXT                                                                        0x01 //!< icon is not self-explanatory, i.e. if displayed, it shall be displayed together with the alpha identifier or text string
+
+/******************************************************************************************************************************************************/
+
+//! DISPLAY TEXT Parameters (Data coding scheme)
+#define        SAT_DCS_SMS_PACKED                                                                              0x00 //!<use the SMS default 7-bit coded alphabet, packed into 8-bit octets, as defined in TS 123 038 [3]
+#define        SAT_DCS_SMS_UNPACKED                                                                    0x04 //!<use the SMS default 7-bit coded alphabet as defined in TS 123 038 [3] with bit 8 set to 0
+#define        SAT_DCS_SMS_UNICODE                                                                             0x08 //!<use the UCS2 alphabet if the UCS2 is supported, as defined in TS 123 038 [3]
+
+/******************************************************************************************************************************************************/
+
+// Command Menu Selection parameters:  
+#define SAT_MENU_SELECTION_NO_HELP_REQUESTED                   0x00 //!< do not insert help request tag in the enveloppe message MENU SELECTION
+#define SAT_MENU_SELECTION_HELP_REQUESTED                              0x01 //!< insert help request tag in the enveloppe message MENU SELECTION to request help information on the item selected
+//#define SAT_MENU_SELECTION_APP_MENU_REQUEST                  0x03
+
+/******************************************************************************************************************************************************/
+
+//! Browser termination cause to join in the structure of enveloppe (Browser termination)  
+#define SAT_BROWSER_USER_TERMINATION                                                   0x00
+#define SAT_BROWSER_ERROR_TERMINATION                                                  0x01
+
+/******************************************************************************************************************************************************/
+
+//! Terminate reasons (not used)
+//#define SAT_TERMINATE_USER_STOPPED_REDIALING                                 0
+//#define SAT_TERMINATE_ENDS_OF_REDIALING_REACHED                              1
+//#define SAT_TERMINATE_USER_ENDS_SESSION                                              2
+/******************************************************************************************************************************************************/
+
+//! Setup Call actions
+#define SAT_CALL_REJECT                                                                                        0x00 //!< User did not accept the proactive command SETUP CALL
+#define SAT_CALL_ACCEPT                                                                                        0x01 //!< User accept to setup the call
+
+/******************************************************************************************************************************************************/
+
+//! General result codes
+#define        SAT_RES_COMMAND_SUCCESSFUL                                                                      0x00    //!<Command performed successfully
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_PARTIAL_COMPREHENSION           0x01    //!<Command performed with partial comprehension
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_MISSING_INFORMATION                     0x02    //!<Command performed, with missing information
+#define        SAT_RES_REFRESH_SUCCESSFUL_WITH_ADDITIONAL_EFS_READ                     0x03    //!<REFRESH performed with additional EFs read
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_ICON_NOT_FOUND                           0x04    //!<Command performed successfully, but requested icon could not be displayed
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_MODIFIED_BY_CALL_CONTROL         0x05    //!<Command performed, but modified by call control by NAA
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_LIMITED_SERVICE                          0x06    //!<Command performed successfully, limited service
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_MODIFICATION                            0x07    //!<Command performed with modification
+  
+#define        SAT_RES_ABORTED_BY_USER                                                                         0x10    //!<Proactive UICC session terminated by the user
+#define        SAT_RES_BACKWARD                                                                                        0x11    //!<Backward move in the proactive UICC session requested by the user
+#define        SAT_RES_NO_RESPONSE                                                                                     0x12    //!<No response from user
+#define        SAT_RES_HELP_REQUIRED                                                                           0x13    //!<Help information required by the user
+#define        SAT_RES_USSD_ABORTED_BY_USER                                                            0x14    //!<USSD or SS transaction terminated by the user
+#define        SAT_RES_ME_UNABLE_TO_PROCESS_COMMAND                                            0x20    //!<terminal currently unable to process command
+#define        SAT_RES_NETWORK_UNABLE_TO_PROCESS_COMMAND                                       0x21    //!<Network currently unable to process command
+#define        SAT_RES_USER_REJECTED_SETUP_CALL                                                        0x22    //!<User did not accept the proactive command
+#define        SAT_RES_USER_CLEARED_BEFORE_RELEASE                                                     0x23    //!<User cleared down call before connection or network release
+#define        SAT_RES_ACTION_CONTRADICT_TIMER_STATE                                           0x24    //!<Action in contradiction with the current timer state
+#define        SAT_RES_TEMP_PROBLEM_IN_CALL_CONTROL                                            0x25    //!<Interaction with call control by NAA, temporary problem
+#define        SAT_RES_LAUNCH_BROWSER_ERROR                                                            0x26    //!<Launch browser generic error code
+#define        SAT_RES_COMMAND_BEYOND_ME_CAPABILITIES                                          0x30    //!<Command beyond terminal's capabilities
+#define        SAT_RES_COMMAND_TYPE_NOT_UNDERSTOOD                                                     0x31    //!<Command type not understood by terminal
+#define        SAT_RES_COMMAND_DATA_NOT_UNDERSTOOD                                                     0x32    //!<Command data not understood by terminal
+#define        SAT_RES_COMMAND_NUMBER_NOT_KNOWN                                                        0x33    //!<Command number not known by terminal
+#define        SAT_RES_SS_RETURN_ERROR                                                                         0x34    //!<SS Return Error
+#define        SAT_RES_SMS_RP_ERROR                                                                            0x35    //!<SMS RP-ERROR
+#define        SAT_RES_REQUIRED_VALUES_MISSING                                                         0x36    //!<Error, required values are missing
+#define        SAT_RES_USSD_RETURN_ERROR                                                                       0x37    //!<USSD Return Error
+//#define      SAT_MULTIPLE_CARD_COMMAND_ERROR                                         0x38     //!<MultipleCard commands error
+#define        SAT_RES_PERMANENT_PROBLEM_IN_SMS_OR_CALL_CONTROL                        0x39    //!<Interaction with call control by USIM or MO short message control by USIM, permanent problem
+#define        SAT_RES_BEARER_INDEPENDENT_PROTOCOL_ERROR                                       0x3A    //!<Bearer Independent Protocol error
+#define        SAT_RES_ACCESS_TECHNOLOGY_UNABLE_TO_PROCESS                                     0x3B    //!<Access Technology unable to process command
+#define        SAT_RES_FRAMES_ERROR                                                                            0x3C    //!<Frames error
+#define        SAT_RES_MMS_ERROR                                                                                       0x3D    //!<MMS Error
+
+
+/**
+ * @addtogroup SAT
+ * @{
+ */
+#define        ALP_TEL_CARD_GET_FILE_MESSAGE                                                   ((SAT_SERVICE_ID << 8) | 0x0000)
+#define        SAT_GET_CONFIG_MESSAGE                                                  ((SAT_SERVICE_ID << 8) | 0x0001)
+#define        SAT_SET_CONFIG_MESSAGE                                                  ((SAT_SERVICE_ID << 8) | 0x0002)
+#define        SAT_TERMINATE_MESSAGE                                                   ((SAT_SERVICE_ID << 8) | 0x0003)
+#define        SAT_GET_CMD_PARAMETERS_MESSAGE                                  ((SAT_SERVICE_ID << 8) | 0x0004)
+#define        SAT_SET_CMD_RESPONSE_MESSAGE                                    ((SAT_SERVICE_ID << 8) | 0x0005)
+#define        SAT_MENU_SELECTION_MESSAGE                                              ((SAT_SERVICE_ID << 8) | 0x0006)
+#define        SAT_CALL_ACTION_MESSAGE                                                 ((SAT_SERVICE_ID << 8) | 0x0007)
+#define        SAT_NOTIFY_CARD_OF_EVENT_MESSAGE                                ((SAT_SERVICE_ID << 8) | 0x0008)
+
+#define        SAT_MESSAGES_COUNT                                                              ((SAT_NOTIFY_CARD_OF_EVENT_MESSAGE & ALP_TEL_MESSAGE_MASK) + 1) //!< Total count of CAT service messages
+
+
+#endif // SAT_VALUES_H
+
diff --git a/vmodem/include/server/eloop.h b/vmodem/include/server/eloop.h
new file mode 100644 (file)
index 0000000..8995cac
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*********************************************************************
+* $Id: eloop.h,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+*
+* Created : 20050329
+*
+* Copyright (C) Samsung Electronics
+*
+*********************************************************************/
+
+#ifndef __ELOOP_H__
+#define __ELOOP_H__
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/poll.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "phoneserver.h"
+
+typedef int (*EloopCallback)(void *data);
+typedef int (*EloopInputCallback)(PhoneServer * ps, int fd, EloopCondition cond, void *data);
+
+
+int eloop_add_timeout(unsigned int time_slice, EloopCallback cb, void *data);
+void eloop_remove_timeout(int tag);
+int eloop_add_input(PhoneServer * ps, int fd, EloopCondition cond, EloopInputCallback cb, void *data);
+void eloop_remove_input(int tag);
+void eloop_main(void);
+void eloop_quit(void);
+
+
+
+typedef struct _TimeoutStruct
+{
+    int64_t expire;
+    EloopCallback cb;
+    int tag;
+    void *data;
+    int time_slice;
+    struct _TimeoutStruct *next;
+    struct _TimeoutStruct *prev;
+}
+TimeoutStruct;
+
+typedef struct _InOutStruct
+{
+    PhoneServer * ps;
+    int fd;
+    EloopCondition cond;
+    EloopInputCallback cb;
+    int tag;
+    void *data;
+    struct _InOutStruct *next;
+    struct _InOutStruct *prev;
+} InOutStruct;
+
+#endif /* __ELOOP_H__ */
+
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++end of file
+
+
diff --git a/vmodem/include/server/flight.h b/vmodem/include/server/flight.h
new file mode 100644 (file)
index 0000000..e1f89d3
--- /dev/null
@@ -0,0 +1,43 @@
+
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the 
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
+ *
+ * Contributors:
+ * - S-Core Co., Ltd 
+ * 
+ */
+
+#ifndef _SERVER_FLIGHT_H_
+#define _SERVER_FLIGHT_H_
+
+#include <string.h>
+#include "oem_rx_power.h"
+#include "at_rx_func.h"
+#include <vconf/vconf.h>
+#include <vconf/vconf-keys.h>
+
+/* For Flight Mode */
+extern int g_svc_type;
+
+bool is_flight_mode(void);
+
+#endif 
diff --git a/vmodem/include/server/gsm.h b/vmodem/include/server/gsm.h
new file mode 100644 (file)
index 0000000..a467f97
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+//////////////////////////////////////////////////////////////////
+// gsm.h
+*/
+
+#ifndef __PS_GSM_H__
+#define __PS_GSM_H__
+
+#include <vgsm_error.h>
+#include <gsmstate.h>
+#include <stdarg.h>
+#include "state.h"
+
+GSM_Error GSM_Init(bool checkerror);
+GSM_Error GSM_PhonePowerOn(int first_boot);
+bool GSM_PhonePowerStatus(void);
+void GSM_Terminate(void);
+GSM_Error GSM_Start(void);
+
+#endif /* __PS_GSM_H__ */
+
diff --git a/vmodem/include/server/lxtsms.h b/vmodem/include/server/lxtsms.h
new file mode 100644 (file)
index 0000000..7e80e17
--- /dev/null
@@ -0,0 +1,838 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTSMS_H_
+#define _LXTSMS_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+#include "linuxtapi.h"
+#include "lxtsmstypedef.h"
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+#define DEF_INIT_MAGIC_CODE                                                0xFF
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ type define area
+
+
+
+    // Global ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    // SMS_TIME_STAMP_RELATIVE
+    // offset value | relative time period                     | validity period | delivery time
+    // =============|==========================================|=================|===============
+    // 0 ~ 143      |  (value + 1) * 5 min                     |        x        |        x
+    // =============|==========================================|=================|===============
+    // 144 ~ 167    |  12 hours + ((value -143) * 30 min)      |        x        |        x
+    // =============|==========================================|=================|===============
+    // 168 ~ 196    |  (value - 166) days                      |        x        |        x
+    // =============|==========================================|=================|===============
+    // 197 ~ 244    |  (value - 192) weeks                     |        x        |        x
+    // =============|==========================================|=================|===============
+    // 245          |  Indefinite                              |        x        |
+    // =============|==========================================|=================|===============
+    // 246          |  Immediate [1]                           |        x        |
+    // =============|==========================================|=================|===============
+    // 247          |  Valid until mobile becomes inactive     |        x        |        x
+    //              |  Deliver when mobile next becomes active |                 |
+    // =============|==========================================|=================|===============
+    // 248          |  Valid until registration area changes,  |        x        |
+    //              |  discard if not registered               |                 |
+    // =============|==========================================|=================|===============
+    // 249 ~ 255    |  reserved                                |                 |
+    // =============|==========================================|=================|===============
+
+
+
+
+
+
+    // Teleservice Identifier (0x01) +++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of teleservice id
+        unsigned char length;
+
+        // teleservice identifier
+        SMS_TELESERVICE_ID service_id;
+
+    }
+    SMS_TELESERVICE_IDENTIFIER;
+
+
+
+
+
+
+
+
+
+
+    // Broadcast Service Category (0x02) +++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of broadcast service category
+        unsigned char length;
+
+        // service category(2byte)
+        SMS_BROADCAST_SERVICE_CATEGORY_CATEGORY category;
+
+    }
+    SMS_BROADCAST_SERVICE_CATEGORY;
+
+
+
+
+
+
+
+
+
+
+
+    // Address (0x03) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length - 5 + num_fields
+        unsigned char length;
+
+        // digit mode indicator - 0x00 : 4BIT_DTMF, 0x01:8BIT_CODE;
+        SMS_ADDRESS_DIGIT_MODE digit_mode;
+
+        // number mode indicator - 0x00 : ANSI TI.607, 0x01 : Data Network
+        SMS_ADDRESS_NUMBER_MODE number_mode;
+
+        // type of number -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) ) then use SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK
+        // if ( DIGIT_MODE == 0 ) then ignore this field
+        SMS_ADDRESS_NUMBER_TYPE number_type;
+
+        // numbering plan -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_PLAN
+        // if ( ( DIGIT_MODE == 0 ) || ( NUMBER_MODE == 1 ) ) then ignore this field
+        SMS_ADDRESS_NUMBER_PLAN number_plan;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // digit number
+        // if ( DIGIT_MODE == 0 ) then ASCII
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then ANSI X3.4(7bit code for american standard, all significant bit '0')
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE == 2 ) ) mail address
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE != 2 ) ) ip address
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+    }
+    SMS_ADDRESS;
+
+
+
+
+
+
+
+
+
+
+
+    // Subaddress (0x04) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+
+        // parameter length - 3 + num_fields
+        unsigned char length;
+
+        // subaddress type - use SMS_SUBADDRESS_TYPE
+        SMS_SUBADDRESS_TYPE type;
+
+        // odd/even indicator
+        // if the last digit_number contains information only in the 4 most sign bit then '1' else '0'
+        unsigned char odd;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // subaddress octet
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+    }
+    SMS_SUBADDRESS;
+
+
+
+
+
+
+
+
+
+
+
+    // Bearer Reply Option (0x05) ++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // length of rearer reply option
+        unsigned char length;
+
+        // reply sequence number
+        // This field shall be set to a value identifying the SMS message for
+        // which acknowledgment is requested. : 0 ~ 63 ( modulo of 8 )
+        unsigned char reply_seq;
+
+    }
+    SMS_BEARER_REPLY_OPTION;
+
+
+
+
+
+
+
+
+
+
+
+    // Cause Codes (0x06) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // reply sequence number
+        // this field shall be set to the reply sequence number in the
+        // Bearer Reply Option parameter of the message being acknowledged.
+        unsigned char reply_seq;
+
+        // error report class - use SMS_CAUSE_CODES_ERROR_CLASS
+        SMS_CAUSE_CODES_ERROR_CLASS error_class;
+
+        // error cause identifier - if ERROR_CLASS is 0, then this field is ignored.
+        // if ERROR_CLASS is 2 or 3, then use SMS_CAUSE_CODE_CAUSE_CODE_NETWORK
+        // if ERROR_CLASS is 4, then use SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL
+        SMS_CAUSE_CODE_CAUSE_CODE cause_code;
+
+    }
+    SMS_CAUSE_CODES;
+
+
+
+
+
+
+
+
+
+
+
+    // Message Identifier (0x07) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // length of message identifier
+        unsigned char length;
+
+        // use SMS_MESSAGE_TYPE
+        SMS_MESSAGE_TYPE message_type;
+
+        // Message ID Number(2 byte)
+        unsigned short message_id;
+
+    }
+    SMS_MESSAGE_IDENTIFIER;
+
+
+
+
+
+
+
+
+
+
+
+    // User Data (0x08) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // user data length
+        unsigned char length;
+
+        // encoding - use SMS_USER_DATA_MSG_ENCODING
+        SMS_USER_DATA_MSG_ENCODING msg_encoding;
+
+        // number of digit_number
+        unsigned char num_fields;
+
+        // user data
+        unsigned char* user_data;
+
+    }
+    SMS_USER_DATA;
+
+
+
+
+
+
+
+
+
+
+
+    // User Response Code (0x09) +++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // length of user response code
+        unsigned char length;
+
+        // this field value depends on the teleservices or the carrier
+        unsigned char response_code;
+
+    }
+    SMS_USER_RESPONSE_CODE;
+
+
+
+
+
+
+
+
+
+
+
+    // Message Center Time Stamp (0x0A) ++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // length of message center time stamp
+        unsigned char length;
+
+        // time stamp
+        unsigned char time_stamp[6];
+
+    }
+    SMS_MESSAGE_CENTER_TIME_STAMP;
+
+
+
+
+
+
+
+
+
+
+    // Validity Period - Absolute (0x0B) +++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // prameter length
+        unsigned char length;
+
+        // time stamp
+        unsigned char validity_period[6];
+
+    }
+    SMS_VALIDITY_PERIOD_ABSOLUTE;
+
+
+
+
+
+
+
+
+
+
+
+    // Validity Period - Relative (0x0C) +++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // relative value
+        unsigned char validity;
+
+
+    }
+    SMS_VALIDITY_PERIOD_RELATIVE;
+
+
+
+
+
+
+
+
+
+
+    // Deferred Delivery Time - Absolute (0x0D) ++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // time stamp
+        unsigned char deferred_delivery_time[6];
+
+    }
+    SMS_DEFERRED_DELIVERY_TIME_ABSOLUTE;
+
+
+
+
+
+
+
+
+
+
+    // Deferred Delivery Time - Relative (0x0E) ++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // relative value
+        unsigned char deferred_delivery_time;
+
+    }
+    SMS_DEFERRED_DELIVERY_TIME_RELATIVE;
+
+
+
+
+
+
+
+
+
+
+    // Priority Indicator (0x0F) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // level of priority
+        SMS_PRIORITY_INDICATOR_PRIORITY priority;
+
+    }
+    SMS_PRIORITY_INDICATOR;
+
+
+
+
+
+
+
+
+
+
+    // Privacy Indicator (0x10) ++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // privacy level
+        SMS_PRIVACY_INDICATOR_PRIVACY privacy;
+
+    }
+    SMS_PRIVACY_INDICATOR;
+
+
+
+
+
+
+
+
+
+
+    // Reply Option (0x11) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // TRUE if User acknowledgment is requested (0x00 : FALSE, 0x01 : TRUE)
+        unsigned char user_ack_req;
+
+        // TRUE if Delivery acknowledgment is requested (0x00 : FALSE, 0x01 : TRUE)
+        unsigned char dak_req;
+
+    }
+    SMS_REPLY_OPTION;
+
+
+
+
+
+
+
+
+
+
+    // Number of Messages (0x12) +++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // number of voice mail (0 ~ 99)
+        unsigned char message_count;
+
+    }
+    SMS_NUMBER_OF_MESSAGES;
+
+
+
+
+
+
+
+
+
+
+    // Alert on Message Delivery (0x13) ++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // the type of alerts used to distinguish different priorities of the message
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY alert_priority;
+
+    }
+    SMS_ALERT_ON_MESSAGE_DELIVERY;
+
+
+
+
+
+
+
+
+
+
+    // Language Indicator (0x14) +++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // language indicator
+        SMS_LANGUAGE_INDICATOR_LANGUAGE language;
+
+    }
+    SMS_LANGUAGE_INDICATOR;
+
+
+
+
+
+
+
+
+
+
+    // Call Back Number (0x15) +++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+
+        // parameter length - 5 + num_fields
+        unsigned char length;
+
+        // digit mode indicator - 0x00 : 4BIT_DTMF, 0x01:8BIT_CODE;
+        SMS_ADDRESS_DIGIT_MODE digit_mode;
+
+        // type of number -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) ) then use SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK
+        // if ( DIGIT_MODE == 0 ) then ignore this field
+        SMS_ADDRESS_NUMBER_TYPE number_type;
+
+
+        // numbering plan -
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then use SMS_ADDRESS_NUMBER_PLAN
+        // if ( ( DIGIT_MODE == 0 ) || ( NUMBER_MODE == 1 ) ) then ignore this field
+        SMS_ADDRESS_NUMBER_PLAN number_plan;
+
+        // the number of digit_number
+        unsigned char num_fields;
+
+        // digit number
+        // if ( DIGIT_MODE == 0 ) then ASCII
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 0 ) ) then ANSI X3.4(7bit code for american standard, all significant bit '0')
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE == 2 ) ) mail address
+        // if ( ( DIGIT_MODE == 1 ) && ( NUMBER_MODE == 1 ) && ( NUMBER_TYPE != 2 ) ) ip address
+        unsigned char digit_number[DEF_SMS_MAX_DIGIT_NUMBER];
+
+
+    }
+    SMS_CALL_BACK_NUMBER;
+
+
+
+
+
+
+
+
+
+
+    // Display Mode (0x16) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // message display mode
+        SMS_MESSAGE_DISPLAY_MODE msg_display_mode;
+
+        // prl update
+        unsigned char prl_update;
+
+        // encoding
+        unsigned char encoding;
+
+    }
+    SMS_DISPLAY_MODE;
+
+
+
+
+
+
+
+
+
+
+    // Multiple Encoding User Data (0x17) ++++++++++++++++++++++++++++++++++++++++++
+    // TBD...
+    typedef struct
+    {
+        // message encoding
+        unsigned char msg_encoding;
+
+        // user data length
+        unsigned char num_fields;
+
+        // user data
+        unsigned char* user_data;
+
+    }
+    SMS_MULTIPLE_ENCODING_USER_DATA_ENDCODING_SPECIFIC_FIELDS;
+
+
+    typedef struct
+    {
+        unsigned char length;
+        SMS_MULTIPLE_ENCODING_USER_DATA_ENDCODING_SPECIFIC_FIELDS *encoding_specific_fields;
+
+    }
+    SMS_MULTIPLE_ENCODING_USER_DATA;
+
+
+
+
+
+
+
+
+
+
+    // Memory Index (0x18) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    typedef struct
+    {
+        // parameter length
+        unsigned char length;
+
+        // memory address
+        unsigned short mem_address;
+
+    }
+    SMS_MEMORY_INDEX;
+
+
+
+
+
+
+
+
+
+
+
+
+    // SMS Message +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    typedef struct
+    {
+        // ruim memory index
+        unsigned char uim_memory_index;
+
+        // ruim tag
+        unsigned char uim_tag;
+
+        // Remaining frame count
+        unsigned char rfr_cnt;
+
+        // 0x00 : SMS Point to Point Message, 0x01 : SMS Broadcast Message
+        unsigned char sms_msg_cat;
+
+        // parametr mask
+        unsigned char sms_param_mask[4];
+
+        // One of more occurrences of the following parameter record ------------
+
+        // service id (1 byte) -- 0x01
+        SMS_TELESERVICE_IDENTIFIER teleserviceIdentifier;
+
+        // broadcast service category (2 byte) -- 0x02
+        SMS_BROADCAST_SERVICE_CATEGORY broadcastServiceCategory;
+
+        // Address-Destination Address or Origination Address -- 0x03
+        SMS_ADDRESS address;
+
+        // Subaddress-Destination or Origination -- 0x04
+        SMS_SUBADDRESS subaddress;
+
+        // Bearer reply option - Reply sequence number -- 0x05
+        // This field shall be set to a value identifying the SMS message for
+        // which acknowledgment is requested. : 0 ~ 63 ( modulo of 8 )
+        SMS_BEARER_REPLY_OPTION bearer_reply_option;
+
+        // Cause Codes -- 0x06
+        SMS_CAUSE_CODES cause_codes;
+
+        // message identifier -- 0x07
+        SMS_MESSAGE_IDENTIFIER message_identifier;
+
+        // user data -- 0x08
+        SMS_USER_DATA user_data;
+
+        // user response code -
+        //This field value depends on the teleservices or the carrier-- 0x09
+        SMS_USER_RESPONSE_CODE response_code;
+
+        // Message Center Time Stamp -- 0x0A
+        SMS_MESSAGE_CENTER_TIME_STAMP message_center_time_stamp;
+
+        // Validity Period - Absolute -- 0x0B
+        SMS_VALIDITY_PERIOD_ABSOLUTE validity_period_absolute;
+
+        // Validity Period - Relative -- 0x0C
+        SMS_VALIDITY_PERIOD_RELATIVE validity_period_relative;
+
+        // Deferred Delivery Time - Absolute -- 0x0D
+        SMS_DEFERRED_DELIVERY_TIME_ABSOLUTE deferred_delivery_time_absolute;
+
+        // Deferred Delivery Time - Relative -- 0x0E
+        SMS_DEFERRED_DELIVERY_TIME_RELATIVE deferred_delivery_time_relative;
+
+        // Priority Indicator - use SMS_PRIORITY_INDICATOR 0x0F
+        SMS_PRIORITY_INDICATOR priority_indicator;
+
+        // Privacy Indicator - use SMS_PRIVACY_INDICATOR 0x10
+        SMS_PRIVACY_INDICATOR privacy_indicator;
+
+        // reply option -- 0x11
+        SMS_REPLY_OPTION reply_option;
+
+        // Number of Messages --0x12 (0 ~ 99)
+        // The number of messages element is a 0 to 99 decimal number
+        SMS_NUMBER_OF_MESSAGES number_of_messages;
+
+        // Alert on Message Delivery -- Ox13 - use SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY
+        SMS_ALERT_ON_MESSAGE_DELIVERY alert_message_delivery;
+
+        // language indicator -- 0x14 - use SMS_LANGUAGE_INDICATOR_LANGUAGE
+        SMS_LANGUAGE_INDICATOR language_indicator;
+
+        // call back number -- 0x15
+        SMS_CALL_BACK_NUMBER call_back_number;
+
+        // message display mode -- 0x16 - use SMS_MESSAGE_DISPLAY_MODE
+        SMS_DISPLAY_MODE message_display_mode;
+
+        // multiple encoding user data -- 0x17
+        SMS_MULTIPLE_ENCODING_USER_DATA multiple_encoding_user_data;
+
+        // memory index -- 0x18
+        SMS_MEMORY_INDEX memory_index;
+
+
+    }
+    TSamsungSMS;
+
+
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++ function prototype define
+    void lxt_sms_init_message(LXT_SMS *s);
+    int lxt_sms_paramsParser(TSamsungSMS *s, unsigned char *r);
+    void lxt_sms_parser(LXT_SMS *s,unsigned char memoryIndex,unsigned char tag,unsigned char rfr_cnt,unsigned char msg_cat,unsigned char *param_mask,unsigned char *rawdata,unsigned char length);
+    int lxt_sms_paramsDeparser(TSamsungSMS *s, unsigned char param_id, unsigned char *r);
+    unsigned char *lxt_sms_deparser(LXT_SMS *s, unsigned char *length);
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LXTSMS_H_
diff --git a/vmodem/include/server/lxtsmstypedef.h b/vmodem/include/server/lxtsmstypedef.h
new file mode 100644 (file)
index 0000000..97b04f2
--- /dev/null
@@ -0,0 +1,340 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTSMSTYPEDEF_H_
+#define _LXTSMSTYPEDEF_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+    typedef enum
+    {
+        SMS_PARAM_ID_TELESERVICE_IDENTIFIER=                                    0x01,
+        SMS_PARAM_ID_BROADCAST_SERVICE_CATEGORY=                                0x02,
+        SMS_PARAM_ID_ADDRESS=                                                   0x03,
+        SMS_PARAM_ID_SUBADDRESS=                                                0x04,
+        SMS_PARAM_ID_BEARER_REPLY_OPTION=                                       0x05,
+        SMS_PARAM_ID_CAUSE_CODES=                                               0x06,
+        SMS_PARAM_ID_MESSAGE_IDENTIFIER=                                        0x07,
+        SMS_PARAM_ID_USER_DATA=                                                 0x08,
+        SMS_PARAM_ID_USER_RESPONSE_CODE=                                        0x09,
+        SMS_PARAM_ID_MESSAGE_CENTER_TIME_STAMP=                                 0x0a,
+        SMS_PARAM_ID_VALIDITY_PERIOD_ABSOLUTE=                                  0x0b,
+        SMS_PARAM_ID_VALIDITY_PERIOD_RELATIVE=                                  0x0c,
+        SMS_PARAM_ID_DEFERRED_DELIVERY_TIME_ABSOLUTE=                           0x0d,
+        SMS_PARAM_ID_DEFERRED_DELIVERY_TIME_RELATIVE=                           0x0e,
+        SMS_PARAM_ID_PRIORITY_INDICATOR=                                        0x0f,
+        SMS_PARAM_ID_PRIVACY_INDICATOR=                                         0x10,
+        SMS_PARAM_ID_REPLY_OPTION=                                              0x11,
+        SMS_PARAM_ID_NUMBER_OF_MESSAGES=                                        0x12,
+        SMS_PARAM_ID_ALERT_ON_MESSAGE_DELIVERY=                                 0x13,
+        SMS_PARAM_ID_LANGUAGE_INDICATOR=                                        0x14,
+        SMS_PARAM_ID_CALL_BACK_NUMBER=                                          0x15,
+        SMS_PARAM_ID_DISPLAY_MODE=                                              0x16,
+        SMS_PARAM_ID_MULTIPLE_ENCODING_USER_DATA=                               0x17,
+        SMS_PARAM_ID_MEMORY_INDEX=                                              0x18
+    }SMS_PARAM_ID;
+
+
+
+    typedef enum
+    {
+        SMS_ADDRESS_DIGIT_MODE_4BIT_DTMF=                                       0x00,
+        SMS_ADDRESS_DIGIT_MODE_8BIT_CODE=                                       0x01
+    }SMS_ADDRESS_DIGIT_MODE;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_MODE_ANSI_TI_DOT_607=                                0x00,
+        SMS_ADDRESS_NUMBER_MODE_DATA_NETWORK=                                   0x01
+    }SMS_ADDRESS_NUMBER_MODE;
+
+    typedef unsigned char SMS_ADDRESS_NUMBER_TYPE;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_UNKNOWN=                        0x00,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_INTERNATIONAL_NUMBER=           0x01,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_NATIONAL_NUMBER=                0x02,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_NETWORK_SPECIFIC_NUMBER=        0x03,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_SUBSCRIBER_NUMBER=              0x04,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_RESERVED=                       0x05,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_ABBREVIATED_NUMBER=             0x06,
+        SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607_RESERVED_FOR_EXTENSION=         0x07
+    }SMS_ADDRESS_NUMBER_TYPE_ANSI_TI_DOT_607;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_UNKNOWN=                           0x00,
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_INTERNET_PROTOCOL_RFC791=          0x01,
+        SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK_INTERNET_EMAIL_ADDRESS_RFC822=     0x02
+    }SMS_ADDRESS_NUMBER_TYPE_DATA_NETWORK;
+
+    typedef enum
+    {
+        SMS_ADDRESS_NUMBER_PLAN_UNKNOWN=                                                                                                0x00,
+        SMS_ADDRESS_NUMBER_PLAN_ISDN_TELEPHONY_NUMBERING_PLAN=                                                                          0x01,
+        SMS_ADDRESS_NUMBER_PLAN_DATA_NUMBERING_PLAN=                                                                                    0x02,
+        SMS_ADDRESS_NUMBER_PLAN_TELEX_NUMBERING_PLAN=                                                                                   0x03,
+        SMS_ADDRESS_NUMBER_PLAN_PRIVATE_NUMBERING_PLAN=                                                                                 0x09,
+        SMS_ADDRESS_NUMBER_PLAN_RESERVED_FOR_EXTENSION=                                                                                 0x0F
+    }SMS_ADDRESS_NUMBER_PLAN;
+
+
+    typedef enum
+    {
+        SMS_TELESERVICE_ID_TELESRV_CPT_95=                                      0x00,
+        SMS_TELESERVICE_ID_TELESRV_CMT_95=                                      0x01,
+        SMS_TELESERVICE_ID_TELESRV_VMN_95=                                      0x02,
+        SMS_TELESERVICE_ID_TELESRV_CMT_91_CLI=                                  0x03,
+        SMS_TELESERVICE_ID_TELESRV_CMT91_VOICE_MAIL=                            0x04,
+        SMS_TELESERVICE_ID_TELESRV_CMT_91_SHORT_MSG=                            0x05,
+        SMS_TELESERVICE_ID_TELESRV_MSG_WAITING=                                 0x06,
+        SMS_TELESERVICE_ID_TELESRV_WAP=                                         0x07
+    }SMS_TELESERVICE_ID;
+
+    typedef enum
+    {
+        SMS_BROADCAST_SERVICE_CATEGORY_UNKNOWN_OR_UNSPECIFIED=                0x0000,
+        SMS_BROADCAST_SERVICE_CATEGORY_EMERGENCY_BROADCASTS=                  0x0001,
+        SMS_BROADCAST_SERVICE_CATEGORY_ADMINISTRATIVE=                        0x0002,
+        SMS_BROADCAST_SERVICE_CATEGORY_MAINTENANCE=                           0x0003,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_LOCAL=                    0x0004,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_REGIONAL=                 0x0005,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_NATIONAL=                 0x0006,
+        SMS_BROADCAST_SERVICE_CATEGORY_GENERAL_NEWS_INTERNATIONAL=            0x0007,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_LOCAL=         0x0008,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_REGIONAL=      0x0009,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_NATIONAL=      0x000A,
+        SMS_BROADCAST_SERVICE_CATEGORY_BUSINESS_FINANCIAL_NEWS_INTERNATIONAL= 0x000B,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_LOCAL=                     0x000C,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_REGIONAL=                  0x000D,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_NATIONAL=                  0x000E,
+        SMS_BROADCAST_SERVICE_CATEGORY_SPORTS_NEWS_INTERNATIONAL=             0x000F,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_LOCAL=              0x0010,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_REGIONAL=           0x0011,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_NATIONAL=           0x0012,
+        SMS_BROADCAST_SERVICE_CATEGORY_ENTERTAINMENT_NEWS_INTERNATIONAL=      0x0013,
+        SMS_BROADCAST_SERVICE_CATEGORY_LOCAL_WEATHER=                         0x0014,
+        SMS_BROADCAST_SERVICE_CATEGORY_AREA_TRAFFIC_REPORTS=                  0x0015,
+        SMS_BROADCAST_SERVICE_CATEGORY_LOCAL_AIRPORT_FLIGHT_SCHEDULES=        0x0016,
+        SMS_BROADCAST_SERVICE_CATEGORY_RESTAURANTS=                           0x0017,
+        SMS_BROADCAST_SERVICE_CATEGORY_LODGINGS=                              0x0018,
+        SMS_BROADCAST_SERVICE_CATEGORY_RETAIL_DIRECTORY=                      0x0019,
+        SMS_BROADCAST_SERVICE_CATEGORY_ADVERTISEMENTS=                        0x001A,
+        SMS_BROADCAST_SERVICE_CATEGORY_STOCK_QUOTES=                          0x001B,
+        SMS_BROADCAST_SERVICE_CATEGORY_EMPLOYMENT_OPPORTUNITIES=              0x001C,
+        SMS_BROADCAST_SERVICE_CATEGORY_MEDICAL_HEALTH_HOSPITALS=              0x001D,
+        SMS_BROADCAST_SERVICE_CATEGORY_TECHNOLOGY_NEWS=                       0x001E,
+        SMS_BROADCAST_SERVICE_CATEGORY_MULTI_CATEGORY=                        0x001F
+    }SMS_BROADCAST_SERVICE_CATEGORY_CATEGORY;
+
+
+    typedef enum
+    {
+        SMS_SUBADDRESS_TYPE_NSAP=                                               0x00,
+        SMS_SUBADDRESS_TYPE_USER_SPECIFIED=                                     0x01
+    }SMS_SUBADDRESS_TYPE;
+
+
+    typedef enum
+    {
+        SMS_CAUSE_CODES_ERROR_CLASS_NONE_ERROR=                                 0x00,
+        SMS_CAUSE_CODES_ERROR_CLASS_TEMPORARY_ERROR=                            0x02,
+        SMS_CAUSE_CODES_ERROR_CLASS_PERMANENT_ERROR=                            0x03,
+        SMS_CAUSE_CODES_ERROR_CLASS_PHONE_INTERNAL_STATUS=                      0x04
+    }SMS_CAUSE_CODES_ERROR_CLASS;
+
+    typedef unsigned char SMS_CAUSE_CODE_CAUSE_CODE;
+
+    typedef enum
+    {
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_ADDRESS_VACANT=                          0,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_ADDRESS_TRANSLATION_FAILURE=             1,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NETWORK_RESOURCE_SHORTAGE=               2,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NETWORK_FAILURE=                         3,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_INVALID_TELESERVICE_ID=                  4,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM=                   5,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM_MORE_FIRST=        6,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_NETWORK_PROBLEM_MORE_LAST=        31,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NO_PAGE_RESPONSE=                       32,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_BUSY=                       33,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_NO_ACK=                                 34,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_RESOURCE_SHORTAGE=          35,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED=                 36,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_OUT_OF_SERVICE=             37,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_DESTINATION_NO_LONGER_AT_THIS_ADDRESS=  38,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM=                 39,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM_MORE_FIRST=      40,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_TERMINAL_PROBLEM_MORE_LAST=       47,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED_MORE_FIRST=      48,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_DELIVERY_POSTPONED_MORE_LAST=       63,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RADIO_IF_RESOURCE_SHORTAGE=             64,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RADIO_IF_INCOMPATIBLE=                  65,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM=                 66,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM_MORE_FIRST=      67,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_RADIO_IF_PROBLEM_MORE_LAST=       95,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNEXPECTED_PARM_SIZE_S=                 96,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_ORIGINATION_DENIED=                 97,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_TERMINATION_DENIED=                 98,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SUPPLMENTARY_SERVICE_NOT_SUPPORTED=     99,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_SMS_NOT_SUPPORTED=                     100,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_RESERVED_101=                          101,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_MISSING_EXPECTED_PARM=                 102,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_MISSING_MANDATORY_PARM=                103,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNRECOGNIZED_PARM_VALUE=               104,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_UNEXPECTED_PARM_VALUE=                 105,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_USER_DATA_SIZE_ERROR=                  106,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS=                107,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS_MORE_FIRST=     108,
+        SMS_CAUSE_CODE_CAUSE_CODE_NETWORK_OTHER_GENERAL_PROBLEMS_MORE_LAST=      255
+    }SMS_CAUSE_CODE_CAUSE_CODE_NETWORK;
+
+    typedef enum
+    {
+        // 0x00 : layer 2 acknowledgment received
+        // 0x02 : SMS transmission failed because a transmission time is expired
+        //        or phone internal error occurred during the SMS transmission
+
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_L2ACK_RCVD=                   0x00,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL=                         0x01,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_NO_SVC=                  0x02,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_PHONE_BUSY=              0x03,
+        SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL_STATUS_FAIL_OTHER=                   0x04
+    }SMS_CAUSE_CODE_CAUSE_CODE_INTERNAL;
+
+
+
+    typedef enum
+    {
+        SMS_MESSAGE_TYPE_RESERVED=                                              0x00,
+        SMS_MESSAGE_TYPE_SMS_DELIVER_MESSAGE=                                   0x01,
+        SMS_MESSAGE_TYPE_SMS_SUBMIT_MESSAGE=                                    0x02,
+        SMS_MESSAGE_TYPE_SMS_CANCELLATION_MESSAGE=                              0x03,
+        SMS_MESSAGE_TYPE_SMS_DELIVERY_ACKNOWLEDGMENT_MESSAGE=                   0x04,
+        SMS_MESSAGE_TYPE_SMS_USER_ACKNOWLEDGMENT_MESSAGE=                       0x05,
+        SMS_MESSAGE_TYPE_ALL_MESSAGE=                                           0x0F
+    }SMS_MESSAGE_TYPE;
+
+
+
+    typedef enum
+    {
+        SMS_USER_DATA_MSG_ENCODING_OCTET=                                       0x00,
+        SMS_USER_DATA_MSG_ENCODING_IS_91_EXTENDED_PROTOCOL=                     0x01,
+        SMS_USER_DATA_MSG_ENCODING_7BIT_ASCII=                                  0x02,
+        SMS_USER_DATA_MSG_ENCODING_IA5=                                         0x03,
+        SMS_USER_DATA_MSG_ENCODING_UNICODE=                                     0x04,
+        SMS_USER_DATA_MSG_ENCODING_SHIFT_JIS=                                   0x05,
+        SMS_USER_DATA_MSG_ENCODING_KSC5601=                                     0x06,
+        SMS_USER_DATA_MSG_ENCODING_ISO_8859_8=                                  0x07,
+        SMS_USER_DATA_MSG_ENCODING_ISO_8859_1=                                  0x08,
+        SMS_USER_DATA_MSG_ENCODING_KSC5601_KOREAN=                              0x10
+    }SMS_USER_DATA_MSG_ENCODING;
+
+
+    typedef enum
+    {
+        SMS_PRIORITY_INDICATOR_NORMAL=                                          0x00,
+        SMS_PRIORITY_INDICATOR_INTERACTIVE=                                     0x01,
+        SMS_PRIORITY_INDICATOR_URGENT=                                          0x02,
+        SMS_PRIORITY_INDICATOR_EMERGENCY=                                       0x03
+    }SMS_PRIORITY_INDICATOR_PRIORITY;
+
+
+
+    typedef enum
+    {
+        SMS_PRIVACY_INDICATOR_NOT_RESTRICTED=                                   0x00,
+        SMS_PRIVACY_INDICATOR_RESTRICTED=                                       0x01,
+        SMS_PRIVACY_INDICATOR_CONFIDENTIAL=                                     0x02,
+        SMS_PRIVACY_INDICATOR_SECRET=                                           0x03
+    }SMS_PRIVACY_INDICATOR_PRIVACY;
+
+
+
+    typedef enum
+    {
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_MOBILE_DEFAULT_ALERT=         0x00,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_LOW_PRIORITY_ALERT=           0x01,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_MEDIUM_PRIORITY_ALERT=        0x02,
+        SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY_HIGH_PRIORITY_ALERT=          0x03
+    }SMS_ALERT_MESSAGE_DELIVERY_ALERT_PRIORITY;
+
+
+
+    typedef enum
+    {
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_UNKNOWN=                                0x00,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_ENGLISH=                                0x01,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_FRENCH=                                 0x02,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_SPANISH=                                0x03,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_JAPANESE=                               0x04,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN=                                 0x05,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_CHINESE=                                0x06,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_HEBREW=                                 0x07,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN_1=                               0x40,
+        SMS_LANGUAGE_INDICATOR_LANGUAGE_KOREAN_SKT=                             0xFE
+    }SMS_LANGUAGE_INDICATOR_LANGUAGE;
+
+
+
+    typedef enum
+    {
+        SMS_MESSAGE_DISPLAY_MODE_IMMEDIATE_DISPLAY=                             0x00,
+        SMS_MESSAGE_DISPLAY_MODE_MOBILE_DEFAULT_SETTING=                        0x01,
+        SMS_MESSAGE_DISPLAY_MODE_USER_INVOKE=                                   0x03,
+        SMS_MESSAGE_DISPLAY_MODE_RESERVED=                                      0x04
+    }SMS_MESSAGE_DISPLAY_MODE;
+
+
+
+
+
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
+
+    // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++function prototype
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // _LXTSMSTYPEDEF_H_
diff --git a/vmodem/include/server/lxtutil.h b/vmodem/include/server/lxtutil.h
new file mode 100644 (file)
index 0000000..fed00d9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _LXTUTIL_H_
+#define _LXTUTIL_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void* lxt_util_malloc(int size);
+void lxt_util_free(void *p);
+int lxt_util_readRawBytes(int fd, void *data, int size);
+int lxt_util_writeRawBytes(int fd, void *data, int size);
+void lxt_util_rawdataPrint(void *rawdata, int rawdatasize, const char *title);
+int lxt_msg_send_to_server(int fd, void *data, int size);
+int lxt_msg_send_message(int fd, unsigned char g, unsigned char a, unsigned short len, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LXTUTIL_H_
diff --git a/vmodem/include/server/misc.h b/vmodem/include/server/misc.h
new file mode 100644 (file)
index 0000000..44cce0e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+//////////////////////////////////////////////////////////////////
+// misc.h
+*/
+
+#ifndef __PS_MISC_H__
+#define __PS_MISC_H__
+
+#include <linuxtapi.h>
+
+void TAPIMessageInit(LXT_MESSAGE *packet);
+void TAPIMessageFree(LXT_MESSAGE * packet);
+char const* printCurrentState(LXT_PHONE_STATE CurrentState);
+int packed_S32(unsigned char* bytearray);
+unsigned short packed_U16(unsigned char* bytearray);
+void PacketDataFree(void *p);
+int ReadBytes(int fd, void *data, int size);
+void* PacketDataMalloc(int size);
+int WriteBytes(int fd, void *data, int size);
+
+#endif /* __PS_MISC_H__ */
+
diff --git a/vmodem/include/server/phoneprotocol.h b/vmodem/include/server/phoneprotocol.h
new file mode 100644 (file)
index 0000000..475b268
--- /dev/null
@@ -0,0 +1,754 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _PHONEPROTOCOL_H_
+#define _PHONEPROTOCOL_H_
+
+
+// define of environment+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+// define of phone state+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    LXT_STATE_OFF                                                           = 0x01,
+    LXT_STATE_ON                                                            = 0x02,
+    LXT_STATE_UIM_NOT_READY                                                 = 0x03,
+    LXT_STATE_UIM_READY                                                     = 0x08,
+    LXT_STATE_NO_SERVICE                                                    = 0x10,
+    LXT_STATE_STANDBY                                                       = 0x20,
+    LXT_STATE_WAITING_OUTGOING_CALL                                         = 0x31,
+    LXT_STATE_WAITING_INCOMING_CALL                                         = 0x32,
+    LXT_STATE_WAITING_DATA_SERVICE                                          = 0x33,
+    LXT_STATE_CONVERSATION                                                  = 0x40,
+    LXT_STATE_DATA_SERVICED                                                 = 0x50,
+    LXT_STATE_DIAL_UP_DATA_SERVICED                                         = 0x55,
+    LXT_STATE_RELEASED                                                      = 0x60,
+    LXT_STATE_RESERVED                                                      = 0x1F
+
+} LXT_PHONE_STATE;
+
+
+// define of message cast method++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_MESSAGE_CAST_METHOD
+{
+    LXT_MESSAGE_CAST_METHOD_BY_MYSELF                                       = 0x40,  // ID of by me(comsumption by server)
+    LXT_MESSAGE_CAST_METHOD_BY_OWNER                                        = 0x41,  // ID of by owner(decide by server)
+    LXT_MESSAGE_CAST_METHOD_BROADCAST                                       = 0x42   // ID of all(broadcast by server)
+};
+
+
+// define of id+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    LXT_ID_CLIENT_RESERVED                                                  = 0x00, // ID of Reserved
+    LXT_ID_CLIENT_INDICATOR                                                 = 0x01, // ID of GUI Server
+    LXT_ID_CLIENT_PHONE                                                     = 0x02, // ID of Phone Client
+    LXT_ID_CLIENT_SMS                                                       = 0x03, // ID of SMS Client
+    LXT_ID_CLIENT_RUIM                                                      = 0x04, // ID of RUIM Manager
+    LXT_ID_CLIENT_SERVICEMODE                                               = 0x05, // ID of Service Mode
+    LXT_ID_CLIENT_DATASERVICE                                               = 0x06, // ID of Data service
+    LXT_ID_CLIENT_DIAL_ON_DEMAND                                            = 0x07, // ID of Dial on demand
+    LXT_ID_CLIENT_UTK                                                       = 0x08, // ID of UTK Client
+    LXT_ID_CLIENT_ADDRESS                                                   = 0x09, // ID of Address Book
+    LXT_ID_CLIENT_PHONE_SETUP                                               = 0x0A, // ID of Phone setup
+    LXT_ID_CLIENT_CARD_MANAGER                                              = 0x0B, // ID of CARD Manager
+    LXT_ID_CLIENT_SMS_DAEMON                                                = 0x0C, // ID of SMS Daemon
+    LXT_ID_CLIENT_GPS                                                       = 0x0D, // ID of GPS 
+    LXT_ID_CLIENT_SECURITY_SETUP                                            = 0x0E, // ID of Security Setup 
+    LXT_ID_CLIENT_SAT                                                                  = 0x0F, // ID of sim application toolkit 
+    LXT_ID_CLIENT_DATA_1                                                       = 0x10, // ID of data 1 
+    LXT_ID_CLIENT_DATA_2                                                       = 0x11, // ID of data 2 
+    LXT_ID_CLIENT_DATA_3                                                       = 0x12, // ID of data 3 
+    LXT_ID_CLIENT_DATA_4                                                       = 0x13, // ID of data 4 
+    LXT_ID_CLIENT_DATA_5                                                       = 0x14, // ID of data 5 
+    LXT_ID_CLIENT_DATA_6                                                       = 0x15, // ID of data 6
+    LXT_ID_CLIENT_EVENT_INJECTOR                                           = 0x16, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER_RX                                         = 0x17, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER_TX                                         = 0x18, //ID of event injector 
+    LXT_ID_CLIENT_EVENT_MANAGER                                            = 0x19, //ID of event manager
+    LXT_ID_CLIENT_INVALID                                                   = 0x39, // ID of invalid
+    LXT_ID_CLIENT_ANY                                                       = 0xff
+}
+LXT_ID_CLIENT;
+
+
+
+
+
+// define of main group+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_GRP
+{
+    LXT_GRP_INTERNAL                                                        = 0x40,  // Internal
+    LXT_GRP_POWER                                                           = 0x51,  // power
+    LXT_GRP_CONFIGURATION                                                   = 0x52,  // configuration
+    LXT_GRP_CALL                                                            = 0x53,  // call
+    LXT_GRP_DISPLAY                                                         = 0x54,  // display
+    LXT_GRP_SMS                                                             = 0x55,  // sms
+    LXT_GRP_SERVICEMODE                                                     = 0x56,  // service mode
+    LXT_GRP_SOUND                                                           = 0x57,  // sound
+    LXT_GRP_UIM                                                             = 0x58,  // UIM
+    LXT_GRP_DATASERVICE                                                     = 0x59,  // Data service
+    LXT_GRP_UTK                                                             = 0x5A,  // UTK
+    LXT_GRP_SIOMODE                                                         = 0x5B,  // SIO Mode
+    LXT_GRP_RESPONSE                                                        = 0x5F,  // response
+    LXT_GRP_PHONE_BOOK                                                      = 0x61,  // phone book
+    LXT_GRP_CARD_SMS                                                        = 0x62,  // card sms
+    LXT_GRP_GPS                                                             = 0x63,  // GPS 
+    LXT_GRP_EOT                                                             = 0x80   // eot
+    
+};
+
+
+// define of ppp status +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+typedef enum
+{
+    PPP_STATUS_IDLE                         = 0x01,
+    PPP_STATUS_WORKING                      = 0x02,
+    PPP_STATUS_BUSY                         = 0x04,
+    PPP_STATUS_DORMANT                      = 0x05,
+    PPP_STATUS_SUPER                        = 0x06,
+    PPP_EVENT_IP_REASSIGNED                 = 0x10
+
+}
+PPP_STATUS;
+
+// define of action group (client info)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CLIENT_INFO
+{
+    LXT_PDA_INTERNAL_ID_REQUEST                                             = 0x41,   // save id
+    LXT_PDA_INTERNAL_STATE_REQUEST                                          = 0x42,
+    LXT_PDA_INTERNAL_PHONE_NUMBER_REQUEST                                   = 0x43,
+    LXT_PDA_INTERNAL_AUDIO_TO_SPEAKER_REQUEST                               = 0x44,
+    LXT_PDA_INTERNAL_AUDIO_TO_RECEIVER_REQUEST                              = 0x45,
+    LXT_PDA_INTERNAL_FACTORY_MODE_REQUEST                                   = 0x46,
+    LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST                                 = 0x47,
+    LXT_PDA_INTERNAL_SEND_RAWDATA_REQUEST                                   = 0x50,
+    LXT_PDA_INTERNAL_LOOP_BACK_REQEUST                                      = 0x51,
+    LXT_PHN_INTERNAL_NOTIFY_PHONEBOOK_LOADING_COMPLETION_REQUEST            = 0x52,
+    LXT_PHN_INTERNAL_PHONEBOOK_LOADING_COMPLETION_STATUS_REQUEST            = 0x53,
+    LXT_PHN_INTERNAL_BACKUP_BATTERY_CONTROL_REQUEST                         = 0x55,
+    LXT_PHN_INTERNAL_EARJACK_STATUS_REQUEST                                 = 0x56,
+    LXT_PDA_INTERNAL_LAUNCH_SAT_APP_REQUEST                                                                    = 0x57,
+    LXT_PDA_INTERNAL_SETUP_SAT_APP_REQUEST                                                                     = 0x58,
+    LXT_PDA_INTERNAL_PHONE_BATTERY_REQUEST                                                                     = 0x59,
+};
+
+enum LXT_PHN_PHONE_INFO
+{
+    LXT_PHN_INTERNAL_STATE_RESPONSE                                         = 0x42,   // state change
+    LXT_PHN_INTERNAL_STATE_CHANGE_NOTIFICATION                              = 0x43,   // state change
+    LXT_PHN_INTERNAL_PHONE_NUMBER_RESPONSE                                  = 0x44,
+    LXT_PHN_INTERNAL_PDA_SLEEP_NOTIFICATION                                 = 0x45,
+    LXT_PHN_INTERNAL_SERVER_DIE_EMERGENCY                                   = 0x49,
+    LXT_PHN_INTERNAL_SERVER_SIM_COVER_OPENED                                = 0x50,
+    LXT_PHN_INTERNAL_SERVER_SIM_COVER_CLOSED                                = 0x51,
+    LXT_PHN_INTERNAL_SERVER_PHONE_REBUILD_START                             = 0x52,
+    LXT_PHN_INTERNAL_SERVER_PHONE_REBUILD_END                               = 0x53,                
+    LXT_PHN_INTERNAL_SERVER_PHONE_FATAL_ERROR                               = 0x54,
+    LXT_PHN_INTERNAL_SERVER_PHONE_NV_BACKUP_NOTIFICATION                    = 0x55,
+    LXT_PHN_INTERNAL_PHONEBOOK_LOADING_COMPLETION_NOTIFICATION              = 0x56,
+    LXT_PHN_INTERNAL_EARJACK_STATUS_RESPONSE                                = 0x57,
+    LXT_PDA_INTERNAL_LAUNCH_SAT_APP_RESPONSE                                                           = 0x58,
+    LXT_PDA_INTERNAL_SETUP_SAT_APP_RESPONSE                                                                = 0x59,
+};
+
+// define of action group (power)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_POWER
+{
+    LXT_PDA_POWER_ON_REQUEST                                                = 0x41,  // power on
+    LXT_PDA_POWER_RESET_REQUEST                                             = 0x42,  // power reset
+    LXT_PDA_POWER_OFF_REQUEST                                               = 0x43   // power off
+
+};
+
+enum LXT_PHN_POWER
+{
+    LXT_PHN_POWER_BATTERY_STATUS_NOTIFICATION                               = 0x41,
+    LXT_PHN_POWER_PHONE_BOOT_COMPLETED_NOTIFICATION                         = 0x42
+};
+
+
+// define of action group (configuration)+++++++++++++++++++++++++++++++++++++
+/*
+enum LXT_PDA_CONFIGURATION
+{
+    LXT_PDA_CONFIGURATION_SET_DEFAULT_CONFIGURATION_REQUEST                 = 0x41,
+    LXT_PDA_CONFIGURATION_CURRENT_TIME_REQUEST                              = 0x42,  // current time request
+    LXT_PDA_CONFIGURATION_PHONE_NUMBER_REQUEST                              = 0x43,
+    LXT_PDA_CONFIGURATION_PHONE_VERSION_REQUEST                             = 0x44,
+    LXT_PDA_CONFIGURATION_GET_PHONE_LOCK_REQUEST                            = 0x45,
+    LXT_PDA_CONFIGURATION_SET_PHONE_LOCK_REQUEST                            = 0x46,
+    LXT_PDA_CONFIGURATION_GET_RADIO_CONFIGURATION_REQUEST                   = 0x47,
+    LXT_PDA_CONFIGURATION_SET_RADIO_CONFIGURATION_REQUEST                   = 0x48,
+    LXT_PDA_CONFIGURATION_GET_SYSTEM_PREFERENCE_REQUEST                     = 0x49,
+    LXT_PDA_CONFIGURATION_SET_SYSTEM_PREFERENCE_REQUEST                     = 0x4A,
+    LXT_PDA_CONFIGURATION_GET_SYSTEM_PARAMETER_REQUEST                      = 0x4B,
+    LXT_PDA_CONFIGURATION_SET_SYSTEM_PARAMETER_REQUEST                      = 0x4C,
+    LXT_PDA_CONFIGURATION_GET_NAM_INFORMATION_REQUEST                       = 0x4D,
+    LXT_PDA_CONFIGURATION_GET_NAM_DATA_REQUEST                              = 0x4E,
+    LXT_PDA_CONFIGURATION_GET_PHONE_STATE_CHANGING_REQUEST                  = 0x4F,
+    LXT_PDA_CONFIGURATION_SET_PHONE_STATE_CHANGING_REQUEST                  = 0x50,
+    LXT_PDA_CONFIGURATION_BATTERY_MEDIATENESS_CONFIRM                       = 0x51,
+    LXT_PDA_CONFIGURATION_GET_PDA_BATTERY_REQUEST                           = 0x52
+};
+
+enum LXT_PHN_CONFIGURATION
+{
+    LXT_PHN_CONFIGURATION_SET_DEFAULT_CONFIGURATION_RESPONSE                = 0x41,
+    LXT_PHN_CONFIGURATION_CURRENT_TIME_RESPONSE                             = 0x42,
+    LXT_PHN_CONFIGURATION_CURRENT_TIME_NOTIFICATION                         = 0x43,
+    LXT_PHN_CONFIGURATION_PHONE_NUMBER_RESPONSE                             = 0x44,
+    LXT_PHN_CONFIGURATION_PHONE_VERSION_RESPONSE                            = 0x45,
+    LXT_PHN_CONFIGURATION_PHONE_STATE_CHANGE_NOTIFICATION                   = 0x46,
+    LXT_PHN_CONFIGURATION_PHONE_SERVICE_READY_NOTIFICATION                  = 0x47,
+    LXT_PHN_CONFIGURATION_GET_PHONE_LOCK_RESPONSE                           = 0x48,
+    LXT_PHN_CONFIGURATION_PHONE_LOCK_NOTIFICATION                           = 0x49,
+    LXT_PHN_CONFIGURATION_GET_RADIO_CONFIGURATION_RESPONSE                  = 0x4A,
+    LXT_PHN_CONFIGURATION_GET_SYSTEM_PREFERENCE_RESPONSE                    = 0x4B,
+    LXT_PHN_CONFIGURATION_GET_SYSTEM_PARAMETER_RESPONSE                     = 0x4C,
+    LXT_PHN_CONFIGURATION_SYSTEM_PARAMETER_CHANGE_NOTIFICATION              = 0x4D,
+    LXT_PHN_CONFIGURATION_GET_NAM_INFORMATION_RESPONSE                      = 0x4E,
+    LXT_PHN_CONFIGURATION_GET_NAM_DATA_RESPONSE                             = 0x4F,
+    LXT_PHN_CONFIGURATION_GET_PHONE_STATE_CHANGING_RESPONSE                 = 0x50,
+    LXT_PHN_CONFIGURATION_SET_PHONE_STATE_CHANGING_RESPONSE                 = 0x51,
+    LXT_PHN_CONFIGURATION_HFK2_PDA_PASSWORD_INDICATION                      = 0x52,
+    LXT_PHN_CONFIGURATION_BATTERY_MEDIATENESS_INDICATION                    = 0x53,
+    LXT_PHN_CONFIGURATION_GET_PDA_BATTERY_RESPONSE                          = 0x54
+};
+*/
+
+enum LXT_PDA_CONFIGURATION2
+{
+    LXT_PDA_CONFIGURATION2_GET_PHONE_LOCK_REQUEST                           = 0x40,
+    LXT_PDA_CONFIGURATION2_SET_PHONE_LOCK_REQUEST                           = 0x41,
+    LXT_PDA_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_REQUEST                = 0x42,
+    LXT_PDA_CONFIGURATION2_GET_SIO_MODE_REQUEST                             = 0x43,
+    LXT_PDA_CONFIGURATION2_SET_SIO_MODE_REQUEST                             = 0x44,
+    LXT_PDA_CONFIGURATION2_CURRENT_TIME_REQUEST                             = 0x45,
+    LXT_PDA_CONFIGURATION2_PHONE_NUMBER_REQUEST                             = 0x46,
+    LXT_PDA_CONFIGURATION2_PHONE_VERSION_REQUEST                            = 0x47,
+    LXT_PDA_CONFIGURATION2_GET_SYSTEM_PARAMETER_REQUEST                     = 0x48,
+    LXT_PDA_CONFIGURATION2_SET_SYSTEM_PARAMETER_REQUEST                     = 0x49,
+    LXT_PDA_CONFIGURATION2_GET_MODE_PREFERENCE_REQUEST                      = 0x4A,
+    LXT_PDA_CONFIGURATION2_SET_MODE_PREFERENCE_REQUEST                      = 0x4B,
+    LXT_PDA_CONFIGURATION2_GET_SYSTEM_PREFERENCE_REQUEST                    = 0x4C,
+    LXT_PDA_CONFIGURATION2_SET_SYSTEM_PREFERENCE_REQUEST                    = 0x4D,
+    LXT_PDA_CONFIGURATION2_GET_NAM_INFORMATION_REQUEST                      = 0x4E,
+    LXT_PDA_CONFIGURATION2_GET_NAM_DATA_REQUEST                             = 0x4F,
+    LXT_PDA_CONFIGURATION2_GET_PHONE_STATE_CHANGING_REQUEST                 = 0x50,
+    LXT_PDA_CONFIGURATION2_SET_PHONE_STATE_CHANGING_REQUEST                 = 0x51,
+    LXT_PDA_CONFIGURATION2_GET_GPS_MODE_REQUEST                             = 0x52,
+    LXT_PDA_CONFIGURATION2_SET_GPS_MODE_REQUEST                             = 0x53,
+    LXT_PDA_CONFIGURATION2_GET_RADIO_CONFIGURATION_REQUEST                  = 0x54,
+    LXT_PDA_CONFIGURATION2_SET_RADIO_CONFIGURATION_REQUEST                  = 0x55,
+    LXT_PDA_CONFIGURATION2_GET_VOCODER_OPTION_REQUEST                       = 0x56,
+    LXT_PDA_CONFIGURATION2_SET_VOCODER_OPTION_REQUEST                       = 0x57,
+    LXT_PDA_CONFIGURATION2_BATTERY_TYPE_CONFIRM                             = 0x58,
+    LXT_PDA_CONFIGURATION2_BATTERY_CALIBRATION_CONFIRM                      = 0x59,
+    LXT_PDA_CONFIGURATION2_GET_SLOT_MODE_REQUEST                            = 0x5A,
+    LXT_PDA_CONFIGURATION2_SET_SLOT_MODE_REQUEST                            = 0x5B,
+    LXT_PDA_CONFIGURATION2_GET_ESN_REQUEST                                  = 0x5C,
+    LXT_PDA_CONFIGURATION2_PDA_CURR_BATT_ADC_CONFIRM                        = 0x5D,
+    LXT_PDA_CONFIGURATION2_GET_PDA_LOW_BATT_ADC_REQUEST                     = 0x5E,
+    LXT_PDA_CONFIGURATION2_SET_PDA_LOW_BATT_ADC_REQUEST                     = 0x5F,
+    LXT_PDA_CONFIGURATION2_MAC_ADDRESS_REQUEST                              = 0x60,
+    LXT_PDA_CONFIGURATION2_GET_IMEI_REQUEST                                 = 0x61,
+    LXT_PDA_CONFIGURATION2_PDA_VERIFY_RESET_DONE_CONFIRM                    = 0x62,
+    LXT_PHN_CONFIGURATION2_PDA_PASSWORD_CONFIRM                             = 0x63,
+    LXT_PHN_CONFIGURATION2_DEVICE_AUTO_TEST_CONFIRM                             = 0x64,
+    LXT_PHN_CONFIGURATION2_SERVICE_LED_ONOFF_CONFIRM                        = 0x65,
+    LXT_PHN_CONFIGURATION2_SET_PDA_VERSION_REQUEST                          = 0x66
+    /*
+    LXT_PDA_CONFIGURATION2_BATTRY_MEDIATENESS_CONFIRM                      = 0x51,
+    LXT_PDA_CONFIGURATION2_GET_PDA_BATTERY_REQUEST                          = 0x52
+    */
+};
+
+enum LXT_PHN_CONFIGURATION2
+{
+    LXT_PHN_CONFIGURATION2_PHONE_SERVICE_READY_NOTIFICATION                 = 0x40,
+    LXT_PHN_CONFIGURATION2_PHONE_LOCK_RESPONSE                              = 0x41,
+    LXT_PHN_CONFIGURATION2_PHONE_LOCK_NOTIFICATION                          = 0x42,
+    LXT_PHN_CONFIGURATION2_CURRENT_TIME_RESPONSE                            = 0x43,
+    LXT_PHN_CONFIGURATION2_CURRENT_TIME_NOTIFICATION                        = 0x44,
+    LXT_PHN_CONFIGURATION2_PHONE_NUMBER_RESPONSE                            = 0x45,
+    LXT_PHN_CONFIGURATION2_PHONE_VERSION_RESPONSE                           = 0x46,
+    LXT_PHN_CONFIGURATION2_GET_NAM_INFORMATION_RESPONSE                     = 0x47,
+    LXT_PHN_CONFIGURATION2_GET_NAM_DATA_RESPONSE                            = 0x48,
+    LXT_PHN_CONFIGURATION2_PHONE_STATE_CHANGED_RESPONSE                     = 0x49,
+    LXT_PHN_CONFIGURATION2_PHONE_STATE_CHANGED_NOTIFICATION                 = 0x4A,
+    LXT_PHN_CONFIGURATION2_MODE_PREFERENCE_RESPONSE                         = 0x4B,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PREFERENCE_RESPONSE                       = 0x4C,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PARAMETER_RESPONSE                        = 0x4D,
+    LXT_PHN_CONFIGURATION2_SYSTEM_PARAMETER_CHANGE_NOTIFICATION             = 0x4E,
+    LXT_PHN_CONFIGURATION2_SIO_MODE_RESPONSE                                = 0x4F,
+    LXT_PHN_CONFIGURATION2_GET_GPS_MODE_RESPONSE                            = 0x50,
+    LXT_PHN_CONFIGURATION2_GET_RADIO_CONFIGURATION_RESPONSE                 = 0x51,
+    LXT_PHN_CONFIGURATION2_GET_VOCODER_OPTION_RESPONSE                      = 0x52,
+    LXT_PHN_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_RESPONSE               = 0x53,
+    LXT_PHN_CONFIGURATION2_BATTERY_TYPE_INDICATION                          = 0x54,
+    LXT_PHN_CONFIGURATION2_BATTERY_CALIBRATION_INDICATION                   = 0x55,
+    LXT_PHN_CONFIGURATION2_BATTERY_CALIBRATION_NOTIFICATION                 = 0x56,
+    LXT_PHN_CONFIGURATION2_BATTERY_WRITE_CALIBRATION_NOTIFICATION           = 0x57,
+    LXT_PHN_CONFIGURATION2_GET_SLOT_MODE_RESPONSE                           = 0x58,
+    LXT_PDA_CONFIGURATION2_GET_ESN_RESPONSE                                 = 0x59,
+    LXT_PHN_CONFIGURATION2_PDA_CURR_BATT_ADC_INDICATION                     = 0x5A,
+    LXT_PHN_CONFIGURATION2_GET_PDA_LOW_BATT_ADC_RESPONSE                    = 0x5B,
+    LXT_PHN_CONFIGURATION2_PDA_DEVICE_AUT_TEST_INDICATION                   = 0x5C,
+    LXT_PHN_CONFIGURATION2_MAC_ADDRESS_RESPONSE                             = 0x5D,
+    LXT_PHN_CONFIGURATION2_GET_IMEI_RESPONSE                                = 0x5E,
+    LXT_PHN_CONFIGURATION2_SET_DEFAULT_CONFIGURATION_INDICATION             = 0x5F,
+    LXT_PHN_CONFIGURATION2_PDA_PASSWORD_INDICATION                          = 0x60,
+    LXT_PHN_CONFIGURATION2_BT_EQUIPMENT_TEST_ADDRESS_NOTIFICATION           = 0x61
+    /*
+    LXT_PHN_CONFIGURATION2_BATTERY_MEDIATENESS_INDICATION                   = 0x53,
+    LXT_PHN_CONFIGURATION2_GET_PDA_BATTERY_RESPONSE                         = 0x54
+    */
+};
+
+// define of action group (call)++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CALL
+{
+    LXT_PDA_CALL_CALL_ORIGINATION_REQUEST                                   = 0x41, // call originnation
+    LXT_PDA_CALL_END_CALL_REQUEST                                           = 0x42, // end call
+    LXT_PDA_CALL_ANSWER_REQUEST                                             = 0x43, // call answer
+    LXT_PDA_CALL_SEND_BURST_DTMF_REQUEST                                    = 0x44,
+    LXT_PDA_CALL_SEND_CONTINUOUS_DTMF_REQUEST                               = 0x45,
+    LXT_PDA_CALL_STOP_CONTINUOUS_DTMF_REQUEST                               = 0x46,
+    LXT_PDA_CALL_FLASH_INFORMATION_REQUEST                                  = 0x47,
+    LXT_PDA_CALL_GET_CALL_TIME_REQUEST                                      = 0x4E,
+    LXT_PDA_CALL_SET_E911_NUMBER_REGISTRATION_REQUEST                       = 0x4F,
+    LXT_PDA_CALL_RETRY_REQUEST                                              = 0x50,
+    LXT_PDA_CALL_CALL_ORIGINATION2_REQUEST                                  = 0x51,
+    LXT_PDA_CALL_GET_VOICE_PRIVACY_OPTION_REQUEST                           = 0x52,
+    LXT_PDA_CALL_SET_VOICE_PRIVACY_OPTION_REQUEST                           = 0x53,
+    LXT_PDA_CALL_CURRENT_VOICE_PRIVACY_STATUS_REQUEST                       = 0x54,    
+    LXT_PDA_CALL_SOS_CALL_REQUEST                                           = 0x55,
+    LXT_PDA_CALL_REJECT_CALL_REQUEST                                        = 0x56    
+};
+
+enum LXT_PHN_CALL
+{
+    LXT_PHN_CALL_INCOMING_CALL_NOTIFICATION                                 = 0x41,
+    LXT_PHN_CALL_CALL_STATUS_NOTIFICATION                                   = 0x42,
+    LXT_PHN_CALL_SEND_BURST_DTMF_TONE_NOTIFICATION                          = 0x43,
+    LXT_PHN_CALL_START_END_ALERT_INFORMATION_NOTIFICATION                   = 0x44,
+    LXT_PHN_CALL_ALERT_INFORMATION_NOTIFICATION                             = 0x45,
+    LXT_PHN_CALL_SIGNALING_INFORMATION_NOTIFICATION                         = 0x46,
+    LXT_PHN_CALL_OTA_STATE_CHANGE_NOTIFICATION                              = 0x47,
+    LXT_PHN_CALL_IOTA_PROCESSING_RESPONSE                                   = 0x48,
+    LXT_PHN_CALL_VOICE_PRIVACY_OPTION_RESPONSE                              = 0x49,
+    LXT_PHN_CALL_CURRENT_VOICE_PRIVACY_AVAIABLE_STATUS_RESPONSE             = 0x4A,
+    LXT_PHN_CALL_VOICE_PRIVACY_SERVICED_NOTIFICATION                        = 0x4B,
+    LXT_PHN_CALL_CURRENT_CALL_INFORMATION_RESPONSE                          = 0x4C,
+    LXT_PHN_CALL_DIAGNOSTIC_CALL_ORIGINATION_NOTIFICATION                   = 0x4D,
+    LXT_PHN_CALL_GET_CALL_TIME_RESPONSE                                     = 0x4E
+
+
+
+
+
+};
+
+// define of action group (display)+++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_DISPLAY
+{
+    LXT_PDA_DISPLAY_RING_TYPE_ICON_REQUEST                                  = 0x41,
+    LXT_PDA_DISPLAY_ICON_REQUEST                                            = 0x47,
+    LXT_PDA_DISPLAY_MISSED_ICON_CHANGED                                     = 0x48,
+};
+
+enum LXT_PHN_DISPLAY
+{
+
+    LXT_PHN_DISPLAY_RING_TYPE_ICON_NOTIFICATION                             = 0x41,
+    LXT_PHN_DISPLAY_PHONE_ICON_CHANGED_NOTIFICATION                         = 0x42,
+    LXT_PHN_DISPLAY_RSSI_ICON_CHANGED_NOTIFICATION                          = 0x43,
+    LXT_PHN_DISPLAY_ROAM_ICON_CHANGED_NOTIFICATION                          = 0x44,
+    LXT_PHN_DISPLAY_BATTERY_ICON_CHANGED_NOTIFICATION                       = 0x45,
+    LXT_PHN_DISPLAY_MESSAGE_ICON_CHANGED_NOTIFICATION                       = 0x46,
+    LXT_PHN_DISPLAY_ICON_RESPONSE                                           = 0x47,
+    LXT_PHN_DISPLAY_MISSED_ICON_NOTIFICATION                                = 0x48,
+
+};
+
+
+// define of action group (sms)+++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SMS
+{
+    LXT_PDA_SMS_SMS_SEND_MESSAGE_REQUEST                                    = 0x41,
+    LXT_PDA_SMS_SMS_SET_LOCAL_COUNT_INDICATION                              = 0x42,
+    LXT_PDA_SMS_SMS_GET_LOCAL_STORAGE_SIZE_REQUEST                          = 0x43,
+    LXT_PDA_SMS_SMS_SET_LOCAL_STORAGE_SIZE_INDICATION                       = 0x44
+};
+
+enum LXT_PHN_SMS
+{
+    // CDMA
+    LXT_PHN_SMS_PHONE_SMS_INCOMING_NOTIFICATION                             = 0x41,
+    LXT_PHN_SMS_PHONE_UIM_SMS_INCOMING_NOTIFICATION                         = 0x42,
+    LXT_PHN_SMS_PHONE_WAP_SMS_INCOMING_NOTIFICATION                         = 0x43,
+    LXT_PHN_SMS_PHONE_VOICE_SMS_INCOMING_NOTIFICATION                       = 0x44,
+    LXT_PHN_SMS_PHONE_SMS_INCOMING_ALERT_NOTIFICATION                       = 0x45,
+    LXT_PHN_SMS_PHONE_SMS_ACKNOWLEDGMENT_MESSAGE_NOTIFICATON                = 0x46,
+    LXT_PHN_SMS_PHONE_SMS_MESSAGE_COUNT_NOTIFICATON                         = 0x47,
+    LXT_PHN_SMS_PHONE_SMS_LOCAL_STORAGE_SIZE_RESPONSE                       = 0x48,
+    LXT_PHN_SMS_PHONE_SMS_DELIVERY_ACKNOWLEDGMENT_NOTIFICATION              = 0x49,
+    LXT_PHN_SMS_PHONE_SMS_REJECT_NOTIFICATION                               = 0x4A,
+    // GSM
+    LXT_PHN_SMS_PHONE_GSM_SMS_DELIVER_NOTIFICATION                          = 0x51,
+    LXT_PHN_SMS_PHONE_GSM_SMS_STATUS_REPORT_NOTIFICATION                    = 0x52,
+    LXT_PHN_SMS_PHONE_GSM_SMS_SUBMIT_REPORT_NOTIFICATION                    = 0x53,
+    LXT_PHN_SMS_PHONE_GSM_SMS_SMMA_NOTIFICATION                             = 0x54,
+    LXT_PHN_SMS_PHONE_EOT
+};
+
+
+// define of action group (sms)+++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_CARD_SMS
+{
+    LXT_PDA_CARD_SMS_EOT
+};
+
+enum LXT_PHN_CARD_SMS
+{
+    // CDMA
+    LXT_PHN_CARD_SMS_INFORMATION_RESPONSE                                   = 0x41,
+    LXT_PHN_CARD_SMS_READ_RESPONSE                                          = 0x42,
+    LXT_PHN_CARD_SMS_WRITE_RESPONSE                                         = 0x43,
+    LXT_PHN_CARD_SMS_DELETE_RESPONSE                                        = 0x44,
+    LXT_PHN_CARD_SMS_SET_TAG_RESPONSE                                       = 0x45,
+    LXT_PHN_CARD_SMS_CLEAR_RESPONSE                                         = 0x46,
+    LXT_PHN_CARD_SMS_MESSAGE_READY_NOTIFICATION                             = 0x47,    
+    LXT_PHN_CARD_SMS_COMPLETE_NOTIFICATION                                  = 0x48,
+
+    // GSM
+    LXT_PHN_CARD_GSM_SMS_INFORMATION_RESPONSE                               = 0x61,
+    LXT_PHN_CARD_GSM_SMS_READ_RESPONSE                                      = 0x62,
+    LXT_PHN_CARD_GSM_SMS_WRITE_RESPONSE                                     = 0x63,
+    LXT_PHN_CARD_GSM_SMS_DELETE_RESPONSE                                    = 0x64,
+    LXT_PHN_CARD_GSM_SMS_SET_TAG_RESPONSE                                   = 0x65,
+    LXT_PHN_CARD_GSM_SMS_CLEAR_RESPONSE                                     = 0x66,
+    LXT_PHN_CARD_GSM_SMS_COMPLETE_NOTIFICATION                              = 0x67,
+    LXT_PHN_CARD_GSM_SMS_PARAMETER_READ_RESPONSE                            = 0x68,
+    LXT_PHN_CARD_GSM_SMS_PARAMETER_WRITE_RESPONSE                           = 0x69,
+    LXT_PHN_CARD_GSM_SMS_MESSAGE_REFERENCE_WRITE_RESPONSE                   = 0x6A,
+};
+
+    
+// define of action group (service mode)++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PDA_SERVICEMODE
+{
+    LXT_PDA_SERVICEMODE_ENTER_SERVICE_MODE_REQUEST                          = 0x41,
+    LXT_PDA_SERVICEMODE_END_SERVICE_MODE_REQUEST                            = 0x42,
+    LXT_PDA_SERVICEMODE_PROCESS_KEY_CODE_REQUEST                            = 0x43,
+    LXT_PDA_SERVICEMODE_FACTORY_MODE_ENABLE_REQUEST                         = 0x44
+};
+
+
+enum LXT_PHN_SERVICEMODE
+{
+    LXT_PHN_SERVICEMODE_END_SERVICE_MODE_NOTIFICATION                       = 0x41,
+    LXT_PHN_SERVICEMODE_DISPLAY_MONITOR_NOTIFICATION                        = 0x42,
+    LXT_PHN_SERVICEMODE_PHONE_LCD_MODE_NOTIFICATION                         = 0x43,
+    LXT_PHN_SERVICEMODE_DISPLAY_PHONE_LCD_NOTIFICATION                      = 0x44,
+    LXT_PHN_SERVICEMODE_DEDICATE_LCD_MODE_NOTIFICATION                      = 0x45,
+
+
+    LXT_PHN_SERVICEMODE_DISPLAY_DEDICATE_LCD_NOTIFICATION                   = 0x46,
+    LXT_PHN_SERVICEMODE_DOWNLOAD_TYPE_NOTIFICATION                          = 0x47,
+    LXT_PDA_SERVICEMODE_FACTORY_MODE_ENABLE_RESPONSE                        = 0x48
+};
+
+// define of action group (sound)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SOUND
+{
+    LXT_PDA_SOUND_START_KEY_TONE_REQUEST                                    = 0x41,
+    LXT_PDA_SOUND_STOP_KEY_TONE_REQUEST                                     = 0x42,
+    LXT_PDA_SOUND_START_NOTIFICATION_TONE_REQUEST                           = 0x43,
+    LXT_PDA_SOUND_START_LAMP_REQUEST                                        = 0x44,
+    LXT_PDA_SOUND_START_VIBRATE_REQUEST                                     = 0x45,
+    LXT_PDA_SOUND_STOP_SOUND_REQUEST                                        = 0x47,
+    LXT_PDA_SOUND_SET_VOLUME_CONTROL_REQUEST                                = 0x48,
+    LXT_PDA_SOUND_SET_MUTE_REQUEST                                          = 0x49,
+    LXT_PDA_SOUND_GET_MUTING_STATUS_REQUEST                                 = 0x4A,
+    LXT_PDA_SOUND_SET_SPEAKER_PHONE_REQUEST                                 = 0x4B,
+    LXT_PDA_SOUND_SET_AUDIO_PATH_CONTROL_REQUEST                            = 0x4C
+};
+
+enum LXT_PHN_SOUND
+{
+    LXT_PHN_SOUND_MUTING_STATUS_RESPONSE                                    = 0x41,
+    LXT_PHN_SOUND_SOUND_PDA_PATH_ON_OFF_NOTIFICATION                        = 0x42
+};
+
+
+
+
+// define of action group (UIM) ++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_UIM
+{
+
+    // i819
+    LXT_PDA_RUIMCONF_AUTHENTICATION_REQUEST                                 = 0x11,
+    LXT_PDA_RUIMCONF_SELECT_NETWORK_REQUEST                                 = 0x12,
+    LXT_PDA_RUIMCONF_ICCID_REQUEST                                          = 0x13,
+    LXT_PDA_RUIMCONF_SELECTION_MODE_REQUEST                                 = 0x14,
+    LXT_PDA_RUIMCONF_CHANGE_AUTHENTICATION_REQUEST                          = 0x15,
+    LXT_PDA_RUIMCONF_CURRENT_PIN_CHECK_STATE_REQUEST                        = 0x16,
+    LXT_PDA_RUIMCONF_CHANGE_PIN_CHECK_STATE_REQUEST                         = 0x17,
+    LXT_PDA_RUIMCONF_RUNTIME_CHANGE_NETWORK_REQUEST                         = 0x18,
+    LXT_PDA_RUIMCONF_DIR_NAME_REQUEST                                       = 0x19,
+    LXT_PDA_RUIMCONF_DIR_NAME_WRITE_REQUEST                                 = 0x1A,
+    LXT_PDA_RUIMCONF_CHANGE_FDN_STATE_REQUEST                               = 0x1B,
+    LXT_PDA_RUIMCONF_CURRENT_FDN_STATE_REQUEST                              = 0x1C,
+    LXT_PDA_RUIMCONF_CHECK_SERVICE_AVAILABLE_REQUEST                        = 0x1D,
+    LXT_PDA_RUIMCONF_IMSI_REQUEST                                           = 0x1E,
+    
+    // i519
+    LXT_PDA_UIM_GET_UIM_LOCK_REQUEST                                        = 0x31,
+    LXT_PDA_UIM_SET_UIM_LOCK_REQUEST                                        = 0x32,
+    LXT_PDA_UIM_UIM_LOCK_VERIFY_INDICATION                                  = 0x33,
+    LXT_PDA_UIM_UIM_LOCK_PASSWORD_WRITE_REQUEST                             = 0x34,
+    LXT_PDA_UIM_CARD_STATUS_REQUEST                                         = 0x41,
+    LXT_PDA_UIM_GET_PIN_CODE_STATUS_REQUEST                                 = 0x42,
+    LXT_PDA_UIM_SET_PIN_CHECK_REQUEST                                       = 0x43,
+    LXT_PDA_UIM_RUIM_PIN_VERIFY_REQUEST                                     = 0x44,
+    LXT_PDA_UIM_CHANGE_PIN_REQUEST                                          = 0x45,
+    LXT_PDA_UIM_GET_ICCID_REQUEST                                           = 0x46,
+    LXT_PDA_UIM_CHV_UNLOCK_REQUEST                                          = 0x47,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_INFORMATION_REQUEST                    = 0x51,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_READ_REQUEST                           = 0x52,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_WRITE_REQUEST                          = 0x53,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_ERASE_REQUEST                          = 0x54,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_CLEAR_REQUEST                          = 0x55,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_ALL_LIST_REQUEST                       = 0x56,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_MIRRORING_REQUEST                      = 0x57,
+    LXT_PDA_UIM_PDA_CARD_SMS_MESSAGE_SET_TAG_REQUEST                        = 0x58,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_INFORMATION_REQUEST                     = 0x61,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_READ_REQUEST                            = 0x62,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_WRITE_REQUEST                           = 0x63,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_ERASE_REQUEST                           = 0x64,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_CLEAR_REQUEST                           = 0x65,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_ALL_LIST_REQUEST                        = 0x66,
+    LXT_PDA_UIM_PDA_CARD_PHONE_BOOK_MIRRORING_REQUEST                       = 0x67,
+    LXT_PDA_UIM_DIR_NAME_READ_REQUEST                                       = 0x68,
+    LXT_PDA_UIM_DIR_NAME_WRITE_REQUEST                                      = 0x69,
+    LXT_PDA_UIM_PDA_CARD_SMS_CLEAR_REQUEST                                  = 0x70,
+    LXT_PDA_UIM_GET_PERMISSION_STATUS_REQUEST                               = 0x80
+};
+
+enum LXT_PHN_UIM
+{
+
+    // i819
+    LXT_PHN_RUIMCONF_STATUS_NOTIFICATION                                    = 0x11,
+    LXT_PHN_RUIMCONF_BLOCK_STATUS_NOTIFICATION                              = 0x12,
+    LXT_PHN_RUIMCONF_AUTHENTICATION_RESPONSE                                = 0x13,
+    LXT_PHN_RUIMCONF_CARD_STATUS_NOTIFICATION                               = 0x14,
+    LXT_PHN_RUIMCONF_SELECT_NETWORK_RESPONSE                                = 0x15,
+    LXT_PHN_RUIMCONF_SELECTION_MODE_NOTIFICATION                            = 0x16,
+    LXT_PHN_RUIMCONF_ICCID_RESPONSE                                         = 0x17,
+    LXT_PHN_RUIMCONF_NETWORK_START_NOTIFICATION                             = 0x18,
+    LXT_PHN_RUIMCONF_SELECTION_MODE_RESPONSE                                = 0x19,
+    LXT_PHN_RUIMCONF_CHANGE_AUTHENTICATION_RESPONSE                         = 0x1A,
+    LXT_PHN_RUIMCONF_CURRENT_PIN_CHECK_STATE_RESPONSE                       = 0x1B,
+    LXT_PHN_RUIMCONF_CHANGE_PIN_CHECK_STATE_RESPONSE                        = 0x1C,
+    LXT_PHN_RUIMCONF_RUNTIME_CHANGE_NETWORK_RESPONSE                        = 0x1D,
+    LXT_PHN_RUIMCONF_DIR_NAME_RESPONSE                                      = 0x1E,
+    LXT_PHN_RUIMCONF_DIR_NAME_WRITE_RESPONSE                                = 0x1F,
+    LXT_PHN_RUIMCONF_CHANGE_FDN_STATE_RESPONSE                              = 0x20,
+    LXT_PHN_RUIMCONF_CURRENT_FDN_STATE_RESPONSE                             = 0x21,
+    LXT_PHN_RUIMCONF_CHECK_SERVICE_AVAILABE_RESPONSE                        = 0x22,
+    LXT_PDA_RUIMCONF_IMSI_RESPONSE                                          = 0x23,
+
+    // i519
+    LXT_PHN_UIM_GET_UIM_LOCK_RESPONSE                                       = 0x31,
+    LXT_PDA_UIM_UIM_LOCK_PASSWORD_WRITE_RESPONSE                            = 0x32,
+    LXT_PHN_UIM_CARD_STATUS_RESPONSE                                        = 0x41,
+    LXT_PHN_UIM_GET_PIN_CODE_STATUS_RESPONSE                                = 0x42,
+    LXT_PHN_UIM_SET_PIN_CHECK_RESPONSE                                      = 0x43,
+    LXT_PHN_UIM_PIN_VERIFY_RESPONSE                                         = 0x44,
+    LXT_PHN_UIM_CHANGE_PIN_RESPONSE                                         = 0x45,
+    LXT_PHN_UIM_GET_ICCID_RESPONSE                                          = 0x46,
+    LXT_PHN_UIM_UIM_LOCK_RESPONSE                                           = 0x47,
+    LXT_PHN_UIM_CHV_UNBLOCK_RESPONSE                                        = 0x48,
+    LXT_PDA_UIM_DIR_NAME_WRITE_RESPONSE                                     = 0x49,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_INFORMATION_RESPONSE                 = 0x51,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_READ_RESPONSE                        = 0x52,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_WRITE_RESPONSE                       = 0x53,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_ERASE_RESPONSE                       = 0x54,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_CLEAR_RESPONSE                       = 0x55,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_ALL_LIST_RESPONSE                    = 0x56,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_MIRRORING_RESPONSE                   = 0x57,
+    LXT_PHN_UIM_PHONE_CARD_SMS_MESSAGE_MIRRORING_DONE_NOTIFICATION          = 0x58,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_INFORMATION_RESPONSE                  = 0x61,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_READ_RESPONSE                         = 0x62,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_WRITE_RESPONSE                        = 0x63,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_ERASE_RESPONSE                        = 0x64,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_CLEAR_RESPONSE                        = 0x65,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_ALL_LIST_RESPONSE                     = 0x66,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_MIRRORING_RESPONSE                    = 0x67,
+    LXT_PHN_UIM_PHONE_CARD_PHONE_BOOK_MIRRORING_DONE_NOTIFICATION           = 0x68,
+    LXT_PHN_UIM_DIR_NAME_READ_RESPONSE                                      = 0x69,
+    LXT_PHN_UIM_DIR_NAME_WRITE_RESPONSE                                     = 0x70,
+    LXT_PHN_UIM_PHONE_CARD_SMS_CLEAR_RESPONSE                               = 0x71,
+    LXT_PDA_UIM_GET_PERMISSION_STATUS_RESPONSE                              = 0x80
+};
+
+
+enum LXT_PDA_PHONE_BOOK
+{
+    LXT_PDA_PHONE_BOOK_INFORMATION_REQUEST                                  = 0x51,
+    LXT_PDA_PHONE_BOOK_READ_REQUEST                                         = 0x52,
+    LXT_PDA_PHONE_BOOK_READ_ENTRIES_REQUEST                                 = 0x53,
+    LXT_PDA_PHONE_BOOK_WRITE_REQUEST                                        = 0x54,
+    LXT_PDA_PHONE_BOOK_ERASE_REQUEST                                        = 0x55,
+    LXT_PDA_PHONE_BOOK_CLEAR_REQUEST                                        = 0x56,
+    LXT_PDA_PHONE_BOOK_GET_ENTRY_LIST_REQUEST                               = 0x57,
+    LXT_PDA_PHONE_BOOK_GET_CACHED_REQUEST                                   = 0x58
+};
+
+enum LXT_PHN_PHONE_BOOK
+{
+    LXT_PHN_PHONE_BOOK_INFORMATION_RESPONSE                                 = 0x51,
+    LXT_PHN_PHONE_BOOK_READ_RESPONSE                                        = 0x52,
+    LXT_PHN_PHONE_BOOK_READ_ENTRIES_RESPONSE                                = 0x53,
+    LXT_PHN_PHONE_BOOK_GET_ENTRY_LIST_RESPONSE                              = 0x54,
+    LXT_PHN_PHONE_BOOK_ACTION_NOTIFICATION                                  = 0x55,
+    LXT_PHN_PHONE_BOOK_COMPLETE_NOTIFICATION                                = 0x56,
+    LXT_PHN_PHONE_BOOK_GET_CACHED_RESPONSE                                  = 0x57,
+    LXT_PHN_PHONE_BOOK_MIRRORING_START_NOTIFICATION                         = 0xA1,
+    LXT_PHN_PHONE_BOOK_MIRRORING_DONE_NOTIFICATION                          = 0xA2,
+};
+
+// define of action group (UTK) ++++++++++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PDA_UTK
+{
+    LXT_PDA_UTK_START_REQUEST                                               = 0x41,
+    LXT_PDA_UTK_GET_KEY_REQUEST                                             = 0x42,
+    LXT_PDA_UTK_END_INPUT_REQUEST                                           = 0x43,
+    LXT_PDA_UTK_SET_UP_MAIN_MENU_REQUEST                                    = 0x44
+};
+
+
+enum LXT_PHN_UTK
+{
+    LXT_PHN_UTK_MENU_TITLE_NOTIFICATION                                     = 0x41,
+    LXT_PHN_UTK_NENU_ITEM_NOTIFICATION                                      = 0x42,
+    LXT_PHN_UTK_SEND_SMS_NOTIFICATION                                       = 0x43,
+    LXT_PHN_UTK_GET_START_INPUT_NOTIFICATION                                = 0x44,
+    LXT_PHN_UTK_DISPLAY_TEXT_NOTIFICATION                                   = 0x45,
+    LXT_PHN_UTK_END_NOTIFICATION                                            = 0x46,
+    LXT_PHN_UTK_CARD_START_RESPONSE                                         = 0x47
+};
+
+
+// define of action group () ++++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GPS
+{
+    LXT_PDA_GPS_MO_SMS_REQUEST                                              = 0x41,
+    LXT_PDA_GPS_MT_SMS_REQUEST                                              = 0x42,
+    LXT_PDA_GPS_SPP_REQUEST                                                 = 0x43,
+    LXT_PDA_GPS_URL_INFO_REQUEST                                            = 0x44,
+    LXT_PDA_GPS_END_REQUEST                                                 = 0x45
+};
+
+enum LXT_PHN_GPS
+{
+    LXT_PHN_GPS_MT_SMS_ARRIVAL_NOTIFICATION                                 = 0x41,
+    LXT_PHN_GPS_MT_SMS_RESPONSE                                             = 0x42,
+    LXT_PHN_GPS_WAP_BASED_SESSION_STATUS_NOTIFICATION                       = 0x43,
+    LXT_PHN_GPS_URL_INFO_RESPONSE                                           = 0x44,
+    LXT_PHN_GPS_SMS_BASED_SESSION_STATUS_NOTIFICATION                       = 0x45
+};
+
+
+// define of action group (Data service) +++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_DATASERVICE
+{
+    LXT_PDA_DATASERVICE_PIN_CONTROL_REQUEST                                 = 0x41
+};
+
+
+enum LXT_PHN_DATASERVICE
+{
+
+    LXT_PHN_DATASERVICE_PIN_CONTROL_NOTIFICATION                            = 0x41,
+    LXT_PHN_DATASERVICE_DS_TE2_DIALING_INDICATION                           = 0x42,
+    LXT_PHN_DATASERVICE_PPP_CONTROL_DISCONNECTING_NOTIFICATION              = 0x43,
+    LXT_PHN_DATASERVICE_PPP_CONTROL_DONE_NOTIFICATION                       = 0x44,
+    LXT_PHN_DATASERVICE_DS_TE2_DATA_RATE_INFO_NOTIFICATION                  = 0x45,
+    LXT_PHN_DATASERVICE_TE2_STATUS_NOTIFICATION                             = 0x46,
+    LXT_PHN_DATASERVICE_DISPLAY_NOTIFICATION                                = 0x47
+};
+
+// define of action group (response)++++++++++++++++++++++++++++++++++++++++++
+
+enum LXT_PHN_RESPONSE
+{
+    LXT_PHN_RESPONSE_GENERAL_RESPONSE                                       = 0x41
+};
+
+
+
+
+// define of action group (SIO Mode)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_SIOMODE
+{
+    LXT_PDA_SIOMODE_SIO_BAUDRATE_GET_REQUEST                                 = 0x41,
+    LXT_PDA_SIOMODE_SIO_BAUDRATE_SET_REQUEST                                 = 0x42,
+    LXT_PDA_SIOMODE_SLOT_MODE_GET_REQUEST                                    = 0x43,
+    LXT_PDA_SIOMODE_SLOT_MODE_SET_REQUEST                                    = 0x44,
+    LXT_PDA_SIOMODE_VOICE_OP_GET_REQUEST                                     = 0x45,
+    LXT_PDA_SIOMODE_VOICE_OP_SET_REQUEST                                     = 0x46,
+    LXT_PDA_SIOMODE_SIO_MODE_GET_REQUEST                                     = 0x47,
+    LXT_PDA_SIOMODE_SIO_MODE_SET_REQUEST                                     = 0x48,
+    LXT_PDA_SIOMODE_LIFETIME_CLEAR_REQUEST                                   = 0x49,
+};
+
+// define of action group (SIO Mode)++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PHN_SIOMODE
+{
+    LXT_PHN_SIOMODE_SIO_BAUDRATE_GET_RESPONSE                                = 0x41,
+    LXT_PHN_SIOMODE_SLOT_MODE_GET_RESPONSE                                   = 0x42,
+    LXT_PHN_SIOMODE_VOICE_OP_GET_RESPONSE                                    = 0x43,
+    LXT_PHN_SIOMODE_SIO_MODE_GET_RESPONSE                                    = 0x44
+};
+
+
+
+
+
+
+
+
+
+#endif // _PHONEPROTOCOL_H_
diff --git a/vmodem/include/server/phoneprotocol4gsm.h b/vmodem/include/server/phoneprotocol4gsm.h
new file mode 100644 (file)
index 0000000..fbe7a4d
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _PHONEPROTOCOL4GSM_H_
+#define _PHONEPROTOCOL4GSM_H_
+
+//  ===========================================================================
+//
+//                          define of main group
+//
+//  ===========================================================================
+enum LXT_GRP_GSM
+{
+    LXT_GRP_GSM_CONFIG                                            = 0xA3,
+    LXT_GRP_GSM_CALL                                              = 0xA4,
+    LXT_GRP_GSM_SUPS                                              = 0xA5,    
+    LXT_GRP_GSM_EOT                                               = 0xff
+};
+
+//  ===========================================================================
+//
+//                          define of sub command
+//
+//  ===========================================================================
+
+// define of action group (configuration) +++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_CONFIG
+{
+    LXT_PDA_GSM_CONFIG_GET_CALL_COST_REQUEST                      = 0x41,
+    LXT_PDA_GSM_CONFIG_RESET_CALL_COST_REQUEST                    = 0x42,
+    LXT_PDA_GSM_CONFIG_SET_MAX_CALL_COST_REQUEST                  = 0x43,
+    LXT_PDA_GSM_CONFIG_GET_CALL_UNIT_PRICE_REQUEST                = 0x44,
+    LXT_PDA_GSM_CONFIG_SET_CALL_UNIT_PRICE_REQUEST                = 0x45,
+    LXT_PDA_GSM_CONFIG_GET_NETWORK_SELECTION_MODE_REQUEST         = 0x46,
+    LXT_PDA_GSM_CONFIG_AUTOMATIC_NETWORK_SELECTION_REQUEST        = 0x47,
+    LXT_PDA_GSM_CONFIG_MANUAL_NETWORK_SELECTION_REQUEST           = 0x48,
+    LXT_PDA_GSM_CONFIG_MANUAL_NETWORK_SELECTION_REG_REQUEST       = 0x49,
+    LXT_PDA_GSM_CONFIG_GET_CALLER_ID_REQUEST                      = 0x4A,
+    LXT_PDA_GSM_CONFIG_SET_CALLER_ID_REQUEST                      = 0x4B,
+    LXT_PDA_GSM_CONFIG_GET_ACTIVE_LINE_REQUEST                    = 0x4C,
+    LXT_PDA_GSM_CONFIG_SET_ACTIVE_LINE_REQUEST                    = 0x4D,
+    LXT_PDA_GSM_CONFIG_SET_FORCE_GSM_MODE_REQUEST                 = 0x4E,
+    LXT_PDA_GSM_CONFIG_GET_SYSTEM_IDENTITY                        = 0x4F
+};
+
+enum LXT_PHN_GSM_CONFIG
+{
+    LXT_PHN_GSM_CONFIG_GET_CALL_COST_RESONSE                      = 0x41,
+    LXT_PHN_GSM_CONFIG_RESET_CALL_COST_RESONSE                    = 0x42,
+    LXT_PHN_GSM_CONFIG_SET_MAX_CALL_COST_NOTIFICATION             = 0x43,
+    LXT_PHN_GSM_CONFIG_GET_CALL_UNIT_PRICE_RESONSE                = 0x44,
+    LXT_PHN_GSM_CONFIG_SET_CALL_UNIT_PRICE_RESONSE                = 0x45,
+    LXT_PHN_GSM_CONFIG_GET_NETWORK_SELECTION_MODE_NOTIFICATION    = 0x46,
+    LXT_PHN_GSM_CONFIG_AUTOMATIC_NETWORK_SELECTION_NOTIFICATION   = 0x47,
+    LXT_PHN_GSM_CONFIG_MANUAL_NETWORK_SELECTION_NOTIFICATION      = 0x48,
+    LXT_PHN_GSM_CONFIG_MANUAL_NETWORK_REGISTRATION_NOTIFICATION   = 0x49,
+    LXT_PHN_GSM_CONFIG_GET_CALLER_ID_RESPONSE                     = 0x4A,
+    LXT_PHN_GSM_CONFIG_SET_CALLER_ID_RESPONSE                     = 0x4B,
+    LXT_PHN_GSM_CONFIG_GET_ACTIVE_LINE_RESPONSE                   = 0x4C,
+    LXT_PHN_GSM_CONFIG_SET_ACTIVE_LINE_RESPONSE                   = 0x4D,
+    LXT_PHN_GSM_CONFIG_SERVING_SYSTEM_IDENTITY_INDICATION         = 0x4E
+};
+
+// define of action group (call)+++++++++++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_CALL
+{
+    LXT_PDA_GSM_CALL_CALL_ORIGINATION_REQUEST                     = 0x41,
+    LXT_PDA_GSM_CALL_END_CALL_REQUEST                             = 0x42,
+    LXT_PDA_GSM_CALL_ANSWER_REQUEST                               = 0x43,
+    LXT_PDA_GSM_CALL_START_DTMF_REQUEST                           = 0x44,
+    LXT_PDA_GSM_CALL_STOP_DTMF_REQUEST                            = 0x45,
+    LXT_PDA_GSM_CALL_REJECT_REQUEST                               = 0x46
+};
+
+enum LXT_PHN_GSM_CALL
+{
+    LXT_PHN_GSM_CALL_INCOMING_CALL_NOTIFICATION                   = 0x41,
+    LXT_PHN_GSM_CALL_CALL_STATUS_NOTIFICATION                     = 0x42,
+    LXT_PHN_GSM_CALL_START_DTMF_ACK_RESPONSE                      = 0x43,
+    LXT_PHN_GSM_CALL_STOP_DTMF_ACK_RESPONSE                       = 0x44,
+    LXT_PHN_GSM_CALL_DIAGNOSTIC_CALL_ORIGINATION_NOTIFICATION     = 0x45
+};
+
+// define of action group (supplementary)++++++++++++++++++++++++++++++++++++
+enum LXT_PDA_GSM_SUPS
+{
+    LXT_PDA_GSM_SUPS_USER_ORIGINATED_SUPS_REQUEST                 = 0x41,
+    LXT_PDA_GSM_SUPS_NETWORK_ORIGINATED_SUPS_USER_CONFIRM         = 0x42,
+    LXT_PDA_GSM_SUPS_GET_SUPS_NETWORK_CONFIRM_DATA_REQUEST        = 0x43,
+    LXT_PDA_GSM_SUPS_PASSWORD_REGISTRATION_REQUEST                = 0x44,
+    LXT_PDA_GSM_SUPS_CALL_HANDLE_SUPS_WITHIN_CALL_REQUEST         = 0x45
+//    LXT_PDA_GSM_SUPS_GET_BARRING_PASSWORD_CONFIRM                 = 0x45,    
+};
+
+enum LXT_PHN_GSM_SUPS
+{
+    LXT_PHN_GSM_SUPS_USER_ORIGINATED_SUPS_NOTIFICATION            = 0x41,
+    LXT_PHN_GSM_SUPS_NETWORK_ORIGINATED_SUPS_INDICATION           = 0x42,
+    LXT_PHN_GSM_SUPS_GET_SUPS_NETWORK_CONFIRM_DATA_RESPONSE       = 0x43,
+    LXT_PHN_GSM_SUPS_PASSWORD_REGISTRATION_NOTIFICATION           = 0x44,
+    LXT_PHN_GSM_SUPS_GET_BARRING_PASSWORD_INDICATION              = 0x45,
+    LXT_PHN_GSM_SUPS_MANAGE_SUPS_WITHIN_CALL_NOTIFICATION         = 0x46,
+    LXT_PHN_GSM_SUPS_STATUS_NOTIFICATION                          = 0x47,
+    LXT_PHN_GSM_SUPS_CALL_PUT_ON_HOLD_BY_REMOTE_INDICATION        = 0x48,
+    LXT_PHN_GSM_SUPS_CALL_RETRIEVED_BY_REMOTE_INDICATION          = 0x49,
+    LXT_PHN_GSM_SUPS_EXPLICIT_CALL_TRANSFER_BY_REMOTE_INDICATION  = 0x4A
+};
+
+
+
+#endif // _PHONEPROTOCOL4GSM_H_
diff --git a/vmodem/include/server/phoneserver.h b/vmodem/include/server/phoneserver.h
new file mode 100644 (file)
index 0000000..40f45a1
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*********************************************************************
+* $Id: phoneserver.h,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+*
+* Copyright (C) Samsung Electronics
+*
+*********************************************************************/
+
+#ifndef __phoneserver_h
+#define __phoneserver_h
+
+#ifdef __arm__
+#include "dpram.h"
+       //#include "mesgbox_set.h"
+#else
+       #include <sys/ioctl.h>
+#endif
+
+#include <linuxtapi.h>
+#include <vgsm_sim.h>
+#include <vgsm_network.h>
+#include <vgsm_call.h>
+#include <vgsm_ss.h>
+
+//#include <mzgsmpb.h>
+
+#include "gsmstate.h"
+
+#define MAX_MISSED_MESSAGE 64
+#define MAX_CALL_COUNT     6
+#define LXT_ID_CLIENT_HANDSFREE 0x1A
+
+typedef enum {
+    ELOOP_READ = 1,
+    ELOOP_WRITE = 2,
+    ELOOP_EXCEPTION = 4,
+} EloopCondition;
+
+typedef struct _Phone_Server PhoneServer;
+
+/* ---------------------------------------------------------------------------
+     IOManager
+   ---------------------------------------------------------------------------*/
+#ifdef __arm__
+typedef struct
+{
+    int  (*Open)     (PhoneServer *);
+    int  (*Close)    (PhoneServer *);
+    void (*SendQuery)(PhoneServer * s, const char * query);
+    void (*SendCast) (PhoneServer * s, const LXT_MESSAGE * packet);
+    int  (*CallBack) (PhoneServer * s,int fd,EloopCondition cond,void * data);
+    int  (*Init)     (PhoneServer *);
+} FunctionsIOM;
+
+extern FunctionsIOM IOMHandle;
+
+typedef enum
+{
+    TFactoryCableStatus_off                 =0x00,
+    TFactoryCableStatus_on                  =0x01
+}
+TFactoryCableStatus;
+
+typedef enum
+{
+    TFactoryCardStatus_off                  =0x00,
+    TFactoryCardStatus_on                   =0x01
+}
+TFactoryCardStatus;
+
+typedef enum
+{
+    TFactoryMode_exit                       =0x00,
+    TFactoryMode_enter                      =0x01,
+    TFactoryMode_unknown                    =0x0f
+}
+TFactoryMode;
+
+typedef struct
+{
+    int fd;
+    //MBSET mbs;
+
+    signed int          _battery_level;
+    TFactoryCableStatus _factory_cable_status;
+    TFactoryCardStatus  _factory_card_status;
+    TFactoryMode        _factory_mode;
+       char                _calibration_status;
+    char                _earjack_status;
+
+    FunctionsIOM * Functions;
+} IOManager;
+#endif
+
+/* ---------------------------------------------------------------------------
+     PPP Gateway : Dial up NetworkingÀ» À§ÇÑ ppp gateway¿ÍÀÇ Åë½ÅÀ» À§ÇÔ
+   ---------------------------------------------------------------------------*/
+typedef struct
+{
+    int (*Open)    (PhoneServer * s);
+    int (*Close)   (PhoneServer * s);
+    int (*CallBack)(PhoneServer * s, int fd, EloopCondition cond, void * data);
+    int (*Read)    (PhoneServer * s, void * data, int count);
+    int (*Write)   (PhoneServer * s, void * data, int count);
+    int (*Disconnect) (PhoneServer * s);
+} FunctionsPPPGW;
+
+extern FunctionsPPPGW PPPGWHandle;
+
+typedef struct
+{
+    int tx_fd;
+    int rx_fd;
+    FunctionsPPPGW * Functions;
+} PPP_GATEWAY;
+
+/* ---------------------------------------------------------------------------
+     dpram : dpram handle GSM InitConnection¿¡¼­ »ý¼ºµÈ fd¸¦ ±×´ë·Î »ç¿ë
+   ---------------------------------------------------------------------------*/
+typedef struct
+{
+    int (*CallBack)(PhoneServer * s, int fd, EloopCondition cond, void * data);
+} FunctionsDpram;
+
+extern FunctionsDpram DpramHandle;
+
+typedef struct
+{
+    int fd;
+
+    FunctionsDpram * Functions;
+} DPRAM;
+
+/* ---------------------------------------------------------------------------
+     dpram event : ppp, SIM cover»óŵîÀÇ phone event¸¦ Àü´ÞÇϴ fd
+   ---------------------------------------------------------------------------*/
+typedef struct
+{
+    int (*Open)    (PhoneServer * s);
+    int (*Close)   (PhoneServer * s);
+    int (*CallBack)(PhoneServer * s, int fd, EloopCondition cond, void * data);
+} FunctionsDpramEvent;
+
+extern FunctionsDpramEvent DpramEventHandle;
+
+typedef struct
+{
+    int fd;
+    FunctionsDpramEvent * Functions;
+} DPRAM_EVENT;
+
+/* ---------------------------------------------------------------------------
+     dpram error : phone binary critical message Ã³¸®
+   ---------------------------------------------------------------------------*/
+typedef struct
+{
+    int (*Open)    (PhoneServer * s);
+    int (*Close)   (PhoneServer * s);
+    int (*CallBack)(PhoneServer * s, int fd, EloopCondition cond, void * data);
+} FunctionsDpramError;
+
+extern FunctionsDpramError DpramErrorHandle;
+
+typedef struct
+{
+    int fd;
+    FunctionsDpramError * Functions;
+} DPRAM_ERROR;
+
+/* ---------------------------------------------------------------------------
+     socket server : client ¿¬°áÀ» À§ÇÑ socket server
+     ´ëºÎºÐÀÇ ÄÚµå´Â TClientInfoÀÇ CallBack¿¡ µé¾îÀÖ´Ù.
+   ---------------------------------------------------------------------------*/
+typedef struct
+{
+    int  (*CallBack)(PhoneServer * s, int fd, EloopCondition cond, void * data);
+} FunctionsClient;
+
+extern FunctionsClient ClientHandle;
+
+typedef struct clientinfo
+{
+    int fd;
+    int tag;
+    int klass;
+    LXT_MESSAGE request;
+    LXT_MESSAGE notification;
+    struct clientinfo *next;
+    FunctionsClient * Functions;
+} TClientInfo;
+
+typedef struct
+{
+    void (*Init)     (PhoneServer * );
+    int  (*Open)     (PhoneServer * );
+    int  (*CallBack) (PhoneServer * s, int fd,EloopCondition cond,void * data);
+    int  (*OpenInet)     (PhoneServer * );
+    int  (*CallBackInet) (PhoneServer * s, int fd,EloopCondition cond,void * data);
+    void (*Cast)     (PhoneServer * s, int clientid, LXT_MESSAGE * packet);
+    void (*BroadCast)(PhoneServer * s, LXT_MESSAGE * packet);
+    void (*RemoveClient)(PhoneServer * ps, TClientInfo *me);
+    void (*CastMissedMessage) (PhoneServer * ps, int klass, int clientfd);
+} FunctionsServer;
+
+extern FunctionsServer ServerHandle;
+
+typedef struct
+{
+    int klass;
+    LXT_MESSAGE mmsg;
+} MissedMessageInfo;
+
+typedef struct
+{
+    int current;
+    MissedMessageInfo mmsg_info[MAX_MISSED_MESSAGE];
+} MissedMessage;
+
+typedef struct
+{
+    int fd;
+    int inet_fd;
+    TClientInfo     * ci;
+    TClientInfo     * current_ci;
+    MissedMessage     mmsg;
+    FunctionsServer * Functions;
+} Server;
+
+extern int vgsm_server_port;
+
+//
+typedef struct
+{
+    //GSM_WaitingCall WaitingCall; // unused
+    LXT_PHONE_STATE CurrentPhoneState;
+    // char prevCallList[MAX_CALL_COUNT];
+    // unsigned short prevCallList[MAX_CALL_COUNT];
+    gsm_call_list_t   prevCallList;
+    bool m_waitingmode;
+    bool m_deviceCall;
+       int                     UIMLockType;
+       int                             UIMLockKey;
+       int                             LastNetState;
+       int                             StatePhoneOn;
+       int                             GSMDataRequest;
+} PhoneServerData;
+/* ---------------------------------------------------------------------------
+     main ±¸Á¶Ã¼
+   ---------------------------------------------------------------------------*/
+typedef struct {
+    void (*SetInternalState) (PhoneServer * ps, LXT_PHONE_STATE state);
+    LXT_PHONE_STATE (*GetInternalState) (PhoneServer * ps);
+    void (*BroadcastInternalStatus) (PhoneServer * ps, LXT_PHONE_STATE state);
+    void (*CastCurrentInternalStatus) (PhoneServer *ps, int clientid);
+    void (*CallListId_Init)    (PhoneServer *ps);
+    void (*RetrievePhoneState) (void);
+} PhoneServerFunc;
+
+extern PhoneServerFunc PhoneServerHandle;
+
+struct _Phone_Server
+{
+#ifdef __arm__
+    //IOManager       Iom;
+#endif
+    PPP_GATEWAY     PPPGW;
+    DPRAM           Dpram;
+    DPRAM_EVENT     DpramEvent;
+    DPRAM_ERROR     DpramError;
+    Server          ServerSocket;
+    // phone server's data collection
+    PhoneServerData Data;
+    PhoneServerFunc * Functions1;
+};
+
+extern const char * clientName[];
+
+
+//////////////////////////////////////////////////////////////////////
+// by nsclass : remove implicit warning sign.
+int PhoneServer_Init(PhoneServer * server, GSM_StateMachine * s);
+int PhoneServer_Connect(void);
+
+extern PhoneServer       GlobalPS;
+extern PhoneServerFunc * FuncPhoneServer;
+extern FunctionsServer * FuncServer;
+extern PhoneServerFunc * FuncPhoneServer;
+
+
+#endif
diff --git a/vmodem/include/server/server_client.h b/vmodem/include/server/server_client.h
new file mode 100644 (file)
index 0000000..77841db
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_CLIENT_
+#define _SERVER_CLIENT_
+
+void server_client_release_noti(void);
+
+
+#endif
+
diff --git a/vmodem/include/server/server_common.h b/vmodem/include/server/server_common.h
new file mode 100644 (file)
index 0000000..e8c6057
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_COMMON_
+#define _SERVER_COMMON_
+
+void init_vgsm(void);
+
+int server_common_after_sim_init(void);
+
+#endif
+
diff --git a/vmodem/include/server/server_common_call.h b/vmodem/include/server/server_common_call.h
new file mode 100644 (file)
index 0000000..83e2048
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SERVER_COMMON_CALL_H_
+#define _SERVER_COMMON_CALL_H_
+#include "vgsm_call.h"
+#include "vgsm_ss.h"
+#include "at_recv.h"
+
+void set_call_list( gsm_call_direction_e_type dir, gsm_call_status_e_type stat, gsm_call_type_e_type type, char *number, int num_len );
+void set_call_list_status( int call_id, int mpty, gsm_call_status_e_type stat );
+int delete_call_list( int call_id );
+void clear_call_list(void);
+void get_call_list( gsm_call_list_t *list );
+int release_all_held_call(void);
+int release_all_active_call(void);
+int drop_call( int call_id );
+int is_prev_ss_state(ss_hold_act_state_e_type prev_state);
+void set_ss_state(ss_hold_act_state_e_type state);
+void set_rx_ss_state(void);
+int swap_call(void);
+int split_call( int call_id );
+int join_call(void);
+int check_call(void);
+int get_active_call_count(void);
+int get_hold_call_count(void);
+int make_call_id(void);
+void set_call_id( int call_id );
+int get_call_id(void);
+void set_call_type( int type );
+int get_call_type(void);
+void set_call_line_id( int line_id );
+int get_call_line_id(void);
+int check_call_error(void);
+int get_callcount(void);
+int valid_call_type(int call_type);
+
+#endif // _SERVER_COMMON_CALL_H_
+
diff --git a/vmodem/include/server/server_common_network.h b/vmodem/include/server/server_common_network.h
new file mode 100644 (file)
index 0000000..e302ab8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SERVER_COMMON_NETWORK_H_
+#define _SERVER_COMMON_NETWORK_H_
+
+#include "vgsm_network.h"
+
+void init_plmn_list(void);
+void set_plmn_list( unsigned char *data, int len );
+gsm_network_plmn_list_t *get_plmn_list(void);
+void init_network_registration(void );
+void set_network_registration( unsigned char *data, int len );
+gsm_network_reg_t *get_network_registration(void);
+void set_plmn_selection( gsm_net_sel_e_type mode, unsigned char plmn[], gsm_net_act_e_type act );
+gsm_net_sel_e_type get_network_sel_mode(void);
+void   set_network_identity( gsm_network_nitz_info_t net_identity);
+void get_network_identity( gsm_network_nitz_info_t *net_identity);
+
+void set_network_service_domain(gsm_net_svc_domain_e_type service_domain ) ;
+gsm_net_svc_domain_e_type get_network_service_domain(void);
+
+void  set_network_band_mode(gsm_net_band_mode_e_type band_mode, int band );
+gsm_net_band_mode_e_type  get_network_band_mode(void);
+int  get_network_band(void);
+
+#endif
+
+
diff --git a/vmodem/include/server/server_common_security.h b/vmodem/include/server/server_common_security.h
new file mode 100644 (file)
index 0000000..b1a72cd
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SERVER_COMMON_SECURITY_H_
+#define _SERVER_COMMON_SECURITY_H_
+
+#include <stdio.h>
+#include "vgsm_sim.h"
+#include "logmsg.h"
+
+#define SIM_DEBUG(frmt, args...)  log_msg(MSGL_VGSM_SIM, frmt, ##args);
+
+typedef enum {
+       SIM_STATE_READY         =       0,
+       SIM_STATE_PIN_REQ               =       1,
+       SIM_STATE_PUK_REQ       ,
+       SIM_STATE_PIN2_REQ,
+       SIM_STATE_PUK2_REQ,
+       SIM_STATE_FRIZEN,
+       SIM_STATE_NO_SIM,
+       SIM_STATE_FDN_STATE,
+       SIM_STATE_PIN2_OK
+} SIM_STATE;
+
+
+int server_sim_db_init(void);
+
+int server_simdata_init(void);
+
+int server_sec_verify_password(char *password,int type,int length);
+
+int server_sec_status_mgr(int type);
+
+int server_sec_set_sec_status(int status);
+
+int server_sec_get_sec_status(void);
+
+int server_sec_get_remain_cnt(int type);
+
+int server_sec_change_password(char *password,int type,int length);
+
+char * server_sec_get_password(int type);
+
+void server_sec_reset_remain_cnt(int type);
+
+int server_sec_get_facility(int type);
+
+int _trans_db_sim_state_type(int type);
+
+int server_sec_set_sec_db_info(SimSecurity *sim_sec,int  ncol);
+
+void server_sec_set_cnt_zero(int type);
+
+int  server_sec_get_sec2_status(void);
+
+int server_sec_set_sec2_status(int status);
+
+void server_sec_set_facility(int type,int flag);
+
+#endif /* _SERVER_COMMON_SECURITY_H_ */
+
diff --git a/vmodem/include/server/server_common_ss.h b/vmodem/include/server/server_common_ss.h
new file mode 100644 (file)
index 0000000..951c14b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SERVER_COMMON_SS_H_
+#define _SERVER_COMMON_SS_H_
+#include"vgsm_ss.h"
+
+void get_aoc_data ( _AOC_t * data);
+void set_aoc_data ( char * data );
+void get_ussd_data ( _USSD_data_t * data);
+void set_ussd_data ( char * data );
+
+int init_ss_info(void);
+int init_ss_info_re(void);
+
+#endif
+
diff --git a/vmodem/include/server/server_rx_call.h b/vmodem/include/server/server_rx_call.h
new file mode 100644 (file)
index 0000000..fda6242
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_CALL_
+#define _SERVER_RX_CALL_
+
+//#include "linuxtapi.h"
+
+int server_rx_call_list_get(void);
+int server_rx_call_answer_exec(void);
+int server_rx_call_originate_exec(void *ptr_data, int data_len );
+int server_rx_call_release_exec(void);
+
+/* APIs for ss_manage_call */
+int server_rx_call_release_all_held(void);
+int server_rx_call_release_all_active(void);
+int server_rx_call_release_single(int call_id);
+int server_rx_call_swap(void);
+int server_rx_call_split_conf(int call_id);
+int server_rx_call_join_conf(void);
+
+int server_rx_call_burst_dtmf_exec(void);
+int server_rx_call_line_id_set(void *ptr_data, int data_len );
+int server_rx_call_line_id_get(void);
+
+#endif
+
diff --git a/vmodem/include/server/server_rx_data.h b/vmodem/include/server/server_rx_data.h
new file mode 100644 (file)
index 0000000..2cb0ebb
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int server_rx_data_GetDataCallStatus(void *ptr_data, int data_len );
diff --git a/vmodem/include/server/server_rx_display.h b/vmodem/include/server/server_rx_display.h
new file mode 100644 (file)
index 0000000..e32c6c9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_DISPLAY_
+#define _SERVER_RX_DISPLAY_
+
+int server_rx_display_icon_info_get(void);
+
+#endif
+
diff --git a/vmodem/include/server/server_rx_gprs.h b/vmodem/include/server/server_rx_gprs.h
new file mode 100644 (file)
index 0000000..46c9d36
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int server_rx_gprs_SetPDPContext(void *ptr_data, int data_len );
+
+int server_rx_gprs_SetPSActDeact(void *ptr_data, int data_len );
+
diff --git a/vmodem/include/server/server_rx_misc.h b/vmodem/include/server/server_rx_misc.h
new file mode 100644 (file)
index 0000000..00ee0d3
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef __SERVER_RX_MISC__
+#define __SERVER_RX_MISC__
+
+int server_rx_misc_me_version(unsigned char flags);
+
+#endif /* __SERVER_RX_MISC__ */
diff --git a/vmodem/include/server/server_rx_network.h b/vmodem/include/server/server_rx_network.h
new file mode 100644 (file)
index 0000000..b1421e6
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_NETWORK_
+#define _SERVER_RX_NETWORK_
+
+int server_rx_net_plmn_list_get(void);
+int server_rx_net_reg_get(void);
+int server_rx_net_current_plmn_get(void);
+int server_rx_net_plmn_selection_get(void);
+
+int server_rx_net_plmn_selection_set(void *ptr_data, int data_len );
+int server_rx_net_band_set(void *ptr_data, int data_len );
+int server_rx_net_band_get(void);
+
+int server_rx_net_service_domain_get(void);
+
+int server_rx_net_mode_sel_get(char * api);
+int server_rx_net_mode_sel_set(char * api);
+
+int server_rx_net_pref_plmn_get(char * api);
+int server_rx_net_pref_plmn_set(char * api);
+
+#endif
+
diff --git a/vmodem/include/server/server_rx_phonebook.h b/vmodem/include/server/server_rx_phonebook.h
new file mode 100644 (file)
index 0000000..a4d4c14
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SERVER_RX_PHONEBOOK_H_
+#define        _SERVER_RX_PHONEBOOK_H_
+
+int server_rx_sim_pb_get_access_req(void* ptr_data, int data_len);
+
+int server_rx_sim_pb_set_access_req(void* ptr_data, int data_len);
+
+int server_rx_sim_pb_get_storage_cnt_req(void* ptr_data, int data_len);
+
+int server_rx_sim_pb_get_entry_info_req(void* ptr_data, int data_len);
+
+int server_rx_sim_pb_get_storage_list_req(void* ptr_data, int data_len);
+
+int server_rx_sim_pb_update_record(char *api);
+
+int server_rx_sim_pb_del_record(char *api);
+
+int server_rx_sim_pb_get_capability_info(char *api);
+
+#endif
diff --git a/vmodem/include/server/server_rx_power.h b/vmodem/include/server/server_rx_power.h
new file mode 100644 (file)
index 0000000..c0774ac
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_POWER_
+#define _SERVER_RX_POWER_
+
+int server_rx_power_up_exec(void);
+int server_rx_online_exec(unsigned char status);
+
+#endif
diff --git a/vmodem/include/server/server_rx_security.h b/vmodem/include/server/server_rx_security.h
new file mode 100644 (file)
index 0000000..c45aa51
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_SECURITY_H_
+#define _SERVER_RX_SECURITY_H_
+
+int server_rx_sim_sec_get_imsi_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_set_pin_status_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_get_pin_status_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_get_lock_info_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_change_password_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_set_phone_lock_req(void* ptr_data, int data_len);
+
+int server_rx_sim_sec_get_phone_lock_req(void* ptr_data, int data_len);
+
+#endif
diff --git a/vmodem/include/server/server_rx_sms.h b/vmodem/include/server/server_rx_sms.h
new file mode 100644 (file)
index 0000000..7f6e105
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int server_rx_sms_SendMsg(void *ptr_data, int data_len);
+int server_rx_sms_DR(void *ptr_data, int data_len);
+
+int server_rx_sms_SCA(void *ptr_data, int data_len );
+
+int server_rx_sms_SCA_set(char * api);
+int server_rx_sms_cbsetconfig(char * api);
+int server_rx_sms_ressvcoption(char * api);
+int server_rx_sms_param_set(char* api);
+int server_rx_sms_param_get(char* api);
+int server_rx_sms_memstatus(char* api);
+int server_rx_sms_stored_msg_status(char* api);
+int server_rx_sms_param_count(char* api);
+int server_rx_sms_mem_status(char* api);
+
diff --git a/vmodem/include/server/server_rx_ss.h b/vmodem/include/server/server_rx_ss.h
new file mode 100644 (file)
index 0000000..acc36ce
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_RX_SS_
+#define _SERVER_RX_SS_
+
+int server_rx_ss_cw_get(int tel_class);
+int server_rx_ss_cb_get(int tel_class, int cb_type);
+int server_rx_ss_cf_get(int tel_class, int cf_type);
+
+int server_rx_ss_cw_set(int tel_class, int ss_mode);
+//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);
+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 server_rx_ss_cb_set(int cb_type, int ss_mode, int tel_class, char *passwd);
+
+int server_rx_ss_cb_passwd_set(char* curr_passwd, char* new_passwd);
+
+int server_rx_ss_cli(char *api);
+
+int server_rx_ss_ussd_get(void);
+
+int server_rx_ss_aoc_get(void);
+
+int server_rx_ss_manage_call_set(char* ptr_data, int data_len);
+void set_outgoing_video_call_barring_state(int state);
+void set_incoming_video_call_barring_state(int state);
+void set_outgoing_voice_call_barring_state(int state);
+void set_incoming_voice_call_barring_state(int state);
+int get_outgoing_voice_call_barring_state(void);
+int get_incoming_voice_call_barring_state(void);
+int get_outgoing_video_call_barring_state(void);
+int get_incoming_video_call_barring_state(void);
+
+extern int g_ss_hold_response_error ;
+extern int g_ss_retrieve_response_error ;
+extern int g_ss_join_response_error ;
+extern int g_ss_split_response_error ;
+extern int g_ss_transfer_response_error ;
+
+#endif
+
diff --git a/vmodem/include/server/server_tx_call.h b/vmodem/include/server/server_tx_call.h
new file mode 100644 (file)
index 0000000..df1aa97
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_CALL_
+#define _SERVER_TX_CALL_
+
+#include "linuxtapi.h"
+
+int server_tx_call_incoming_noti( LXT_MESSAGE * packet );
+
+int server_tx_call_list_noti(void);
+
+int server_tx_call_list_resp(void);
+
+int server_tx_call_msg(void);
+
+int server_tx_call_status(void);
+
+int server_tx_call_release_exec( LXT_MESSAGE * packet );
+
+int server_tx_call_release_internal(int call_id);
+
+int server_tx_call_answer_exec(void);
+
+int server_tx_call_all_release(void);
+
+int server_tx_call_alert_ind(void *ptr_data, int data_len );
+
+void server_tx_call_burst_dtmf_noti(int success);
+
+int server_tx_call_line_id_resp(void);
+
+// 090314
+int callback_list_noti(void);
+void callback_callist(void);
+
+int change_stat_for_at(int gsm_stat);
+int change_dir_for_at(int gsm_dir);
+
+#endif
diff --git a/vmodem/include/server/server_tx_data.h b/vmodem/include/server/server_tx_data.h
new file mode 100644 (file)
index 0000000..921de9f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "linuxtapi.h"
+
+int server_tx_data_CallStatus(LXT_MESSAGE const* packet);
+
+int server_tx_data_DataCallStatus(LXT_MESSAGE const* packet);
diff --git a/vmodem/include/server/server_tx_display.h b/vmodem/include/server/server_tx_display.h
new file mode 100644 (file)
index 0000000..027480a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_DISPLAY_
+#define _SERVER_TX_DISPLAY_
+
+#include "linuxtapi.h"
+
+int server_tx_display_icon_info_resp(void);
+int server_tx_display_icon_info_noti( unsigned char icon_type, unsigned char rssi, unsigned char bat, unsigned char act, unsigned char reg);
+
+#endif
+
diff --git a/vmodem/include/server/server_tx_gprs.h b/vmodem/include/server/server_tx_gprs.h
new file mode 100644 (file)
index 0000000..fcad9e7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+int server_tx_gprs_ipconf_match(void);
+
+int server_tx_gprs_IPConfigurationNotify(LXT_MESSAGE const* packet);
diff --git a/vmodem/include/server/server_tx_network.h b/vmodem/include/server/server_tx_network.h
new file mode 100644 (file)
index 0000000..1e44ab7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_NETWORK_
+#define _SERVER_TX_NETWORK_
+
+#include "linuxtapi.h"
+
+int server_tx_net_plmn_list_noti(LXT_MESSAGE const* packet);
+
+int server_tx_net_reg_noti(LXT_MESSAGE const* packet);
+
+int server_tx_net_current_plmn_noti( LXT_MESSAGE const* packet);
+
+int server_tx_net_current_nitz_noti(LXT_MESSAGE const* packet);
+
+#endif
+
diff --git a/vmodem/include/server/server_tx_phonebook.h b/vmodem/include/server/server_tx_phonebook.h
new file mode 100644 (file)
index 0000000..0d43b77
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_PHONEBOOK_H_
+#define _SERVER_TX_PHONEBOOK_H_
+
+#include "db_phonebook.h"
+
+void server_tx_sim_pb_get_access_RX_UI(PB *pb,int flag);
+
+int server_tx_sim_pb_get_all_db(PB *pb,int cnt);
+
+void callback_pb_action(PB *pb);
+
+#endif
diff --git a/vmodem/include/server/server_tx_power.h b/vmodem/include/server/server_tx_power.h
new file mode 100644 (file)
index 0000000..f0849f8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_POWER_
+#define _SERVER_TX_POWER_
+
+#include "linuxtapi.h"
+
+int server_tx_power_up_resp(void);
+int server_tx_online_noti(unsigned char status);
+int server_tx_battery_status_noti(unsigned char level);
+
+#endif
+
diff --git a/vmodem/include/server/server_tx_security.h b/vmodem/include/server/server_tx_security.h
new file mode 100644 (file)
index 0000000..2b0e22c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_SECURITY_H_
+#define _SERVER_TX_SECURITY_H_
+
+#include "vgsm_sim.h"
+
+int server_tx_sim_init_start(void);
+
+int server_tx_sim_sec_disable_facility(void);
+
+int server_tx_sim_sec_enable_facility(int status);
+
+int server_tx_sim_sec_get_db(SimSecurity *sim_sec);
+
+int server_tx_sim_sec_card_type_noti(void);
+
+int server_tx_sim_sec_pin_status_noti(STATE_TYPE before_state, STATE_TYPE current_state);
+
+int server_tx_sim_data_get_db(unsigned char *sim_data, int len);
+
+int server_tx_sim_info_get_db(unsigned char *sim_info, int len);
+
+#endif
+
diff --git a/vmodem/include/server/server_tx_sms.h b/vmodem/include/server/server_tx_sms.h
new file mode 100644 (file)
index 0000000..0b9be23
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "linuxtapi.h"
+#include "at_msg.h"
+
+int  server_tx_sms_notiIncomingMsg(LXT_MESSAGE const* packet);
+
+int server_tx_sms_send_msg(unsigned char *sms, unsigned char length);
+
+int server_tx_sms_ReceiveAckMsg(LXT_MESSAGE const* packet);
+
+int server_tx_sms_NotiIncomingCBMsg(LXT_MESSAGE const * packet);
+
+void    server_tx_sms_deviceReady(LXT_MESSAGE const* packet);
diff --git a/vmodem/include/server/server_tx_ss.h b/vmodem/include/server/server_tx_ss.h
new file mode 100644 (file)
index 0000000..f04d8fe
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _SERVER_TX_SS_
+#define _SERVER_TX_SS_
+
+#include "vgsm_ss.h"
+#include "misc.h"
+
+int server_tx_ss_state( ss_state_e_type type );
+int server_tx_ss_cli(unsigned char ss_call_type, unsigned char ss_present_indi, unsigned char ss_no_cli_cause );
+void server_tx_ss_cw_set_req( LXT_MESSAGE *packet);
+void server_tx_ss_ccfc_set_req( LXT_MESSAGE *packet);
+void server_tx_ss_cb_set_req( LXT_MESSAGE *packet);
+void server_tx_ss_aoc_get_req ( LXT_MESSAGE *packet);
+void server_tx_ss_aoc_set_req ( LXT_MESSAGE *packet);
+void server_tx_ss_cf_set_req ( LXT_MESSAGE *packet);
+void server_tx_ss_ussd_set_req ( LXT_MESSAGE *packet);
+void server_tx_ss_ussd_get_req ( LXT_MESSAGE *packet);
+
+#endif
+
diff --git a/vmodem/include/server/state.h b/vmodem/include/server/state.h
new file mode 100644 (file)
index 0000000..3448d43
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _STATE_H_
+#define _STATE_H_
+
+#include <linuxtapi.h>
+#include <at_msg.h>
+#include <vgsm.h>
+#include <vgsm_phone.h>
+//#include "db_security.h"
+#include "db_ss.h"
+
+// #define _DEBUG
+
+#ifdef  _DEBUG
+#define _ENTER()    log_msg(MSGL_VGSM_INFO,"ENTER\n")
+#define _LEAVE()       log_msg(MSGL_VGSM_INFO,"LEAVE\n" )
+#else
+#define _ENTER()
+#define _LEAVE()
+#endif  /* _DEBUG */
+
+#define STATE_TYPE(x)              (x).state_type
+#define STATE_MAIN_CMD(x)          (x).main_cmd
+#define STATE_SUB_CMD(x)           (x).sub_cmd
+#define STATE_FUNCTION(x)          (x).state_function
+
+#define STATE_FLAG_TYPE                    0x01
+#define STATE_FLAG_MAIN_CMD        0x02
+#define STATE_FLAG_SUB_CMD         0x04
+#define STATE_FLAG_FUNCTION        0x08
+#define STATE_FLAG_ALL             0xFF
+
+#define MAX_CALL_COUNT             6
+
+/*
+* For State Machine
+*/
+typedef enum {
+       GSM_PWR_CMD=0x01,               /* 0x01 : Power Control Commands */
+       GSM_CALL_CMD,                   /* 0x02 : Call Control Commands */
+       GSM_DATA_CMD,                   /* 0x03 : Data Control Commands */
+       GSM_SMS_CMD,                    /* 0x04 : Short Message Service Commands */
+       GSM_SEC_CMD,                    /* 0x05 : Security - SIM control Commands */
+       GSM_PB_CMD,                     /* 0x06 : Phonebook Control Commands */
+       GSM_DISP_CMD,                   /* 0x07 : Display Control Commands */
+       GSM_NET_CMD,                    /* 0x08 : Network Commands */
+       GSM_SND_CMD,                    /* 0x09 : Sound Control Commands */
+       GSM_MISC_CMD,                   /* 0x0A : Miscellaneous Control Commands */
+       GSM_SVC_CMD,                    /* 0x0B : Service Mode Control Commands - Factory Test or Debug Screen Control */
+       GSM_SS_CMD,                     /* 0x0C : Supplementary Service Control Command */
+       GSM_GPRS_CMD,                   /* 0x0D : GPRS Commands */  // joonook 20041011 create
+       GSM_SAT_CMD,                    /* 0x0E : SIM Toolkit Commands */
+       GSM_CFG_CMD,                    /* 0x0F : Configuration Commands */
+       GSM_IMEI_CMD,                   /* 0x10 : IMEI Tool Commands */
+       GSM_GPS_CMD,                    /* 0x11 : GPSl Commands */
+       GSM_SAP_CMD,                    /* 0x12 : SIM Access Profile Commands */
+       GSM_GEN_CMD=0x80,               /* 0x80 : General Response Command */
+       GSM_CMD_MAX
+}gsm_main_cmd_type;
+
+typedef enum{
+       GSM_SEC_PIN_STATUS                      =0x01,    /* 0x01 : PIN Status Message */
+       GSM_SEC_PHONE_LOCK,                                     /* 0x02 : Phone Lock Message */
+       GSM_SEC_CHANGE_LOCKING_PW,                      /* 0x03 : Change Locking Password Message */
+       GSM_SEC_SIM_LANG,                                               /* 0x04 : SIM Language Message */
+       GSM_SEC_RSIM_ACCESS,                                    /* 0x05 : +CRSM, Restricted SIM Access Message */
+       GSM_SEC_GSIM_ACCESS,                                    /* 0x06 : +CSIM, General SIM Access Message */             
+       GSM_SEC_SIM_ICC_TYPE,                                   /* 0x07 : SIM ICC Type Message*/
+       GSM_SEC_LOCK_INFO,                                      /* 0x08 : Lock Information Message*/
+       GSM_SEC_ISIM_AUTH,                                      /* 0x9 : ISIM Authentication Message */
+       GSM_SEC_MAX
+} gsm_sec_sub_cmd_type; 
+
+typedef enum{
+  GSM_CALL_OUTGOING=0x01,           /* 0x01 : Call Outgoing Message */
+  GSM_CALL_INCOMING,                     /* 0x02 : Call Incoming Message */
+  GSM_CALL_RELEASE,                        /* 0x03 : Call Release Message */
+  GSM_CALL_ANSWER,                        /* 0x04 : Call Answer Message */
+  GSM_CALL_STATUS,                         /* 0x05 : Current Call Status Message */
+  GSM_CALL_LIST,                              /* 0x06 : Current Call List Message */
+  GSM_CALL_BURST_DTMF,                /* 0x07 : Burst DTMF Message */
+  GSM_CALL_CONT_DTMF,                  /* 0x08 : Continuous DTMF Message */
+  GSM_CALL_WAITING,                      /* 0x09 : Call Waiting Message */
+  GSM_CALL_LINE_ID,                      /* 0x0A : Call Line id Message */
+  GSM_CALL_MAX                                /* 0x0B : Max */
+} gsm_call_sub_cmd_type;
+
+typedef enum _STATE_TYPE {
+    STATE_NONE=0x00,
+    STATE_OFF=0x01,
+    STATE_ON,
+    STATE_STANDBY,
+/* Call - begin */
+    STATE_CALL_WAITING_INCOMING,
+    STATE_CALL_WAITING_OUTGOING,
+    STATE_CALL_CONVERSATION,
+    STATE_CALL_RELEASED,
+/* Call - end */
+
+/* SIM -start */
+
+    STATE_SIM_READY,
+    STATE_SIM_PIN,
+    STATE_SIM_FDN, // 0x10
+    STATE_SIM_PUK,
+    STATE_SIM_FRIZEN,
+    STATE_SIM_PUK2,
+    STATE_SIM_PIN2,
+
+    STATE_SIM_PIN_WRONG,
+    STATE_SIM_PUK_WRONG,
+    STATE_SIM_PUK2_WRONG,
+    STATE_SIM_PIN2_WRONG,
+
+    STATE_SIM_PIN_OK,
+    STATE_SIM_PUK_OK, //0x20
+    STATE_SIM_PUK2_OK,
+    STATE_SIM_PIN2_OK,
+       
+    STATE_SIM_PIN_WRONG_ALL,
+    STATE_SIM_PUK_WRONG_ALL,
+    STATE_SIM_PUK2_WRONG_ALL,
+    STATE_SIM_PIN2_WRONG_ALL,
+
+       //STATE_SIM_PIN_LOCK_DISABLE,
+       //0215
+       STATE_SIM_NO_SIM,
+/* SIM -end */
+       
+    STATE_ANY
+} STATE_TYPE;
+
+typedef struct _STATE {
+    int state_type;
+    int main_cmd;
+    int sub_cmd;
+    int (*state_function)(void);
+} STATE;
+
+#if 0 /* start-move to server_common_security.h*/
+typedef enum {
+   SIM_STATE_READY=    0,
+   SIM_STATE_PIN_REQ=  1,
+   SIM_STATE_PUK_REQ   ,       
+   SIM_STATE_PIN2_REQ  ,       
+   SIM_STATE_PUK2_REQ  ,       
+   SIM_STATE_FRIZEN    ,               
+   SIM_STATE_NO_SIM    ,               
+  SIM_STATE_FDN_STATE,
+  SIM_STATE_PIN2_OK
+} SIM_STATE;
+#endif  /* end-move to server_common_security.h*/
+
+typedef struct _STATE_TABLE {
+    STATE current_state;
+    STATE next_state;
+} STATE_TABLE;
+
+typedef struct _STATE_MACHINE {
+    STATE prev_state;
+    STATE current_state;
+} STATE_MACHINE;
+
+#if 0  // moved to vgsm_ss.h
+typedef enum {
+    SS_STATE_HOLD = 0x01,
+    SS_STATE_UNHOLD = 0x02,
+    SS_STATE_CONFERENCE = 0x03,
+    SS_STATE_SWAP = 0x04,
+    SS_STATE_SPLIT = 0x05,
+    SS_STATE_DROP = 0x06
+} SS_State_Type;
+#endif
+//080227 - move to server_common.h
+//void init_vgsm();
+void print_state_table(void);
+void print_state( STATE state );
+void print_state_machine(void);
+int find_next_state_for_state( STATE current, STATE *next, int flag );
+int find_next_state( STATE *next, int flag );
+void set_state_machine( STATE state );
+int change_state_machine( int main_cmd );
+void get_current_state_machine( STATE *state );
+void get_prev_state_machine( STATE *state );
+void send_msg( void);
+void set_current_state( int state, int main_cmd, int sub_cmd);
+#if 0
+void set_call_list( gsm_call_direction_e_type dir, gsm_call_status_e_type stat, gsm_call_type_e_type type, char *number, int num_len );
+void set_call_list_status( int call_id, int mpty, gsm_call_status_e_type stat );
+int delete_call_list( int call_id );
+void clear_call_list();
+void get_call_list( gsm_call_list_t *list );
+int release_all_held_call();
+int release_all_active_call();
+int drop_call( int call_id );
+int swap_call();
+int split_call( int call_id );
+int join_call();
+int check_call();
+//int release_call( int call_id );
+//void release_all_call();
+int get_active_call_count();
+int get_hold_call_count();
+#endif
+
+void set_hdlc_mode( int mode );
+int get_hdlc_mode(void);
+void set_general_response_error( int error );
+int get_general_response_error(void);
+void set_ss_general_response_error( int error );
+int get_ss_general_response_error(void);
+void set_call_status_error( int error );
+int get_call_status_error(void);
+void set_current_general_response_error( int error );
+int get_current_general_response_error(void);
+void set_ss_current_general_response_error( int error );
+int get_ss_current_general_response_error(void);
+void set_current_call_status_error( int error );
+int get_current_call_status_error(void);
+
+#if 0
+void make_call_id();
+void set_call_id( int call_id );
+int get_call_id();
+void set_call_type( int type );
+int get_call_type();
+#endif
+
+void set_sca( SmsAddressInfo SCA );
+int get_sca( SmsAddressInfo *SCA );
+
+#if 0 //moved to server_common_network.h
+void init_plmn_list();
+void set_plmn_list( unsigned char *data, int len );
+gsm_network_plmn_list_t *get_plmn_list();
+void init_network_registration();
+void set_network_registration( unsigned char *data, int len );
+gsm_network_reg_t *get_network_registration();
+void set_plmn_selection( gsm_net_sel_e_type mode, unsigned char plmn[], gsm_net_act_e_type act );
+gsm_net_sel_e_type get_network_sel_mode();
+#endif
+
+#if 0
+/*SS*/
+void set_call_waiting_entry(call_waiting_entry_t * entry, int num);
+call_waiting_entry_t * get_call_waiting_entry();
+call_waiting_entry_t * find_call_waiting_entry(int tel_class);
+
+void set_call_barring_entry(call_barring_entry_t * entry, int num);
+call_barring_entry_t * get_call_barring_entry();
+char find_call_barring_entry(int tel_class, int type, int * count);
+
+void set_call_forwarding_entry(call_forwarding_entry_t * entry, int num);
+call_forwarding_entry_t * get_call_forwarding_entry();
+call_forwarding_entry_t * find_call_forwarding_entry(int tel_class, int type, int * count);
+
+void set_outgoing_call_barring_state(int state);
+BOOL get_outgoing_call_barring_state();
+#endif
+
+/* SIM */
+/* - do not use
+void set_sim_sec_general_response_error( int error );
+int get_sim_sec_general_response_error();
+*/
+
+/* GPRS */
+void init_gprs_info(void);
+GSM_GprsIPConfiguration * get_gprs_ipconfiguration_list(void);
+void set_gprs_ipconfiguration_list(char *ptr, int len);
+
+void set_ss_transfer_response_error(int error, int ss_error_type);
+
+extern gsm_network_plmn_list_t g_plmn_list;
+
+#endif /* _STATE_H_ */
+
diff --git a/vmodem/include/server/state_sim.h b/vmodem/include/server/state_sim.h
new file mode 100644 (file)
index 0000000..d360062
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _STATE_SIM_H_
+#define _STATE_SIM_H_
+
+#include <stdio.h>
+#include "vgsm_sim.h"
+
+//#define FALSE 0
+/*--> 2008-09-29
+#define SIM_DEBUG(frmt, args...)  {do { fprintf(stderr, "\n[VGSM-SIM] [%s:%d] " frmt ,  __func__,  __LINE__, ##args); } while (0);}
+<--*/
+/*++> 2008-09-29 */
+#define SIM_DEBUG(frmt, args...)  fprintf(stderr, "\n[VGSM-SIM] [%s:%d] " frmt ,  __func__,  __LINE__, ##args)
+/*<++*/
+
+typedef enum {
+       SIM_STATE_READY         =       0,
+       SIM_STATE_PIN_REQ               =       1,
+       SIM_STATE_PUK_REQ       ,
+       SIM_STATE_PIN2_REQ,
+       SIM_STATE_PUK2_REQ,
+       SIM_STATE_FRIZEN,
+       SIM_STATE_NO_SIM,
+       SIM_STATE_FDN_STATE,
+       SIM_STATE_PIN2_OK
+} SIM_STATE;
+
+int server_sim_db_init();
+int state_sim_verify_password(char *password,int type,int length);
+char state_sim_status_mgr(int type);
+int state_sim_set_sec_status(int status);
+int state_sim_get_sec_status();
+int state_sim_get_remain_cnt(int type);
+int state_sim_change_password(char *password,int type,int length);
+char * state_sim_get_password(int type);
+void state_sim_reset_remain_cnt(int type);
+int state_sim_get_facility(int type);
+int _trans_db_sim_state_type(int type);
+void state_sim_set_sec_db_info(SimSecurity *sim_sec,int  ncol);
+void state_sim_set_cnt_zero(int type);
+int  state_sim_get_sec2_status();
+int state_sim_set_sec2_status(int status);
+void state_sim_set_facility(int type,int flag);
+
+void set_sim_sec_general_response_error( int error );
+int get_sim_sec_general_response_error();
+
+
+#endif /* _STATE_SIM_H_ */
+
diff --git a/vmodem/include/server/tapi4phonebook.h b/vmodem/include/server/tapi4phonebook.h
new file mode 100644 (file)
index 0000000..f1c43ba
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _TAPI4PHONEBOOK_H_
+#define _TAPI4PHONEBOOK_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+// ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
+#include <stdio.h>
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
+
+
+
+
+
+
+
+
+
+
+
+
+#define MAX_ALPHA_SIZE                                                      32
+#define MAX_DIGITS_SIZE                                                     32
+#define MAX_PHONEBOOK_ITEM                                                 256
+
+typedef enum
+{
+    LXT_PHONEBOOK_PBM_DEFAULT   =       0x00,       // do not use
+    LXT_PHONEBOOK_PBM_SLOT1_ADN =       0x01,       // adn of slot1
+    LXT_PHONEBOOK_PBM_SLOT2_ADN =       0x02,       // adn of slot2
+    LXT_PHONEBOOK_PBM_SLOT1_FDN =       0x03,       // fdn of slot1
+    LXT_PHONEBOOK_PBM_SLOT2_FDN =       0x04,       // fdn of slot2
+    LXT_PHONEBOOK_PBM_MAX       =       0x05,       // do not use
+    LXT_PHONEBOOK_PBM_EOT       =       0x0f        // do not use
+}
+LXT_PHONEBOOK_PBM;
+
+
+// card phone book
+typedef struct
+{
+    int index;                          // 4  byte
+    int alpha_size;                     // 4  byte
+    int num_digits;                     // 4  byte
+    char alpha[MAX_ALPHA_SIZE];         // 32 byte
+    char digits[MAX_DIGITS_SIZE];       // 32 byte
+}
+LXT_PHONEBOOK_ONE_ITEM;
+
+// phone book set
+typedef struct
+{
+    int mpb_id;                         // 4  byte
+    int num_total;                      // 4  byte
+    int num_used;                       // 4  byte
+    int max_entry_alpha_size;           // 4  byte
+    LXT_PHONEBOOK_ONE_ITEM phonebook_item[MAX_PHONEBOOK_ITEM];
+}
+LXT_PHONEBOOK_ALL;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _TAPI4PHONEBOOK_H_
+
+
+// ============================================================================ end of file
+
diff --git a/vmodem/include/server/vgsm_debug.h b/vmodem/include/server/vgsm_debug.h
new file mode 100644 (file)
index 0000000..cc2fe3a
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef _VGSM_DEBUG_H_
+#define _VGSM_DEBUG_H_
+
+#include <stdio.h>
+#include"logmsg.h"
+
+#ifdef _VGSM_DEBUG
+//#define VGSM_DEBUG(frmt, args...)  {do {printf("[VGSM] [%s:%d] " frmt ,  __func__,  __LINE__, ##args); } while (0) ;}
+/*--> 2008-09-20
+#define VGSM_DEBUG(frmt, args...)  {do {log_msg(MSGL_VGSM_INFO,frmt ,  ##args); } while (0) ;}
+#define VGSM_ERR(frmt, args...)  {do {log_msg(MSGL_VGSM_WARN,frmt ,  ##args); } while (0) ;}
+<--*/
+/*++> 2008-09-20 */
+#define VGSM_DEBUG(frmt, args...)      log_msg(MSGL_VGSM_INFO, frmt, ##args)
+/*<++*/
+#else
+#define VGSM_DEBUG(frmt, args...)
+#endif
+
+#endif
+
diff --git a/vmodem/include/sms/sms_header.h b/vmodem/include/sms/sms_header.h
new file mode 100644 (file)
index 0000000..2f9a180
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SMS_HEADER_H_
+#define _SMS_HEADER_H_
+
+typedef unsigned char BYTE;
+typedef unsigned short UINT8;
+typedef unsigned short UINT;
+typedef unsigned int UINT32;
+typedef int BOOL;
+
+#define TAPI_NETTEXT_CB_SIZE_MAX           255
+#define TAPI_NETTEXT_MSG_SIZE_MAX          500
+#define TAPI_NETTEXT_SCADDRESS_LEN_MAX     20
+#define TAPI_NETTEXT_SMDATA_SIZE_MAX       255
+#define TAPI_NETTEXT_ADDRESS_LEN_MAX       255
+
+#ifndef        TRUE
+#define TRUE   1
+#endif /* TRUE */
+
+#ifndef FALSE
+#define FALSE  0
+#endif /* FALSE */
+
+/**
+ * @enum TapiNetTextVPType
+ * This enumeration defines the validity period type.
+ */
+typedef enum
+{
+       TAPI_NETTEXT_VP_NOT_USED = 0,           /**< validity period not used */
+       TAPI_NETTEXT_VP_RELATIVE = 2,           /**< after a predetermined time period after the service center has received the message */
+       TAPI_NETTEXT_VP_ABSOLUTE = 3,
+       TAPI_NETTEXT_VP_ENHANCED = 1,
+
+       TAPI_NETTEXT_VP_MAX
+} TapiNetTextVPType;
+
+/**
+ * @enum TapiNetTextVPRelValue
+ * This structure defines the validity period type.
+ */
+typedef enum
+{
+       TAPI_NETTEXT_VP_REL_1H,         /**< One hour */
+       TAPI_NETTEXT_VP_REL_6H,         /**< Six hours */
+       TAPI_NETTEXT_VP_REL_12H,        /**< Twelve hours */
+       TAPI_NETTEXT_VP_REL_1D,         /**< One day */
+       TAPI_NETTEXT_VP_REL_3D,         /**< Three days */
+       TAPI_NETTEXT_VP_REL_1W,         /**< One week */
+       TAPI_NETTEXT_VP_REL_1M,         /**< One Month */
+       TAPI_NETTEXT_VP_REL_MAX         /**< Max = 63 weeks */
+} TapiNetTextVPRelValue;
+
+typedef struct
+{
+       TapiNetTextVPType vpType;                         /**< Validity period format */
+       TapiNetTextVPRelValue vpRelativeType; /**< Validity period value duration the message must retain in the service center while application attempts delivery */
+       UINT32 vpValue;                                           /** Validity period value */
+} TapiNetTextVP;
+
+/**
+ * @enum TapiNetTextCodingGroupType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_CODGRP_SM_GENERAL_DCS,                     /**< Bits 7..4 00xx */
+       TAPI_NETTEXT_CODGRP_CB_GENERAL_LANG,            /**< 0000 */
+       TAPI_NETTEXT_CODGRP_CB_ALPHA,                           /**< 0001 */
+       TAPI_NETTEXT_CODGRP_CB_RES1,                            /**< 0010 */
+       TAPI_NETTEXT_CODGRP_CB_RES2,                            /**< 0011 */
+       TAPI_NETTEXT_CODGRP_SM_AUTO_DELETION,           /**< 01xx Bits 5..0 are coded the same as SM_GENERAL_DCS */
+       TAPI_NETTEXT_CODGRP_CB_GENERAL_DCS,                     /**< 01xx behavior is as SM_GENERAL_DCS */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_DISCARD,         /**< 1100 */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_STORE,           /**< 1101 */
+       TAPI_NETTEXT_CODGRP_SM_WAITING_STORE_UCS2,      /**< 1110 */
+       TAPI_NETTEXT_CODGRP_CB_WAP,                                     /**< 1110 Cell Broadcast */
+       TAPI_NETTEXT_CODGRP_SM_CLASS_CODING,            /**< 1111 */
+       TAPI_NETTEXT_CODGRP_CB_CLASS_CODING,            /**< 1111 Cell Broadcast */
+       TAPI_NETTEXT_CODGRP_SM_RESERVED,                        /* reserved coding group */
+       TAPI_NETTEXT_CODGRP_MAX
+} TapiNetTextCodingGroupType;
+
+/**
+ * @enum TapiNetTextWaitingType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_WAITING_VOICE_MSG,         /**< voice message waiting */
+       TAPI_NETTEXT_WAITING_FAX_MSG,           /**< FAX message waiting */
+       TAPI_NETTEXT_WAITING_EMAIL_MSG,         /**< E-mail waiting */
+       TAPI_NETTEXT_WAITING_OTHER_MSG,         /**< Other message waiting */
+
+       TAPI_NETTEXT_WAITING_MAX
+} TapiNetTextWaitingType;
+
+/**
+ * @enum TapiNetTextAlphabetType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_ALPHABET_DEFAULT,  /**< GSM alphabet default 7bit */
+       TAPI_NETTEXT_ALPHABET_8BIT,             /**< 8bit */
+       TAPI_NETTEXT_ALPHABET_UCS2,             /**< 16bit ucs2 */
+
+       TAPI_NETTEXT_ALPHABET_KSC5601,  /**< for Korean */
+
+       TAPI_NETTEXT_ALPHABET_MAX
+} TapiNetTextAlphabetType;
+
+/**
+ * @enum TapiNetTextClassType
+ */
+typedef enum
+{
+       TAPI_NETTEXT_CLASS_0,   /**< display immediately */
+       TAPI_NETTEXT_CLASS_1,   /**< may be stored */
+       TAPI_NETTEXT_CLASS_2,   /**< store in SIM */
+       TAPI_NETTEXT_CLASS_3,   /**< transfer to TE */
+       TAPI_NETTEXT_CLASS_NONE,
+
+       TAPI_NETTEXT_CLASS_MAX
+} TapiNetTextClassType;
+
+typedef struct
+{
+       BOOL                                                    bCompressed;            /**< if text is compressed this is TRUE */
+       BOOL                                                    bMsgClassSet;           /**< message class indication. if TRUE = bits 1..0, if FALSE = reserved */
+       BOOL                                                    bMsgIndActive;          /**< message indication group. if TRUE = on, FALSE = off */
+       TapiNetTextCodingGroupType              codingGroupType;        /**< Coding group, GSM 03.38 */
+       TapiNetTextWaitingType                  waitingType;            /**< Type of message waiting */
+       TapiNetTextAlphabetType                 alphabetType;           /**< How to encode a message. */
+       TapiNetTextClassType                    classType;                      /**< The message class */
+       BYTE                                    codingGroup;            /* reserved coding group 7...4 */
+       BYTE                                    code;                   /* code 3...0 */
+} TapiNetTextCodingScheme;
+
+////////////////////////////////Adddress Field/////////////////////////////////
+#define ADDRESS_LEN_MAX        20
+
+//type of number
+typedef enum
+{
+       TYPEOFNUMBER_UNKNOWN                                            =0x00,
+       TYPEOFNUMBER_INTERNATION_NUMER                          =0x01,
+       TYPEOFNUMBER_NATIONAL_NUMBER                            =0x02,
+       TYPEOFNUMBER_NETWORK_SPECIFIC_NUMBER            =0x03,
+       TYPEOFNUMBER_SUBSCRIBER_NUMBER                          =0x04,
+       TYPEOFNUMBER_ALPHANUMERIC                               =0x05,
+       TYPEOFNUMBER_ABBREVIATED                                =0x06,
+       TYPEOFNUMBER_RESERVED_FOR_EXTENSION             =0x07
+       
+}NumberType;
+
+// Numbering-plan-identification (applies for type of number 000,001,010)
+typedef enum
+{
+       NUMBERING_PLAN_IDENTIFICATION_UNKNOWN                   =0x00,
+       NUMBERING_PLAN_IDENTIFICATION_ISDN_TELEPHONE            =0x01,
+       NUMBERING_PLAN_IDENTIFICATION_DATA                              =0x03,
+       NUMBERING_PLAN_IDENTIFICATION_TELEX                             =0x04,
+       NUMBERING_PLAN_IDENTIFICATION_NATIONAL                  =0x08,
+       NUMBERING_PLAN_IDENTIFICATION_PRIVATE                           =0x09,
+       NUMBERING_PLAN_IDENTIFICATION_ERMES                             =0x0B,
+       NUMBERING_PLAN_IDENTIFICATION_RESERVED                  =0x0F
+       
+}NumberingPlan;
+
+typedef struct 
+{
+       NumberType              ton;
+       
+       NumberingPlan           npi;
+               
+       UINT32                  dialnumLen;
+       
+       unsigned char           diallingNum[ADDRESS_LEN_MAX+1];
+       
+} SmsAddressInfo;
+
+#endif /* _SMS_HEADER_H_ */
diff --git a/vmodem/include/sms/sms_util.h b/vmodem/include/sms/sms_util.h
new file mode 100644 (file)
index 0000000..513a645
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SMS_UTIL_H_
+#define _SMS_UTIL_H_
+
+#include "sms_header.h"
+
+//#include <linuxtapi.h>
+
+#define        SIM_TON_UNKNOWN                                 0 //unknown
+#define        SIM_TON_INTERNATIONAL                           1 //international number
+#define        SIM_TON_NATIONAL                                        2 //national number
+#define        SIM_TON_NETWORK_SPECIFIC                        3 //natwork specific number
+#define        SIM_TON_DEDICATED_ACCESS                        4 //subscriber number
+#define        SIM_TON_ALPHA_NUMERIC                           5//alphanumeric, GSM 7-bit default alphabet)
+#define        SIM_TON_ABBREVIATED_NUMBER              6 //abbreviated number
+#define        SIM_TON_RESERVED_FOR_EXT                        7 //reserved for extension
+
+
+#define MAX_UDH_LEN            137 
+#define UDH_MAX                                7
+#define SMDATA_SIZE_MAX        160
+
+
+#define FAIL                   0x00
+#define SUCCESS                0x01
+//////////////////////////////////TPDU type////////////////////////////////
+typedef enum 
+{
+       SMS_TPDU_DELIVER                                = 0x00, // sc -> ms
+       SMS_TPDU_DELIVER_REPORT         = 0x00, // ms -> sc
+       SMS_TPDU_SUBMIT                         = 0x01, // ms -> sc
+       SMS_TPDU_SUBMIT_REPORT          = 0x01, // sc -> ms
+       SMS_TPDU_STATUS_REPORT          = 0x02, // sc -> ms
+       SMS_TPDU_COMMAND                                = 0x02, // ms -> sc
+       SMS_PDU_INVALID_TYPE
+       
+} SmsTPDUType;
+
+typedef struct
+{
+       int             year;
+       int             month;
+       int             day;
+       int             hour;
+       int             minute;
+       int             second;
+       
+} TmDateTime;
+
+
+#define BASE_YEAR              70L                                     /* 1970 is the base year */
+#define MAX_YEAR                       130L                                    /* 2030 is the max year */
+
+
+#define        SIM_SMSP_ADDRESS_LEN                                    20      // digit length
+
+#define SET_TON_NPI(dest, ton, npi) {  \
+       dest = 0x80;                                            \
+       dest |= (ton & 0x07) << 4;                      \
+       dest |= npi & 0x0F;                                     \
+}
+
+
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType ;   //bit 0 ,1
+
+       // reject duplicates [M]
+       BOOL rd ;  // bit 2
+
+       // validity period format [M]
+       TapiNetTextVPType vpf ; //  bits 3, 4
+
+       // reply path [M]
+       BOOL rp ; //bit 7
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       // status report request
+       BOOL  srr ;  // bit 5
+
+       /************BODY************/
+
+       //message reference [M]
+       UINT mr;
+
+       // destination address [M]
+       SmsAddressInfo desAddr;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme [M]
+       TapiNetTextCodingScheme dcs;
+
+       // validity period
+       TapiNetTextVP vp;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT;
+
+typedef struct
+{
+       /************HEADER************/
+       
+       // message type [M]
+       SmsTPDUType  msgType;  //bit 0 ,1
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       /************BODY************/
+
+       // failure Cause [M]
+        UINT   fcs;
+
+       // parameter indicator [M]
+       BYTE paraInd;
+
+       // service centre time stamp [M]
+       TmDateTime scts;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme 
+       TapiNetTextCodingScheme dcs;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT_REPORT;
+
+
+typedef struct
+{      
+       /************HEADER************/
+       SmsTPDUType msgType;   //bit 0 ,1
+       
+       BOOL mms; // bit 2 
+       
+       BOOL rp; // bit 7 
+       
+       BOOL udhi;  //bit 6
+       
+       BOOL sri; // bit , 5status_report_indication
+       
+       /************BODY************/
+
+       SmsAddressInfo orgAddr;
+
+       BYTE  pId;
+
+       TmDateTime scts;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE  * userData;
+       
+}TPDU_SMS_DELIVER;
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ;  //bit 6
+       
+       /************BODY************/
+
+       UINT fcs;
+
+       BYTE paraInd;
+
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_DELIVER_REPORT;
+
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ; //bit 6
+
+       BOOL srr; //bit 5, status_report_request
+
+       /************BODY************/
+
+       UINT  mr; //message_ref
+
+       BYTE pId;
+
+       BYTE cmdType;
+
+       BYTE msgNum;
+
+       SmsAddressInfo destAddr;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_COMMAND;
+
+
+typedef struct
+{
+       /************HEADER************/
+       
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL  udhi ; //bit 6
+
+       BOOL mms ; //bit 2
+
+       BOOL srq; //bit 5, status_report_qualifier
+
+       /************BODY************/
+       
+       UINT  mr;
+
+       SmsAddressInfo rcpAddr; //recipient_addr
+
+       TmDateTime scts;
+
+       TmDateTime dt; //discharge_time
+
+        BYTE  status;
+       
+        BYTE paraInd;
+               
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_STATUS_REPORT;
+
+#define CB_GSM                 0x01
+#define CB_UMTS        0x02
+
+typedef struct
+{
+       BYTE            accessNetwork;                          //GSM or UMTS
+       BYTE            messageType;                            //!< The type of cellbroadcast message. [only UMTS use]
+       UINT            messageId;                                      //!< The source and type of cellbroadcast message.
+       BYTE            geographicalScope;                    //!< The geographical area over which the cellbroadcast message is sent.
+       BYTE            updateNumber;                           //!< Identifies a change of the message content of the same cellbroadcast message.
+       UINT            messageCode;                            //!< Identifies different message themes.
+       BYTE            language;                                       //!< Language of the cellbroadcast message content.
+       BYTE            messageClass;                           //!< Class of the cellbroadcast message.
+       BYTE            page;
+
+       BYTE      *     message;
+       
+}CELLBROADCASTING;  //june
+
+
+
+/**************************************************************************************
+*** (main.c) function header****************************************************************
+***************************************************************************************
+***************************************************************************************/
+
+BOOL EncodeSmsDeliverTpdu(SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, char *rawdata, int *rawdata_len, BYTE pid, BYTE dcs);
+//BOOL EncodeSmsDeliverTpdu(char *rawdata, int *rawdata_len, char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+BOOL EncodeSmsSubmitReportTpdu(char *rawdata, int *rawdata_len);
+BOOL DecodeSmsSubmitTpdu(TPDU_SMS_SUBMIT *tpdu_submit, int pdu_len , char * pPDU);
+
+/*
+int SendMessage();
+int ReadMessage();
+int DeleteMessage();
+int ReceiveMessage(int pdu_len, char * pPDU);
+int GetInformation();
+int Setting();
+
+BOOL DecodeCellBroadcastMsg(int length,char * pPDU);
+BOOL EncodeSmsSubmitTpdu(char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+//BOOL DecodeSmsSubmitTpdu(int pdu_len , char * pPDU);
+int  DecodeSmsDeliverTpdu(int pdu_len , char * pPDU);
+BOOL EncodeSmsDeliverReportTpdu();
+BOOL DecodeSmsSubmitReportTpdu(int length , char *data);
+BOOL DecodeSmsStatusReportTpdu(int pdu_len, char * pPDU);
+*/
+
+/***************************************************************************************/
+void reverse(char* x, int len);
+char* AcItoa(int n, char* str, int b) ;
+int AcToupper(int ch);
+
+int SmsUtilUnpackGSMCode( char* szData, const BYTE* pIn, int in_len );
+int SmsUtilPackGSMCode( BYTE* pOut, const char* szData, int in_len );
+
+void SmsUtilConvertBCD2Digit( char* pDigits, char* pBCD, int digitLen );
+void SmsUtilConvertDigit2BCD( char* pBCD, char* pDigits, int digitLen );
+
+TmDateTime* SmsUtilDecodeTimeStamp( unsigned char* pTimeStamp, TmDateTime *tmDateTime );
+unsigned char* SmsUtilEncodeTimeStamp( TmDateTime* tmDateTime, unsigned char* pTimeStamp );
+
+
+void  SmsUtilDecodeAddrField(char *diallingNum, unsigned char * pAddrField, int *result_ton, int *result_npi );
+int SmsUtilEncodeAddrField( unsigned char* pAddrField, unsigned char* diallingNum, int dialnumLen, int ton, int npi );
+
+int SmsUtilDecodeScAddrField( SmsAddressInfo* pSmsAddrField, BYTE* pAddrField );
+int SmsUtilEncodeScAddrField( BYTE* pAddrField, SmsAddressInfo * pSmsAddrField );
+void SmsUtilDecodeDCS( TapiNetTextCodingScheme* pCodingScheme,   unsigned char dcs );
+void SmsUtilEncodeDCS( BYTE* pDCS, TapiNetTextCodingScheme* pCodingScheme);
+
+UINT8 SmsUtilEncodeValidity( BYTE* pValidity, TapiNetTextVP* pVP );
+
+#endif /* _SMS_UTIL_H_ */
diff --git a/vmodem/include/transport/dpram.h b/vmodem/include/transport/dpram.h
new file mode 100644 (file)
index 0000000..139017e
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/* *   dpram.h                 * */
+#ifndef _DPRAM_H_
+#define _DPRAM_H_
+
+#include <linux/ioctl.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+
+#ifndef __cplusplus
+#ifndef false
+#  define false 0
+#endif
+#ifndef true
+#  define true  !0
+#endif
+#ifndef bool
+#  define bool  char
+#endif
+#endif /* __cplusplus */
+
+#define IOC_MZ_MAGIC           ('h')
+
+/*
+  extra IOCTL mapping
+       0x00 ~ 0x0f                     for TV
+       0x10 ~ 0x2f                     for Camera
+       0x30 ~ 0xff                     reserved for future use
+*/
+#define IOC_MZ2_MAGIC          (0xC1)
+
+/*
+ * for touch devices
+ */
+
+/*
+ * for /dev/misc/apm_bios
+ */
+#define MZ_LED_ON              0x01
+#define MZ_LED_OFF             0x00
+#define MZ_LED_BLINK           0x04
+#define MZ_LED_BLINK_RATE      0x08    /* variable-rate blink */
+#define MZ_LED_READ_ONLY       0x80
+#define MZ_LED_COLOR           0x40
+
+typedef struct {
+  unsigned int index;          /* LED index to control */
+  unsigned int stat;           /* control command or current status */
+  unsigned int rate;           /* blinking rate */
+  unsigned int color;          /* LED color */
+  unsigned int info;           /* capable function */
+} LED_RET;
+
+#define MZ_GET_LED_NO          _IOR(IOC_MZ_MAGIC, 0x8b, unsigned int)
+#define MZ_GET_LED_STATUS      _IOR(IOC_MZ_MAGIC, 0x8c, LED_RET)
+#define MZ_SET_LED_STATUS      _IOW(IOC_MZ_MAGIC, 0x8d, LED_RET)
+
+/*
+ * for /dev/ppp device
+ */
+#define MZ_PPP_DORMANT_ON      _IO (IOC_MZ_MAGIC, 0x92)
+#define MZ_PPP_DORMANT_OFF     _IO (IOC_MZ_MAGIC, 0x93)
+
+/*
+ * for mz_ctrl_mmap
+ */
+typedef struct __mz_mmap_t {
+       int id;
+       unsigned long offset;
+       unsigned long size;
+} mz_mmap_t;
+
+#define MZ_MMAP_GET            _IOR(IOC_MZ_MAGIC, 0x94, mz_mmap_t)
+#define MZ_MMAP_WRITTEN                _IOW(IOC_MZ_MAGIC, 0x95, mz_mmap_t)
+
+/*
+ * PDA test
+ */
+typedef struct _mz_tst_t {
+       int id;
+       unsigned int buf[3];
+       unsigned long jiff;
+} mz_tst_t;
+#define MZ_TST_ID_KEY          0       /* keyboard, button, ... */
+#define MZ_TST_ID_TS           1       /* TouchScreen */
+
+/*******************************************************************/
+//here  i8xx.h
+
+/* Audio Path Control */
+#define HN_AUDIO_PATH          _IOW(IOC_MZ_MAGIC, 0xc0, unsigned long)
+
+/* select MIC1 */
+#define KEYPAD_MIC             (1 << 0)
+#define EAR_MIC                        (1 << 1)
+#define CAM_MIC                        (1 << 2)
+#define BT_MIC                 (1 << 3)
+
+#define REC_MIC1               (1 << 6)
+#define REC_PHONE              (1 << 7)
+
+#define PLAY_OUT2              (1 << 8)
+#define PLAY_HPOUT             (1 << 9)
+#define PLAY_MONOOUT           (1 << 10)
+#define PLAY_CRADLE            (1 << 11)
+#define PLAY_BT                        (1 << 12)
+#define PLAY_UART_BT           (1 << 13)
+#define PLAY_OUT3              (1 << 14)
+
+#define PHONE_RING             (1 << 16)
+#define PHONE_OUT3             (1 << 17)
+#define PHONE_HPOUT            (1 << 18)
+#define PHONE_OUT2             (1 << 19)
+#define PHONE_CRADLE           (1 << 20)
+#define PHONE_BT               (1 << 21)
+
+#define MZ_AMP_ON              (1 << 24)
+#define ADC_PWR_ON             (1 << 25)
+#define MZ_AMP_OFF             (1 << 26)
+
+#define ICP_TX                         (1 << 28)
+#define ICP_RX                         (1 << 29)
+#define BT_LOOPBACK            (1 << 30)
+
+/* Audio EQ Control */
+#define HN_AUDIO_EQ            _IOW(IOC_MZ_MAGIC, 0xde, unsigned long)
+
+#define EQ_FLAT                        (1 << 0)
+#define EQ_POP                 (1 << 1)
+#define EQ_ROCK                        (1 << 2)
+#define EQ_JAZZ                        (1 << 3)
+#define EQ_CLASSIC             (1 << 4)
+#define EQ_DANCE               (1 << 5)
+#define EQ_HEAVY               (1 << 6)
+#define EQ_DISCO               (1 << 7)
+#define EQ_SOFT                        (1 << 8)
+#define EQ_HALL                        (1 << 9)
+#define EQ_LIVE                        (1 << 10)
+
+/* Audio Gain */
+struct audio_gain {
+       unsigned short apply;
+       unsigned int pcm;
+       unsigned int altpcm;
+       unsigned int phone;
+};
+
+#define HN_AUDIO_GAIN          _IOW(IOC_MZ_MAGIC, 0xdf, struct audio_gain)
+
+#define HN_AMP_SET_STATUS      _IOW(IOC_MZ_MAGIC, 0xcf, unsigned int)
+#define HN_AMP_OFF_STATUS      0x0
+#define HN_AMP_ON_STATUS       0x1
+
+/* rescan external perpheral device */
+#define HN_RESCAN_ACCESSARY    _IO (IOC_MZ_MAGIC, 0xc1)
+
+/* rescan & get battery type */
+#define HN_RESCAN_BATTERY_TYPE _IOR(IOC_MZ_MAGIC, 0xc2, unsigned int)
+#define HN_BATTERY_TYPE_STD    0x0
+#define HN_BATTERY_TYPE_EXT    0x1
+#define HN_BATTERY_TYPE_STB    0x2
+
+#define HN_BATTERY_TYPE_STB_RAW        14
+#define HN_RESCAN_BATTERY_TYPE2        _IOR(IOC_MZ_MAGIC, 0xc5, unsigned int)
+
+/* UART & USB port switching */
+#define HN_UART_TO_PHONE       _IO (IOC_MZ_MAGIC, 0xc8)
+#define HN_UART_TO_PDA         _IO (IOC_MZ_MAGIC, 0xc9)
+#define HN_USB_TO_PHONE                _IO (IOC_MZ_MAGIC, 0xca)
+#define HN_USB_TO_PDA          _IO (IOC_MZ_MAGIC, 0xcb)
+#define HN_USB_UART_STATE      _IO (IOC_MZ_MAGIC, 0xce)
+
+#define HN_UART_PATH_PDA       0x0001
+#define HN_UART_PATH_PHONE     0x0002
+#define HN_USB_PATH_PDA                0x0010
+#define HN_USB_PATH_PHONE      0x0020
+
+/* Vibrator Control */
+#define HN_MOTOR_ON            _IO (IOC_MZ_MAGIC, 0xcc)
+#define HN_MOTOR_OFF           _IO (IOC_MZ_MAGIC, 0xcd)
+
+/* Bluetooth Power Control */
+#define HN_BT_ON               _IO (IOC_MZ_MAGIC, 0xdc)
+#define HN_BT_OFF              _IO (IOC_MZ_MAGIC, 0xdd)
+
+/* Keypad */
+#define HN_KEYPAD_ENABLE       _IO (IOC_MZ_MAGIC, 0xea)
+#define HN_KEYPAD_DISABLE      _IO (IOC_MZ_MAGIC, 0xeb)
+#define HN_LOCK_STATUS         _IOR(IOC_MZ_MAGIC, 0xec, unsigned int)
+
+/* DPRAM Control for communication between PDA and Phone */
+
+/* DPRAM ioctls for DPRAM tty devices */
+#define HN_DPRAM_PHONE_ON              _IO (IOC_MZ_MAGIC, 0xd0)
+#define HN_DPRAM_PHONE_OFF             _IO (IOC_MZ_MAGIC, 0xd1)
+#define HN_DPRAM_PHONE_GETSTATUS       _IOR(IOC_MZ_MAGIC, 0xd2, unsigned int)
+#define HN_DPRAM_PHONE_DOWNLOAD                _IO (IOC_MZ_MAGIC, 0xd5)
+#define HN_DPRAM_PHONE_REBUILD         _IO (IOC_MZ_MAGIC, 0xd9)
+#define HN_DPRAM_PHONE_MAGICCODE       _IO (IOC_MZ_MAGIC, 0xda)
+
+/* return codes for HN_DPRAM_PHONE_GETSTATUS */
+#define HN_DPRAM_PHONE_STATUS_OFF      0x00
+#define HN_DPRAM_PHONE_STATUS_ON       0x01
+
+/* DPRAM ioctls for DPRAM ctl device */
+#define HN_DPRAM_PPP_ENABLE            _IO (IOC_MZ_MAGIC, 0xd3)
+#define HN_DPRAM_PPP_DISABLE           _IO (IOC_MZ_MAGIC, 0xd4)
+#define HN_DPRAM_PPP_AC_ENABLE         _IO (IOC_MZ_MAGIC, 0xd6)
+#define HN_DPRAM_PPP_AC_DISABLE                _IO (IOC_MZ_MAGIC, 0xd7)
+#define HN_DPRAM_SIM_GETSTATUS         _IOR(IOC_MZ_MAGIC, 0xd8, unsigned int)
+
+/* return codes for HN_DPRAM_SIM_GETSTATUS */
+#define HN_DPRAM_SIM_STATUS_CLOSE      0x00
+#define HN_DPRAM_SIM_STATUS_OPEN       0x01
+
+/* DPRAM events through /dev/dpram/ctl */
+#define HN_DPRAM_EVENT_PPP_ACCESS      0x0001
+#define HN_DPRAM_EVENT_PHONE_DN_DONE   0x0002
+#define HN_DPRAM_EVENT_SIM_COVER_OPEN  0x0004
+#define HN_DPRAM_EVENT_SIM_COVER_CLOSE 0x0008
+#define HN_DPRAM_EVENT_PHONE_REB_START 0x0010
+#define HN_DPRAM_EVENT_PHONE_REB_END   0x0020
+#define HN_DPRAM_EVENT_PHONE_INACTIVE  0x0040
+#define HN_DPRAM_EVENT_PHONE_ACTIVE    0x0080
+
+/* button definition */
+#define HN_POWER_BUTTON                MZ_SCANCODE_POWER
+#define HN_CAMERA_BUTTON       MZ_SCANCODE_U1
+#define HN_CAMERA_AF_BUTTON    MZ_SCANCODE_U3
+#define HN_VOICE_BUTTON                MZ_SCANCODE_RECORD
+
+#define HN_SIDE_UP_BUTTON      MZ_SCANCODE_SLIDE_UP
+#define HN_SIDE_DOWN_BUTTON    MZ_SCANCODE_SLIDE_DOWN
+
+#define HN_HOME_BUTTON         MZ_SCANCODE_MENU
+#define HN_BACK_BUTTON         MZ_SCANCODE_CLR
+#define HN_SEND_BUTTON         MZ_SCANCODE_SEND
+#define HN_END_BUTTON          MZ_SCANCODE_END
+#define HN_END_LONG_BUTTON     MZ_SCANCODE_F11
+
+#define HN_UP_BUTTON           MZ_SCANCODE_UP
+#define HN_DOWN_BUTTON         MZ_SCANCODE_DOWN
+#define HN_LEFT_BUTTON         MZ_SCANCODE_LEFT
+#define HN_RIGHT_BUTTON                MZ_SCANCODE_RIGHT
+#define HN_OK_BUTTON           MZ_SCANCODE_ENTER
+
+#define HN_EAR_SEND_BUTTON     MZ_SCANCODE_U2
+
+#define HN_0_BUTTON            MZ_SCANCODE_PAD_0
+#define HN_1_BUTTON            MZ_SCANCODE_PAD_1
+#define HN_2_BUTTON            MZ_SCANCODE_PAD_2
+#define HN_3_BUTTON            MZ_SCANCODE_PAD_3
+#define HN_4_BUTTON            MZ_SCANCODE_PAD_4
+#define HN_5_BUTTON            MZ_SCANCODE_PAD_5
+#define HN_6_BUTTON            MZ_SCANCODE_PAD_6
+#define HN_7_BUTTON            MZ_SCANCODE_PAD_7
+#define HN_8_BUTTON            MZ_SCANCODE_PAD_8
+#define HN_9_BUTTON            MZ_SCANCODE_PAD_9
+#define HN_ASTERISK_BUTTON     MZ_SCANCODE_ASTERISK
+#define HN_SHARP_BUTTON                MZ_SCANCODE_SHARP
+
+#define HN_MENU_BUTTON         MZ_SCANCODE_F12
+#define HN_CANCEL_BUTTON       MZ_SCANCODE_CLR
+#define HN_ADDRESS_BUTTON      MZ_SCANCODE_F5
+#define HN_MSG_BUTTON          MZ_SCANCODE_F6
+#define HN_UMAX_BUTTON         MZ_SCANCODE_F7
+
+#define HN_PLAY_BUTTON         MZ_SCANCODE_F8
+#define HN_PREVIOUS_BUTTON     MZ_SCANCODE_F9
+#define HN_NEXT_BUTTON         MZ_SCANCODE_F10
+
+/*
+ * CAMERA interface from intc3
+ */
+#define WCAM_VIDIOCSCAMREG     _IOW(IOC_MZ2_MAGIC, 0x10, int)
+#define WCAM_VIDIOCGCAMREG     _IOR(IOC_MZ2_MAGIC, 0x11, int)
+#define WCAM_VIDIOCSCIREG      _IOW(IOC_MZ2_MAGIC, 0x12, int)
+#define WCAM_VIDIOCGCIREG      _IOR(IOC_MZ2_MAGIC, 0x13, int)
+#define WCAM_VIDIOCSINFOR      _IOW(IOC_MZ2_MAGIC, 0x14, int)
+#define WCAM_VIDIOCGINFOR      _IOR(IOC_MZ2_MAGIC, 0x15, int)
+
+typedef struct _mz_cif_reg_t {
+       int val1, val2;
+} mz_cif_reg_t;
+
+/*
+ * camera DSP control
+ */
+struct i819_cam_window {
+       int width;
+       int height;
+       int zoom;
+       int color_space;
+       int ret_mode;
+};
+#define HN_CAM_S_WB            _IOW(IOC_MZ2_MAGIC, 0x16, unsigned int)
+#define HN_CAM_S_BRIGHTNESS    _IOW(IOC_MZ2_MAGIC, 0x17, unsigned int)
+#define HN_CAM_S_EFFECT                _IOW(IOC_MZ2_MAGIC, 0x18, unsigned int)
+#define HN_CAM_PREPARE_STILL   _IO (IOC_MZ2_MAGIC, 0x19)
+#define HN_CAM_S_FOCUS_AUTO    _IOW(IOC_MZ2_MAGIC, 0x1a, int)
+#define HN_CAM_S_FOCUS_MAN     _IOW(IOC_MZ2_MAGIC, 0x1b, int)
+#define HN_CAM_CHANGETO_C      _IO (IOC_MZ2_MAGIC, 0x1c)
+#define HN_CAM_RETURNTO_B      _IO (IOC_MZ2_MAGIC, 0x1d)
+#define HN_CAM_G_IRIS          _IOR(IOC_MZ2_MAGIC, 0x1e, int)
+#define HN_CAM_G_LENS          _IOR(IOC_MZ2_MAGIC, 0x1f, unsigned int)
+#define HN_CAM_G_WBR           _IOR(IOC_MZ2_MAGIC, 0x20, unsigned int)
+#define HN_CAM_G_WBB           _IOR(IOC_MZ2_MAGIC, 0x21, unsigned int)
+#define HN_CAM_TEST_EMP                _IO(IOC_MZ2_MAGIC, 0x22)
+/* removed : #define HN_CAM_S_FLASH            _IO(IOC_MZ2_MAGIC, 0x23) */
+#define HN_CAM_AF_SET          _IOW(IOC_MZ2_MAGIC, 0x23, int)
+#define HN_CAM_CHECK_WB_1              _IO(IOC_MZ2_MAGIC, 0x24)
+#define HN_CAM_CHECK_WB_2              _IO(IOC_MZ2_MAGIC, 0x25)
+#define HN_CAM_PREPARE_STILL_2         _IO (IOC_MZ2_MAGIC, 0x26)
+#define HN_CAM_S_FOCUS_SEMI_AUTO       _IOW(IOC_MZ2_MAGIC, 0x27, unsigned int)
+#define HN_CAM_MORE_SHARPEN            _IO (IOC_MZ2_MAGIC, 0x28)
+#define HN_CAM_NORMAL_SHARPEN          _IO (IOC_MZ2_MAGIC, 0x29)
+#define HN_CAM_S_WINDOW                _IOWR(IOC_MZ2_MAGIC, 0x2A, struct i819_cam_window)
+#define HN_CAM_S_LENS          _IO (IOC_MZ2_MAGIC, 0x2B)
+#define HN_CAM_S_WB_SP         _IO (IOC_MZ2_MAGIC, 0x2C)
+#define HN_CAM_FREEZE_AWB      _IO (IOC_MZ2_MAGIC, 0x2D)
+
+
+#define FOCUS_MODE_NORMAL      0
+#define FOCUS_MODE_MACRO       1
+#define FOCUS_MODE_POTRAIT     2
+#define FOCUS_MODE_LANDSCAPE   3
+
+/*
+ * Image format definition
+ */
+#define CAMERA_IMAGE_FORMAT_RAW8                0
+#define CAMERA_IMAGE_FORMAT_RAW9                1
+#define CAMERA_IMAGE_FORMAT_RAW10               2
+#define CAMERA_IMAGE_FORMAT_RGB444              3
+#define CAMERA_IMAGE_FORMAT_RGB555              4
+#define CAMERA_IMAGE_FORMAT_RGB565              5
+#define CAMERA_IMAGE_FORMAT_RGB666_PACKED       6
+#define CAMERA_IMAGE_FORMAT_RGB666_PLANAR       7
+#define CAMERA_IMAGE_FORMAT_RGB888_PACKED       8
+
+/* Camera Flash Modes */
+#define HN_FLASH_MODE_UNKNOWN          0
+#define HN_FLASH_MODE_STILLIMAGE       1
+#define HN_FLASH_MODE_MOVIE            2
+
+/* Light Sensor control */
+#define HN_GET_ILLUMINANCE     _IOR(IOC_MZ_MAGIC, 0xfa, unsigned int)
+#define HN_LIGHT_SENSOR_ON     _IO (IOC_MZ_MAGIC, 0xfb)
+#define HN_LIGHT_SENSOR_OFF    _IO (IOC_MZ_MAGIC, 0xfc)
+
+/* TVOUT */
+#define HN_TVO2_S_BASE         _IOW(IOC_MZ2_MAGIC, 0x00, int)
+#define HN_TVO2_G_BASE_DESC    _IOR(IOC_MZ2_MAGIC, 0x01, unsigned long)
+#define HN_TVO2_POWER_ON       _IO (IOC_MZ2_MAGIC, 0x02)
+#define HN_TVO2_POWER_OFF      _IO (IOC_MZ2_MAGIC, 0x03)
+#define HN_TVO2_START          _IO (IOC_MZ2_MAGIC, 0x04)
+#define HN_TVO2_STOP           _IO (IOC_MZ2_MAGIC, 0x05)
+#define HN_TVO2_FRAMERATE      _IOW(IOC_MZ2_MAGIC, 0x06, int)
+#define HN_TVO2_S_CMDADR       _IOW(IOC_MZ2_MAGIC, 0x07, unsigned long)
+#define HN_TVO2_S_DATADR       _IOW(IOC_MZ2_MAGIC, 0x08, unsigned long)
+
+/*
+ * Framebuffer control
+ */
+#define HN_FB_SET_DISP_ORDER   _IOW (IOC_MZ_MAGIC, 0xf6, int)
+#define FB_DISP_ORDER_BASE_BOTTOM      0
+#define FB_DISP_ORDER_BASE_TOP         1
+#define HN_FB_SET_K1_CONST     _IOW (IOC_MZ_MAGIC, 0xf7, int)
+#define HN_FB_SET_K2_CONST     _IOW (IOC_MZ_MAGIC, 0xf8, int)
+#define HN_FB_SET_K3_CONST     _IOW (IOC_MZ_MAGIC, 0xf9, int)
+
+/*
+ * Backup Battery Cut-On/Off
+ */
+#define HN_BAK_BATTERY_ON      _IO (IOC_MZ_MAGIC, 0xfe)
+#define HN_BAK_BATTERY_OFF     _IO (IOC_MZ_MAGIC, 0xff)
+
+/*
+ * mz_mmap mapping
+ */
+#define MMAP_SIZE              4096    /* = kernel's PAGE_SIZE */
+
+#define HN_MMAP_BATTERY                0x01
+typedef struct _hn_mmap_bat_t {
+       unsigned int voltage, raw;
+       unsigned int level, battery, ac, blite;
+
+       unsigned int cpu, load;
+       unsigned int master, altpcm, pcm, flash;
+       unsigned long stat;
+
+       /* used by iom */
+       unsigned int phone_fsm_bak;
+       unsigned int stat_bak;
+} hn_mmap_bat_t;
+
+#if defined(__KERNEL__)
+struct hn_b_mmap_t {
+       mz_kmap_t k;
+       hn_mmap_bat_t *v;
+};
+extern struct hn_b_mmap_t hn_b_mmap;
+#endif
+
+/*
+ * mz_ops_t.bstat
+ */
+#define HN_BATTERY_AMP                 (1 << 0)
+#define HN_BATTERY_LCD_OFF             (1 << 1)
+#define HN_BATTERY_BT                  (1 << 2)
+#define HN_BATTERY_CAM_ON              (1 << 3)
+#define HN_BATTERY_CAM_RUN             (1 << 4)
+#define HN_BATTERY_CAM_FLASH           (1 << 5)
+#define HN_BATTERY_TV                  (1 << 6)
+#define HN_BATTERY_MMC                 (1 << 7)
+#define HN_BATTERY_MOTOR               (1 << 8)
+#define HN_BATTERY_LED0                        (1 << 9)
+#define HN_BATTERY_LED1                        (1 << 10)
+#define HN_BATTERY_LED2                        (1 << 11)
+
+
+/*******************************************************************/
+typedef struct {
+    int         hPhone;
+    bool        Power;
+    struct termios  old_settings;
+} GSM_Device_DPRAMData;
+
+
+#endif /* _DPRAM_H_ */
+
+
diff --git a/vmodem/include/transport/gsmstate.h b/vmodem/include/transport/gsmstate.h
new file mode 100644 (file)
index 0000000..31e39bc
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*********************************************************************
+* $Id: gsmstate.h,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+*
+* Created : 20050329
+*
+* Copyright (C) Samsung Electronics
+*
+*********************************************************************/
+
+/* ------------------------------------------------------------------------
+   ¶óÀ̺귯¸®ÀÇ ±¸Á¶¸¦ ÀÌÇØÇϴµ¥ °¡Àå Áß¿äÇÑ Çì´õÆÄÀÏ.
+   ±¸Á¶Ã¼ _GSM_StateMachineÀÇ ÀνºÅϽº Çϳª·Î ¿òÁ÷À̴ ÇüÅÂÀÓ
+   µû¶ó¼­ ÀÌ ±¸Á¶Ã¼ÀÇ ¸â¹öµéÀ» °ËÅäÇϸé ÀüüÀûÀΠ±¸Á¶¸¦ ÆľÇÇÒ¼ö ÀÖ½¿.
+
+   È帧Àº ¾Æ·¡¿Í °°´Ù.
+   +----------------------------------------------------------------+
+   | Phone Layer (AT command generate)  | (AT command reply)        |
+   +----------------------------------------------------------------+
+       |                                      |
+       | Request                              | Reply Call
+       |                                      |
+   +----------------------------------------------------------------+
+   | AT Protocol layer                  | AT Procotol StateMachine  |
+   +----------------------------------------------------------------+
+       |                                      |
+       | Write                                | Read
+       |                                      |
+   +----------------------------------------------------------------+
+   | Device Layer (DPRAM)                                           |
+   +----------------------------------------------------------------+
+
+   ------------------------------------------------------------------------*/
+
+#ifndef __gsm_state_h
+#define __gsm_state_h
+
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <vgsm_error.h>
+
+typedef struct _GSM_StateMachine           GSM_StateMachine;
+
+//#include "protocol.h"
+ #include "dpram.h"
+
+#include <vgsm_network.h>
+#include <vgsm_sim.h>
+#include <vgsm_call.h>
+#include <vgsm_ss.h>
+//#include <mzgsmpb.h>
+#include <vgsm_display.h>
+
+/* --------------------------------------------------------------------------
+   Device layer
+   dpram read, write, settingÀÇ functionÀ» Æ÷ÇÔ
+   device fd°°Àº µ¥ÀÌŸ°¡ ÀÖ½¿. Æ¯º°È÷ ½Å°æ¾µ ºÎºÐÀº ¾ø½¿.
+   --------------------------------------------------------------------------*/
+/**
+ * Äڵ堳»¿ëÀº I519/I819ÀÇ Äڵ带 ±×´ë·Î »ç¿ëÇÏ¿´À¸¸ç ÇüÅ´ ¶óÀ̺귯¸®
+ * ÀÇ ±¸Á¶¿¡ ¸Â°Ô function pointer·Î ¼±¾ðÇÏ¿´´Ù.
+ */
+typedef struct {
+    GSM_Error (*OpenDevice)    (GSM_StateMachine *s);
+    GSM_Error (*CloseDevice)   (GSM_StateMachine *s);
+    int       (*ReadDevice)    (GSM_StateMachine *s, void *buf, size_t nbytes);
+    int       (*WriteDevice)   (GSM_StateMachine *s, void *buf, size_t nbytes);
+       int       (*PowerOnDevice) (GSM_StateMachine *s, int first_boot);
+       int       (*PowerOffDevice)(GSM_StateMachine *s);
+       bool      (*PowerStatus)   (GSM_StateMachine *s);
+    int       (*WriteMagicCode)(GSM_StateMachine *s, unsigned char );
+} GSM_Device_Functions;
+
+extern GSM_Device_Functions DPRAMDevice;
+
+//
+typedef struct {
+    union {
+        char fake;
+        GSM_Device_DPRAMData       DPRAM;
+    } Data;
+    GSM_Device_Functions *Functions;
+} GSM_Device;
+
+
+/* --------------------------------------------------------------------------
+                               Phone layer
+   --------------------------------------------------------------------------*/
+
+#define MAX_MANUFACTURER_LENGTH     50
+#define MAX_MODEL_LENGTH            50
+#define MAX_VERSION_LENGTH          50
+#define GSM_MAX_NUMBER_LENGTH       50
+/*
+ * Phone Data :
+ * PhoneServer¿¡¼­ ÂüÁ¶ÇؾߠÇÒ ¸ðµç µ¥ÀÌŸ¸¦ ¿©±â¿¡ ¸ð¾ÆµÎ¸é µÈ´Ù.
+ *
+ * ¾Æ·¡ÀÇ ±¸Á¶Ã¼ ¸â¹ö¿¡ Æ÷ÇԵȠº¯¼ö´Â Àü¿ª º¯¼ö »ç¿ëÇϵíÀÌ »ç¿ëÇϴ °ÍÀÌ
+ * ¸ñÀûÀÌ´Ù. I519/I819¿¡¼­ PhoneServer°¡ °¡Áö°í ÀÖ´ø µ¥ÀÌŸ¸¦ ¾Æ·¡ÀÇ ±¸Á¶Ã¼¿¡
+ * ¸ô¾Æ¼­ »ç¿ëÇϸ頿ëÀÌÇÏ´Ù.
+ */
+typedef struct {
+    double VerNum;
+    bool ExternalMode;
+    bool EnableCLIP;
+    bool EnableCallWaiting;
+    bool EnableUSSD;
+    int  AocMode;
+    bool EnableCSSI;
+    bool EnableCSSU;
+    GSM_Error DispatchError;
+    int  NetworkRegistration;
+    char Manufacturer[MAX_MANUFACTURER_LENGTH];
+    char Model[MAX_MODEL_LENGTH];
+    char Version[MAX_VERSION_LENGTH];
+    char * AT_Result;
+    char * External_Result;
+    bool FacLockStatus;
+    bool PBReady;
+    int  PIN_retry;
+    unsigned short CMECode;
+    unsigned short CMSCode;
+    bool PhonePower;
+    bool RamDump;
+    bool TCInfo;
+    char dumpaddr[256];
+
+    int  ALS;
+    int  Band;
+    int                      ArrayIndex;
+    bool PBMirroringDone;
+    bool AutoRedial;
+/* 
+    GSM_PHONEBOOK_ALL       *PBAllItem;
+    GSM_PB_ONE_ITEM         *PBOneItem;
+    GSM_PB_StorageInfo      *pbinfo;
+    GSM_SM_StorageInfo      *sminfo;
+*/
+//    GSM_CLIR_Data           *CLIRData;
+//   GSM_AOC_Data            *AocData;
+    gsm_call_list_t            *CallList;
+//    GSM_CCWAList            *CCWAList;
+//    GSM_CCFCList            *CCFCList;
+//    GSM_NetworkReg          *NetworkInfo;   // Network Info
+/*
+    GSM_SecurityCodeType    *SecurityStatus; // Security Status
+*/
+//    GSM_CurrentOperator     *OperatorInfo;
+/*
+    GSM_CRSM_Result         *CRSM_Result;
+*/
+//    GSM_IndicatorEvent      *IndValue;
+//    GSM_Protocol_Message    *RequestMsg;
+//    GSM_Protocol_Message    *SentMsg;
+//    GSM_Phone_RequestID     RequestID;
+} GSM_Phone_Data;
+
+// phone function
+
+/*
+// »ç¿ëÀÚ ¿¹¾à ¿µ¿ª
+typedef struct {
+    GSM_Error (*SetIncomingCall)    (GSM_StateMachine *s, bool enable);
+} GSM_AT_Functions_User;
+*/
+
+
+/**
+ * User defined function set, which use making notification packet for
+ * phone client(e.g dialer, indicator, smsdaemon, etc..)
+ */
+// extern GSM_AT_Functions_User    FuncUser;
+
+/**
+ * Set of AT command wrapper.
+ */
+
+
+
+typedef struct {
+    GSM_Phone_Data           Data;
+} GSM_Phone;
+
+
+
+// °¡Àå »óÀ§ÀÇ ±¸Á¶Ã¼
+struct _GSM_StateMachine {
+    bool opened;    //
+    int  ReplyNum;  // AT command¸¦ È£ÃâÇÒ¶§ÀǠȽ¼ö. Åë»ó 1ȸÀÌ´Ù. »èÁ¦ °ËÅä
+    GSM_Device             Device;
+    GSM_Phone              Phone;
+};
+
+/* ------------------------ Others ---------------------- */
+
+GSM_Error GSM_InitConnection        (GSM_StateMachine *s, int ReplyNum);
+GSM_Error GSM_TerminateConnection   (GSM_StateMachine *s);
+
+void GSM_OSErrorInfo(GSM_StateMachine *s, char const* description);
+
+#endif
diff --git a/vmodem/include/transport/onedram.h b/vmodem/include/transport/onedram.h
new file mode 100644 (file)
index 0000000..82f1570
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/* *   ondram.h                * */
+#ifndef _ONEDRAM_H_
+#define _ONEDRAM_H_
+
+#define DEBUG_TITLE    "VGSM"
+
+#define ONEDRAM_IP "127.0.0.1"
+#define ONEDRAM_PORT 7777
+
+#define UART_PSI_IP "127.0.0.1"
+#define UART_PSI_PORT 7776
+
+#define BUFFER_SIZE 1024
+#define CONNECT_AT 0x1234ABCD
+#define CONNECT_RES 0xABCD1234
+
+
+#define RAMDUMP_YES 0x00BB
+#define RAMDUMP_NO  0x00CC
+
+#define IND                            0x30
+#define VERS                   0xf0
+#define CRC_OK                 0x01
+#define CRC_ERR                        0xff
+
+#define UART_PSI_RETRY         20
+#define InfoSize 0x16
+
+int UART_PSI_read(int AT_socket, void *buf, int nbytes);
+int UART_PSI_write(int AT_socket, void *buf, int nbytes);
+int UART_PSI_load (void);
+
+static GSM_Error onedram_close(GSM_StateMachine *s);
+static GSM_Error onedram_open (GSM_StateMachine *s);
+static int onedram_poweron(GSM_StateMachine * s, int first_boot);
+static int onedram_poweroff(GSM_StateMachine * s);
+static int onedram_read(GSM_StateMachine *s, void *buf, size_t nbytes);
+static int onedram_write(GSM_StateMachine *s, void *buf, size_t nbytes);
+static bool onedram_powerstatus(GSM_StateMachine *s);
+static int onedram_write_magic_code(GSM_StateMachine * s, unsigned char req);
+
+#endif /* _ONEDRAM_H_ */
+
+
+
diff --git a/vmodem/oem/oem_rx_call.c b/vmodem/oem/oem_rx_call.c
new file mode 100644 (file)
index 0000000..1eb4f1a
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_rx_call.c */
+
+#include "server_rx_call.h"
+#include "oem_rx_call.h"
+
+int  oem_rx_call_list_get(void)
+{
+       return server_rx_call_list_get();
+}
+
+int oem_rx_call_answer_exec(void)
+{
+       return server_rx_call_answer_exec();
+}
+
+int oem_rx_call_originate_exec(void * ptr_data, int data_len)
+{
+       return server_rx_call_originate_exec(ptr_data, data_len);
+}
+
+int oem_rx_call_release_exec(void)
+{
+       return server_rx_call_release_exec();
+}
+
+int oem_rx_call_burst_dtmf_exec(void)
+{
+       return server_rx_call_burst_dtmf_exec();
+}
+
+int oem_rx_call_line_id_set(void * ptr_data, int data_len)
+{
+       return server_rx_call_line_id_set(ptr_data, data_len);
+}
+
+int oem_rx_call_line_id_get(void)
+{
+       return server_rx_call_line_id_get();
+}
+
+
+
diff --git a/vmodem/oem/oem_rx_data.c b/vmodem/oem/oem_rx_data.c
new file mode 100644 (file)
index 0000000..872f68f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_data.h"
+#include "oem_rx_data.h"
+
+int oem_rx_data_GetDataCallStatus(void * ptr_data, int data_len)
+{
+       return server_rx_data_GetDataCallStatus(ptr_data, data_len);
+}
diff --git a/vmodem/oem/oem_rx_display.c b/vmodem/oem/oem_rx_display.c
new file mode 100644 (file)
index 0000000..4e9a30f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_rx_display.c */
+
+#include "server_rx_display.h"
+#include "oem_rx_display.h"
+
+int  oem_rx_display_icon_info_get(void)
+{
+       return server_rx_display_icon_info_get();
+}
diff --git a/vmodem/oem/oem_rx_gprs.c b/vmodem/oem/oem_rx_gprs.c
new file mode 100644 (file)
index 0000000..bfb50be
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_gprs.h"
+#include "oem_rx_gprs.h"
+
+int oem_rx_gprs_SetPDPContext(void * ptr_data, int data_len)
+{
+       return server_rx_gprs_SetPDPContext(ptr_data, data_len);
+}
+
+int oem_rx_gprs_SetPSActDeact(void * ptr_data, int data_len)
+{
+       return server_rx_gprs_SetPSActDeact(ptr_data, data_len);
+}
diff --git a/vmodem/oem/oem_rx_misc.c b/vmodem/oem/oem_rx_misc.c
new file mode 100644 (file)
index 0000000..b4cf8e4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_misc.h"
+#include "oem_rx_misc.h"
+
+int oem_rx_misc_me_version(unsigned char flags)
+{
+       return server_rx_misc_me_version(flags);
+}
diff --git a/vmodem/oem/oem_rx_network.c b/vmodem/oem/oem_rx_network.c
new file mode 100644 (file)
index 0000000..90c6389
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_rx_network.c */
+
+#include "logmsg.h"
+#include "server_rx_network.h"
+#include "oem_rx_network.h"
+#include "oem_tx_network.h"
+
+int  oem_rx_net_plmn_list_get(void)
+{
+       return server_rx_net_plmn_list_get();
+}
+
+int  oem_rx_net_reg_get(void)
+{
+       return server_rx_net_reg_get();
+}
+
+/* Update for public open */
+/*  WIRELESS */
+static const unsigned char default_identity[64] = { 
+       0x01, 0x01, 0x00, 0x10, 0x02, 0xd7, 0xa4, 0xb4, 0xc8, 0x2c, 
+       0x4e, 0xa7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+       0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 
+       0x31, 0x23 };
+
+int  oem_rx_net_current_plmn_get(void)
+{
+       int ret;
+
+       ret = server_rx_net_current_plmn_get();
+
+       return ret;
+}
+
+int  oem_rx_net_plmn_selection_get(void)
+{
+       return server_rx_net_plmn_selection_get();
+}
+
+int oem_rx_net_plmn_selection_set(void * ptr_data, int data_len)
+{
+       return server_rx_net_plmn_selection_set(ptr_data, data_len);
+}
+
+int  oem_rx_net_band_set(void * ptr_data, int data_len)
+{
+       return server_rx_net_band_set(ptr_data, data_len);
+}
+
+int  oem_rx_net_service_domain_get(void)
+{
+       return server_rx_net_service_domain_get();
+}
+
+int  oem_rx_net_band_get(void)
+{
+       return server_rx_net_band_get();
+}
+
+int  oem_rx_net_mode_sel_get(char * api)
+{
+       return server_rx_net_mode_sel_get(api);
+}
+
+int  oem_rx_net_mode_sel_set(char * api)
+{
+       return server_rx_net_mode_sel_set(api);
+}
+
+int  oem_rx_net_pref_plmn_set(char * api)
+{
+       return server_rx_net_pref_plmn_set(api);
+}
+
+int  oem_rx_net_pref_plmn_get(char * api)
+{
+       return server_rx_net_pref_plmn_get(api);
+}
+
diff --git a/vmodem/oem/oem_rx_phonebook.c b/vmodem/oem/oem_rx_phonebook.c
new file mode 100644 (file)
index 0000000..cb0d731
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_phonebook.h"
+#include "server_common_security.h"
+#include "oem_rx_phonebook.h"
+
+int oem_rx_sim_pb_get_access_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_get_access_req(ptr_data, data_len);
+}
+
+
+int oem_rx_sim_pb_set_access_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_set_access_req(ptr_data, data_len);
+}
+
+
+int oem_rx_sim_pb_get_storage_cnt_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_get_storage_cnt_req(ptr_data, data_len);
+}
+
+
+int oem_rx_sim_pb_get_entry_info_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_get_entry_info_req(ptr_data, data_len);
+}
+
+
+int oem_rx_sim_pb_get_storage_list_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_get_storage_list_req(ptr_data, data_len);
+}
+
+/**************************************090226*************************************************/
+int oem_rx_sim_pb_exec_access_req(void* ptr_data, int data_len)
+{
+       unsigned char *p = (unsigned char*)(ptr_data);
+       int sim_mode = p[0];                            // action type or mode
+
+       SIM_DEBUG("\n");
+       switch(sim_mode)
+       {
+               case 0x03:      //TAPI_SIM_PB_ACCESS_MODE_EDIT:
+                       return server_rx_sim_pb_update_record("TelTapisimPBUpdateRecord");
+               break;
+               case 0x02:      //TAPI_SIM_PB_ACCESS_MODE_DEL:
+                       return server_rx_sim_pb_del_record("TelTapisimPBDeleteRecord");
+               break;
+
+       }
+       return 0;
+}
+
+int oem_rx_sim_pb_get_capability_info(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_pb_get_capability_info("TelTapiSimPbGet3GCapabilityInfo");
+}
+/************************************** 090226*************************************************/
diff --git a/vmodem/oem/oem_rx_power.c b/vmodem/oem/oem_rx_power.c
new file mode 100644 (file)
index 0000000..cc76115
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_rx_power.c */
+
+#include "server_rx_power.h"
+#include "oem_rx_power.h"
+#include "logmsg.h"
+
+int oem_rx_power_up_exec(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return server_rx_power_up_exec();
+}
+
+int oem_rx_online_exec(unsigned char status)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return server_rx_online_exec(status);
+}
diff --git a/vmodem/oem/oem_rx_security.c b/vmodem/oem/oem_rx_security.c
new file mode 100644 (file)
index 0000000..7a0bc5a
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_security.h"
+#include "oem_rx_security.h"
+#include "server_common_security.h"
+
+int oem_rx_sim_sec_get_imsi_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_get_imsi_req(ptr_data, data_len);
+}
+
+int oem_rx_sim_sec_set_pin_status_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_set_pin_status_req(ptr_data, data_len);
+}
+
+int oem_rx_sim_sec_get_pin_status_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_get_pin_status_req (ptr_data, data_len);
+}
+
+int oem_rx_sim_sec_get_lock_info_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_get_lock_info_req(ptr_data, data_len);
+}
+
+int oem_rx_sim_sec_change_password_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_change_password_req(ptr_data, data_len);
+}
+
+int oem_rx_sim_sec_get_phone_lock_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return server_rx_sim_sec_get_phone_lock_req(ptr_data, data_len);
+}
+
+
diff --git a/vmodem/oem/oem_rx_sms.c b/vmodem/oem/oem_rx_sms.c
new file mode 100644 (file)
index 0000000..60228f6
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_rx_sms.h"
+#include "oem_rx_sms.h"
+
+int oem_rx_sms_SendMsg(void * ptr_data, int data_len)
+{
+ return server_rx_sms_SendMsg(ptr_data, data_len);
+}
+
+int oem_rx_sms_SCA(void * ptr_data, int data_len)
+{
+ return server_rx_sms_SCA(ptr_data, data_len);
+}
+
+int oem_rx_sms_DR(void * ptr_data, int data_len)
+{
+ return server_rx_sms_DR(ptr_data, data_len);
+}
+
+int oem_rx_sms_SCA_set(char* api)
+{
+ return server_rx_sms_SCA_set(api);
+}
+
+int oem_rx_sms_cbsetconfig(char *api)
+{
+ return server_rx_sms_cbsetconfig(api);
+}
+
+int oem_rx_sms_ressvcoption(char *api)
+{
+       return server_rx_sms_ressvcoption(api);
+}
+
+int oem_rx_sms_param_set(char *api)
+{
+       return server_rx_sms_param_set(api);
+}
+
+int oem_rx_sms_param_get(char *api)
+{
+       return server_rx_sms_param_get(api);
+}
+
+int oem_rx_sms_memstatus(char *api)
+{
+       return server_rx_sms_memstatus(api);
+}
+
+int oem_rx_sms_stored_msg_status(char *api)
+{
+       return server_rx_sms_stored_msg_status(api);
+}
+
+int oem_rx_sms_param_count(char *api)
+{
+       return server_rx_sms_param_count(api);
+}
+
+int oem_rx_sms_mem_status(char *api)
+{
+       return server_rx_sms_mem_status(api);
+}
diff --git a/vmodem/oem/oem_rx_ss.c b/vmodem/oem/oem_rx_ss.c
new file mode 100644 (file)
index 0000000..79a521d
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_rx_ss.c */
+
+#include "server_rx_call.h"
+#include "server_rx_ss.h"
+#include "oem_rx_ss.h"
+
+#include "vgsm_debug.h"
+
+int oem_rx_ss_manage_call_set(char* ptr_data, int data_len)
+{
+       return server_rx_ss_manage_call_set(ptr_data, data_len);
+}
+
+int oem_rx_ss_cw_get(int tel_class)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cw_get(tel_class);
+}
+
+int oem_rx_ss_cf_get(int tel_class, int cf_type)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cf_get(tel_class, cf_type);
+}
+
+int oem_rx_ss_cb_get(int tel_class, int cb_type)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cb_get(tel_class, cb_type);
+}
+
+int oem_rx_ss_cw_set(int tel_class, int ss_mode)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cw_set(tel_class, ss_mode);
+}
+
+/**************************************090226*************************************************/
+int oem_rx_ss_cli(char * api)
+{
+       return server_rx_ss_cli(api);
+}
+/**************************************090226*************************************************/
+
+
+//int oem_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)
+int oem_rx_ss_cf_set(int ss_mode, int type, int tel_class,  int replyTime, int num_len, char *number, int num_type)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cf_set(ss_mode, type, tel_class,  replyTime, num_len, number, num_type);
+}
+
+int oem_rx_ss_cb_set(int cb_type, int ss_mode, int tel_class, char *passwd)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cb_set(cb_type, ss_mode, tel_class, passwd);
+}
+
+int oem_rx_ss_cb_passwd_set(char* curr_passwd, char* new_passwd)
+{
+       VGSM_DEBUG("\n");
+       return server_rx_ss_cb_passwd_set(curr_passwd, new_passwd);
+}
+
+
diff --git a/vmodem/oem/oem_tx_call.c b/vmodem/oem/oem_tx_call.c
new file mode 100644 (file)
index 0000000..b96e3f9
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_tx_call.c */
+
+#include "oem_tx_call.h"
+#include "at_tx_call.h"
+
+int oem_tx_call_incoming_noti(void *data, int len)
+{
+       return at_tx_call_incoming_noti(data, len);     
+}
+
+int oem_tx_call_waiting_noti(void *data, int len)
+{
+       return at_tx_call_waiting_noti(data, len);
+}
+
+int oem_tx_call_list_noti(void *data, int len)
+{      
+       return at_tx_call_list_noti(data, len);
+}
+
+int oem_tx_call_list_resp(void *data, int len)
+{
+       return at_tx_call_list_resp(data, len);
+}
+
+int oem_tx_call_status_noti(void *data, int len)
+{
+       return at_tx_call_status_noti(data, len);
+}
+
+int oem_tx_call_burst_dtmf_noti(void *data, int len)
+{
+       return at_tx_call_burst_dtmf_noti(data, len);
+
+}
+
+int oem_tx_call_line_id_resp(void *data, int len)
+{
+       return at_tx_call_line_id_resp(data, len);
+
+}
+
+int oem_tx_call_gen_resp(char* resp)
+{
+       return at_tx_call_gen_resp(resp);
+}
+
diff --git a/vmodem/oem/oem_tx_data.c b/vmodem/oem/oem_tx_data.c
new file mode 100644 (file)
index 0000000..3abebe7
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_tx_data.h"
+#include "oem_tx_data.h"
+
+int oem_tx_data_CallStatus(void *data, int len)
+{
+       return at_tx_data_CallStatus(data, len);
+}
+
+int oem_tx_data_DataCallStatus(void *data, int len)
+{
+       return at_tx_data_DataCallStatus(data, len);
+}
diff --git a/vmodem/oem/oem_tx_display.c b/vmodem/oem/oem_tx_display.c
new file mode 100644 (file)
index 0000000..699a671
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_tx_display.c */
+
+#include "at_tx_display.h"
+#include "oem_tx_display.h"
+
+int oem_tx_display_icon_info_noti(void *data, int len)
+{
+       return at_tx_display_icon_info_noti(data, len);
+}
+
+int oem_tx_display_icon_info_resp(void *data, int len)
+{
+       return at_tx_display_icon_info_resp(data, len);
+}
+
+
diff --git a/vmodem/oem/oem_tx_gprs.c b/vmodem/oem/oem_tx_gprs.c
new file mode 100644 (file)
index 0000000..888e7dc
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_tx_gprs.h"
+#include "oem_tx_gprs.h"
+
+int oem_tx_gprs_IPConfigurationNotify(void *data, int len)
+{
+       return at_tx_gprs_IPConfigurationNotify(data, len);
+}
+
+
diff --git a/vmodem/oem/oem_tx_misc.c b/vmodem/oem/oem_tx_misc.c
new file mode 100644 (file)
index 0000000..c2f02c5
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "oem_tx_misc.h"
+#include "at_tx_misc.h"
+
+int oem_tx_misc_version(void *data, int len)
+{
+       return at_tx_misc_version(data, len);
+}
diff --git a/vmodem/oem/oem_tx_network.c b/vmodem/oem/oem_tx_network.c
new file mode 100644 (file)
index 0000000..060c85c
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_tx_network.c */
+
+#include "at_tx_network.h"
+#include "oem_tx_network.h"
+
+int oem_tx_net_plmn_list_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_plmn_list_noti(data, len);
+}
+
+int oem_tx_net_plmn_list_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_plmn_list_resp(data, len);
+}
+
+int oem_tx_net_reg_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+        return at_tx_net_reg_noti(data, len);
+}
+
+int oem_tx_net_reg_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_reg_resp(data, len);
+}
+
+int oem_tx_net_current_plmn_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_current_plmn_noti(data, len);
+}
+
+int oem_tx_net_current_plmn_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_current_plmn_resp(data, len);
+}
+
+int oem_tx_net_plmn_selection_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_plmn_selection_resp(data, len);
+}
+
+int oem_tx_net_gen_phone_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_gen_resp(data, len);
+}
+
+int oem_tx_net_current_nitz_noti(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_current_nitz_noti(data, len);
+}
+
+int oem_tx_net_band_get_resp(void *data, int len)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return at_tx_net_band_get_resp(data, len);
+}
diff --git a/vmodem/oem/oem_tx_phonebook.c b/vmodem/oem/oem_tx_phonebook.c
new file mode 100644 (file)
index 0000000..a3ebcc2
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm_pb.h"
+#include "at_tx_phonebook.h"
+#include "oem_tx_phonebook.h"
+#include "server_common_security.h"
+
+int oem_tx_sim_pb_get_storage_cnt_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_pb_get_storage_cnt_res(ptr_data, data_len);
+}
+
+int oem_tx_sim_pb_get_entry_info_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_pb_get_entry_info_res(ptr_data, data_len);
+}
+
+int oem_tx_sim_pb_get_storage_list_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_pb_get_storage_list_res(ptr_data, data_len);
+}
+
+int oem_tx_sim_pb_set_access_res(int error)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_pb_set_access_res(error);
+}
+
+int oem_tx_sim_pb_get_access_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_pb_get_access_res(ptr_data, data_len);
+}
diff --git a/vmodem/oem/oem_tx_power.c b/vmodem/oem/oem_tx_power.c
new file mode 100644 (file)
index 0000000..17bc5d9
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_tx_power.c */
+
+#include "oem_tx_power.h"
+#include "at_tx_power.h"
+#include <stdlib.h>
+
+int oem_tx_power_up_resp(void *data, int len)
+{
+       return at_tx_power_up_resp(data, len);
+}
+
+int oem_tx_power_online_noti(void *data, int len)
+{
+       return at_tx_power_online_noti(data, len);
+}
+
+int oem_tx_battery_status_noti(void *data, int len)
+{
+       return at_tx_battery_status_noti(data, len);
+}
diff --git a/vmodem/oem/oem_tx_security.c b/vmodem/oem/oem_tx_security.c
new file mode 100644 (file)
index 0000000..cc82c89
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_tx_security.h"
+#include "oem_tx_security.h"
+#include "server_common_security.h"
+
+int oem_tx_sim_sec_get_imsi_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_get_imsi_res(ptr_data, data_len);
+}
+
+
+int oem_tx_sim_sec_set_pin_status_res(int error)
+{
+       SIM_DEBUG("error value=[%x]\n",error);
+       return at_tx_sim_sec_set_pin_status_res(error);
+}
+
+
+int oem_tx_sim_sec_get_pin_status_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_get_pin_status_res(ptr_data, data_len);
+}
+
+
+int oem_tx_sim_sec_get_lock_info_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_get_lock_info_res(ptr_data, data_len);
+}
+
+
+int oem_tx_sim_sec_change_password_res(void* ptr_data)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_change_password_res(ptr_data);
+}
+
+
+int oem_tx_sim_sec_set_phone_lock_res(int error)
+{
+       SIM_DEBUG("error value=[%x]\n",error);
+       return at_tx_sim_sec_set_phone_lock_res(error);
+}
+
+
+int oem_tx_sim_sec_get_phone_lock_res(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_get_phone_lock_res(ptr_data, data_len);
+}
+
+
+int oem_tx_sim_sec_set_rsim_access_res(int error)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_set_rsim_access_res(error);
+}
+
+
+int oem_tx_sim_sec_card_type_noti(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_card_type_noti(ptr_data, data_len);
+}
+
+
+int oem_tx_sim_sec_pin_status_noti(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+       return at_tx_sim_sec_pin_status_noti(ptr_data, data_len);
+}
+
diff --git a/vmodem/oem/oem_tx_sms.c b/vmodem/oem/oem_tx_sms.c
new file mode 100644 (file)
index 0000000..8ecb857
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "at_tx_sms.h"
+#include "oem_tx_sms.h"
+
+int oem_tx_sms_deviceReady(void *data, int len)
+{
+       return at_tx_sms_deviceReady(data, len);
+}
+
+int oem_tx_sms_NotiIncomingMsg(void *data, int len)
+{
+       return at_tx_sms_NotiIncomingMsg(data, len);
+}
+
+int oem_tx_sms_sendDeliverReport(void *data, int len)
+{
+       return at_tx_sms_sendDeliverReport(data, len);
+}
+
+int oem_tx_sms_sendMsg(void *data, int len)
+{
+       return at_tx_sms_sendMsg(data, len);
+}
+
+int oem_tx_sms_sendCBSMsg(void *data, int len)
+{
+       return at_tx_sms_sendCBSMsg(data, len);
+}
+
+int oem_tx_sms_SCA(void *data, int len)
+{
+       return at_tx_sms_SCA(data, len);
+}
+
diff --git a/vmodem/oem/oem_tx_ss.c b/vmodem/oem/oem_tx_ss.c
new file mode 100644 (file)
index 0000000..3b5a2f7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  oem_tx_ss.c */
+
+#include "at_tx_ss.h"
+#include "oem_tx_ss.h"
+
+int oem_tx_ss_ssinfo_noti(void *data, int len)
+{
+       return at_tx_ss_ssinfo_noti(data, len);
+}
+
+int oem_tx_ss_cw_resp(void *data, int len)
+{
+       return at_tx_ss_cw_resp(data, len);
+}
+
+int oem_tx_ss_cb_resp(void *data, int len)
+{
+       return at_tx_ss_cb_resp(data, len);
+}
+
+int oem_tx_ss_cf_resp(void *data, int len)
+{
+       return at_tx_ss_cf_resp(data, len);
+}
+
+int oem_tx_ss_gen_resp(void *data)
+{
+       return at_tx_ss_gen_resp(data);
+}
+
+int oem_tx_ss_aoc_noti(void *data, int len)
+{
+       return at_tx_ss_aoc_noti(data, len);
+}
diff --git a/vmodem/sat/apdu_tool.c b/vmodem/sat/apdu_tool.c
new file mode 100644 (file)
index 0000000..9c0d0b9
--- /dev/null
@@ -0,0 +1,1283 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/******************************************************************************
+ *     Includes
+ *****************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "sat_values.h"
+#include "sat_util.h"
+#include "logmsg.h"
+
+//
+//#include <alp/telephony.h>
+//#include <alp/textmgr.h>
+//#include <alp/pddk/phone_driver.h>
+//#include <gtk/gtk.h>
+
+
+//#include "phone_driver_debug.h"
+//
+
+
+struct _VGSMApduFragment;
+
+
+// SIMPLE-TLV data objects encoding function type
+typedef int(VGSMApduEncodeSimpleTLVObjectFunc)(struct _VGSMApduFragment* encoderP, struct _VGSMApduFragment* fragmentP);
+
+
+//////////////////////////////////////////////////////////////////////////
+// Temporary (to remove when the converters are available
+
+#define        chrAsterisk                                     0x002A
+#define        chrPlusSign                                     0x002B
+#define        chrCapital_W                            0x0057
+#define        chrQuestionMark                         0x003F
+#define        chrCircumflexAccent                     0x005E
+#define        chrDigitZero                            0x0030
+#define        chrNumberSign                           0x0023
+
+
+#define U8_LENGTH(c) \
+    ((int)(c)<=0x7f ? 1 : \
+        ((int)(c)<=0x7ff ? 2 : \
+            ((int)(c)<=0xd7ff ? 3 : \
+                ((int)(c)<=0xdfff || (int)(c)>0x10ffff ? 0 : \
+                    ((int)(c)<=0xffff ? 3 : 4)\
+                ) \
+            ) \
+        ) \
+    )
+
+
+/**
+ * Append a code point to a string, overwriting 1 to 4 bytes.
+ * The offset points to the current end of the string contents
+ * and is advanced (post-increment).
+ * "Unsafe" macro, assumes a valid code point and sufficient space in the string.
+ * Otherwise, the result is undefined.
+ *
+ * @param s const unsigned char * string buffer
+ * @param i string offset
+ * @param c code point to append
+ * @see U8_APPEND
+ * @stable ICU 2.4
+ */
+#define U8_APPEND_UNSAFE(s, i, c) { \
+    if((int)(c)<=0x7f) { \
+        (s)[(i)++]=(unsigned char)(c); \
+    } else { \
+        if((int)(c)<=0x7ff) { \
+            (s)[(i)++]=(unsigned char)(((c)>>6)|0xc0); \
+        } else { \
+            if((int)(c)<=0xffff) { \
+                (s)[(i)++]=(unsigned char)(((c)>>12)|0xe0); \
+            } else { \
+                (s)[(i)++]=(unsigned char)(((c)>>18)|0xf0); \
+                (s)[(i)++]=(unsigned char)((((c)>>12)&0x3f)|0x80); \
+            } \
+            (s)[(i)++]=(unsigned char)((((c)>>6)&0x3f)|0x80); \
+        } \
+        (s)[(i)++]=(unsigned char)(((c)&0x3f)|0x80); \
+    } \
+}
+
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////
+// APDU Simple object encoders
+// See chapter 12 of the 11.11 documentation
+
+// DCS: Data Coding Scheme for UD
+#define VGSM_SMS_DCS_MODE_MASK                                                 0x0C    // 00001100
+#define VGSM_SMS_DCS_MODE_7BIT                                                 0x00    // 00000000
+#define VGSM_SMS_DCS_MODE_8BIT                                                 0x04    // 00000100
+#define VGSM_SMS_DCS_MODE_UCS2BIT                                              0x08    // 00001000
+#define VGSM_SMS_DCS_MODE_RESERVEDBIT                                  0x0C    // 00001100
+
+#define VGSM_APDU_COMPREHENSION_REQUIRED_FLAG                          0x80
+
+
+// SIMPLE-TLV data objects count // TODO: enum last
+#define VGSM_ADPU_SIMPLE_TLV_COUNT                             0x3F
+
+// say an object buffer is dynamically allocated (even if its size <= 4)
+#define VGSM_APDU_DYNAMIC_BUFFER_FLAG                  0x01
+
+#define VGSM_MAX_DECODED_SIZE                                  256
+
+
+// BER-TLV data objects: { count of simple objects, simple-tlv object1, simple-tlv object 2, ... }
+typedef struct _VGSMApduFragment
+{
+       unsigned char                                   flags;                  // internal flags
+       unsigned char                                   tag;                    // BER or SIMPLE object tag
+       int                                                     length;                 // data length in bytes
+        struct _VGSMApduFragment*      son;                    // pointer to the first son
+        struct _VGSMApduFragment*      lson;                   // pointer to the last son
+        struct _VGSMApduFragment*      next;                   // pointer to the next brother
+       union buffer
+       {
+               char*                                           dataP;                  // data buffer
+               unsigned char                           data[4];                // for data size <= 4
+       } buffer;
+} VGSMApduFragment;
+
+typedef struct _VGSMApduEncoder
+{
+       SatApduEncoderCallback                  HLGetDataF;
+       void*                                                                   HLDataP;
+       char*                                                                   BERFormat;
+       VGSMApduFragment                                                BERObject;
+       int                                                                     BERFormatLength;
+} VGSMApduEncoder;
+
+#define prv_apdu_get_length_of_length(L) \
+       ((L) >= 128 ? 2 : 1)
+
+
+///////
+static int alp_pdrv_charset_convert(const char* srcTextP, size_t srcBytes, unsigned char srcEncoding, char* dstTextP, size_t* dstBytes, unsigned char dstEncoding, const char* substitutionStr, size_t substitutionLen)
+{
+       int     err             = 0;
+       /*
+       size_t                  srcSize = srcBytes;
+       int     err             = ALP_STATUS_OK;
+
+       if (dstEncoding == srcEncoding)
+       {
+
+               memcpy(dstTextP, srcTextP, srcBytes);
+               * dstBytes= srcBytes;
+               return ALP_STATUS_OK;
+       }
+
+       // check if UTF8 charset correspond to the local charset
+       if ((srcEncoding == VGSM_CHARSET_UTF8) || (dstEncoding == VGSM_CHARSET_UTF8))
+       {
+               const gchar *charset;
+
+               // Get the current character encoding
+               if (g_get_charset (&charset)==TRUE)  // g_get_charset seems to not work properly, always returns ANSI X3.4-1968
+               {
+                       TRACE( "alp_pdrv_charset_convert: [%s]:", charset);
+               }
+               else
+                       TRACE("alp_pdrv_charset_convert: [%s] not UTF-8 ! :", charset);
+       }
+
+
+       // Converting charset
+       if ((srcEncoding==VGSM_CHARSET_UCS2)&&(dstEncoding==VGSM_CHARSET_UTF8))
+       {
+               err=alp_txt_utf8_from_ucs2((unsigned char*)srcTextP, srcBytes, (unsigned char *)dstTextP, *dstBytes, dstBytes, 0);
+       }
+
+       else if ((srcEncoding==VGSM_CHARSET_UTF8)&&(dstEncoding==VGSM_CHARSET_UCS2))
+       {
+               err=alp_txt_utf8_to_ucs2((unsigned char*)srcTextP, srcBytes, (unsigned char *)dstTextP, *dstBytes, dstBytes, 0);
+       }
+
+       else if ((srcEncoding==VGSM_CHARSET_UTF8)&&(dstEncoding==VGSM_CHARSET_GSM))
+       {
+               alp_txt_utf8_to_gsm((char*)srcTextP, srcBytes, (char*)dstTextP, *dstBytes, dstBytes,0);
+
+       }
+
+       else if ((srcEncoding==VGSM_CHARSET_GSM)&&(dstEncoding==VGSM_CHARSET_UTF8))
+       {
+               err=alp_txt_utf8_from_gsm((char*)srcTextP, srcBytes, (char*)dstTextP, *dstBytes, dstBytes,0);
+       }
+
+       else if ((srcEncoding==VGSM_CHARSET_GSM)&&(dstEncoding==VGSM_CHARSET_UCS2))
+       {
+
+               size_t dstSize = *dstBytes;
+               unsigned char * intermediateTextP= malloc(dstSize);
+
+               //first convert GSM character into UTF8 character
+               err=alp_txt_utf8_from_gsm((char*)srcTextP, srcBytes, intermediateTextP, dstSize, &dstSize,0);
+
+               //then convert UTF8 character into UCS2 character
+               err=alp_txt_utf8_to_ucs2(intermediateTextP, dstSize, (unsigned char *)dstTextP, *dstBytes, dstBytes, 0);
+
+               if (intermediateTextP) free (intermediateTextP);
+
+       }
+
+       else
+       {
+               TRACE( "alp_pdrv_charset_convert: conversion not supported !");
+               return  ALP_STATUS_TEL_FEATURE_NOT_SUPPORTED;
+       }
+
+       TRACE( "alp_pdrv_charset_convert: Buffer after charset conversion, err[%lX], size[%lu]:", err, *dstBytes);
+       */
+       return err;
+}
+
+///////
+
+
+
+#if 0
+/*******************************************************************
+ * PURPOSE:
+ *
+ * PROTOTYPE:
+ * static int PrvGsmEncodeDCS7(unsigned char* Data,
+ *                     unsigned char* Text, int TextLen)
+ *
+ * PARAMETERS:
+ * Data                        IN              The 7bits packed buffer
+ * Text                        OUT             The 8bits unpacked buffer
+ * TextLen             IN              The bytes count of Text
+ *
+ *******************************************************************/
+
+static void prv_gsm_encode_dcs7(unsigned char* bufferP, int* bufferSize)
+{
+       unsigned char*  readP;
+       unsigned char*  writeP;
+       unsigned short  theWord = 0;
+       unsigned char   n;
+       int                     i;
+       int                     newSize = 0;
+
+       for (readP = bufferP, writeP = bufferP, i = 0; i < *bufferSize; i++, readP++)
+       {
+               n = i & 7;
+
+               if (n == 0)
+               {
+                       *writeP = *readP;
+                       *writeP &= 0x7F;
+               }
+               else
+               {
+                       theWord = (*readP & 0x7F) << (8 - n);
+                       *writeP |= (theWord & 0x00FF);
+                       *++writeP = theWord >> 8;
+               }
+
+               if (n != 7)
+                       newSize++;
+       }
+
+       *bufferSize = newSize;
+}
+#endif
+
+/*******************************************************************
+ * PURPOSE:
+ * Convert UTF8 Text to GSM/USCS2 etc
+ *
+ * PROTOTYPE:
+ * static int prv_convert_utf8_text(PrvApduEncoderType* encoderP,
+ *     PrvApduFragmentType* fragmentP)
+ *
+ * PARAMETERS:
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+static int prv_convert_utf8_text(VGSMApduEncoder* encoderP, VGSMApduFragment* fragmentP)
+{
+       char*                   dcsP = fragmentP->buffer.dataP;
+       unsigned char   destEncoding = VGSM_CHARSET_UTF8;
+       int                     packed = 1;
+//     int                     bufferSize=0;
+//     char*                   bufferP=0;
+       int             err = 0;
+
+/*
+       switch(*dcsP)
+       {
+       case SAT_RESP_TYPE_YES_NO_OPTION:
+               *dcsP = VGSM_SMS_DCS_MODE_7BIT;
+               break;
+
+       case SAT_RESP_TYPE_UNPACKED_DIGITS_ONLY:
+       case SAT_RESP_TYPE_UNPACKED_SMS_ALPHABET:
+               *dcsP = VGSM_SMS_DCS_MODE_7BIT;
+               destEncoding = VGSM_CHARSET_GSM;
+               break;
+
+       case SAT_RESP_TYPE_PACKED_DIGITS_ONLY:
+       case SAT_RESP_TYPE_PACKED_SMS_ALPHABET:
+               *dcsP = VGSM_SMS_DCS_MODE_8BIT;
+               destEncoding = VGSM_CHARSET_GSM;
+               packed = TRUE;
+               break;
+
+       case SAT_RESP_TYPE_UCS2_DIGITS_ONLY:
+       case SAT_RESP_TYPE_UCS2_ALPHABET:
+               *dcsP = VGSM_SMS_DCS_MODE_UCS2BIT;
+               destEncoding = VGSM_CHARSET_UCS2;
+               break;
+       }
+
+       if (destEncoding != VGSM_CHARSET_UTF8)
+       {
+               bufferSize = VGSM_APDU_CONVERTION_BUFFER_SIZE;
+               bufferP = (char*) malloc(bufferSize);
+
+               if (!bufferP)
+               {
+                       err = -1;
+                       goto finalize;
+               }
+
+               // the coding scheme
+               bufferP[0] = *dcsP;
+
+               // convert from utf8 to GSM or UCS2
+               if ((err = alp_pdrv_charset_convert((char*) (fragmentP->buffer.dataP + 1), (int) fragmentP->length - 1, VGSM_CHARSET_UTF8, (char*) bufferP + 1, &bufferSize, destEncoding, NULL, 0)) != TRUE)
+               {
+                       free(bufferP);
+                       goto finalize;
+               }
+
+               // replace the old buffer
+               free(fragmentP->buffer.dataP);
+               fragmentP->length = bufferSize + 1;
+               bufferP = realloc(bufferP, fragmentP->length);
+               fragmentP->buffer.dataP = bufferP;
+
+               // pack GSM
+               if (packed)
+                       prv_gsm_encode_dcs7((unsigned char*)bufferP, &fragmentP->length);
+       }
+       */
+
+       //temp..  only use UCS2BIT....
+       *dcsP = VGSM_SMS_DCS_MODE_8BIT;
+       destEncoding = VGSM_CHARSET_UTF8;
+       packed = 0;
+
+//finalize:
+       return err;
+}
+
+
+/*******************************************************************
+ * PURPOSE:
+ * Encode an apdu BER. Creates al TLV Objects and populate them.
+ *
+ * PROTOTYPE:
+ *
+ * PARAMETERS:
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+static int prv_apdu_encode_ber(VGSMApduEncoder* encoderP)
+{
+       int                     err = 0;
+       VGSMApduFragment*       fragmentP = &encoderP->BERObject;
+       unsigned char                   i;
+
+       for (i = 0; i < encoderP->BERFormatLength && err == 0; i++)
+       {
+               // create a new fragment
+               VGSMApduFragment* newFragmentP = (VGSMApduFragment*) malloc(sizeof(VGSMApduFragment));
+
+               if (newFragmentP == NULL)
+               {
+                       TRACE(MSGL_VGSM_ERR, "newFragmentP is NULL\n");
+                       err = -1;
+                       goto finalize;
+               }
+
+
+               memset(newFragmentP, 0, sizeof(VGSMApduFragment));
+
+               newFragmentP->tag = encoderP->BERFormat[i];
+
+               // insert it as the last son of fragmentP
+               if (!fragmentP->lson)
+                       fragmentP->son = fragmentP->lson = newFragmentP;
+               else
+                       fragmentP->lson = fragmentP->lson->next = newFragmentP;
+
+
+
+               // encode the simple-TLV object
+               if (newFragmentP->tag < VGSM_ADPU_SIMPLE_TLV_COUNT)
+               {
+                       if (newFragmentP->tag == SAT_TEXT_STRING || newFragmentP->tag == SAT_ITEM ||newFragmentP->tag == SAT_ALPHA_IDENTIFIER ||newFragmentP->tag == SAT_SMS_TPDU ||newFragmentP->tag == SAT_ADDRESS)
+                               newFragmentP->flags |= VGSM_APDU_DYNAMIC_BUFFER_FLAG;
+
+                       err = encoderP->HLGetDataF(newFragmentP->tag, (char *)&(newFragmentP->buffer.data[0]), &newFragmentP->length, encoderP->HLDataP);
+
+                       //
+                       TRACE(MSGL_VGSM_INFO, "Cnt is %d Tag is %x and len is %dand data is %s\n",i,newFragmentP->tag,newFragmentP->length,&(newFragmentP->buffer.data[0]));
+                       //
+
+                       switch(newFragmentP->tag)
+                       {
+                       case SAT_COMMAND_DETAILS:
+                               newFragmentP->tag = newFragmentP->buffer.data[3];       // get the CR flag
+                               break;
+
+                       case SAT_TEXT_STRING: //temp .... only use UTF8
+                               prv_convert_utf8_text(encoderP, newFragmentP);
+                               break;
+
+                       }
+               }
+               else
+                       {
+                               TRACE(MSGL_VGSM_ERR, "newFragmentP->tag > VGSM_ADPU_SIMPLE_TLV_COUNT\n");
+                               err = -1;
+                       }
+       }
+
+finalize:
+       return err;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Encode an object tag and length in hexadecimal string format
+ *
+ * PROTOTYPE:
+ * static char* AdpuSPrintHeader(char* destP, PrvApduFragmentType* objectP)
+ *
+ * PARAMETERS:
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+static char* prv_adpu_sprint_header(char* destP, VGSMApduFragment* objectP)
+{
+       char*                   writeP = destP;
+       unsigned char   len = (unsigned char) objectP->length;
+
+       writeP += sprintf(writeP, "%02X", objectP->tag | VGSM_APDU_COMPREHENSION_REQUIRED_FLAG);
+
+       if (len >= 128)
+               writeP += sprintf(writeP, "81");
+
+       writeP += sprintf(writeP, "%02X", len);
+
+       return writeP;
+}
+
+
+/*******************************************************************
+ * PURPOSE:
+ * Encode a TLV object body (bytes are converted to hexadecimal string)
+ *
+ * PROTOTYPE:
+ * static char* AdpuSPrintBody(char* destP, PrvApduFragmentType* objectP)
+ *
+ * PARAMETERS:
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+static char* prv_adpu_sprint_body(char* destP, VGSMApduFragment* objectP)
+{
+       char*   writeP = destP;
+       unsigned char*  readP;
+       unsigned char i;
+       unsigned char len = (unsigned char) objectP->length;
+
+
+       if (objectP->length > 4 || (objectP->flags & VGSM_APDU_DYNAMIC_BUFFER_FLAG) != 0)
+               readP = (unsigned char *)objectP->buffer.dataP;
+       else
+               readP = objectP->buffer.data;
+
+
+
+       for(i = 0; i < len; i++)
+        writeP += sprintf(writeP, "%02X", readP[i]);
+
+       return writeP;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Create a new Apdu encoder object
+ *
+ * PROTOTYPE:
+ * extern int PDrvCatApduEncode(unsigned char tag, PDrvCatApduEncoderCallbackType* getDataF,
+ *                     void* HLDataP, char** stringPP)
+ *
+ * PARAMETERS:
+ * tag                         IN                      The tag of the BER object to encode (example: SAT_MENU_SELECTION)
+ * getDataF                    IN                      A callback called when the encoder needs data.
+ *                                                             The encoder will ask for data using kAlpPDrvCatGetDataXXXX constants.
+ *                                                             ex. SAT_ITEMIdentifier
+ * HLDataP                     IN                      structure that will be passed to the callback. Generally, it's
+ *                                                             a telephony structure related to the BER object to encode
+ *                                                             (ex. a TelCatMenuSelectionType structure for the SAT_MENU_SELECTION
+ *                                                             BER object)
+ * stringPP                    OUT                     The decoder returns a newly allocated string. This string is the
+ *                                                             encoded object. This string must be freed with 'free' by the caller
+ *                                                             of PDrvCatApduEncode.
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+int sat_apdu_encode(unsigned char tag, SatApduEncoderCallback getDataF, void* HLDataP, char** stringPP)
+{
+       int                     err = 0;
+       VGSMApduEncoder         encoder;
+       VGSMApduFragment        *TLVObjectP, *nextP;
+       char                                    *hexP, *writeP;
+       int                                     size;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       // init the encoder
+       memset(&encoder, 0, sizeof(VGSMApduEncoder));
+
+       encoder.BERObject.tag = tag;   // ex)SAT_DISPLAY_TEXT
+       encoder.HLGetDataF = getDataF; //ex)cmd_display_text_callback
+       encoder.HLDataP = HLDataP; //ex)dp_text
+
+       // get the format for the BER command (depending on the tag)
+       err = (*(encoder.HLGetDataF))(SAT_GET_DATA_FORMAT, (char*) (&encoder.BERFormat), &encoder.BERFormatLength, encoder.HLDataP);
+
+       if (err)
+               {
+               TRACE(MSGL_VGSM_ERR, "get the format for the BER command\n");
+               goto finalize;
+               }
+
+       TRACE(MSGL_VGSM_INFO, "BERFormatLength=%d\n", encoder.BERFormatLength);
+
+
+
+
+       /////////////////////////////////////////////////////////////////
+
+
+       // encode BER object and TVL objects. TLV objects are assembled into a list
+       err = prv_apdu_encode_ber(&encoder);
+       if (err)
+               {
+               TRACE(MSGL_VGSM_ERR, "encode BER object and TVL objects. \n");
+               goto finalize;
+               }
+
+
+
+       // compute length of the BER object   //get length
+       encoder.BERObject.length = 0;
+       for (TLVObjectP = encoder.BERObject.son; TLVObjectP != NULL; TLVObjectP = TLVObjectP->next)
+               encoder.BERObject.length += TLVObjectP->length /* length of the object */+ prv_apdu_get_length_of_length(TLVObjectP->length) /* 1 or 2 */ + 1 /* tag */;
+
+
+       // alocate room for the whole object in ascii hex format (2 chars / byte) and a terminal 0.
+       if (tag != SAT_RESPONSE)
+               size=((encoder.BERObject.length + prv_apdu_get_length_of_length(encoder.BERObject.length) /* 1 or 2 */ + 1 /* BER tag */) * 2 + 1);
+       else size=((encoder.BERObject.length) * 2 + 1); //no BERObject header for SAT_RESPONSE
+
+       hexP = (char*) malloc(size);
+
+       if (!hexP)
+       {
+               err = -1;
+               TRACE(MSGL_VGSM_ERR, "\n!hexP\n");
+               goto finalize;
+       }
+
+//////////////////////////////////////////////////////////
+
+       // print the BER object
+       writeP = hexP;
+       if (tag != SAT_RESPONSE)
+               writeP = prv_adpu_sprint_header(writeP, &encoder.BERObject);
+
+       // print TLV Objects
+       for (TLVObjectP = encoder.BERObject.son; TLVObjectP != NULL; TLVObjectP = TLVObjectP->next)
+       {
+               TRACE(MSGL_VGSM_INFO, "TLVObjectP->length=%d\n", TLVObjectP->length);
+
+               writeP = prv_adpu_sprint_header(writeP, TLVObjectP);
+               writeP = prv_adpu_sprint_body(writeP, TLVObjectP);
+
+       }
+
+       //*writeP = 0;  // terminal 0  not useful since the sprintf terminate the string with '/0'
+       *stringPP = hexP;
+
+
+finalize:
+       // delete temporary objects
+
+       for (TLVObjectP = encoder.BERObject.son; TLVObjectP != NULL; )
+       {
+
+               if (TLVObjectP->length > 4 || (TLVObjectP->flags & VGSM_APDU_DYNAMIC_BUFFER_FLAG) != 0)
+                       {
+
+                            if(TLVObjectP->tag == SAT_TEXT_STRING)
+                               if(TLVObjectP->buffer.dataP)
+                                       free(TLVObjectP->buffer.dataP);
+                       }
+
+               nextP = TLVObjectP->next;
+
+               if(TLVObjectP)
+                       free(TLVObjectP);
+
+               TLVObjectP = nextP;
+
+       }
+
+
+       return err;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Read one or more bytes in an hex ascii stream
+ *
+ * PROTOTYPE:
+ * int PrvReadApduByte(PDrvApduDecoderType* decoderP, unsigned char length,
+ *                                     unsigned char* bufferToFillP)
+ *
+ * PARAMETERS:
+ *     decoderP                        IN/OUT  the apdu encoder object. It's updated to
+ *                                                             reflect read progress.
+ *
+ *     length                          IN              Count of bytes to read
+ *
+ *     bufferToFillP           OUT             Buffer in which copy the data
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+static int prv_read_apdu_byte(SatApduDecoder* decoderP, unsigned char length, char* bufferToFillP)
+{
+       if (length > decoderP->apduSizeInBytes)
+               length = decoderP->apduSizeInBytes;
+       memcpy(bufferToFillP, decoderP->apduReadP, length);
+       decoderP->apduReadP += length;
+       decoderP->apduSizeInBytes -= length;
+       return 0;
+}
+
+
+/*******************************************************************
+ * PURPOSE:
+ * Convert SMS 7bits packed to 8bits
+ *
+ * PROTOTYPE:
+ * static int PrvGsmDecodeDCS7(unsigned char* Data, int DataTextLen,
+ *                     unsigned char* Text, int TextLen)
+ *
+ * PARAMETERS:
+ * Data                        IN              The 7bits packed buffer
+ * Text                        OUT             The 8bits unpacked buffer
+ * TextLen             IN              The bytes count of Text
+ *
+ *******************************************************************/
+
+static int prv_gsm_decode_dcs7(unsigned char* Data, char* Text, int TextLen)
+{
+       unsigned short  theIndex;
+       unsigned short  theByte; // to hold left shifting
+       unsigned short  value_for_test;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       while (TextLen > 0)
+       {
+               theByte = 0;
+        for (theIndex  = 0; theIndex < 7 && TextLen > 0; theIndex++)   // there is 8 characters in seven bytes
+               {
+
+                       value_for_test= (unsigned short)(Data[theIndex] & 0x00FF);
+                       theByte |= (value_for_test << theIndex);        // nextbyte most_significant to rest
+                       *Text++ = (unsigned char) (theByte & 0x7F);                                                     // take least_significant 7-bit
+                       TRACE(MSGL_VGSM_INFO, "byte before=%x  byte after=%x, value_for_test=%x", (char)Data[theIndex],(char) (theByte & 0x7F), value_for_test);
+                       TextLen--;
+                       theByte >>= 7;                                                                                          // rest shift-7-bit to least_significant
+               }
+
+               if (TextLen > 0)
+               {
+                       *Text++ = (char) theByte;
+                       TextLen--;
+               }
+               Data += 7;
+       }
+
+       return 0;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Implement the TS11.11 Annex B UCS2 text conversion
+ *
+ * PROTOTYPE:
+ * static int PrvAlphaFieldsUCS2Convert(char* srcP,
+ *                     int srcSize, char* dstP, int* dstSize)
+ *
+ * PARAMETERS:
+ *     srcP                    IN              The source string
+ *  srcSize                    IN              The source string size
+ *  dstP                       OUT             The destination string
+ *  dstSize                    IN/OUT  The destination string size/real size
+ *
+ *******************************************************************/
+
+static int prv_alpha_fields_ucs2_convert(char* srcP, int srcSize, char* dstP, int* dstSize)
+{
+       int     err                     = 0;
+       char            UCS2Type        = (char) (*srcP);
+       char*           tmpString       = NULL;                 // ucs2 temp string
+
+       TRACE(MSGL_VGSM_INFO, "prv_alpha_fields_ucs2_convert: UCS2Type=%x",UCS2Type);
+
+       if (UCS2Type == (char) 0x80)
+       {
+               // jump over the 0x80 code
+               srcP++;
+               srcSize--;
+
+               TRACE(MSGL_VGSM_INFO, "no  GSM default alphabet characters");
+
+
+               // remove terminal 0xFF
+               while (srcSize > 0 && srcP[srcSize - 1] == (char) 0xFF)
+                       srcSize--;
+
+       }
+       else
+       {
+               // we  make a valid ucs2 string in tmpString
+
+               char                    charsToProcess = srcP[1];                       // length
+               unsigned short  ucs2Base;                                                       // ucs2 base to add to each char
+               char*                   writeP;                                                         // the write pointer on tmpString
+
+               if ((unsigned char) UCS2Type == (unsigned char) 0x81)
+               {
+                       ucs2Base = ((char) srcP[2]) << 7;                                       // bit 15-8 of the base
+                       srcP += 3;                                                                      // jump over code, length, base
+               }
+               else // UCS2Type = 0x82
+               {
+                       ucs2Base = (srcP[2] << 8) + srcP[3];            // the base is coded on 2 bytes, MSB first
+                       srcP += 4;                                                                      // jump over code, length, base
+               }
+
+               srcSize = charsToProcess * 2;                                   // allocate tmpString
+               writeP = tmpString = (char*) malloc(srcSize);
+               if (tmpString == NULL)
+               {
+                       err = -1;
+                       goto finalize;
+               }
+
+               while (charsToProcess > 0)
+               {
+                       if ((*srcP & 0x80) == 0)
+                       {
+                               // GSM alphabet: convert the character to an ucs2 one and add it to tmpString
+                               int ucs2Size = 2;
+
+                               err = alp_pdrv_charset_convert(srcP, 1, VGSM_CHARSET_GSM, writeP, (size_t *)&ucs2Size, VGSM_CHARSET_UCS2, NULL, 0);
+                               writeP += 2;
+                               TRACE(MSGL_VGSM_INFO, "convert GSM default alphabet characters (%x) into UCS2 character",srcP[0]);
+                       }
+                       else
+                       {
+                               // UCS2 char: compute the ucs2 char and add it
+                               unsigned short ucs2Char = ucs2Base + (((unsigned short) (*srcP)) & 0x007F);
+                               *writeP++ = (char) ((ucs2Char & 0xFF00) >> 8);
+                               *writeP++ = (char) (ucs2Char & 0x00FF);
+                       }
+                       charsToProcess--;
+                       srcP++;
+               }
+               srcP = tmpString;
+       }
+
+       err = alp_pdrv_charset_convert(srcP, srcSize, VGSM_CHARSET_UCS2, dstP, (size_t *)dstSize, VGSM_CHARSET_UTF8, NULL, 0);
+
+       if (tmpString)
+               free(tmpString);
+
+finalize:
+       return err;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Make text conversion (typically, 7bits->8bits, GSM to current)
+ *
+ * PROTOTYPE:
+ * void PrvConvertTextData(PDrvApduDecoderType* decoderP, unsigned char **dataP)
+ *
+ * PARAMETERS:
+ *     decoderP                        IN/OUT  the apdu encoder object
+ *  dataP                              IN/OUT  The initial buffer. In return, the converted buffer
+ *
+ *******************************************************************/
+
+static void prv_convert_text_data(SatApduDecoder* decoderP, char** dataP)
+{
+       int     err = 0;
+       char                    DCS = (*dataP)[0] & VGSM_SMS_DCS_MODE_MASK;                             // the codind scheme
+       char*                   encodedStringP = (*dataP) + 1;                                                          // the encoded string
+       int                     encodedStringSize = decoderP->currentObjectLength - 1;          // the length of the encoded string
+       int                     decodedStringSize;
+       char*                   decodedStringP;
+       int                     bufferSize = 1024;      // we have a max of 274 chars. But we think about multibytes locale charset encoding
+       char*                   bufferP;
+
+
+       if (DCS == VGSM_SMS_DCS_MODE_7BIT)
+       {
+               TRACE(MSGL_VGSM_INFO, "DCS = VGSM_SMS_DCS_MODE_7BIT");
+
+               decodedStringSize = (encodedStringSize * 8) / 7;
+
+               TRACE(MSGL_VGSM_INFO,  "decodedStringSize=%x encodedStringSize=%x",decodedStringSize,encodedStringSize);
+
+               // Handle the edge case where 8n-1 chars were transmited (in this case, decodedStringSize is now 8n):
+               // If the last char is a <cr>, it's just padding and we have to ignore it
+               if ((decodedStringSize & 0x07) == 0 && (encodedStringP[encodedStringSize - 1] & 0xFE) == (0x0D << 1))
+                       decodedStringSize--;    // ignore the last padding cr
+               decodedStringP = malloc(decodedStringSize);
+               err = prv_gsm_decode_dcs7((unsigned char*)encodedStringP, decodedStringP, decodedStringSize);
+               free(*dataP);
+               *dataP = decodedStringP;
+       }
+       else
+       {
+               memmove(*dataP, encodedStringP, encodedStringSize);
+               decodedStringSize = encodedStringSize;
+               decodedStringP = *dataP;
+       }
+
+       // convert from GSM or UCS2 to utf8 charset
+       bufferP = (char*) malloc(bufferSize);
+       if (!bufferP)
+               bufferSize = 0;
+       else
+       {
+               err = alp_pdrv_charset_convert((char*) decodedStringP, decodedStringSize, (DCS == VGSM_SMS_DCS_MODE_UCS2BIT) ? VGSM_CHARSET_UCS2 : VGSM_CHARSET_GSM, (char*) bufferP, (size_t *)&bufferSize, VGSM_CHARSET_UTF8, NULL, 0);
+       }
+
+       if (!err)
+       {
+               bufferP = (char*) realloc(bufferP, bufferSize + 1);
+               bufferP[bufferSize] = 0;
+               free(*dataP);
+               *dataP = bufferP;
+       }
+       else
+       {
+               free(bufferP);
+       }
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Make alpha identifier  conversion (typically, GSM to current)
+ *
+ * PROTOTYPE:
+ * static void PrvConvertAlphaData(unsigned char tag, PDrvApduDecoderType* decoderP,
+ *                                             unsigned char **dataP)
+ *
+ * PARAMETERS:
+ *  tag                                        IN              the object TLV tag
+ *     decoderP                        IN/OUT  the apdu encoder object
+ *  dataP                              IN/OUT  The initial buffer. In return, the converted buffer
+ *
+ *******************************************************************/
+
+static void prv_convert_alpha_data(unsigned char tag, SatApduDecoder* decoderP, char** dataP)
+{
+       int     err = 0;
+       int             bufferSize = 1024;      // we have a max of 274 chars. But we think about multibytes locale charset encoding
+       char*           bufferP;
+       char*           encodedStringP = *dataP;                                                                // the encoded string
+       int             encodedStringSize = decoderP->currentObjectLength;              // the length of the encoded string
+
+       bufferP = (char*) malloc(bufferSize);
+
+       if (tag == SAT_ITEM)
+       {
+               // there is 1 byte for itemId
+               *bufferP++ = *encodedStringP++;
+               encodedStringSize--;
+               bufferSize--;
+       }
+
+       if (((unsigned char)encodedStringP[0] >= (unsigned char) 0x80) && ((unsigned char) encodedStringP[0] <= (unsigned char) 0x82))
+       {
+               // UCS2 Annex B TS 11.11
+               err = prv_alpha_fields_ucs2_convert((char*) encodedStringP, encodedStringSize, (char*) bufferP, &bufferSize);
+       }
+       else
+       {
+               // GSM charset
+               err = alp_pdrv_charset_convert((char*) encodedStringP, encodedStringSize, VGSM_CHARSET_GSM, (char*) bufferP,(size_t *)&bufferSize, VGSM_CHARSET_UTF8, NULL, 0);
+       }
+
+       if (tag == SAT_ITEM)
+       {
+               bufferP--;
+               bufferSize++;
+       }
+
+       if (!err)
+       {
+               bufferP = (char*) realloc(bufferP, bufferSize + 1);
+               bufferP[bufferSize] = 0;
+
+               free(*dataP);
+               *dataP = bufferP;
+       }
+       else
+       {
+               free(bufferP);
+       }
+       TRACE(MSGL_VGSM_INFO, "done");
+
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Make dialing number/address conversion
+ *
+ * PROTOTYPE:
+ * int PrvConvertDialingNumberData(unsigned char tag,
+ *                                     PDrvApduDecoderType* decoderP, unsigned char **dataP)
+ *
+ * PARAMETERS:
+ *  tag                                        IN              the object TLV tag
+ *     decoderP                        IN/OUT  the apdu encoder object
+ *  dataP                              IN/OUT  The initial buffer. In return, the converted buffer
+ *
+ *******************************************************************/
+
+
+static void prv_convert_dialing_number_data(unsigned char tag, SatApduDecoder* decoderP, char** dataP)
+{
+       //int   err = 0;
+       int             bufferSize = 0;
+       char*           bufferP;
+       char*           encodedStringP = *dataP;                                                                // the encoded string
+       int             encodedStringSize = decoderP->currentObjectLength;              // the length of the encoded string
+       int     oneChar;
+       char            oneNibble;
+       char            nibbleIndex;
+
+       bufferP = (char*) malloc(VGSM_MAX_DECODED_SIZE);
+
+       if ((tag == SAT_ADDRESS)|| (tag==SAT_SS_STRING) || (tag == SAT_SUBADDRESS))
+       {
+               // handle the TON and NPI
+               if ((*encodedStringP & 0x70) == 0x10)
+                       U8_APPEND_UNSAFE(bufferP, bufferSize, chrPlusSign);
+
+               encodedStringP++;
+               encodedStringSize--;
+       }
+
+       if (tag == SAT_USSD_STRING)
+       {
+               //bypass the data coding scheme
+               encodedStringP++;
+               encodedStringSize--;
+       }
+
+       // read the address
+       for(; (encodedStringSize > 0) && (bufferSize < VGSM_MAX_DECODED_SIZE); encodedStringSize--, encodedStringP++)
+       {
+               // read the digit (BCD nibble)
+               for(nibbleIndex = 0; nibbleIndex < 2; nibbleIndex++)
+               {
+                       if (nibbleIndex == 0)
+                               oneNibble = (unsigned char)(*encodedStringP & 0x0F);
+                       else
+                               oneNibble = (unsigned char)((*encodedStringP >> 4)& 0x0F);
+
+                       // Convert the digit to Platform character
+                       switch(oneNibble)
+                       {
+                       case 0x0A:
+                               oneChar = chrAsterisk;
+                               break;
+                       case 0x0B:
+                               oneChar = chrNumberSign;
+                               break;
+                       case 0x0C:
+                               // DTMF Control Digits Separator
+                               oneChar = chrCapital_W;
+                               break;
+                       case 0x0D:
+                               // Wild character
+                               oneChar = chrQuestionMark;
+                               break;
+                       case 0x0E:
+                               // Expansion digit
+                               oneChar = chrCircumflexAccent;
+                               break;
+                       case 0x0F:
+                               // Endmark
+                               goto END;
+                       default:
+                               oneChar = chrDigitZero + (int)oneNibble;
+                               break;
+                       }
+                       // Append the new character to result
+                       if (bufferSize + U8_LENGTH(oneChar) < VGSM_MAX_DECODED_SIZE)
+                               U8_APPEND_UNSAFE(bufferP, bufferSize, oneChar);
+               }
+       }
+
+END:
+       //if (!err)
+       {
+               bufferP = (char*) realloc(bufferP, bufferSize + 1);
+               bufferP[bufferSize] = '\0';
+               free(*dataP);
+               *dataP = bufferP;
+               TRACE(MSGL_VGSM_INFO, "address decoded");
+
+
+               decoderP->currentObjectLength= bufferSize+1;
+
+       }
+#if 0
+       else
+       {
+               free(bufferP);
+       }
+#endif
+
+}
+
+
+
+/*******************************************************************
+ * PURPOSE:
+ * decode a BRV or TLV object
+ *
+ * PROTOTYPE:
+ * static int  PrvDecodeObject(PDrvApduDecoderType* decoderP)
+ *
+ * PARAMETERS:
+ *     decoderP                        IN/OUT  the apdu encoder object. It's updated to
+ *                                                             reflect read progress.
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+
+/* UNUSED */ int prv_decode_object(SatApduDecoder* decoderP);
+int prv_decode_object(SatApduDecoder* decoderP)
+{
+       unsigned char   tag;
+       char*                   dataP;
+       int             err = 0;
+
+       tag = decoderP->currentObjectTag;
+       if (tag >= 0x81 && tag <= 0xBE)         // take care about the CR flag
+               tag &= 0x7F;
+
+
+               // 0x01< TLV tag < 0x70              0xD0 < BER tag < 0xDF
+       if ((tag >= 0x01 && tag <= 0x70) || ((tag >= 0xD0 && tag <= 0xDF)))
+       {
+               // supported tags
+               if (decoderP->formatP == NULL || strchr((char*)decoderP->formatP, (char)tag))
+               {
+                       // if tag is referenced: call the callback
+
+
+
+                       if ((tag >= 0xD0 && tag <= 0xDF) || decoderP->currentObjectLength == 0)
+                       {
+                               // BER Object: No data, or empty TLV object
+                               dataP = NULL;
+                       }
+                       else
+                       {
+                               // non empty TLV Object: allocate the data buffer
+                               dataP = (char*) malloc(decoderP->currentObjectLength);
+                               if (!dataP)
+                               {
+                                       err = -1;
+                                       goto finalize;
+                               }
+                               // get the object bytes
+                               prv_read_apdu_byte(decoderP, decoderP->currentObjectLength, dataP);
+                               TRACE(MSGL_VGSM_INFO, "read apdu byte done");
+                       }
+
+                       if (dataP)
+                       {
+                               // decode text string
+                               if (tag == SAT_TEXT_STRING || tag == SAT_DEFAULT_TEXT)
+                                       prv_convert_text_data(decoderP, &dataP);
+                               else if (tag == SAT_ALPHA_IDENTIFIER || tag == SAT_ITEM || tag == SAT_URL)
+                                       prv_convert_alpha_data(tag, decoderP, &dataP);
+                               else if (tag == SAT_DTMF_STRING || tag == SAT_ADDRESS || tag == SAT_SUBADDRESS || tag == SAT_SS_STRING || tag == SAT_USSD_STRING )
+                                       prv_convert_dialing_number_data(tag, decoderP, &dataP);
+                       }
+
+                       TRACE(MSGL_VGSM_INFO, "call the callback");
+
+                       if (dataP!=NULL)
+                               TRACE(MSGL_VGSM_INFO, "%s %d\n", dataP , decoderP->currentObjectLength);
+
+                       // call the callback
+                       err = decoderP->HLSetDataF(tag, decoderP, dataP);
+
+                       // free allocated data
+                       if (dataP!=NULL) free(dataP);
+
+               }
+               else
+               {
+                       // pass the object (BER objects are not passed because we go into them to search for TLV objects)
+                       if (tag >= 0x01 && tag <= 0x3E)         // Simple TLV Object
+                       {
+                               decoderP->apduReadP += decoderP->currentObjectLength;
+                               decoderP->apduSizeInBytes -= decoderP->currentObjectLength;
+                       }
+               }
+       }
+       else
+       {
+               // unsupported tags
+               err = -1;               // TODO: error "unsupported tag"
+               goto finalize;
+       }
+
+finalize:
+       return err;
+}
+
+/*******************************************************************
+ * PURPOSE:
+ * Create a new Apdu decoder object
+ *
+ * PROTOTYPE:
+ * extern int PDrvCatApduDecode(unsigned char* apduP, int apduSizeInBytes,
+ *                     unsigned char* tags, PDrvCatApduDecoderCallbackType* setDataF, void* dataP)
+ *
+ * PARAMETERS:
+ * apduP               IN              apdu in binary format
+ *
+ * apduSizeInBytes     IN      count of apdu bytes
+ *
+ * tags                        IN              0 terminated array of tags. It's the set of tags of objects
+ *                                             the caller cares about. The callback will be called each time
+ *                                             an object tag in the adpu matches one of the tags in the array
+ *
+ * setDataF            IN              callback to call when a matching tag is found
+ *
+ * dataP               IN              The caller provides a structure that will be passed to
+ *                                             the callback. The callback normally fills this structure
+ *                                             with data found in objects.
+ *
+ * RETURNED:
+ *       error code
+ *
+ *******************************************************************/
+/*
+int sat_apdu_decode(char* apduP, int apduSizeInBytes, char* tags, SatApduDecoderCallback setDataF, void* dataP)
+{
+       SatApduDecoder  decoder;
+       int                     err = 0;
+
+       // init the decoder object
+       decoder.apduP = decoder.apduReadP = apduP;
+       decoder.apduSizeInBytes = apduSizeInBytes;
+       decoder.formatP = tags;
+       decoder.HLDataP = dataP;
+       decoder.HLSetDataF = setDataF;
+
+       // read objects one after one
+       while (decoder.apduSizeInBytes > 0 && err == 0)
+       {
+               // read the tag byte
+               if ((err = prv_read_apdu_byte(&decoder, 1, &decoder.currentObjectTag)) != 0)
+                       goto finalize;
+
+               TRACE( "sat_apdu_decode: decoder.currentObjectTag=%d", decoder.currentObjectTag);
+               //TRACE( (char*)TLVObjectP->buffer.data , TLVObjectP->length));
+
+               // read the object size
+               if ((err = prv_read_apdu_byte(&decoder, 1, &decoder.currentObjectLength)) != 0)
+                       goto finalize;
+
+               TRACE( "sat_apdu_decode: decoder.currentObjectLength=%ld", decoder.currentObjectLength);
+
+               if (decoder.currentObjectLength == 0x81)
+               {
+                       if ((err = prv_read_apdu_byte(&decoder, 1, &decoder.currentObjectLength)) != 0)
+                               goto finalize;
+                       TRACE( "sat_apdu_decode: decoder.currentObjectLength=%d", decoder.currentObjectLength);
+
+               }
+
+               // decode the object
+               err = prv_decode_object(&decoder);
+       }
+
+finalize:
+       TRACE( "sat_apdu_decode: error=%x",err);
+
+       return err;
+}
+*/
diff --git a/vmodem/sat/sat_util.c b/vmodem/sat/sat_util.c
new file mode 100644 (file)
index 0000000..7867c51
--- /dev/null
@@ -0,0 +1,3360 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <assert.h>
+#include <sys/time.h>
+#include "at_tx_func.h"
+
+#include "sat_util.h"
+#include "vgsm_sat.h"
+
+
+char sMbiz_getInkeyRespType[4] =
+{
+       SAT_RESP_TYPE_UNPACKED_DIGITS_ONLY,
+       SAT_RESP_TYPE_UNPACKED_SMS_ALPHABET,
+       SAT_RESP_TYPE_UCS2_DIGITS_ONLY,
+       SAT_RESP_TYPE_UCS2_ALPHABET
+};
+
+typedef struct MbizSetCmdResponseParamsTag
+{
+       SatCmdResponse* responseP;
+       void*                                   proactiveCmdP;
+} MbizSetCmdResponseParamsType;
+
+typedef struct MbizSetCmdResponseParamsTagInternal
+{
+       SatCmdResponseInternal* responseP;
+       void*                                   proactiveCmdP;
+} MbizSetCmdResponseParamsTypeInternal;
+
+char g_item_cnt;
+
+char MbizPrvSetCmdResponseFormat[16]   = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_RESULT };
+
+char   MenSelectionFormat[]    = { SAT_DEVICE_IDENTITIES, SAT_ITEM_IDENTIFIER, SAT_HELP_REQUEST };
+
+char   DisplayTextFormat[8]    = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_TEXT_STRING/*,SAT_ICON_IDENTIFIER,SAT_IMMEDIATE_RESPONSE, SAT_DURATION*/};
+
+char   GetInkeyFormat[8]       = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_TEXT_STRING/*,SAT_ICON_IDENTIFIER,SAT_IMMEDIATE_RESPONSE, SAT_DURATION*/};
+
+char   GetInputFormat[8]       = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_TEXT_STRING/*,SAT_ICON_IDENTIFIER,SAT_IMMEDIATE_RESPONSE, SAT_DURATION*/};
+
+char   SetUpMenuFormat[8]      = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_ALPHA_IDENTIFIER,SAT_ITEM};
+
+char   SendSMSFormat[8]        = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_ALPHA_IDENTIFIER,SAT_ADDRESS,SAT_SMS_TPDU};
+
+char   SetUpCallFormat[8]      = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES};
+
+char   MbizPrvEventDownloadFormat[]    = { SAT_EVENT_LIST, SAT_DEVICE_IDENTITIES, 0 };
+
+
+
+
+
+/******************************************************************************
+ * Function:   str_to_bin
+ *
+ * Description:        convert ASCII char to binary form(HEX)
+ *
+ * Parameters: char* iStringP          input; string format
+ *                             char *oBinP             output; binary format
+ ******************************************************************************/
+static int str_to_bin(char* iStringP, char **oBinPP, int *oBinLenP)
+{
+       int             stringLen, binLen;
+       char *          binP = NULL;
+       unsigned int    i;
+       char *          tmp = NULL;
+
+
+
+       stringLen       = (int)strlen((char *)iStringP);
+       binLen          = stringLen / 2;
+
+
+       binP= (char *)malloc(binLen);
+       if(binP == NULL)
+       {
+               TRACE(MSGL_VGSM_INFO, "memory allocation faillure");
+               return -1;
+       }
+       memset(binP, 0, binLen);
+
+       tmp = malloc(2 * sizeof(char));
+       for(i=0;i<binLen;i++){
+               memset(tmp, 0, 2);
+               memcpy(tmp, &iStringP[i*2], 2);
+               binP[i] = (char)strtol(tmp, NULL, 16);
+       }
+
+       if(tmp)
+               free(tmp);
+
+       // oBinPP's memory will be freed by the function which called str_to_bin().
+       *oBinPP = (char *)binP;
+       *oBinLenP = binLen;
+
+       TRACE(MSGL_VGSM_INFO, "output binary is");
+
+
+       return 0;
+}
+
+
+#if 0
+/******************************************************************************
+ * Function:   cmd_param_init
+ *
+ * Description:        Initialize a memory block for the sub-allocator
+ *
+ * Parameters: paramsP         a param block, defining the location
+ *                                                     and the size of the block
+ ******************************************************************************/
+
+static int cmd_param_init(SatCmdParams* paramsP)
+{
+       char*           blockP;
+       int             blockSize;
+       int*            queueP;
+       int*            headP;
+
+
+
+       blockP          = (char*) paramsP->cmdParamP;
+       TRACE( "blockP paramsP->cmdParamP = %s", blockP);
+
+       blockSize       = (int) (paramsP->cmdParamSize & ~3);
+       TRACE( "blockSize = %d", blockSize);
+
+       if (blockSize < 2 * sizeof(int))
+               return -1;
+
+       queueP  = (int*) (blockP + blockSize - sizeof(int));
+       headP   = queueP - 1;
+       *headP  = 0;
+       *queueP = blockSize - 2 * sizeof(int);
+
+       return TRUE;
+}
+
+
+/******************************************************************************
+ * Function:   get_cmd_param_size
+ *
+ * Description:        give the real size of the proactive command parameter
+ *
+ * Parameters: paramsP         a param block, defining the location
+ *                                                     and the size of the block
+ * Return      :       the real size used in the param block by the proactive command parameter
+ ******************************************************************************/
+
+static int get_cmd_param_size(SatCmdParams* paramsP)
+{
+       char*           blockP;
+       int             blockSize;
+       int*            queueP;
+       int*            headP;
+
+
+       blockP          = (char*) paramsP->cmdParamP;
+       blockSize               = (int) (paramsP->cmdParamSize & ~3);
+       queueP          = (int*) (blockP + blockSize - sizeof(int));
+       headP           = queueP - 1;
+
+       return (*headP);
+}
+
+/******************************************************************************
+ * Function:   cmd_param_alloc_head
+ *
+ * Description:        Allocate a sub-block at the begining of the block
+ *
+ * Parameters: paramsP         a param block, defining the location
+ *                                                     and the size of the block
+ *                             size            the size of the sub block to allocate
+ ******************************************************************************/
+
+static void* cmd_param_alloc_head(SatCmdParams* paramsP, int size)
+{
+       char*           blockP;
+       int             blockSize;
+       int*            queueP;
+       int*            headP;
+       int             p;
+
+       blockP          = (char*) paramsP->cmdParamP;
+       blockSize               = (int) (paramsP->cmdParamSize & ~3);
+       queueP          = (int*) (blockP + blockSize - sizeof(int));
+       headP           = queueP - 1;
+       p                       = *headP;
+
+       if (*headP + size >= *queueP)
+               return NULL;
+
+       *headP += size;
+
+       if (size & 3)
+               *headP += (int) (4 - (size & 3));
+
+       return blockP + p;
+}
+
+/******************************************************************************
+ * Function:   prv_cmd_param_alloc_queue
+ *
+ * Description:        Allocate a sub-block at the end of the block
+ *
+ * Parameters: paramsP         a param block, defining the location
+ *                                                     and the size of the block
+ *                             size            the size of the sub block to allocate
+ ******************************************************************************/
+
+static void* prv_cmd_param_alloc_queue(SatCmdParams* paramsP, int size)
+{
+       char*   blockP;
+       int     blockSize;
+       int*    queueP;
+       int*    headP;
+
+       alp_prv_mbiz_begin_proc(prv_cmd_param_alloc_queue);
+
+       blockP          = (char*) paramsP->cmdParamP;
+       blockSize       = (int) (paramsP->cmdParamSize & ~3);
+       queueP          = (int*) (blockP + blockSize - sizeof(int));
+       headP           = queueP - 1;
+
+       if (*queueP - size < *headP)
+               return NULL;
+
+       *queueP -= size;
+
+       if (size & 3)
+               *queueP -= (int) (4 - (size & 3));
+
+       return blockP + *queueP;
+}
+
+/******************************************************************************
+ * Function:   get_cmd_buffer
+ *
+ * Description:        Get bytes from a buffer and copy them in a sub-block
+ *
+ * Parameters: paramsP                 a param block, defining the location
+ *                                                             and the size of the block
+ *                             srcP                    The source buffer
+ *                             size                    the size of the sub block to allocate and fill
+ *                             destPP                  a reference to the sub block to allocate and fill
+ ******************************************************************************/
+
+static int get_cmd_buffer(SatCmdParams* paramsP, char* srcP, char size, char** destPP)
+{
+
+
+       *destPP = cmd_param_alloc_head(paramsP, size);
+
+       if (*destPP == NULL)
+               return -1;
+
+       memcpy(*destPP, srcP, size);
+
+       return TRUE;
+}
+
+
+
+static int  menu_selection_callback(int request, char* bufferP, int* bufferSize, SatMenuSelection* menuSelectionP)
+{
+       int err = TRUE;
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+                       *((char**) bufferP) = MenSelectionFormat;
+                       if (menuSelectionP->evtCode == SAT_MENU_SELECTION_HELP_REQUESTED)
+                   *bufferSize = 3;
+                       else
+                   *bufferSize = 2;
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+                       bufferP[0] = SAT_DEVICE_KEYPAD;
+                       bufferP[1] = SAT_DEVICE_SIM;
+                       break;
+
+               case SAT_ITEM_IDENTIFIER:
+                       *bufferSize = 1;
+                       *bufferP = menuSelectionP->appId;
+                       break;
+
+               case SAT_HELP_REQUEST:
+                       *bufferSize = 0;
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+}
+
+int   menu_selection( SatMenuSelection* iSelectionP , char *           apduStrP)
+{
+       char*           apduP;
+       int                     apduLen;
+       int     err = TRUE;
+
+//     char*           raw_packet = NULL;
+//     int                     raw_packet_size=0;
+
+
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser");
+       TRACE(MSGL_VGSM_INFO, "need help = %x, selected Item identifier = %x", iSelectionP->evtCode, iSelectionP->appId);
+
+       if ((err = sat_apdu_encode(SAT_MENU_SELECTION, (SatApduEncoderCallback) menu_selection_callback, iSelectionP, &apduStrP)) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+
+       }
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "str_to_bin failed with error (0x%08x).", err);
+
+               return err;
+
+       }
+
+       return err;
+
+
+}
+#endif
+
+/*
+//////
+static int set_cmd_response_callback(int request, char* bufferP, int16_t* bufferSize, MbizSetCmdResponseParamsType* paramsP)
+{
+       int err = TRUE;
+
+       switch (request)
+       {
+       case SAT_GET_DATA_FORMAT:
+               {
+               char* writeP = MbizPrvSetCmdResponseFormat + 3;
+               switch (paramsP->responseP->cmdId)
+               {
+               case SAT_CMD_GET_INKEY:
+               case SAT_CMD_GET_INPUT:
+                       if ((paramsP->responseP->resCode & 0xF0) == 0)
+                               *writeP++ = SAT_TEXT_STRING;
+                       break;
+
+               case SAT_CMD_SELECT_ITEM:
+                       if ((paramsP->responseP->resCode & 0xF0) == 0)
+                               *writeP++ = SAT_ITEM_IDENTIFIER;
+                       break;
+               }
+               *((char**) bufferP) = MbizPrvSetCmdResponseFormat;
+               *bufferSize = writeP - MbizPrvSetCmdResponseFormat;
+               break;
+               }
+
+       case SAT_COMMAND_DETAILS:
+               {
+               char* objectP = paramsP->proactiveCmdP;
+               char tag;
+
+               *bufferSize = 3;
+
+               if (objectP == NULL)
+                       err = -1;
+               else
+               {
+                       // get the original
+                       objectP += 4 + (objectP[1] == 0x81);
+                       tag = objectP[-2];
+                       *bufferP++ = *objectP++;
+                       *bufferP++ = *objectP++;
+                       *bufferP++ = *objectP;
+                       // The CR tag must be send back to the encoder in 4th byte
+                       *bufferP++ = tag;
+               }
+               break;
+               }
+
+       case SAT_DEVICE_IDENTITIES:
+               *bufferSize = 2;
+               bufferP[0] = SAT_DEVICE_ME;
+               bufferP[1] = SAT_DEVICE_SIM;
+               break;
+
+       case SAT_RESULT:
+               *bufferSize = 2;
+               bufferP[0] = paramsP->responseP->resCode;
+               bufferP[1] = paramsP->responseP->addInfo;
+               break;
+
+       case SAT_TEXT_STRING:
+               {
+               char** dataPP = (char**) bufferP;
+               char* dataP;
+
+               // Here the buffer MUST be allocated with malloc.
+               // The APDU encoder will free it
+               *bufferSize = paramsP->responseP->respSize + 1;
+               dataP = *dataPP = malloc(*bufferSize);
+               if (dataP)
+               {
+                       dataP[0] = paramsP->responseP->respType;
+                       memcpy(dataP + 1, paramsP->responseP->respP, paramsP->responseP->respSize);
+               }
+               else
+                       err = -1;
+               break;
+               }
+
+       case SAT_ITEM_IDENTIFIER:
+               *bufferSize = 1;
+               *bufferP = paramsP->responseP->itemIdentifier;
+               break;
+
+       default:
+               err = -1;
+               break;
+       }
+
+       return err;
+}
+*/
+
+#if 0
+void prtbin(unsigned char dt,char * bin)
+{
+       int i;
+
+        for (i=7; i>=0; i--)
+        {
+         if (dt&0x80)  *bin++ = '1';
+                else *bin++ = '0';
+
+               dt<<=1;
+        }
+}
+
+void bin2dec(unsigned char bin,int *dec)
+{
+       int i,j;
+       int k;
+
+        for (i=8; i>0; i--)
+        {
+               k=1;
+
+                 if (bin&0x80)
+                       {
+                               if(i==1)
+                                       dec +=1;
+
+                               else{
+                                               for(j=i;i>0;j--)
+                                                       {
+                                                               k = k*2;
+                                                       }
+                                               dec += k;
+                                       }
+                       }
+
+               bin<<=1;
+        }
+}
+#endif
+
+
+
+//////
+static int cmd_display_text_callback(int request, char* bufferP, int* bufferSize, DP_TEXT* dp_text)
+{
+//char DisplayTextFormat[]     = { SAT_COMMAND_DETAILS, SAT_DEVICE_IDENTITIES, SAT_TEXT_STRING,SAT_ICON_IDENTIFIER,SAT_IMMEDIATE_RESPONSE, SAT_DURATION};
+
+       int err = 0;
+       int str_len=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+
+       str_len = strlen(dp_text->text_string);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = DisplayTextFormat + 3;
+
+                       if (dp_text->icon_identifier == 1)
+                               *writeP++ = SAT_ICON_IDENTIFIER;
+
+                       if (dp_text->immediate_response == 1)
+                               *writeP++ = SAT_IMMEDIATE_RESPONSE;
+
+                       if (dp_text->duration == 1)
+                               *writeP++ = SAT_DURATION;
+
+
+                       *((char**) bufferP) = DisplayTextFormat;
+                       *bufferSize = writeP - DisplayTextFormat;
+
+
+
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x21;//typr of command
+
+                       if(dp_text->priority == 0 && dp_text->clear_msg == 0)
+                               bufferP[2] = 0x00;//command qualifier 0/0
+                       else if(dp_text->priority == 0 && dp_text->clear_msg == 1)
+                              bufferP[2] = 0x01;//command qualifier 0/1
+                       else if(dp_text->priority == 1 && dp_text->clear_msg == 0)
+                               bufferP[2] = 0x80;//command qualifier 1/0
+                       else if(dp_text->priority == 1 && dp_text->clear_msg == 1)
+                               bufferP[2] = 0x81;//command qualifier 1/1
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_DISPLAY;//destination device identities
+
+                       break;
+
+               case SAT_TEXT_STRING:
+
+                       dataPP = (char**) bufferP;
+
+
+                       // Here the buffer MUST be allocated with malloc.
+                       // The APDU encoder will free it
+                       *bufferSize = str_len + 1;
+
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       if (dataP)
+                       {
+                               dataP[0] = dp_text->coding_scheme;
+                               memcpy(dataP + 1, dp_text->text_string, str_len);
+                       }
+
+                       else
+                               err = -1;
+                       break;
+
+               case SAT_ICON_IDENTIFIER:
+                       *bufferSize = 2;
+
+                       if(dp_text->icon_qualifier == 0)
+                               bufferP[0] = 0x00;//icon is self explanatory
+                       else
+                               bufferP[0] = 0x01;//icon is not self explanatory
+
+                       bufferP[1] = 0x4f;//dp_text->icon_identifier;//icon_identifier address EF-img
+
+                       break;
+
+                 case SAT_IMMEDIATE_RESPONSE:
+                       *bufferSize = 0;
+                       break;
+
+               case SAT_DURATION:
+                       *bufferSize = 2;
+                       if(dp_text->duration_unit == 0)
+                               bufferP[0] = 0x00;//time unit
+                       else if(dp_text->duration_unit == 1)
+                               bufferP[0] = 0x01;//time unit
+                       else if(dp_text->duration_unit == 2)
+                               bufferP[0] = 0x02;//time unit
+
+                       bufferP[1] = 0x02;//time interval
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+
+///////
+//////
+static int cmd_set_menu_callback(int request, char* bufferP, int* bufferSize, void* data)
+{
+       int err = 0;
+       int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+//     char* bits[8];
+       int i=0;
+//     char *alpha_id="test setmenu";
+
+       unsigned char cmd_detail=0;
+       unsigned char num=0;
+//     unsigned char * t_num;
+
+//     GSM_SatProactiveCmd cmd;
+
+       SET_MENU* set_menu;
+       SET_MENU *temp_set_menu;
+
+       //
+//     int str_size=0;
+       unsigned char * pdata = (unsigned char *)(data);
+         /////////////////////////
+       num = *pdata++;
+       cmd_detail = *pdata++;
+
+       set_menu = (SET_MENU *)(pdata);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = SetUpMenuFormat + 4;
+
+                       g_item_cnt = num;
+
+                       for(i=0;i<num-1;i++)  // one is mandaotory
+                               *writeP++ = SAT_ITEM;
+
+                       *((char**) bufferP) = SetUpMenuFormat;
+                       *bufferSize = writeP - SetUpMenuFormat;
+
+                       TRACE(MSGL_VGSM_INFO, "cmd detail is <%x>\n",cmd_detail);
+                       TRACE(MSGL_VGSM_INFO, "num is <%d>\n",g_item_cnt);
+                       TRACE(MSGL_VGSM_INFO, "bufferSize is <%d>",*bufferSize);
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x02;//commnad number
+                       bufferP[1] = 0x25;//type of command
+
+                       dec= cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_ME;//destination device identities
+
+                       break;
+
+               case SAT_ALPHA_IDENTIFIER:
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       temp_set_menu = &(set_menu[0]);
+
+                       if (dataP)
+                               memcpy(dataP, temp_set_menu->alpah_string, strlen(temp_set_menu->alpah_string));
+
+                       TRACE(MSGL_VGSM_INFO, "dataP is <%s>",dataP);
+
+                       *bufferSize = strlen(temp_set_menu->alpah_string);
+                       break;
+
+               case SAT_ITEM:
+//                     TRACE("\CNT NUMBER is <%d>",g_item_cnt);
+
+                       temp_set_menu = &(set_menu[num-g_item_cnt]);
+                       g_item_cnt = g_item_cnt-1;
+
+                       str_len = strlen(temp_set_menu->item_string);
+
+                       *bufferSize = str_len + 1;
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       TRACE(MSGL_VGSM_INFO, "Id number is <%d>\n",temp_set_menu->id_num);
+                       TRACE(MSGL_VGSM_INFO, "text string is <%s>\n",temp_set_menu->item_string);
+                       TRACE(MSGL_VGSM_INFO, "strlen is <%d>\n",str_len);
+
+
+                       if (dataP)
+                       {
+                               dataP[0] = temp_set_menu->id_num;
+                               memcpy(dataP + 1, temp_set_menu->item_string, str_len);
+                       }
+
+                       else
+                               err = -1;
+
+                       TRACE(MSGL_VGSM_INFO, "Id number is <%d>\n",dataP[0]);
+                       TRACE(MSGL_VGSM_INFO, "text string is <%s>\n",dataP + 1);
+
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+
+//////
+static int cmd_select_item_callback(int request, char* bufferP, int* bufferSize, void* data)
+{
+       int err = 0;
+       int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+//     char* bits[8];
+       int i=0;
+
+       unsigned char cmd_detail=0;
+       unsigned char num=0;
+//     unsigned char * t_num;
+         char *alpha_id = "test Select";
+//     GSM_SatProactiveCmd cmd;
+
+       SET_MENU* set_menu;
+       SET_MENU *temp_set_menu;
+
+       //
+//     int str_size=0;
+       unsigned char * pdata = (unsigned char *)(data);
+         /////////////////////////
+       num = *pdata++;
+       cmd_detail = *pdata++;
+
+       set_menu = (SET_MENU *)(pdata);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = SetUpMenuFormat + 4;
+
+                       g_item_cnt = num;
+
+                       for(i=0;i<num-1;i++)  // one is mandaotory
+                               *writeP++ = SAT_ITEM;
+
+                       *((char**) bufferP) = SetUpMenuFormat;
+                       *bufferSize = writeP - SetUpMenuFormat;
+
+                       TRACE(MSGL_VGSM_INFO, "cmd detail is <%x>\n",cmd_detail);
+                       TRACE(MSGL_VGSM_INFO, "num is <%d>\n",g_item_cnt);
+                       TRACE(MSGL_VGSM_INFO, "\bufferSize is <%d>",*bufferSize);
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x24;//type of command
+
+                       dec= cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_ME;//destination device identities
+
+                       break;
+
+               case SAT_ALPHA_IDENTIFIER:
+                       *bufferSize = 4;
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       TRACE(MSGL_VGSM_INFO, "alpha_id is <%s>",alpha_id);
+
+                       if (dataP)
+                               memcpy(dataP, alpha_id,strlen(alpha_id));
+
+                       TRACE(MSGL_VGSM_INFO, "dataP is <%s>",dataP);
+
+                       break;
+
+               case SAT_ITEM:
+//                     TRACE(MSGL_VGSM_INFO, "\CNT NUMBER is <%d>",g_item_cnt);
+
+                       temp_set_menu = &(set_menu[num-g_item_cnt]);
+                       g_item_cnt = g_item_cnt-1;
+
+                       str_len = strlen(temp_set_menu->item_string);
+
+                       *bufferSize = str_len + 1;
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       TRACE(MSGL_VGSM_INFO, "Id number is <%d>\n",temp_set_menu->id_num);
+                       TRACE(MSGL_VGSM_INFO, "text string is <%s>\n",temp_set_menu->item_string);
+                       TRACE(MSGL_VGSM_INFO, "strlen is <%d>\n",str_len);
+
+
+                       if (dataP)
+                       {
+                               dataP[0] = temp_set_menu->id_num;
+                               memcpy(dataP + 1, temp_set_menu->item_string, str_len);
+                       }
+
+                       else
+                               err = -1;
+
+                       TRACE(MSGL_VGSM_INFO, "Id number is <%d>\n",dataP[0]);
+                       TRACE(MSGL_VGSM_INFO, "text string is <%s>\n",dataP + 1);
+
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+//////
+//////
+static int cmd_send_sms_callback(int request, char* bufferP, int* bufferSize, void* data)
+{
+       int err = 0;
+//     int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+       char** tpduPP;
+       char* tpduP;
+//     char* bits[8];
+//     int i=0;
+       char *alpha_id="test Send SMS";
+       unsigned char address;
+
+//     GSM_SatProactiveCmd cmd;
+       SEND_SMS *send_sms_packet;
+       //
+//     int str_size=0;
+
+       send_sms_packet = (SEND_SMS *)(data);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = SendSMSFormat + 5;
+
+                       *((char**) bufferP) = SendSMSFormat;
+                       *bufferSize = writeP - SendSMSFormat;
+
+                       TRACE(MSGL_VGSM_INFO, "bufferSize is <%d>",*bufferSize);
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x13;//type of command
+
+                       dec= send_sms_packet->cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       // ???????????????????
+                       bufferP[1] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[0] = SAT_DEVICE_ME;//destination device identities
+
+                       break;
+
+               case SAT_ALPHA_IDENTIFIER:
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       if (dataP)
+                               memcpy(dataP, alpha_id, strlen(alpha_id));
+
+                       *bufferSize = strlen(alpha_id);
+
+                       break;
+
+               case SAT_ADDRESS:
+                       *bufferSize = strlen(send_sms_packet->dial_num) + 1;
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       if (dataP)
+                       {
+                               address = send_sms_packet->address;
+                               dataP[0] =(char)address;
+                               memcpy(dataP + 1, send_sms_packet->dial_num, strlen(send_sms_packet->dial_num));
+                       }
+
+                       else
+                               {
+                                       TRACE(MSGL_VGSM_INFO, "dataP is NULL \n");
+                                       err = -1;
+                               }
+
+                       break;
+
+                 case SAT_SMS_TPDU:
+                       *bufferSize = strlen(send_sms_packet->tpdu_sms) ;
+
+                       tpduPP = (char**) bufferP;
+                       tpduP = *tpduPP = malloc(*bufferSize);
+
+                       TRACE(MSGL_VGSM_INFO, "TPDU-send_sms_packet->tpdu_sms is <%s>\n",send_sms_packet->tpdu_sms);
+
+                       if (tpduP)
+                               memcpy(tpduP , send_sms_packet->tpdu_sms, strlen(send_sms_packet->tpdu_sms));
+                       else
+                               {
+                                       TRACE(MSGL_VGSM_INFO, "dataP is NULL \n");
+                                       err = -1;
+                               }
+
+                       TRACE(MSGL_VGSM_INFO, "TPDU-dataP is <%s>\n",tpduP);
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+//////
+static int cmd_set_up_call_callback(int request, char* bufferP, int* bufferSize, void* data)
+{
+       int err = 0;
+//     int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+//     char* bits[8];
+       int i=0;
+
+//     GSM_SatProactiveCmd cmd;
+
+       //int                   cnt=0;
+
+       static unsigned char cmd_detail;
+       static unsigned char options;
+       static char dial_len;
+       static char *dial_num;
+       static unsigned char address;
+       static char alpha_user_len;
+       static char *alpha_user;
+//     static char alpha_call_len;
+//     static char *alpha_call;
+       static char duration_unit;
+//     static char alpha_state;
+
+
+       //
+//     int str_size;
+       int tmp_address=0;
+       unsigned char * pdata = (unsigned char *)(data);
+//////////////
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = SetUpCallFormat + 2;
+
+                       options = *pdata++;
+                       cmd_detail = *pdata++;
+                       dial_len = *pdata++;
+                       dial_num = malloc(dial_len);
+                       memset(dial_num,0,dial_len);
+                       memcpy(dial_num,pdata,dial_len);
+                       //
+                       TRACE(MSGL_VGSM_INFO,  " *-options is %x\n",options);
+                       TRACE(MSGL_VGSM_INFO,  " *-dial_num is %s \n ",dial_num);
+                       TRACE(MSGL_VGSM_INFO,  " *-dial_len is %d \n ",dial_len);
+
+
+                       pdata+=dial_len;
+
+               //      alpha_state=0;
+
+                       ///////////////////////////////
+                       switch(options)
+                               {
+                                       case 0x00 : // not options
+
+                                               address = *pdata;
+                                               //
+                                               TRACE(MSGL_VGSM_INFO," *-address is %x \n ",address);
+                                               *writeP++ = SAT_ADDRESS;
+                                               break;
+
+                                       case 0x01: // alpha_
+
+                                               alpha_user_len= *pdata++;
+                                               alpha_user = malloc(alpha_user_len);
+                                               memset(alpha_user,0,alpha_user_len);
+                                               memcpy(alpha_user,pdata,alpha_user_len);
+                                               pdata += alpha_user_len;
+/*
+                                               alpha_call_len= *pdata++;
+                                               alpha_call = malloc(alpha_call_len);
+                                               memset(alpha_call,0,alpha_call_len);
+                                               memcpy(alpha_call,pdata,alpha_call_len);
+                                               pdata += alpha_call_len;
+                                               //
+*/
+                                               TRACE(MSGL_VGSM_INFO,"*-alpha_user is %s \n ",alpha_user);
+       //                                      TRACE(MSGL_VGSM_INFO,"*-alpha_call is %s \n ",alpha_call);
+                                               TRACE(MSGL_VGSM_INFO,"*-alpha_user_len is %d \n ",alpha_user_len);
+       //                                      TRACE(MSGL_VGSM_INFO,"*-alpha_call_len is %d \n ",alpha_call_len);
+
+                                               address = *pdata;
+                                               //
+                                               TRACE(MSGL_VGSM_INFO,"*-address is %x \n ",address);
+                                               *writeP++ = SAT_ALPHA_IDENTIFIER;
+                                               *writeP++ = SAT_ADDRESS;
+                                       //      *writeP++ = SAT_ALPHA_IDENTIFIER;
+
+                                               break;
+
+                                       case 0x02: // DURATION
+                                               address = *pdata++;
+                                               //
+                                               TRACE(MSGL_VGSM_INFO,"*-address is %x \n ",address);
+
+                                               duration_unit = *pdata;
+                                               //
+                                               TRACE(MSGL_VGSM_INFO,"*-duration_unit is %x \n ",duration_unit);
+
+                                               *writeP++ = SAT_ADDRESS;
+                                               *writeP++ = SAT_DURATION;
+                                               break;
+                                       case 0x03: //  alpha_ & DURATION
+                                               alpha_user_len= *pdata++;
+                                               alpha_user = malloc(alpha_user_len);
+                                               memset(alpha_user,0,alpha_user_len);
+                                               memcpy(alpha_user,pdata,alpha_user_len);
+                                               pdata += alpha_user_len;
+/*
+                                               alpha_call_len= *pdata++;
+                                               alpha_call = malloc(alpha_call_len);
+                                               memset(alpha_call,0,alpha_user_len);
+                                               memcpy(alpha_call,pdata,alpha_call_len);
+                                               pdata += alpha_call_len;
+*/
+                                               //
+                                               TRACE(MSGL_VGSM_INFO,"*-alpha_user is %s \n ",alpha_user);
+                                       //      TRACE(MSGL_VGSM_INFO,"*-alpha_call is %s \n ",alpha_call);
+                                               TRACE(MSGL_VGSM_INFO,"*-alpha_user_len is %d \n ",alpha_user_len);
+                                       //      TRACE(MSGL_VGSM_INFO,"*-alpha_user_len is %d \n ",alpha_user_len);
+
+                                               address = *pdata++;
+                                               duration_unit = *pdata;
+
+                                               //
+                                               TRACE(MSGL_VGSM_INFO,"*-address is %x \n ",address);
+                                               TRACE(MSGL_VGSM_INFO,"*-duration_unit is %x \n ",duration_unit);
+
+                                               *writeP++ = SAT_ALPHA_IDENTIFIER;
+                                               *writeP++ = SAT_ADDRESS;
+                                               *writeP++ = SAT_DURATION;
+                                       //      *writeP++ = SAT_ALPHA_IDENTIFIER;
+                                               break;
+
+                               }
+
+                       *((char**) bufferP) = SetUpCallFormat;
+                       *bufferSize = writeP - SetUpCallFormat;
+
+                       TRACE(MSGL_VGSM_INFO,"cmd detail is <%x>\n",cmd_detail);
+                       TRACE(MSGL_VGSM_INFO,"\bufferSize is <%d>",*bufferSize);
+
+                       for(i=0;i<*bufferSize;i++)
+                               TRACE(MSGL_VGSM_INFO,"*- SetUpCallFormat is <%x>",SetUpCallFormat[i]);
+
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x10;//SAT_CMD_SETUP_CALL;//type of command
+
+                       dec= cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_EARPIECE;//destination device identities
+
+                       break;
+
+               case SAT_ALPHA_IDENTIFIER:
+
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+               //      if(alpha_state == 0)
+               //              {
+               //                      alpha_state =1;
+                                       TRACE(MSGL_VGSM_INFO,"alpha_user is <%s>",alpha_user);
+
+                                       if (dataP)
+                                               memcpy(dataP, alpha_user,alpha_user_len);
+
+                                       *bufferSize = alpha_user_len;
+                                       TRACE(MSGL_VGSM_INFO,"dataP is <%s>",dataP);
+               //              }
+               /*
+                       else
+                               {
+                                       alpha_state =0;
+                                       TRACE(MSGL_VGSM_INFO,"alpha_call is <%s>",alpha_call);
+
+                                       if (dataP)
+                                               memcpy(dataP, alpha_call,alpha_call_len);
+
+                                       *bufferSize = alpha_call_len;
+                                       TRACE(MSGL_VGSM_INFO,"dataP is <%s>",dataP);
+                               }
+               */
+                       break;
+
+               case SAT_DURATION:
+                       *bufferSize = 2;
+                       TRACE(MSGL_VGSM_INFO,"duration_unit is <%x>",duration_unit);
+                       if(duration_unit == 0)
+                               bufferP[0] = 0x00;//time unit
+                       else if(duration_unit == 1)
+                               bufferP[0] = 0x01;//time unit
+                       else if(duration_unit == 2)
+                               bufferP[0] = 0x02;//time unit
+
+                       bufferP[1] = 0x02;//time interval
+
+                       break;
+
+               case SAT_ADDRESS:
+                       *bufferSize = dial_len + 1;
+
+                       dataPP = (char**) bufferP;
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       if (dataP)
+                       {
+                               tmp_address = address;
+                               dataP[0] =(char)tmp_address;
+                               memcpy(dataP + 1, dial_num, dial_len);
+                       }
+
+                       else
+                               {
+                                       TRACE(MSGL_VGSM_INFO,"dataP is NULL \n");
+                                       err = -1;
+                               }
+                       TRACE(MSGL_VGSM_INFO,"Id number is <%#x>\n",dataP[0]);
+                       TRACE(MSGL_VGSM_INFO,"text string is <%s>\n",dataP + 1);
+
+                       break;
+
+
+               default:
+                       {
+                       TRACE(MSGL_VGSM_INFO,"Defalut \n");
+                       err = -1;
+                       }
+       }
+
+       return err;
+
+}
+//////
+//////
+static int cmd_get_input_callback(int request, char* bufferP, int* bufferSize, GET_INPUT* get_input)
+{
+       int err = 0;
+       int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+
+//     char* bits[8];
+
+       str_len = strlen(get_input->text_string);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = GetInputFormat + 3;
+
+                       if (get_input->icon_identifier == 1)
+                               *writeP++ = SAT_ICON_IDENTIFIER;
+
+                       if (get_input->immediate_response == 1)
+                               *writeP++ = SAT_IMMEDIATE_RESPONSE;
+
+                       if (get_input->duration == 1)
+                               *writeP++ = SAT_DURATION;
+
+
+                       *((char**) bufferP) = GetInputFormat;
+                       *bufferSize = writeP - GetInputFormat;
+
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x23;//type of command
+
+                       //bin2dec(get_inkey->cmd_detail,&dec);  //  different - signed,unsigned....
+                       dec= get_input->cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_DISPLAY;//destination device identities
+
+                       break;
+
+               case SAT_TEXT_STRING:
+
+                       dataPP = (char**) bufferP;
+
+
+                       // Here the buffer MUST be allocated with malloc.
+                       // The APDU encoder will free it
+                       *bufferSize = str_len + 1;
+
+                       dataP = *dataPP = malloc(*bufferSize);
+
+
+
+                       if (dataP)
+                       {
+                               dataP[0] = get_input->coding_scheme;
+                               memcpy(dataP + 1, get_input->text_string, str_len);
+                       }
+
+                       else
+                               err = -1;
+                       break;
+
+               case SAT_ICON_IDENTIFIER:
+                       *bufferSize = 2;
+
+                       if(get_input->icon_qualifier == 0)
+                               bufferP[0] = 0x00;//icon is self explanatory
+                       else
+                               bufferP[0] = 0x01;//icon is not self explanatory
+
+                       bufferP[1] = 0x4f;//dp_text->icon_identifier;//icon_identifier address EF-img
+
+                       break;
+
+                 case SAT_IMMEDIATE_RESPONSE:
+                       *bufferSize = 0;
+                       break;
+
+               case SAT_DURATION:
+                       *bufferSize = 2;
+                       if(get_input->duration_unit == 0)
+                               bufferP[0] = 0x00;//time unit
+                       else if(get_input->duration_unit == 1)
+                               bufferP[0] = 0x01;//time unit
+                       else if(get_input->duration_unit == 2)
+                               bufferP[0] = 0x02;//time unit
+
+                       bufferP[1] = 0x02;//time interval
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+
+//////
+static int cmd_get_inkey_callback(int request, char* bufferP, int* bufferSize, GET_INKEY* get_inkey)
+{
+       int err = 0;
+       int str_len=0;
+       int dec=0;
+
+       char* writeP;
+       char** dataPP;
+       char* dataP;
+
+//     char* bits[8];
+
+       str_len = strlen(get_inkey->text_string);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+
+                       writeP = GetInkeyFormat + 3;
+
+                       if (get_inkey->icon_identifier == 1)
+                               *writeP++ = SAT_ICON_IDENTIFIER;
+
+                       if (get_inkey->immediate_response == 1)
+                               *writeP++ = SAT_IMMEDIATE_RESPONSE;
+
+                       if (get_inkey->duration == 1)
+                               *writeP++ = SAT_DURATION;
+
+
+                       *((char**) bufferP) = GetInkeyFormat;
+                       *bufferSize = writeP - GetInkeyFormat;
+
+                       break;
+
+               case SAT_COMMAND_DETAILS:
+
+                       *bufferSize = 3 ;//
+
+                       bufferP[0] = 0x01;//commnad number
+                       bufferP[1] = 0x22;//type of command
+
+                       //bin2dec(get_inkey->cmd_detail,&dec);  //  different - signed,unsigned....
+                       dec= get_inkey->cmd_detail;
+                       bufferP[2] =dec;
+
+                       bufferP[3] = 0x81 ; //tag - for  CR  ..The CR tag must be send back to the encoder in 4th byte
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+
+                       bufferP[0] = SAT_DEVICE_SIM;//source device identities
+                       bufferP[1] = SAT_DEVICE_DISPLAY;//destination device identities
+
+                       break;
+
+               case SAT_TEXT_STRING:
+
+                       dataPP = (char**) bufferP;
+
+
+                       // Here the buffer MUST be allocated with malloc.
+                       // The APDU encoder will free it
+                       *bufferSize = str_len + 1;
+
+                       dataP = *dataPP = malloc(*bufferSize);
+
+                       if (dataP)
+                       {
+                               dataP[0] = get_inkey->coding_scheme;
+                               memcpy(dataP + 1, get_inkey->text_string, str_len);
+                       }
+
+                       else
+                               err = -1;
+                       break;
+
+               case SAT_ICON_IDENTIFIER:
+                       *bufferSize = 2;
+
+                       if(get_inkey->icon_qualifier == 0)
+                               bufferP[0] = 0x00;//icon is self explanatory
+                       else
+                               bufferP[0] = 0x01;//icon is not self explanatory
+
+                       bufferP[1] = 0x4f;//dp_text->icon_identifier;//icon_identifier address EF-img
+
+                       break;
+
+                 case SAT_IMMEDIATE_RESPONSE:
+                       *bufferSize = 0;
+                       break;
+
+               case SAT_DURATION:
+                       *bufferSize = 2;
+                       if(get_inkey->duration_unit == 0)
+                               bufferP[0] = 0x00;//time unit
+                       else if(get_inkey->duration_unit == 1)
+                               bufferP[0] = 0x01;//time unit
+                       else if(get_inkey->duration_unit == 2)
+                               bufferP[0] = 0x02;//time unit
+
+                       bufferP[1] = 0x02;//time interval
+
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+
+}
+
+int   Display_Text( DP_TEXT* dp_text)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+//     int                     i;
+       GSM_SatProactiveCmd cmd;
+
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "Display_Text: selection by CAT Browser");
+//     TRACE(MSGL_VGSM_INFO, "Display_Text: priority is %x   clear msg is %d text is %s",dp_text->priority,dp_text->priority,dp_text->text_string);
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_display_text_callback, dp_text, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_INFO, "Display_Text: sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+       }
+
+       if(apduStrP==NULL)
+               TRACE(MSGL_VGSM_INFO,"NULL\n");
+
+       str_size = strlen(apduStrP);
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_INFO, "Display_Text: str_to_bin failed with error (0x%08x).", err);
+               return err;
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+int   Get_Inkey( GET_INKEY* get_inkey)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+//     int                     i;
+       GSM_SatProactiveCmd cmd;
+
+       //
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser");
+
+       TRACE(MSGL_VGSM_INFO,"In VGSM : cmd detail - %d\n",get_inkey->cmd_detail);
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_get_inkey_callback, get_inkey, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_INFO, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+
+       }
+
+       assert(apduStrP);
+
+       str_size = strlen(apduStrP);
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_INFO, "str_to_bin failed with error (0x%08x).", err);
+
+               return err;
+
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+int   Get_Input( GET_INPUT* get_input)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+//     int                     i;
+       GSM_SatProactiveCmd cmd;
+
+       //
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser");
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_get_input_callback, get_input, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+
+       }
+
+       assert(apduStrP);
+
+       str_size = strlen(apduStrP);
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "str_to_bin failed with error (0x%08x).", err);
+
+               return err;
+
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+/////////////////
+int   Set_Menu(void *data)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+
+       GSM_SatProactiveCmd cmd;
+
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser");
+
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_set_menu_callback, data, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+
+       }
+
+       assert(apduStrP!=NULL);
+
+       str_size = strlen(apduStrP);
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "str_to_bin failed with error (0x%08x).", err);
+               return err;
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+int   Select_Item(void *data)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+
+       GSM_SatProactiveCmd cmd;
+
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser");
+
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_select_item_callback, data, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+
+       }
+
+       assert(apduStrP);
+
+       str_size = strlen(apduStrP);
+
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "str_to_bin failed with error (0x%08x).", err);
+               return err;
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+////////
+int   Send_SMS(void *data)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+//     int                     i=0;
+
+       GSM_SatProactiveCmd cmd;
+
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser\n");
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_send_sms_callback, data, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+       }
+
+       assert(apduStrP!=NULL);
+
+       str_size = strlen(apduStrP);
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "str_to_bin failed with error (0x%08x).", err);
+
+               return err;
+
+       }
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+////
+int   Set_Up_Call(void *data)
+{
+       char *          apduStrP=NULL;
+       char*           apduP;
+       int                     apduLen;
+       int                     err = 1;
+//     int                     i=0;
+
+       GSM_SatProactiveCmd cmd;
+
+       int str_size=0;
+
+       // make and send
+       TRACE(MSGL_VGSM_INFO, "selection by CAT Browser\n");
+
+       if ((err = sat_apdu_encode(SAT_PROACTIVE_SIM_COMMAND, (SatApduEncoderCallback) cmd_set_up_call_callback, data, &apduStrP)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "sat_apdu_encode failed with error (0x%08x).", err);
+               return err;
+       }
+
+       str_size = strlen(apduStrP);
+
+
+       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != 0)
+       {
+               TRACE(MSGL_VGSM_ERR, "str_to_bin failed with error (0x%08x).", err);
+
+               return err;
+
+       }
+
+
+       cmd.length = str_size/2;
+       cmd.cmd = (unsigned char*)apduP;
+       TxSAT_ATGetProactiveCommand(&cmd);
+
+       return 1;
+
+}
+
+#if 0
+////
+/***********************************************************************
+ * FUNCTION:   cmd_generic_callback
+ ***********************************************************************/
+
+static int cmd_generic_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+       SatCmdParams* paramsP = (SatCmdParams*) decoderP->HLDataP;
+
+
+       switch (tag)
+       {
+       case SAT_ALPHA_IDENTIFIER:
+       case SAT_TEXT_STRING:
+       {
+               if (objectP)
+               {
+                       if (paramsP->textP!=NULL) free(paramsP->textP);
+                       paramsP->textSize = strlen((char*) objectP) + 1;
+                       paramsP->textP= (char*)malloc(paramsP->textSize);
+
+                       strncpy(paramsP->textP, (char*) objectP, paramsP->textSize - 1);
+                       paramsP->textP[paramsP->textSize - 1] = 0;
+                       TRACE( "cmd_generic_callback: paramsP->textP=%s", paramsP->textP);
+
+
+               }
+               else
+               {
+                       //if the alpha identifier is provided by the UICC and is a null data object,
+                       //this is an indication that the terminal should not give any information
+                       //to the user concerning what is happening
+                       paramsP->textSize = 1;
+                       paramsP->textP= (char*)malloc(paramsP->textSize);
+                       paramsP->textP[0] = 0;
+
+               }
+
+               break;
+       }
+       case SAT_ICON_IDENTIFIER:
+       {
+               if (objectP)
+               {
+                       paramsP->explicitIcon = (objectP[0] & NON_EXPLICIT_ICON) == 0;
+                       paramsP->iconId = objectP[1];
+               }
+               break;
+       }
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+//////////////////////////////////////////////////////
+
+/***********************************************************************
+ * FUNCTION:   cmd_display_text_callback
+ ***********************************************************************/
+
+int cmd_display_text_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+       SatCmdParams*   paramsP                         = (SatCmdParams*) decoderP->HLDataP;
+       SatDisplayText* displayTextParamsP      = (SatDisplayText*) paramsP->cmdParamP;
+
+       alp_prv_mbiz_begin_proc(cmd_display_text_callback);
+
+       cmd_generic_callback(tag, decoderP, objectP);
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               if (objectP)
+               {
+                       displayTextParamsP->clearAfterDelay = (COMMAND_QUALIFIER & DISPLAY_TEXT_DETAILS_CLEAR_AFTER_DELAY) == 0;
+                       displayTextParamsP->priority = COMMAND_QUALIFIER & DISPLAY_TEXT_DETAILS_PRIORITY;
+               }
+               break;
+
+       case SAT_IMMEDIATE_RESPONSE:
+               displayTextParamsP->immediateResponse = TRUE;
+               break;
+
+       case SAT_DURATION:
+       {
+               switch (objectP[0])     // switch on time unit
+               {
+               case 0: // minutes
+                       displayTextParamsP->duration = (int) objectP[1] * 60000;
+                       break;
+
+               case 1: // seconds
+                       displayTextParamsP->duration = (int) objectP[1] * 1000;
+                       break;
+
+               case 2: // tenths of seconds
+                       displayTextParamsP->duration = (int) objectP[1] * 100;
+                       break;
+
+               default:
+                       break;
+               }
+
+               break;
+       }
+
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_get_inkey_callback
+ ***********************************************************************/
+
+int cmd_get_inkey_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*   paramsP                 = (SatCmdParams*) decoderP->HLDataP;
+       SatGetInkey*    getInkeyParamsP = (SatGetInkey*) paramsP->cmdParamP;
+
+       alp_prv_mbiz_begin_proc(cmd_get_inkey_callback);
+
+       cmd_generic_callback(tag, decoderP, objectP);
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               if (objectP)
+               {
+                       getInkeyParamsP->helpInfo = (COMMAND_QUALIFIER & GET_DETAILS_HELP_INFO) == GET_DETAILS_HELP_INFO;
+                       getInkeyParamsP->respType = COMMAND_QUALIFIER & GETINKEY_DETAILS_YES_NO ?
+                               SAT_RESP_TYPE_YES_NO_OPTION :
+                               sMbiz_getInkeyRespType[COMMAND_QUALIFIER & GETINKEY_DETAILS_DCS_MASK];
+               }
+               break;
+
+       case SAT_DURATION:
+               {
+                       switch (objectP[0])     // switch on time unit
+                       {
+                       case 0: // minutes
+                               getInkeyParamsP->duration = (int) objectP[1] * 60000;
+                               break;
+
+                       case 1: // seconds
+                               getInkeyParamsP->duration = (int) objectP[1] * 1000;
+                               break;
+
+                       case 2: // tenths of seconds
+                               getInkeyParamsP->duration = (int) objectP[1] * 100;
+                               break;
+
+                       default:
+                               break;
+                       }
+               break;
+               }
+
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_get_input_callback
+ ***********************************************************************/
+
+int cmd_get_input_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*   paramsP                 = (SatCmdParams*) decoderP->HLDataP;
+       SatGetInput*    getInputParamsP = (SatGetInput*)        paramsP->cmdParamP;
+       int                     err                             = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_get_input_callback);
+
+       cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               getInputParamsP->helpInfo               = (COMMAND_QUALIFIER & GET_DETAILS_HELP_INFO) == GET_DETAILS_HELP_INFO;
+               getInputParamsP->hideUserInput  = (COMMAND_QUALIFIER & GETINPUT_DETAILS_HIDE_INPUT) == GETINPUT_DETAILS_HIDE_INPUT;
+               getInputParamsP->respType               = sMbiz_getInkeyRespType[COMMAND_QUALIFIER & GETINKEY_DETAILS_DCS_MASK];
+
+               if (COMMAND_QUALIFIER & GETINPUT_DETAILS_PACKED_BIT)
+                       getInputParamsP->respType++;    // packed
+
+               break;
+
+       case SAT_DEFAULT_TEXT:
+               getInputParamsP->defRespSize = (char) strlen((char*) objectP) + 1;
+
+               if ((err = get_cmd_buffer(paramsP, objectP, getInputParamsP->defRespSize, (char**) &getInputParamsP->defRespP)) != TRUE)
+                       return err;
+
+               break;
+
+       case SAT_RESPONSE_LENGTH:
+               getInputParamsP->minRespLength = objectP[0];
+               getInputParamsP->maxRespLength = objectP[1];
+               break;
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+
+
+/***********************************************************************
+ * FUNCTION:   cmd_select_item_callback
+ ***********************************************************************/
+
+int cmd_select_item_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+
+       SatCmdParams*   paramsP         = (SatCmdParams*) decoderP->HLDataP;
+       SatItemList*            itemListP       = (SatItemList*)        paramsP->cmdParamP;
+       SatItem*                itemPtr;
+       int                     err                     = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_select_item_callback);
+
+       cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+       {
+               char softKeyFlag;
+
+               if (tag == SAT_CMD_SETUP_MENU)
+                       softKeyFlag = SETUP_MENU_DETAILS_SOFTKEY;
+               else
+                       softKeyFlag = SELECT_ITEM_DETAILS_SOFTKEY;
+
+               itemListP->helpInfo     = (COMMAND_QUALIFIER & GET_DETAILS_HELP_INFO) == GET_DETAILS_HELP_INFO;
+               itemListP->softKey      = (COMMAND_QUALIFIER & softKeyFlag) == softKeyFlag;
+
+               break;
+       }
+
+       case SAT_ITEM:
+       {
+               SatItem* itemP = cmd_param_alloc_head(paramsP, sizeof(SatItem));
+
+               TRACE(MSGL_VGSM_INFO, "cmd_select_item_callback: itemP=%x", itemP));
+
+
+               if (!itemP)
+                       return -1;
+
+               itemP->nameSize = strlen(((char*) (objectP)) + 1) + 1;
+               itemP->nameP    = cmd_param_alloc_head(paramsP, itemP->nameSize);
+               itemP->nextItemP= NULL;
+
+               if (!itemP->nameP)
+                       return -1;
+
+               memcpy(itemP->nameP, objectP + 1, itemP->nameSize - 1);
+               itemP->nameP[itemP->nameSize - 1] = 0;
+               itemP->id = *objectP;
+
+
+               TRACE(MSGL_VGSM_INFO, "cmd_select_item_callback: itemP->nameP=%s, itemP->nameSize=%d",itemP->nameP,itemP->nameSize));
+
+
+               itemListP->itemCount++;
+
+               if (itemListP->itemCount==1)
+                       itemListP->firstItemP=itemP;
+
+               else {
+
+                       TRACE(MSGL_VGSM_INFO, "cmd_select_item_callback: itemListP->itemCount=%d", itemListP->itemCount));
+
+                       itemPtr = itemListP->firstItemP;
+
+                       while(itemPtr->nextItemP!=NULL){
+                               itemPtr=itemPtr->nextItemP;
+                       }
+                       itemPtr->nextItemP=itemP;
+
+                       TRACE(MSGL_VGSM_INFO, "cmd_select_item_callback: itemPtr=%x", itemPtr));
+                       TRACE(MSGL_VGSM_INFO, "cmd_select_item_callback: itemPtr->nextItemP=%x", itemPtr->nextItemP));
+
+               }
+
+
+               break;
+       }
+
+       case SAT_ITEMS_NEXT_ACTION_INDICATOR:
+               if (decoderP->currentObjectLength == itemListP->itemCount)
+               {
+                       SatItem*        itemP;
+                       char                    i;
+
+                       for (i=0, itemP = itemListP->firstItemP; itemP!=NULL ; i++, itemP=itemP->nextItemP)
+                                               itemP->nextActionInd = objectP[i];
+               }
+               break;
+
+       case SAT_ITEM_ICON_IDENTIFIER_LIST:
+               if (decoderP->currentObjectLength == itemListP->itemCount + 1)
+               {
+                       SatItem*        itemP;
+                       char                    i;
+
+                       for (i=0, itemP = itemListP->firstItemP; itemP!=NULL ; i++, itemP=itemP->nextItemP)
+                       {
+                               itemP->expIcon  = (objectP[0] & NON_EXPLICIT_ICON) == 0;
+                               itemP->iconId   = objectP[i + 1];
+                       }
+               }
+
+               break;
+
+       // for select item only: the Item identifier gives an indication of the default item
+       case SAT_ITEM_IDENTIFIER:
+               itemListP->defItemId = objectP[0];
+               break;
+
+       default:
+               break;
+       }
+
+       return err;
+}
+
+
+
+/***********************************************************************
+ * FUNCTION:   cmd_refresh_callback
+ ***********************************************************************/
+
+int cmd_refresh_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*           paramsP         = (SatCmdParams*) decoderP->HLDataP;
+       SatRefreshFileList*     refreshP                = (SatRefreshFileList*)paramsP->cmdParamP;
+       int                             err                     = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_refresh_callback);
+
+       cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               refreshP->opCode = COMMAND_QUALIFIER;
+               break;
+
+       case SAT_FILE_LIST:
+               refreshP->fileIdCount = objectP[0]; //number of files in the file list
+               refreshP->filePathCount = (decoderP->currentObjectLength - 1)/2; // number of path in the file list, a path is composed of two bytes
+               if ((err = get_cmd_buffer(paramsP, objectP + 1, decoderP->currentObjectLength - 1, (char**) &refreshP->filePathP)) != TRUE)
+                       return err;
+               break;
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+
+/***********************************************************************
+ * FUNCTION:   cmd_setup_event_list_callback
+ ***********************************************************************/
+
+int cmd_setup_event_list_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*           paramsP                 = (SatCmdParams*) decoderP->HLDataP;
+       SatSetUpEventList*      setUpEventListP = (SatSetUpEventList*) paramsP->cmdParamP;
+       int                             err                             = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_setup_event_list_callback);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_EVENT_LIST:
+               setUpEventListP->eventCount = decoderP->currentObjectLength;
+               if ((err = get_cmd_buffer(paramsP, objectP, setUpEventListP->eventCount, &setUpEventListP->eventP)) != TRUE)
+                       return err;
+               break;
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_setup_call_callback
+ ***********************************************************************/
+
+int cmd_setup_call_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*   paramsP         = (SatCmdParams*) decoderP->HLDataP;
+       SatSetUpCall*   setUpCallP      = (SatSetUpCall*) paramsP->cmdParamP;
+
+       static char             text;
+       static char             icon;
+       int             err;
+
+       alp_prv_mbiz_begin_proc(cmd_setup_call_callback);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               setUpCallP->condition = COMMAND_QUALIFIER;
+               text = icon = 0;
+               break;
+
+       case SAT_ALPHA_IDENTIFIER:
+       {
+               char size = (char) (strlen((char*) objectP) + 1);
+
+               if (text == 0)
+               {
+                       setUpCallP->userConfTextSize = size;
+                       err = get_cmd_buffer(paramsP, objectP, size, (char**) &setUpCallP->userConfTextP);
+                       text = 1;
+               }
+               else
+               {
+                       setUpCallP->callEstaTextSize = size;
+                       err = get_cmd_buffer(paramsP, objectP, size, (char**) &setUpCallP->callEstaTextP);
+                       icon = 1;
+               }
+
+               if (err)
+                       return err;
+
+               break;
+       }
+
+       case SAT_ICON_IDENTIFIER:
+               if (icon == 0)
+               {
+                       setUpCallP->userConfExplicitIcon = (objectP[0] & NON_EXPLICIT_ICON) == 0;
+                       setUpCallP->userConfIconId = objectP[1];
+                       icon = 1;
+               }
+               else
+               {
+                       setUpCallP->callEstaExplicitIcon = (objectP[0] & NON_EXPLICIT_ICON) == 0;
+                       setUpCallP->callEstaIconId = objectP[1];
+               }
+               break;
+
+       case SAT_ADDRESS:
+               setUpCallP->numberSize = strlen(((char*) (objectP)) + 1) + 1; // bypass the TON/NPI byte
+               if ((err = get_cmd_buffer(paramsP, objectP, setUpCallP->numberSize, (char**) &setUpCallP->numberP)) != TRUE)
+                       return err;
+               text = 1;
+               break;
+
+       case SAT_CAPABILILITY_CONFIGURATION_PARAMETERS:
+               setUpCallP->bearerCapSize = (char) (strlen((char*) objectP) + 1);
+               if ((err = get_cmd_buffer(paramsP, objectP, setUpCallP->bearerCapSize, &setUpCallP->bearerCapP)) != TRUE)
+                       return err;
+               break;
+
+       case SAT_SUBADDRESS:
+               setUpCallP->subAddressSize = (char) (strlen((char*) objectP) + 1);
+               if ((err = get_cmd_buffer(paramsP, objectP, setUpCallP->subAddressSize, (char**) &setUpCallP->subAddressP)) != TRUE)
+                       return err;
+               break;
+
+       case SAT_DURATION:
+               {
+                       switch (objectP[0])     // switch on time unit
+                       {
+                       case 0: // minutes
+                               setUpCallP->duration = (int) objectP[1] * 60000;
+                               break;
+
+                       case 1: // seconds
+                               setUpCallP->duration = (int) objectP[1] * 1000;
+                               break;
+
+                       case 2: // tenths of seconds
+                               setUpCallP->duration = (int) objectP[1] * 100;
+                               break;
+
+                       default:
+                               break;
+                       }
+               break;
+               }
+
+       default:
+               break;
+       }
+
+       return TRUE;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_launch_browser_callback
+ ***********************************************************************/
+
+int cmd_launch_browser_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*           paramsP                 = (SatCmdParams*) decoderP->HLDataP;
+       SatLaunchBrowser*       launchBrowserP  = (SatLaunchBrowser*) paramsP->cmdParamP;
+       static char*                    filePathCursorP;
+       int                             err = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_launch_browser_callback);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               launchBrowserP->condition = COMMAND_QUALIFIER;
+               break;
+
+       case SAT_BROWSER_IDENTITY:
+               launchBrowserP->browserId = objectP[0];
+               break;
+
+       case SAT_URL:
+               launchBrowserP->urlSize = (char) strlen((char*) objectP) + 1;
+               err = get_cmd_buffer(paramsP, objectP, launchBrowserP->urlSize, (char**) &launchBrowserP->urlP);
+               break;
+
+       case SAT_BEARER:
+               launchBrowserP->prefBearerCount = decoderP->currentObjectLength;
+               err = get_cmd_buffer(paramsP, objectP, launchBrowserP->prefBearerCount, &launchBrowserP->prefBearersP);
+               break;
+
+       case SAT_PROVISIONING_FILE_REFERENCE:
+               launchBrowserP->fileIdCount++;
+               if (launchBrowserP->fileIdCount == 1)
+               {
+                       // allocate a max size for file paths
+                       launchBrowserP->filePathP = cmd_param_alloc_head(paramsP, 256);
+                       if (launchBrowserP->filePathP == NULL)
+                       {
+                               err = -1;
+                               break;
+                       }
+                       filePathCursorP = (char*) launchBrowserP->filePathP;
+               }
+               memcpy(filePathCursorP, objectP, decoderP->currentObjectLength);
+               filePathCursorP += decoderP->currentObjectLength;
+               break;
+
+       case SAT_TEXT_STRING:
+               launchBrowserP->gatewaySize = strlen((char*) objectP + 1);
+               err = get_cmd_buffer(paramsP, objectP, launchBrowserP->gatewaySize, (char**) &launchBrowserP->gatewayP);
+               break;
+
+       case SAT_ALPHA_IDENTIFIER:
+       case SAT_ICON_IDENTIFIER:
+               err = cmd_generic_callback(tag, decoderP, objectP);
+               break;
+
+       default:
+               break;
+       }
+
+       return err;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_play_tone_callback
+ ***********************************************************************/
+
+int cmd_play_tone_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*   paramsP         = (SatCmdParams*) decoderP->HLDataP;
+       SatPlayTone*    playToneP       = (SatPlayTone*) paramsP->cmdParamP;
+       int                     err                     = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_play_tone_callback);
+
+       err = cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               playToneP->vibrateAlert = COMMAND_QUALIFIER;
+               break;
+
+       case SAT_TONE:
+               playToneP->sndCode = objectP[0];
+               break;
+
+       case SAT_DURATION:
+               switch (objectP[0])     // switch on time unit
+               {
+               case 0: // minutes
+                       playToneP->sndDuration = (int) objectP[1] * 60000;
+                       break;
+
+               case 1: // seconds
+                       playToneP->sndDuration = (int) objectP[1] * 1000;
+                       break;
+
+               case 2: // tenths of seconds
+                       playToneP->sndDuration = (int) objectP[1] * 100;
+                       break;
+
+               default:
+                       break;
+               }
+               break;
+
+       default:
+               break;
+       }
+
+       return err;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_send_short_message_callback
+ ***********************************************************************/
+
+int cmd_send_short_message_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*                   paramsP                         = (SatCmdParams*) decoderP->HLDataP;
+       SatSendShortMessage*    sendShortMessageP       = (SatSendShortMessage*) paramsP->cmdParamP;
+       int                                     err                                     = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_send_short_message_callback);
+
+       err = cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_COMMAND_DETAILS:
+               sendShortMessageP->packingRequired = (COMMAND_QUALIFIER & 1) == 1;
+               break;
+
+       case SAT_ADDRESS:
+               sendShortMessageP->addressSize = strlen((char*) objectP) + 1;
+               if ((err = get_cmd_buffer(paramsP, objectP, sendShortMessageP->addressSize, (char**) &sendShortMessageP->addressP)) != TRUE)
+                       return err;
+               break;
+
+       case SAT_SMS_TPDU:
+               sendShortMessageP->TPDUSize = decoderP->currentObjectLength;
+               if ((err = get_cmd_buffer(paramsP, objectP, sendShortMessageP->TPDUSize, &sendShortMessageP->TPDUP)) != TRUE)
+                       return err;
+               break;
+
+       default:
+               break;
+       }
+
+       return err;
+}
+
+/***********************************************************************
+ * FUNCTION:   cmd_send_callback
+ ***********************************************************************/
+
+int cmd_send_callback(char tag, SatApduDecoder* decoderP, char* objectP)
+{
+
+       SatCmdParams*   paramsP = (SatCmdParams*) decoderP->HLDataP;
+       SatBuffer*              bufferP = (SatBuffer*) paramsP->cmdParamP;
+       int                     err             = TRUE;
+
+       alp_prv_mbiz_begin_proc(cmd_send_callback);
+
+       err = cmd_generic_callback(tag, decoderP, objectP);
+
+       if (objectP == NULL)
+               return TRUE;
+
+       switch (tag)
+       {
+       case SAT_SS_STRING:
+       case SAT_USSD_STRING:
+       case SAT_DTMF_STRING:
+       case SAT_AT_COMMAND:
+               bufferP->bufferSize = decoderP->currentObjectLength;
+               if ((err = get_cmd_buffer(paramsP, objectP, bufferP->bufferSize, &bufferP->bufferP)) != TRUE)
+                       return err;
+               break;
+       }
+
+       return err;
+}
+
+
+/***********************************************************************
+ *
+ * FUNCTION:   get_cmd_parameters
+ *
+ * DESCRIPTION: Retrieve the parameters of the currently running
+ *                             proactive command.
+ *                             Analyse parameters of received Proactive Command
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => ioParamsP    :
+ *
+ * RETURNED:   Error if any
+ *
+ ***********************************************************************/
+
+int get_cmd_parameters(AlpPhoneDriver* ioDriverP, SatCmdParams* ioParamsP)
+{
+       SatApduDecoderCallback  commandCallback = NULL;
+       char*                                           commandTags     = NULL;
+       int                                     err                             = TRUE;
+
+       if (ioDriverP->catCmdDataP == NULL)
+       {
+               TRACE(MSGL_VGSM_INFO, "get_cmd_parameters: ERROR: Invalid pointer, check why we got this."));
+               err = -1;
+               goto ERR;
+       }
+
+       switch (ioParamsP->cmdId)
+       {
+       //case SAT_CMD_SETUP_IDLE_MODE_TEXT:
+               //commandCallback = cmd_generic_callback;
+               //break;
+
+       case SAT_CMD_DISPLAY_TEXT:
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatDisplayText)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_display_text_callback;
+
+               break;
+
+       case SAT_CMD_GET_INKEY:
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatGetInkey)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_get_inkey_callback;
+
+               break;
+
+       case SAT_CMD_PLAY_TONE:
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatPlayTone)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_play_tone_callback;
+
+               break;
+
+
+       case SAT_CMD_GET_INPUT:
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatGetInput)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_get_input_callback;
+
+               break;
+
+       case SAT_CMD_SELECT_ITEM:
+       case SAT_CMD_SETUP_MENU:
+       {
+               SatItemList* itemListP;
+
+               if ((err = cmd_param_init(ioParamsP)) != TRUE)
+                       goto ERR;
+
+               if ((itemListP = cmd_param_alloc_head(ioParamsP, sizeof(SatItemList))) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               itemListP->itemCount=0;
+
+               commandCallback = cmd_select_item_callback;
+
+               break;
+       }
+
+       case SAT_CMD_REFRESH:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatRefreshFileList)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_refresh_callback;
+
+               break;
+
+       case SAT_CMD_SETUP_EVENTLIST:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatSetUpEventList)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_setup_event_list_callback;
+
+               break;
+
+       case SAT_CMD_SETUP_CALL:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatSetUpCall)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_setup_call_callback;
+
+
+               break;
+
+       case SAT_CMD_LAUNCH_BROWSER:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatLaunchBrowser)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_launch_browser_callback;
+
+               break;
+
+       case SAT_CMD_SEND_SHORT_MESSAGE:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatSendShortMessage)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_send_short_message_callback;
+
+               break;
+
+       case SAT_CMD_SEND_USSD:
+       case SAT_CMD_SEND_DTMF:
+       case SAT_CMD_RUN_AT_COMMAND:
+       case SAT_CMD_SEND_SS:
+
+               err = cmd_param_init(ioParamsP);
+               if (err)
+                       goto ERR;
+
+               if (cmd_param_alloc_head(ioParamsP, sizeof(SatBuffer)) == NULL)
+               {
+                       err = -1;
+                       goto ERR;
+               }
+
+               commandCallback = cmd_send_callback;
+
+               break;
+
+
+       default:
+               TRACE(MSGL_VGSM_INFO, "get_cmd_parameters: Unsupported proactive command (%hu).", (uint16_t) ioParamsP->cmdId));
+               err = -1;
+               goto ERR;
+       }
+
+       err = sat_apdu_decode(((AlpPDrvMbizCatData*) ioDriverP->catCmdDataP)->buffer, ((AlpPDrvMbizCatData*) ioDriverP->catCmdDataP)->bufferSize, commandTags, commandCallback, ioParamsP);
+
+       //get the real size used by the proactive command parameters
+       ioParamsP->cmdParamSize = get_cmd_param_size(ioParamsP);
+       ioParamsP->cmdParamP    = realloc(ioParamsP->cmdParamP,ioParamsP->cmdParamSize);
+
+       return err;
+
+ERR:
+       TRACE(MSGL_VGSM_INFO, "get_cmd_parameters: state %u failed with error (0x%08lX).", ioDriverP->state, err));
+       TRACE(MSGL_VGSM_INFO, "get_cmd_parameters: ioParamsP->cmdParamP=%lx).",ioParamsP->cmdParamP ));
+
+       return err;
+}
+
+
+/***********************************************************************
+ *
+ * FUNCTION:   set_cmd_response_callback
+ *
+ * DESCRIPTION: Make a specific response according to the currently
+ *                             running proactive command to send it to UICC.
+ *                             that is, Send Terminal Response in 3GPP spec
+ *
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => iResponseP   :
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+static int set_cmd_response_callback(int request, char* bufferP, int16_t* bufferSize, MbizSetCmdResponseParamsType* paramsP)
+{
+       int err = TRUE;
+
+       switch (request)
+       {
+       case SAT_GET_DATA_FORMAT:
+               {
+               char* writeP = MbizPrvSetCmdResponseFormat + 3;
+               switch (paramsP->responseP->cmdId)
+               {
+               case SAT_CMD_GET_INKEY:
+               case SAT_CMD_GET_INPUT:
+                       if ((paramsP->responseP->resCode & 0xF0) == 0)
+                               *writeP++ = SAT_TEXT_STRING;
+                       break;
+
+               case SAT_CMD_SELECT_ITEM:
+                       if ((paramsP->responseP->resCode & 0xF0) == 0)
+                               *writeP++ = SAT_ITEM_IDENTIFIER;
+                       break;
+               }
+               *((char**) bufferP) = MbizPrvSetCmdResponseFormat;
+               *bufferSize = writeP - MbizPrvSetCmdResponseFormat;
+               break;
+               }
+
+       case SAT_COMMAND_DETAILS:
+               {
+               char* objectP = paramsP->proactiveCmdP;
+               char tag;
+
+               *bufferSize = 3;
+
+               if (objectP == NULL)
+                       err = -1;
+               else
+               {
+                       // get the original
+                       objectP += 4 + (objectP[1] == 0x81);
+                       tag = objectP[-2];
+                       *bufferP++ = *objectP++;
+                       *bufferP++ = *objectP++;
+                       *bufferP++ = *objectP;
+                       // The CR tag must be send back to the encoder in 4th byte
+                       *bufferP++ = tag;
+               }
+               break;
+               }
+
+       case SAT_DEVICE_IDENTITIES:
+               *bufferSize = 2;
+               bufferP[0] = SAT_DEVICE_ME;
+               bufferP[1] = SAT_DEVICE_SIM;
+               break;
+
+       case SAT_RESULT:
+               *bufferSize = 2;
+               bufferP[0] = paramsP->responseP->resCode;
+               bufferP[1] = paramsP->responseP->addInfo;
+               break;
+
+       case SAT_TEXT_STRING:
+               {
+               char** dataPP = (char**) bufferP;
+               char* dataP;
+
+               // Here the buffer MUST be allocated with malloc.
+               // The APDU encoder will free it
+               *bufferSize = paramsP->responseP->respSize + 1;
+               dataP = *dataPP = malloc(*bufferSize);
+               if (dataP)
+               {
+                       dataP[0] = paramsP->responseP->respType;
+                       memcpy(dataP + 1, paramsP->responseP->respP, paramsP->responseP->respSize);
+               }
+               else
+                       err = -1;
+               break;
+               }
+
+       case SAT_ITEM_IDENTIFIER:
+               *bufferSize = 1;
+               *bufferP = paramsP->responseP->itemIdentifier;
+               break;
+
+       default:
+               err = -1;
+               break;
+       }
+
+       return err;
+}
+
+/***********************************************************************
+ *
+ * FUNCTION:   set_cmd_response
+ *
+ * DESCRIPTION: Send a specific response according to the currently
+ *                             running proactive command.
+ *                             that is, Send Terminal Response in 3GPP spec
+ *                             This fuction is only for calling by CAT Brower
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => iResponseP:
+ *
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+int set_cmd_response(AlpPhoneDriver* ioDriverP, SatCmdResponse* iResponseP)
+{
+       MbizSetCmdResponseParamsType            params;
+
+       char *          apduStrP;
+       char *          apduP;
+       int             apduLen;
+       int     err = TRUE;
+
+       char*           raw_packet = NULL;
+       int                     raw_packet_size=0;
+
+       alp_prv_mbiz_begin_proc(set_cmd_response);
+
+       TRACE(MSGL_VGSM_INFO, "set_cmd_response: State (%u).", ioDriverP->state);
+
+
+       // Send a Terminal Response to UICC
+       switch (ioDriverP->state)
+       {
+       case 0: //  send the command
+               if (ioDriverP->catCmdDataP == NULL)
+               {
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: ERR!! There is no SAT payload.");
+                       return ALP_STATUS_TEL_INVALID_PARAMETER;
+               }
+
+               params.proactiveCmdP    = ((AlpPDrvMbizCatData*) ioDriverP->catCmdDataP)->buffer;
+               params.responseP                = iResponseP;
+
+               TRACE(MSGL_VGSM_INFO, "set_cmd_response: reponse");
+
+               ALP_TM(B(printf_CLASS, (char*)iResponseP , sizeof(SatCmdResponse)));
+
+               TRACE(MSGL_VGSM_INFO, "set_cmd_response: %x %lx %x %x %x %x",iResponseP->itemIdentifier,iResponseP->respSize,iResponseP->cmdId,iResponseP->respType,iResponseP->resCode,iResponseP->addInfo);
+
+               if ((err = sat_apdu_encode(SAT_RESPONSE, (SatApduEncoderCallback) set_cmd_response_callback, &params, &apduStrP)) != TRUE)
+               {
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: sat_apdu_encode failed with error (0x%08lX).", err);
+
+                       return err;
+                       break;
+               }
+
+               if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != TRUE)
+               {
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: str_to_bin failed with error (0x%08lX).", err));
+
+                       return err;
+                       break;
+               }
+
+
+               // Make packet with encoded apdu
+               if ((err = TxSAT_GetProactiveCommand(&raw_packet,&raw_packet_size, apduP, apduLen)) != TRUE)
+               {
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: TxSAT_GetProactiveCommand failed with error (0x%08lX).", err));
+
+                       return err;
+                       break;
+               }
+
+               // Send the command
+               if ((err = alp_prv_comm_send_at_cmd(ioDriverP, ioDriverP->receiveTimeoutMs, raw_packet,raw_packet_size)) != TRUE)
+               {
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: alp_prv_comm_send_at_cmd failed with error (0x%08lX).", err));
+
+                       return err;
+                       break;
+               }
+               // Set internal to 0
+               ioDriverP->internal = 0;
+
+               if(apduP)               // This variable is malloc on str_to_bin()
+                       free(apduP);
+               if(apduStrP)    // This variable is malloc on sat_apdu_encode()
+                       free(apduStrP);
+
+               // Remove previous SAT payload because sending TR for it is successfull.
+               if (ioDriverP->catCmdDataP)
+               {
+                       free(ioDriverP->catCmdDataP);
+                       ioDriverP->catCmdDataP=NULL;
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: free ioDriverP->catCmdDataP, %lx",ioDriverP->catCmdDataP));
+               }
+
+               ioDriverP->state++;
+
+
+       case 1: // waiting for response for each cmdId
+               // 0x0E SIM Toolkit Commands
+               // 0x03 Proactive Command
+               if( (err = alp_prv_analyse_response(ioDriverP,0x0E, 0x03,NULL, NULL))  != TRUE)
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: response fail!"));
+               else
+                       TRACE(MSGL_VGSM_INFO, "set_cmd_response: response O.K."));
+
+               // Command is finished
+               ioDriverP->state = 0;
+
+               return err;
+               break;
+
+       default:
+               TRACE(MSGL_VGSM_INFO, "set_cmd_response: Invalid state."));
+               return -1;
+       }
+
+
+       return err;
+
+}
+
+
+
+
+/***********************************************************************
+ *
+ * FUNCTION:   menu_selection
+ *
+ * DESCRIPTION: Notify the card to launch an application or to provide
+ *                             its help information if any.
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => iSelectionP  :
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+
+/***********************************************************************
+ *
+ * FUNCTION:   call_action
+ *
+ * DESCRIPTION: Inform the card if the user accepted/rejected to set up
+ *                             the call according to the given action.
+ *                             Terminal Response for SETUP CALL proactive cmd
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => iAction              :
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+int call_action(AlpPhoneDriver* ioDriverP, char iAction)
+{
+       int     err = TRUE;
+
+       alp_prv_mbiz_begin_proc(call_action);
+
+       TRACE(MSGL_VGSM_INFO, "call_action: State (%u).", ioDriverP->state));
+
+
+       if (iAction == SAT_CALL_ACCEPT)
+               TRACE(MSGL_VGSM_INFO, "call_action: should call, not yet"));
+       else
+               TRACE(MSGL_VGSM_INFO, "call_action: release call, not yet"));
+
+       return err;
+}
+
+static int event_download_callback(int request, char* bufferP, int16_t* bufferSize, SatEventToCard* eventP)
+{
+       int err = TRUE;
+
+       alp_prv_mbiz_begin_proc(event_download_callback);
+
+       switch (request)
+       {
+               case SAT_GET_DATA_FORMAT:
+                       *((char**) bufferP) = MbizPrvEventDownloadFormat;
+                       switch (eventP->evtCode)
+                       {
+                       case SAT_EVENT_USER_ACTIVITY:
+                   *bufferSize = 2;
+                               break;
+
+                       case SAT_EVENT_IDLE_SCREEN_AVAILABLE:
+                   *bufferSize = 2;
+                               break;
+
+                       case SAT_EVENT_LANGUAGE_SELECTION:
+                   *bufferSize = 3;
+                               MenSelectionFormat[2] = SAT_LANGUAGE;
+                               break;
+
+                       case SAT_EVENT_BROWSER_TERMINATION:
+                   *bufferSize = 3;
+                               MenSelectionFormat[2] = SAT_BROWSER_TERMINATION_CAUSE;
+                               break;
+                       }
+                       break;
+
+               case SAT_DEVICE_IDENTITIES:
+                       *bufferSize = 2;
+                       if (eventP->evtCode == SAT_EVENT_IDLE_SCREEN_AVAILABLE)
+                               bufferP[0] = SAT_DEVICE_DISPLAY;
+                       else
+                               bufferP[0] = SAT_DEVICE_ME;
+                       bufferP[1] = SAT_DEVICE_SIM;
+                       break;
+
+               case SAT_EVENT_LIST:
+                       bufferP[0] = eventP->evtCode;
+                       *bufferSize = 1;
+                       break;
+
+               case SAT_LANGUAGE:
+                       *bufferSize = 2;
+                       bufferP[0] = eventP->lanCode[0];
+                       bufferP[1] = eventP->lanCode[1];
+                       break;
+
+               case SAT_BROWSER_TERMINATION_CAUSE:
+                       *bufferSize = 1;
+                       bufferP[0] = eventP->browserTerminationCause;
+                       break;
+
+               default:
+                       err = -1;
+       }
+
+       return err;
+}
+
+
+/***********************************************************************
+ *
+ * FUNCTION:   notify_card_of_event
+ *
+ * DESCRIPTION: Notify the card of an event that has occurred on the
+ *                             PDA according to the event selected
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => iEventP              :
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+int notify_card_of_event(AlpPhoneDriver* ioDriverP, SatEventToCard* iEventP)
+{
+       char*   bufferP;
+       int     bufferSize;
+       char*   apduP;
+       char*   apduStrP;
+       int     apduLen;
+
+       char*   raw_packet = NULL;
+       int             raw_packet_size=0;
+
+       int     err = TRUE;
+
+       alp_prv_mbiz_begin_proc(notify_card_of_event);
+
+       TRACE(MSGL_VGSM_INFO, "notify_card_of_event: received event by CAT Browser"));
+
+       ALP_TM(B(printf_CLASS, (char*)iEventP , sizeof(SatEventToCard)));
+
+       switch (ioDriverP->state)
+       {
+               case 0:
+                       if ((err = sat_apdu_encode(SAT_EVENT_DOWNLOAD, (SatApduEncoderCallback) event_download_callback, iEventP, &apduStrP)) != TRUE)
+                       {
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: sat_apdu_encode failed with error (0x%08lX).", err));
+                               return err;
+                               break;
+                       }
+
+                       if ((err = str_to_bin(apduStrP, &apduP, &apduLen)) != TRUE)
+                       {
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: str_to_bin failed with error (0x%08lX).", err));
+                               return err;
+                               break;
+                       }
+
+                       // Make packet with encoded apdu
+                       if ((err = TxSAT_SetEventDownload(&raw_packet,&raw_packet_size, apduP, apduLen)) != TRUE)
+                       {
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: TxSAT_SetEventDownload failed with error (0x%08lX).", err));
+                               return err;
+                               break;
+                       }
+
+                       ALP_TM(B(printf_CLASS, raw_packet,raw_packet_size));
+
+                       // Send the command
+                       if ((err = alp_prv_comm_send_at_cmd(ioDriverP, ioDriverP->receiveTimeoutMs, raw_packet,raw_packet_size)) != TRUE)
+                       {
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: alp_prv_comm_send_at_cmd failed with error (0x%08lX).", err));
+                               return err;
+                               break;
+                       }
+                       // Set internal to 0
+                       ioDriverP->internal = 0;
+
+                       if(apduP)               // This variable is malloc on str_to_bin()
+                               free(apduP);
+                       if(apduStrP)    // This variable is malloc on sat_apdu_encode()
+                               free(apduStrP);
+
+                       ioDriverP->state++;
+
+
+               case 1: // waiting for general response
+                       // 0x0E : SIM Toolkit Commands
+                       // 0x05 : Event Download
+                       if( (err = alp_prv_analyse_response(ioDriverP,0x0E, 0x05,NULL, NULL))  != TRUE)
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: response fail!"));
+                       else
+                               TRACE(MSGL_VGSM_INFO, "notify_card_of_event: response O.K."));
+
+                       // Command is finished
+                       ioDriverP->state = 0;
+
+                       return err;
+                       break;
+
+               default:
+                       TRACE(MSGL_VGSM_INFO, "notify_card_of_event: Invalid state."));
+                       return -1;
+                       break;
+       }
+
+       return err;
+
+}
+
+// lucky29
+/***********************************************************************
+ *
+ * FUNCTION:   prv_card_analyse_crsm
+ *
+ * DESCRIPTION:
+ *
+ * PARAMETERS:         => ioDriverP    : Pointer to a driver
+ *                                     => ioFileP              :
+ *
+ * RETURNED:   Error if any
+ ***********************************************************************/
+
+int prv_card_analyse_crsm(AlpPhoneDriver* ioDriverP, AlpTelCardFile* ioFileP)
+{
+       int     err;
+
+       char                    *bufP, *tmpBufP;
+       char                    cmdType=0;
+       int                     bufSize, tmpBufSize, val;
+       int             value;
+
+       alp_prv_mbiz_begin_proc(prv_card_analyse_crsm);
+
+       // Analyse the data
+       // +CRSM: <sw1>,<sw2>[,<response>]
+
+       /*
+       if ((err = alp_pdrv_analyse_buffer(ioDriverP, &bufP, &bufSize, kCRSM, prv_analyse_line)) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: alp_pdrv_analyse_buffer failed with error (0x%08lX).", err));
+               return err;
+       }
+       */
+       // 0x05 : Security - SIM control Commands
+       // 0x05 : +CRSM, Restricted SIM Access Message
+       if ((err = alp_prv_analyse_response(ioDriverP, 0x05, 0x05,RxSEC_ResRSIMAccess,ioFileP)) != TRUE)
+                       {
+                               TRACE(MSGL_VGSM_INFO, "alp_prv_mbiz_spc_initiate_call: alp_prv_analyse_response() failed with error (0x%08lX).", err));
+                               break;
+                       }
+
+       TRACE(MSGL_VGSM_INFO, "IN prv_card_analyse_crsm "));
+
+       switch (ioFileP->fileStruct)
+       {
+       case SAT_CARD_FILE_STRUCT_TRANSPARENT:  cmdType = VGSM_CARD_COMMAND_INS_READ_BINARY; break;
+       case SAT_CARD_FILE_STRUCT_LINEAR_FIXED:
+       case SAT_CARD_FILE_STRUCT_CYCLIC:               cmdType = VGSM_CARD_COMMAND_INS_READ_RECORD; break;
+       case (char) -1:                                                         cmdType = VGSM_CARD_COMMAND_INS_GET_RESPONSE; break;
+       default:                                                                                return ALP_STATUS_TEL_INVALID_INDEX;
+       }
+
+       // Get <sw1>
+       if ((err = alp_pdrv_get_int(bufP, bufSize, &value)) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: alp_pdrv_get_int failed with error (0x%08lX).", err));
+                       goto failed;
+       }
+
+       TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: Response code (%lu).", value));
+
+       if (value != VGSM_CARD_RESPONSE_NORMAL_ENDING)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: Get info failed."));
+
+               if (value == VGSM_CARD_RESPONSE_REFERENCING_ERROR)
+                       return ALP_STATUS_TEL_CARD_FILE_NOT_FOUND;
+               else
+                       return -1;
+       }
+
+               // Remove the ','
+       if ((err = alp_pdrv_search_char(&bufP, &bufSize, ',')) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: alp_pdrv_search_char failed with error (0x%08lX).", err));
+               goto failed;
+       }
+       bufP++;
+       bufSize--;
+
+       // Skip <sw2>, remove the ','
+       if ((err = alp_pdrv_search_char(&bufP, &bufSize, ',')) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: alp_pdrv_search_char failed with error (0x%08lX).", err));
+               goto failed;
+       }
+       bufP++;
+       bufSize--;
+
+       // Get <response>
+       tmpBufP = bufP;
+       tmpBufSize = bufSize;
+       // Copy the response into the buffer and return
+       if ((err = alp_pdrv_search_char(&tmpBufP, &tmpBufSize, '\x0D')) != TRUE)
+       {
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: alp_pdrv_search_char failed with error (0x%08lX).", err));
+               goto failed;
+       }
+
+       tmpBufSize = (tmpBufP - bufP);
+       if ( (tmpBufSize/2) > ioFileP->bufSize )
+       {
+               err = ALP_STATUS_TEL_BUFFER_SIZE;
+               TRACE(MSGL_VGSM_INFO, "prv_card_analyse_crsm: failed because ioFileP->bufSize=%ld and tmpBufSize=%ld ", ioFileP->bufSize,tmpBufSize/2));
+
+               goto failed;
+       }
+
+       val = ioFileP->bufSize;
+       if ((err = alp_pdrv_hexadecimal_string_to_bytes((char*)bufP, bufSize, ioFileP->bufP+ioFileP->byteCount, &val)) != TRUE)
+       {
+               TRACE( "prv_card_analyse_crsm: alp_pdrv_hexadecimal_string_to_bytes failed with error (0x%08lX).", err));
+               goto failed;
+       }
+
+       if (cmdType == VGSM_CARD_COMMAND_INS_GET_RESPONSE)
+       {
+               ioFileP->fileSize = (ioFileP->bufP[2]*256) + ioFileP->bufP[3];
+               ioFileP->fileStruct = ioFileP->bufP[13];
+               if (ioFileP->fileStruct != SAT_CARD_FILE_STRUCT_TRANSPARENT)
+                       ioFileP->recSize  = ioFileP->bufP[14];
+       }
+       else if( (cmdType == VGSM_CARD_COMMAND_INS_READ_RECORD) && (ioFileP->mode == SAT_CARD_MODE_READ_FILE) )
+       {
+               ioFileP->recId++;
+       }
+
+       // Update byte counter
+       ioFileP->byteCount += val;
+       ioFileP->bufSize-=val;
+
+       // Remove the line
+       alp_pdrv_comm_remove_line(ioDriverP);
+
+failed:
+
+       return err;
+}
+
+
+
+
+
+
+#endif
+
+
+
diff --git a/vmodem/sat/sat_util.h b/vmodem/sat/sat_util.h
new file mode 100644 (file)
index 0000000..0d6e559
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef        _SAT_UTIL_H_
+#define _SAT_UTIL_H_
+
+#include "sat_values.h"
+
+//#include <linuxtapi.h>
+
+#define        SIM_TON_UNKNOWN                                 0 //unknown
+#define        SIM_TON_INTERNATIONAL                           1 //international number
+#define        SIM_TON_NATIONAL                                        2 //national number
+#define        SIM_TON_NETWORK_SPECIFIC                        3 //natwork specific number
+#define        SIM_TON_DEDICATED_ACCESS                        4 //subscriber number
+#define        SIM_TON_ALPHA_NUMERIC                           5//alphanumeric, GSM 7-bit default alphabet)
+#define        SIM_TON_ABBREVIATED_NUMBER              6 //abbreviated number
+#define        SIM_TON_RESERVED_FOR_EXT                        7 //reserved for extension
+
+
+#define MAX_UDH_LEN            137
+#define UDH_MAX                                7
+#define SMDATA_SIZE_MAX        160
+
+
+#define FAIL                   0x00
+#define SUCCESS                0x01
+
+
+
+
+
+//////////////////////////////////TPDU type////////////////////////////////
+#if 0
+typedef enum
+{
+       SMS_TPDU_DELIVER                                = 0x00, // sc -> ms
+       SMS_TPDU_DELIVER_REPORT         = 0x00, // ms -> sc
+       SMS_TPDU_SUBMIT                         = 0x01, // ms -> sc
+       SMS_TPDU_SUBMIT_REPORT          = 0x01, // sc -> ms
+       SMS_TPDU_STATUS_REPORT          = 0x02, // sc -> ms
+       SMS_TPDU_COMMAND                                = 0x02, // ms -> sc
+       SMS_PDU_INVALID_TYPE
+
+} SmsTPDUType;
+
+typedef struct
+{
+       int             year;
+       int             month;
+       int             day;
+       int             hour;
+       int             minute;
+       int             second;
+
+} TmDateTime;
+#endif
+
+#define BASE_YEAR              70L                                     /* 1970 is the base year */
+#define MAX_YEAR                       130L                                    /* 2030 is the max year */
+
+
+#define        SIM_SMSP_ADDRESS_LEN                                    20      // digit length
+
+#define SET_TON_NPI(dest, ton, npi) {  \
+       dest = 0x80;                                            \
+       dest |= (ton & 0x07) << 4;                      \
+       dest |= npi & 0x0F;                                     \
+}
+
+
+int   Display_Text( DP_TEXT* dp_text);
+int   Get_Inkey( GET_INKEY* get_inkey);
+int   Get_Input( GET_INPUT* get_input);
+int   Set_Menu(void *data);
+int   Select_Item(void *data);
+int   Send_SMS(void *data);
+int   Set_Up_Call(void *data);
+
+int sat_apdu_encode(unsigned char tag, SatApduEncoderCallback getDataF, void* HLDataP, char** stringPP);
+
+
+#if 0
+
+
+typedef struct
+{
+       /************HEADER************/
+
+       // message type [M]
+       SmsTPDUType  msgType ;   //bit 0 ,1
+
+       // reject duplicates [M]
+       BOOL rd ;  // bit 2
+
+       // validity period format [M]
+       TapiNetTextVPType vpf ; //  bits 3, 4
+
+       // reply path [M]
+       BOOL rp ; //bit 7
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       // status report request
+       BOOL  srr ;  // bit 5
+
+       /************BODY************/
+
+       //message reference [M]
+       UINT mr;
+
+       // destination address [M]
+       SmsAddressInfo desAddr;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme [M]
+       TapiNetTextCodingScheme dcs;
+
+       // validity period
+       TapiNetTextVP vp;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+
+}TPDU_SMS_SUBMIT;
+
+typedef struct
+{
+       /************HEADER************/
+
+       // message type [M]
+       SmsTPDUType  msgType;  //bit 0 ,1
+
+       // user data header indication
+       BOOL udhi ;   //bit 6
+
+       /************BODY************/
+
+       // failure Cause [M]
+        UINT   fcs;
+
+       // parameter indicator [M]
+       BYTE paraInd;
+
+       // service centre time stamp [M]
+       TmDateTime scts;
+
+       // protocol identifier [M]
+       BYTE pId;
+
+       // data coding scheme
+       TapiNetTextCodingScheme dcs;
+
+       // user data length [M]
+       UINT udl;
+
+       // user data
+       BYTE *  userData;
+
+}TPDU_SMS_SUBMIT_REPORT;
+
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType;   //bit 0 ,1
+
+       BOOL mms; // bit 2
+
+       BOOL rp; // bit 7
+
+       BOOL udhi;  //bit 6
+
+       BOOL sri; // bit , 5status_report_indication
+
+       /************BODY************/
+
+       SmsAddressInfo orgAddr;
+
+       BYTE  pId;
+
+       TmDateTime scts;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE  * userData;
+
+}TPDU_SMS_DELIVER;
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ;  //bit 6
+
+       /************BODY************/
+
+       UINT fcs;
+
+       BYTE paraInd;
+
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_DELIVER_REPORT;
+
+
+typedef struct
+{
+       /************HEADER************/
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL udhi ; //bit 6
+
+       BOOL srr; //bit 5, status_report_request
+
+       /************BODY************/
+
+       UINT  mr; //message_ref
+
+       BYTE pId;
+
+       BYTE cmdType;
+
+       BYTE msgNum;
+
+       SmsAddressInfo destAddr;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_COMMAND;
+
+
+typedef struct
+{
+       /************HEADER************/
+
+       SmsTPDUType msgType ;   //bit 0 ,1
+
+       BOOL  udhi ; //bit 6
+
+       BOOL mms ; //bit 2
+
+       BOOL srq; //bit 5, status_report_qualifier
+
+       /************BODY************/
+
+       UINT  mr;
+
+       SmsAddressInfo rcpAddr; //recipient_addr
+
+       TmDateTime scts;
+
+       TmDateTime dt; //discharge_time
+
+        BYTE  status;
+
+        BYTE paraInd;
+
+       BYTE pId;
+
+       TapiNetTextCodingScheme dcs;
+
+       UINT udl;
+
+       BYTE * userData;
+
+}TPDU_SMS_STATUS_REPORT;
+
+#endif
+
+/**************************************************************************************
+*** (main.c) function header****************************************************************
+***************************************************************************************
+***************************************************************************************/
+#if 0
+BOOL EncodeSmsDeliverTpdu(SmsAddressInfo SCA, TPDU_SMS_DELIVER tpdu_deliver, char *rawdata, int *rawdata_len);
+//BOOL EncodeSmsDeliverTpdu(char *rawdata, int *rawdata_len, char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+BOOL EncodeSmsSubmitReportTpdu(char *rawdata, int *rawdata_len);
+BOOL DecodeSmsSubmitTpdu(TPDU_SMS_SUBMIT *tpdu_submit, int pdu_len , char * pPDU);
+#endif
+/*
+int SendMessage();
+int ReadMessage();
+int DeleteMessage();
+int ReceiveMessage(int pdu_len, char * pPDU);
+int GetInformation();
+int Setting();
+
+BOOL DecodeCellBroadcastMsg(int length,char * pPDU);
+BOOL EncodeSmsSubmitTpdu(char* diallingNum, int dialNumLen, char* msg, int msg_len) ;
+//BOOL DecodeSmsSubmitTpdu(int pdu_len , char * pPDU);
+int  DecodeSmsDeliverTpdu(int pdu_len , char * pPDU);
+BOOL EncodeSmsDeliverReportTpdu();
+BOOL DecodeSmsSubmitReportTpdu(int length , char *data);
+BOOL DecodeSmsStatusReportTpdu(int pdu_len, char * pPDU);
+*/
+
+/***************************************************************************************/
+
+#endif /* _SAT_UTIL_H_ */
+
diff --git a/vmodem/sat/sat_values.h b/vmodem/sat/sat_values.h
new file mode 100644 (file)
index 0000000..6351fd1
--- /dev/null
@@ -0,0 +1,1150 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#ifndef SAT_VALUES_H
+#define SAT_VALUES_H
+
+#undef FALSE
+#undef TRUE
+#define TRUE 1
+#define FALSE 0
+
+
+#define VGSM_CHARSET_UTF8                                                      1//"UTF-8"
+#define VGSM_CHARSET_UCS2                                                      2//"UCS-2"
+#define VGSM_CHARSET_GSM                                                       3//"GSM-7"
+
+
+/////////////
+#define ALP_STATUS_OK                                          0
+/////////////
+
+
+
+// maximu size of a string in an apdu
+#define VGSM_APDU_CONVERTION_BUFFER_SIZE                       256
+
+
+typedef struct _SatApduDecoder         SatApduDecoder;
+
+// Apdu decoder/encoder callbacks
+typedef int    (*SatApduEncoderCallback)               (unsigned long request, char* bufferP, int* bufferSize, void* HLData);
+typedef int    (*SatApduDecoderCallback)               (char tag, SatApduDecoder* decoderP, char* objectP);
+
+///
+#define MAX_STRING     255;
+
+typedef struct _DISPLAY_TEXT  DP_TEXT;
+struct _DISPLAY_TEXT {
+       char priority;
+       char clear_msg;
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+
+};
+///
+
+typedef struct _GET_INKEY  GET_INKEY;
+struct _GET_INKEY {
+       unsigned char cmd_detail;
+
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+//     char duration_interval;
+//     char  text_len;
+
+};
+///
+typedef struct _GET_INKEY  GET_INPUT;
+struct _GET_INPUT {
+       unsigned char cmd_detail;
+
+       char text_string[255];
+       char coding_scheme;
+       char icon_qualifier;
+       char icon_identifier;
+       char icon_identifier_flag;
+       char immediate_response;
+       char duration;
+       char duration_unit;
+
+
+};
+
+
+typedef struct _SET_MENU  SET_MENU;
+struct _SET_MENU {
+       //unsigned char cmd_detail;
+       char id_num;
+       char alpah_string[255];
+       char item_string[255];
+};
+///
+typedef struct _SEND_SMS  SEND_SMS;
+struct _SEND_SMS {
+       unsigned char cmd_detail;
+       unsigned char address;
+       char dial_num[25];
+       char  tpdu_sms[255];
+};
+///
+
+struct _SatApduDecoder
+{
+       SatApduDecoderCallback  HLSetDataF;
+       void*                                                   HLDataP;
+       unsigned char*                                  formatP;
+       unsigned char*                                  apduP;
+       int                                                     apduSizeInBytes;
+       unsigned char*                                  apduReadP;
+       unsigned char                                   currentObjectTag;
+       unsigned char                                   currentObjectLength;
+};
+
+
+
+
+
+typedef struct _SatCmdResponseInternal SatCmdResponseInternal;
+struct _SatCmdResponseInternal
+{
+       char cmdId;             //!< Command Identifier
+       char resCode;           //!< Result codes applicable to command iCmdId, see ALP_TEL_CAT_RES_XXX
+       char infoType;          // type for local information
+       int infoLen;                    // length for local information
+       char *infoData;
+};
+
+
+
+#define HEX_DIGIT(b) ((b) >= '0' && (b) <= '9' ? (b) - '0' : (b) - 'A' + 10)
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+
+
+
+#define CAT_CONFIG_STRING_MAX_SIZE     48                      //!< Cat config max size
+
+#define        alp_prv_mbiz_param_to_buffer(bufferP, paramP, paramSize)        \
+{                                                                                                                              \
+       unsigned char* bufferOffset = (unsigned char*) (bufferP);                       \
+       memmove((bufferP), (paramP), (paramSize));                                      \
+       bufferOffset += (paramSize);                                                                    \
+       (bufferP) = (void*) bufferOffset;                                                                       \
+}
+
+// STK config
+#define                DEFAULT_PROFIL_SIZE     17
+
+// Structure and coding of TERMINAL PROFILE
+//     First byte (Download)
+#define                PROFILE_DOWNLOAD_FACILITY                       0x01
+#define                SMS_PP_DATA_DOWNLOAD_FACILITY   0x02
+#define                CELL_BROADCAST_FACILITY                 0x04
+#define                MENU_SELECTION_FACILITY                 0x08
+#define                NIEEXX_RESPONSE_CODE_FACILITY           0x10
+#define                TIMER_EXPIRATION_FACILITY                       0x20
+#define                USSD_STRING_FACILITY                            0x40
+#define                AUTOMATIC_REDIAL_FACILITY                       0x80
+
+//     Second byte (Other)
+#define                COMMAND_RESULT_FACILITY                                 0x01
+#define                CALL_CONTROL_BY_SIM_FACILITY                            0x02
+#define                CC_WITH_CELL_IDENTITY_FACILITY                          0x04
+#define                SHORT_MESSAGE_CONTROL_BY_SIM_FACILITY   0x08
+#define                ALPHA_IDENTIFIER_HANDLING_FACILITY              0x10
+#define                UCS2_ENTRY_FACILITY                                                     0x20
+#define                UCS2_DISPLAY_FACILITY                                           0x40
+#define                DISPLAY_EXTENSION_TEXT_FACILITY                 0x80
+
+//     Third byte (Proactive SIM)
+#define                PROSIM_DISPLAY_TEXT_FACILITY            0x01
+#define                PROSIM_GET_INKEY_FACILITY                       0x02
+#define                PROSIM_GET_INPUT_FACILITY                       0x04
+#define                PROSIM_MORE_TIME_FACILITY                       0x08
+#define                PROSIM_PLAY_TONE_FACILITY                       0x10
+#define                PROSIM_POLL_INTERVAL_FACILITY           0x20
+#define                PROSIM_POLLING_OFF_FACILITY             0x40
+#define                PROSIM_REFRESH_FACILITY                 0x80
+
+//     Fourth byte (Proactive SIM)
+#define                PROSIM_SELECT_ITEM_FACILITY             0x01
+#define                PROSIM_SEND_SHORT_MESG_FACILITY 0x02
+#define                PROSIM_SEND_SS_FACILITY                 0x04
+#define                PROSIM_SEND_USSD_FACILITY                       0x08
+#define                PROSIM_SETUP_CALL_FACILITY                      0x10
+#define                PROSIM_SETUP_MENU_FACILITY              0x20
+#define                PROSIM_LOCAL_INFO1_FACILITY             0x40
+#define                PROSIM_LOCAL_INFO2_FACILITY             0x80
+
+//     Fifth byte (Event driven information)
+#define                PROSIM_SETUP_EVENT_LIST_FACILITY                0x01
+#define                EVENT_MT_CALL_FACILITY                                  0x02
+#define                EVENT_CALL_CONNECTED_FACILITY                   0x04
+#define                EVENT_CALL_DISCONNECT_FACILITY          0x08
+#define                EVENT_LOCATION_STATUS_FACILITY          0x10
+#define                EVENT_USER_ACTIVITY_FACILITY                    0x20
+#define                EVENT_IDLE_SCREEN_FACILITY                              0x40
+#define                EVENT_CARD_READER_STATUS_FACILITY       0x80
+
+//     Sixth byte (Event driven information extensions)
+#define                EVENT_LANGUAGE_SELECTION_FACILITY               0x01
+#define                EVENT_BROWSER_TERMINATION_FACILITY      0x02
+#define                EVENT_DATA_AVAILABLE_FACILITY                   0x04
+#define                EVENT_CHANNEL_STATUS_FACILITY                   0x08
+
+//     Seventh byte (Multiple card proactive commands) for class "a"
+#define                PROSIM_POWER_ON_CARD_FACILITY                   0x01
+#define                PROSIM_POWER_OFF_CARD_FACILITY                  0x02
+#define                PROSIM_PERFORM_CARD_APDU_FACILITY               0x04
+#define                PROSIM_GET_READER_STATUS_FACILITY               0x08
+#define                PROSIM_GET_READER_IDENTIFIER_FACILITY           0x10
+
+//     Eighth byte (Proactive SIM)
+#define                PROSIM_TIMER_MANAGEMENT_FACILITY                        0x01
+#define                PROSIM_GET_TIMER_VALUE_FACILITY                 0x02
+#define                PROSIM_PROVIDE_LOCAL_INFO3_FACILITY             0x04
+#define                BINARY_GET_KEY_FACILITY                                 0x08
+#define                SETUP_IDLE_MODE_TEXT_FACILITY                           0x10
+#define                RUN_AT_COMMAND_FACILITY                                 0x20
+#define                SETUP_CALL_2ND_ALPHA_ID_FACILITY                        0x40
+#define                SECOND_CAPABILITY_CONFIG_PARAM_FACILITY         0x80
+
+//     Ninth byte
+#define                SUSTAINED_DISPLAY_TEXT_FACILITY                 0x01
+#define                SEND_DTMF_COMMAND_FACILITY                              0x02
+#define                PROSIM_PROVIDE_BCCH_INFO_FACILITY               0x04
+#define                PROSIM_PROVIDE_LANGUAGE_INFO_FACILITY   0x08
+#define                PROSIM_PROVIDE_TIMING_INFO_FACILITY             0x10
+#define                PROSIM_LANGUAGE_NOTIFICATION_FACILITY   0x20
+#define                PROSIM_LAUNCH_BROWSER_FACILITY                  0x40
+
+//     Tenth byte (Soft keys support)
+#define                SOFTKEY_FOR_SELECT_ITEM_FACILITY                        0x01
+#define                SOFTKEY_FOR_SETUP_MENU_FACILITY                 0x02
+
+//     Eleventh byte (Soft keys information)
+#define                MAXIMUM_NUMBER_OF_SOFTKEYS                              0x00
+
+//     Twelfth byte (Bearer Independent protocol proactive commands (class "e")
+#define                PROSIM_OPEN_CHANNEL_FACILITY                            0x01
+#define                PROSIM_CLOSE_CHANNEL_FACILITY                           0x02
+#define                PROSIM_RECEIVE_DATA_FACILITY                            0x04
+#define                PROSIM_SEND_DATA_FACILITY                                       0x08
+#define                PROSIM_GET_CHANNEL_STATUS_FACILITY              0x10
+
+//     Thirteenth byte (Bearer Independent protocol supported bearers (class "e")
+#define                CSD_SUPPORTED_FACILITY                                          0x01
+#define                GPRS_SUPPORTED_FACILITY                                 0x02
+#define                NUMBER_OF_CHANNELS_SUPPORTED_BY_ME(X)   (((char)X) << 5)
+
+//     Fourteenth byte (Screen height)
+#define                NUMBER_OF_CHARACTERS_DOWN_TE_DISPLAY(X) (((char)X) & 0x1F)
+#define                SCREEN_SIZING_PARAMETERS_FACILITY                               0x80
+
+//     Fifteenth byte (Screen width)
+#define                NUMBER_OF_CHARACTERS_ACROSS_TE_DISPLAY(X)       (((char)X) & 0x7F)
+#define                VARIABLE_SIZE_FONTS_FACILITY                                    0x80
+
+//     Sixteenth byte (Screen effects)
+#define                DISPLAY_CAN_BE_RESIZED                          0x01
+#define                TEXT_WRAPPING_SUPPORTED                 0x02
+#define                TEXT_SCROLLING_SUPPPORTED                       0x04
+#define                MENU_WIDTH_REDUCTION(X)                 (((char)X) << 5)
+
+//     Seventeenth byte: (Bearer independent protocol supported transport interface) for class "e"
+#define                TCP_SUPPORTED                                           0x01
+#define                UDP_SUPPPORTED                                          0x02
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#define SELECT_BY_PATH_REFERENCING                             0x08
+#define SELECT_BY_FILE_IDENTIFIER                              0x00
+#define RETURN_FCP_TEMPLATE                                            0x04
+
+#define SEND_LINE_MAX_BUFFER                                   500 // as alp_pdrv_comm_send_line takes into account up to 512 bytes in the arglist
+#define SEND_LINE_MAX_BUFFER                                   500 // as alp_pdrv_comm_send_line takes into account up to 512 bytes in the arglist
+// the data buffer to send with the AT command should not exceed: 512 bytes - (max command AT header size)
+
+#define COMMAND_QUALIFIER                                              objectP[2]      
+#define TYPE_OF_COMMAND                                                        objectP[1]
+
+#define NON_EXPLICIT_ICON                                              0x01
+
+#define GETINPUT_DETAILS_HIDE_INPUT                            0x04
+#define GETINPUT_DETAILS_PACKED_BIT                    0x08
+
+#define GETINKEY_DETAILS_YES_NO                                        0x04
+#define GETINKEY_DETAILS_DCS_MASK                              0x03
+
+#define DISPLAY_TEXT_DETAILS_CLEAR_AFTER_DELAY 0x80
+#define DISPLAY_TEXT_DETAILS_PRIORITY                  0x01
+
+#define SETUP_MENU_DETAILS_SOFTKEY                             0x01
+#define SELECT_ITEM_DETAILS_SOFTKEY                            0x04
+
+#define GET_DETAILS_HELP_INFO                                  0x80
+
+#define READ_RECORD_MODE_ABSOLUTE                              0x04
+
+#define SELECT_BY_PATH_REFERENCING                             0x08
+#define SELECT_BY_FILE_IDENTIFIER                              0x00
+
+#define RETURN_FCP_TEMPLATE                                            0x04
+
+#define CAT_CONFIG_STRING_MAX_SIZE                             48              //!< Cat config max size
+
+
+
+/**
+ * @addtogroup ALP_TELEPHONY_SERVICES_CAT
+ * @{
+ */
+typedef struct _SatConfig SatConfig;
+struct _SatConfig
+{
+       char*                                   profileP;                               //!< Terminal Profile standard parameters
+       int                                            profileSize;                     //!< Profile data size, in bytes
+       char                                            lanCode[2];                     //!< ISO 639 language code
+       char                                            mode;                                   //!< Result code presentation enable/disable
+};
+
+typedef struct _SatFile SatFile;
+struct _SatFile
+{
+       int*                                    pathP;                  //!< Absolute path of the file to read in the SIM.
+                                                                                               //!< Example: { 0x3F00, 0x7F20, 0x6F21 }
+                                                                                               //!< Consists of file identifiers from the Master File
+                                                                                               //!< to the Elementary File to be accessed
+       char*                                   bufP;                   //!< Buffer to be filled in with requested file body bytes.
+       int                                             bufSize;                //!< Buffer size in bytes
+       int                                             byteCount;              //!< Amount of applicable bytes in ioBufP
+
+       int                                     partOffset;             //!< Offset of requested file body part
+       int                                     partSize;               //!< Size of requested file body part
+
+       int                                     fileSize;               //!< EF size
+       char                                            fileStruct;             //!< EF structure (transparent, linear fixed or cyclic)
+       char                                            mode;                   //!< Access mode (see EF access mode)
+
+       char                                            pathCount;              //!< File identifiers count in iPathP
+       char                                            recId;                  //!< Identifier of the record to be read. Range 1..254
+       char                                            recSize;                //!< Size of a record, in bytes.
+                                                                                               //!< 0 if the file is not a Linear Fixed or a Cyclic EF
+};
+
+typedef struct _SatCmdParams SatCmdParams;
+struct _SatCmdParams
+{
+       void*                                           cmdParamP;                              //!< Structure associated to the command (according to iCmdId)
+       int                                             cmdParamSize;                   //!< Size of the specific command parameter buffer
+                                                                                                               //!< Common parameter for all (almost) commands
+       char*                                           textP;                                  //!< Text to display
+       char                                            iconId;                                 //!< Icon identifier
+       char                                            cmdId;                                  //!< See the Proactive Commands Id for more details
+       char                                            explicitIcon;                   //!< Icon is explicit
+       char                                            noResponse;                             //!< true if the command does not need a response       
+       int                                             textSize;                               //!< The size of the encoded text
+};
+
+typedef struct _SatCmdResponse SatCmdResponse;
+struct _SatCmdResponse
+{
+       char*                                           respP;                                  //!< Associated text response
+       unsigned char                           itemIdentifier;                 //!< Item identifier  
+       int                                             respSize;                               //!< Associated text response size in bytes
+       char                                            cmdId;                                  //!< Command Identifier
+       char                                            respType;                               //!< Expected response type, see ALP_TEL_CAT_RESP_TYPE_XXX
+       char                                            resCode;                                //!< Result codes applicable to command iCmdId, see ALP_TEL_CAT_RES_XXX
+       char                                            addInfo;                                //!< Additional information code
+                                                                                                               //!< -> Yes/No response or Item identifier for instance
+};
+
+typedef struct _SatMenuSelection SatMenuSelection;
+struct _SatMenuSelection
+{
+       char                                            evtCode;                                //!< Menu Selection event code, see ALP_TEL_CAT_MENU_SELECTION_XXX
+       char                                            appId;                                  //!< Associated application identifier
+};
+
+typedef struct _SatEventToCard SatEventToCard;
+struct _SatEventToCard
+{
+       char                                            evtCode;                                        //!< Event Download code, see ALP_TEL_CAT_EVENT_XXX
+       char                                            lanCode[2];                                     //!< ISO 639 language code
+       char                                            browserTerminationCause;        //!< Browser Termination cause code, see ALP_TEL_CAT_BROWSER_XXX
+};
+
+
+typedef struct _SatRefreshFileList     SatRefreshFileList;
+struct _SatRefreshFileList
+{
+       unsigned short*                         filePathP;                      //!< Concatenated absolute paths of the modified EF
+                                                                                                       //!< or NULL if no specific file has been mentioned.
+       unsigned char                           filePathCount;          //!< Number of paths in the file list
+       unsigned char                           fileIdCount;            //!< Number of files described in the file list
+       unsigned char                           opCode;                         //!< Operation code (see above the refresh command qualifier )
+       unsigned char*                          AID;                            //!< Application identifier (only used for 3G platform)
+};
+
+typedef struct _SatSetUpEventList SatSetUpEventList;
+struct _SatSetUpEventList
+{
+       char*                                   eventP;                         //!< Events to be monitored, see ALP_TEL_CAT_EVENT_XXX
+       char                                            eventCount;                     //!< Events number in eventP or 0 to stop monitoring
+};
+
+typedef struct _SatSetUpCall SatSetUpCall;
+struct _SatSetUpCall
+{
+       char*                                   bearerCapP;                             //!< Bearer capability configuration params (GSM 04.08 5.3.0 section 10.5.4.5)
+       char*                                           numberP;                                //!< Dialing number
+       char*                                           userConfTextP;                  //!< Text to display. NULL if not provided
+       char*                                           callEstaTextP;                  //!< Text to display, NULL if not provided
+       char*                                           subAddressP;                    //!< called party subaddress
+       int                                             userConfTextSize;               //!< Text buffer size in bytes
+       int                                             numberSize;                             //!< Number buffer size in bytes
+       int                                             callEstaTextSize;               //!< Call establishment text buffer size in bytes
+       int                                             subAddressSize;                 //!< subaddress size in bytes
+       char                                            bearerCapSize;                  //!< Bearer capability size, in bytes
+       
+       unsigned long                           duration;                               //!< if the time elapsed since the first call set-up attempt has exceeded the duration request, the redial mechanism shall be terminated 
+       char                                            condition;                              //!< Set up call commmand qualifier, see ALP_TEL_CAT_SETUP_CALL_XXX
+       
+       char                                            userConfIconId;                 //!< Icon id. 0 if no icon
+       char                                            userConfExplicitIcon;   //!< Icon is explicit
+       char                                            callEstaIconId;                 //!< Icon id. 0 if no icon
+       char                                            callEstaExplicitIcon;   //!< Icon is explicit
+       
+};
+
+typedef struct _SatLaunchBrowser SatLaunchBrowser;
+struct _SatLaunchBrowser
+{
+       char*                                           urlP;                           //!< The URL
+       int                                             urlSize;
+       char*                                           gatewayP;                       //!< Gateway name, Proxy identity to be used
+       int                                             gatewaySize;
+       int*                                    filePathP;                      //!< Concatenated absolute paths of provisioning EF
+                                                                                                       //!< or NULL if no specific file has been mentioned.
+       char*                                   prefBearersP;           //!< Prioritized list of ALP_TEL_CAT_BEARER_XXX bearer codes
+       char                                            fileIdCount;            //!< File identifiers count in filePathP
+       char                                            prefBearerCount;        //!< Number of bearer codes in prefBearersP.
+       char                                            condition;                      //!< Launch browser conditions, see ALP_TEL_CAT_LAUNCH_BROWSER_XXX
+       char                                            browserId;                      //!< Browser Identity
+};
+
+typedef struct _SatPlayTone SatPlayTone;
+struct _SatPlayTone
+{
+       int                                     sndDuration;            //!< Sound duration in ms. 0 for default or 100..15300000
+       char                                            sndCode;                        //!< One of the ALP_TEL_CAT_PLAY_TONE_XXX codes
+       unsigned char                           vibrateAlert;           //!< One of the ALP_TEL_CAT_VIBRATE_XXX codes
+};
+
+typedef struct _SatDisplayText SatDisplayText;
+struct _SatDisplayText
+{
+       char                                            priority;                       //!< Priority level
+       char                                            clearAfterDelay;        //!< Wait for user's action
+       char                                            immediateResponse;      //!< Send a response to the SIM ASAP
+       unsigned long                           duration;                       //!< the terminal shall continue to dsiplay the text until the expiration of this variable display timeout      
+};
+
+typedef struct _SatGetInkey SatGetInkey;
+struct _SatGetInkey
+{
+       char                                            helpInfo;                       //!< Help information is provided by the SIM
+       char                                            respType;                       //!< Expected response type. See ALP_TEL_CAT_RESP_TYPE_XXX
+       unsigned long                           duration;                       //!> the terminal shall wait until either the user enters a single characters or the timeout expires.
+};
+
+typedef struct _SatGetInput SatGetInput;
+struct _SatGetInput
+{
+       char*                                           defRespP;                       //!< Default response text to propose
+       int                                             defRespSize;            //!< Default response text size in bytes
+       char                                            hideUserInput;          //!< Mask entered data
+       char                                            helpInfo;                       //!< Help information is provided by the SIM
+       char                                            minRespLength;          //!< Minimum response length, in characters
+       char                                            maxRespLength;          //!< Maximum response length, in characters
+       char                                            respType;                       //!< Expected response type, see ALP_TEL_CAT_RESP_TYPE_XXX
+};
+
+typedef struct _SatItem SatItem;
+struct _SatItem
+{
+       char*                                           nameP;                          //!< Item name
+       int                                             nameSize;                       //!< Item name size in bytes
+       char                                            id;                                     //!< Item identifier
+       char                                            iconId;                         //!< Icon Identifier
+       char                                            expIcon;                        //!< Icon is explicit
+       char                                            nextActionInd;          //!< Identifier of the next command for this item
+       SatItem*                                nextItemP;                      //!> @ of the next item (if any)
+};
+
+typedef struct _SatItemList SatItemList;
+struct _SatItemList
+{
+       SatItem*                                firstItemP;                     //!< The first Item
+       int                                             itemCount;                      //!< Number of items 
+       char                                            softKey;                        //!< Item can be selected by tapping on its icon
+       char                                            helpInfo;                       //!< Help information is provided by the SIM
+       char                                            defItemId;                      //!< Identifier of the item that should be pre-selected.
+};
+
+typedef struct _SatSendShortMessage SatSendShortMessage;
+struct _SatSendShortMessage
+{
+       char*                                           addressP;                       //!< RP_Destination_Address (optional)
+       int                                             addressSize;
+       char*                                   TPDUP;                          //!< SMS TPDU
+       int                                             TPDUSize;
+       char                                            packingRequired;
+};
+
+typedef struct _SatBuffer SatBuffer;
+struct _SatBuffer              //!< used in: SendData, SendDTMF, Send USSD, Send SS
+{
+       char*                                   bufferP;                                //!< the data buffer
+       int                                             bufferSize;                             //!< the data buffer size
+       char                                            other;                                  //!< other parameter specific to the command (if any)
+};
+
+typedef struct _SatOpenChannel SatOpenChannel;
+struct _SatOpenChannel
+{
+       char*                                           addressP;
+       char*                                           subAddressP;
+       char*                                           otherAddressP;
+       char*                                           destinationAddressP;
+       char*                                           loginP;
+       char*                                           passwordP;
+       char*                                   bearerParamsP;
+       char*                                           accessPointP;
+       int                                     duration1;                              //!< duration1 in ms
+       int                                     duration2;                              //!< duration2 in ms
+       int                                     bufferSize;
+       int                                     transportPort;
+       char                                            onDemand;                               //!< Is link established immediately
+       char                                            bearerCode;                     //!< Bearer code, see ALP_TEL_CAT_BEARER_XXX
+       char                                            otherAddressType;               //!< see ALP_TEL_CAT_ADDRESS_XXX
+       char                                            destinationAddressType; //!< see ALP_TEL_CAT_ADDRESS_XXX
+       char                                            transportType;                  //!< see ALP_TEL_CAT_TRANSPORT_XXX
+       char                                            addressSize;
+       char                                            subAddressSize;
+       char                                            otherAddressSize;
+       char                                            bearerParamsSize;
+       char                                            loginSize;
+       char                                            passwordSize;
+       char                                            destinationAddressSize;
+       char                                            accessPointSize;
+};
+
+
+//! answer made by the phone module directly to the SIM 
+typedef struct _SatMEanswer SatMEanswer;
+struct _SatMEanswer    
+{
+       char                                            cmdId;                                  //!< Command Identifier
+       char                                            resCode;                                //!< Result codes applicable to command iCmdId 
+       char                                            addInfo;                                //!< Additional information code
+                               
+};
+
+
+//! answer made by the SIM to the phone module CALL CONTROL or MO Short Message CONTROL command 
+typedef struct _SatSIManswer SatSIManswer;
+struct _SatSIManswer   
+{
+       char                                    result;                         //!< call control or MO Short Message control result, see ALP_TEL_CAT_RESULT_CONTROL_XXX
+       
+       char*                                   textP;                          //!< Text to display
+       int                                     textSize;                       //!< The size of the encoded text
+       
+       char*                                   addressP1;                      //!> if it's a call control answer adressP1= dialling number, if the address data is not present, the terminal shall assume the dialling number is not to be modified 
+                                                                                               //!> if it's a MO short message control answer addressP1= RP_Destination_Address, if the address data object 1 is not present, then the ME shall assume the RP_Destination_Address of the Service Centre is not to be modified.
+       char                                    addressSize1;           //!> address size
+       
+       char*                                   addressP2;                      //!> apply only if it's a a MO short message control answer addressP2= TP_Destination_Address, if the address data object 2 is not present, then the ME shall assume the TP_Destination_Address is not to be modified.
+       char                                    addressSize2;           //!> address size
+       
+                                                                                               
+       char*                                   subAddressP;            //!> subaddress
+       char                                    subAddressSize;         //!> subaddress buffer size
+       
+       char                                    BCrepeatIndicator;      //!> BC repeat indicator
+       
+       char*                           capabilityConfP1;       //!< Capability configuration parameters1
+       char                                    capabilityConfSize1;//!< the capability configuration parameters1 size
+       
+       char*                           capabilityConfP2;       //!< Capability configuration parameters2 
+       char                                    capabilityConfSize2;//!< the capability configuration parameters2 size
+};
+
+
+
+
+// Card command
+#define SAT_CARD_COMMAND_INS_READ_BINARY                               0xB0
+#define SAT_CARD_COMMAND_INS_READ_RECORD                               0xB2
+#define SAT_CARD_COMMAND_INS_GET_RESPONSE                              0xC0
+#define SAT_CARD_COMMAND_INS_UPDATE_BINARY                             0xD6
+#define SAT_CARD_COMMAND_INS_UPDATE_RECORD                             0xDC
+#define SAT_CARD_COMMAND_INS_STATUS                                    0xF2
+
+
+// Card response
+#define SAT_CARD_RESPONSE_NORMAL_ENDING                                        0x90
+#define SAT_CARD_RESPONSE_NORMAL_ENDING_WITH_EXTRA_INFO        0x91
+#define SAT_CARD_RESPONSE_DATA_LEN_WITH_DOWNLOAD_ERROR         0x9E
+#define SAT_CARD_RESPONSE_DATA_LEN                                                     0x9F
+#define SAT_CARD_RESPONSE_SIM_TOOLKIT_BUSY                                     0x93
+#define SAT_CARD_RESPONSE_MEMORY_ERROR                                         0x92
+#define SAT_CARD_RESPONSE_REFERENCING_ERROR                            0x94
+#define SAT_CARD_RESPONSE_SECURITY_ERROR                                       0x98
+#define SAT_CARD_RESPONSE_INCORRECT_PARAM3                                     0x67
+#define SAT_CARD_RESPONSE_INCORRECT_PARAM1OR2                          0x6B
+#define SAT_CARD_RESPONSE_UNKNOW_INS                                           0x6D
+#define SAT_CARD_RESPONSE_WRONG_INS                                            0x6E
+#define SAT_CARD_RESPONSE_TECHNICAL_PROBLEM                            0x6F
+
+
+// APDU encoder/decoder
+
+// Call control or MO SMS conrol
+#define SAT_ALLOWED                                                            0x00
+#define        SAT_NOT_ALLOWED                                                 0x01
+#define        SAT_ALLOWED_WITH_MODIFICATION                           0x02
+
+
+
+// BER-tags
+#define SAT_RESPONSE                                                           0x00
+#define SAT_PROACTIVE_SIM_COMMAND                                      0xD0
+#define        SAT_SMS_PP_DOWNLOAD                                             0xD1
+#define        SAT_CELL_BRAOADCAST_DOWNLOAD                            0xD2
+#define        SAT_MENU_SELECTION                                                      0xD3
+#define        SAT_CALL_CONTROL                                                        0xD4
+#define        SAT_MO_SHORT_MESSAGE_CONTROL                            0xD5
+#define        SAT_EVENT_DOWNLOAD                                                      0xD6
+#define        SAT_TIMER_EXPIRATION                                            0xD7
+
+
+
+
+// SIMPLE-TLV data objects tags 
+#define SAT_COMMAND_DETAILS                                            0x01 //!> Command details tag
+#define SAT_DEVICE_IDENTITIES                                          0x02 //!> Device identity tag
+#define SAT_RESULT                                                                     0x03 //!> Result tag
+#define SAT_DURATION                                                           0x04 //!> Duration tag 
+#define SAT_ALPHA_IDENTIFIER                                           0x05 //!> Alpha identifier tag
+#define SAT_ADDRESS                                                            0x06 //!> Address tag
+#define SAT_CAPABILILITY_CONFIGURATION_PARAMETERS      0x07 //!> Capability configuration parameters tag
+#define SAT_SUBADDRESS                                                         0x08 //!> Subaddress tag
+#define SAT_SS_STRING                                                          0x09 //!> SS string tag
+#define SAT_USSD_STRING                                                        0x0A //!> USSD string tag
+#define SAT_SMS_TPDU                                                           0x0B //!> SMS TPDU tag
+#define SAT_CELL_BROADCAST_PAGE                                        0x0C //!> Cell Broadcast page tag
+#define SAT_TEXT_STRING                                                        0x0D //!> Text string tag 
+#define SAT_TONE                                                                       0x0E //!> Tone tag
+#define SAT_ITEM                                                                       0x0F //!> Item tag
+#define SAT_ITEM_IDENTIFIER                                            0x10 //!> Item identifier tag 
+#define SAT_RESPONSE_LENGTH                                            0x11 //!> Response length tag 
+#define SAT_FILE_LIST                                                          0x12 //!> File List tag
+#define SAT_LOCATION_INFORMATION                                       0x13 //!> Location Information tag
+#define SAT_IMEI                                                                       0x14 //!> IMEI tag 
+#define SAT_HELP_REQUEST                                                       0x15 //!> Help request tag 
+#define SAT_NETWORK_MEASUREMENT_RESULTS                        0x16 //!> Network Measurement Results tag 
+#define SAT_DEFAULT_TEXT                                                       0x17 //!> Default Text tag
+#define SAT_ITEMS_NEXT_ACTION_INDICATOR                        0x18 //!> Items Next Action Indicator tag
+#define SAT_EVENT_LIST                                                         0x19 //!> Event list tag
+#define SAT_CAUSE                                                                      0x1A //!> Cause tag
+#define SAT_LOCATION_STATUS                                            0x1B //!> Location status tag 
+#define SAT_TRANSACTION_IDENTIFIER                                     0x1C //!> Transaction identifier tag
+#define SAT_BCCH_CHANNEL_LIST                                          0x1D //!> BCCH channel list tag
+#define SAT_ICON_IDENTIFIER                                            0x1E //!> Icon identifier tag
+#define SAT_ITEM_ICON_IDENTIFIER_LIST                          0x1F //!> Item Icon identifier list tag
+//#define SAT_CARD_READER_STATUS                                               0x20 //!> Card reader status tag
+#define SAT_CARD_ATR                                                           0x21 //!> Card ATR tag
+#define SAT_C_ADPU                                                                     0x22 //!> C-APDU tag 
+#define SAT_R_ADPU                                                                     0x23 //!> R-APDU tag
+#define SAT_TIMER_IDENTIFIER                                           0x24 //!> Timer identifier tag
+#define SAT_TIMER_VALUE                                                        0x25 //!> Timer value tag
+#define SAT_DATE_TIME_AND_TIME_ZONE                            0x26 //!> Date-Time and Time zone tag
+#define SAT_CALL_CONTROL_REQUESTED_ACTION                      0x27 //!> Call control requested action tag
+#define SAT_AT_COMMAND                                                         0x28 //!> AT Command tag
+#define SAT_AT_RESPONSE                                                        0x29 //!> AT Response tag
+#define SAT_BC_REPEAT_INDICATOR                                        0x2A //!> BC Repeat Indicator tag
+#define SAT_IMMEDIATE_RESPONSE                                         0x2B //!> Immediate response tag
+#define SAT_DTMF_STRING                                                        0x2C //!> DTMF string tag
+#define SAT_LANGUAGE                                                           0x2D //!> Language tag
+#define SAT_TIMING_ADVANCE                                                     0x2E //!> Timing Advance tag
+#define SAT_AID                                                                        0x2F //!> AID tag 
+#define SAT_BROWSER_IDENTITY                                           0x30 //!> Browser Identity tag 
+#define SAT_URL                                                                        0x31 //!> URL tag
+#define SAT_BEARER                                                                     0x32 //!> Bearer tag
+#define SAT_PROVISIONING_FILE_REFERENCE                        0x33 //!> Provisioning Reference File tag
+#define SAT_BROWSER_TERMINATION_CAUSE                          0x34 //!> Browser Termination Cause tag
+#define SAT_BEARER_DESCRIPTION                                         0x35 //!> Bearer description tag
+#define SAT_CHANNEL_DATA                                                       0x36 //!> Channel data tag
+#define SAT_CHANNEL_DATA_LENGTH                                        0x37 //!> Channel data length tag
+#define SAT_CHANNEL_STATUS                                                     0x38 //!> Channel status tag
+#define SAT_BUFFER_SIZE                                                        0x39 //!> Buffer size tag
+//#define SAT_CARD_READER_IDENTIFIER                                   0x3A //!> Card reader identifier tag
+#define SAT_FILE_UPDATE_INFORMATION                            0x3B //!> File Update Information tag
+#define SAT_SIM_ME_INTERFACE_TRANSPORT_LEVEL           0x3C //!> UICC/terminal interface transport level tag
+// 0x3D Not used                                                           
+#define SAT_OTHER_ADDRESS                                                      0x3E //!> Other address (data destination address) tag
+
+
+// 
+//Access Technology tag                                             0x3F
+//Display parameters tag                                            0x40
+//Service Record tag                                                0x41
+//Device Filter tag                                                 0x42
+//Service Search tag                                                0x43
+//Attribute information tag                                         0x44
+//Service Availability tag                                          0x45
+//Reserved for 3GPP2 (ESN tag)                                      0x46
+//Network Access Name tag                                           0x47
+//Reserved for 3GPP2 (CDMA-SMS-TPDU tag)                            0x48
+//Remote Entity Address tag                                         0x49
+//Reserved for 3GPP (I-WLAN Identifier tag)                         0x4A
+//Reserved for 3GPP (I-WLAN Access Status tag)                      0x4B
+//RFU                                                                  0x4C to 0x4F
+//Text attribute tag                                                   '50'
+//Item text attribute list tag                                         '51'
+//Reserved for 3GPP (PDP context Activation parameter tag)             '52'
+//RFU                                                                                          '53' to '61'
+//IMEISV tag                                                                           '62'
+//Battery state tag                                                                    '63'
+//Browsing status tag                                                                  '64'
+//Network Search Mode tag                                                              '65'
+//Frame Layout tag                                                                     '66'
+//Frames Information tag                                                               '67'
+//Frame identifier tag                                                                 '68'
+//Reserved for 3GPP (UTRAN Measurement Qualifier tag)                  '69'
+//Multimedia Message Reference tag                                                 '6A'
+//Multimedia Message Identifier tag                                            '6B'
+//Reserved for 3GPP (Multimedia Message Transfer Status tag) 1         '6C'
+//MEID tag                                                                                                                     '6D' 
+//Multimedia Message Content Identifier tag                                                    '6E' 
+//Multimedia Message Notification tag                                                          '6F' 
+
+
+// admissible values for kGetDataDeviceIdentities param
+#define SAT_DEVICE_KEYPAD                                              0x01
+#define SAT_DEVICE_DISPLAY                                             0x02
+#define SAT_DEVICE_EARPIECE                                    0x03
+#define SAT_DEVICE_SIM                                                 0x81
+#define SAT_DEVICE_ME                                                  0x82
+#define SAT_DEVICE_NETWORK                                             0x83
+
+#define SAT_GET_DATA_FORMAT                                            0
+
+
+
+/**
+ * @addtogroup ALP_TELEPHONY_SERVICES_CAT
+ * @{
+ */
+
+//! Proactive Commands Id
+#define SAT_CMD_REFRESH                                                                        0x01
+#define SAT_CMD_SETUP_EVENTLIST                                                        0x05
+#define SAT_CMD_SETUP_CALL                                                             0x10
+#define SAT_CMD_SEND_SS                                                                        0x11
+#define SAT_CMD_SEND_USSD                                                              0x12
+#define SAT_CMD_SEND_SHORT_MESSAGE                                             0x13
+#define SAT_CMD_SEND_DTMF                                                              0x14
+#define SAT_CMD_LAUNCH_BROWSER                                                 0x15
+#define SAT_CMD_PLAY_TONE                                                              0x20
+#define SAT_CMD_DISPLAY_TEXT                                                           0x21
+#define SAT_CMD_GET_INKEY                                                              0x22
+#define SAT_CMD_GET_INPUT                                                              0x23
+#define SAT_CMD_SELECT_ITEM                                                            0x24
+#define SAT_CMD_SETUP_MENU                                                             0x25
+#define SAT_CMD_SETUP_IDLE_MODE_TEXT                                   0x28
+#define SAT_CMD_RUN_AT_COMMAND                                                 0x34
+#define SAT_CMD_OPEN_CHANNEL                                                   0x40
+#define SAT_CMD_CLOSE_CHANNEL                                                  0x41
+#define SAT_CMD_RECEIVE_DATA                                                   0x42
+#define SAT_CMD_SEND_DATA                                                              0x43
+
+
+/******************************************************************************************************************************************************/
+//! read file parameters
+
+//! Card EF access mode
+#define        SAT_CARD_MODE_GET_INFO                                                          0x00    //!<  Get EF information
+#define        SAT_CARD_MODE_READ_FILE                                                         0x01    //!<  Read EF body 
+#define        SAT_CARD_MODE_READ_PART                                                         0x02    //!<  Read EF part 
+#define        SAT_CARD_MODE_READ_REC                                                          0x03    //!<  Read EF record
+
+//! Card EF structure
+#define SAT_CARD_FILE_STRUCT_TRANSPARENT                                       0x00    //!< Transparent EF file: binary files
+#define SAT_CARD_FILE_STRUCT_LINEAR_FIXED                                      0x01    //!< Linear Fixed File: file divided into several equal-length records
+#define SAT_CARD_FILE_STRUCT_CYCLIC                                                    0x03    //!< Cyclic File: used to keep track of data in chronological order
+
+/******************************************************************************************************************************************************/
+
+//! SetUpEventList parameters: each byte in the event list shall be coded with one of the values below: 
+#define SAT_EVENT_USER_ACTIVITY                                                                0x04    //!< User activity
+#define SAT_EVENT_IDLE_SCREEN_AVAILABLE                                                0x05    //!< Idle screen available
+#define SAT_EVENT_LANGUAGE_SELECTION                                           0x07    //!< Language selection
+#define SAT_EVENT_BROWSER_TERMINATION                                          0x08    //!< Browser termination
+#define SAT_EVENT_DATA_AVAILABLE                                                       0x09    //!< Data available
+#define SAT_EVENT_CHANNEL_STATUS                                                       0x0A    //!< Channel status
+#define SAT_EVENT_ACCES_TECH_CHANGE                                                    0x0B    //!< Access Technology Change
+#define SAT_EVENT_DISPLAY_PARAMETERS_CHANGED                           0x0C    //!< Display parameters changed
+#define SAT_EVENT_LOCAL_CONNECTION                                                     0x0D    //!< Local connection
+#define SAT_EVENT_BROWSING_STATUS                                                      0x0F    //!< Browsing status
+#define SAT_EVENT_FRAMES_INFORMATION_CHANGE                                    0x10    //!< Frames Information Change
+#define SAT_EVENT_IWLAN_ACCESS_STATUS                                          0x11    //!< I-WLAN Access Status
+
+/******************************************************************************************************************************************************/
+//! PLAY TONE command parameters
+
+#define SAT_PLAY_TONE_DIAL_TONE                                                                        0x01    //!< Dial tone
+#define SAT_PLAY_TONE_CALLER_BUSY                                                              0x02    //!< Called subscriber busy
+#define SAT_PLAY_TONE_CONGESTION                                                               0x03    //!< Congestion
+#define SAT_PLAY_TONE_RADIO_PATH_ACKNOWLEDGE                                   0x04    //!< Radio path acknowledge
+#define SAT_PLAY_TONE_CALL_DROPPED                                                             0x05    //!< Radio path not available/Call dropped
+#define SAT_PLAY_TONE_SPECIAL_INFORMATION_OR_ERROR                             0x06    //!< Error/Special information
+#define SAT_PLAY_TONE_CALL_WAITING_TONE                                                        0x07    //!< Call waiting tone
+#define SAT_PLAY_TONE_RINGING_TONE                                                             0x08    //!< Ringing tone
+  
+//! Terminal proprietary tones:
+#define SAT_GENERAL_BEEP                                                                               0x10    //!< General beep       
+#define SAT_POSITIVE_ACKNOWLEDGE_TONE                                                  0x11    //!< Positive acknowledgement tone
+#define SAT_NEGATIVE_ACKNOWLEDGE_TONE                                                  0x12    //!< Negative acknowledgement or error tone
+#define SAT_USER_RINGING_TONE                                                                  0x13    //!< Ringing tone as selected by the user for incoming speech call
+#define SAT_USER_SMS_TONE                                                                              0x14    //!< Alert tone as selected by the user for incoming SMS
+#define SAT_CRITICAL_ALERET                                                                            0x15    //!< Critical Alert - This tone is to be used in critical situations.        terminal;
+  
+//! Themed tones:
+#define SAT_VIBRATE_ONLY                                                                               0x20    //!< vibrate only, if available
+#define SAT_HAPPY_TONE                                                                                 0x30    //!< happy tone
+#define SAT_SAD_TONE                                                                                   0x31    //!< sad tone
+#define SAT_URGENT_ACTION_TONE                                                                 0x32    //!< urgent action tone
+#define SAT_QUESTION_TONE                                                                              0x33    //!< question tone
+#define SAT_MESSAGE_RECEIVED_TONE                                                              0x34    //!< message received tone
+
+//! Melody tones:
+#define SAT_MELODY1_TONE                                                                               0x40    //!< Melody 1
+#define SAT_MELODY2_TONE                                                                               0x41    //!< Melody 2
+#define SAT_MELODY3_TONE                                                                               0x42    //!< Melody 3
+#define SAT_MELODY4_TONE                                                                               0x43    //!< Melody 4
+#define SAT_MELODY5_TONE                                                                               0x44    //!< Melody 5
+#define SAT_MELODY6_TONE                                                                               0x45    //!< Melody 6
+#define SAT_MELODY7_TONE                                                                               0x46    //!< Melody 7
+#define SAT_MELODY8_TONE                                                                               0x47    //!< Melody 8
+
+
+/**********************************************************************************************************************************************************************
+*     
+*              Command qualifier     
+*     
+**********************************************************************************************************************************************************************/
+
+//! Refresh command qualifier
+#define SAT_REFRESH_SIM_INIT_AND_FULL_FILE_CHANGE_NOTIFICATION 0x00    //!< NAA Initialization and Full File Change Notification
+#define SAT_REFRESH_FILE_CHANGE_NOTIFICATION                                   0x01    //!< File Change Notification
+#define SAT_REFRESH_SIM_INIT_AND_FILE_CHANGE_NOTIFICATION              0x02    //!< NAA Initialization and File Change Notification
+#define SAT_REFRESH_SIM_INIT                                                                   0x03    //!< NAA Initialization
+#define SAT_REFRESH_SIM_RESET                                                                  0x04    //!< UICC Reset
+#define SAT_REFRESH_USIM_INIT                                                                  0x05    //!< NAA Application Reset, only applicable for a 3G platform
+#define SAT_REFRESH_USIM_RESET                                                                 0x06    //!< NAA Session Reset, only applicable for a 3G platform;
+
+/******************************************************************************************************************************************************/
+
+//! SetUpCall command qualifier 
+#define SAT_SETUP_CALL_ONLY_IF_NOT_BUSY                                                                        0x00    //!< Set up call, but only if not currently busy on another call
+#define SAT_SETUP_CALL_ONLY_IF_NOT_BUSY_WITH_REDIAL                                            0x01    //!< Set up call, but only if not currently busy on another call, with redial
+#define SAT_SETUP_CALL_AND_PUT_ALL_OTHER_CALLS_ON_HOLD                                 0x02    //!< Set up call, putting all other calls (if any) on hold
+#define SAT_SETUP_CALL_AND_PUT_ALL_OTHER_CALLS_ON_HOLD_WITH_REDIAL             0x03    //!< Set up call, putting all other calls (if any) on hold, with redial
+#define SAT_SETUP_CALL_AND_DISCONNECT_ALL_OTHER_CALLS                                  0x04    //!< Set up call, disconnecting all other calls (if any)
+#define SAT_SETUP_CALL_AND_DISCONNECT_ALL_OTHER_CALLS_WITH_REDIAL              0x05    //!< Set up call, disconnecting all other calls (if any), with redial
+
+/******************************************************************************************************************************************************/
+
+//! SEND SHORT MESSAGE command qualifier
+#define  SAT_SEND_SMS_PACKING_NOT_REQUIRED                     0x00 //!< bit 1: 0 = packing not required;
+#define  SAT_SEND_SMS_PACKING_REQUIRED                         0x01 //!< bit 1: 1 = SMS packing by the ME required.
+
+/******************************************************************************************************************************************************/
+
+//! Play Tone command qualifier
+#define SAT_VIBRATE_ALERT_UP_TO_TERMINAL                       0x00    //!< use of vibrate alert is up to the terminal
+#define SAT_VIBRATE_ALERT_WITH_TONE                                    0x01    //!< vibrate alert, if available, with the tone
+
+/******************************************************************************************************************************************************/
+
+//! DISPLAY MULTIMEDIA MESSAGE / DISPLAY TEXT command qualifier 
+
+// priority
+#define        SAT_NORMAL_PRIORITY                                                     0x00    //!<normal priority
+#define        SAT_HIGH_PRIORITY                                                       0x01    //!<high priority
+
+//clearAfterDelay      
+#define        SAT_USER_CLEAR                                                          0x00    //!<wait for user to clear message
+#define        SAT_CLEAR_AFTER_DELAY                                           0x01    //!<clear after delay
+
+/******************************************************************************************************************************************************/
+
+//! GET INKEY / GET INPUT command qualifier (common part)
+
+//respType
+#define         SAT_RESP_TYPE_YES_NO_OPTION                            0x01    // Character sets disabled and the "Yes/No" response is requested, applies to GetInkey
+#define  SAT_RESP_TYPE_UNPACKED_DIGITS_ONLY                    0x02    // unpacked digits (0 to 9, *, #, and +) only, applies to GetInkey, GetInput
+#define  SAT_RESP_TYPE_PACKED_DIGITS_ONLY                      0x03    // packed digits (0 to 9, *, #, and +) only, applies to GetInput
+#define  SAT_RESP_TYPE_UCS2_DIGITS_ONLY                                0x04    // UCS2 digits (0 to 9, *, #, and +) only, applies to GetInkey, GetInput
+#define  SAT_RESP_TYPE_UNPACKED_SMS_ALPHABET           0x05    // SMS default alphabet 8 bits data, applies to GetInkey, GetInput 
+#define  SAT_RESP_TYPE_PACKED_SMS_ALPHABET                     0x06    // SMS default alphabet 7 bits packed, applies to GetInput
+#define  SAT_RESP_TYPE_UCS2_ALPHABET                           0x07    // 16 bits UCS2 alphabet, applies to GetInkey, GetInput
+                                                                                                                                        
+/******************************************************************************************************************************************************/
+
+//! GET INPUT command qualifier dispatched on the field hideUserInput
+
+//hideUserInput
+#define  SAT_GET_INPUT_NO_ECHO                                         0x00    //!< user input shall not be revealed in any way
+#define  SAT_GET_INPUT_WITH_ECHO                                       0x01    //!< terminal may echo user input on the display
+
+/******************************************************************************************************************************************************/
+
+//! SELECT ITEM command qualifier
+
+// specific to SELECT ITEM command
+#define SAT_DEFAULT_STYLE                                                      0x00    //!< presentation type is not specified
+#define SAT_PRESENT_AS_DATA_VALUES                                     0x01    //!< presentation as a choice of data values
+#define SAT_PRESENT_AS_NAVIGATION_OPTIONS                      0x02    //!< presentation as a choice of navigation options
+
+
+/******************************************************************************************************************************************************/
+//! Setup menu command qualifier dispatched on the softkey and helpInfo fields         
+
+//softKey
+#define  SAT_NO_SOFT_KEY                                                       0x00    //!< no selection preference
+#define  SAT_SOFT_KEY_PREFERRED                                                0x01    //!< selection using softkey preferred
+   
+/******************************************************************************************************************************************************/
+           
+//! Language Notification command qualifier
+#define SAT_LANGUAGE_NON_SPECIFIC_NOTIFICATION         0x00    //!< non-specific language notification
+#define SAT_LANGUAGE_SPECIFIC_NOTIFICATION                     0x01    //!< specific language notification
+
+/******************************************************************************************************************************************************/
+
+//! LaunchBrowser command qualifier 
+#define SAT_LAUNCH_BROWSER_IF_NOT_ALREADY_LAUNCHED                             0x00    //!< launch browser if not already launched
+#define SAT_LAUNCH_BROWSER_USE_EXISTING                                                        0x02    //!< use the existing browser (the browser shall not use the active existing secured session)
+#define SAT_LAUNCH_BROWSER_CLOSE_EXISTING_AND_LAUNCH_NEW               0x03    //!< close the existing browser session and launch new browser session
+
+/******************************************************************************************************************************************************/
+
+//! Open Channel command qualifier
+#define SAT_ON_DEMAND_LINK_ESTABLISHMENT                                               0x00    //!< on demand link establishment
+#define SAT_IMMEDIATE_LINK_ESTABLISHMENT                                               0x01    //!< immediate link establishment
+
+/******************************************************************************************************************************************************/
+//! common to Setup Menu/Get input / Get inkey
+
+//helpInfo
+#define  SAT_NO_HELP                                                                                   0x00    //!< no help available
+#define  SAT_HELP_AVAILABLE                                                                            0x01    //!< help available
+
+
+
+//!********************************************************************************
+//!* TLV data objects parameters                                                  *
+//!*                                                                                                                                                     *
+//!********************************************************************************
+
+//!Bearer codes used in the LAUNCH BROWSER command within the bearer list
+//!the terminal shall use the list of bearers associated with the Launch Broser command to choose which bearers are allowed in order of priority.
+#define SAT_BEARER_SMS                                                                                 0x00    //!< short message
+#define SAT_BEARER_CSD                                                                                 0x01    //!< circuit switched data
+#define SAT_BEARER_USSD                                                                                        0x02    //!<
+#define SAT_BEARER_GPRS                                                                                        0x03    //!< 
+
+/******************************************************************************************************************************************************/
+//! Command OPEN CHANNEL parameters or response to OPEN CHANNEL: 
+
+//type of adress in the TLV object "Other adress"
+#define        SAT_ADDRESS_IPV4                                                                                0x21
+#define        SAT_ADDRESS_IPV6                                                                                0x97
+
+//!Transport protocol type in the TLV object "UICC/ME interface transport level"
+#define        SAT_TRANSPORT_UDP                                                                               0x01    //!< UDP, UICC in client mode (as defined in RFC 768 [9])
+#define        SAT_TRANSPORT_TCP_CLIENT_MODE                                                   0x02    //!< TCP, UICC in client mode (as defined in RFC 793 [10])
+#define        SAT_TRANSPORT_TCP_SERVER_MODE                                                   0x03    //!< TCP, UICC in server mode (as defined in RFC 793 [10])
+
+//! Bearer type in the bearer description parameter 
+#define SAT_CSD                                                                                                        0x01    //!< circuit switched data
+#define SAT_GPRS_3G_PACKET_SERVICE                                                             0x02    //!< GPRS / 3G packet service
+#define SAT_DEFAULT_BEARER                                                                             0x03    //!< default bearer for requested transport layer
+#define SAT_TECHNOLOGY_INDEPENDANT                                                             0x04    //!< local link technology independent
+#define SAT_BLUETOOTH                                                                                  0x05    //!< Bluetooth
+#define SAT_IRDA                                                                                               0x06    //!< IrDA
+#define SAT_RS232                                                                                              0x07    //!< RS232
+#define SAT_PACKET_DATA_SERVICE                                                                        0x08    //!< TIA/EIA/IS-820 packet data service 
+#define SAT_UTRAN                                                                                              0x09    //!< UTRAN packet service with extended parameters
+#define SAT_USB                                                                                                        0x10    //!< USB
+
+/******************************************************************************************************************************************************/
+
+//! Icon qualifier (indicates to the terminal how the icon is to be used)
+#define SAT_SHOW_ICON_WITHOUT_TEXT                                                             0x00 //!< icon is self-explanatory, i.e. if displayed, it replaces the alpha identifier or text string
+#define SAT_SHOW_ICON_WITH_TEXT                                                                        0x01 //!< icon is not self-explanatory, i.e. if displayed, it shall be displayed together with the alpha identifier or text string
+
+/******************************************************************************************************************************************************/
+
+//! DISPLAY TEXT Parameters (Data coding scheme)
+#define        SAT_DCS_SMS_PACKED                                                                              0x00 //!<use the SMS default 7-bit coded alphabet, packed into 8-bit octets, as defined in TS 123 038 [3]
+#define        SAT_DCS_SMS_UNPACKED                                                                    0x04 //!<use the SMS default 7-bit coded alphabet as defined in TS 123 038 [3] with bit 8 set to 0
+#define        SAT_DCS_SMS_UNICODE                                                                             0x08 //!<use the UCS2 alphabet if the UCS2 is supported, as defined in TS 123 038 [3]
+
+/******************************************************************************************************************************************************/
+
+// Command Menu Selection parameters:  
+#define SAT_MENU_SELECTION_NO_HELP_REQUESTED                   0x00 //!< do not insert help request tag in the enveloppe message MENU SELECTION
+#define SAT_MENU_SELECTION_HELP_REQUESTED                              0x01 //!< insert help request tag in the enveloppe message MENU SELECTION to request help information on the item selected
+//#define SAT_MENU_SELECTION_APP_MENU_REQUEST                  0x03 //!<  ??? specific to I250 phone driver
+
+/******************************************************************************************************************************************************/
+
+//! Browser termination cause to join in the structure of enveloppe (Browser termination)  
+#define SAT_BROWSER_USER_TERMINATION                                                   0x00
+#define SAT_BROWSER_ERROR_TERMINATION                                                  0x01
+
+/******************************************************************************************************************************************************/
+
+//! Terminate reasons (not used)
+//#define SAT_TERMINATE_USER_STOPPED_REDIALING                                 0
+//#define SAT_TERMINATE_ENDS_OF_REDIALING_REACHED                              1
+//#define SAT_TERMINATE_USER_ENDS_SESSION                                              2
+/******************************************************************************************************************************************************/
+
+//! Setup Call actions
+#define SAT_CALL_REJECT                                                                                        0x00 //!< User did not accept the proactive command SETUP CALL
+#define SAT_CALL_ACCEPT                                                                                        0x01 //!< User accept to setup the call
+
+/******************************************************************************************************************************************************/
+
+//! General result codes
+#define        SAT_RES_COMMAND_SUCCESSFUL                                                                      0x00    //!<Command performed successfully
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_PARTIAL_COMPREHENSION           0x01    //!<Command performed with partial comprehension
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_MISSING_INFORMATION                     0x02    //!<Command performed, with missing information
+#define        SAT_RES_REFRESH_SUCCESSFUL_WITH_ADDITIONAL_EFS_READ                     0x03    //!<REFRESH performed with additional EFs read
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_ICON_NOT_FOUND                           0x04    //!<Command performed successfully, but requested icon could not be displayed
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_MODIFIED_BY_CALL_CONTROL         0x05    //!<Command performed, but modified by call control by NAA
+#define        SAT_RES_COMMAND_SUCCESSFUL_BUT_LIMITED_SERVICE                          0x06    //!<Command performed successfully, limited service
+#define        SAT_RES_COMMAND_SUCCESSFUL_WITH_MODIFICATION                            0x07    //!<Command performed with modification
+  
+#define        SAT_RES_ABORTED_BY_USER                                                                         0x10    //!<Proactive UICC session terminated by the user
+#define        SAT_RES_BACKWARD                                                                                        0x11    //!<Backward move in the proactive UICC session requested by the user
+#define        SAT_RES_NO_RESPONSE                                                                                     0x12    //!<No response from user
+#define        SAT_RES_HELP_REQUIRED                                                                           0x13    //!<Help information required by the user
+#define        SAT_RES_USSD_ABORTED_BY_USER                                                            0x14    //!<USSD or SS transaction terminated by the user
+#define        SAT_RES_ME_UNABLE_TO_PROCESS_COMMAND                                            0x20    //!<terminal currently unable to process command
+#define        SAT_RES_NETWORK_UNABLE_TO_PROCESS_COMMAND                                       0x21    //!<Network currently unable to process command
+#define        SAT_RES_USER_REJECTED_SETUP_CALL                                                        0x22    //!<User did not accept the proactive command
+#define        SAT_RES_USER_CLEARED_BEFORE_RELEASE                                                     0x23    //!<User cleared down call before connection or network release
+#define        SAT_RES_ACTION_CONTRADICT_TIMER_STATE                                           0x24    //!<Action in contradiction with the current timer state
+#define        SAT_RES_TEMP_PROBLEM_IN_CALL_CONTROL                                            0x25    //!<Interaction with call control by NAA, temporary problem
+#define        SAT_RES_LAUNCH_BROWSER_ERROR                                                            0x26    //!<Launch browser generic error code
+#define        SAT_RES_COMMAND_BEYOND_ME_CAPABILITIES                                          0x30    //!<Command beyond terminal's capabilities
+#define        SAT_RES_COMMAND_TYPE_NOT_UNDERSTOOD                                                     0x31    //!<Command type not understood by terminal
+#define        SAT_RES_COMMAND_DATA_NOT_UNDERSTOOD                                                     0x32    //!<Command data not understood by terminal
+#define        SAT_RES_COMMAND_NUMBER_NOT_KNOWN                                                        0x33    //!<Command number not known by terminal
+#define        SAT_RES_SS_RETURN_ERROR                                                                         0x34    //!<SS Return Error
+#define        SAT_RES_SMS_RP_ERROR                                                                            0x35    //!<SMS RP-ERROR
+#define        SAT_RES_REQUIRED_VALUES_MISSING                                                         0x36    //!<Error, required values are missing
+#define        SAT_RES_USSD_RETURN_ERROR                                                                       0x37    //!<USSD Return Error
+//#define      SAT_MULTIPLE_CARD_COMMAND_ERROR                                         0x38     //!<MultipleCard commands error
+#define        SAT_RES_PERMANENT_PROBLEM_IN_SMS_OR_CALL_CONTROL                        0x39    //!<Interaction with call control by USIM or MO short message control by USIM, permanent problem
+#define        SAT_RES_BEARER_INDEPENDENT_PROTOCOL_ERROR                                       0x3A    //!<Bearer Independent Protocol error
+#define        SAT_RES_ACCESS_TECHNOLOGY_UNABLE_TO_PROCESS                                     0x3B    //!<Access Technology unable to process command
+#define        SAT_RES_FRAMES_ERROR                                                                            0x3C    //!<Frames error
+#define        SAT_RES_MMS_ERROR                                                                                       0x3D    //!<MMS Error
+
+
+
+/**
+ * @addtogroup SAT
+ * @{
+ */
+#define        ALP_TEL_CARD_GET_FILE_MESSAGE                                                   ((SAT_SERVICE_ID << 8) | 0x0000)
+#define        SAT_GET_CONFIG_MESSAGE                                                  ((SAT_SERVICE_ID << 8) | 0x0001)
+#define        SAT_SET_CONFIG_MESSAGE                                                  ((SAT_SERVICE_ID << 8) | 0x0002)
+#define        SAT_TERMINATE_MESSAGE                                                   ((SAT_SERVICE_ID << 8) | 0x0003)
+#define        SAT_GET_CMD_PARAMETERS_MESSAGE                                  ((SAT_SERVICE_ID << 8) | 0x0004)
+#define        SAT_SET_CMD_RESPONSE_MESSAGE                                    ((SAT_SERVICE_ID << 8) | 0x0005)
+#define        SAT_MENU_SELECTION_MESSAGE                                              ((SAT_SERVICE_ID << 8) | 0x0006)
+#define        SAT_CALL_ACTION_MESSAGE                                                 ((SAT_SERVICE_ID << 8) | 0x0007)
+#define        SAT_NOTIFY_CARD_OF_EVENT_MESSAGE                                ((SAT_SERVICE_ID << 8) | 0x0008)
+
+#define        SAT_MESSAGES_COUNT                                                              ((SAT_NOTIFY_CARD_OF_EVENT_MESSAGE & ALP_TEL_MESSAGE_MASK) + 1) //!< Total count of CAT service messages
+
+
+
+#endif // SAT_VALUES_H
diff --git a/vmodem/server/client.c b/vmodem/server/client.c
new file mode 100644 (file)
index 0000000..423753d
--- /dev/null
@@ -0,0 +1,1656 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include "gsmstate.h"
+#include "phoneprotocol4gsm.h"
+#include "vgsm_phone.h"
+#include "vgsm_ss.h"
+// #include <mzgsmsat.h> 
+// #include <mzgsmsound.h>
+#include "vgsm_sms.h"
+#include "vgsm_gprs.h"
+#include "db_gprs.h"
+#include "logmsg.h"
+
+#include "phoneserver.h"
+#include "at_tx_func.h"
+#include "at_rx_func.h"
+#include "misc.h"
+#include "at_send.h"
+#include "state.h"
+
+//#include "db_phonebook.h"
+#include "server_common_security.h"
+#include "server_common_network.h"
+#include "vgsm_sim.h"
+#include "server_tx_security.h"
+#include "server_tx_phonebook.h"
+#include "db_security.h"
+#include "db_phonebook.h"
+
+#include "sat_util.h"
+#include "sat_values.h"
+#include "server_tx_sms.h"
+#include "server_tx_data.h"
+#include "server_tx_gprs.h"
+
+#include "flight.h"
+
+#include "server_tx_call.h"
+#include "server_common_call.h"
+#include "server_common_ss.h"
+#include "server_tx_ss.h"
+#include "server_tx_network.h"
+#include "server_tx_display.h"
+#include "server_tx_power.h"
+#include "server_client.h"
+/* for temporary power code. so it will be removed */
+#include "at_msg.h"
+#include "vgsm_phone.h"
+/* end */
+
+#define MAX_RESULT_LENGTH 1024
+
+GSM_Device_Functions            * Device;
+int                    smsSentStatus = 0;
+
+extern GSM_StateMachine           GlobalS;
+
+#define MMI_SC_LENGTH2          14
+#define MMI_SC_LENGTH3          10
+
+#if 0
+static char * mmi_sc2[] =
+{
+    "21", // CFU
+    "67", // CF Busy
+    "61", // CF No Reply
+    "62", // CF Not Reachable
+    "43", // Call Waiting
+    "30", // CLIP
+    "31", // CLIR
+    "76", // COLP
+    "77", // COLR
+    "33", // CB, all outgoing
+    "35", // CB, all incoming"
+    "03", // CB, change of password
+    "04", // Change PIN1
+    "05"  // Change PUK1
+};
+
+static char * mmi_sc3[] =
+{
+    "331",// CB, outgoing int'l
+    "332",// CB, outgoing int'l except HOME
+    "351",// CB, incoming Roaming
+    "330",// CB, all calls
+    "333",// CB, all outgoing
+    "353",// CB, all incoming
+    "002",// All CF
+    "004",// All Conditional CF
+    "042",// Change PIN2
+    "052" // Change PUK2
+};
+
+static bool isUSSD(char * data)
+{
+    // ** : register and activate
+       // *  : activate
+       // *# : interrogate
+       // #  : deactivate
+       // ## : de-register (and de-activate)
+
+    int start = 0;
+    int ii;
+
+    if  (data[0] == '*' && data[1] == '*') // register and activate
+        start = 2;
+    else
+    if  (data[0] == '*' && (data[1] != '*' && data[1] != '#') ) // activate
+        start = 1;
+    else
+    if  (data[0] == '*' && data[1] == '#') // interrogate
+        start = 2;
+    else
+    if  (data[0] == '#' && (data[1] != '#' && data[1] != '*')) // deactivate
+        start = 1;
+    else
+    if  (data[0] == '#' && data[1] == '#')  // de-register (and deactivate)
+        start = 2;
+    else
+        TRACE(MSGL_WARN, "Warning : Bad MMI code <%s>\n", data);
+
+    for (ii = 0; ii < MMI_SC_LENGTH2; ii ++)
+    {
+        if  (strncmp( (const char *)&data[start], mmi_sc2[ii], 2) == 0) // Normal SS SC
+            return false;
+    }
+
+    for (ii = 0; ii < MMI_SC_LENGTH3; ii ++)
+    {
+        if  (strncmp( (const char *)&data[start], mmi_sc3[ii], 3) == 0) // Normal SS SC
+            return false;
+    }
+
+    return true;
+}
+#endif
+
+#if 0
+void do_ext(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    int action = packet->action;
+    int length = packet->length;
+    int klass = ci->klass;
+
+    char * p = (char *)(packet->data);
+    switch (action)
+    {
+        case GSM_EXT_SET_INTERNAL_STATE_REQ :
+            {
+                LXT_PHONE_STATE state = (LXT_PHONE_STATE)p[0];
+                TRACE(MSGL_VGSM_INFO, "## GSM_EXT_SET_INTERNAL_STATE_REQ %d\n",
+                                                               (int)state);
+                FuncPhoneServer->BroadcastInternalStatus( &GlobalPS,
+                        state);
+            }
+            break;
+
+        case GSM_EXT_SET_AUDIO_PATH_REQ :
+                       break;
+        case GSM_EXT_SET_VOICE_VOL_REQ :
+                       break;
+        case GSM_EXT_SET_IMEI_REQ :
+                       break;
+               case GSM_EXT_SET_BTMAC_REQ :
+                       break;
+               case GSM_EXT_GET_BTMAC_REQ :
+                       break;
+       }
+}
+
+
+#endif /* 0 */
+
+// 090326              // restore data in EI
+static void do_restore_ei(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       log_msg(MSGL_VGSM_INFO,"do_restore_EI\n");
+
+       init_ss_info_re();
+       init_plmn_list();
+       server_sim_db_init();
+       callback_callist();
+
+       log_msg(MSGL_VGSM_INFO,"do_restore_EI\n");
+}
+
+static void do_sat(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+
+    int action = packet->action;
+//    char * p = (char *)(packet->data);
+
+    DP_TEXT *dp_text;
+    GET_INKEY *get_inkey;
+    GET_INPUT *get_input;
+
+       TRACE(MSGL_VGSM_INFO, "%x\n", action);
+    switch (action)
+       {
+       case GSM_SAT_PROACTIVE_DISPLAY_TEXT     :
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_DISPLAY_TEXT\n");
+
+                       dp_text = (DP_TEXT *)(packet->data);
+                       Display_Text(dp_text);
+                       break;
+               }
+
+       case GSM_SAT_PROACTIVE_GET_INKEY:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_GET_INKEY\n");
+                       get_inkey = (GET_INKEY *)(packet->data);
+                       Get_Inkey(get_inkey);
+                       break;
+               }
+
+       case GSM_SAT_PROACTIVE_GET_INPUT:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_GET_INPUT\n");
+                       get_input = (GET_INPUT *)(packet->data);
+                       Get_Input(get_input);
+                       break;
+               }
+
+       case GSM_SAT_PROACTIVE_SET_MENU:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_SET_MENU\n");
+                       Set_Menu(packet->data);
+                       break;
+               }
+
+       case GSM_SAT_PROACTIVE_SELECT_ITEM:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_SELECT_ITEM\n");
+                       Select_Item(packet->data);
+                       break;
+               }
+       case GSM_SAT_PROACTIVE_SEND_SMS:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_SEND_SMS\n");
+                       Send_SMS(packet->data);
+                       break;
+               }
+       case GSM_SAT_PROACTIVE_SET_UP_CALL:
+               {
+                       log_msg(MSGL_VGSM_INFO,"Client - GSM_SAT_PROACTIVE_SET_UP_CALL\n");
+                       Set_Up_Call(packet->data);
+                       break;
+               }
+
+       #if 0
+       case GSM_SAT_ENVELOPE_COMMAND_REQ:
+           {
+                       GSM_SatEnvelopeCmd cmd;
+
+                       cmd.length = length;
+                       cmd.cmd = p;
+                       TxSAT_ExecEnvelopeCommand(&cmd);
+               }
+               break;
+       case GSM_SAT_PROFILE_DOWNLOAD_SET:
+           {
+                       GSM_SatProfileDown cmd;
+
+                       cmd.result_code = length;
+                       memcpy(cmd.usat_profile, p, 20);
+                       TxSAT_SetProfileDownload(&cmd);
+               }
+               break;
+       case GSM_SAT_TERMINATE_SESSION_SET:
+           {
+                       TxSAT_SetTerminateUSATSession(p);
+               }
+               break;
+       case GSM_SAT_PROVIDE_LOCAL_INFOMATION_GET:
+           {
+                       unsigned char infoType;
+                       infoType = *p;
+                       TxSAT_GetProvideLocalInfo(infoType);
+               }
+               break;
+       case GSM_SAT_POLLING_GET:
+           {
+                       GSM_SatPollingGetType cmd;
+                       cmd.pollReqType = *p++;
+                       cmd.present = *p++;
+                       cmd.units = *p++;
+                       cmd.value = *p;
+                       TxSAT_GetPolling(&cmd);
+               }
+               break;
+       case GSM_SAT_REFRESH_GET:
+           {
+                       GSM_SatRefreshGetType cmd;
+                       cmd.refreshMode = *p++;
+                       cmd.numOfFile = *p++;
+                       cmd.filePathLength = *p++;
+                       memcpy(cmd.fullFilePath, p, 256);
+                       p += 256;
+                       cmd.aidPresent = *p++;
+                       memcpy(cmd.aid, p, 16);
+                       TxSAT_GetRefresh(&cmd);
+               }
+               break;
+       case GSM_SAT_SETUP_EVENT_LIST_GET:
+           {
+                       GSM_SatEventListGetType cmd;
+                       cmd.length = *p++;
+                       memcpy(cmd.eventList, p, 17);
+                       TxSAT_GetSetupEventList(&cmd);
+               }
+               break;
+               #endif
+
+       default :
+               break;
+       }
+}
+
+static void do_data(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    TRACE(MSGL_VGSM_INFO, "\n");
+
+    //GSM_Error error;
+
+    int action = packet->action;
+    //int length = packet->length;
+    //int client_id = ci->klass;
+
+    //char * p = (char *)(packet->data);
+    TRACE(MSGL_VGSM_INFO, "%x\n", action);
+    switch (action)
+    {
+       case GSM_DATA_STATUS :
+           server_tx_data_CallStatus(packet);
+           break;
+    }
+}
+
+
+static void preprocess_do_gprs(LXT_MESSAGE * packet)
+{
+       int i, num;
+       GprsDbEntry entry;
+       char *pos;
+
+       // preprocess gprs data from evt injector
+       char *p = (char *)(packet->data);
+       TRACE(MSGL_VGSM_CALL, "\n");
+       // clean up gprs db
+       if (g_gprs_conflist.num > 0) {
+
+               for (i = 0; i < g_gprs_conflist.num; i++) {
+                       GprsDbEntry rm_entry;
+
+                       strcpy(rm_entry.apn, g_gprs_conflist.pentry[i].apn);
+
+                       vgsm_gprs_database_remove(&rm_entry);
+               }
+       }
+
+       num = *((int *)p);
+
+       pos = p + sizeof(int);
+
+       for (i = 0; i < num; i++ ) {
+               strcpy(entry.apn, (char *)pos);
+               strcpy(entry.intf, (char *)(pos + 255));
+
+               entry.ipconf.cid = pos[265];
+
+               memcpy((char *)(&(entry.ipconf.fieldflag)), pos + 266, 2);
+               memcpy((char *)(entry.ipconf.ip_addr), pos + 268, 4);
+               memcpy((char *)(entry.ipconf.primary_dns), pos + 272, 4);
+               memcpy((char *)(entry.ipconf.secondary_dns), pos + 276, 4);
+               memcpy((char *)(entry.ipconf.default_gateway), pos + 280, 4);
+               memcpy((char *)(entry.ipconf.subnet_mask), pos + 284, 4);
+
+               // add to gprs db
+               vgsm_gprs_database_add(&entry);
+
+               pos += 255 + 10 + 23;
+       }
+
+}
+
+
+static void do_gprs(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+
+       int action = packet->action;
+
+       TRACE(MSGL_VGSM_CALL, "%x\n", action);
+       switch (action) {
+               case GSM_GPRS_IP_CONFIGURATION:
+                       // process VGSM specific job
+                       preprocess_do_gprs(packet);
+                       server_tx_gprs_IPConfigurationNotify(packet);
+                       break;
+       }
+}
+
+
+static void do_display_indicator(const LXT_MESSAGE * packet)
+{
+       const unsigned char *p;
+
+       assert(packet->data);
+       assert(packet->length >= 4);
+
+       p = packet->data;
+
+       server_tx_display_icon_info_noti(p[0], p[1], p[2], p[3], GSM_NET_REG_STAT_REG_HOME);
+}
+
+static void do_display(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    TRACE(MSGL_VGSM_INFO, "\n");
+
+    //GSM_Error error;
+
+    int action = packet->action;
+    //int length = packet->length;
+    //int client_id = ci->klass;
+
+    //char * p = (char *)(packet->data);
+       TRACE(MSGL_VGSM_CALL, "do_display %x\n", action);
+    switch (action)
+    {
+        case GSM_DISPLAY_INDICATOR_NOTI :
+               do_display_indicator(packet);
+           break;
+    }
+}
+
+static void do_power_battery_status(LXT_MESSAGE * packet)
+{
+       unsigned char *p = packet->data;
+       unsigned char level;
+
+       assert(packet->length >= 1);
+       level = p[0];
+       server_tx_battery_status_noti(level);
+
+       /* there seems to be two different messages that notify similar information - send both? */
+       if (0)
+               server_tx_display_icon_info_noti(0x02, 0, level, 0, 0); /* only notify the battery level */
+}
+
+
+static void do_power(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    TRACE(MSGL_VGSM_INFO, "\n");
+
+    int action = packet->action;
+
+    TRACE(MSGL_VGSM_INFO, "do_power %x\n", action);
+
+
+    switch (action)
+    {
+       case GSM_POWER_MODEM_ON_REQ: 
+               oem_rx_power_up_exec();
+               break;
+       case GSM_POWER_BATTERY_STATUS_NOTI:
+               do_power_battery_status(packet);
+               break;
+       default:
+               break;
+    }
+}
+
+static void do_network(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       int action = packet->action;
+       TRACE(MSGL_VGSM_INFO, "do_network %x\n", action);
+
+       switch (action)
+       {
+               case GSM_NETWORK_REG_NOTI:
+                       server_tx_net_reg_noti(packet);
+                       break;
+
+               case GSM_NETWORK_PLMN_LIST:
+                       server_tx_net_plmn_list_noti(packet);
+                       break;
+
+               case GSM_NETWORK_CURRENT_PLMN_NOTI:
+                       server_tx_net_current_plmn_noti(packet);
+                       break;
+               case GSM_NETWORK_CURRENT_NITZ_INFO:
+                       server_tx_net_current_nitz_noti(packet);
+                       break;
+       }
+}
+
+
+static void do_sim(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       log_msg(MSGL_VGSM_ERR,"\n");
+
+       int action = packet->action;
+       int length = packet->length;
+       int i;
+
+       char * p = (char *)(packet->data);
+
+       gsm_sec_lock_e_type type;
+       gsm_sec_status_type status;
+       gsm_sec_lock_mode_e_type flag;
+
+       char *password;
+       PB * pb;
+
+       STATE current;
+
+       get_current_state_machine( &current );
+       TRACE(MSGL_VGSM_INFO, "do_sim %x\n", action);
+       TRACE(MSGL_VGSM_INFO, "current_state=[%x]\n\n", STATE_TYPE(current) );
+
+       switch (action)
+       {
+
+/************************************************************************************/
+/*                                                                                                                                                                     */
+/*                                                                     security part                                                                           */
+/*                                                                                                                                                                     */
+/************************************************************************************/
+               case GSM_SIM_INIT_REQ:
+                       server_sim_db_init();
+              break;
+
+           // 090602
+               case GSM_SIM_REINIT_REQ:
+                       for(i=0;i<7;i++)
+                       {
+                      db_sim_info_add(i,NULL);
+                      db_sim_data_add(i,NULL);
+                       }
+               
+               break;
+               
+               case  GSM_SIM_STATUS_SET:
+               {
+                       status = p[0];
+
+                       log_msg(MSGL_VGSM_ERR,"status=[%x]\n",status);
+
+                       switch(status)
+                       {
+                               case GSM_SEC_STATUS_PIN_READY:
+                                       server_sec_set_sec_status(GSM_SIM_READY);
+                                       server_sec_reset_remain_cnt(GSM_SIM_READY);
+                                       server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_UNLOCK);
+                                       //server_tx_sim_sec_disable_facility();
+                                       break;
+
+                               case GSM_SEC_STATUS_PIN_REQ:
+                                       server_sec_set_sec_status(GSM_SIM_PIN_REQ_STATE);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PIN_REQ_STATE);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PUK_REQ);
+                                       server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_PUK_REQ:
+                                       server_sec_set_sec_status(GSM_SIM_PUK_REQ);
+                                       server_sec_set_cnt_zero(GSM_SIM_PIN_REQ_STATE);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PUK_REQ);
+                                       server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_PIN2_REQ:
+                                       server_sec_set_sec2_status(GSM_SIM_PIN2_REQ);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PIN2_REQ);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PUK2_REQ);
+                                       //server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_PUK2_REQ:
+                                       server_sec_set_sec2_status(GSM_SIM_PUK2_REQ);
+                                       server_sec_set_cnt_zero(GSM_SIM_PIN2_REQ);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PUK2_REQ);
+                                       //server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_PERM_BLOCKED:
+                                       server_sec_set_sec_status(GSM_SIM_FRIZEN);
+                                       server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_NO_SIM:
+                                       server_sec_set_sec_status(GSM_SIM_NO_SIM);
+                                       server_sec_set_facility(GSM_SIM_FACILITY_PIN, GSM_SEC_LOCK_MODE_LOCK);
+                                       break;
+
+                               case GSM_SEC_STATUS_PIN2_READY:
+                                       server_sec_set_sec2_status(GSM_SIM_PIN2_OK);
+                                       server_sec_reset_remain_cnt(GSM_SIM_PIN2_OK);
+                                       break;
+
+                               default :
+                                       log_msg(MSGL_VGSM_ERR,"ERROR -Not handled status =[%d] in sim status set \n", status);
+                                       break;
+                       }
+               }
+               break;
+
+               case GSM_SIM_CHANGE_PASS_SET :
+               {
+                       type = p[0];
+                       password = malloc(length-1);
+                       memcpy(password,&p[1],length-1);
+
+                       switch(type)
+                       {
+                               case GSM_SEC_LOCK_TYPE_SC:
+                                       server_sec_change_password(password,GSM_SIM_PIN_REQ_STATE,length-1);
+                                       break;
+
+                               case GSM_SEC_LOCK_TYPE_SC2:
+                                       server_sec_change_password(password,GSM_SIM_PIN2_REQ,length-1);
+                                       break;
+#if 1                                                                                                                                                                                  // 090215
+                case GSM_SEC_LOCL_TYPE_PUK:
+                    server_sec_change_password(password,GSM_SIM_PUKSET_REQ,length-1);
+                    break;
+                case GSM_SEC_LOCL_TYPE_PUK2:
+                    server_sec_change_password(password,GSM_SIM_PUK2SET_REQ,length-1);
+                    break;
+#endif
+
+                               default :
+                                       log_msg(MSGL_VGSM_ERR,"ERROR -Not handled type =[%d] in change pw \n", type);
+                                       break;
+                       }
+               }
+               break;
+
+               case GSM_SIM_FACILITY_SET:
+               {
+                       type = p[0];
+                       flag =  p[1];
+
+                       log_msg(MSGL_VGSM_ERR,"GSM_SIM_FACILITY_SET - type, flag = [%d],[%d]\n", type, flag);
+
+               if(type == GSM_SEC_LOCK_TYPE_SC)
+                       {
+                               server_sec_set_facility(GSM_SIM_FACILITY_PIN,flag);
+                       }
+               else if( type == GSM_SEC_LOCK_TYPE_FD)
+                       {
+                               server_sec_set_facility(GSM_SIM_FACILITY_FDN,flag);
+                       }
+                       else
+                       {
+                               log_msg(MSGL_VGSM_ERR,"ERROR - Not handled type =[%d] in facility set \n", type);
+                       }
+               }
+               break;
+
+               case GSM_SIM_GET_SIM_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_GET_SIM_DB_REQ\n");
+                       db_sim_sec_restore(VGSM_SIMTypeget);
+               }
+               break;
+               
+               case GSM_SIMINFO_REQ:
+               {
+                       int *list;
+                       char table[10];
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIMINFO_REQ\n");
+                       list = (int*)packet->data;
+                       log_msg(MSGL_VGSM_ERR,"list : %d\n",*list);
+
+                       switch(*list)
+                       {
+                               case 0:
+                                       strcpy(table, "Tusim_li");
+                               break;
+                               case 1:
+                                       strcpy(table, "Tecc");
+                               break;
+                               case 2:
+                                       strcpy(table, "Tsst");
+                               break;
+                               case 3:
+                                       strcpy(table, "Test");
+                               break;
+                               case 4:
+                                       strcpy(table, "Tcphs");
+                               break;
+                               case 5:
+                                       strcpy(table, "Tspn");
+                               break;
+                               case 6:
+                                       strcpy(table, "Timsi");
+                               break;
+                       }
+                       db_sim_info_restore(table);
+               }
+               break;
+
+               case GSM_SIMDATA_REQ:
+               {
+                       int *list;
+                       char table[10];
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIMDATA_REQ\n");
+                       list = (int*)packet->data;
+                       log_msg(MSGL_VGSM_ERR,"list : %d\n",*list);
+
+                       switch(*list)
+                       {
+                               case 0:
+                                       strcpy(table, "Ticcid");
+                               break;
+                               case 1:
+                                       strcpy(table, "Tusim_li");
+                               break;
+                               case 2:
+                                       strcpy(table, "Tecc");
+                               break;
+                               case 3:
+                                       strcpy(table, "Tsst");
+                               break;
+                               case 4:
+                                       strcpy(table, "Test");
+                               break;
+                               case 5:
+                                       strcpy(table, "Tspn");
+                               break;
+                               case 6:
+                                       strcpy(table, "Timsi");
+                               break;
+                       }
+                       db_sim_data_restore(table);
+               }
+               break;
+
+               case GSM_SIMSAVE_REQ:
+               {
+                       _SIMD_t *simd_t;
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIMDATA_REQ\n");
+
+                       simd_t = (_SIMD_t*)packet->data;
+
+                       log_msg(MSGL_VGSM_ERR,"1. type1 : %d, type2 : %d, size : %d\n",simd_t->type1, simd_t->type2, simd_t->size);
+                       log_msg(MSGL_VGSM_ERR,"2. data : %x, %x, %x\n",simd_t->tmp[0], simd_t->tmp[1], simd_t->tmp[2]);
+
+                       if(simd_t->type1 == 0)
+                               db_sim_info_add(simd_t->type2, simd_t);
+                       else if(simd_t->type1 == 1)
+                               db_sim_data_add(simd_t->type2, simd_t);
+                       else
+                               log_msg(MSGL_VGSM_ERR,"ERROR, type1 : %d, type2 : %d\n", simd_t->type1, simd_t->type2);
+               }
+               break;
+
+
+/************************************************************************************/
+/*                                                                                                                                                                     */
+/*                                                                     Phonebook part                                                                  */
+/*                                                                                                                                                                     */
+/************************************************************************************/
+
+               case GSM_SIM_MAKE_PB_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_MAKE_PB_DB_REQ\n");
+                       db_sim_pb_create();
+               }
+               break;
+
+               case GSM_SIM_ADD_PB_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_ADD_PB_DB_REQ\n");
+
+                       pb = (PB *)(packet->data);
+                       db_sim_pb_set_mgr(pb->db_st_type,1);
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_ADD_PB_DB_REQ : %d , %s ,%s, %s\n",pb->db_st_type,pb->name,pb->number,pb->address);
+
+                       db_sim_pb_add(pb);
+                       db_sim_pb_restore(pb);
+
+               }
+               break;
+
+               case GSM_SIM_GET_PB_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_GET_PB_DB_REQ\n");
+
+                       pb = (PB *)(packet->data);
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_GET_PB_DB_REQ : %d , %s \n",pb->db_st_type,pb->name);
+
+                       db_sim_pb_get(pb);
+                       db_sim_pb_restore(pb);
+               }
+               break;
+
+               case GSM_SIM_DELETE_PB_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_DELETE_PB_DB_REQ\n");
+
+                       pb = (PB *)(packet->data);
+                       db_sim_pb_set_mgr(pb->db_st_type,1);
+
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_DELETE_PB_DB_REQ : %d , %s \n",pb->db_st_type,pb->name);
+
+                       db_sim_pb_remove(pb);
+                       db_sim_pb_restore(pb);
+               }
+               break;
+
+               case GSM_SIM_GET_ALL_PB_DB_REQ:
+               {
+                       log_msg(MSGL_VGSM_ERR,"action ->GSM_SIM_GET_ALL_PB_DB_REQ\n");
+
+                       pb = (PB *)(packet->data);
+                       //db_sim_pb_set_mgr(pb->db_st_type,1);
+
+                       db_sim_pb_restore(pb);
+               }
+               break;
+
+               default:
+                       log_msg(MSGL_VGSM_ERR,"ERROR - Not handled action =[%x] \n", action);
+               break;
+       }
+}
+
+
+static void do_sups(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    int action = packet->action;
+    TRACE(MSGL_VGSM_INFO, "do_sups %x\n", action);
+
+    switch (action)
+    {
+    case GSM_SUPS_CONFERENCE:
+       server_tx_ss_state( SS_STATE_CONFERENCE );
+       break;
+    case GSM_SUPS_HOLD:
+       server_tx_ss_state( SS_STATE_HOLD );
+       break;
+    case GSM_SUPS_UNHOLD:
+       server_tx_ss_state( SS_STATE_UNHOLD );
+       break;
+
+    case GSM_SUPS_SET_CW_REQ :
+       server_tx_ss_cw_set_req( packet);
+            break;
+
+    case GSM_SUPS_SET_CCFC_REQ:
+       server_tx_ss_ccfc_set_req(packet);
+            break;
+
+    case GSM_SUPS_SET_CB_REQ:
+       server_tx_ss_cb_set_req(packet);
+            break;
+#if 1
+       case GSM_SUPS_AOC_GET:
+               server_tx_ss_aoc_get_req(packet);
+       break;
+       case GSM_SUPS_AOC_SET:
+               server_tx_ss_aoc_set_req(packet);
+       break;
+#endif
+       // 090330 090406 //////////////////////////////////////////////
+       case GSM_SUPS_CW_SET:
+               server_tx_ss_cw_set_req(packet);
+       break;
+
+       /*
+       case GSM_SUPS_CW_GET:
+               server_tx_ss_cw_get_req(packet);
+       break;
+       */
+
+       case GSM_SUPS_CF_SET:
+               server_tx_ss_cf_set_req(packet);
+       break;
+
+       /*
+       case GSM_SUPS_CF_GET:
+               server_tx_ss_cf_get_req(packet);
+       break;
+       */
+
+       case GSM_SUPS_CB_SET:
+               server_tx_ss_cb_set_req(packet);
+       break;
+
+       /*
+       case GSM_SUPS_CB_GET:
+               server_tx_ss_cb_get_req(packet);
+       break;
+       */
+
+       //090406//////////////////////////////////////////////////////////
+
+       case GSM_SUPS_USSD_SET :
+               server_tx_ss_ussd_set_req(packet);
+       break;
+
+       case GSM_SUPS_USSD_GET :
+               server_tx_ss_ussd_get_req(packet);
+       break;
+
+       default :
+                 TRACE(MSGL_VGSM_INFO, "do_sups no handle = %x\n", action);
+    }
+}
+
+static void do_emulator(PhoneServer * ps,
+                TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    int action = packet->action;
+
+    TRACE(MSGL_VGSM_INFO, "do_emulator %x\n", action);
+    switch (action)
+    {
+       case GSM_EMULATOR_HDLC_REQ:
+           ATTxEmulator_HDLC_Req(packet);
+           break;
+       case GSM_EMULATOR_HDLC_MODE:
+           ATTxEmulator_HDLC_Mode(packet);
+           break;
+       case GSM_EMULATOR_HDLC_CLEAR:
+           ATTxEmulator_HDLC_Clear();
+           break;
+       case GSM_EMULATOR_SET_CALL_GENERAL_RESPONSE_ERROR:
+           ATTxEmulator_Set_General_Response_Error(packet);
+           break;
+       case GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR:
+           ATTxEmulator_Set_SS_General_Response_Error(packet);
+           break;
+       case GSM_EMULATOR_SET_CALL_STATUS_ERROR:
+           ATTxEmulator_Set_Call_Status_Error(packet);
+           break;
+       case GSM_EMULATOR_SET_SCA:
+           ATTxEmulator_Set_SCA(packet);
+           break;
+// ss error cause set
+       case GSM_EMULATOR_SET_SS_HOLD_RESPONSE_ERROR:
+       case GSM_EMULATOR_SET_SS_RETRIEVE_RESPONSE_ERROR:
+       case GSM_EMULATOR_SET_SS_JOIN_RESPONSE_ERROR:
+       case GSM_EMULATOR_SET_SS_SPLIT_RESPONSE_ERROR:
+       case GSM_EMULATOR_SET_SS_TRANSFER_RESPONSE_ERROR:
+           ATTxEmulator_Set_SS_Response_Error(packet, action);
+           break;
+    }
+}
+
+static void do_client(PhoneServer * ps,
+                TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    int action = packet->action;
+
+    TRACE(MSGL_VGSM_INFO, "do_client %x\n", action);
+    switch (action)
+    {
+       case GSM_CLIENT_RELEASE_NOTI:
+           server_client_release_noti();
+           break;
+    }
+}
+
+
+static void do_sms(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       unsigned char *p;
+    int action = packet->action;
+
+    TRACE(MSGL_VGSM_INFO, "do_sms %x\n", action);
+    switch (action)
+    {
+       case GSM_SMS_SEND_MSG_REQ:
+               server_tx_sms_notiIncomingMsg(packet);
+               break;
+       case GSM_SMS_SEND_ACK_REQ:
+               p = (unsigned char *)packet->data;
+               smsSentStatus = (int)p[0];
+
+               server_tx_sms_ReceiveAckMsg(packet);
+               break;
+       case GSM_SMS_INCOMING_CB_MSG_REQ:
+               server_tx_sms_NotiIncomingCBMsg(packet);
+               break;
+#if 0
+               case GSM_SMS_SEND_MSG_REQ:
+                       TxSMS_ExecSendMsg(packet);
+                       break;
+               case GSM_SMS_READ_MSG_REQ:
+                       TxSMS_GetReadMsg(packet);
+                       break;
+               case GSM_SMS_SAVE_MSG_REQ:
+                       TxSMS_ExecSaveMsg(packet);              // by luxmea
+                       break;
+               case GSM_SMS_DEL_MSG_REQ:
+                       TxSMS_ExecDeleteMsg(packet);
+                       break;
+               case GSM_SMS_SEND_ACK_REQ:
+                       TxSMS_SetSendAck(packet);
+                       break;
+               case GSM_SMS_GET_SEL_MEM_REQ:
+                       TxSMS_GetSelectMem(packet);
+                       break;
+               case GSM_SMS_SET_SEL_MEM_REQ:
+                       TxSMS_SetSelectMem(packet);
+                       break;
+               case GSM_SMS_STORED_MSG_CNT_REQ:
+                       TxSMS_GetStoredMsgCount(packet);
+                       break;
+               case GSM_SMS_GET_MSG_CONFIG_REQ:
+                       TxSMS_GetMsgConfig(packet);
+                       break;
+               case GSM_SMS_SET_MSG_CONFIG_REQ:
+                       TxSMS_SetMsgConfig(packet);
+                       break;
+               case GSM_SMS_GET_SVC_OPTION_REQ:
+                       TxSMS_GetSvcOption(packet);
+                       break;
+               case GSM_SMS_SET_SVC_OPTION_REQ:
+                       TxSMS_SetSvcOption(packet);
+                       break;
+               case GSM_SMS_MEM_FULL_REQ:
+                       TxSMS_SetMemFull(packet);
+                       break;
+        case GSM_SMS_GET_CB_CONFIG_REQ:
+            TxSMS_GetCBConfig(packet);
+            break;
+        case GSM_SMS_SET_CB_CONFIG_REQ:
+            TxSMS_SetCBConfig(packet);
+            break;
+        case GSM_SMS_SET_MSG_STATUS_REQ:
+            TxSMS_SetMsgStatus(packet);
+            break;
+        case GSM_SMS_SET_BLK_LIST_REQ:
+            TxSMS_SetBlkList(packet);
+            break;
+               default:
+                       TxSMS_DefaultSms(0, 0);
+                       break;
+#endif /* 0 */
+       }
+
+#if 0
+    char AT_Result[MAX_RESULT_LENGTH] = {0, };
+
+    memcpy(buffer, p, length);
+
+    error = SMSFunc->SendMessage(&GlobalS, buffer, AT_Result);
+
+    if  (error == ERR_TIMEOUT)
+        TRACE(MSGL_VGSM_INFO, "MS TIMEOUT Error\n");
+    else
+    {
+        FuncResponse->ResponseSMS(klass, AT_Result);
+    }
+#endif
+}
+
+#if 0
+static int IsFligthMode()
+{
+#ifdef __arm__
+       int fd;
+       fd = open("/setting/flightmode.conf\n", O_RDONLY);
+
+       if (fd != -1)
+               return 1;
+
+#endif
+       return 0;
+}
+#endif /* 0 */
+
+static void do_internal(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       int klass = ci->klass;
+       int clientfd = ci->fd;
+       int action = packet->action;
+       int length = packet->length;
+
+       TRACE(MSGL_VGSM_INFO, "do_internal %x\n", action);
+
+       char * p = (char *)(packet->data);
+
+       switch (action)
+    {
+       case LXT_PDA_INTERNAL_ID_REQUEST :
+               {
+                       int clientid;
+
+                       clientid = (int)packed_S32((unsigned char *)p);
+                       ci->klass = clientid;
+                       TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_ID_REQUEST [0x%x]: %s\n", clientid, clientName[clientid]);
+
+                       // nsclass : when user change language setting.
+                       /*
+                       if (LXT_ID_CLIENT_INDICATOR == clientid) {
+                               if (!IsFligthMode()) {
+                                       if (LXT_STATE_OFF == FuncPhoneServer->GetInternalState(&GlobalPS)) {
+                                               GSM_PhonePowerOn(0);
+                                       }
+                               }
+                       }
+                       */
+                       /******************/
+               }
+               break;
+
+        case LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST :
+            {
+                Server * server = &ps->ServerSocket;
+                TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST \n");
+                if  (server != NULL)
+                {
+                       server->Functions->CastMissedMessage(ps, klass, clientfd);
+                }
+            }
+            break;
+
+        case LXT_PDA_INTERNAL_STATE_REQUEST :
+            {
+                TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_MISSED_MESSAGE_REQUEST ..WARNING: it's not implemented\n");
+                               // nsclass : when user change language setting. phone power off sound
+                               /*
+                               if (LXT_ID_CLIENT_INDICATOR == klass) {
+                                       if (!IsFligthMode())
+                                               return;
+                               }
+                FuncPhoneServer->CastCurrentInternalStatus(&GlobalPS, klass);
+                               */
+                               /******************/
+                break;
+            }
+
+               case LXT_PDA_INTERNAL_LAUNCH_SAT_APP_REQUEST:
+                       {
+                               LXT_MESSAGE packet;
+                               TAPIMessageInit(&packet);
+                               TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_LAUNCH_SAT_APP_REQUEST\n");
+                               packet.group = LXT_GRP_INTERNAL;
+                               packet.action = LXT_PDA_INTERNAL_LAUNCH_SAT_APP_RESPONSE;
+                               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_CARD_MANAGER, &packet);
+                       }
+                       break;
+           case LXT_PDA_INTERNAL_SETUP_SAT_APP_REQUEST:
+                       {
+                               LXT_MESSAGE packet;
+                               TAPIMessageInit(&packet);
+                               TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_SETUP_SAT_APP_REQUEST\n");
+                               packet.group = LXT_GRP_INTERNAL;
+                               packet.action = LXT_PDA_INTERNAL_SETUP_SAT_APP_RESPONSE;
+                               packet.length = length;
+                               packet.data = (void *)p;
+                               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_CARD_MANAGER, &packet);
+                       }
+                       break;
+
+               case LXT_PDA_INTERNAL_PHONE_BATTERY_REQUEST:
+                       {
+                               TRACE(MSGL_VGSM_INFO, "Request phone battery\n");
+                               log_msg(MSGL_VGSM_INFO,"WARNING: it's not implemented \n");
+                       }
+                       break;
+        default :
+            break;
+    }
+}
+
+#if 0
+void do_power(PhoneServer* ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+    GSM_Error error;
+
+    int action = packet->action;
+    int length = packet->length;
+
+    char * p = (char *)(packet->data);
+
+    switch (action)
+    {
+        case LXT_PDA_POWER_ON_REQUEST :
+            /*
+                        * Interanl state´Â ½ÇÁ¦ dpram event¿¡¼­ active¸¦ È®ÀÎÇÑ ÈÄ¿¡ Ã³¸®
+                        */
+                       Device->PowerOnDevice(&GlobalS, 0);
+            break;
+
+        case LXT_PDA_POWER_OFF_REQUEST :
+                       /*
+                        *
+                        */
+            // FuncPhoneServer->BroadcastInternalStatus(&GlobalPS, LXT_STATE_OFF);
+            // error = MiscFunc->PowerOff(&GlobalS);
+            // Device->PowerOffDevice(&GlobalS);
+
+                       /* Phone doesn't seem to respond correctly to the Power-Off request.
+                       After Power-Off request, we got Phone-Active signals repeatedly. civily, 2005.09.26 [
+            TxPWR_ExecPhonePowerOff();
+                       */ // civily, 2005.09.26 ]
+                       TxPWR_ExecPhonePowerOff();
+               FuncPhoneServer->BroadcastInternalStatus(&GlobalPS, LXT_STATE_OFF);
+                       break;
+
+        default :
+            TRACE(MSGL_VGSM_INFO, "nexpected request cmd from clients 0x%02x\n", action);
+            break;
+    }
+}
+#endif /* 0 */
+
+static void do_call(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+    int action = packet->action;
+    int error ;
+
+    TRACE(MSGL_VGSM_INFO, "do_call %x\n", action);
+
+       switch (action)
+       {
+               case GSM_CALL_MAKE_REQ :
+                       log_msg(MSGL_VGSM_INFO,"GSM_CALL_MAKE_REQ\n");
+                       server_tx_call_incoming_noti(packet);
+                       break;
+
+               case GSM_CALL_HANGUP_REQ :
+                       log_msg(MSGL_VGSM_INFO,"GSM_CALL_HANGUP_REQ\n");
+                       server_tx_call_release_exec(packet);
+                       break;
+
+               case GSM_CALL_ANSWER_REQ :
+                       log_msg(MSGL_VGSM_INFO,"GSM_CALL_ANSWER_REQ\n");
+                       {
+                               int active = get_active_call_count();
+                               int hold = get_hold_call_count();
+
+                               if(active >=1 && hold >= 1)
+                               {
+                                       log_msg(MSGL_VGSM_INFO,"======== 1 active + 1held call ========\n");
+                                       return ;
+                               }
+                               else if(active>=1)
+                               {
+                                       log_msg(MSGL_VGSM_INFO,"======== 1 active call   ========\n");
+                                       swap_call();
+                                       server_tx_call_list_noti();
+                               }
+                               else
+                               {
+                                       log_msg(MSGL_VGSM_INFO,"======== no established call! ========\n");
+                                       server_tx_call_answer_exec();
+                               }
+                       }
+                       break;
+               case GSM_CALL_ALERT_IND:
+                       log_msg(MSGL_VGSM_INFO,"GSM_CALL_ALERT_IND\n");
+                       server_tx_call_alert_ind(packet->data, packet->length);
+                       break;
+
+               // 090312
+               case GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR:
+                       log_msg(MSGL_VGSM_INFO,"GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR\n");
+                       ATTxEmulator_Set_General_Response_Error(packet);
+                       error = get_general_response_error();
+                       log_msg(MSGL_VGSM_INFO,"======== Disconnect! error set  %x ========\n", error);
+                       break;
+
+               default:
+                       assert(0);
+       }
+}
+
+#if 0
+void do_sound(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       TRACE(MSGL_VGSM_INFO, "\n" );
+
+    GSM_Error error;
+
+    int klass = ci->klass;
+    int action = packet->action;
+    int length = packet->length;
+
+    char * ptr = (char *)(packet->data);
+
+    switch (action)
+    {
+       case GSM_SND_AUDIO_PATH_CTRL_REQ:
+               {
+                       GSM_SoundAudioPathType type;
+                       type = *ptr;
+                       TxSND_SetAudioPathCtrl(type);
+               }
+               break;
+
+       case GSM_SND_SET_SPKR_VOLUME_CTRL_REQ:
+               {
+                       TxSND_SetVolumeCtrl(ptr[0], ptr[1]);
+               }
+               break;
+
+       case GSM_SND_NOTI_TONE_REQ:
+               {
+                       GSM_SndNotiToneSet tone;
+
+                       tone.mode               = ptr[0];
+                       tone.volume             = ptr[0];
+                       tone.count              = ptr[0];
+                       tone.tone_type  = ptr[0];
+
+                       TxSND_SetNotiTone(&tone);
+               }
+               break;
+
+       case GSM_SND_GET_GAIN_CTRL_REQ:
+               TxSND_GetGainCtrl(ptr);
+               break;
+
+       case GSM_SND_SET_GAIN_CTRL_REQ:
+               TxSND_ExecGainCtrl(ptr);
+               break;
+
+       case GSM_SND_SET_MIC_MUTE_CTRL_REQ:
+               {
+                       GSM_SoundMuteStatusType mute;
+
+                       mute = *ptr;
+                       TxSND_SetMICMuteCtrl(mute);
+               }
+               break;
+
+       default:
+               break;
+    }
+}
+
+void do_svcmode(PhoneServer * ps, TClientInfo * ci, LXT_MESSAGE * packet)
+{
+       TRACE(MSGL_VGSM_INFO, "\n" );
+
+       char *ptr = (char *) packet->data;
+
+    switch (packet->action)
+    {
+       case GSM_SVCMODE_ENTER_REQ:
+               TxSVCMode_SetEnterServiceMode(ptr);
+               break;
+
+       case GSM_SVCMODE_END_REQ:
+               TxSVCMode_SetEndServiceMode(ptr[0]);
+               break;
+
+       case GSM_SVCMODE_PROCESS_KEY_REQ:
+               TxSVCMode_SetProcessKeyCode(ptr[0]);
+               break;
+       }
+}
+#endif /* 0 */
+
+static int client_callback(PhoneServer * ps, int fd, EloopCondition cond, void * data)
+{
+       log_msg(MSGL_VGSM_INFO," client_callback fd=%d \n",fd);
+       TClientInfo * ci = data;
+
+       LXT_MESSAGE packet;
+       int rc = -1;
+       int group;
+       int action;
+       int length;
+       //int klass = ci->klass;
+       int clientfd = ci->fd;
+
+       unsigned char * p = 0;
+
+       TAPIMessageInit(&packet);
+
+       rc = ReadBytes(clientfd, &packet, 4);
+
+       if  (rc <= 0)
+       {
+               Server * server = &ps->ServerSocket;
+               if  (server != NULL)
+               {
+                       TRACE(MSGL_VGSM_INFO, "Client was disconnected\n");
+                       server->Functions->RemoveClient(ps, ci);
+               }
+               return -1;
+       }
+
+       if  (packet.length > 0)
+       {
+               packet.data = (unsigned char *) PacketDataMalloc(packet.length + 1);
+               rc = ReadBytes(clientfd, packet.data, packet.length);
+               p = (unsigned char *)packet.data;
+       }
+
+       group = packet.group;
+       action = packet.action;
+       length = packet.length;
+
+       TRACE(MSGL_VGSM_INFO, "in client_callback, group : %x\n", group);
+       switch (group)
+       {
+       case GSM_CALL:
+               change_state_machine( GSM_CALL_CMD );
+               if( is_flight_mode() ){
+                       TRACE(MSGL_VGSM_INFO, "Flight mode on \n");
+                       /* not call */
+               }else{
+                       TRACE(MSGL_VGSM_INFO, "Flight mode off \n");
+                       do_call(ps, ci, &packet);
+               }
+               break;
+       case GSM_NETWORK:
+               do_network(ps, ci, &packet);
+               break;
+       case GSM_SUPS:
+           do_sups(ps, ci, &packet);
+           break;
+       case GSM_SMS:
+               if( is_flight_mode() ){
+                       TRACE(MSGL_VGSM_INFO, "Flight mode on \n");
+                       /* not sms */
+               }else{
+                       TRACE(MSGL_VGSM_INFO, "Flight mode off \n");
+                       do_sms(ps, ci, &packet);
+               }
+               break;
+       case GSM_DISPLAY:
+        do_display(ps, ci, &packet);
+        break;
+       case GSM_SIM:
+           do_sim(ps, ci, &packet);
+           break;
+       case GSM_DATA :
+        do_data(ps, ci, &packet);
+        break;
+       case GSM_SAT:
+               do_sat(ps, ci, &packet);
+               break;
+       case GSM_EMULATOR :
+           do_emulator(ps, ci, &packet);
+           break;
+       case GSM_GPRS :
+        do_gprs(ps, ci, &packet);
+        break;
+       case GSM_POWER :
+        do_power(ps, ci, &packet);
+        break;
+       case GSM_CLIENT:
+               do_client(ps, ci, &packet);
+               break;
+    case LXT_GRP_INTERNAL :
+        do_internal(ps, ci, &packet);
+        break;
+       //090326
+       case RESTORE_EI_DATA    :
+               do_restore_ei(ps, ci, &packet);
+
+
+#if 0
+        case LXT_GRP_POWER    :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+            do_power(ps, ci, &packet);
+            break;
+
+        case GSM_CALL      :
+#ifdef __arm__
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+#endif
+            do_call(ps, ci, &packet);
+            break;
+
+        case GSM_MISC      :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                if  (action == GSM_MISC_RAMDUMP_REQ)
+                    do_misc(ps, ci, &packet);
+                else
+                    FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_misc(ps, ci, &packet);
+            break;
+
+        case GSM_SMS       :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+//                     if  (GlobalS.Phone.Data.PhonePower == false)
+//                break;
+            do_sms(ps, ci, &packet);
+            break;
+
+        case GSM_SUPS      :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                                 break;
+            do_sups(ps, ci, &packet);
+            break;
+
+        case GSM_SIM      :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_sim(ps, ci, &packet);
+            break;
+
+        case GSM_NETWORK  :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_network(ps, ci, &packet);
+            break;
+
+               case GSM_DATA :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_data(ps, ci, &packet);
+            break;
+
+               case GSM_SOUND:
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_sound(ps, ci, &packet);
+            break;
+
+               case GSM_EXT :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_ext(ps, ci, &packet);
+            break;
+
+               case GSM_SERVICEMODE:
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_svcmode(ps, ci, &packet);
+            break;
+
+               case GSM_EMULATOR :
+/* todo : nsclass
+                       if  (GlobalS.Phone.Data.RamDump == true)
+            {
+                FuncResponse->ResponseRamDump(ci->klass);
+                break;
+            }
+*/
+
+                       if  (GlobalS.Phone.Data.PhonePower == false)
+                break;
+            do_emulator(ps, ci, &packet);
+#endif /* 0 */
+        default :
+            break;
+    }
+    TAPIMessageFree(&packet);
+    return 1;
+}
+
+FunctionsClient ClientHandle =
+{
+    client_callback
+};
+
diff --git a/vmodem/server/eloop.c b/vmodem/server/eloop.c
new file mode 100644 (file)
index 0000000..5d097fb
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <string.h>
+//#include <common/state.h>
+#include "eloop.h"
+
+#include "logmsg.h"
+
+static TimeoutStruct *timeout_head = 0;
+static InOutStruct *inout_head = 0;
+static int timeout_tag = 1;
+static int inout_tag = 1;
+static int inout_num = 0;
+
+static void insert_timeout(TimeoutStruct *me)
+{
+    TimeoutStruct *ts = timeout_head, *prev = 0;
+    while(ts)
+    {
+        if (ts->expire > me->expire)
+        {
+            /* prev me ts */
+            me->next = ts;
+            me->prev = prev;
+            if (prev)
+            {
+                prev->next = me;
+            }
+            else
+            {
+                timeout_head = me;
+            }
+            ts->prev = me;
+            return;
+        }
+        prev = ts;
+        ts = ts->next;
+    }
+    me->next = 0;
+    me->prev = prev;
+    if (prev)
+    {
+        prev->next = me;
+    }
+    else
+    {
+        timeout_head = me;
+    }
+}
+
+static void remove_timeout(TimeoutStruct *me)
+{
+    if (me->prev)
+    {
+        me->prev->next = me->next;
+    }
+    else
+    {
+        timeout_head = me->next;
+    }
+    if (me->next)
+    {
+        me->next->prev = me->prev;
+    }
+}
+
+static void invoke_timeout(TimeoutStruct *me)
+{
+    int ret = (*me->cb)(me->data);
+    remove_timeout(me);
+    if (ret >= 0)
+    {
+        me->expire += me->time_slice * 1000;
+        insert_timeout(me);
+    }
+}
+
+static void insert_input(InOutStruct *me)
+{
+       if (inout_head)
+               inout_head->prev = me;
+       me->next = inout_head;
+       me->prev = 0;
+       inout_head = me;
+       inout_num++;
+}
+
+static void remove_input(InOutStruct *me)
+{
+       TRACE(MSGL_VGSM_INFO,"\n");
+
+       if (me->prev)
+       {
+               me->prev->next = me->next;
+       }
+       else
+       {
+               inout_head = me->next;
+       }
+
+       if (me->next)
+       {
+               me->next->prev = me->prev;
+       }
+       inout_num--;
+}
+
+static void invoke_inout(InOutStruct *me, EloopCondition cond)
+{
+    int ret;
+
+       TRACE(MSGL_VGSM_INFO,"\n");
+
+    ret = (me->cb)(me->ps, me->fd, cond, me->data);
+    if (ret < 0)
+    {
+        remove_input(me);
+    }
+       //ServerHandle
+       //DPRAMHandle
+       //ClientHandle
+}
+
+static int64_t time_get_current(void)
+{
+    struct timeval tv;
+    gettimeofday(&tv, 0);
+    return tv.tv_sec * 1000000LL + tv.tv_usec;
+}
+
+/*     ++ 2008-08-06.
+       ++ This function is not used anywhere.
+       ++ I recommend removing this function.
+*/
+int eloop_add_timeout(unsigned int time_slice, EloopCallback cb, void *data)
+{
+    TimeoutStruct *ts = malloc(sizeof (TimeoutStruct));
+    ts->cb = cb;
+    ts->data = data;
+    ts->expire = time_get_current() + time_slice * 1000;
+    ts->time_slice = time_slice;
+    ts->tag = timeout_tag++;
+    insert_timeout(ts);
+    return ts->tag;
+}
+
+void eloop_remove_timeout(int tag)
+{
+    TimeoutStruct *ts = timeout_head;
+    while(ts)
+    {
+        if (ts->tag == tag)
+        {
+            remove_timeout(ts);
+            free(ts);
+            return;
+        }
+        ts = ts->next;
+    }
+}
+
+int eloop_add_input(PhoneServer * ps, int fd, EloopCondition cond, EloopInputCallback cb, void *data)
+{
+    InOutStruct *io = malloc(sizeof (InOutStruct));
+    io->ps = ps;
+    io->fd = fd;
+    io->cond = cond;
+    io->cb = cb;
+    io->data = data;
+    io->tag = inout_tag++;
+    insert_input(io);
+
+    return io->tag;
+}
+
+void eloop_remove_input(int tag)
+{
+    InOutStruct *io = inout_head;
+    while(io)
+    {
+        if (io->tag == tag)
+        {
+            remove_input(io);
+            free(io);
+            return;
+        }
+        io = io->next;
+    }
+}
+
+static int loop_cont;
+
+static void main_iter(void)
+{
+    int timeout = -1;
+    struct pollfd *ufds = 0;
+    int nfds = inout_num;
+    int i;
+    int n;
+
+   TRACE(MSGL_VGSM_INFO,"\n");
+
+    if (timeout_head)
+    {
+        timeout = timeout_head->expire - time_get_current();
+        timeout /= 1000; /* us -> ms */
+
+        while(timeout < 0)
+        {
+            invoke_timeout(timeout_head);
+            if (!timeout_head)
+                break;
+            timeout = timeout_head->expire - time_get_current();
+            timeout /= 1000; /* us -> ms */
+        }
+
+        if (!timeout_head)
+            timeout = -1;
+    }
+
+    if (!loop_cont)
+        return;
+
+    if (nfds > 0)
+    {
+        InOutStruct *io = inout_head;
+        ufds = malloc(sizeof (struct pollfd) * nfds);
+
+        for(i=0;i<nfds;i++)
+        {
+            ufds[i].fd = io->fd;
+            ufds[i].events = 0;
+
+            if (io->cond & ELOOP_READ)
+            {
+                ufds[i].events |= POLLIN;
+            }
+
+            if (io->cond & ELOOP_WRITE)
+            {
+                ufds[i].events |= POLLOUT;
+            }
+
+            io = io->next;
+        }
+    }
+    n = poll(ufds, nfds, timeout);
+
+    if (n == 0)
+    {
+        invoke_timeout(timeout_head);
+    }
+    else if (n > 0)
+    {
+        InOutStruct *ts = inout_head;
+
+        for(i=0;i<nfds;i++)
+        {
+            InOutStruct *next = ts->next;
+
+            if (ufds[i].revents)
+            {
+                int cond = 0;
+
+                if (ufds[i].revents & POLLIN)
+                {
+                                       TRACE(MSGL_VGSM_INFO, "[%d,fd=%d] READ Condition\n", i, ufds[i].fd);
+                                       cond |= ELOOP_READ;
+                }
+                if (ufds[i].revents & POLLOUT)
+                {
+                    cond |= ELOOP_WRITE;
+                                       TRACE(MSGL_VGSM_INFO, "[%d,fd=%d] WRITE Condition\n", i, ufds[i].fd);
+                }
+                if (ufds[i].revents & POLLERR)
+                {
+                    cond |= ELOOP_EXCEPTION;
+                                       TRACE(MSGL_VGSM_INFO, "[%d,fd=%d] EXCEPTION Condition\n", i, ufds[i].fd);
+                }
+
+                invoke_inout(ts, cond);
+            }
+            ts = next;
+        }
+    }
+    else
+    {
+        perror("poll");
+    }
+    free(ufds);
+}
+
+void eloop_main(void)
+{
+    //eloop_add_timeout(100, time_callback, 0);
+       TRACE(MSGL_VGSM_INFO, "loop start!!!\n");
+
+    loop_cont = 1;
+    do
+    {
+        main_iter();
+    }
+    while(loop_cont);
+}
+
+void eloop_quit(void)
+{
+    loop_cont = 0;
+}
diff --git a/vmodem/server/flight.c b/vmodem/server/flight.c
new file mode 100644 (file)
index 0000000..bf2aaaa
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+
+// start here
+#include <string.h>
+#include "oem_rx_power.h"
+#include "at_rx_func.h"
+#include "flight.h"
+#include <vconf/vconf.h>
+#include <vconf/vconf-keys.h>
+
+/* For Flight Mode */
+int g_svc_type = VCONFKEY_TELEPHONY_SVCTYPE_3G; 
+
+bool is_flight_mode(void)
+{
+       bool ret = false;
+       int status;
+
+       if(vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &status)) {
+               TRACE(MSGL_WARN, "vconf_get_bool(%s) fail\n", VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL);
+               return ret; 
+       }    
+
+       if(status == 1){ 
+               ret = true;
+               TRACE(MSGL_VGSM_INFO, "============ Flight mode On  ==========\n");
+       }else{
+               ret = false;
+               TRACE(MSGL_VGSM_INFO, "============ Flight mode Off ==========\n");
+       }    
+
+       TRACE(MSGL_VGSM_INFO, "============ Flight mode value: %d ==========\n", ret);
+
+       return ret; 
+}
+
+
diff --git a/vmodem/server/func_ps.c b/vmodem/server/func_ps.c
new file mode 100644 (file)
index 0000000..3cad52d
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "phoneserver.h"
+//#include "data_reqclient.h"
+//#include "data_connclient.h"                w
+#include "at_tx_func.h"
+#include "misc.h"
+//#include "ps_request_response_mgr.h"
+
+/* todo : nsclass
+extern GSM_AT_Functions_Security * SecurityFunc;
+extern GSM_StateMachine            GlobalS;
+extern ResponseFunc              * FuncResponse;
+extern GSM_AT_Functions_Network  * NetworkFunc;
+*/
+
+static void RetrievePhoneState(void)
+{
+}
+
+static const char* getStateName(LXT_PHONE_STATE state)
+{
+
+    switch(state)
+    {
+    case LXT_STATE_OFF :
+        return "STATE_OFF";
+
+    case LXT_STATE_ON :
+        return "STATE_ON";
+
+    case LXT_STATE_UIM_NOT_READY :
+        return "STATE_UIM_NOT_READY";
+
+    case LXT_STATE_UIM_READY :
+        return "STATE_UIM_READY";
+
+    case LXT_STATE_NO_SERVICE :
+        return "STATE_NO_SERVICE";
+
+    case LXT_STATE_STANDBY :
+        return "STATE_STANDBY";
+
+    case LXT_STATE_WAITING_OUTGOING_CALL :
+        return "STATE_WAITING_OUTGOING_CALL";
+
+    case LXT_STATE_WAITING_INCOMING_CALL :
+        return "STATE_WAITING_INCOMING_CALL";
+
+    case LXT_STATE_WAITING_DATA_SERVICE :
+        return "STATE_WAITING_DATA_SERVICE";
+
+    case LXT_STATE_CONVERSATION :
+        return "STATE_CONVERSATION";
+
+    case LXT_STATE_DATA_SERVICED :
+        return "STATE_DATA_SERVICED";
+
+    case LXT_STATE_DIAL_UP_DATA_SERVICED :
+        return "STATE_DIAL_UP_DATA_SERVICED";
+
+    case LXT_STATE_RELEASED :
+        return "STATE_RELEASED";
+
+    default :
+        return "STATE_UNDEFINED";
+
+    }
+
+    return 0;
+
+}
+
+static void svr_svrmgr_write_state(LXT_PHONE_STATE stateBefore, LXT_PHONE_STATE stateCurr)
+{
+       char file_name[128] = {0, };
+       char data[128] = {0,};
+       int fd = 0;
+       int rc;
+
+       //sprintf(file_name,"/tmp/.phone_state");
+       sprintf(file_name,"/tmp/.vgsm_state");
+
+       fd = open(file_name, O_CREAT|O_WRONLY|O_TRUNC,00777);
+
+       sprintf(        data, "[STATE NAME]  before = %s \t after = %s\n",
+                               getStateName(stateBefore),
+                               getStateName(stateCurr));
+
+       if(fd >=0)
+       {
+               rc = write(fd, data, strlen(data));
+               close(fd);
+       }
+}
+
+static void SetInternalState(PhoneServer * ps, LXT_PHONE_STATE state)
+{
+    ps->Data.CurrentPhoneState = state;
+}
+
+static LXT_PHONE_STATE GetInternalState(PhoneServer * ps)
+{
+    return ps->Data.CurrentPhoneState;
+}
+
+static void OnPhoneOff(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       // 1. clear request client.
+       //GetReqClientMgr()->m_pFunc->RemoveAllClient();
+
+       // 2. connected client.
+       //GetConnClientMgr()->m_pFunc->CloseAllConnection();
+}
+
+static void OnPhoneOn(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+}
+
+static void BroadcastInternalStatus(PhoneServer *ps, LXT_PHONE_STATE state)
+{
+    LXT_MESSAGE packet;
+
+    unsigned char * data = NULL;
+    LXT_PHONE_STATE CurrentPhoneState;
+
+    CurrentPhoneState = FuncPhoneServer->GetInternalState(&GlobalPS);  // &PhoneServerHandle->GetInternalState
+
+       // todo : nsclass : I must decomment out below function when phone is corrected.
+       TRACE(MSGL_VGSM_INFO, "Attempt to change (%s -> %s)\n",
+               printCurrentState(CurrentPhoneState), printCurrentState(state));
+
+       if (LXT_STATE_OFF == CurrentPhoneState) {
+               if (LXT_STATE_ON != state) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s), because state isn't LXT_STATE_ON\n", printCurrentState(state));
+                       return;
+               }
+       }
+
+       if (LXT_STATE_ON != state) {
+               if (GlobalPS.Data.StatePhoneOn != 1) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s), because Phone state is NOT StatePhoneOn", printCurrentState(state));
+                       return;
+               }
+       }
+
+       if (LXT_STATE_UIM_NOT_READY == CurrentPhoneState) {
+               if ((LXT_STATE_WAITING_OUTGOING_CALL != state)                                          // For SOS call with No-SIM, civily, YL29
+                       && (LXT_STATE_UIM_READY != state && LXT_STATE_OFF != state)) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s)\n", printCurrentState(state));
+                       return;
+               }
+       }
+
+       if (LXT_STATE_WAITING_OUTGOING_CALL == CurrentPhoneState) {
+               if (LXT_STATE_CONVERSATION != state && LXT_STATE_DATA_SERVICED != state && LXT_STATE_OFF != state &&
+                       LXT_STATE_RELEASED != state) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s)\n", printCurrentState(state));
+                       return;
+               }
+       }
+
+       if (LXT_STATE_WAITING_INCOMING_CALL == CurrentPhoneState) {
+               if (LXT_STATE_CONVERSATION != state && LXT_STATE_DATA_SERVICED != state && LXT_STATE_OFF != state &&
+                       LXT_STATE_RELEASED != state) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s)\n", printCurrentState(state));
+                       return;
+               }
+       }
+
+       if (LXT_STATE_CONVERSATION == CurrentPhoneState || LXT_STATE_DATA_SERVICED == CurrentPhoneState) {
+               if (LXT_STATE_STANDBY == state) {
+                       TRACE(MSGL_VGSM_INFO, "Can't change state(%s)\n", printCurrentState(state));
+                       return;
+               }
+       }
+
+    if (CurrentPhoneState == state)
+    {
+        TRACE(MSGL_VGSM_INFO, "PhoneState is equal %d\n", state);
+        return;
+    }
+
+    TRACE(MSGL_VGSM_INFO, "Success to change (%s -> %s)\n",
+                               printCurrentState(CurrentPhoneState),
+                               printCurrentState(state) );
+
+    FuncPhoneServer->SetInternalState(&GlobalPS, state);       // &PhoneServerHandle;
+
+    TAPIMessageInit(&packet);
+
+    packet.group = LXT_GRP_INTERNAL;
+    packet.action = LXT_PHN_INTERNAL_STATE_CHANGE_NOTIFICATION;
+    packet.length = 0x01;
+    data = (unsigned char *)malloc(packet.length);
+    data[0] = (unsigned char )state;
+    packet.data = (void *)data;
+
+    FuncServer->BroadCast(&GlobalPS, &packet); // &ServerHandle->server_broadcast
+
+       if (state == LXT_STATE_ON) {
+               GlobalPS.Data.StatePhoneOn = 1;
+               OnPhoneOn();
+       } else if (state == LXT_STATE_OFF) {
+               GlobalPS.Data.StatePhoneOn = 0;
+               OnPhoneOff();
+       }
+
+    free(data);
+    svr_svrmgr_write_state(CurrentPhoneState,state);
+}
+
+static void CastCurrentInternalStatus(PhoneServer *ps, int clientid)
+{
+    LXT_MESSAGE packet;
+
+    unsigned char * data = NULL;
+    LXT_PHONE_STATE CurrentState;
+
+    CurrentState = FuncPhoneServer->GetInternalState(&GlobalPS);
+
+    TRACE(MSGL_VGSM_INFO, "LXT_PDA_INTERNAL_STATE_RESPONSE <%s> <%s>\n",
+                                               clientName[clientid], printCurrentState(CurrentState) );
+    TAPIMessageInit(&packet);
+
+    packet.group = LXT_GRP_INTERNAL;
+    packet.action = LXT_PHN_INTERNAL_STATE_RESPONSE;
+    packet.length = 0x01;
+    data = (unsigned char *)malloc(packet.length);
+    data[0] = (unsigned char )CurrentState;
+    packet.data = (void *)data;
+
+    FuncServer->Cast(&GlobalPS, clientid, &packet);
+    free(data);
+}
+
+static void CallListId_Init(PhoneServer *ps)
+{
+    int ii;
+
+    memset( &ps->Data.prevCallList, 0x00, sizeof(gsm_call_list_t));
+
+    for (ii = 0; ii < MAX_CALL_COUNT; ii ++)
+        ps->Data.prevCallList.CallInfo[ii].idx = 0x00;
+}
+
+PhoneServerFunc PhoneServerHandle = {
+    SetInternalState,
+    GetInternalState,
+    BroadcastInternalStatus,
+    CastCurrentInternalStatus,
+    CallListId_Init,
+    RetrievePhoneState,
+};
+
diff --git a/vmodem/server/gsm.c b/vmodem/server/gsm.c
new file mode 100644 (file)
index 0000000..4c4a815
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <gsmstate.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "phoneserver.h"
+#include "logmsg.h"
+#include "vgsm_debug.h"
+#include "gsm.h"
+
+GSM_StateMachine           GlobalS;
+
+GSM_Device_Functions     * Device;
+
+GSM_Error GSM_Init(bool checkerror)
+{
+    GSM_Error error;
+
+    // nsclass: phone state
+    GlobalPS.Data.StatePhoneOn = 0;
+    GlobalPS.Data.CurrentPhoneState = LXT_STATE_OFF;
+    GlobalPS.Data.GSMDataRequest = 0;
+
+    error = GSM_InitConnection(&GlobalS,1);
+    if  (error != ERR_NONE)
+        return error;
+
+    Device = GlobalS.Device.Functions; // &DPRAMDevice
+
+    return ERR_NONE;
+}
+
+GSM_Error GSM_PhonePowerOn(int first_boot)
+{
+    GSM_Error error = ERR_NONE;
+
+       TRACE(MSGL_VGSM_INFO,"\n");
+
+    Device->PowerOnDevice(&GlobalS, first_boot);       // &DPRAMDevice->dpram_poweron
+
+    return error;
+}
+
+bool GSM_PhonePowerStatus(void)
+{
+       TRACE(MSGL_VGSM_INFO,"\n");
+
+    return Device->PowerStatus(&GlobalS);      // &DPRAMDevice
+}
+
+void GSM_Terminate(void)
+{
+    GSM_Error error;
+
+    error=GSM_TerminateConnection(&GlobalS);
+    TRACE(MSGL_VGSM_ERR, "error is %d.\n", error);
+}
+
+/*
+GSM_Error SendInitCommand()
+{
+    GSM_Error error;
+
+    error = MiscFunc->SetDefault(&GlobalS);
+    if  (error != ERR_NONE) return error;
+
+    error = MiscFunc->SetDefault(&GlobalS);
+    if  (error != ERR_NONE) return error;
+
+    error = MiscFunc->SetEquipmentError(&GlobalS, 1);
+    if  (error != ERR_NONE) return error;
+
+    error = CallFunc->SetCallExtendedFormat(&GlobalS, true);
+    if  (error != ERR_NONE) return error;
+
+    error = CallFunc->SetIntermediateCR(&GlobalS, true);
+    if  (error != ERR_NONE) return error;
+
+    error = CallFunc->SetCallMode(&GlobalS, 0);
+    if  (error != ERR_NONE) return error;
+
+    error = NetworkFunc->SetNetworkReg(&GlobalS, 1);
+    if  (error != ERR_NONE) return error;
+
+    error = GPRSFunc->SetGPRSRegStatus(&GlobalS, 1);
+    if  (error != ERR_NONE) return error;
+
+    error = SSFunc->SetCID(&GlobalS, true);
+    if  (error != ERR_NONE) return error;
+
+    error = SSFunc->SetEnabledCallWaiting(&GlobalS, true);
+    if  (error != ERR_NONE) return error;
+
+    error = SSFunc->SetSSNotification(&GlobalS, false, true);
+    if  (error != ERR_NONE) return error;
+
+    error = SSFunc->SetEnableNotifyAOC(&GlobalS, 2);
+    if  (error != ERR_NONE) return error;
+
+    error = SSFunc->SetEnabledUSSD(&GlobalS, true);
+    if  (error != ERR_NONE) return error;
+
+    error = SMSFunc->SetSMSFormat(&GlobalS, 0);
+    if  (error != ERR_NONE) return error;
+
+    error = SMSFunc->SetSMSInitReceivingMode(&GlobalS);
+    if  (error != ERR_NONE) return error;
+}
+*/
+
+GSM_Error GSM_Start(void)
+{
+       return ERR_NONE;
+}
+
+//GSM_Error GSM_ModemInit()
+//{
+//    GSM_Error error;
+//
+//    error = MiscFunc->SetIndicatorEvent(&GlobalS);
+//    error = MiscFunc->SetEquipmentError(&GlobalS, 1);
+//    error = SSFunc->SetSSNotification(&GlobalS, true, true);
+//    error = CallFunc->SetCallExtendedFormat(&GlobalS, false);
+//    /*
+//      * ¾Æ·¡ÀÇ Ãʱ⠸í·É¾î´Â À̹̠Phone power on½Ã¿¡ ¹Ý¿µÀÌ µÇ¾î ÀÖÀ¸¹Ç·Î
+//      * »ý·«ÇÑ´Ù.
+//    error = SendInitCommand();
+//    if  (error != ERR_NONE)
+//        return error;
+//    */
+//    return ERR_NONE;
+//}
+//
+
diff --git a/vmodem/server/logmsg.c b/vmodem/server/logmsg.c
new file mode 100644 (file)
index 0000000..7422dfb
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/**
+ * Copyright (C) 2007 All rights reserved.
+ *
+ * @file logmsg.c
+ * @brief - implementation file
+ *
+ * @defgroup
+ *
+ * $Id: logmsg.c,v 1.1.1.1 2008-12-08 04:45:34 okdear Exp $
+ *
+ * <Revision History>
+ *             0000-00-00:
+ */
+#include <unistd.h>
+#include <assert.h>
+#include "logmsg.h"
+
+static const char *msglevel[] = {
+                               "[fatal]",
+                               "[ err]",
+                               "[warn]",
+                               "[info]",
+                               "[call]",
+                               "[ sms]",
+                               "[ sim]",
+                               "[ ss ]",
+                               "[ net]",
+                               "[gprs]",
+                               "[disp]",
+                               "[ at ]",
+                               "[func]",
+                               "[ all ]",
+};
+
+static int msg_level = MSGL_DEFAULT;
+static char module[MODNAME_MAX] = { 0, };
+static const char logfile[] = "/tmp/vgsm.log";
+
+/**
+  * @brief
+  *
+  * @param level
+  * @param format
+  * @param ...
+  */
+void real_log_msg(int level, const char *format, ...)
+{
+       char tmp[MSGSIZE_MAX] = { 0, };
+       char txt[MSGSIZE_MAX] = { 0, };
+       char timeinfo[256] = { 0, };
+       FILE *fp;
+       struct tm *tm_time;
+       struct timeval tval;
+
+       va_list va;
+
+       if (level > msg_level )
+               return;
+
+       va_start(va, format);
+       vsnprintf(tmp, MSGSIZE_MAX, format, va);
+       va_end(va);
+
+       tmp[MSGSIZE_MAX - 2] = '\n';
+       tmp[MSGSIZE_MAX - 1] = 0;
+
+       if (msg_level == MSGL_FILE) {
+               gettimeofday(&tval, NULL);
+               tm_time = gmtime(&(tval.tv_sec));
+               strftime(timeinfo, sizeof(timeinfo), "%Y/%m/%d %H:%M:%S", tm_time);
+
+               //sprintf(txt, "%s %s %s / %s", timeinfo, msglevel[level], module, tmp);
+
+               sprintf(txt, "%s %s:%s",msglevel[level], module, tmp);
+               fp = fopen(logfile, "a+");
+               fputs(txt, fp);
+               fclose(fp);
+
+               return;
+       }
+
+    /// print log message to stderr
+       fprintf(stderr, "%s %s / %s", msglevel[level], module, tmp);
+       return;
+}
+
+/**
+  * @brief
+  *
+  * @param mod
+  */
+void ge_log_msg_init(char *mod)
+{
+       char *env = getenv("VGSM_VERBOSE");
+
+
+       if (env) {
+               msg_level = atoi(env);
+               /*
+                * check message level range
+                */
+               if (!(0 < msg_level && msg_level < MSGL_FILE ) && msg_level != MSGL_FILE) {
+                       fprintf(stdout, "\n>>> debug_level must be 0~12 <otherwise: MSGL_ERR<1>\n");
+                       msg_level = MSGL_DEFAULT;
+               }
+       }
+       else {
+               msg_level = MSGL_DEFAULT;
+       }
+
+       if (!mod) {
+               fprintf(stderr, "module name needed\n");
+               exit(0);
+       }
+
+       assert(strlen(mod) < sizeof module);
+       strcpy(module, mod);
+
+       if (msg_level == MSGL_FILE) {
+               fprintf(stdout, "\n<<< vgsm >>> save log-messages to %s\n", logfile);
+       } else
+               fprintf(stdout, "\n>>> msg_level: %d, module_name: %s\n\n", msg_level, module);
+
+       return;
+}
+/**
+ * vim:set tabstop=4 shiftwidth=4 foldmethod=marker wrap:
+ *
+ */
+
diff --git a/vmodem/server/main.c b/vmodem/server/main.c
new file mode 100644 (file)
index 0000000..eb1d114
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <gsmstate.h>
+#include "phoneserver.h"
+#include <linux/capability.h>
+#include "eloop.h"
+#include "gsm.h"
+#include "logmsg.h"
+
+#include <signal.h>
+
+#include "server_common.h"             // for init_vgsm()
+
+#include "at_send.h"
+#include "at_tx_func.h"
+
+extern GSM_StateMachine  GlobalS;
+
+#include <limits.h>
+
+//#include "db_ss.h"
+
+static int eventloop(PhoneServer * ps)
+{
+       DPRAM       * dpram       = &ps->Dpram;
+       Server      * server      = &ps->ServerSocket;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       if( vgsm_server_port  ==0 ){
+               if  (dpram->fd > 0)
+               {
+                       int iotag;
+                       iotag = eloop_add_input(        ps, dpram->fd,  ELOOP_READ,
+                                                                               dpram->Functions->CallBack, 0); // &DpramHandle->dpram_callback
+                       TRACE(MSGL_VGSM_INFO, "DPRAM callback is registerd at [%d,fd=%d]\n", iotag, dpram->fd);
+               }
+
+       }
+
+       if  (server->fd > 0)
+       {
+               int iotag;
+               iotag = eloop_add_input(        ps, server->fd, ELOOP_READ,
+                                                                       server->Functions->CallBack, 0);        // &ServerHandle->server_callback
+               TRACE(MSGL_VGSM_INFO, "Server callback is registerd at [%d,fd=%d]\n", iotag, server->fd);
+       }
+
+       if  (server->inet_fd > 0)
+       {
+               int iotag;
+               iotag = eloop_add_input(        ps, server->inet_fd, ELOOP_READ,
+                                                                       server->Functions->CallBackInet, 0);    // &ServerHandle->server_inet_callback
+               TRACE(MSGL_VGSM_INFO, "Server inet callback is registerd at [%d,fd=%d]\n", iotag, server->inet_fd);
+       }
+
+       // main event loop
+       eloop_main();
+
+       return 0;
+}
+
+static void signalHandler(int iSigno)
+{
+       TRACE(MSGL_VGSM_INFO, "signo = %d\n", iSigno);
+       printf("signo = %d\n", iSigno);
+       exit(1);
+       return;
+}
+
+static void  argument_handling(int argc, char *argv[])
+{
+       vgsm_server_port=0;
+
+       int i;
+
+       if((argc%2) == 0) {
+               TRACE(MSGL_FATAL, "bad arguments\n");
+       }
+
+       if (argc >= 2) {
+               for (i=1; i<argc; i+=2)
+                       if(strcmp(argv[i], "--port") == 0) {
+                       vgsm_server_port=atoi(argv[i+1]);
+                       TRACE(MSGL_WARN," ====== vgsm server port  :   %d    ", vgsm_server_port);
+                       TRACE(MSGL_WARN," ====== Important !!!! VDPRAM driver is not used as transport ====== ");
+                       }
+                       else {
+                               TRACE(MSGL_FATAL,"\nTo set up the port  --port  [ portnumber ]\n ");
+                               exit(1);
+                       } 
+       }       
+}
+
+int main(int argc, char *argv[])
+{
+    GSM_Error error;
+    bool phone_power;
+
+       ge_log_msg_init("vgsm");
+
+    struct sigaction sa;
+    sa.sa_handler = signalHandler;
+    sigemptyset (&sa.sa_mask);
+    sa.sa_flags = SA_SIGINFO;
+
+    if (sigaction (SIGINT, &sa, NULL) == -1) {
+           TRACE(MSGL_FATAL, "sigaction error\n");
+           exit (1);
+    }
+
+    signal (SIGTERM, signalHandler);
+    signal (SIGPIPE, signalHandler);
+
+    TRACE(MSGL_VGSM_INFO, "START VIRTUAL GSM\n");
+
+    argument_handling(argc, argv);
+
+    error = GSM_Init(true);
+    if (error != ERR_NONE)
+    {
+        TRACE(MSGL_FATAL, "GSM_Init failed\n");
+               exit(-1);
+    }
+       else
+        TRACE(MSGL_VGSM_INFO, "GSM_Init ok\n");
+
+    if (PhoneServer_Init(&GlobalPS, &GlobalS) < 0)
+    {
+        TRACE(MSGL_FATAL, "PhoneServer_Init failed\n");
+               exit(-1);
+    }
+    else if(PhoneServer_Connect() < 0) {
+        TRACE(MSGL_VGSM_INFO, "PhoneServer_Connect failed\n");
+               exit(-1);
+    }
+
+    phone_power = GSM_PhonePowerStatus();
+
+#ifdef __arm__
+       error = GSM_PhonePowerOn(1);
+#else
+       FuncPhoneServer->BroadcastInternalStatus(&GlobalPS, LXT_STATE_ON);      // &PhoneServerHandle->BroadcastInternalStatus
+       GSM_Start();
+#endif
+
+       FuncPhoneServer->BroadcastInternalStatus(&GlobalPS, LXT_STATE_ON);      // &PhoneServerHandle->BroadcastInternalStatus
+       FuncPhoneServer->SetInternalState(&GlobalPS, LXT_STATE_ON);                     // &PhoneServerHandle->SetInternalState
+
+       init_vgsm();
+
+       eventloop(&GlobalPS);
+
+       return 0;
+}
diff --git a/vmodem/server/misc.c b/vmodem/server/misc.c
new file mode 100644 (file)
index 0000000..d9912c2
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+
+#include <linuxtapi.h>
+
+#include "misc.h"
+
+void* PacketDataMalloc(int size)
+{
+    void *p;
+
+    p = malloc(size);
+
+    if (p == NULL)
+        return p;
+    else
+    {
+        memset(p, 0, size);
+        return p;
+    }
+}
+
+void PacketDataFree(void *p)
+{
+    if (p != NULL)
+    {
+        free(p);
+        p = NULL;
+        return;
+    }
+}
+
+int ReadBytes(int fd, void *data, int size)
+{
+    int rc;
+
+    if ( (data == 0) || (fd < 0) )
+    {
+        return -1;
+    }
+
+    rc = read(fd, data, size);
+
+    if (rc <= 0)
+    {
+        return -1;
+    }
+
+    return rc;
+
+}
+
+int WriteBytes(int fd, void *data, int size)
+{
+    int rc;
+
+    if ( (data == 0) || (fd < 0) )
+    {
+        return -1;
+    }
+
+    rc = write(fd, data, size);
+
+    if (rc <= 0)
+    {
+        return -1;
+    }
+    // assert(rc == size);
+
+    return rc;
+
+}
+
+void TAPIMessageFree(LXT_MESSAGE * packet)
+{
+    packet->length = 0;
+    packet->group = 0;
+    packet->action = 0;
+    PacketDataFree(packet->data);
+    packet->data = 0;
+
+    return;
+}
+
+void TAPIMessageInit(LXT_MESSAGE *packet)
+{
+    packet->length = 0;
+    packet->group = 0;
+    packet->action = 0;
+    packet->data = 0;
+}
+
+int packed_S32(unsigned char* bytearray)
+{
+    unsigned char* p = bytearray;
+    int i;
+    int rc = 0;
+
+    if (!p) return 0;
+
+    for(i = sizeof(int); i >= 0; i--) rc = rc | p[i] << i*8;
+
+    return rc;
+}
+
+unsigned short packed_U16(unsigned char* bytearray)
+{
+    unsigned char* p = bytearray;
+    int i;
+    unsigned short rc = 0;
+
+    if (!p) return 0;
+
+    for(i = sizeof(unsigned short); i >= 0; i--) rc = rc | p[i] << i*8;
+
+    return rc;
+}
+
+char const* printCurrentState(LXT_PHONE_STATE CurrentState)
+{
+    switch (CurrentState)
+    {
+        case LXT_STATE_OFF :
+            return "LXT_STATE_OFF";
+
+        case LXT_STATE_ON  :
+            return "LXT_STATE_ON";
+
+        case LXT_STATE_UIM_NOT_READY :
+            return "LXT_STATE_UIM_NOT_READY";
+
+        case LXT_STATE_UIM_READY     :
+            return "LXT_STATE_UIM_READY";
+
+        case LXT_STATE_NO_SERVICE :
+            return "LXT_STATE_NO_SERVICE";
+
+        case LXT_STATE_STANDBY :
+            return "LXT_STATE_STANDBY";
+
+        case LXT_STATE_WAITING_OUTGOING_CALL :
+            return "LXT_STATE_WAITING_OUTGOING_CALL";
+
+        case LXT_STATE_WAITING_INCOMING_CALL :
+            return "LXT_STATE_WAITING_INCOMING_CALL";
+
+        case LXT_STATE_WAITING_DATA_SERVICE :
+            return "LXT_STATE_WAITING_DATA_SERVICE";
+
+        case LXT_STATE_CONVERSATION :
+            return "LXT_STATE_CONVERSATION";
+
+        case LXT_STATE_DATA_SERVICED :
+            return "LXT_STATE_DATA_SERVICED";
+
+        case LXT_STATE_DIAL_UP_DATA_SERVICED :
+            return "LXT_STATE_DIAL_UP_DATA_SERVICED";
+
+        case LXT_STATE_RELEASED :
+            return "LXT_STATE_RELEASED";
+
+        case LXT_STATE_RESERVED :
+            return "LXT_STATE_RESERVED";
+
+        default :
+            return "Unknown";
+    }
+}
+
diff --git a/vmodem/server/phoneserver.c b/vmodem/server/phoneserver.c
new file mode 100644 (file)
index 0000000..104f485
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+ #include <dpram.h>
+#include <gsmstate.h>
+
+#include "phoneserver.h"
+#include "logmsg.h"
+
+PhoneServer            GlobalPS;
+
+FunctionsDpram       * FuncDpram;
+
+FunctionsServer      * FuncServer;     // &ServerHandle
+/******************/
+PhoneServerFunc      * FuncPhoneServer;
+
+int PhoneServer_Init(PhoneServer * server, GSM_StateMachine * s) // server = GlobalPS
+{
+    // Dpram FD
+    GSM_Device_DPRAMData * d = &s->Device.Data.DPRAM;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+    if( vgsm_server_port==0 )
+           server->Dpram.fd = d->hPhone;
+
+    // Dpram
+    server->Dpram.Functions = NULL;
+    server->Dpram.Functions = &DpramHandle;
+
+    // Socket Server
+    server->ServerSocket.Functions = NULL;
+    server->ServerSocket.Functions = &ServerHandle;
+    server->ServerSocket.Functions->Init(server);
+
+    server->Functions1 = NULL;
+    server->Functions1 = &PhoneServerHandle;
+
+    server->Data.m_waitingmode = false;
+    server->Data.m_deviceCall  = false;
+
+    return 0;
+}
+
+int PhoneServer_Connect()
+{
+       // Dpram
+       FuncDpram = GlobalPS.Dpram.Functions;   // &DpramHandle
+
+       // Socket Server
+       FuncServer = GlobalPS.ServerSocket.Functions;   // &ServerHandle
+       
+       if(FuncServer->Open(&GlobalPS) < 0 )            // &ServerHandle->server_open
+               return -1;
+       
+       if(FuncServer->OpenInet(&GlobalPS) < 0) // &ServerHandle->server_inet_open
+               return -1;
+
+       FuncPhoneServer = GlobalPS.Functions1;  // &PhoneServerHandle
+
+       FuncPhoneServer->CallListId_Init(&GlobalPS);    // &PhoneServerHandle->CallListId_Init
+
+       return 0;
+}
+
+
+const char * clientName[] =
+{
+       "LXT_ID_CLIENT_RESERVED",                       //= 0x00, // ID of Reserved
+       "LXT_ID_CLIENT_INDICATOR",                      //= 0x01, // ID of GUI Server
+       "LXT_ID_CLIENT_PHONE",                          //= 0x02, // ID of Phone Client
+       "LXT_ID_CLIENT_SMS",                            //= 0x03, // ID of SMS Client
+       "LXT_ID_CLIENT_RUIM",                           //= 0x04, // ID of RUIM Manager
+       "LXT_ID_CLIENT_SERVICEMODE",            //= 0x05, // ID of Service Mode
+       "LXT_ID_CLIENT_DATASERVICE",            //= 0x06, // ID of Data service
+       "LXT_ID_CLIENT_DIAL_ON_DEMAND",         //= 0x07, // ID of Dial on demand
+       "LXT_ID_CLIENT_UTK",                            //= 0x08, // ID of UTK Client
+       "LXT_ID_CLIENT_ADDRESS",                        //= 0x09, // ID of Address Book
+       "LXT_ID_CLIENT_PHONE_SETUP",            //= 0x0A, // ID of Phone setup
+       "LXT_ID_CLIENT_CARD_MANAGER",           //= 0x0B, // ID of CARD Manager
+       "LXT_ID_CLIENT_SMS_DAEMON",                     //= 0x0C, // ID of SMS Daemon
+       "LXT_ID_CLIENT_GPS",                            //= 0x0D, // ID of GPS
+       "LXT_ID_CLIENT_SECURITY_SETUP",         //= 0x0E, // ID of Security Setup
+       "LXT_ID_CLIENT_SAT",                            //= 0x0F, // ID of sim application toolkit
+       "LXT_ID_CLIENT_DATA_1",                         //= 0x10, // ID of data 1
+       "LXT_ID_CLIENT_DATA_2",                         //= 0x11, // ID of data 2
+       "LXT_ID_CLIENT_DATA_3",                         //= 0x12, // ID of data 3
+       "LXT_ID_CLIENT_DATA_4",                         //= 0x13, // ID of data 4
+       "LXT_ID_CLIENT_DATA_5",                         //= 0x14, // ID of data 5
+       "LXT_ID_CLIENT_DATA_6",                         //= 0x15, // ID of data 6
+       "LXT_ID_CLIENT_EVENT_INJECTOR",         //= 0x16, // ID of event injector
+       "LXT_ID_CLIENT_EVENT_MANAGER_RX",       //= 0x17, // ID of event injector
+       "LXT_ID_CLIENT_EVENT_MANAGER_TX",       //= 0x18, // ID of event injector
+       "LXT_ID_CLIENT_EVENT_MANAGER",          //= 0x19, // ID of event manager 
+};
+
diff --git a/vmodem/server/server.c b/vmodem/server/server.c
new file mode 100644 (file)
index 0000000..095d35e
--- /dev/null
@@ -0,0 +1,603 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <errno.h>
+
+
+#include "phoneserver.h"
+#include "eloop.h"
+//#include "data_conn_mgr.h"
+#include "misc.h"
+#include "state.h" //define ENTER()
+#include "logmsg.h"
+
+#define MAX_LISTEN_COUNT       32
+//#define DEF_DOMAIN_SOCKET_NAME "/tmp/.phone_socket"
+#define DEF_DOMAIN_SOCKET_NAME "/tmp/.vgsm_socket"
+
+int vgsm_server_port=0;
+
+
+extern GSM_StateMachine           GlobalS;
+
+static void server_save_message(PhoneServer * ps, LXT_ID_CLIENT klass, LXT_MESSAGE * packet)
+{
+    int ii;
+
+    Server * server = &ps->ServerSocket;
+    if  (server->mmsg.current >= MAX_MISSED_MESSAGE)
+    {
+               TRACE(MSGL_WARN, "Warning!!! overrun max missed call\n");
+        server->mmsg.current = 0;
+    }
+
+    // save currunt
+    ii = server->mmsg.current;
+       TRACE(MSGL_VGSM_INFO, "Add current missed cast index: %d (client id: 0x%x)\n", ii, klass);
+       TRACE(MSGL_VGSM_INFO, "packet->group: 0x%x packet->action: 0x%x\n", packet->group, packet->action);
+
+#ifdef _DEBUG_
+       if (server->mmsg.mmsg_info[ii].klass != LXT_STATE_RELEASED) {
+               TRACE(MSGL_VGSM_ERR, "CRITICAL!!! overwrite data that not yet sent message to client\n");
+               TRACE(MSGL_VGSM_ERR, "group:0x%x, action: 0x%x\n", server->mmsg.mmsg_info[ii].group, server->mmsg.mmsg_info[ii].action);
+       }
+#endif
+    // set id
+    server->mmsg.mmsg_info[ii].klass = klass;
+
+    // clear message
+    TAPIMessageFree(&(server->mmsg.mmsg_info[ii].mmsg));
+
+    // copy message
+    server->mmsg.mmsg_info[ii].mmsg.length = packet->length;
+    server->mmsg.mmsg_info[ii].mmsg.group  = packet->group;
+    server->mmsg.mmsg_info[ii].mmsg.action = packet->action;
+
+    if  (packet->length > 0)
+    {
+        server->mmsg.mmsg_info[ii].mmsg.data =
+            (unsigned char *)PacketDataMalloc(packet->length);
+        memcpy(server->mmsg.mmsg_info[ii].mmsg.data, packet->data, packet->length);
+    }
+
+    server->mmsg.current ++;
+}
+
+static int server_send_to_client(int handle, LXT_MESSAGE * packet)
+{
+       int datasize;
+       int rc = -1;
+
+       TRACE(MSGL_VGSM_INFO, "server_send_to_client : fd = %d, total size = 4+%d ... \n", handle, packet->length);
+       // save size (length of packet is only datasize)
+       datasize = packet->length;
+
+       rc = WriteBytes(handle, packet, 4);
+       if( rc != 4 )
+               TRACE(MSGL_VGSM_ERR, "server_send_to_client1 : write error : rc = %d\n", rc);
+
+       // FIXME : Broken PIPE ¿À·ù ¼öÁ¤ÇÒ°Í.
+       if  (datasize > 0)
+       {
+               rc = WriteBytes(handle, packet->data, datasize);
+               if (rc != datasize )
+                       TRACE(MSGL_VGSM_ERR, "server_send_to_client2 : write error : rc = %d\n", rc);
+       }
+       return rc;
+}
+
+static TClientInfo * server_get_client(PhoneServer * ps, int clientid)
+{
+    Server * server = &ps->ServerSocket;
+
+    TClientInfo * ci = server->current_ci;
+    if  (ci)
+        TRACE(MSGL_VGSM_INFO, "server get client is not null\n");
+
+    while (ci)
+    {
+        //if  (ci->klass == clientid)
+        if  (ci->klass == LXT_ID_CLIENT_EVENT_INJECTOR || ci->klass == clientid)
+            return ci;
+        ci = ci->next;
+    }
+    return NULL;
+}
+
+#if 0
+static void get_domain_socket_name(char * result)
+{
+    strcpy(result, DEF_DOMAIN_SOCKET_NAME);
+    strcat(result, (const char*)"-");
+    strcat(result, getenv("USER"));
+    return;
+}
+#endif
+
+static void server_initialize(PhoneServer * ps)
+{
+    Server * server = &ps->ServerSocket;
+    int ii;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+    server->fd = -1;
+    server->inet_fd = -1;
+    server->current_ci = NULL;
+
+    // Å¬¶óÀ̾ðÆ® Á¢¼ÓÀüÀÇ ¸Þ¼¼Áö¸¦ ´ã¾ÆµÎ±â À§ÇØ ÇÊ¿äÇÔ.
+    for (ii = 0; ii < MAX_MISSED_MESSAGE; ii ++)
+    {
+        server->mmsg.mmsg_info[ii].klass = LXT_ID_CLIENT_RESERVED;
+        TAPIMessageInit( &(server->mmsg.mmsg_info[ii].mmsg) );
+    }
+}
+
+static int  server_open(PhoneServer * ps)
+{
+    Server * server = &ps->ServerSocket;
+
+    int rc = -1;
+    int len;
+    struct sockaddr_un serverAddr;
+    char socket_name[64] = {0, };
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       //090501
+    //get_domain_socket_name(socket_name);
+
+    server->fd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+       log_msg(MSGL_VGSM_INFO, "fd =%d \n", server->fd);
+
+    if (server->fd < 0)
+    {
+        TRACE(MSGL_VGSM_ERR, "socket() failed\n");
+        return -1;
+    }
+
+    unlink(socket_name);
+
+    memset(&serverAddr, 0, sizeof(serverAddr));
+    serverAddr.sun_family = AF_UNIX;
+    strcpy(serverAddr.sun_path, socket_name);
+    len = sizeof(serverAddr.sun_family) + strlen(socket_name);
+
+    rc = bind(server->fd, (struct sockaddr *)&serverAddr, len);
+
+    if (rc != 0)
+    {
+        TRACE(MSGL_VGSM_ERR, "bind() failed\n");
+        close(server->fd);
+        return -1;
+    }
+
+    rc = listen(server->fd, MAX_LISTEN_COUNT);
+
+    if  (rc != 0)
+    {
+        TRACE(MSGL_VGSM_ERR, "listen() failed\n");
+        close(server->fd);
+        return -1;
+    }
+
+    return 0;
+}
+
+
+static int server_callback(PhoneServer * ps, int fd, EloopCondition cond, void * data)
+{
+       log_msg(MSGL_VGSM_INFO, "fd = %d \n",fd);
+       Server * server = &ps->ServerSocket;
+
+       struct sockaddr_in addr;
+       int len = sizeof(addr);
+       memset(&addr, 0, len);
+
+       int client_fd = accept(server->fd, (struct sockaddr *)&addr, (socklen_t *)&len);
+
+       TRACE(MSGL_VGSM_INFO, "Client fd %d server fd %d\n", client_fd, server->fd);
+
+       if  (client_fd > 0)
+       {
+               server->ci = malloc(sizeof (TClientInfo));
+               server->ci->Functions = NULL;
+               server->ci->Functions = &ClientHandle;
+               server->ci->fd = client_fd;
+               server->ci->klass = -1;
+               server->ci->next = server->current_ci;
+               server->current_ci = server->ci;
+               TAPIMessageInit(&(server->ci->request));
+               TAPIMessageInit(&(server->ci->notification));
+               int tag = eloop_add_input(ps, server->ci->fd, ELOOP_READ,
+                           server->ci->Functions->CallBack, server->ci);
+               server->ci->tag = tag;
+               TRACE(MSGL_VGSM_INFO, "Server inet callback is registerd at [%d]\n", tag);
+       }
+       else
+       {
+               perror("accept 2");
+       }
+       return 1;
+}
+
+
+
+static int  server_inet_open(PhoneServer * ps)
+{
+       Server * server = &ps->ServerSocket;
+       struct sockaddr_in server_addr;
+       int val;
+
+       memset(&server_addr, 0, sizeof server_addr);
+       server_addr.sin_family = AF_INET;
+       server_addr.sin_port = htons(3578);
+       server_addr.sin_addr.s_addr = INADDR_ANY;
+
+       TRACE(MSGL_VGSM_INFO, "listening to port %d\n", server_addr.sin_port);
+
+       if((server->inet_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+       {
+               perror("socket() failed");
+               return -1;
+       }
+
+       val = 1;
+       setsockopt(server->inet_fd, SOL_SOCKET, SO_REUSEADDR
+               , (const char *)&val, sizeof(val));
+
+       if(bind(server->inet_fd, (struct sockaddr *)&server_addr, sizeof server_addr) == -1)
+       {
+               perror("bind() failed");
+               close(server->inet_fd);
+               return -1;
+       }
+
+       if(listen(server->inet_fd, MAX_LISTEN_COUNT) == -1)
+       {
+               perror("listen() failed");
+               close(server->inet_fd);
+               return -1;
+       }
+
+       return 0;
+}
+
+
+#if 1
+static int server_inet_callback(PhoneServer * ps, int fd, EloopCondition cond, void * data)
+{
+    Server * server = &ps->ServerSocket;
+
+    struct sockaddr_in addr;
+    int len = sizeof(addr);
+       memset(&addr, 0, len);
+
+    int client_fd = accept(server->inet_fd, (struct sockaddr *)&addr, (socklen_t *)&len);
+
+       TRACE(MSGL_VGSM_INFO, "\n\n\ninet socket accept!!!\n\n\n");
+    TRACE(MSGL_VGSM_INFO, "Client fd %d server fd %d\n",
+                                       client_fd, server->inet_fd);
+       /*
+       if  (client_fd > 0)
+       {
+               DPRAM * dpram = &GlobalPS.Dpram;
+
+               //      ++ 2008-08-05
+               //      ++ Data.DPRAM is union. So, DPRAM is not clear whether it is fake or DPRAM.
+               //      ++ It should be sure what is.
+               //
+               GSM_Device_DPRAMData   *d = &GlobalS.Device.Data.DPRAM;
+
+               d->Power = true;
+               d->hPhone = client_fd;
+
+               dpram->fd=client_fd;
+
+               int iotag;
+               iotag = eloop_add_input(ps, dpram->fd, ELOOP_READ,
+                                                               dpram->Functions->CallBack, 0); // dpram_callback
+               TRACE(MSGL_VGSM_INFO, "Server inet callback is registerd at [%d]\n", iotag);
+       }
+       else
+       {
+               perror("accept 3");
+       }
+       return 1;
+       */
+
+       if  (client_fd > 0)
+       {
+               server->ci = malloc(sizeof (TClientInfo));
+               server->ci->Functions = NULL;
+               server->ci->Functions = &ClientHandle;
+               server->ci->fd = client_fd;
+               server->ci->klass = -1;
+               server->ci->next = server->current_ci;
+               server->current_ci = server->ci;
+               TAPIMessageInit(&(server->ci->request));
+               TAPIMessageInit(&(server->ci->notification));
+               int tag = eloop_add_input(ps, server->ci->fd, ELOOP_READ,
+                           server->ci->Functions->CallBack, server->ci);
+               server->ci->tag = tag;
+               TRACE(MSGL_VGSM_INFO, "Server inet callback is registerd at [%d]\n", tag);
+       }
+       else
+       {
+               perror("accept 2");
+       }
+       return 1;
+
+}
+#else
+
+static int server_inet_callback(PhoneServer * ps, int fd, EloopCondition cond, void * data)
+{
+       log_msg(MSGL_VGSM_INFO, "fd = %d \n",fd);
+       Server * server = &ps->ServerSocket;
+
+       struct sockaddr_in addr;
+       int len = sizeof(addr);
+       memset(&addr, 0, len);
+
+       int client_fd = accept(server->fd, (struct sockaddr *)&addr, (socklen_t *)&len);
+
+       TRACE(MSGL_VGSM_INFO, "Client fd %d server fd %d\n", client_fd, server->fd);
+
+       if  (client_fd > 0)
+       {
+               server->ci = g_new(TClientInfo, 1);
+               server->ci->Functions = NULL;
+               server->ci->Functions = &ClientHandle;
+               server->ci->fd = client_fd;
+               server->ci->klass = -1;
+               server->ci->next = server->current_ci;
+               server->current_ci = server->ci;
+               TAPIMessageInit(&(server->ci->request));
+               TAPIMessageInit(&(server->ci->notification));
+               int tag = eloop_add_input(ps, server->ci->fd, ELOOP_READ,
+                           server->ci->Functions->CallBack, server->ci);
+               server->ci->tag = tag;
+               TRACE(MSGL_VGSM_INFO, "Server inet callback is registerd at [%d]\n", tag);
+       }
+       else
+       {
+               perror("accept 2");
+       }
+       return 1;
+}
+
+#endif
+
+const char *str_main_cmd[] = {
+       "GSM_COMMON", // 0x00
+"GSM_CALL",//                             0x01
+"GSM_NETWORK",//                     0x02
+"GSM_SUPS",//                             0x03
+"GSM_SMS",//                              0x04
+"GSM_MISC", //                             0x05
+"GSM_DISPLAY", //                          0x06
+"GSM_SIM", //                              0x07
+"GSM_DATA", //                             0x08
+"GSM_SAT", //                                    0x09
+"GSM_SOUND", //                                0x0A
+"GSM_EXT",//                              0x0B
+"GSM_SERVICEMODE",//           0x0C
+"GSM_EMULATOR ",//                   0x0D
+"GSM_GPRS", //                            0x0E
+"GSM_POWER",//                         0x0F
+"GSM_CLIENT" //                               0x10
+};
+
+static void server_cast(PhoneServer * ps, int clientid, LXT_MESSAGE * packet)
+{
+       _ENTER();
+    Server * server = &ps->ServerSocket;
+
+       TRACE(MSGL_VGSM_INFO, "clientid(%d) \n", clientid);
+
+    if  (server == NULL)
+        TRACE(MSGL_VGSM_INFO, "server cast server is null\n");
+    TClientInfo *ci = 0;
+    int clientfd = -1;
+
+    ci = server_get_client(ps, clientid);
+
+    if  (ci)
+        clientfd = ci->fd;
+    else
+        TRACE(MSGL_VGSM_INFO, "server cast client is null\n");
+
+    if  (clientfd > 0)
+    {
+        TRACE(MSGL_VGSM_INFO, "CAST MESSAGE TO [0x%x], MAIN[%s], SUB[0x%x] : ci fd [%d]\n", ci->klass, str_main_cmd[packet->group], packet->action, clientfd);
+
+        server_send_to_client(clientfd, packet);
+    }
+    else
+    {
+        server_save_message(ps, (LXT_ID_CLIENT)clientid, packet);
+    }
+}
+
+static void server_broadcast(PhoneServer * ps, LXT_MESSAGE * packet)
+{
+       _ENTER();
+       Server * server = &ps->ServerSocket;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       TClientInfo * ci = server->current_ci;
+       int clientfd = -1;
+
+       if  (ci)
+               TRACE(MSGL_VGSM_INFO, "server get client is not null\n");
+
+       while (ci)
+       {
+               if  (ci->fd > 0)
+               {
+                       if  (ci->klass == 0x10)
+                       {
+                               ci = ci->next;
+                               continue;
+                       }
+
+                       WriteBytes(ci->fd, packet, 4);
+                       if  (packet->length > 0)
+                               WriteBytes(ci->fd, packet->data, packet->length);
+               }
+
+               ci = ci->next;
+       }
+
+       // nsclass : Especially, cast internal message to phone indicator, because, phone applet broadcast
+       // phone state to other client.(save missed message)
+       // 1. LXT_ID_CLIENT_INDICATOR
+       ci = server_get_client(ps, LXT_ID_CLIENT_INDICATOR);
+       if (ci)
+               clientfd = ci->fd;
+
+       if (clientfd < 0)
+               server_save_message(ps, LXT_ID_CLIENT_INDICATOR, packet);
+
+       // 2. LXT_ID_CLIENT_DATASERVICE
+       clientfd = -1;
+       ci = server_get_client(ps, LXT_ID_CLIENT_DATASERVICE);
+       if (ci)
+               clientfd = ci->fd;
+
+       if (clientfd < 0)
+               server_save_message(ps, LXT_ID_CLIENT_DATASERVICE, packet);
+
+       // 3. LXT_ID_CLIENT_CARD_MANAGER
+       clientfd = -1;
+       ci = server_get_client(ps, LXT_ID_CLIENT_CARD_MANAGER);
+       if (ci)
+               clientfd = ci->fd;
+
+       if (clientfd < 0)
+               server_save_message(ps, LXT_ID_CLIENT_CARD_MANAGER, packet);
+
+       return;
+}
+
+static void clear_client_related_data(int client_id)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       // 1. Multiple PDP related
+       //GetDataConnectMgr()->m_pFunc->ClearClient((unsigned char)client_id);
+
+       // 2. RequestResponse related
+}
+
+static void server_remove_client(PhoneServer * ps, TClientInfo *me)
+{
+       Server * server = &ps->ServerSocket;
+       TClientInfo *curr = server->current_ci, *prev = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       while (curr)
+       {
+               if (curr == me)
+               {
+                       if  (prev)
+                       {
+                               prev->next = curr->next;
+                       }
+                       else
+                       {
+                               server->current_ci = curr->next;
+                       }
+                       TAPIMessageFree( &(curr->notification) );
+                       TAPIMessageFree( &(curr->request) );
+                       close(curr->fd);
+
+                       clear_client_related_data(curr->klass);
+
+                       PacketDataFree(curr);
+                       return;
+               }
+               prev = curr;
+               curr = curr->next;
+       }
+}
+
+//void server_cast_missed_message(PhoneServer * ps, LXT_ID_CLIENT klass,
+static void server_cast_missed_message(PhoneServer * ps, int klass, int clientfd)
+{
+       Server * server = &ps->ServerSocket;
+       //TClientInfo *curr = server->current_ci, *prev = 0;
+       int ii = 0;
+       //int jj;
+       int rc;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       for (ii = 0; ii < MAX_MISSED_MESSAGE; ii ++)
+       {
+               if  (server->mmsg.mmsg_info[ii].klass == klass)
+               {
+                       rc = WriteBytes( clientfd, &(server->mmsg.mmsg_info[ii].mmsg), 4);
+                       if  (server->mmsg.mmsg_info[ii].mmsg.length > 0)
+                       {
+                               // tx data to client
+                               rc = WriteBytes(        clientfd,
+                                                                       server->mmsg.mmsg_info[ii].mmsg.data,
+                                                                       server->mmsg.mmsg_info[ii].mmsg.length);
+            }
+
+                       server->mmsg.mmsg_info[ii].klass = LXT_ID_CLIENT_RESERVED;
+                       TRACE(MSGL_VGSM_INFO, "removed missed cast index: %d by client(0x%x)\n", ii, klass);
+
+                       // clear message
+                       TAPIMessageFree(&(server->mmsg.mmsg_info[ii].mmsg));
+               }
+       }
+}
+
+FunctionsServer ServerHandle =
+{
+       server_initialize,
+       server_open,
+       server_callback,
+       server_inet_open,
+       server_inet_callback,
+       server_cast,
+       server_broadcast,
+       server_remove_client,
+       server_cast_missed_message
+};
+
diff --git a/vmodem/server/server_client.c b/vmodem/server/server_client.c
new file mode 100644 (file)
index 0000000..2d5dbe8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "misc.h"
+#include "vgsm_debug.h"
+#include "vgsm_phone.h"
+#include "phoneserver.h"
+#include "logmsg.h"
+#include "server_client.h"
+
+void server_client_release_noti(void)
+{
+       log_msg(MSGL_VGSM_INFO," Cast\n" );
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       packet.data = NULL;
+       packet.length = 0;
+       packet.group  = GSM_CLIENT;
+       packet.action = GSM_CLIENT_RELEASE_NOTI_ACK;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       //return 1;
+}
+
diff --git a/vmodem/server/server_common.c b/vmodem/server/server_common.c
new file mode 100644 (file)
index 0000000..0697240
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_common_network.h"
+#include "server_common_security.h"
+#include "server_common_ss.h"
+#include "db_gprs.h"
+#include "db_ss.h"
+#include "db_network.h"
+
+#include "server_tx_sms.h"
+#include "server_tx_display.h"
+#include "server_tx_network.h"
+#include "server_common.h"
+
+//080227 - after editting gprs part in state.c, will be removed.
+#include "state.h"
+
+
+unsigned char g_rssi_value = 0x05;
+unsigned char g_hdr_rssi_value = 0x00;
+unsigned char g_battery_level = 0x04;
+
+void init_vgsm(void)
+{
+       // initialize network db
+       vgsm_network_database_init();
+       init_plmn_list();
+       init_network_registration();
+
+       // initialize sim security & phonebook db
+       server_sim_db_init();
+
+       // initialize sim data - 090502
+       server_simdata_init();
+
+       // initialize gprs db
+       vgsm_gprs_database_init();
+       init_gprs_info();
+
+       // initialize ss db
+       vgsm_ss_database_init();
+       init_ss_info();
+}
+
+
+int server_common_after_sim_init(void)
+{
+       /* request device ready for SMS */
+       server_tx_sms_deviceReady(NULL);
+
+       /* network reg init */
+       server_tx_net_reg_noti(NULL);
+
+       /* display info noti */
+       server_tx_display_icon_info_noti(0xff, g_rssi_value, g_battery_level, 0, 0);
+
+       return 1;
+}
diff --git a/vmodem/server/server_common_call.c b/vmodem/server/server_common_call.c
new file mode 100644 (file)
index 0000000..a0fef53
--- /dev/null
@@ -0,0 +1,611 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/****************************************
+*****    server_common_call.c
+*****************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "logmsg.h"
+#include "misc.h"
+#include "phoneserver.h"
+#include "state.h"
+
+#include "server_tx_call.h"
+#include "server_rx_call.h"
+#include "server_common_call.h"
+#include "state.h" // for _ENTER()
+#include "vgsm_ss.h"
+
+#define MAX_CONFERENCE_CALL_COUNT      5
+
+static gsm_call_list_t g_call_list;
+static int g_call_id = -1;
+static int g_call_type = -1;
+static int g_call_line_id = 0; // default line id is 0.
+static ss_hold_act_state_e_type g_ss_hold_act_state =  SS_NONE;
+
+void set_call_list( gsm_call_direction_e_type dir, gsm_call_status_e_type stat, gsm_call_type_e_type type, char *number, int num_len )
+{
+    _ENTER();
+
+       int call_id = get_call_id();
+
+       if( g_call_list.CallCount >= MAX_CALL_COUNT )
+               return;
+
+       assert(valid_call_type(type));
+
+    g_call_list.CallCount++;
+    log_msg(MSGL_VGSM_INFO, "CallCount: %d\n", g_call_list.CallCount);
+    //g_call_list.CallCount = 1; // for single call
+
+    g_call_list.CallInfo[call_id].idx = call_id;
+    g_call_list.CallInfo[call_id].dir = dir;
+    g_call_list.CallInfo[call_id].stat = stat;
+    g_call_list.CallInfo[call_id].call_type = type;
+    g_call_list.CallInfo[call_id].mpty = 0x00;
+    memcpy( g_call_list.CallInfo[call_id].number, number, num_len );
+    g_call_list.CallInfo[call_id].num_len = num_len;
+    g_call_list.CallInfo[call_id].num_type = 0x01; //0x23;
+
+    _LEAVE();
+}
+
+void get_call_list( gsm_call_list_t *list )
+{
+    memcpy( list, &g_call_list, sizeof( gsm_call_list_t ) );
+}
+
+void set_call_list_status( int call_id, int mpty, gsm_call_status_e_type stat )
+{
+    _ENTER();
+
+    if( g_call_list.CallCount >= MAX_CALL_COUNT )
+       return;
+
+    g_call_list.CallInfo[call_id].stat = stat;
+    g_call_list.CallInfo[call_id].mpty = 0x00;
+
+    _LEAVE();
+}
+
+int delete_call_list( int call_id )
+{
+    _ENTER();
+
+    log_msg(MSGL_VGSM_INFO,"delete call_id : %x\n", call_id);
+    if( call_id < 0 || call_id >= MAX_CALL_COUNT )
+       return 0;
+
+    memset( &(g_call_list.CallInfo[call_id]), 0, sizeof( gsm_call_list_info_t ) );
+
+    g_call_list.CallCount--;
+
+    if( g_call_list.CallCount < 0 )
+       g_call_list.CallCount = 0;
+
+    _LEAVE();
+
+    return 1;
+}
+
+void clear_call_list(void)
+{
+    _ENTER();
+
+    memset( &g_call_list, 0, sizeof( gsm_call_list_t ) );
+    //g_call_list.CallCount = 0;
+
+    _LEAVE();
+}
+
+// 090320
+int get_callcount(void)
+{
+       return g_call_list.CallCount;
+}
+
+int get_active_call_count(void)
+{
+    int i = 0, active = 0;
+
+    for( i=0; i<MAX_CALL_COUNT; ++i ) {
+       switch( g_call_list.CallInfo[i].stat ) {
+       case GSM_CALL_STATUS_ACTIVE:
+           active++;
+           break;
+       default:
+           break;
+       }
+    }
+
+    return active;
+}
+
+int get_hold_call_count(void)
+{
+    int i = 0, hold = 0;
+
+    for( i=0; i<MAX_CALL_COUNT; ++i ) {
+       switch( g_call_list.CallInfo[i].stat ) {
+       case GSM_CALL_STATUS_HELD:
+           hold++;
+           break;
+       default:
+           break;
+       }
+    }
+
+    return hold;
+}
+int is_prev_ss_state(ss_hold_act_state_e_type prev_state)
+{
+       if( prev_state == g_ss_hold_act_state )
+               return 1;
+       return 0;
+}
+
+void set_ss_state(ss_hold_act_state_e_type state)
+{
+       g_ss_hold_act_state = state;
+}
+
+void set_rx_ss_state(void)
+{
+       int i;
+       for( i=0; i<MAX_CALL_COUNT; ++i )
+       {
+               switch( g_call_list.CallInfo[i].stat )
+               {
+                       case GSM_CALL_STATUS_ACTIVE:
+                               set_ss_state(SS_RX_HOLD);
+                               break;
+                       case GSM_CALL_STATUS_HELD:
+                               set_ss_state(SS_RX_ACTIVATE);
+                               break;
+
+                       default:
+                               break;
+               }
+       }
+}
+
+int swap_call(void)
+{
+    _ENTER();
+
+    int i = 0, active = 0, hold = 0;
+    unsigned char *data = 0;
+    LXT_MESSAGE packet;
+
+    active = get_active_call_count();
+    hold = get_hold_call_count();
+
+    for( i=0; i<MAX_CALL_COUNT; ++i ) {
+       switch( g_call_list.CallInfo[i].stat ) {
+       case GSM_CALL_STATUS_ACTIVE:
+       {
+           g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_HELD;
+           break;
+          }
+       case GSM_CALL_STATUS_WAITING:
+       {
+           //STATE next;
+           set_call_id( i );
+           server_rx_call_answer_exec();
+       /*
+           if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+               set_state_machine( next );
+               send_msg();
+           }
+           */
+           g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_ACTIVE;
+       }
+           break;
+       case GSM_CALL_STATUS_HELD:
+           if( ( active > 0 ) || ( hold == g_call_list.CallCount ) )
+               g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_ACTIVE;
+           break;
+       case GSM_CALL_STATUS_DIALING:
+               {
+                       //STATE next;
+                       set_call_id( i );
+                       server_rx_call_answer_exec();
+                       /*
+                       if( find_next_state( &next, STATE_FLAG_ALL ) )
+                       {
+                               set_state_machine( next );
+                               send_msg();
+                       }
+                       */
+                       g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_ACTIVE;
+               }
+               break;
+
+       default:
+           break;
+       }
+    }
+
+    TAPIMessageInit(&packet);
+
+    data = malloc(sizeof(unsigned char)*1);
+    if( active == g_call_list.CallCount )
+       data[0] = SS_STATE_HOLD; /* hold */
+    else if( hold == g_call_list.CallCount )
+       data[0] = SS_STATE_UNHOLD; /* unhold */
+    else if( active != 0 && hold != 0 )
+       data[0] = SS_STATE_SWAP; /* swap */
+
+    packet.data = data;
+    packet.length = 1;
+
+    packet.group  = GSM_SUPS;
+    packet.action = GSM_SUPS_STATE;
+    packet.length = 1;
+
+    FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+    free(data);
+
+    _LEAVE();
+
+    return 1;
+}
+
+int drop_call( int call_id )
+{
+       _ENTER();
+
+       int i = 0;
+       int active_call_id = -1;
+       unsigned char *data = 0;
+       LXT_MESSAGE packet;
+
+       if( call_id < 0 || call_id >= MAX_CALL_COUNT )
+               return 0;
+/*
+       for( i=0; i<MAX_CALL_COUNT; ++i ) {
+               switch( g_call_list.CallInfo[i].stat ) {
+                       case GSM_CALL_STATUS_ACTIVE:
+                               if( g_call_list.CallInfo[i].idx == call_id )
+                                       server_tx_call_release_internal( g_call_list.CallInfo[i].idx );
+                               else
+                               {
+                                       if( active_call_id == -1 )
+                                               active_call_id = g_call_list.CallInfo[i].idx;           // 1 active call
+                                       else if( active_call_id >= 0 )
+                                               active_call_id = -2;                                            // 2 or more active calls
+                               }
+
+                               break;
+                       default: // TODO: held call release check!!
+                               break;
+               }
+       }
+*/
+       for( i=0; i<MAX_CALL_COUNT; ++i )
+       {
+               if( g_call_list.CallInfo[i].idx == call_id )
+               {
+                       server_tx_call_release_internal( g_call_list.CallInfo[i].idx );
+                       active_call_id = call_id;
+                       break;
+
+               }
+       }
+
+       if( active_call_id >= 0 )
+               g_call_list.CallInfo[active_call_id].mpty = 0x00;
+
+       TAPIMessageInit(&packet);
+
+       data = malloc(sizeof(unsigned char)*1);
+       data[0] = SS_STATE_DROP; /* drop */
+
+       packet.data = data;
+       packet.length = 1;
+
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_STATE;
+       packet.length = 1;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       free(data);
+
+       _LEAVE();
+
+       return 1;
+}
+
+int split_call( int call_id )
+{
+       _ENTER();
+
+       int i = 0, active = 0, hold = 0;
+       unsigned char *data = 0;
+       LXT_MESSAGE packet;
+
+       hold = get_hold_call_count();
+       if( hold > 0 )
+               return 0;
+
+       active = get_active_call_count();
+
+       for( i=0; i<MAX_CALL_COUNT; ++i ) {
+               switch( g_call_list.CallInfo[i].stat ) {
+                       case GSM_CALL_STATUS_ACTIVE:
+                               if( g_call_list.CallInfo[i].idx != call_id )
+                               {
+                                       g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_HELD;
+                                       if( active == 2 )
+                                               g_call_list.CallInfo[i].mpty = 0x00;
+                               }
+                       else
+                               g_call_list.CallInfo[i].mpty = 0x00;
+                       break;
+
+                       default:
+                               break;
+               }
+       }
+
+       TAPIMessageInit(&packet);
+
+       data = (unsigned char *)malloc(sizeof(unsigned char)*1);
+       data[0] = SS_STATE_SPLIT; /* split */
+
+       packet.data = data;
+       packet.length = 1;
+
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_STATE;
+       packet.length = 1;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       free(data);
+
+       _LEAVE();
+
+       return 1;
+}
+
+int join_call(void)
+{
+    _ENTER();
+
+    int i = 0;
+    unsigned char *data = 0;
+    LXT_MESSAGE packet;
+
+    log_msg(MSGL_VGSM_INFO, "%d, %d\n", get_active_call_count(), get_hold_call_count() );
+
+    if( get_hold_call_count() >= MAX_CONFERENCE_CALL_COUNT )
+       return 0;
+
+    for( i=0; i<MAX_CALL_COUNT; ++i ) {
+       switch( g_call_list.CallInfo[i].stat ) {
+       case GSM_CALL_STATUS_HELD:
+           g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_ACTIVE;
+       case GSM_CALL_STATUS_ACTIVE:
+           g_call_list.CallInfo[i].mpty = 0x01;
+           break;
+       default:
+           break;
+       }
+    }
+
+    TAPIMessageInit(&packet);
+
+    data = (unsigned char *)malloc(sizeof(unsigned char)*1);
+    data[0] = SS_STATE_CONFERENCE; /* conference */
+
+    packet.data = data;
+    packet.length = 1;
+
+    packet.group  = GSM_SUPS;
+    packet.action = GSM_SUPS_STATE;
+    packet.length = 1;
+
+    FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+    free(data);
+
+    _LEAVE();
+
+    return 1;
+}
+
+int check_call(void)
+{
+       int i = 0, active = 0, hold = 0;
+
+       for( i=0; i<MAX_CALL_COUNT; ++i ) {
+               switch( g_call_list.CallInfo[i].stat ) {
+               case GSM_CALL_STATUS_HELD:
+                       hold++;
+                       break;
+               case GSM_CALL_STATUS_ACTIVE:
+                       active++;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       if( active != 0 && hold != 0 )
+               return 0;
+       else
+               return 1;
+}
+
+int active_waiting_or_held_call(bool onWaiting)
+{
+    int i = 0;
+
+    for( i = 0; i<MAX_CALL_COUNT; ++i ) {
+        switch( g_call_list.CallInfo[i].stat ) {
+        case GSM_CALL_STATUS_WAITING:
+        {
+            set_call_id( i );
+            server_rx_call_answer_exec();
+            break;
+        }
+        case GSM_CALL_STATUS_HELD:
+            if(onWaiting == false)
+                g_call_list.CallInfo[i].stat = GSM_CALL_STATUS_ACTIVE;
+            break;
+        default:
+            break;
+        }
+    }
+
+    return 1;
+}
+
+int release_all_active_call(void)
+{
+    int i = 0;
+    bool onWaiting = false;
+
+    for( i = 0; i<MAX_CALL_COUNT; ++i ) {
+        switch( g_call_list.CallInfo[i].stat ) {
+        case GSM_CALL_STATUS_ACTIVE:
+            server_tx_call_release_internal( g_call_list.CallInfo[i].idx );
+            break;
+        case GSM_CALL_STATUS_WAITING:
+            onWaiting = true;
+            break;
+        default:
+            break;
+        }
+    }
+
+    return active_waiting_or_held_call(onWaiting);
+}
+
+int release_all_held_call(void)
+{
+    int i = 0;
+
+       for( i=0; i<MAX_CALL_COUNT; ++i )
+       {
+               switch( g_call_list.CallInfo[i].stat )
+               {
+       case GSM_CALL_STATUS_HELD:
+                       case GSM_CALL_STATUS_INCOMING :
+                       case GSM_CALL_STATUS_WAITING :
+           server_tx_call_release_internal( g_call_list.CallInfo[i].idx );
+           break;
+
+       default:
+           break;
+       }
+    }
+
+    return 1;
+}
+
+// End of Call.
+
+
+int make_call_id(void)
+{
+       int i = 0;
+
+       if( g_call_list.CallCount == 0 ) {
+               g_call_id = 0;
+               return g_call_id;
+       }
+
+       for( i=0; i<MAX_CALL_COUNT; ++i ) {
+               if( g_call_list.CallInfo[i].stat == GSM_CALL_STATUS_NONE ) {
+                       g_call_id = i;
+                       break;
+               }
+       }
+       return g_call_id;
+}
+
+void set_call_id( int call_id )
+{
+       if( call_id < 0 || call_id >= MAX_CALL_COUNT )
+               return;
+       g_call_id = call_id;
+}
+
+int get_call_id(void)
+{
+    return g_call_id;
+}
+
+void set_call_type( int type )
+{
+       assert(valid_call_type(type));
+    g_call_type = type;
+}
+
+int get_call_type(void)
+{
+       assert(valid_call_type(g_call_type));
+    return g_call_type;
+}
+
+void set_call_line_id( int line_id )
+{
+    g_call_line_id = line_id;
+}
+
+int get_call_line_id(void)
+{
+    return g_call_line_id;
+}
+
+int valid_call_type(int call_type)
+{
+       return 1;
+}
+
+/*   check general response error & call status error    */
+int check_call_error(void)
+{
+       int gen_resp_err;
+       int call_status_err;
+
+       gen_resp_err = get_general_response_error();
+       set_current_general_response_error( gen_resp_err );
+       call_status_err = get_call_status_error();
+       set_current_call_status_error( call_status_err);
+       return gen_resp_err;
+}
+
diff --git a/vmodem/server/server_common_gprs.c b/vmodem/server/server_common_gprs.c
new file mode 100644 (file)
index 0000000..a298126
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "db_gprs.h"
+#include "linuxtapi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "vgsm_phone.h"
+#include "phoneserver.h"
+#include "logmsg.h"
+#include "state.h"
+
+
+extern GprsConfList g_gprs_conflist;
+
+void init_gprs_info(void)
+{
+       /* apn: "Tizen", interface: "lo", ip: 1.2.3.4, primary dns: 10.10.10.10
+          , second dns: 11.11.11.11, gateway: 1.2.3.1, subnet: 255.255.255.0 */
+       GprsDbEntry entry = {"Tizen", "lo", {1, 0x001F, 
+               {0x01, 0x02, 0x03, 0x04}, {0x0A, 0x0A, 0x0A, 0x0A},
+               {0x0B, 0x0B, 0x0B, 0x0B}, {0x01, 0x02, 0x03, 0x01},
+               {0xFF, 0xFF, 0xFF, 0x00}}};
+
+       LXT_MESSAGE packet;
+       char *buf, *pos;
+       int len, i;
+       GprsDbEntry *pentry;
+
+       // load database
+       vgsm_gprs_database_restore();
+
+       log_msg(MSGL_VGSM_INFO,"num of current saved GPRS IP configuration: %i \n", g_gprs_conflist.num);
+
+       if (g_gprs_conflist.num == 0) {
+               // add default IP configuration to DB
+               vgsm_gprs_database_add(&entry);
+       }
+
+       // load database
+       vgsm_gprs_database_restore(); 
+
+       len = sizeof(int) + (g_gprs_conflist.num * (255 + 10 + 23));
+
+       // send noti to evt injector
+       if ((buf = malloc(len)) == NULL) {
+               log_msg(MSGL_VGSM_ERR,"init_gprs_info: memory alloc error\n");
+               return;
+       }
+
+       memset(buf, 0, len);
+
+       *((int *)buf) = g_gprs_conflist.num;
+
+       pos = buf + sizeof(int);
+
+       for (i = 0; i < g_gprs_conflist.num; i++ ) {
+               pentry = &(g_gprs_conflist.pentry[i]);
+
+               strcpy(pos, pentry->apn);
+
+               strcpy(pos + 255, pentry->intf);
+
+               pos[265] = pentry->ipconf.cid;
+
+               memcpy(pos + 266, (char *)(&(pentry->ipconf.fieldflag)), 2);
+               memcpy(pos + 268, (char *)(pentry->ipconf.ip_addr), 4);
+               memcpy(pos + 272, (char *)(pentry->ipconf.primary_dns), 4);
+               memcpy(pos + 276, (char *)(pentry->ipconf.secondary_dns), 4);
+               memcpy(pos + 280, (char *)(pentry->ipconf.default_gateway), 4);
+               memcpy(pos + 284, (char *)(pentry->ipconf.subnet_mask), 4);
+
+               pos += 255 + 10 + 23;
+       }
+
+       packet.group  = GSM_DATA;
+       packet.action = GSM_DATA_GPRS_INIT_REQ;
+       packet.length = len;
+       packet.data = (void *)buf;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if (buf)
+               free(buf);
+}
diff --git a/vmodem/server/server_common_network.c b/vmodem/server/server_common_network.c
new file mode 100644 (file)
index 0000000..8d77ec1
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_network.h"
+#include "db_network.h"
+#include "vgsm_debug.h"
+
+#include "linuxtapi.h"
+#include "phoneserver.h"
+#include "vgsm_phone.h"
+#include "server_common_network.h"
+
+gsm_network_plmn_list_t g_plmn_list;
+gsm_network_reg_t g_network_reg;
+gsm_net_sel_e_type g_network_sel_mode = GSM_NET_SEL_AUTO;
+gsm_net_band_mode_e_type  g_network_band_mode = 0x01;
+gsm_net_svc_domain_e_type g_service_domain = 0x01;
+int  g_network_band = 0x40000000;
+gsm_network_nitz_info_t   g_network_identity ;
+#if 0
+        = {
+       GSM_NET_NITZ_MMINFO_CS,
+       GSM_NET_NITZ_SHORT_NAME_MASK,
+       1,
+       4,
+       {0x41,0x42,0x43,0x44,0,},//"ABCD",
+       0,
+       0,
+       {0x33,0x34,0x35,0x36,0,}//"ABCD",
+};  // need to initial
+#endif
+
+
+/*
+ * load plmn list from network db.
+ * if not exising plmn, then load default plmn and backup the plmn (mckim)
+ */
+void init_plmn_list(void)
+{
+       NetworkEntry entry;
+       /* Update for public open
+          0x34, 0x35, 0x30, 0x30, 0x31, 0x23 // 45001#
+          =>
+          0x31, 0x31, 0x31, 0x31, 0x31, 0x23 // 11111#
+        */
+       //char plmn[6] = {0x31, 0x31, 0x31, 0x31, 0x31, 0x23}; // "111111#"
+       char plmn[6]; // "111111#"
+       memset(plmn, '\0', sizeof(plmn));
+       plmn[0] = 0x31;
+       plmn[1] = 0x31;
+       plmn[2] = 0x31;
+       plmn[3] = 0x31;
+       plmn[4] = 0x31;
+       plmn[5] = 0x23;
+
+       LXT_MESSAGE packet;
+       char *buf;
+       int i;
+
+       // load 
+       vgsm_network_database_restore();
+
+       VGSM_DEBUG("num of current saved PLMN: %i \n", g_plmn_list.num_record);
+
+       if (g_plmn_list.num_record == 0) {
+               g_plmn_list.num_record = 1;
+               g_plmn_list.precord = malloc(sizeof(gsm_network_plmn_record_t)*g_plmn_list.num_record); // it needs free().
+               memset(g_plmn_list.precord, '\0', sizeof(g_plmn_list.precord));
+               g_plmn_list.precord[0].status = GSM_NET_PLMN_STATUS_AVAIL; // PLMN_STATUS
+               
+               //memcpy(g_plmn_list.precord[0].plmn, plmn, 6);
+               g_plmn_list.precord[0].plmn[0] = plmn[0];
+               g_plmn_list.precord[0].plmn[1] = plmn[1];
+               g_plmn_list.precord[0].plmn[2] = plmn[2];
+               g_plmn_list.precord[0].plmn[3] = plmn[3];
+               g_plmn_list.precord[0].plmn[4] = plmn[4];
+               g_plmn_list.precord[0].plmn[5] = plmn[5];
+               
+               g_plmn_list.precord[0].act = GSM_NET_ACT_UTRAN; // ACT
+
+               // add to db
+               VGSM_DEBUG("precord[0].plmn:%c %c %c %c %c %c\n", g_plmn_list.precord[0].plmn[0], g_plmn_list.precord[0].plmn[1], g_plmn_list.precord[0].plmn[2], g_plmn_list.precord[0].plmn[3], g_plmn_list.precord[0].plmn[4], g_plmn_list.precord[0].plmn[5]);
+               memcpy(entry.number_PLMN, g_plmn_list.precord[0].plmn, 6);
+               VGSM_DEBUG("number_PLMN:%s\n", entry.number_PLMN);
+               entry.PLMN_status = g_plmn_list.precord[0].status;
+               entry.ACT = g_plmn_list.precord[0].act;
+
+               vgsm_network_database_add(&entry);
+       }
+
+       // send noti to evt injector
+       if ((buf = malloc(1 + g_plmn_list.num_record * 8)) == NULL) { 
+               log_msg(MSGL_VGSM_ERR,"init_plmn_list: memory alloc error\n");
+               return;
+       }
+
+       buf[0] = g_plmn_list.num_record;
+
+       for (i = 0; i < g_plmn_list.num_record; i++) {
+               int idx = 1 + 8 * i;
+               buf[idx] = g_plmn_list.precord[i].status;
+               memcpy((buf + idx + 1), g_plmn_list.precord[i].plmn, 6);
+               buf[idx + 7] = g_plmn_list.precord[i].act;
+       }
+
+       packet.group  = GSM_NETWORK;
+       packet.action = GSM_NETWORK_PLMN_LIST;
+       packet.length = 1 + g_plmn_list.num_record * 8;
+       packet.data = (void *)buf;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);     // &ServerHandle->server_cast
+
+       if(buf)
+               free(buf);
+}
+
+
+void set_plmn_list( unsigned char *data, int len )
+{
+       int i = 0, j = 1;
+       NetworkEntry entry;
+       VGSM_DEBUG("\n");
+
+       if (g_plmn_list.num_record != 0) {
+
+               // clean network db (mckim)
+               for (i = 0; i < g_plmn_list.num_record; i++) {
+                       memcpy(entry.number_PLMN, g_plmn_list.precord[i].plmn, 6);
+                       vgsm_network_database_remove(&entry);
+               }
+
+               g_plmn_list.num_record = 0;
+
+               free( g_plmn_list.precord );
+               g_plmn_list.precord = 0;
+       }
+
+       g_plmn_list.num_record = data[0];
+
+       g_plmn_list.precord = (gsm_network_plmn_record_t *)malloc(sizeof(gsm_network_plmn_record_t)*g_plmn_list.num_record);
+
+       for (i = 0; i < g_plmn_list.num_record; ++i) {
+
+               g_plmn_list.precord[i].status = data[j++];
+               memcpy(g_plmn_list.precord[i].plmn, &data[j], 6);
+               j += 6;
+               g_plmn_list.precord[i].act = data[j++];
+
+               // update network db (mckim)
+               memcpy(entry.number_PLMN, g_plmn_list.precord[i].plmn, 6);
+               entry.PLMN_status = g_plmn_list.precord[i].status;
+               entry.ACT = g_plmn_list.precord[i].act;
+
+               vgsm_network_database_add(&entry);
+       }
+
+}
+
+
+gsm_network_plmn_list_t *get_plmn_list()
+{
+    return &g_plmn_list;
+}
+
+// TODO:  this function will be based on network db.
+void init_network_registration( void)
+{
+       VGSM_DEBUG("\n");
+       g_network_reg.act = GSM_NET_ACT_UTRAN;
+       g_network_reg.service_domain = GSM_NET_SERVICE_DOMAIN_COMBINED; //GSM_NET_SERVICE_DOMAIN_PACKET;
+       g_network_reg.reg_status = GSM_NET_REG_STAT_REG_HOME;
+       g_network_reg.edge_support = GSM_NET_EDGE_NOTSUPPORT;
+       g_network_reg.lac[0] = 0x11;
+       g_network_reg.lac[1] = 0x20;
+       g_network_reg.cell_id[0] = 0x00;
+       g_network_reg.cell_id[1] = 0x00;
+       g_network_reg.cell_id[2] = 0x00;
+       g_network_reg.cell_id[3] = 0x0A;
+       g_network_reg.rej_cause = 0x00;
+}
+
+void set_network_registration( unsigned char *data, int len )
+{
+       VGSM_DEBUG("\n");
+       g_network_reg.act = data[0];
+       g_network_reg.service_domain = data[1];
+       g_network_reg.reg_status = data[2];
+       g_network_reg.edge_support = data[3];
+       g_network_reg.lac[0] = data[4];
+       g_network_reg.lac[1] = data[5];
+       g_network_reg.cell_id[0] = data[6];
+       g_network_reg.cell_id[1] = data[7];
+       g_network_reg.cell_id[2] = data[8];
+       g_network_reg.cell_id[3] = data[9];
+       g_network_reg.rej_cause = data[10];
+}
+
+gsm_network_reg_t *get_network_registration()
+{
+    return &g_network_reg;
+}
+
+void set_plmn_selection( gsm_net_sel_e_type mode, unsigned char plmn[], gsm_net_act_e_type act )
+{
+       int i = 0, find = 0;
+
+       g_network_sel_mode = mode;
+
+       /* manual */
+       if( mode == GSM_NET_SEL_MANU )
+       {
+               for(i=0; i<g_plmn_list.num_record; ++i)
+               {
+                       if( memcmp( g_plmn_list.precord[i].plmn, plmn, 6 ) == 0 )
+                       {
+                               g_plmn_list.precord[i].status = GSM_NET_PLMN_STATUS_CURRENT;
+                               find = 1;
+                       }
+                       else if( g_plmn_list.precord[i].status == GSM_NET_PLMN_STATUS_CURRENT )
+                               g_plmn_list.precord[i].status = GSM_NET_PLMN_STATUS_AVAIL;
+               }
+       }
+
+       if( mode == GSM_NET_SEL_AUTO)// || ( mode == GSM_NET_SEL_MANU_AUTO && find == 0 ) )
+       {
+               /* automatic */
+               for(i=0; i<g_plmn_list.num_record; ++i)
+               {
+                       if( i == 0 )
+                               g_plmn_list.precord[i].status = GSM_NET_PLMN_STATUS_CURRENT;
+                       else if( g_plmn_list.precord[i].status == GSM_NET_PLMN_STATUS_CURRENT )
+                               g_plmn_list.precord[i].status = GSM_NET_PLMN_STATUS_AVAIL;
+               }
+       }
+}
+
+void  set_network_band_mode(gsm_net_band_mode_e_type band_mode, int band)
+{
+       g_network_band_mode = band_mode ;
+       g_network_band = band ;
+}
+
+gsm_net_sel_e_type get_network_sel_mode()
+{
+    return g_network_sel_mode;
+}
+
+void  set_network_service_domain(gsm_net_svc_domain_e_type  sevice_domain)
+{
+       g_service_domain = sevice_domain ;
+
+}
+
+gsm_net_svc_domain_e_type get_network_service_domain()
+{
+       return g_service_domain;
+
+}
+
+
+gsm_net_band_mode_e_type  get_network_band_mode(  )
+{
+    return  g_network_band_mode ;
+}
+
+int  get_network_band( )
+{
+    return  g_network_band ;
+}
+
+void set_network_identity( gsm_network_nitz_info_t net_identity)
+{
+       memcpy( &g_network_identity, &net_identity, sizeof( g_network_identity));
+}
+
+void get_network_identity( gsm_network_nitz_info_t *net_identity)
+{
+       memcpy( net_identity, &g_network_identity, sizeof(g_network_identity));
+}
diff --git a/vmodem/server/server_common_security.c b/vmodem/server/server_common_security.c
new file mode 100644 (file)
index 0000000..917ab5d
--- /dev/null
@@ -0,0 +1,736 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "misc.h"
+#include "state.h"
+#include "server_common_security.h"
+#include "db_security.h"
+#include "db_phonebook.h"
+
+#include "phoneserver.h"
+
+static char g_pin_value[9];
+static char g_puk_value[9];
+static char g_pin2_value[9];
+static char g_puk2_value[9];
+static int g_pin_cnt;
+static int g_pin2_cnt;
+static int g_puk_cnt;
+static int g_puk2_cnt;
+static int g_sim_state;
+static int g_facility_pin;
+static int g_facility_fdn;
+static int g_lock_sc2_state;
+
+//static int g_sim_sec_general_response_error = 0x8000;
+
+int server_simdata_init()
+{
+       int ret_info =  0;
+       int ret_data =  0;
+       int i;
+
+       SIM_DEBUG("\n");
+
+       /* SIM SECURITY DATA    */
+       ret_info        =       db_sim_info_create();
+       ret_data        =       db_sim_data_create();
+
+       // return value '1' means that sim db already exists. so, we don`t need to put new record.
+       if(ret_info != 1)
+       {
+               for(i=0;i<7;i++)
+                       //090602
+                       db_sim_info_add(i,NULL);
+       }
+       if(ret_data != 1)
+       {
+               for(i=0;i<7;i++)
+                       //090602
+                       db_sim_data_add(i,NULL);
+       }
+
+//     db_sim_info_restore(VGSM_SIMTypeLoad);
+//     db_sim_data_restore(VGSM_SIMTypeLoad);
+
+       return 1;
+}
+
+//init
+int server_sim_db_init()
+{
+       int ret =       0;
+
+       SIM_DEBUG("\n");
+
+       /* SIM SECURITY DATA    */
+       ret     =       db_sim_sec_create();
+
+       // return value '1' means that sim db already exists. so, we don`t need to put new record.
+       if(ret != 1)
+       {
+               db_sim_sec_add();
+       }
+
+       db_sim_sec_restore(VGSM_SIMTypeLoad);
+
+       /* SIM PHONEBOOK DATA   */
+       db_sim_pb_create();
+
+       return 1;
+}
+
+
+//080226 -for mem free in mem alloc func. void -> int.
+int server_sec_set_sec_db_info(SimSecurity *sim_sec,int  ncol)
+{
+       SIM_DEBUG("\n");
+//init
+       memset(g_pin_value,0,9);
+       memset(g_puk_value,0,9);
+       memset(g_pin2_value,0,9);
+       memset(g_puk2_value,0,9);
+
+       g_pin_cnt               =       0;
+       g_pin2_cnt              =       0;
+       g_puk_cnt               =       0;
+       g_puk2_cnt              =       0;
+       g_sim_state             =       0;
+       g_facility_pin  =       0;
+       g_facility_fdn  =       0;
+       g_lock_sc2_state        =       0;
+
+//load
+       memcpy(g_pin_value,sim_sec->pin_value, strlen(sim_sec->pin_value));
+       memcpy(g_puk_value,sim_sec->puk_value, strlen(sim_sec->puk_value));
+       memcpy(g_pin2_value,sim_sec->pin2_value,strlen(sim_sec->puk_value));
+       memcpy(g_puk2_value,sim_sec->puk2_value, strlen(sim_sec->puk2_value));
+
+       g_pin_cnt               =sim_sec->pin_cnt;
+       g_pin2_cnt              =sim_sec->pin2_cnt;
+       g_puk_cnt               =sim_sec->puk_cnt;
+       g_puk2_cnt              =sim_sec->puk2_cnt;
+       g_sim_state             =_trans_db_sim_state_type(sim_sec->sim_state);
+       g_facility_pin  =sim_sec->facility_pin;
+       g_facility_fdn  =sim_sec->facility_fdn;
+       g_lock_sc2_state        = _trans_db_sim_state_type(sim_sec->lock_sc2_state);
+
+
+       if(sim_sec)
+               free(sim_sec);
+
+       return 1;
+
+}
+
+
+int _trans_db_sim_state_type(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case SIM_STATE_READY:
+                       return GSM_SIM_READY;
+               case SIM_STATE_PIN_REQ:
+                       return GSM_SIM_PIN_REQ_STATE ;
+               case SIM_STATE_PUK_REQ:
+                       return GSM_SIM_PUK_REQ;
+               case SIM_STATE_PIN2_REQ:
+                       return GSM_SIM_PIN2_REQ;
+               case SIM_STATE_PUK2_REQ:
+                       return GSM_SIM_PUK2_REQ;
+               case SIM_STATE_FRIZEN:
+                       return GSM_SIM_FRIZEN;
+               case SIM_STATE_NO_SIM:
+                       return GSM_SIM_NO_SIM;
+               case SIM_STATE_FDN_STATE:
+                       return GSM_SIM_FDN_STATE;
+               case SIM_STATE_PIN2_OK:
+                       return GSM_SIM_PIN2_OK;
+
+               case GSM_SIM_READY:
+                       return SIM_STATE_READY;
+               case GSM_SIM_PIN_REQ_STATE:
+                       return SIM_STATE_PIN_REQ ;
+               case GSM_SIM_PUK_REQ:
+                       return SIM_STATE_PUK_REQ;
+               case GSM_SIM_PIN2_REQ:
+                       return SIM_STATE_PIN2_REQ;
+               case GSM_SIM_PUK2_REQ:
+                       return SIM_STATE_PUK2_REQ;
+               case GSM_SIM_FRIZEN:
+                       return SIM_STATE_FRIZEN;
+               case GSM_SIM_NO_SIM:
+                       return SIM_STATE_NO_SIM;
+               case GSM_SIM_FDN_STATE:
+                       return SIM_STATE_FDN_STATE;
+               case GSM_SIM_PIN2_OK:
+                       return SIM_STATE_PIN2_OK;
+
+               default:
+               break;
+       }
+       return 1;
+}
+
+
+/*
+       flag value ->
+       GSM_SEC_LOCK_MODE_UNLOCK : 0x00 : Disable
+       GSM_SEC_LOCK_MODE_LOCK  : 0x01 : Enable
+*/
+void server_sec_set_facility(int type,int flag)
+{
+       SIM_DEBUG("\n");
+
+       if(GSM_SIM_FACILITY_PIN == type )
+       {
+               g_facility_pin = flag;
+               db_sim_sec_edit(DB_F_PIN,NULL,g_facility_pin);
+       }
+
+       if(GSM_SIM_FACILITY_FDN == type )
+       {
+               g_facility_fdn = flag;
+               db_sim_sec_edit(DB_F_FDN,NULL,g_facility_fdn);
+       }
+}
+
+int server_sec_get_facility(int type)
+{
+       SIM_DEBUG("\n");
+
+       if(GSM_SIM_FACILITY_PIN == type )
+               return g_facility_pin;
+       if(GSM_SIM_FACILITY_FDN == type )
+               return g_facility_fdn;
+
+       return 1;
+}
+
+
+/*
+       do not use now.
+*/
+char * server_sec_get_password(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+                       SIM_DEBUG("g_pin_value = [%s]  \n",g_pin_value);
+                       return  g_pin_value;
+
+               case GSM_SIM_PIN2_REQ:
+                       return  g_pin2_value;
+
+               case GSM_SIM_PUK_REQ:
+                       return  g_puk_value;
+
+               case GSM_SIM_PUK2_REQ:
+                       return g_puk2_value;
+
+               default:
+                       break;
+       }
+
+       return 0;
+}
+
+
+// this func change sim_db - pin1 or pin2 password col.
+int server_sec_change_password(char *password,int type,int length)
+{
+       int ret =       0;
+
+       SIM_DEBUG("\n");
+
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       packet.group    =       GSM_SIM;
+       packet.action   =       GSM_SIM_CHANGE_PASS_SET;
+       packet.length   =       0;
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       memset(g_pin_value,0,8);
+                       memcpy(g_pin_value,password,length);
+
+                       ret     =       db_sim_sec_edit(DB_PIN ,g_pin_value,0);
+
+                       if(ret == SIM_SUCCESS)
+                       {
+                               SIM_DEBUG("change sim_db pin1 password success\n");
+                               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+                       }
+                       else
+                       {
+                               SIM_DEBUG("FAIL to updata information at DB\n");
+                               return 0;
+                       }
+
+                       return 1;
+               }
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       memset(g_pin2_value,0,8);
+                       memcpy(g_pin2_value,password,length);
+
+                       ret     =       db_sim_sec_edit(DB_PIN2 ,g_pin2_value,0);
+
+                       if(ret == SIM_SUCCESS)
+                       {
+                               SIM_DEBUG("change sim_db pin2 password success\n");
+                               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+                       }
+                       else
+                       {
+                               SIM_DEBUG("FAIL to updata information at DB\n");
+                               return 0;
+                       }
+
+                       return 1;
+               }
+
+
+               case GSM_SIM_PUKSET_REQ:
+               {
+                       memset(g_puk_value,0,8);
+                       memcpy(g_puk_value,password,length);
+
+                       ret     =       db_sim_sec_edit(DB_PUK ,g_puk_value,0);
+
+                       if(ret == SIM_SUCCESS)
+                       {
+                               SIM_DEBUG("change sim_db pin1 password success\n");
+                               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+                       }
+                       else
+                       {
+                               SIM_DEBUG("FAIL to updata information at DB\n");
+                               return 0;
+                       }
+
+
+                       return 1;
+               }
+
+               case GSM_SIM_PUK2SET_REQ:
+               {
+                       memset(g_puk2_value,0,8);
+                       memcpy(g_puk2_value,password,length);
+
+                       ret     =       db_sim_sec_edit(DB_PUK2 ,g_puk2_value,0);
+
+                       if(ret == SIM_SUCCESS)
+                       {
+                               SIM_DEBUG("change sim_db pin1 password success\n");
+                               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+                       }
+                       else
+                       {
+                               SIM_DEBUG("FAIL to updata information at DB\n");
+                               return 0;
+                       }
+
+
+                       return 1;
+               }
+
+               default:
+                       SIM_DEBUG("ERROR-Not handled type=[%x]",type);
+                       break;
+       }
+
+       return 0;
+}
+
+
+int server_sec_verify_password(char *password,int type,int length)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       length = strlen(g_pin_value);
+
+                       SIM_DEBUG("g_pin_value =[%s]\n",g_pin_value);
+                        SIM_DEBUG("input password value=[%s]\n",password);
+
+                       if(!memcmp(g_pin_value,password,length))  /* correct case */
+                       {
+                                g_pin_cnt      =       3;
+                                db_sim_sec_edit(DB_PIN_CNT,NULL,g_pin_cnt);
+                                return SIM_SUCCESS;
+                       }
+                       else
+                       {
+                               return SIM_FAIL;
+                       }
+               }
+                       
+               case GSM_SIM_PIN2_REQ:
+               {
+                       length = strlen(g_pin2_value);
+
+                       SIM_DEBUG("g_pin2_value =[%s]\n",g_pin2_value);
+                       SIM_DEBUG("input password value=[%s]\n",password);
+
+                       if(!memcmp(g_pin2_value,password,length))
+                       {
+                               g_pin2_cnt      =       3;
+                               db_sim_sec_edit(DB_PIN2_CNT,NULL,g_pin2_cnt);
+                               return SIM_SUCCESS;
+                       }
+                       else
+                       {
+                               return SIM_FAIL;
+                       }
+               }
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       length = strlen(g_puk_value);
+
+                       SIM_DEBUG("g_puk_value=[%s]\n",g_puk_value);
+                       SIM_DEBUG("input password=[%s]\n",password);
+
+                       if(!memcmp(g_puk_value,password,length))
+                       {
+                                g_pin_cnt      =       3;
+                                g_puk_cnt      =       10;
+
+                               db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+                               db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+
+                               return SIM_SUCCESS;
+                       }
+                       else
+                       {
+                               return SIM_FAIL;
+                       }
+               }
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       length = strlen(g_puk2_value);
+
+                       if(!memcmp(g_puk2_value,password,length))
+                       {
+                               g_pin2_cnt      =       3;
+                               g_puk2_cnt      =       10;
+
+                               db_sim_sec_edit(DB_PIN2_CNT,NULL,g_pin2_cnt);
+                               db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+
+                               return SIM_SUCCESS;
+                       }
+                       else
+                       {
+                               return SIM_FAIL;
+                       }
+               }
+
+               default:
+                       break;
+
+       }
+       return SIM_FAIL;
+}
+
+
+int server_sec_status_mgr(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       g_pin_cnt--;
+                       db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+
+                       if(g_pin_cnt == 0 )
+                       {
+                               server_sec_set_sec_status(GSM_SIM_PUK_REQ);
+                       }
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       g_pin2_cnt--;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+
+                       if(g_pin2_cnt == 0 )
+                       {
+                               server_sec_set_sec2_status(GSM_SIM_PUK2_REQ);
+                       }
+               }
+               break;
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       g_puk_cnt--;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+
+                       if(g_puk_cnt == 0 )
+                       {
+                               server_sec_set_sec_status(GSM_SIM_FRIZEN);
+                       }
+               }
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       g_puk2_cnt--;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+
+                       if(g_puk2_cnt == 0 )
+                       {
+                               server_sec_set_sec_status(GSM_SIM_FRIZEN);
+                       }
+               }
+               break;
+
+               default:
+                       SIM_DEBUG("No Matched lock type=[%x]\n",type);
+                       break;
+
+       }
+
+       return 1;
+}
+
+
+int server_sec_set_sec_status(int status)
+{
+       int ret =       0;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       packet.group    =       GSM_SIM;
+       packet.action   =       GSM_SIM_STATUS_SET;
+       packet.length   =       0;
+       SIM_DEBUG("\n");
+
+       SIM_DEBUG("status=[%x]\n",status);
+
+       g_sim_state = status;
+
+       status=_trans_db_sim_state_type(g_sim_state);
+
+       SIM_DEBUG("after trans status is %x\n",status);
+
+       ret     =       db_sim_sec_edit(DB_SIM_STATE, NULL,status);
+
+       if(ret == SIM_SUCCESS)
+       {
+               SIM_DEBUG("change sim_db pin1 status success\n");
+               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+       }
+
+       return g_sim_state;
+}
+
+
+int server_sec_get_sec_status()
+{
+       SIM_DEBUG("\n");
+
+       return g_sim_state ;
+}
+
+
+int server_sec_set_sec2_status(int status)
+{
+       int ret =       0;
+
+       SIM_DEBUG("\n");
+
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       packet.group    =       GSM_SIM;
+       packet.action   =       GSM_SIM_STATUS_SET;
+       packet.length   =       0;
+
+       SIM_DEBUG("status=[%x]\n",status);
+
+       g_lock_sc2_state = status;
+
+       status=_trans_db_sim_state_type(g_lock_sc2_state);
+
+       ret     =       db_sim_sec_edit(DB_LOCK_SC2_STATE, NULL,status);
+
+       if(ret == SIM_SUCCESS)
+       {
+               SIM_DEBUG("change sim_db pin2 status success\n");
+               FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );
+       }
+
+       return g_lock_sc2_state;
+}
+
+
+int  server_sec_get_sec2_status()
+{
+       SIM_DEBUG("\n");
+
+       return g_lock_sc2_state ;
+}
+
+
+void server_sec_reset_remain_cnt(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                        g_pin_cnt = 3;
+                        db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       g_pin2_cnt = 3;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+               }
+               break;
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       g_puk_cnt = 10;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               }
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       g_puk2_cnt = 10;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               }
+               break;
+
+               case GSM_SIM_READY:
+               {
+                       g_pin_cnt = 3;
+                       g_puk_cnt = 10;
+                       db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_OK:
+               {
+                       g_pin2_cnt = 3;
+                       g_puk2_cnt = 10;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               }
+               break;
+
+               default:
+                       SIM_DEBUG("Unhandled type=[%x]\n", type);
+                       break;
+
+       }
+
+}
+
+
+void server_sec_set_cnt_zero(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                        g_pin_cnt = 0;
+                        db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+                       g_pin2_cnt = 0;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+               break;
+
+               case GSM_SIM_PUK_REQ:
+                       g_puk_cnt = 0;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+                       g_puk2_cnt = 0;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               break;
+
+               default:
+                       SIM_DEBUG("Unhandled type=[%x]\n", type);
+                       break;
+       }
+}
+
+
+int server_sec_get_remain_cnt(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+                       return   g_pin_cnt;
+               case GSM_SIM_PIN2_REQ:
+                       return   g_pin2_cnt;
+               case GSM_SIM_PUK_REQ:
+                       return   g_puk_cnt;
+               case GSM_SIM_PUK2_REQ:
+                       return   g_puk2_cnt;
+               default:
+                       SIM_DEBUG("Unhandled type=[%x]\n", type);
+                       break;
+       }
+       return 0;
+}
+
diff --git a/vmodem/server/server_common_ss.c b/vmodem/server/server_common_ss.c
new file mode 100644 (file)
index 0000000..de3ddf7
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "vgsm_ss.h"
+#include "db_ss.h"
+#include "oem_tx_ss.h"
+#include "misc.h"
+
+#include "phoneserver.h"
+#include "vgsm_phone.h"
+#include "vgsm_debug.h"
+#include "server_common_ss.h"
+#include "at_func.h"
+
+_AOC_t  g_aoc_data ;
+_USSD_data_t   g_ussd_data;
+int iset=0;
+
+static call_waiting_entry_t * setinitDB(call_waiting_entry_t *entry, int class, int mode, int count)
+{
+       entry->tel_class = class;
+       entry->ss_mode = mode;
+       entry->count = count;
+       strcpy(entry->number, SUBSCRIBER_NUM);
+       vgsm_ss_database_add(SS_CMD_CW, entry);
+       return entry;
+}
+
+int init_ss_info_re(void)
+{
+       call_waiting_entry_t * entry = malloc(sizeof(call_waiting_entry_t));
+       memset(entry, 0, sizeof(call_waiting_entry_t));
+
+
+       VGSM_DEBUG("\n");
+
+       LXT_MESSAGE cw_packet, cf_packet, cb_packet, cb_pwd_packet;
+       TAPIMessageInit(&cw_packet);
+       TAPIMessageInit(&cf_packet);
+       TAPIMessageInit(&cb_packet);
+       TAPIMessageInit(&cb_pwd_packet);
+
+       /* CW DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CW);
+
+       call_waiting_entry_t * cw_entry = get_call_waiting_entry();
+       cw_packet.data = cw_entry;
+       cw_packet.group  = GSM_SUPS;
+       cw_packet.action = GSM_SUPS_SET_CW_REQ;
+       cw_packet.length = (sizeof(call_waiting_entry_t) * cw_entry[0].count);
+       if(cw_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cw_packet);  // &ServerHandle->server_cast
+
+       /* CF DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CF);
+
+       call_forwarding_entry_t * cf_entry = get_call_forwarding_entry();
+       cf_packet.data = cf_entry;
+       cf_packet.group  = GSM_SUPS;
+       cf_packet.action = GSM_SUPS_SET_CCFC_REQ;
+       cf_packet.length = (sizeof(call_forwarding_entry_t) * cf_entry[0].count);
+
+       if(cf_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cf_packet);  // &ServerHandle->server_cast
+
+       /* CB DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CB);
+
+       call_barring_entry_t * cb_entry  = get_call_barring_entry();
+       cb_packet.data = cb_entry;
+       cb_packet.group  = GSM_SUPS;
+       cb_packet.action = GSM_SUPS_SET_CB_REQ;
+       cb_packet.length = (sizeof(call_barring_entry_t) * cb_entry[0].count);
+
+       if(cb_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cb_packet);  // &ServerHandle->server_cast
+
+       /* CB PASSWORD NOTIFY */
+       char* cb_pwd = get_callbarring_pwd();
+       cb_pwd_packet.data = cb_pwd;
+       cb_pwd_packet.group  = GSM_SUPS;
+       cb_pwd_packet.action = GSM_SUPS_PWDSET_CB_REQ;
+       cb_pwd_packet.length = sizeof(cb_pwd);
+       VGSM_DEBUG("callbarring password : %c%c%c%c  \n", cb_pwd[0], cb_pwd[1], cb_pwd[2], cb_pwd[3]);
+
+       if(cb_pwd_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cb_pwd_packet);      // &ServerHandle->server_cast
+
+       return 1;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int init_ss_info(void)
+{
+       call_waiting_entry_t * entry = (call_waiting_entry_t *)malloc(sizeof(call_waiting_entry_t));
+       memset(entry, 0, sizeof(call_waiting_entry_t));
+
+
+       VGSM_DEBUG("\n");
+
+       LXT_MESSAGE cw_packet, cf_packet, cb_packet, cb_pwd_packet;
+       TAPIMessageInit(&cw_packet);
+       TAPIMessageInit(&cf_packet);
+       TAPIMessageInit(&cb_packet);
+       TAPIMessageInit(&cb_pwd_packet);
+
+#if    1               // 090224
+//     vgsm_ss_sqlite_cw_check_exist(17);
+//     if(cw_count !=0)                                                        // 1 : Registration, 2 : Deregistration, 3 : Activation, 4 : Deactivation
+               setinitDB(entry,1,4,0);                         // 1 : voice
+//     vgsm_ss_sqlite_cw_check_exist(19);
+//     if(cw_count !=0)
+               setinitDB(entry,4,4,1);                         // 4 : fax
+//     vgsm_ss_sqlite_cw_check_exist(22);
+//     if(cw_count !=0)
+               setinitDB(entry,8,4,2);                         // 8 : SMS
+               setinitDB(entry,32,4,3);                        // 32 : async
+#endif
+
+       /* CW DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CW);
+
+       call_waiting_entry_t * cw_entry = get_call_waiting_entry();
+       cw_packet.data = cw_entry;
+       cw_packet.group  = GSM_SUPS;
+       cw_packet.action = GSM_SUPS_SET_CW_REQ;
+       cw_packet.length = (sizeof(call_waiting_entry_t) * cw_entry[0].count);
+       if(cw_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cw_packet);  // &ServerHandle->server_cast
+
+       /* CF DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CF);
+
+       call_forwarding_entry_t * cf_entry = get_call_forwarding_entry();
+       cf_packet.data = cf_entry;
+       cf_packet.group  = GSM_SUPS;
+       cf_packet.action = GSM_SUPS_SET_CCFC_REQ;
+       cf_packet.length = (sizeof(call_forwarding_entry_t) * cf_entry[0].count);
+
+       if(cf_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cf_packet);  // &ServerHandle->server_cast
+
+       /* CB DB RESTORE */
+       vgsm_ss_database_restore(SS_CMD_CB);
+
+       call_barring_entry_t * cb_entry  = get_call_barring_entry();
+       cb_packet.data = cb_entry;
+       cb_packet.group  = GSM_SUPS;
+       cb_packet.action = GSM_SUPS_SET_CB_REQ;
+       cb_packet.length = (sizeof(call_barring_entry_t) * cb_entry[0].count);
+
+       if(cb_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cb_packet);  // &ServerHandle->server_cast
+
+       /* CB PASSWORD NOTIFY */
+       char* cb_pwd = get_callbarring_pwd();
+       cb_pwd_packet.data = cb_pwd;
+       cb_pwd_packet.group  = GSM_SUPS;
+       cb_pwd_packet.action = GSM_SUPS_PWDSET_CB_REQ;
+       cb_pwd_packet.length = sizeof(cb_pwd);
+       VGSM_DEBUG("callbarring password : %c%c%c%c  \n", cb_pwd[0], cb_pwd[1], cb_pwd[2], cb_pwd[3]);
+
+       if(cb_pwd_packet.length)
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &cb_pwd_packet);      // &ServerHandle->server_cast
+
+       return 1;
+}
+
+void set_aoc_data (char *at)
+{
+       VGSM_DEBUG("\n");
+       int len=0;
+
+       len = sizeof(g_aoc_data);
+
+       memcpy ( &g_aoc_data, at, len-3); // currency is not set
+       // 090414
+       oem_tx_ss_aoc_noti(at, len-3);  // currency is not set
+}
+
+void get_aoc_data ( _AOC_t * data)
+{
+       VGSM_DEBUG("\n");
+       memcpy ( data, &g_aoc_data, sizeof(g_aoc_data));
+
+}
+
+void set_ussd_data (char *at)
+{
+       VGSM_DEBUG("\n");
+       int len=0;
+
+       len = sizeof(g_ussd_data);
+       iset = 1;
+
+       memcpy ( &g_ussd_data, at, len-3); // currency is not set
+}
+
+void get_ussd_data ( _USSD_data_t * data)
+{
+       VGSM_DEBUG("\n");
+       if(iset != 0)
+       {
+               memcpy ( data, &g_ussd_data, sizeof(g_ussd_data));
+       }
+       else
+       {
+               strcpy(g_ussd_data.time, "Not set yet!!");
+               strcpy(g_ussd_data.weather, "Not set yet!!");
+               memcpy ( data, &g_ussd_data, sizeof(g_ussd_data));
+       }
+}
diff --git a/vmodem/server/server_dpram.c b/vmodem/server/server_dpram.c
new file mode 100644 (file)
index 0000000..f51279c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <gsmstate.h>
+
+#include "phoneserver.h"
+#include "eloop.h"
+#include "logmsg.h"
+#include "at/at_func.h"
+
+extern GSM_StateMachine GlobalS;
+
+static int dpram_callback(PhoneServer * ps, int fd, EloopCondition cond, void * data)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       GSM_ATDispatchDpramData(&GlobalS);
+    return 1;
+}
+
+FunctionsDpram DpramHandle =
+{
+    dpram_callback
+};
diff --git a/vmodem/server/server_rx_call.c b/vmodem/server/server_rx_call.c
new file mode 100644 (file)
index 0000000..1dff447
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*     server_rx_call.c        */
+
+#include <assert.h>
+
+#include "server_tx_call.h"
+#include "server_rx_call.h"
+#include "linuxtapi.h"
+#include "phoneserver.h"
+#include "vgsm_call.h"
+#include "state.h"
+#include "misc.h"
+#include "oem_tx_call.h"
+#include "server_common_call.h"
+#include "db_ss.h"
+#include "logmsg.h"
+#include "at_recv.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+#define MAX_GSM_DIALED_DIGITS_NUM           82
+// caution: MAX_GSM_DIALED_DIGITS_NUMBER and MAX_GSM_DIALED_DIGITS_NUM are confusingly similar
+
+int server_rx_call_list_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       server_tx_call_list_resp();
+       return 1;
+}
+
+int server_rx_call_answer_exec(void)
+{
+    STATE next;
+
+    TRACE(MSGL_VGSM_INFO, "\n");
+
+    unsigned char data[1];
+    LXT_MESSAGE packet;
+    TAPIMessageInit(&packet);
+    int call_gen_resp_err=-1;
+
+    /*   check general response error & call status error    */
+    call_gen_resp_err = check_call_error();
+
+    data[0] = 0x02;            //The object is simulator,   0x01 : Outgoing Call, 0x02 : Answer Call, 0x03 : Release Call
+
+    packet.data = data;
+    packet.length = sizeof data;
+    packet.group  = GSM_CALL;
+    packet.action = GSM_CALL_STATE;
+
+    FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+    set_current_state( STATE_CALL_WAITING_INCOMING, GSM_CALL_CMD, GSM_CALL_ANSWER);
+
+    if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+        set_state_machine( next );
+        send_msg();
+    }
+
+    return 1;
+}
+
+int server_rx_call_originate_exec(void *ptr_data, int data_len )
+{
+       const unsigned char *p = ptr_data;
+       unsigned short call_type;
+       unsigned char clir_status;
+       unsigned char num_len;
+       unsigned char num_type;
+       const unsigned char *number;
+       unsigned char call_id;
+       STATE next;
+
+       number = malloc(MAX_GSM_DIALED_DIGITS_NUM);
+       TRACE(MSGL_VGSM_INFO, "\n");
+       char* call_data = strchr((char*)p, 'D');
+        char token[] = ";";
+        char* ret = NULL;
+
+        ret = strtok(call_data+1, token);
+        if(ret)
+               strcpy((char*)number, ret);
+
+       // DOCUMENTATION ERROR
+       //
+       // Section 1.1.1 Call Outgoing Message (SUB_CMD = 0x01) claims:
+       //
+       // NUMBER[ ]     variable     Destination number in ASCII.
+       //                             : Maximum length is 82 bytes
+       //
+       // but the NUMBER is not variable, it is fixed at 82 bytes
+
+       call_type = GSM_CALL_TYPE_VOICE;
+
+       assert(valid_call_type(call_type));
+
+       clir_status = GSM_CALL_STATUS_DIALING;
+       num_len = strlen((char*)number);
+       num_type = GSM_NUM_TYPE_INTERNATIONAL;
+
+       assert(num_len <= MAX_GSM_DIALED_DIGITS_NUM);
+
+
+       if(get_outgoing_voice_call_barring_state())
+       {
+               TRACE(MSGL_VGSM_INFO, "call is barred!\n");
+
+               oem_tx_call_gen_resp(AT_CME_ERR_OPER_NOT_ALLOWED);
+       
+               return 1;
+       }
+       oem_tx_call_gen_resp(AT_GEN_ERR_NO_ERROR);
+       
+       call_id = make_call_id();
+       set_call_type( call_type );
+       
+       unsigned char data[MAX_GSM_DIALED_DIGITS_NUMBER+4];
+
+       if (num_len > MAX_GSM_DIALED_DIGITS_NUMBER)
+               num_len = MAX_GSM_DIALED_DIGITS_NUMBER;
+
+       data[0] = call_id;
+       data[1] = call_type;
+
+       if(clir_status == GSM_CALL_CLIR_STATUS_INVOCATION)
+               num_len = 0;
+
+       data[2] = num_len;
+       data[3] = clir_status;
+
+       memset(&data[4], 0, MAX_GSM_DIALED_DIGITS_NUMBER);
+       memcpy(&data[4], number, num_len);
+
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+       packet.data = data;
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_MAKE_REQ;
+       packet.length = num_len + 4;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       set_call_list( GSM_CALL_DIR_MO, GSM_CALL_STATUS_DIALING, call_type, (char*)number, num_len );
+
+       callback_callist();
+
+       data[0] = 0x01; //The object is simulator,   0x01 : Outgoing Call, 0x02 : Answer Call, 0x03 : Release Call
+
+       packet.data = data;
+       packet.length = 1;
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_STATE;
+       packet.length = 1;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       set_current_state( STATE_STANDBY, GSM_CALL_CMD, GSM_CALL_OUTGOING);
+       
+       if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+               set_state_machine( next );
+               send_msg();
+       }
+       return 1;
+}
+
+int server_rx_call_release_exec(void) // ÀÌ°ÍÀº all call releae ÀΠ°æ¿ìÀÌ´Ù. Çϳª release ´Â SS MANAGE CALL msg·Î ¼ö½ÅµÈ´Ù.
+{
+       int call_gen_resp_err;
+
+       /* check general response error & call status error */
+       call_gen_resp_err = check_call_error();
+       server_tx_call_all_release();
+       return 1;
+}
+
+int server_rx_call_burst_dtmf_exec(void)
+{
+       int success = 1;
+
+       server_tx_call_burst_dtmf_noti(success);
+       return 1;
+}
+
+int server_rx_call_line_id_set(void *ptr_data, int data_len )
+{
+       const unsigned char *p = ptr_data;
+       unsigned char line_id;
+       int n = 0;
+       
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       line_id = p[n++];
+
+       if (n != data_len)
+               TRACE(MSGL_WARN, "data_len = %d, expected = %d\n", data_len, n);
+
+       set_call_line_id(line_id);
+       
+       return 1;
+}
+
+
+int server_rx_call_line_id_get(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       server_tx_call_line_id_resp();
+       return 1;
+}
+
+/*
+*      0_SEND=0x01,
+*      Releases all held calls or sets User Determined User Busy (UDUB) for a waiting call
+*/
+int server_rx_call_release_all_held(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       release_all_held_call();
+       server_tx_call_list_noti();
+       return 1;
+}
+
+
+int server_rx_call_release_all_active(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       release_all_active_call();
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+int server_rx_call_release_single(int call_id)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       drop_call(call_id);
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+int server_rx_call_swap(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       set_rx_ss_state();
+       swap_call();
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+int server_rx_call_split_conf(int call_id)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       split_call(call_id);
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+int server_rx_call_join_conf(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       join_call();
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+
+
diff --git a/vmodem/server/server_rx_data.c b/vmodem/server/server_rx_data.c
new file mode 100644 (file)
index 0000000..cf8200a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "server_tx_data.h"
+#include "server_rx_data.h"
+
+
+int server_rx_data_GetDataCallStatus(void *ptr_data, int data_len )
+{
+       return server_tx_data_DataCallStatus(NULL);
+}
diff --git a/vmodem/server/server_rx_display.c b/vmodem/server/server_rx_display.c
new file mode 100644 (file)
index 0000000..ee9a65f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*     server_rx_network.c     */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "oem_tx_display.h"
+#include "oem_rx_display.h"
+#include "server_rx_display.h"
+#include "server_tx_display.h"
+#include "server_common_call.h"
+#include "vgsm_display.h"
+#include "vgsm_debug.h"
+
+int server_rx_display_icon_info_get(void)
+{
+       return server_tx_display_icon_info_resp();
+}
+
diff --git a/vmodem/server/server_rx_gprs.c b/vmodem/server/server_rx_gprs.c
new file mode 100644 (file)
index 0000000..347af6f
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "server_tx_data.h"
+#include "vgsm_phone.h"
+#include "linuxtapi.h"
+#include "state.h"
+#include "phoneserver.h"
+#include "server_tx_gprs.h"
+#include "server_rx_gprs.h"
+#include "vgsm_gprs.h"
+#include "misc.h"
+#include "logmsg.h"
+#include "at_func.h"
+
+GSM_SetPDPContext g_pdpcontext;
+
+int server_rx_gprs_SetPDPContext(void *ptr_data, int data_len )
+{
+       TRACE(MSGL_VGSM_INFO, "data_len(%d) >= 128 \n", data_len);
+
+       if (ptr_data && (data_len > 0)) {
+               char *ptr = (char *)ptr_data;
+               char cdata[SEND_BUF_SIZE];
+               memset(cdata, '\0', sizeof(cdata));
+               strcpy(cdata, ptr);
+
+               memset(&g_pdpcontext, 0, sizeof(g_pdpcontext));
+
+               char* data = strchr(cdata, '=');
+               char* ret = NULL;
+               
+               ret = strtok(data+1, TOKEN);
+               if(ret)
+                       g_pdpcontext.cid = atoi(ret);
+
+               g_pdpcontext.mode = GSM_GPRS_DEFINE_PDP_MODE_ADD;
+               
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+               {
+                       if(!strcmp(ret, IP))
+                               g_pdpcontext.pdp_type = GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IP;
+                       else if(!strcmp(ret, PPP))
+                               g_pdpcontext.pdp_type = GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_PPP;
+                       else if(!strcmp(ret, IPV6))
+                               g_pdpcontext.pdp_type = GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IPV6;
+                       else
+                               g_pdpcontext.pdp_type = GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_UNKNOWN;
+               }
+
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+                       memcpy(g_pdpcontext.apn, ret, strlen(ret));
+
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+                       memcpy(g_pdpcontext.pdp_addr, ret, strlen(ret));
+               else
+                       strcpy(g_pdpcontext.pdp_addr, EMUL_IP);
+
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+                       g_pdpcontext.d_comp = atoi(ret);
+
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+                       g_pdpcontext.h_comp = atoi(ret);
+
+               log_msg(MSGL_VGSM_INFO,"MODE[%x] CID[%x] PDP_TYPE[%x] APN[%s] \n", 
+                               g_pdpcontext.mode, g_pdpcontext.cid, g_pdpcontext.pdp_type, g_pdpcontext.apn);
+               log_msg(MSGL_VGSM_INFO,"PDP_ADDRESS[%s] D_COMP[%x] H_COMP[%x] \n",
+                               g_pdpcontext.pdp_addr, g_pdpcontext.d_comp, g_pdpcontext.h_comp);
+       }
+
+       return 1;
+}
+
+int server_rx_gprs_SetPSActDeact(void *ptr_data, int data_len )
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       if (ptr_data && (data_len > 0)) {
+               char *data = 0, *ptr = (char *)ptr_data;
+               char cdata[SEND_BUF_SIZE];
+               memset(cdata, '\0', sizeof(cdata));
+                strcpy(cdata, ptr);
+               
+               char* tdata = strchr(cdata, '=');
+                char* ret = NULL;
+
+               LXT_MESSAGE packet;
+
+               TAPIMessageInit(&packet);
+
+               data = malloc(sizeof(char)*1);
+               ret = strtok(tdata+1, TOKEN);
+               if(ret)
+                        data[0] = atoi(ret);  /* 0: stop, 1: start */
+                else 
+                        return 0;
+
+               ret = strtok(NULL, TOKEN);
+               if(ret)
+                       log_msg(MSGL_VGSM_INFO,"STATE[%x, 0:stop, 1:start] CID[%d] \n", data[0], atoi(ret));
+
+               packet.data = data;
+               packet.length = 1;
+
+               packet.group  = GSM_DATA;
+               packet.action = GSM_DATA_STATE;
+               packet.length = 1;
+
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+               free(data);
+
+               return 1;
+       }
+
+       return 0;
+}
+
diff --git a/vmodem/server/server_rx_misc.c b/vmodem/server/server_rx_misc.c
new file mode 100644 (file)
index 0000000..7472307
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <string.h>
+#include <assert.h>
+
+#include "server_rx_misc.h"
+#include "server_common_call.h"
+#include "oem_tx_misc.h"
+#include "at_func.h"
+
+static const char *sw_version = "vmodem sw 0.1";
+static const char *hw_version = "vmodem hw 0.1";
+static const char *rf_cal_date = "2009/09/09";
+static const char *product_code = "Protector";
+static const char *model_id = "i8290";
+
+#define MAX_VERSION_FIELD_LEN 0x20
+
+int server_rx_misc_me_version(unsigned char flags)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       sprintf(sndbuf, "%s%s,%s,%s,%s,%s%s", CGMR, sw_version, hw_version, rf_cal_date, product_code, model_id, CRLF);
+
+/*
+#define ADD_VERSION_STRING(mask, string) \
+       if (mask) { \
+               strcat(sndbuf, string);\
+       }
+
+       ADD_VERSION_STRING(0x01, sw_version)
+       ADD_VERSION_STRING(0x02, hw_version)
+       ADD_VERSION_STRING(0x04, rf_cal_date)
+       ADD_VERSION_STRING(0x08, product_code)
+       ADD_VERSION_STRING(0x10, model_id)
+
+#undef ADD_VERSION_STRING
+
+       // FIXME: add CDMA fields PRL and ERI
+
+*/             
+       return oem_tx_misc_version(sndbuf, strlen(sndbuf));
+}
+
diff --git a/vmodem/server/server_rx_network.c b/vmodem/server/server_rx_network.c
new file mode 100644 (file)
index 0000000..b8268cc
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/* server_rx_network.c */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <unistd.h>
+
+#include "oem_tx_network.h"
+#include "server_common_network.h"
+#include "vgsm_network.h"
+#include "vgsm_debug.h"
+#include "server_tx_network.h"
+#include "at_rx_network.h"
+#include "server_rx_network.h"
+#include "at_func.h"
+#include "at_gen_resp.h"
+
+int server_rx_net_plmn_list_get(void)
+{
+       unsigned char *data = 0;
+       int ret = 0, len = 0;
+       int i = 0, n = 0;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       char tmpbuf[128];
+       char plmn_data[6];
+
+       VGSM_DEBUG("\n");
+
+       gsm_network_plmn_list_t *plmn_list = get_plmn_list();
+
+       VGSM_DEBUG("plmn_list->num_record:[%d]\n", plmn_list->num_record);
+
+       len = 1+(plmn_list->num_record*10);
+       data = malloc(len);
+
+       data[n++] = plmn_list->num_record; /* NUM_RECORD */
+       sprintf(sndbuf, "%s", COPS);
+
+       for (i=0; i<plmn_list->num_record; ++i)
+       {
+               data[n++] = plmn_list->precord[i].status;
+               memcpy(&data[n], plmn_list->precord[i].plmn, 6);
+               plmn_data[0] = plmn_list->precord[i].plmn[0];
+               plmn_data[1] = plmn_list->precord[i].plmn[1];
+               plmn_data[2] = plmn_list->precord[i].plmn[2];
+               plmn_data[3] = plmn_list->precord[i].plmn[3];
+               plmn_data[4] = plmn_list->precord[i].plmn[4];
+               plmn_data[5] = plmn_list->precord[i].plmn[5];
+               
+               n += 6;
+               data[n++] = plmn_list->precord[i].act;
+               data[n++] =0x11; /* LAC  2bytes*/
+               memset(tmpbuf, '\0', sizeof(tmpbuf));
+               VGSM_DEBUG("plmn: %s\n", plmn_data);
+               sprintf(tmpbuf, "(%d,\"%c%c%c%c%c%c\",\"%c%c%c%c%c%c\",\"%c%c%c%c%c%c\")", plmn_list->precord[i].status, 
+                                                               plmn_data[0], plmn_data[1], plmn_data[2], plmn_data[3], plmn_data[4], plmn_data[5],
+                                                               plmn_data[0], plmn_data[1], plmn_data[2], plmn_data[3], plmn_data[4], plmn_data[5],
+                                                               plmn_data[0], plmn_data[1], plmn_data[2], plmn_data[3], plmn_data[4], plmn_data[5]);
+               strcat(sndbuf, tmpbuf);
+               if(i + 1 == plmn_list->num_record)
+                       strcat(sndbuf, CRLF);
+               else
+                       strcat(sndbuf, TOKEN);
+       }
+       //sleep(3);
+       ret = oem_tx_net_plmn_list_resp(sndbuf, strlen(sndbuf));
+
+       if (data)
+               free(data);
+
+       return ret;
+}
+
+int server_rx_net_reg_get(void)
+{
+       unsigned char data[13];
+       int n = 0;
+
+       VGSM_DEBUG("\n");
+
+       gsm_network_reg_t *reg = get_network_registration();
+
+       data[n++] = reg->act; /* ACT */
+       data[n++] = reg->service_domain; /* SERVICE_DOMAIN */
+       data[n++] = reg->reg_status; /* REG_STATUS */
+       data[n++] = reg->edge_support; /* EDGE_SUPPORT */
+       data[n++] = reg->lac[0]; /* LAC */
+       data[n++] = reg->lac[1]; /* LAC */
+       data[n++] = reg->cell_id[0]; /* CELL-ID */
+       data[n++] = reg->cell_id[1]; /* CELL-ID */
+       data[n++] = reg->cell_id[2]; /* CELL-ID */
+       data[n++] = reg->cell_id[3]; /* CELL-ID */
+       // FIXME: where do the other two CELL-ID bytes come from?
+       data[n++] = 0; /* CELL-ID */
+       data[n++] = 0; /* CELL-ID */
+       data[n++] = 0; /* REJ_CAUSE */
+
+       return oem_tx_net_reg_resp(data, n);
+}
+
+#define PLMN_SIZE 6
+/* Update for public open
+   45001# => 11111#
+ */
+static const unsigned char default_plmn[PLMN_SIZE] = { '1','1','1','1','1','#' };
+
+static void find_plmn( unsigned char *plmn, unsigned char *act)
+{
+       gsm_network_plmn_list_t *plmn_list = get_plmn_list();
+       int i;
+
+       for (i = 0; i < plmn_list->num_record; ++i)
+       {
+               if (plmn_list->precord[i].status == GSM_NET_PLMN_STATUS_CURRENT)
+               {
+                       memcpy(plmn, plmn_list->precord[i].plmn, sizeof default_plmn);
+                       *act = plmn_list->precord[i].act;
+                       return;
+               }
+       }
+
+       // set defaults
+       *act = GSM_NET_ACT_UTRAN;
+       memcpy(plmn, default_plmn, sizeof default_plmn);
+}
+
+int server_rx_net_current_plmn_get(void)
+{
+       gsm_network_reg_t *reg = get_network_registration();
+//     unsigned char *plmn, *act;
+       unsigned char data[16];
+       int n = 0;
+       int i =0;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       VGSM_DEBUG("\n");
+
+       data[n++] = GSM_NET_SEL_AUTO; // GSM_AUTO. this mode is different from  get_network_sel_mode().
+       data[n++] = reg->reg_status;
+
+#if 1
+       data[n++] = reg->act;
+       for(i=0;i<sizeof(default_plmn);i++)
+       {
+               data[n++] = default_plmn[i];
+       }
+       //LAC
+       data[n++] = reg->lac[0];                        /* LAC */
+       data[n++] = reg->lac[1];                        /* LAC */
+       
+#else
+       act = &data[n++];
+       plmn = &data[n];
+       n += sizeof default_plmn;
+       data[n++] = 0x02; //GSM_FIRST
+
+       assert(n <= sizeof data);
+
+       find_plmn(plmn, act);
+#endif
+       sprintf(sndbuf, "%s%d,%d,%s,%d%s", COPS, data[0], GSM_NET_PLMN_FORMAT_NUMERIC, default_plmn, data[2], CRLF); 
+       return oem_tx_net_current_plmn_resp(sndbuf, strlen(sndbuf));
+}
+
+
+int server_rx_net_plmn_selection_get(void)
+{
+       unsigned char data[1];
+       int n = 0;
+
+       VGSM_DEBUG("\n");
+
+       data[n++] = get_network_sel_mode(); // MODE_SELECT
+
+       return oem_tx_net_plmn_selection_resp(data, n);
+}
+
+
+int server_rx_net_plmn_selection_set(void *ptr_data, int data_len )
+{
+       unsigned char* ptr = (unsigned char *)ptr_data;
+       gsm_net_act_e_type act;
+       unsigned char plmn[7];
+       gsm_net_sel_e_type mode;
+
+       VGSM_DEBUG("\n");
+
+       mode = *ptr++;
+       memcpy( plmn, ptr, 6 );
+       plmn[6] = 0;
+       ptr += 6;
+       act = *ptr;
+
+       VGSM_DEBUG("mode=%d, plmn=%s, act=%d \n ", mode, plmn, act);
+
+       assert(mode <= 4);
+
+       set_plmn_selection(mode, plmn, act);
+
+       return server_tx_net_reg_noti(NULL);
+}
+
+int server_rx_net_band_set(void *ptr_data, int data_len )
+{
+       unsigned char* ptr = ptr_data;
+       gsm_net_band_mode_e_type net_band_mode;
+       int net_band;
+       char data[5];
+       int n = 0;
+
+       net_band_mode = ptr[0];
+       net_band  = (ptr[1] & 0xFF);
+       net_band  = net_band | ((ptr[2] & 0xFF) << 8);
+       net_band  = net_band | ((ptr[3] & 0xFF) << 16);
+       net_band  = net_band | ((ptr[4] & 0xFF) << 24);
+
+       VGSM_DEBUG("net_band_mode=%d net_band=0x%08x \n", net_band_mode, net_band);
+
+       set_network_band_mode( net_band_mode, net_band );
+       at_cast_network_band_set( net_band_mode, net_band );
+       assert(n <= sizeof data);
+
+       return oem_tx_net_gen_phone_resp(data, n);
+}
+
+int server_rx_net_band_get(void)
+{
+       gsm_net_band_mode_e_type net_band_mode ;
+       int net_band ;
+       int n = 0;
+       unsigned char data[5];
+
+       net_band_mode = get_network_band_mode();
+       net_band = get_network_band();
+
+       VGSM_DEBUG("net_band_mod e= %d, band = 0x%08x\n", net_band_mode, net_band);
+
+       data[n++] = net_band_mode;
+       data[n++] =(net_band & 0xFF);
+       data[n++] =( (net_band >> 8 ) & 0xFF);
+       data[n++] =( (net_band >> 16 ) & 0xFF);
+       data[n++] =( (net_band >> 24 ) & 0xFF);
+
+       return oem_tx_net_band_get_resp(data, n);
+}
+
+int server_rx_net_service_domain_get(void)
+{
+       VGSM_DEBUG("\n");
+
+       int ret =0;
+
+       gsm_net_svc_domain_e_type net_svc_domain ;
+
+       int  len = 1;
+       unsigned char data[len];
+
+       memset( data, 0, sizeof(unsigned char)*len );
+
+       net_svc_domain = get_network_service_domain( );
+
+       data[0] = net_svc_domain; // MODE_SELECT
+
+       VGSM_DEBUG("net_svc_domain=%d,   \n ", net_svc_domain );
+
+        //ret = server_tx_net_net_svc_domain_resp(data,len);
+
+       return ret;
+}
+
+int server_rx_net_mode_sel_get(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+int server_rx_net_mode_sel_set(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_net_pref_plmn_get(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_net_pref_plmn_set(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+#if 0
+int server_rx_net_plmn_list(char * api)
+{
+       //unimplemented(api);
+       return 1;
+}
+#endif
diff --git a/vmodem/server/server_rx_phonebook.c b/vmodem/server/server_rx_phonebook.c
new file mode 100644 (file)
index 0000000..4720ad8
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_sim.h"
+#include "vgsm_pb.h"
+#include "db_phonebook.h"
+#include "oem_tx_phonebook.h"
+#include "server_rx_phonebook.h"
+
+#include "server_common_security.h"
+#include "at_recv.h"
+
+int server_rx_sim_pb_get_access_req(void* ptr_data, int data_len)
+{
+       int ret;
+       int data_size ;
+       unsigned char *p;
+       int num_len;
+       int name_len;
+       int add_len;
+       int n = 0;
+       PB pb;
+
+       SIM_DEBUG("\n");
+
+       assert(ptr_data);
+       assert(data_len > 0);
+
+       memset(&pb, 0, sizeof(PB));
+
+       db_sim_pb_get(&pb);
+       db_sim_pb_restore(&pb);
+
+       add_len         = strlen(pb.address);
+       num_len         = strlen(pb.number);
+       name_len        = strlen(pb.name);
+       data_size       = 1+add_len+1+2+1+1+num_len+1+1+name_len;
+
+       TRACE(MSGL_VGSM_INFO, "address = %s\n", pb.address);
+       TRACE(MSGL_VGSM_INFO, "number  = %s\n", pb.number);
+       TRACE(MSGL_VGSM_INFO, "name    = %s\n", pb.name);
+
+       p = malloc(data_size);
+
+       p[n++]  =       0x03;
+
+       memcpy(&p[n], pb.address, add_len);
+       n += add_len;
+
+       p[n++]  =       0x01;
+       p[n++]  =       0;
+       p[n++]  =       0;
+       p[n++]  =       num_len;
+       p[n++]  =       0x00;
+
+       memcpy(&p[n], pb.number, num_len);
+       n += num_len;
+
+       p[n++]  =       name_len;
+       p[n++]  =       0x01;
+
+       memcpy(&p[n], pb.name, name_len);
+       n += name_len;
+
+       ret     = oem_tx_sim_pb_get_access_res(p, n);
+
+       free(p);
+
+       return ret;
+}
+
+
+int server_rx_sim_pb_set_access_req(void* ptr_data, int data_len)
+{
+       PB *pb;
+       unsigned char *p = 0;
+       //unsigned short index_;
+       int num_len,name_len,cnt,add_len;
+
+       SIM_DEBUG("\n");
+
+       if(ptr_data && data_len >0)
+       {
+               p=(unsigned char*)ptr_data;
+               cnt=0;
+
+               switch(p[0])
+               {
+                       case 0x01: //ADD   2G..
+                       {
+                               cnt++;//mode
+                               pb= malloc(sizeof(PB));
+                               memset(pb,0,(sizeof(PB)));
+                               add_len=p[cnt];
+
+                               //memcpy(&index_,&p[cnt] ,strlen());
+                               //cnt+=2; //idex
+                               cnt++; //3 // 3G or 2G
+
+                               pb->db_st_type=0;
+                               //pb->index=index_;
+                               memcpy(pb->address,&p[cnt],add_len);
+                               cnt+=add_len;
+
+                               num_len=p[cnt];
+                               cnt++;//num len
+                               cnt++;//num type
+                               memcpy(pb->number,&p[cnt],num_len);
+                               cnt+=num_len;  //num
+                               name_len=p[cnt];
+                               cnt++;//name len
+                               cnt++;//name enctype
+                               memcpy(pb->name,&p[cnt],name_len);
+
+                               SIM_DEBUG("\n rx_sim_pb_access <%d,%s,%s,%s>\n",pb->db_st_type,pb->name,pb->number,pb->address);
+
+                               db_sim_pb_add(pb);
+                               db_sim_pb_restore(pb);
+
+                               //set_sim_sec_general_response_error(0x8000);
+
+                               oem_tx_sim_pb_set_access_res(0x8000);
+
+                               if(pb) free(pb);
+                       }
+                       break;
+
+                       case 0x02://DELETE
+                       {
+                               pb= malloc(sizeof(PB));
+                               memset(pb,0,(sizeof(PB)));
+
+                               add_len=p[cnt];
+
+                               //memcpy(&index_,&p[1] ,sizeof(unsigned short));
+                               //pb->index=index_;
+
+                               db_sim_pb_remove(pb);
+                               db_sim_pb_restore(pb);
+
+                               //set_sim_sec_general_response_error(0x8000);
+
+                               oem_tx_sim_pb_set_access_res(0x8000);
+
+                               if(pb) free(pb);
+                       }
+                       break;
+
+                       case 0x03://EDIT       NOT support...  EDIT = DELETE + ADD ...
+                               break;
+
+                       default:
+                               break;
+
+               }
+       }
+       return 1;
+}
+
+int server_rx_sim_pb_get_storage_cnt_req(void* ptr_data, int data_len)
+{
+       int setted_st = db_sim_pb_set_mgr(0,0);
+       unsigned short used     = db_sim_pb_cnt_mgr(NULL,setted_st,0);
+       unsigned short total = 255;
+       unsigned char p[5];
+       int n = 0;
+
+       SIM_DEBUG("\n");
+
+       assert(ptr_data);
+       assert(data_len > 0);
+
+       p[n++] = db_sim_pb_set_mgr(0,0);
+       copy_unsigned_short(&p[n], total);
+       n += 2;
+       copy_unsigned_short(&p[n], used);
+       n += 2;
+
+       return oem_tx_sim_pb_get_storage_cnt_res(p, n);
+}
+
+int server_rx_sim_pb_get_entry_info_req(void* ptr_data, int data_len)
+{
+       unsigned short index_min = 0;
+       unsigned short index_max = 255;
+       unsigned short num_max = 255;
+       unsigned short text_max = 255;
+       unsigned char p[8];
+       int n = 0;
+
+       SIM_DEBUG("\n");
+
+       assert(ptr_data);
+       assert(data_len > 0);
+
+       copy_unsigned_short(&p[n], index_min);
+       n += 2;
+       copy_unsigned_short(&p[n], index_max);
+       n += 2;
+       copy_unsigned_short(&p[n], num_max);
+       n += 2;
+       copy_unsigned_short(&p[n], text_max);
+       n += 2;
+
+       return oem_tx_sim_pb_get_entry_info_res(p, n);
+}
+
+int server_rx_sim_pb_get_storage_list_req(void* ptr_data, int data_len)
+{
+       unsigned char p[4];
+       int n = 0;
+
+       SIM_DEBUG("\n");
+
+       assert(ptr_data);
+       assert(data_len > 0);
+
+       p[n++] = 0xff;
+       p[n++] = 0xff;
+       p[n++] = 0xff;
+       p[n++] = 0xff;
+
+       return oem_tx_sim_pb_get_storage_list_res(p, n);
+}
+
+int server_rx_sim_pb_update_record(char *api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sim_pb_del_record(char *api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sim_pb_get_capability_info(char *api)
+{
+       at_unimplemented(api);
+       return 1;
+}
diff --git a/vmodem/server/server_rx_power.c b/vmodem/server/server_rx_power.c
new file mode 100644 (file)
index 0000000..cb67bf8
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  server_rx_power.c */
+
+#include "server_tx_power.h"
+#include "server_rx_power.h"
+#include "logmsg.h"
+
+int server_rx_power_up_exec(void)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return server_tx_power_up_resp();
+}
+
+int server_rx_online_exec(unsigned char status)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+       return server_tx_online_noti(status);
+}
diff --git a/vmodem/server/server_rx_security.c b/vmodem/server/server_rx_security.c
new file mode 100644 (file)
index 0000000..b48deb2
--- /dev/null
@@ -0,0 +1,752 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "vgsm_sim.h"
+#include "state.h"
+#include "server_common_security.h"
+#include "db_security.h"
+#include "server_tx_security.h"
+#include "server_rx_security.h"
+#include "oem_tx_security.h"
+
+#include "misc.h"      // TAPIMessageInit()
+#include "linuxtapi.h"
+#include "vgsm_phone.h"
+#include "phoneserver.h"
+#include "at_recv.h"
+#include "at_func.h"
+#include "at_gen_resp.h"
+
+int server_rx_sim_sec_get_imsi_req(void* ptr_data, int data_len)
+{
+       char pdata[16];
+
+       //SIM_DEBUG("\n");
+       strcpy(pdata, IMSI_NUM);
+
+       return oem_tx_sim_sec_get_imsi_res( pdata, strlen(pdata));
+}
+
+
+int server_rx_sim_sec_set_pin_status_req(void* ptr_data, int data_len)
+{
+       int result = -1;
+       int length_p;
+       int new_length_p = 0;
+       int current_status;
+       int lock_type;
+       char *password          =       0;
+       char *new_password      =       0;
+
+       //int cnt_pin2;
+       //int cnt_puk2;
+       //char *t_password;
+
+       unsigned char *p = 0;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG("\n");
+
+       TAPIMessageInit(&packet);
+
+       if (ptr_data && data_len > 0)
+       {
+               packet.data = malloc(data_len+3 /*p[19~21]*/);
+               memcpy(packet.data, ptr_data, data_len);
+       }
+
+       p = (unsigned char *)(packet.data);
+
+       packet.group    =       GSM_SIM;
+       /*pin->pin_len + pin->puk_len + status + remain count;*/
+       packet.length   =       1 + 1 + 1 + 8 + 8 + 1 + 1 + 1;
+
+       /****************************************************
+       *                               CHV1 , SC verification                                  *
+       *****************************************************/
+       if(p[0] == GSM_SEC_LOCK_TYPE_SC)
+       {
+               packet.action = GSM_SIM_PIN_REQ_STATE;
+
+               /* PUK CODE VERIFY CASE */
+               if(p[2] > 0)    //puk  length exist. -> PUK case.
+               {
+                       lock_type                       =       GSM_SIM_PUK_REQ;
+
+                       length_p                        =       p[2];   //puk
+                       password                        =       malloc(length_p+1);
+                       memcpy(password,&p[11],length_p);
+                       password[length_p]      =       '\0';
+
+                       new_length_p            = p[1]; //new pin
+                       new_password    = malloc(new_length_p+1);
+                       memcpy(new_password,&p[3],new_length_p);
+                       new_password[new_length_p]      =       '\0';
+               }
+               /* PIN CODE VERIFY CASE */
+               else
+               {
+                       lock_type               =       GSM_SIM_PIN_REQ_STATE;
+                       length_p                =       p[1];   //pin
+                       password                =       malloc(length_p+1);
+                       memcpy(password,&p[3],length_p);
+                       password[length_p]      =       '\0';
+               }
+
+               current_status = server_sec_get_sec_status();
+
+               /* PIN check enable case from here */
+               if(current_status  == lock_type)
+               {
+                       result  =       server_sec_verify_password(password,lock_type,length_p);
+               }
+               else
+               {
+                       SIM_DEBUG("Not matched lock type with current_status!! current_status,lock_type=[%x],[%x]",current_status, lock_type);
+               }
+
+               switch(result)
+               {
+                       /* INCORRECT PASSWORD   */
+                       case SIM_FAIL:
+                       {
+                               SIM_DEBUG("wrong password\n");
+
+                               p[19]   =       server_sec_get_sec_status();
+
+                               //ÇØ´ç lock_type ÀÇ remain count ¸¦ °¨¼Ò½ÃÅ´.
+                               server_sec_status_mgr(lock_type);
+
+                               p[20]   =       server_sec_get_remain_cnt(p[19]);
+                               p[21]   =       0;
+
+                               /* incorrect pin input 3 times  */
+                               if(p[19] ==GSM_SIM_PIN_REQ_STATE && p[20] == 0)
+                               {
+                                       // TAPI_OP_GEN_ERR_SIM_PUK_REQU 12      0x000c
+                                       oem_tx_sim_sec_set_pin_status_res(0x000c /*error code*/);
+                               }
+                               /* incorrect puk input 10 times */
+                               else if(p[19] ==GSM_SIM_PUK_REQ && p[20] == 0)
+                               {
+                                       // TAPI_OP_GEN_ERR_SIM_PERM_BLOCKED             0x800b
+                                       oem_tx_sim_sec_set_pin_status_res(0x800B /*error code*/);
+                               }
+                               else
+                               {
+                                       // TAPI_OP_GEN_ERR_INCORRECT_PW 16      0x0010
+                                       oem_tx_sim_sec_set_pin_status_res(0x0010 /*error code*/);
+                               }
+                       }
+                       break;
+
+                       /* CORRECT PASSWORD     */
+                       case SIM_SUCCESS:
+                       {
+                               SIM_DEBUG("passwd OK\n");
+
+                               p[19]   =       server_sec_get_sec_status();
+                               p[20]   =       server_sec_get_remain_cnt(p[19]);
+                               p[21]   =       1;
+
+                               oem_tx_sim_sec_set_pin_status_res(0x8000 /*error code*/);
+
+                               if(lock_type == GSM_SIM_PUK_REQ)
+                               {
+                                       server_sec_change_password(new_password,GSM_SIM_PIN_REQ_STATE,new_length_p);
+
+                                       server_tx_sim_sec_pin_status_noti(STATE_SIM_PUK, STATE_SIM_PUK_OK);
+                                       }
+                               else
+                               {
+                                       server_tx_sim_sec_pin_status_noti(STATE_SIM_PIN, STATE_SIM_PIN_OK);
+                               }
+                       }
+                       break;
+
+                       default:
+                               SIM_DEBUG("Unhandled Verify Result=[%x]\n", result);
+                               break;
+
+               }
+
+       }
+
+       /****************************************************
+       *                               CHV2 , SC2 verification                                 *
+       *****************************************************/
+       else if(p[0] == GSM_SEC_LOCK_TYPE_SC2)
+       {
+               packet.action = GSM_SIM_PIN2_REQ;
+
+               if(p[2] > 0) //puk 2
+               {
+                       lock_type               =       GSM_SIM_PUK2_REQ;
+                       length_p                =       p[2];   //puk2
+                       password                =       malloc(length_p+1);
+                       memcpy(password,&p[11],length_p);
+                       password[length_p] = '\0';
+
+                       new_length_p            = p[1]; //new pin2
+                       new_password    = malloc(new_length_p+1);
+                       memcpy(new_password,&p[3],new_length_p);
+                       new_password[new_length_p] = '\0';
+               }
+               else
+               {
+                       lock_type               =       GSM_SIM_PIN2_REQ;
+                       length_p                =       p[1];   //pin2
+                       password                =       malloc(length_p+1);
+                       memcpy(password,&p[3],length_p);
+                       password[length_p] = '\0';
+               }
+
+               // ¿Ö ÇÊ¿ä?? -> Ã³À½ ºÎÆÃÇÒ ½ÃÁ¡¿¡¼­ current_status°ªÀ» ±âÁØÀ¸·Î pda·Î pin_status_noti¸¦ º¸³»¹Ç·Î
+               // pda¿¡¼­ set pin status¸¦ º¸³¾ ½ÃÁ¡Àº Ç×»ó current status¿¡ ÇØ´çÇϴ °ªÀ» º¸³½´Ù.
+               current_status  =       server_sec_get_sec2_status();
+
+               /* PIN check enable case from here */
+               if(current_status  == lock_type)
+               {
+                       result  =       server_sec_verify_password(password,lock_type,length_p);
+               }
+               else
+               {
+                       SIM_DEBUG("Not matched lock type with current_status!! current_status,lock_type=[%x],[%x]",current_status, lock_type);
+               }
+
+               switch(result)
+               {
+                       /* INCORRECT PASSWORD   */
+                       case SIM_FAIL:
+                       {
+                               SIM_DEBUG("wrong password\n");
+
+                               p[19]   =       server_sec_get_sec2_status();
+
+                               // reduce retry count.
+                               server_sec_status_mgr(lock_type);
+
+                               p[20]   =       server_sec_get_remain_cnt(p[19]);
+                               p[21]   =       0;
+
+                               /* incorrect pin input 3 times  */
+                               if(p[19] ==GSM_SIM_PIN2_REQ && p[20] == 0)
+                               {
+                                       // TAPI_OP_GEN_ERR_SIM_PUK_REQU 12      0x000c
+                                       oem_tx_sim_sec_set_pin_status_res(0x000c /*error code*/);
+                               }
+                               /* incorrect puk input 10 times */
+                               else if(p[19] ==GSM_SIM_PUK2_REQ && p[20] == 0)
+                               {
+                                       // TAPI_OP_GEN_ERR_SIM_PERM_BLOCKED             0x800b
+                                       oem_tx_sim_sec_set_pin_status_res(0x800B /*error code*/);
+                               }
+                               else
+                               {
+                                       // TAPI_OP_GEN_ERR_INCORRECT_PW 16      0x0010
+                                       oem_tx_sim_sec_set_pin_status_res(0x0010 /*error code*/);
+                               }
+                       }
+                       break;
+
+                       /* CORRECT PASSWORD     */
+                       case SIM_SUCCESS:
+                       {
+                               SIM_DEBUG("correct password\n");
+
+                               p[19]   =       server_sec_get_sec2_status();
+                               p[20]   =       server_sec_get_remain_cnt(p[19]);
+                               p[21]   =       1;
+
+                               oem_tx_sim_sec_set_pin_status_res(0x8000 /*error code*/);
+
+                               if(lock_type == GSM_SIM_PUK2_REQ)
+                               {
+                                       server_sec_change_password(new_password,GSM_SIM_PIN2_REQ,new_length_p);
+                                       server_tx_sim_sec_pin_status_noti(STATE_SIM_PUK2, STATE_SIM_PUK2_OK);
+                               }
+                               else
+                               {
+                                       server_tx_sim_sec_pin_status_noti(STATE_SIM_PIN2, STATE_SIM_PIN2_OK);
+                               }
+                       }
+                       break;
+
+                       default:
+                       break;
+
+               }
+
+       }
+
+       if(password)
+               free(password);
+
+       if(new_password)
+               free(new_password);
+
+       //FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return 1;
+}
+/*
+do not use in XOcean.
+*/
+int server_rx_sim_sec_get_pin_status_req(void* ptr_data, int data_len)
+{
+       int ret = 0;
+       int data_size = 2;
+       unsigned char pdata[2];
+
+       SIM_DEBUG("\n");
+
+       switch( server_sec_get_sec_status())
+       {
+               case   GSM_SIM_PIN_REQ_STATE :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PIN;
+               }
+               break;
+
+               case  GSM_SIM_PIN2_REQ :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC2;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PIN2;
+               }
+               break;
+
+               case  GSM_SIM_PUK_REQ :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PUK;
+               }
+               break;
+
+               case  GSM_SIM_PUK2_REQ :
+               {
+                       pdata[0]        =       GSM_SEC_LOCL_TYPE_PUK2;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PUK2;
+               }
+               break;
+
+               case  GSM_SIM_FRIZEN :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_UNAVAIL;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PERM_BLOCKED;
+               }
+               break;
+
+               case  GSM_SIM_NO_SIM :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_NO_SIM;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+               }
+               break;
+
+               case  GSM_SIM_FDN_STATE :
+               {
+                       pdata[0]        =       GSM_SEC_LOCK_TYPE_FD;
+                       pdata[1]        =       GSM_SEC_LOCK_KEY_PIN2;
+               }
+               break;
+
+               case GSM_SIM_READY:
+               {
+                               pdata[0]        =       GSM_SEC_LOCK_TYPE_READY;
+                               pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+               }
+               break;
+
+               default:
+               break;
+
+       }
+
+       ret     =       oem_tx_sim_sec_get_pin_status_res( pdata, data_size);
+
+       return ret;
+}
+
+
+int server_rx_sim_sec_get_lock_info_req(void* ptr_data, int data_len)
+{
+       SIM_DEBUG("\n");
+
+       int lock_type;
+       unsigned char pdata[4];
+       unsigned char *p = ptr_data;
+
+       lock_type=      p[1];
+
+       SIM_DEBUG("lock_type(3:SC, 9:SC2) =[%x]\n",lock_type);
+
+       switch(lock_type)
+       {
+               case GSM_SEC_LOCK_TYPE_SC:
+               {
+                       switch( server_sec_get_sec_status())
+                       {
+                               case   GSM_SIM_PIN_REQ_STATE :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_SC;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PIN;
+                                       pdata[3]        =       server_sec_get_remain_cnt(GSM_SIM_PIN_REQ_STATE);
+                               }
+                               break;
+
+                               case  GSM_SIM_PUK_REQ :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_SC;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PUK;
+                                       pdata[3]        =       server_sec_get_remain_cnt(GSM_SIM_PUK_REQ);
+                               }
+                               break;
+
+                               case  GSM_SIM_FRIZEN :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_UNAVAIL;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PERM_BLOCKED;
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               case  GSM_SIM_NO_SIM :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_NO_SIM;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               case GSM_SIM_READY:
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_SIM_INIT_COMPLETED;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               default:
+                                       SIM_DEBUG("Not handled security status =[%x]\n", server_sec_get_sec_status());
+                               break;
+                       }
+               }
+               break;
+
+               case GSM_SEC_LOCK_TYPE_SC2 :
+               {
+                       switch( server_sec_get_sec2_status())
+                       {
+                               case   GSM_SIM_PIN2_REQ :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_SC2;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PIN2;
+                                       pdata[3]        =       server_sec_get_remain_cnt(GSM_SIM_PIN2_REQ);
+                               }
+                               break;
+
+                               case  GSM_SIM_PUK2_REQ :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_SC2;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PUK2;
+                                       pdata[3]        =       server_sec_get_remain_cnt(GSM_SIM_PUK2_REQ);
+                               }
+                               break;
+
+                               case  GSM_SIM_FRIZEN :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_UNAVAIL;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_PERM_BLOCKED;
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               case  GSM_SIM_NO_SIM :
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_NO_SIM;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               case GSM_SIM_PIN2_OK:
+                               {
+                                       pdata[0]        =       1;
+                                       pdata[1]        =       GSM_SEC_LOCK_TYPE_SC2;
+                                       pdata[2]        =       GSM_SEC_LOCK_KEY_UNLOCKED;      // or GSM_SEC_LOCK_KEY_PIN2_DISABLE
+                                       pdata[3]        =       0;
+                               }
+                               break;
+
+                               default:
+                                       SIM_DEBUG("Not handled security status =[%x]\n", server_sec_get_sec2_status());
+                               break;
+                       }
+               }
+               break;
+
+               default:
+                       SIM_DEBUG("Unhandled Lock_type =[%x]\n",lock_type);
+                       break;
+       }
+
+       return oem_tx_sim_sec_get_lock_info_res(pdata, sizeof pdata);
+}
+
+
+int server_rx_sim_sec_change_password_req(void* ptr_data, int data_len)
+{
+       int result = -1;
+        int length_p;
+        int new_length_p;
+        int lock_type;
+        char *password=0;
+        char *new_password=0;
+       const char* scmd;
+        int nn = 0, found = 0;
+       int recv_type = 0;
+       char tmpmsg[SEND_BUF_SIZE];
+        memset(tmpmsg, '\0', sizeof(tmpmsg));
+        strcpy(tmpmsg, (char*)ptr_data);
+       char* tdata = strchr(tmpmsg, '=');
+        char token[] = "\"";
+        char* ret = NULL;
+       
+       ret = strtok(tdata+1, token);
+        if(ret)
+        {
+               length_p = strlen(ret);
+               password = malloc(length_p+1);
+               strcpy(password, ret);
+               strcat(password, "\0");
+       }
+       
+       ret = strtok(NULL, token);
+       ret = strtok(NULL, token);
+       if(ret)
+       {
+               new_length_p = strlen(ret);
+               new_password = malloc(new_length_p+1);
+               strcpy(new_password, ret);
+               strcat(new_password, "\0");
+       }
+       
+       ret = strtok(NULL, TOKEN);
+       if(ret)
+       {
+               for (nn = 0; ; nn++) {
+                       scmd = sDefaultLock[nn].code;
+                       if (!scmd) // end of list
+                               break;
+
+                       if ( !strcmp( scmd, ret ) ) {
+                               found = 1;
+                               break;
+                       }
+               }
+
+               if(found)
+                       recv_type = sDefaultLock[nn].lock_e_type;
+               else
+                       recv_type = GSM_SEC_LOCK_TYPE_UNAVAIL;
+       }
+       else
+               recv_type = GSM_SEC_LOCK_TYPE_SC;
+
+       SIM_DEBUG("%02x\n", recv_type);
+
+       if(recv_type == GSM_SEC_LOCK_TYPE_SC)
+        {
+               lock_type = GSM_SIM_PIN_REQ_STATE;
+        }
+        else if(recv_type == GSM_SEC_LOCK_TYPE_SC2 /*add more...*/)
+        {
+                       lock_type = GSM_SIM_PIN2_REQ;
+        }
+        else //  Note temp...!!!
+        {
+                       SIM_DEBUG("no matching lock type. ERROR!!!\n");
+                       lock_type = GSM_SIM_PIN2_REQ;
+        }
+       
+       result = server_sec_verify_password(password,lock_type,length_p);
+
+       /* fail case    */
+       if(result       ==      SIM_FAIL)
+       {
+               // reduce retry count.
+               server_sec_status_mgr(lock_type);
+               oem_tx_sim_sec_change_password_res(AT_CME_ERR_INCORRECT_PWD);
+       }
+       /* success case */
+       else if(result  ==      SIM_SUCCESS)
+       {
+               server_sec_change_password(new_password,lock_type,length_p);
+               oem_tx_sim_sec_change_password_res(AT_GEN_ERR_NO_ERROR);
+       }
+
+       if(password)
+               free(password);
+
+       if(new_password)
+               free(new_password);
+
+       return 1;
+}
+
+
+int server_rx_sim_sec_set_phone_lock_req(void* ptr_data, int data_len)
+{
+       int length_p;
+       int lock_type;
+       char *password=0;
+       int result = -1;
+       int facility_type = 0;
+       int mode;
+       unsigned char *p = 0;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG("\n");
+
+       TAPIMessageInit(&packet);
+
+       if (ptr_data && data_len > 0)
+       {
+               packet.data = (unsigned char *) malloc(data_len);
+               memcpy(packet.data, ptr_data, data_len);
+       }
+
+       p = (unsigned char *)(packet.data);
+
+       packet.group    = GSM_SIM;
+       packet.length   = 1 + 1 +1+  8 +  1 + 1 ;/*lock_type + lock_mode +pw_len +  pw + result(true,false);*/
+       packet.action   = GSM_SIM_SET_PHONELOCK_REQ;
+
+       length_p = p[2]; //current len
+       password = malloc(length_p+1);
+       memcpy(password,&p[3],length_p);
+       password[length_p] = '\0';
+
+       if(p[0] == GSM_SEC_LOCK_TYPE_SC)
+       {
+               lock_type               =       GSM_SIM_PIN_REQ_STATE;//pin
+               facility_type   =       GSM_SIM_FACILITY_PIN;
+               p[12]           =       0x00;
+       }
+       else if(p[0] == GSM_SEC_LOCK_TYPE_FD)
+       {
+               lock_type               =       GSM_SIM_PIN2_REQ; //fdn
+               facility_type   =       GSM_SIM_FACILITY_FDN;
+               p[12]           =       0x01;
+       }
+       else
+               assert(0);
+
+       result = server_sec_verify_password(password,lock_type,length_p);
+
+       if(result       ==      SIM_FAIL)
+       {
+               //gen err
+               p[11]=0x00;
+
+               // reduce retry count.
+               server_sec_status_mgr(lock_type);
+
+               oem_tx_sim_sec_set_phone_lock_res(0x0010);
+       }
+       else if(result  ==      SIM_SUCCESS)
+       {
+               p[11]=0x01;
+               mode = p[1];
+
+               server_sec_set_facility(facility_type,mode);
+
+               oem_tx_sim_sec_set_phone_lock_res(0x8000);
+       }
+       else
+               assert(0);
+
+       if(password)
+               free(password);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return  1;
+}
+/*
+       do not use in XOcean.
+*/
+int server_rx_sim_sec_get_phone_lock_req(void* ptr_data, int data_len)
+{
+       unsigned char pdata[2];
+       unsigned char *p = ptr_data;
+
+       SIM_DEBUG("\n");
+
+       assert( data_len >= 2);
+
+       switch( p[0])
+       {
+       case GSM_SEC_LOCK_TYPE_SC :
+               pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+               pdata[1]        =       server_sec_get_facility(GSM_SIM_FACILITY_PIN) ;
+               break;
+
+       case  GSM_SEC_LOCK_TYPE_FD :
+               pdata[0]        =       GSM_SEC_LOCK_TYPE_FD;
+               pdata[1]        =       server_sec_get_facility(GSM_SIM_FACILITY_FDN);
+               break;
+
+       default:
+               assert(0);
+               break;
+       }
+
+       return oem_tx_sim_sec_get_phone_lock_res(pdata, sizeof pdata);
+}
+
diff --git a/vmodem/server/server_rx_sms.c b/vmodem/server/server_rx_sms.c
new file mode 100644 (file)
index 0000000..bfd8179
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "server_tx_sms.h"
+#include "server_rx_sms.h"
+#include "vgsm_phone.h"
+#include "linuxtapi.h"
+#include "state.h"
+#include "phoneserver.h"
+#include "oem_tx_sms.h"
+#include "misc.h"
+#include "at_recv.h"
+#include "at_gen_resp.h"
+#include "sms_util.h"
+
+extern SmsAddressInfo g_sca;
+extern int smsSentStatus;
+
+
+int server_rx_sms_DR(void *ptr_data, int data_len)
+{
+       return -1;
+}
+
+static int sms_msg_hook_modify(void * data, int len)
+{       
+       int position;
+       unsigned char *rawdata = (unsigned char *)data;
+       TPDU_SMS_SUBMIT tpdu_submit;
+       memset(&tpdu_submit, 0, sizeof(TPDU_SMS_SUBMIT));
+
+       /* position is the hit of user data location */
+       /* Mobile Oriented sms (1) */
+       position = DecodeSmsSubmitTpdu(&tpdu_submit, len - 3, (char*)&rawdata[3], 1);
+
+       TRACE(MSGL_VGSM_INFO, "DecodeSmsSubmitTpdu => [return %d], udhl:%d\n", position, rawdata[position]);
+
+       TRACE(MSGL_VGSM_INFO, "[%d][%s]\n"
+               , tpdu_submit.desAddr.dialnumLen, tpdu_submit.desAddr.diallingNum);
+       TRACE(MSGL_VGSM_INFO, "[%d][%s]\n"
+               , tpdu_submit.udl, tpdu_submit.userData);
+
+       /* modify length */
+       TRACE(MSGL_VGSM_INFO, "length is modified [%d] => [%d] \n"
+               , rawdata[(position+2)], tpdu_submit.udl);
+       rawdata[(position+2)] = (unsigned char)tpdu_submit.udl;
+
+       /* modify user data */
+       memset(&rawdata[position+3], 0, tpdu_submit.udl);
+       memcpy(&rawdata[position+3], tpdu_submit.userData, tpdu_submit.udl);
+
+       return 0;
+}
+
+int server_rx_sms_SendMsg(void *ptr_data, int data_len)
+{
+       unsigned char rawdata[0x100];
+       int rawdata_len = 0;
+       unsigned char data[data_len];
+
+       LXT_MESSAGE     packet;
+       TAPIMessageInit(&packet);
+       
+       memcpy(data, ptr_data, data_len);
+       TRACE(MSGL_VGSM_INFO, "smsSentStatus:%d\n", smsSentStatus);
+       // pick out each field
+       unsigned char *to_event_injector = data;
+
+       // data send to event injector includes
+       packet.data   = to_event_injector;
+       packet.group  = GSM_SMS;
+       packet.action = GSM_SMS_SEND_MSG_REQ;
+       packet.length = data_len;
+       
+       sms_msg_hook_modify(packet.data, packet.length);
+       
+       if(smsSentStatus == 0)
+       {
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+               // send a response
+               EncodeSmsSubmitReportTpdu(rawdata, &rawdata_len);
+               server_tx_sms_send_msg(rawdata, rawdata_len);
+       }
+       else
+       {
+               at_gen_resp_send(AT_CMS_ERR_UNKNOWN_ERR);
+       }
+       // 0x04 : Short Message Service Commands
+       // 0x01 : Send the SMS-SUBMIT, SMS-COMMAND or SMS-SUBMIT-REPORT message
+       set_current_state( STATE_ANY, 0x04, 0x01);
+
+       return 1;
+}
+
+int get_sca( SmsAddressInfo *SCA )
+{
+       memcpy( SCA, &g_sca, sizeof( SmsAddressInfo ) );
+
+       return 1;
+}
+
+int server_rx_sms_SCA(void *ptr_data, int data_len )
+{
+       int len = 0;
+       unsigned char data[20];
+       SmsAddressInfo SCA;
+
+       get_sca(&SCA);
+
+       len = SmsUtilEncodeAddrField(data, SCA.diallingNum, SCA.dialnumLen, 0x01, 0x01);
+
+       return oem_tx_sms_SCA(data, len);
+}
+
+int server_rx_sms_SCA_set(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_cbsetconfig(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_ressvcoption(char * api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_param_set(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_param_get(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_memstatus(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_stored_msg_status(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_param_count(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_sms_mem_status(char* api)
+{
+       at_unimplemented(api);
+       return 1;
+}
diff --git a/vmodem/server/server_rx_ss.c b/vmodem/server/server_rx_ss.c
new file mode 100644 (file)
index 0000000..0575e54
--- /dev/null
@@ -0,0 +1,638 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "vgsm_ss.h"
+#include "oem_tx_ss.h"
+#include "server_common_ss.h"
+#include "db_ss.h"
+#include "misc.h"
+#include "vgsm_phone.h"
+#include "state.h" // gen_resp()
+#include "phoneserver.h"
+#include "server_rx_ss.h"
+#include "server_rx_call.h"
+#include "vgsm_debug.h"
+#include "logmsg.h"
+#include "at_func.h"
+#include "at_recv.h"
+#include "at_gen_resp.h"
+
+#define SS_ERR_NEGATIVE_PW_CHECK       0x8126
+#define SS_PW_ATTEMPS_VIOLATION        0x812b
+
+// 090305
+int server_rx_ss_cw_get(int tel_class)
+{
+       VGSM_DEBUG("\n");
+
+       call_waiting_entry_t * cw_entry;
+       char * data = 0;
+       int data_len = 64;
+       int ss_status, ret;
+
+       log_msg(MSGL_VGSM_INFO,"tel_class = %d \n", tel_class);
+       cw_entry = find_call_waiting_entry(tel_class);
+       if(cw_entry->ss_mode == SS_MODE_ACT)
+               ss_status = AT_SS_STATUS_ACTIVE;
+       else
+               ss_status = AT_SS_STATUS_NOT_ACTIVE;
+
+       data = malloc(sizeof(char) * data_len);
+       strcpy(data, CCWA);
+       sprintf(&data[strlen(data)], "%d", ss_status);
+       strcat(data, TOKEN);
+       sprintf(&data[strlen(data)], "%d", AT_CALL_CLASS_VOICE);
+       strcat(data, CRLF);
+
+       log_msg(MSGL_VGSM_INFO,"found & resp: tel_class = %d, ss_mode = %d, ss_status = %d \n"
+                       , cw_entry->tel_class, cw_entry->ss_mode, ss_status);
+
+       ret = oem_tx_ss_cw_resp(data, strlen(data));
+
+       free(data);
+       return 1;
+}
+
+int server_rx_ss_cb_get(int tel_class, int cb_type)
+{
+       VGSM_DEBUG("\n");
+
+       call_barring_entry_t * cb_entry;
+
+       log_msg(MSGL_VGSM_INFO,"tel_class = %d, cb_type = %d \n", tel_class, cb_type);
+
+       cb_entry = find_call_barring_entry(tel_class, cb_type);
+
+       return at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+}
+
+int server_rx_ss_cf_get(int tel_class, int cf_type)
+{
+       VGSM_DEBUG("\n");
+
+       call_forwarding_entry_t * cf_entry;
+       int ss_status, ret;
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       log_msg(MSGL_VGSM_INFO,"tel_class = %d, cf_type = %d \n", tel_class, cf_type);
+       cf_entry = find_call_forwarding_entry(tel_class, cf_type);
+
+       log_msg(MSGL_VGSM_INFO," entry->count = %d \n", cf_entry->count);
+
+       if(cf_entry->ss_mode == SS_MODE_REG || cf_entry->ss_mode == SS_MODE_ACT)
+               ss_status = AT_SS_STATUS_ACTIVE;
+       else
+               ss_status = AT_SS_STATUS_NOT_ACTIVE;
+
+       sprintf(sndbuf, "%s%d,%d", CCFC, ss_status, cf_entry->tel_class);
+       if(ss_status == AT_SS_STATUS_ACTIVE)
+       {
+               log_msg(MSGL_VGSM_INFO, "cf number:%s\n", cf_entry->number);
+               sprintf(&sndbuf[strlen(sndbuf)], ",%s", cf_entry->number);
+       }
+       strcat(sndbuf, CRLF);
+
+       ret = oem_tx_ss_cf_resp(sndbuf, strlen(sndbuf));
+
+       return 1;
+}
+
+int server_rx_ss_cli(char *api)
+{
+       at_unimplemented(api);
+       return 1;
+}
+
+int server_rx_ss_cw_set(int tel_class, int ss_mode)
+{
+       VGSM_DEBUG("\n");
+
+       int i;
+       int db_err;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       log_msg(MSGL_VGSM_INFO,"tel_class = %d, ss_mode = %d \n", tel_class, ss_mode);
+
+       /* add or update */
+       call_waiting_entry_t * entry = malloc(sizeof(call_waiting_entry_t));
+       if(entry == NULL){
+               log_msg(MSGL_VGSM_ERR,"malloc fail \n");
+               return 0;
+       }
+       memset(entry, 0, sizeof(call_waiting_entry_t));
+       entry->tel_class = tel_class;
+       entry->ss_mode = ss_mode;
+       strcpy(entry->number, SUBSCRIBER_NUM);
+       log_msg(MSGL_VGSM_INFO, "%s", entry->number);
+       if( ( db_err = vgsm_ss_database_add(SS_CMD_CW, entry) ) > 0){
+               log_msg(MSGL_WARN,"vgsm_ss_database_add() is failed!!db_err = %d \n", db_err);
+       }
+
+       if(entry){
+               free(entry);
+       }
+
+       /* resp */
+       call_waiting_entry_t * resp_entry = get_call_waiting_entry();
+       if(!resp_entry){
+               /* Not happen ?? */
+               log_msg(MSGL_WARN,"entry is NULL!!!\n");
+       }
+
+       if(resp_entry){
+               for(i=0; i<resp_entry[0].count; i++){
+                       log_msg(MSGL_VGSM_INFO,"i : %d,  tel_class : %d, ss_mode : %d\n"
+                                       , i, resp_entry[i].tel_class, resp_entry[i].ss_mode);
+               }
+       }
+
+       resp_entry[0].tel_class = 255;// temporary      
+       packet.data = resp_entry;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_SET_CW_REQ;
+       packet.length = (sizeof(call_waiting_entry_t) * resp_entry[0].count);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+       resp_entry[0].tel_class = 1;
+
+       return 0;
+}
+
+//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)
+int server_rx_ss_cf_set(int ss_mode, int type, int tel_class, int replyTime, int num_len, char *number, int num_type)
+{
+       VGSM_DEBUG("\n");
+
+       int i;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       call_forwarding_entry_t * entry = malloc(sizeof(call_forwarding_entry_t));
+       memset(entry, 0, sizeof(call_forwarding_entry_t));
+
+       entry->ss_mode = ss_mode;
+       entry->type = type;
+       entry->tel_class = tel_class;
+       entry->replyTime = replyTime;
+//     entry->number_type = num_type;
+//     entry->satype = satype;
+//     memcpy(entry->subaddr, subaddr, MAX_GSM_DIALED_DIGITS_NUMBER);
+       
+       if(num_len)
+       {
+               strcpy(entry->number, number);
+               log_msg(MSGL_VGSM_INFO,"============ %s(%d) \n", entry->number, num_len);
+       }
+
+
+       // 090326
+       log_msg(MSGL_VGSM_INFO,"=check=========== (%x)(%x) \n", entry->type, entry->ss_mode);
+       if(entry->ss_mode == SS_MODE_DEACT || entry->ss_mode == SS_MODE_DEREG)
+       {
+               // 090326
+               //if(entry->type == SS_CF_TYPE_CF_ALL && entry->ss_mode == SS_MODE_DEACT)               //disable all call forwarding
+               if(entry->type == SS_CF_TYPE_CF_ALL)            //disable all call forwarding
+               {
+                       // 090327  SS_CF_TYPE_CFU ---> SS_CF_TYPE_CF_ALL
+                       if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CF_ALL) > 0)
+                               log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFU is failed!!\n");
+
+               }
+               // 090326
+               //else if(entry->type == SS_CF_TYPE_CFC && entry->ss_mode == SS_MODE_DEACT)             //disable all conditional call forwarding
+               else if(entry->type == SS_CF_TYPE_CFC)          //disable all conditional call forwarding
+               {
+                       if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFB) > 0)
+                               log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFB is failed!!\n");
+
+                       if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRy) > 0)
+                               log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRy is failed!!\n");
+
+                       if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRc) > 0)
+                               log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRc is failed!!\n" );
+               }
+               // add 090326
+               else
+               {
+                       if(entry->type == SS_CF_TYPE_CFU)
+                       {
+                               if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFU) > 0)
+                                       log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFU is failed!!\n");
+                       }
+                       else if(entry->type == SS_CF_TYPE_CFB)
+                       {
+                               if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFB) > 0)
+                                       log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFB is failed!!\n");
+                       }
+                       else if(entry->type == SS_CF_TYPE_CFNRy)
+                       {
+                               if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRy) > 0)
+                                       log_msg(MSGL_WARN, "vgsm_ss_database_remove() SS_CF_TYPE_CFNRy is failed!!\n" );
+                       }
+                       else if(entry->type == SS_CF_TYPE_CFNRc)
+                       {
+                               if(vgsm_ss_database_remove(SS_CMD_CF, entry->tel_class, SS_CF_TYPE_CFNRc) > 0)
+                                       log_msg(MSGL_WARN,"vgsm_ss_database_remove() SS_CF_TYPE_CFNRc is failed!!\n");
+                       }
+               }
+       }
+       else
+       {
+               //call forwarding table update
+               if(vgsm_ss_database_add(SS_CMD_CF, entry) > 0)
+                       log_msg(MSGL_VGSM_INFO,"vgsm_ss_database_add() is failed!!\n" );                
+       }
+
+       if(entry)
+               free(entry);
+
+       //eventinjector¿¡°Ô data send -> ui update
+       call_forwarding_entry_t * resp_entry = get_call_forwarding_entry();
+
+       //for debug
+       if(!resp_entry)
+               log_msg(MSGL_WARN,"entry is NULL!!! \n" );
+       if(resp_entry)
+       {
+               for(i=0; i<resp_entry[0].count; i++)
+               {
+                       log_msg(MSGL_WARN,"i: %d, tel_class : 0x%x, type : %d, number : %s, ss_mode : %d\n",
+                                       i, resp_entry[i].tel_class, resp_entry[i].type, resp_entry[i].number, resp_entry[i].ss_mode);
+               }
+       }
+
+       packet.data = resp_entry;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_SET_CCFC_REQ;
+       packet.length = (sizeof(call_forwarding_entry_t) * resp_entry[0].count);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       return 1;
+}
+
+int server_rx_ss_cb_set(int cb_type, int ss_mode, int tel_class, char *passwd)
+{
+       VGSM_DEBUG("\n");
+
+       int i, gen_resp_err;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+       int cb_pwd_fail_count = 0;
+
+       call_barring_entry_t * entry =  malloc(sizeof(call_barring_entry_t));
+       memset(entry, 0, sizeof(call_barring_entry_t));
+
+       entry->type =cb_type;
+       entry->ss_mode = ss_mode;
+       entry->tel_class = tel_class;
+       char* tmp_cb_pwd = get_callbarring_pwd();
+       VGSM_DEBUG("orig_pwd:%s, input_pwd:%s\n", tmp_cb_pwd, passwd);
+
+       if( strcmp(passwd, tmp_cb_pwd) != 0)
+       {
+               VGSM_DEBUG("Wrong CallBarring Passwd\n");
+               cb_pwd_fail_count = increase_callbarring_pwd_fail_count();
+               VGSM_DEBUG("cb_pwd_fail_count = %d\n",cb_pwd_fail_count);
+
+               if(cb_pwd_fail_count >= 3)
+                       gen_resp_err = SS_PW_ATTEMPS_VIOLATION; // numberOfPW_AttemptsViolation
+               else
+                       gen_resp_err = SS_ERR_NEGATIVE_PW_CHECK; // NegativePasswordCheck
+
+               oem_tx_ss_gen_resp(AT_CME_ERR_INCORRECT_PWD);
+               free(entry);
+               return 1;
+       }
+
+       VGSM_DEBUG("Right CallBarring Passwd\n");
+
+       clear_callbarring_pwd_fail_count();
+
+       /* gen resp */
+       set_ss_current_general_response_error( get_ss_general_response_error() );
+       gen_resp_err = get_ss_current_general_response_error();
+       oem_tx_ss_gen_resp(AT_GEN_ERR_NO_ERROR);
+       
+       if(gen_resp_err != 0x8000)
+       {
+               log_msg(MSGL_WARN, "gen_resp_err : %d \n", gen_resp_err);
+               free(entry);
+               return 1;
+       }
+
+       if(entry->tel_class == AT_CALL_SS_CLASS_VIDEO)
+       {
+               if(entry->type == SS_CB_TYPE_AB)
+                {
+                        set_outgoing_video_call_barring_state(entry->ss_mode);
+                        set_incoming_video_call_barring_state(entry->ss_mode);
+                }
+                else if(entry->type == SS_CB_TYPE_BAOC)
+                {
+                        set_outgoing_video_call_barring_state(entry->ss_mode);
+                }
+                else if(entry->type == SS_CB_TYPE_BAIC)
+                {
+                        set_incoming_video_call_barring_state(entry->ss_mode);
+                }
+       }
+       else
+       {
+               if(entry->type == SS_CB_TYPE_AB)
+               {
+                       set_outgoing_voice_call_barring_state(entry->ss_mode);
+                       set_incoming_voice_call_barring_state(entry->ss_mode);
+               }
+               else if(entry->type == SS_CB_TYPE_BAOC)
+               {
+                       set_outgoing_voice_call_barring_state(entry->ss_mode);
+               }
+               else if(entry->type == SS_CB_TYPE_BAIC)
+               {
+                       set_incoming_voice_call_barring_state(entry->ss_mode);
+               }
+       }
+
+       if( (entry->type == SS_CB_TYPE_AB ) && (entry->ss_mode == SS_MODE_DEREG || entry->ss_mode == SS_MODE_DEACT)) // cancel all.
+       {
+               entry->type = SS_CB_TYPE_BAOC;
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
+
+               entry->type = SS_CB_TYPE_BOIC;
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
+
+               entry->type = SS_CB_TYPE_BOIC_NOT_HC;
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
+
+               entry->type = SS_CB_TYPE_BAIC;
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
+
+               entry->type = SS_CB_TYPE_BIC_ROAM;                      
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );
+
+               entry->type = SS_CB_TYPE_AB; //rollback.
+       }               
+       else
+       {
+               if(vgsm_ss_database_add(SS_CMD_CB, entry) > 0)
+                       log_msg(MSGL_WARN, "vgsm_ss_database_add() is failed!!\n" );            
+       }
+
+       if(entry)
+               free(entry);
+
+       call_barring_entry_t * resp_entry  = get_call_barring_entry();
+
+       //for debug
+       if(!resp_entry)
+               log_msg(MSGL_WARN, "entry is NULL!!! \n" );
+       if(resp_entry)
+       {
+               for(i=0; i<resp_entry[0].count; i++)
+               {
+                       log_msg(MSGL_VGSM_INFO,"i : %d,  tel_class : %d, ss_mode : %d\n",
+                                       i, resp_entry[i].tel_class, resp_entry[i].ss_mode);
+               }
+       }
+
+       packet.data = resp_entry;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_SET_CB_REQ;
+       packet.length = (sizeof(call_barring_entry_t) * resp_entry[0].count);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       return 1;
+
+}
+
+int server_rx_ss_cb_passwd_set(char* curr_passwd, char* new_passwd)
+{
+       VGSM_DEBUG("\n");
+
+       int gen_resp_err;
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+       int cb_pwd_fail_count = 0;
+
+       char* tmp_cb_pwd = get_callbarring_pwd();
+
+       if( memcmp(tmp_cb_pwd, curr_passwd, 4 ) != 0)
+       {
+               VGSM_DEBUG("Wrong CallBarring Passwd\n");
+               cb_pwd_fail_count = increase_callbarring_pwd_fail_count();
+               VGSM_DEBUG("cb_pwd_fail_count = %d\n",cb_pwd_fail_count);
+
+               if(cb_pwd_fail_count >= 3)
+                       gen_resp_err = SS_PW_ATTEMPS_VIOLATION; // numberOfPW_AttemptsViolation
+               else
+                       gen_resp_err = SS_ERR_NEGATIVE_PW_CHECK; // NegativePasswordCheck
+
+               oem_tx_ss_gen_resp(gen_resp_err);
+               return 1;
+       }
+
+       VGSM_DEBUG("Right CallBarring Passwd\n");
+
+       clear_callbarring_pwd_fail_count();
+
+       /* gen resp */
+       set_ss_current_general_response_error( get_ss_general_response_error() );
+       gen_resp_err = get_ss_current_general_response_error();
+       oem_tx_ss_gen_resp(gen_resp_err);
+       if(gen_resp_err != 0x8000)
+       {
+               log_msg(MSGL_WARN,"gen_resp_err : %d \n", gen_resp_err);
+               return 1;
+       }
+
+       set_callbarring_pwd(new_passwd);
+
+       VGSM_DEBUG("CallBarring Passwd changed\n");
+
+       packet.data = new_passwd;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_PWDSET_CB_REQ;
+       packet.length = sizeof(new_passwd);
+
+       VGSM_DEBUG("CallBarring Passwd changed\n");
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+       /* EI¿¡¼­´Â ÀÌ·¯ÇÑ event¸¦ ¼ö½ÅÇϸé,
+        * popup(callbarring password changed!!) --> callbarring password : new_passwd
+        */
+
+       return 1;
+}
+
+int server_rx_ss_aoc_get(void)                         // 090215   vgsm -> EI
+{
+       LXT_MESSAGE packet;
+       unsigned char * data = 0;
+       int             data_len;
+       _AOC_t  tmp;
+
+       tmp.acm = 123;
+       tmp.ccm = 234;
+       tmp.maxacm = 345;
+       tmp.ppu = 456;
+       tmp.chartype = 7;
+
+       data_len = sizeof(tmp);
+
+       VGSM_DEBUG("\n");
+
+       get_aoc_data( &tmp);
+
+       data = malloc(sizeof(unsigned char) * data_len);
+       memset(data, 0, data_len);
+       memcpy(data, &tmp, data_len);
+
+       VGSM_DEBUG("Send AOC DATA to EI\n");
+       packet.data = data;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_AOC_GET;
+       packet.length = data_len;
+
+       VGSM_DEBUG("Send AOC DATA to EI\n");
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       free(data);
+       return 1;
+}
+
+int server_rx_ss_ussd_get(void)                                // 090215   vgsm -> EI
+{
+       LXT_MESSAGE packet;
+       unsigned char * data = 0;
+       int             data_len;
+       _USSD_data_t    tmp;
+
+       strcpy(tmp.time, "12:00:00, 2000");
+       strcpy(tmp.weather, "Fine");
+
+       data_len = sizeof(tmp);
+
+       VGSM_DEBUG("\n");
+
+       get_ussd_data( &tmp);
+
+       data = malloc(sizeof(unsigned char) * data_len);
+       memset(data, 0, data_len);
+       memcpy(data, &tmp, data_len);
+
+       VGSM_DEBUG("Send USSD DATA to EI\n");
+       VGSM_DEBUG("time : %s\n", tmp.time);
+       VGSM_DEBUG("weather : %s\n", tmp.weather);
+       packet.data = data;
+       packet.group  = GSM_SUPS;
+       packet.action = GSM_SUPS_USSD_GET;
+       packet.length = data_len;
+
+       VGSM_DEBUG("Send ussd DATA to EI\n");
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+#if 1
+       free(data);
+#endif
+       return 1;
+}
+
+int server_rx_ss_manage_call_set(char* ptr_data, int data_len)
+{
+       int rtn=0;
+       int signal = 0;
+        char* data = strchr(ptr_data, '=');
+        char token[] = "\n";
+        char* ret = NULL;
+       int call_id = 0;
+
+        ret = strtok(data+1, token);
+        if(ret)
+               signal = atoi(ret);
+
+        if(signal == AT_GSM_SS_CM_0_SEND)      // release all held call
+        {
+               rtn = server_rx_call_release_all_held();
+        }
+        else if(signal == AT_GSM_SS_CM_1_SEND)    // release all active call and the other (held or waiting) call
+        {
+                       rtn = server_rx_call_release_all_active(); 
+       }
+        else if(signal == AT_GSM_SS_CM_2_SEND)    // active call on hold and held or waiting call on active
+        {
+               VGSM_DEBUG("g_ss_hold_response_error: err =%x \n", g_ss_hold_response_error);   
+                //at_gen_resp_send( g_ss_hold_response_error);
+                if ( g_ss_hold_response_error == 0x8000 )
+                       rtn = server_rx_call_swap();
+                else
+                        VGSM_DEBUG("g_ss_hold_response_error: err =%x \n", g_ss_hold_response_error);
+        }
+        else if(signal == AT_GSM_SS_CM_3_SEND)    // add a held call to the conversation
+        {
+               VGSM_DEBUG("g_ss_join_response_error: err =%x \n", g_ss_join_response_error);
+                //at_gen_resp_send( g_ss_join_response_error);
+                if ( g_ss_join_response_error == 0x8000   )
+                       rtn = server_rx_call_join_conf();  // TODO: call id is needed?? check....
+                else
+                       VGSM_DEBUG("g_ss_join_response_error: err =%x \n", g_ss_join_response_error);
+        }
+        else if(signal >= 10 && signal < 20 )    // AT_GSM_SS_CM_1X_SEND : connect the two call and disconnect the subscriber from both calls
+        {
+               call_id = signal - 11;
+               rtn = server_rx_call_release_single(call_id);
+        }
+        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.
+       {
+               call_id = signal - 21;
+               VGSM_DEBUG("server_rx_call_split_conf : err =%x \n", g_ss_split_response_error);
+                //at_gen_resp_send( g_ss_split_response_error);
+                if ( g_ss_split_response_error == 0x8000   )
+                       rtn = server_rx_call_split_conf(call_id);
+                else
+                       VGSM_DEBUG("server_rx_call_split_conf : err =%x \n", g_ss_split_response_error);
+       }
+       else
+       {
+               VGSM_DEBUG (" not supported ID = %d \n" , signal);
+       }
+
+       return rtn;
+}
+
+
diff --git a/vmodem/server/server_tx_call.c b/vmodem/server/server_tx_call.c
new file mode 100644 (file)
index 0000000..79b1243
--- /dev/null
@@ -0,0 +1,693 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// server_tx_calll.c
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "state.h" // linuxtapi.h
+#include "misc.h"
+
+#include "phoneserver.h"
+
+#include "vgsm_call.h"
+#include "oem_tx_call.h"
+#include "server_tx_call.h"
+#include "server_common_call.h"
+#include "server_tx_ss.h"
+#include "logmsg.h"
+#include "at_gen_resp.h"
+#include "at_func.h"
+
+// caution: MAX_GSM_DIALED_DIGITS_NUMBER and MAX_GSM_DIALED_DIGITS_NUM are confusingly similar
+
+int server_tx_call_msg(void)
+{
+       _ENTER();
+
+       STATE state;
+
+       get_current_state_machine(&state );
+
+       switch(STATE_SUB_CMD(state))
+       {
+               case GSM_CALL_STATUS:
+                       server_tx_call_status();
+                       break;
+               case GSM_CALL_LIST:
+                       server_tx_call_list_resp();
+                       break;
+               default:
+                       log_msg(MSGL_WARN, "unknown subcommand %d\n", STATE_SUB_CMD(state));
+       }
+
+       _LEAVE();
+
+       return 1;
+}
+
+//int TxCall_CallStatus()
+int server_tx_call_status(void) // it means call state.
+{
+       int ret = 0;
+       STATE prev;
+       int i;
+       int call_state = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       LXT_MESSAGE packet;
+       gsm_call_list_t * callList = malloc(sizeof(gsm_call_list_t));
+
+       get_prev_state_machine( &prev );
+
+       //      if( STATE_SUB_CMD(prev) == GSM_CALL_OUTGOING )
+       if( STATE_TYPE(prev) == STATE_STANDBY ) // it means GSM_CALL_OUTGOING in state_machine.
+       {
+               call_state = GSM_CALL_STATE_OUTGOING;
+               log_msg(MSGL_VGSM_INFO, "STATE_STANBY\n");
+               set_call_list_status( get_call_id(), 0, GSM_CALL_STATUS_DIALING );
+               get_call_list(callList);
+       }
+       else if( STATE_TYPE(prev) == STATE_CALL_WAITING_OUTGOING || STATE_TYPE(prev) == STATE_CALL_WAITING_INCOMING )
+       {
+               call_state = GSM_CALL_STATE_CONNECTED;
+
+               // find client id of incoming call & set active
+               get_call_list(callList);
+               for( i=0; i<MAX_CALL_COUNT; ++i ) {
+                       if(callList->CallInfo[i].stat  == GSM_CALL_STATUS_INCOMING ){
+                               log_msg(MSGL_VGSM_INFO,"call id(%d) is GSM_CALL_STATUS_INCOMING \n", i);
+                               set_call_id( i );
+                               break;
+                       }
+               }
+               set_call_list_status( get_call_id(), 0, GSM_CALL_STATUS_ACTIVE );
+               at_gen_resp_send(AT_GEN_ERR_CONNECT);
+
+               // re get call list
+               get_call_list(callList);
+
+               for(i = 0; i < callList->CallCount; i++){
+                       log_msg(MSGL_VGSM_INFO,"call id : %d, number : %s, multiparty : %d, stat : %d \n",
+                                       callList->CallInfo[i].idx, callList->CallInfo[i].number,
+                                       callList->CallInfo[i].mpty, callList->CallInfo[i].stat);
+               }
+
+               packet.data = (gsm_call_list_t*)callList;
+               packet.group  = GSM_CALL;
+               packet.action = GSM_CALL_CONNECTED_LINE_NOTI;
+               packet.length = sizeof(gsm_call_list_t);
+
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+       }
+       else if( STATE_TYPE(prev) == STATE_CALL_RELEASED )
+       {
+               call_state = GSM_CALL_STATE_RELEASED;
+               at_gen_resp_send(AT_GEN_ERR_RELEASE);           
+
+               get_call_list(callList);
+               packet.data = (gsm_call_list_t*)callList;
+               packet.group  = GSM_CALL;
+               packet.action = GSM_CALL_STATUS_NOTI;
+               packet.length = sizeof(gsm_call_list_t);
+
+               FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+               set_call_list_status( get_call_id(), 0, GSM_CALL_STATUS_NONE );
+               get_call_list(callList);
+       }
+       /* Why does not it exist in case of STATE_CALL_CONVERSATION */
+
+       /*       In call status msg, incoming msg do not exist.
+                else if( STATE_SUB_CMD(prev) == GSM_CALL_INCOMING )
+                {
+                pdata[2] = GSM_CALL_STATE_INCOMING;
+                }
+        */
+
+       unsigned char pdata[128];
+       int at_stat = change_stat_for_at(callList->CallInfo[get_call_id()].stat);
+       TRACE(MSGL_VGSM_INFO, "call id:%d, orignal stat: %d, send stat: %d\n", get_call_id(), callList->CallInfo[get_call_id()].stat, at_stat);
+       
+       if(callList->CallInfo[get_call_id()].number)
+       {
+               sprintf((char*)pdata, "%d,%d,%d,%d,%d,%s,%d", get_call_id() + 1, change_dir_for_at(callList->CallInfo[get_call_id()].dir), 
+                                                               at_stat, AT_CALL_MODE_VOICE, AT_CALL_MPTY_FALSE, 
+                                                               callList->CallInfo[get_call_id()].number,callList->CallInfo[get_call_id()].num_type); 
+       }
+       else
+       {
+               sprintf((char*)pdata, "%d,%d,%d,%d,%d", get_call_id() + 1, change_dir_for_at(callList->CallInfo[get_call_id()].dir), at_stat, AT_CALL_MODE_VOICE, AT_CALL_MPTY_FALSE);
+       }
+       free(callList);
+       set_current_call_status_error( 0x00 );
+
+       ret = oem_tx_call_status_noti(pdata, strlen((char*)pdata));
+
+       _LEAVE();
+
+       return ret;
+}
+
+int server_tx_call_list_noti(void)
+{
+       _ENTER();
+
+       int i = 0, j = 0, ret = 0;
+       int CallCount = 0;
+       int len = 0;
+       unsigned char *data = NULL;
+       LXT_MESSAGE packet;
+       gsm_call_list_t         * callList = malloc(sizeof(gsm_call_list_t));
+
+       get_call_list(callList);
+       CallCount = callList->CallCount;
+       // FIXME: probably want MAX_GSM_DIALED_DIGITS_NUM here
+       len = 32 + (8+MAX_GSM_DIALED_DIGITS_NUMBER);
+       data = malloc(len*2);
+       log_msg(MSGL_VGSM_INFO,"CallCount %d\n", CallCount);
+       j = 1;
+       for (i=0; i < MAX_CALL_COUNT; i++) {
+               if( callList->CallInfo[i].stat == GSM_CALL_STATUS_NONE )
+                       continue;
+               log_msg(MSGL_VGSM_INFO,"index = %d    : Call_STATUS %d\n", i, callList->CallInfo[i].stat);
+               
+               assert(valid_call_type(callList->CallInfo[i].call_type));
+               memset( data, 0, len * 2 );
+               sprintf((char*)data, "%d,%d,%d,%d,%d,%s,%d%s", callList->CallInfo[i].idx + 1,
+                                                        change_dir_for_at(callList->CallInfo[i].dir),
+                                                        change_stat_for_at(callList->CallInfo[i].stat), AT_CALL_MODE_VOICE, callList->CallInfo[i].mpty, 
+                                                       callList->CallInfo[i].number, callList->CallInfo[i].num_type, CRLF);
+                log_msg(MSGL_VGSM_INFO, "%s", data);
+               ret = oem_tx_call_status_noti(data, strlen((char*)data));
+       }
+       
+       /* send to EI */
+       packet.data = (gsm_call_list_t*)callList;
+       packet.length = sizeof(gsm_call_list_t);
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_CALL_LIST_IND;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       free(data);
+       free(callList);
+
+       _LEAVE();
+
+       return ret;
+}
+
+int change_stat_for_at(int gsm_stat)
+{
+       int stat = 0;
+       switch(gsm_stat)
+       {
+       case GSM_CALL_STATUS_NONE:
+               stat = AT_CALL_STAT_RELEASED;
+               break;
+       case GSM_CALL_STATUS_ACTIVE:
+               stat = AT_CALL_STAT_ACTIVE;
+               break;
+       case GSM_CALL_STATUS_HELD:
+               stat = AT_CALL_STAT_HELD;
+               break;
+       case GSM_CALL_STATUS_DIALING:
+               stat = AT_CALL_STAT_DIALING;
+               break;
+       case GSM_CALL_STATUS_ALERT:
+               stat = AT_CALL_STAT_ALERTING;
+               break;
+       case GSM_CALL_STATUS_INCOMING:
+               stat = AT_CALL_STAT_INCOMING;
+               break;
+       case GSM_CALL_STATUS_WAITING:
+               stat = AT_CALL_STAT_WAITING;
+               break;
+       case GSM_CALL_STATUS_MAX:
+       default:
+               stat = AT_CALL_STAT_DIALING;
+               break;
+       }
+
+       return stat;
+}
+
+int change_dir_for_at(int gsm_dir)
+{
+       int dir = 0;
+
+       switch(gsm_dir)
+       {
+       case GSM_CALL_DIR_MO:
+               dir = 0;
+               break;
+       case GSM_CALL_DIR_MT:
+               dir = 1;
+               break;
+       default:
+               dir = 0;
+               break;
+       }
+       return dir;
+}
+
+int server_tx_call_list_resp(void)
+{
+       int i = 0, ret = 0;
+       int CallCount = 0;
+       int len = 0;
+       unsigned char *data = NULL;
+       gsm_call_list_t * callList = malloc(sizeof(gsm_call_list_t));
+
+       _ENTER();
+
+       get_call_list(callList);
+       CallCount = callList->CallCount;
+       len = 32 + (8+MAX_GSM_DIALED_DIGITS_NUMBER);
+       data = malloc(len*2);
+       log_msg(MSGL_VGSM_INFO,"CallCount %d\n", CallCount);
+       for (i=0; i < MAX_CALL_COUNT; i++) {
+               if( callList->CallInfo[i].stat == GSM_CALL_STATUS_NONE )
+                       continue;
+               log_msg(MSGL_VGSM_INFO,"index = %d    : Call_STATUS %d\n",  i, callList->CallInfo[i].stat);
+
+               assert(valid_call_type(callList->CallInfo[i].call_type));
+               memset( data, 0, len * 2);
+               sprintf((char*)data, "%s%d,%d,%d,%d,%d,%s,%d%s", CLCC,callList->CallInfo[i].idx + 1, 
+                                                       change_dir_for_at(callList->CallInfo[i].dir),
+                                                       change_stat_for_at(callList->CallInfo[i].stat), 
+                                                       AT_CALL_MODE_VOICE, callList->CallInfo[i].mpty, 
+                                                       callList->CallInfo[i].number, callList->CallInfo[i].num_type, CRLF);
+               log_msg(MSGL_VGSM_INFO, "%s", data);    
+               ret = oem_tx_call_list_resp(data, strlen((char*)data));
+       }
+       at_gen_resp_send(AT_GEN_ERR_NO_ERROR);
+
+       free(data);
+       free(callList);
+
+       _LEAVE();
+
+       return ret;
+}
+
+static void cast_call_incomming(unsigned char call_id)
+{
+       _ENTER();
+
+       unsigned char data[1];
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       /*   check general response error & call status error    */
+
+       data[0] = call_id;              //The object is simulator,   0x01 : Outgoing Call, 0x02 : Answer Call, 0x03 : Release Call
+
+       packet.data = data;
+       packet.length = 1;
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_ID;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       log_msg(MSGL_VGSM_INFO," -------------------------incoming call id : %d\n",call_id);
+}
+
+
+int server_tx_call_incoming_noti( LXT_MESSAGE * packet ) //¸ÁÀÔÀå¿¡¼± outgoing call.
+{
+       int num_len = 0, ret = 0;
+       char number[MAX_GSM_DIALED_DIGITS_NUMBER];
+       char *p, data[8 + MAX_GSM_DIALED_DIGITS_NUMBER];
+       unsigned char ss_present_indi ;
+       unsigned char ss_call_type ;
+       unsigned char ss_no_cli_cause ;
+       unsigned char call_id ;
+       STATE state;
+       gsm_call_list_t list;
+       gsm_call_status_e_type call_status = GSM_CALL_STATUS_INCOMING;
+       char clir = GSM_CALL_CLIR_STATUS_NOT_CHANGED;           //gsm_clir_status_e_type
+       int call_exist = 0;  //  ÇöÀç call list¿¡, callÀÌ ¾ø´Ù¸é incoming noti Àü¼ÛÇÑ´Ù.
+       unsigned short call_type;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       get_current_state_machine( &state );
+       if( ( state.state_type == STATE_CALL_WAITING_OUTGOING ) ||
+                       ( state.state_type == STATE_CALL_WAITING_INCOMING ) )
+       {
+               log_msg(MSGL_WARN,"state_type = %d\n",state.state_type);
+               return 0;
+       }
+
+       if( check_call() == 0 )
+       {
+               log_msg(MSGL_WARN, "1 active and 1 hold \n");
+               // delete for multi call ( 6 call ) return 0;
+       }
+
+       get_call_list( &list );
+       if( list.CallCount > 0 ) {
+               call_status = GSM_CALL_STATUS_WAITING;
+
+               // sub_cmd = GSM_CALL_WAITING;
+               call_exist = 1; // call list¿¡ call ÀÌ Á¸ÀçÇϸé, incoming noti ´ë½Å¿¡ waiting noti¸¦ Àü¼ÛÇÑ´Ù.
+       }
+
+       assert(packet->length >= 8);
+       p = packet->data;
+
+       call_id = make_call_id();
+       call_type = p[0] << 8;
+       cast_call_incomming(call_id);
+       set_call_type(call_type);
+
+       memset(number, 0, MAX_GSM_DIALED_DIGITS_NUMBER);
+
+       clir = p[2];
+
+       if(clir == GSM_CALL_CLIR_STATUS_INVOCATION)
+       {
+               log_msg(MSGL_VGSM_INFO,"  GSM_CALL_CLIR_STATUS_INVOCATION -> no num  \n");
+               num_len = 0; // È®ÀÎÇÏÀÚ. num_len °¡ MAX_GSM_DIALED_DIGITS_NUMBER µÇ¾î¾ßÇÏ´ÂÁö check...
+               memset(number, 0, MAX_GSM_DIALED_DIGITS_NUMBER);
+               ss_present_indi = p[5];
+               ss_no_cli_cause = p[6];
+
+       }
+       else
+       {
+               num_len = p[3];
+               memcpy(number, &p[7], num_len);
+               log_msg(MSGL_VGSM_INFO,"  call num len %d  \n", num_len);
+               ss_present_indi = 0;
+               ss_no_cli_cause = 0;
+       }
+
+       set_call_list( GSM_CALL_DIR_MT, call_status, call_type, number, num_len );
+
+       //090314
+       callback_callist();
+
+       char* number_type;
+       if(number[0] == '+')
+               number_type = "129";
+        else
+                number_type = "145";    // default
+       
+       if(call_exist == 0)
+       {
+               sprintf(data, "%d,%d,%d,%d,%d,%s,%s", call_id + 1, AT_CALL_DIR_MT, AT_CALL_STAT_INCOMING, AT_CALL_MODE_VOICE, AT_CALL_MPTY_FALSE, number, number_type);
+               TRACE(MSGL_VGSM_INFO, "data: %s\n", data);
+               ret = oem_tx_call_incoming_noti(data, strlen(data));
+       }
+       else
+       {
+               sprintf(data, "%s,%s,%d", number, number_type, AT_CALL_CLASS_VOICE);
+               TRACE(MSGL_VGSM_INFO, "data: %s\n", data);
+               ret = oem_tx_call_waiting_noti(data, strlen(data));
+
+               memset(data, '\0', strlen(data));
+               sprintf(data, "%d,%d,%d,%d,%d,%s,%s", call_id + 1, AT_CALL_DIR_MT, AT_CALL_STAT_WAITING, AT_CALL_MODE_VOICE, AT_CALL_MPTY_FALSE, number, number_type);
+                TRACE(MSGL_VGSM_INFO, "data: %s\n", data);
+               return oem_tx_call_status_noti(data, strlen(data));
+       }
+
+       //log_msg(MSGL_VGSM_INFO,"!!!!!!!!server_tx_call_incoming_noti!!!!!!!!!!! number : %d, number len : %d \n", number[0], num_len);
+       if( GSM_CALL_TYPE_FORWARDED == p[1] )
+       {
+               ss_call_type = 0x33 ;
+               // forwardcall
+       }
+       else
+       {
+               ss_call_type = 0x31 ; //calling party
+       }
+
+       log_msg(MSGL_VGSM_INFO,"  call type = %d,  num len=%d  PI=%d  Cli-cause %d \n", p[0], num_len,ss_present_indi,ss_no_cli_cause);
+
+       server_tx_ss_cli(ss_call_type, ss_present_indi, ss_no_cli_cause); // TODO:  it will be changed..
+
+       _LEAVE();
+
+       return ret;
+}
+
+//int TxCall_ExecRelease( LXT_MESSAGE * packet )
+int server_tx_call_release_exec(LXT_MESSAGE * packet )
+{
+       int i, ret = 0;
+       int call_id = 0;
+       unsigned char *p = 0;
+       STATE state;
+       int call_gen_resp_err =-1;
+
+       log_msg(MSGL_VGSM_INFO, "\n");
+
+       get_current_state_machine( &state );
+
+       if( state.state_type == STATE_STANDBY )
+       {
+               // general error send
+               call_gen_resp_err = check_call_error();
+               //oem_tx_call_gen_resp(call_gen_resp_err);
+               set_general_response_error(0x8000);
+       }
+
+       // STATE_CALL_WAITING_INCOMING
+
+       gsm_call_list_t *callList = malloc(sizeof(gsm_call_list_t));
+
+       p = (unsigned char *)packet->data; // call id
+
+       log_msg(MSGL_VGSM_INFO," release call id = %d \n", p[0]);
+
+       call_id = p[0];
+
+       get_call_list(callList);
+       for (i=0; i < MAX_CALL_COUNT; i++)
+       {
+               if( callList->CallInfo[i].stat == GSM_CALL_STATUS_NONE )
+                       continue;
+               if( callList->CallInfo[i].idx == call_id)
+               {
+                       ret = server_tx_call_release_internal( call_id );
+                       break;
+               }
+       }
+
+       _LEAVE();
+       return ret;
+}
+
+//int TxCall_ExecAnswer()
+int server_tx_call_answer_exec(void)
+{
+       STATE next;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       /*
+          GSM_CallList list;
+
+          get_call_list( &list );
+          if( list.CallCount <= 0 )
+          return 0;
+
+          if( ( list.CallInfo[get_call_id()].stat == GSM_CALL_STATE_ACTIVE ) ||
+          ( list.CallInfo[get_call_id()].stat == GSM_Call_Held ) )
+          return 0;
+        */
+
+       set_current_state( STATE_CALL_WAITING_OUTGOING, GSM_CALL_CMD, GSM_CALL_ANSWER);
+
+       if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+               set_state_machine( next );
+               send_msg();
+       }
+
+       _LEAVE();
+       return 1;
+}
+
+
+int server_tx_call_alert_ind(void *ptr_data, int data_len )
+{
+       //    STATE next;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       //send resp ( no error ) to Phone
+       //      oem_tx_call_gen_resp(0x8000);
+
+       //send noti ( outgoing  )to Phone
+       //      set_current_state( STATE_STANDBY, GSM_CALL_CMD, GSM_CALL_OUTGOING);
+
+       /*      
+               if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+       // call server_tx_call_msg()
+       set_state_machine( next );
+       send_msg();
+       }
+        */
+
+       //send noti ( alert  )to Phone
+       unsigned short call_type = get_call_type();
+
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+       sprintf(sndbuf, "%d,%d,%d,%d,%d", get_call_id() + 1, AT_CALL_DIR_MO, AT_CALL_STAT_ALERTING, AT_CALL_CLASS_VOICE, AT_CALL_MPTY_FALSE);
+
+       set_current_call_status_error( 0x00 );
+
+       set_call_list_status( get_call_id(), 0, GSM_CALL_STATUS_ALERT );
+
+       callback_callist();             // renewal call_list in the EI
+
+       return oem_tx_call_status_noti(sndbuf, strlen(sndbuf));
+}
+
+
+//int release_call( int call_id )
+int server_tx_call_release_internal(int call_id)
+{
+       char data[1];
+       LXT_MESSAGE packet;
+       STATE next;
+       gsm_call_list_t * list = malloc(sizeof(gsm_call_list_t));
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       set_call_id( call_id ); // ³ªÁß¿¡  server_tx_call_status() º¸³»´Â °æ¿ì¿¡, g_call_id¸¦ °¡Á®¿À¹Ç·Î ¿©±â¼­ set ÇؾßÇÑ´Ù.
+
+       TAPIMessageInit(&packet);
+
+       data[0] = 0x03; //0x01 : Outgoing Call, 0x02 : Answer Call, 0x03 : Release Call
+
+       packet.data = data;
+       packet.length = 1;
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_STATE;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       set_current_state( STATE_CALL_RELEASED, GSM_CALL_CMD, GSM_CALL_RELEASE);
+
+       set_ss_state(SS_NONE);
+
+       if( find_next_state( &next, STATE_FLAG_ALL ) ) {
+               set_state_machine( next );
+               send_msg();
+       }
+
+       log_msg(MSGL_VGSM_INFO,"deleted call id : %d \n", call_id);
+       delete_call_list( call_id );
+       get_call_list(list);
+       if(list){
+               packet.data = list;
+               packet.length = sizeof(gsm_call_list_t);
+       }
+       else{
+               packet.data = NULL;
+               packet.length = 0;
+       }
+
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_STATUS_NOTI;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       free(list);
+
+       return 1;
+}
+
+int server_tx_call_all_release(void)
+{
+       int i = 0;
+       gsm_call_list_t * list = malloc(sizeof(gsm_call_list_t));
+       get_call_list(list);
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       for( i=0; i<MAX_CALL_COUNT; ++i ) {
+               if( list->CallInfo[i].stat != GSM_CALL_STATUS_NONE )
+                       server_tx_call_release_internal( list->CallInfo[i].idx );
+       }
+
+       free(list);
+
+       return 1;
+}
+
+
+void server_tx_call_burst_dtmf_noti(int success)
+{
+       int n = 0;
+       unsigned char data[1];
+
+       data[n++] = success;
+
+       oem_tx_call_burst_dtmf_noti(data, n);
+}
+
+int server_tx_call_line_id_resp(void)
+{
+       int n = 0;
+       unsigned char data[1];
+
+       data[n++] = get_call_line_id();
+
+       oem_tx_call_line_id_resp(data, n);
+       return 1;
+}
+
+
+void callback_callist(void)
+{
+       _ENTER();
+
+       LXT_MESSAGE packet;
+       gsm_call_list_t * callList = malloc(sizeof(gsm_call_list_t));
+
+       get_call_list(callList);
+
+       /* send to EI */
+       packet.data = (gsm_call_list_t*)callList;
+       packet.length = sizeof(gsm_call_list_t);
+       packet.group  = GSM_CALL;
+       packet.action = GSM_CALL_CALL_LIST_IND;         // 0x29 in vgsm_phone.h
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+       free(callList);
+       _LEAVE();
+}
diff --git a/vmodem/server/server_tx_data.c b/vmodem/server/server_tx_data.c
new file mode 100644 (file)
index 0000000..1a4700d
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "oem_tx_data.h"
+#include "server_tx_data.h"
+#include "linuxtapi.h"
+#include "at_msg.h"
+#include "vgsm_data.h"
+#include <string.h>
+
+int server_tx_data_CallStatus(LXT_MESSAGE const* packet)
+{
+       int len = 4;
+       unsigned char data[4];
+
+       memset( data, 0, sizeof(unsigned char)*4 );
+
+       if (packet && packet->data) {
+               unsigned char *ptr = (unsigned char *)packet->data;
+
+               data[0] = ptr[0];
+               data[1] = ptr[1];
+               data[2] = ptr[2];
+               data[3] = ptr[3];
+       }
+       else {
+               data[0] = 0x01; /* CID */
+               data[1] = GSM_DATA_TE2_DATA_CALL_RESULT_OK; /* DATA_CALL_STATE */
+               data[2] = GSM_DATA_CALL_REASON_NORMAL; /* DATA_CALL_STATE_RSN */
+               data[3] = GSM_DATA_CALL_INTERNAL_PS_CALL; /* EXTERNAL_PS_CALL */
+       }
+
+       return oem_tx_data_CallStatus(data, len);
+}
+
+int server_tx_data_DataCallStatus(LXT_MESSAGE const* packet)
+{
+    int len = 4;
+    unsigned char data[4];
+
+    memset( data, 0, sizeof(unsigned char)*4 );
+
+    if (packet && packet->data) {
+       unsigned char *ptr = (unsigned char *)packet->data;
+
+       data[0] = ptr[0];
+       data[1] = ptr[1];
+       data[2] = ptr[2];
+       data[3] = ptr[3];
+    }
+    else {
+       data[0] = 0x01; /* CID */
+       data[1] = GSM_DATA_TE2_DATA_CALL_RESULT_OK; /* DATA_CALL_STATE */
+       data[2] = GSM_DATA_CALL_REASON_NORMAL; /* DATA_CALL_STATE_RSN */
+       data[3] = GSM_DATA_CALL_INTERNAL_PS_CALL; /* EXTERNAL_PS_CALL */
+    }
+
+    return oem_tx_data_DataCallStatus(data, len);
+}
diff --git a/vmodem/server/server_tx_display.c b/vmodem/server/server_tx_display.c
new file mode 100644 (file)
index 0000000..db04eff
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "oem_tx_display.h"
+#include "server_tx_display.h"
+#include "server_common_call.h"
+#include "vgsm_display.h"
+#include "vgsm_debug.h"
+#include "linuxtapi.h"
+#include "logmsg.h"
+
+extern unsigned char g_rssi_value;
+extern unsigned char g_hdr_rssi_value;
+extern unsigned char g_battery_level;
+
+int server_tx_display_icon_info_resp(void)
+{
+       unsigned char data[10];
+       int n = 0;
+
+       /* default value (if needed, make global variable) */
+       data[n++] = 0xff; /* ICON_TYPE */
+       data[n++] = g_rssi_value; /* RSSI */
+       data[n++] = g_hdr_rssi_value; /* RSSI */
+       data[n++] = g_battery_level; /* BATTERY */
+
+       return oem_tx_display_icon_info_resp(data, n);
+}
+
+int server_tx_display_icon_info_noti( unsigned char icon_type, unsigned char rssi, unsigned char bat, unsigned char act, unsigned char reg)
+{
+       unsigned char data[10];
+       int n = 0;
+
+       TRACE(MSGL_VGSM_INFO, "icon %02x rssi %02x battery %02x\n", icon_type,rssi, bat);
+       g_rssi_value = rssi;
+       g_battery_level = bat;
+
+       data[n++] = icon_type;
+       data[n++] = g_rssi_value;
+       data[n++] = g_hdr_rssi_value;
+       data[n++] = g_battery_level;
+
+       return oem_tx_display_icon_info_noti(data, n);
+}
+
diff --git a/vmodem/server/server_tx_gprs.c b/vmodem/server/server_tx_gprs.c
new file mode 100644 (file)
index 0000000..d27794f
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "oem_tx_gprs.h"
+#include "linuxtapi.h"
+#include "at_msg.h"
+#include "vgsm_gprs.h"
+#include "db_gprs.h"
+#include "vgsm_gprs.h"
+#include "logmsg.h"
+#include <string.h>
+#include "server_tx_gprs.h"
+#include "at_func.h"
+
+extern GprsConfList g_gprs_conflist;
+extern GSM_SetPDPContext g_pdpcontext;
+
+int server_tx_gprs_ipconf_match(void)
+{
+       int i;
+
+       for (i = 0; i < g_gprs_conflist.num; i++) {
+               log_msg(MSGL_VGSM_INFO,"apn(%s) conflist[%d](%s) \n"
+                               , g_pdpcontext.apn, i, g_gprs_conflist.pentry[i].apn);
+               if (strcmp(g_pdpcontext.apn, g_gprs_conflist.pentry[i].apn) != 0)
+                       return i;
+       }
+
+       return -1;
+}
+
+int server_tx_gprs_IPConfigurationNotify(LXT_MESSAGE const* packet)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       char* pdp_type = NULL;
+
+       switch(g_pdpcontext.pdp_type)
+       {
+       case GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IP:
+               pdp_type = IP;
+               break;
+       case GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_PPP:
+               pdp_type = PPP;
+               break;
+       case GSM_GPRS_DEFINE_PDP_CONTEXT_P_TYPE_IPV6:
+               pdp_type = IPV6;
+               break;
+       default:
+               pdp_type = UNKNOWN;
+               break;
+       }
+
+       // search database
+       vgsm_gprs_database_restore();
+
+       sprintf(sndbuf, "%s%d,%s,%s,%s,%d,%d%s", CGDCONT, g_pdpcontext.cid, pdp_type, g_pdpcontext.apn, g_pdpcontext.pdp_addr, g_pdpcontext.d_comp, g_pdpcontext.h_comp, CRLF);
+       
+       log_msg(MSGL_VGSM_INFO,"packet:%s, length:%d\n", sndbuf, strlen(sndbuf));
+
+       return oem_tx_gprs_IPConfigurationNotify(sndbuf, strlen(sndbuf));
+}
+
+
diff --git a/vmodem/server/server_tx_network.c b/vmodem/server/server_tx_network.c
new file mode 100644 (file)
index 0000000..36c49ba
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*
+/////////////////////////////////////////////////////////////////////
+// at_tx_network.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "server_common_network.h"
+#include "oem_tx_network.h"
+#include "server_tx_network.h"
+#include "vgsm_network.h"
+#include "vgsm_debug.h"
+#include "linuxtapi.h"
+
+//int TxNET_PLMNList(LXT_MESSAGE const* packet, int cmd_type)
+int server_tx_net_plmn_list_noti(LXT_MESSAGE const* packet)
+{
+       VGSM_DEBUG("\n");
+
+       unsigned char *data = 0;
+       int ret = 0, len = 0;
+
+       unsigned char *ptr = (unsigned char *)packet->data;
+       int i = 0;
+
+       len = 1+(ptr[0]*8);
+       data = malloc(sizeof(unsigned char)*len);
+
+       for(i=0; i<len; ++i)
+           data[i] = ptr[i];
+
+       set_plmn_list( data, len ); //network.db clean and update
+
+       ret = oem_tx_net_plmn_list_noti(data, len);
+
+       if(data)
+               free( data );
+
+       return ret;
+
+}
+
+int server_tx_net_reg_noti(LXT_MESSAGE const* packet)
+{
+       VGSM_DEBUG("\n");
+
+       int ret = 0, len = 11;
+       unsigned char data[len ];
+
+       memset( data, 0, sizeof(unsigned char)*len );
+
+       if (packet && packet->data) 
+       {
+               VGSM_DEBUG("\n");
+               unsigned char *ptr = (unsigned char *)packet->data;
+               int i = 0;
+
+               for(i=0; i<len; ++i)
+                   data[i] = ptr[i];
+
+               set_network_registration( data, len );
+       }
+       else  // it is the cast that  net reg noti is sended after net selection set.
+       {
+               VGSM_DEBUG("\n");
+               gsm_network_reg_t *reg = get_network_registration();
+
+               data[0] = reg->act;                             /* ACT */
+               data[1] = reg->service_domain;  /* SERVICE_DOMAIN */
+               data[2] = reg->reg_status;              /* REG_STATUS */
+               data[3] = reg->edge_support;    /* EDGE_SUPPORT */
+               data[4] = reg->lac[0];                  /* LAC */
+               data[5] = reg->lac[1];                  /* LAC */
+               data[6] = reg->cell_id[0];              /* CELL-ID */
+               data[7] = reg->cell_id[1];              /* CELL-ID */
+               data[8] = reg->cell_id[2];              /* CELL-ID */
+               data[9] = reg->cell_id[3];              /* CELL-ID */
+               
+               data[10] = reg->rej_cause;
+       }
+
+       ret = oem_tx_net_reg_noti(data, len);
+
+       return ret;
+}
+    
+//int TxNET_CurrentPLMN( LXT_MESSAGE const* packet)
+int server_tx_net_current_plmn_noti( LXT_MESSAGE const* packet)
+{
+       VGSM_DEBUG("\n");
+       int ret = 0, len = 9;
+       unsigned char data[len];
+       unsigned char *p = (unsigned char *)(packet->data);
+
+       memset(data, 0, sizeof(data));
+
+       memcpy(data, p, len);
+
+       ret = oem_tx_net_current_plmn_noti(data, len);
+
+       return ret;
+}
+
+int server_tx_net_current_nitz_noti(LXT_MESSAGE const* packet)
+{
+       VGSM_DEBUG("\n");
+       int ret = 0, len;
+       unsigned char *p = (unsigned char *)(packet->data);
+       gsm_network_nitz_info_t net_identity_info;
+
+       len = sizeof(gsm_network_nitz_info_t);
+
+       memcpy(&net_identity_info, p, sizeof(net_identity_info));
+
+       set_network_identity( net_identity_info);
+
+       ret = oem_tx_net_current_nitz_noti(p, len);
+
+       return ret;
+}
diff --git a/vmodem/server/server_tx_phonebook.c b/vmodem/server/server_tx_phonebook.c
new file mode 100644 (file)
index 0000000..d397d0a
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_phone.h"
+#include "vgsm_pb.h"
+#include "oem_tx_phonebook.h"
+#include "server_tx_phonebook.h"
+#include "db_phonebook.h"
+
+#include "misc.h"      // TAPIMessageInit()
+#include "linuxtapi.h"
+#include "vgsm_phone.h"
+#include "phoneserver.h"
+
+/*
+*      phonebook access¿¡ ´ëÇÑ °á°ú¸¦ EI¿Í simulator ¾ç¹æÇâÀ¸·Î º¸³½´Ù.        => EI·Î¸¸ º¸³½!!!!
+*      flag : 0 -> EI UI + simulator
+*              1,2 -> EI UI
+*/
+
+void callback_pb_action(PB *pb)
+{
+       LXT_MESSAGE packet;
+
+       TAPIMessageInit(&packet);
+       packet.data = malloc(sizeof(PB));
+       packet.group = GSM_SIM;
+       packet.length = sizeof(PB);
+       packet.action = GSM_SIM_ERR_ADD_NOTI;
+
+       memcpy(packet.data,pb,packet.length);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+}
+
+void server_tx_sim_pb_get_access_RX_UI(PB *pb,int flag)
+{
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+
+       //RX Eventenjector UI
+       packet.data     =       (unsigned char *)malloc(sizeof(PB));
+       packet.group    =       GSM_SIM;
+       packet.length   =       sizeof(PB);
+
+       switch(flag)
+       {
+               case 0:
+                       packet.action = GSM_SIM_GET_PB_DB_REQ;
+               break;
+
+               case 1:
+                       packet.action = GSM_SIM_ADD_EVENT_PB_DB_REQ;
+               break;
+
+               case 2:
+                       packet.action = GSM_SIM_DELETE_EVENT_PB_DB_REQ;
+               break;
+       }
+
+       memcpy(packet.data,pb, packet.length);
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+}
+
+
+int server_tx_sim_pb_get_all_db(PB *pb,int cnt)
+{
+       LXT_MESSAGE packet;
+       TAPIMessageInit(&packet);
+       int length;
+
+       //length = cnt * 62;
+       length = cnt * sizeof(PB);
+
+       //packet.data = (PB *) malloc(sizeof(PB)*cnt);
+
+       packet.data     = (PB *)pb;
+//     packet.data =   pb;
+       packet.group    = GSM_SIM;
+       packet.length   = length ;
+       packet.action   = GSM_SIM_GET_ALL_PB_DB_REQ;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+/*
+       if(packet.data)
+               free(packet.data);
+*/
+       return  1;
+
+}
diff --git a/vmodem/server/server_tx_power.c b/vmodem/server/server_tx_power.c
new file mode 100644 (file)
index 0000000..833e835
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/*  server_tx_power.c */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "phoneserver.h"
+#include "vgsm_phone.h"
+#include "linuxtapi.h"
+#include "gsm.h"
+#include "oem_tx_power.h"
+#include "server_tx_power.h"
+
+#include "server_tx_security.h"
+#include "at_func.h"
+#include "at_send.h"
+#include "flight.h"
+
+#include "server_common_network.h"
+#include "server_tx_network.h"
+#include "server_tx_display.h"
+
+extern unsigned char g_battery_level;
+
+void* change_level(void *data);
+
+int server_tx_power_up_resp(void)
+{
+       char sndbuf[SEND_BUF_SIZE];
+       memset(sndbuf, '\0', sizeof(sndbuf));
+
+       LXT_MESSAGE packet;
+       packet.group  = GSM_POWER;
+       packet.action = GSM_POWER_MODEM_ON_REQ;
+       packet.length =  0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       FuncServer->Cast( &GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet );   //&ServerHandle->server_cast
+
+       sprintf(sndbuf, "%s%d%s", CPAS, AT_GSM_PWR_UP_READY, CRLF);
+       oem_tx_power_up_resp(sndbuf, strlen(sndbuf));   // power up noti
+
+       /*  sim init processing   */
+       server_tx_sim_init_start();
+
+       // sim init
+       memset(sndbuf, '\0', sizeof(sndbuf));
+        sprintf(sndbuf, "%s%s%s", CPIN, STINIT_COMPL, CRLF);
+        at_msg_send(ACK_SEQ_NOTIFICATION, sndbuf, strlen(sndbuf));
+        return server_common_after_sim_init();
+}
+
+/* To support Flight mode on/off */
+int server_tx_online_noti(unsigned char status)
+{
+       int nrn_len = 11;
+       int pon_len = 0;
+       unsigned char pon_data[10];     /* power online noti */
+       unsigned char nrn_data[11];     /* net reg noti */
+       unsigned char rssi = 0x05;
+
+       TRACE(MSGL_VGSM_INFO, "status = %d\n", status);
+
+       memset( nrn_data, 0, sizeof(unsigned char)*nrn_len );
+
+       gsm_network_reg_t *reg = get_network_registration();
+
+       nrn_data[0] = reg->act;             /* ACT */
+       nrn_data[1] = reg->service_domain;  /* SERVICE_DOMAIN */
+       nrn_data[2] = reg->reg_status;      /* REG_STATUS */
+       nrn_data[3] = reg->edge_support;    /* EDGE_SUPPORT */
+       nrn_data[4] = reg->lac[0];          /* LAC */
+       nrn_data[5] = reg->lac[1];          /* LAC */
+       nrn_data[6] = reg->cell_id[0];      /* CELL-ID */
+       nrn_data[7] = reg->cell_id[1];      /* CELL-ID */
+       nrn_data[8] = reg->cell_id[2];      /* CELL-ID */
+       nrn_data[9] = reg->cell_id[3];      /* CELL-ID */
+       nrn_data[10] = reg->rej_cause;
+
+       if(status == AT_GSM_PWR_PHONE_ONLINE_OFF){
+
+               nrn_data[0] = GSM_NET_ACT_NOTSPECIFIED; /* ACT */
+               nrn_data[2] = GSM_NET_REG_STAT_NOT_REG; /* reg_status */
+               pon_data[pon_len++] = AT_GSM_PWR_PHONE_RSN_ONLINE_OFF;
+               rssi = 0x00;
+
+       }else if(status == AT_GSM_PWR_PHONE_ONLINE_ON){
+
+               nrn_data[0] = GSM_NET_ACT_UTRAN;                        /* ACT */
+               nrn_data[2] = GSM_NET_REG_STAT_REG_HOME;        /* reg_status */
+               pon_data[pon_len++] = AT_GSM_PWR_PHONE_RSN_ONLINE_ON;
+               rssi = 0x05; /* initial value */
+
+       }else if(status == AT_GSM_PWR_PHONE_ONLINE_MAX){
+               pon_data[pon_len++] = AT_GSM_PWR_PHONE_RSN_ONLINE_MAX;
+       }else{
+               pon_data[pon_len++] = AT_GSM_PWR_PHONE_RSN_ONLINE_FAIL;
+       }
+
+       /* change act & reg status */
+       set_network_registration( nrn_data, nrn_len ); /* change ACT & status */
+
+       server_tx_net_reg_noti(NULL); /* return */
+
+       oem_tx_power_online_noti(pon_data, pon_len);
+
+       server_tx_display_icon_info_noti(AT_GSM_DISP_ICON_TYPE_ALL, rssi, g_battery_level, 0, 0);
+
+       return 1;
+}
+
+int server_tx_battery_status_noti(unsigned char level)
+{
+       unsigned char data[1];
+       int n = 0;
+
+       TRACE(MSGL_VGSM_INFO, "level = %d\n", level);
+
+       assert(level <= 5);
+
+       data[n++] = level;
+
+       return oem_tx_battery_status_noti(data, n);
+}
diff --git a/vmodem/server/server_tx_security.c b/vmodem/server/server_tx_security.c
new file mode 100644 (file)
index 0000000..3494799
--- /dev/null
@@ -0,0 +1,399 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_sim.h"
+#include "state.h"
+#include "server_common.h"
+#include "server_common_security.h"
+#include "db_security.h"
+#include "server_tx_security.h"
+#include "oem_tx_security.h"
+
+#include "misc.h"      // TAPIMessageInit()
+#include "linuxtapi.h"
+#include "vgsm_phone.h"
+#include "phoneserver.h"
+
+int server_tx_sim_init_start(void)
+{
+       int status;
+
+       SIM_DEBUG("\n");
+       //not used
+       //server_tx_sim_sec_card_type_noti();
+
+       //load from sim db
+       db_sim_sec_restore(VGSM_SIMTypeLoad);
+
+       status = server_sec_get_sec_status();
+
+       SIM_DEBUG("boot time sim status =[%x]\n", status);
+
+       if(status       ==      GSM_SIM_READY) {
+               server_tx_sim_sec_disable_facility();
+       }
+       else {
+               server_tx_sim_sec_enable_facility(status);
+       }
+
+       return 1;
+}
+
+
+int server_tx_sim_sec_disable_facility(void)
+{
+       unsigned char *p = 0;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG("\n");
+       SIM_DEBUG("pin lock disable mode - it means key not needed(ready) \n");
+
+       TAPIMessageInit(&packet);
+
+       packet.data     =       malloc(2);
+       p                       =       (unsigned char *)(packet.data);
+
+       packet.group    =       GSM_SIM;
+       packet.length   =       1 + 1 ;
+       packet.action   =       GSM_SIM_FACILITY_RES;
+
+       //server_sec_set_sec_status(GSM_SIM_READY);
+       //set_current_state( STATE_SIM_READY, GSM_SEC_CMD, GSM_SEC_PIN_STATUS);
+
+       server_tx_sim_sec_pin_status_noti(STATE_ON, STATE_SIM_READY);
+
+       p[0]    =       0;
+       p[1]    =       GSM_SIM_READY;
+
+       /*      ++ 2008-09-29
+       */
+       //FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return 1;
+}
+
+
+int server_tx_sim_sec_enable_facility(int status)
+{
+       unsigned char *p = 0;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG("\n");
+       SIM_DEBUG("sim status =[%d]\n", status);
+
+       TAPIMessageInit(&packet);
+
+       packet.data     =       malloc(2);
+       p                       =       (unsigned char *)(packet.data);
+
+       packet.group    =       GSM_SIM;
+       packet.length   =       1 + 1;
+       packet.action   =       GSM_SIM_FACILITY_RES;
+
+       p[0]    =       1;
+       p[1]    =       status;
+
+       switch (status)
+       {
+       /*
+               case GSM_SIM_READY :
+                       set_current_state(STATE_SIM_READY, GSM_SEC_CMD, GSM_SEC_PIN_STATUS, 0 );
+               break;
+       */
+               case GSM_SIM_PIN_REQ_STATE :
+                       server_tx_sim_sec_pin_status_noti(STATE_ON, STATE_SIM_PIN);
+               break;
+
+               case GSM_SIM_PUK_REQ :
+                       server_tx_sim_sec_pin_status_noti(STATE_ON, STATE_SIM_PUK);
+               break;
+
+               case GSM_SIM_FRIZEN :
+                       server_tx_sim_sec_pin_status_noti(STATE_ON, STATE_SIM_FRIZEN);
+               break;
+
+               case GSM_SIM_NO_SIM :
+                       server_tx_sim_sec_pin_status_noti(STATE_ON, STATE_SIM_NO_SIM);
+               break;
+
+               default :
+                       SIM_DEBUG("No handled sim status=[%x]", status);
+               break;
+       }
+
+       //server_tx_sim_sec_pin_status_noti();
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return 1;
+}
+
+
+////////////////////////// 090512 //////////////////////////////////////////
+int server_tx_sim_data_get_db(unsigned char *sim_data, int len)
+{
+       int length;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG(" len_data :%d\n",len);
+
+       TAPIMessageInit(&packet);
+
+       //length = 9+9+9+9+4+4+4+4+4+4+4+4; //68
+       length = len; //43
+
+       packet.data     =       sim_data;
+       packet.group    =       GSM_SIM;
+       packet.length   =       length ;
+       packet.action   =       GSM_SIMDATA_RES;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return  1;
+}
+
+int server_tx_sim_info_get_db(unsigned char *sim_info, int len)
+{
+       int length;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG(" len_info : %d\n",len);
+
+       TAPIMessageInit(&packet);
+
+       //length = 9+9+9+9+4+4+4+4+4+4+4+4; //68
+       length = len; //43
+
+       packet.data     =       sim_info;
+       packet.group    =       GSM_SIM;
+       packet.length   =       length ;
+       packet.action   =       GSM_SIMINFO_RES;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return  1;
+}
+//////////////////////////////////////////////////////////////////////////////////
+
+int server_tx_sim_sec_get_db(SimSecurity *sim_sec)
+{
+       int length;
+       LXT_MESSAGE packet;
+
+       SIM_DEBUG("\n");
+
+       TAPIMessageInit(&packet);
+
+       length = 9+9+9+9+4+4+4+4+4+4+4+4; //68
+
+       packet.data     =       malloc(sizeof(SimSecurity));
+       packet.data     =       sim_sec;
+       packet.group    =       GSM_SIM;
+       packet.length   =       length ;
+       packet.action   =       GSM_SIM_GET_SIM_DB_RES;
+
+       FuncServer->Cast(&GlobalPS, LXT_ID_CLIENT_EVENT_INJECTOR, &packet);
+
+       if(packet.data)
+               free(packet.data);
+
+       return  1;
+}
+
+
+int server_tx_sim_sec_card_type_noti(void)
+{
+       int ret = 0;
+       int data_size = 1;
+       unsigned char *pdata = 0;
+
+       SIM_DEBUG("\n");
+
+       pdata = malloc(sizeof(unsigned char)*data_size);
+
+       pdata[0] = GSM_SEC_SIM_3G;
+
+       ret = oem_tx_sim_sec_card_type_noti(pdata, data_size);
+
+       if( pdata )
+               free( pdata );
+
+       return ret;
+}
+
+
+/* this API is for NOTIFICATION of SIM PIN STATUS      */
+int server_tx_sim_sec_pin_status_noti(STATE_TYPE before_state, STATE_TYPE current_state)
+{
+       int ret = 0;
+       int data_size = 2;
+       unsigned char *pdata = 0;
+
+       int send_sim_init_msg   =       0;
+
+//     STATE current;
+//     STATE prev;
+
+       SIM_DEBUG("\n");
+
+       pdata = malloc(sizeof(unsigned char)*data_size);
+
+//     get_current_state_machine( &current );
+//     get_prev_state_machine( &prev );
+
+//     SIM_DEBUG("STATE_TYPE(prev)=%d \n", STATE_TYPE(prev));
+
+       switch(before_state)
+       {
+               //add STATE_STANDBY for test.
+               case STATE_STANDBY :
+               case STATE_ON:
+               {
+                       switch(current_state)
+                       {
+                               case STATE_SIM_READY :
+                               {
+                                       /*      lock disableÀÏ °æ¿ì modem(vgsm)ÀÌ simulator·Î º¸³»Áà¾ß ÇÒ NOTI
+                                               1) GSM_SEC_LOCK_TYPE_READY
+                                               2) GSM_SEC_SIM_INIT_COMPLETED
+                                               3) GSM_SEC_PB_INIT_COMPLETED    - ÇöÀç phonebookÀÌ ¹Ì±¸Çö »óŶ󠺸³»Áö ¾ÊÀ½.
+                                       */
+                                       pdata[0]        =       GSM_SEC_LOCK_TYPE_READY;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+#if 0 //20110714 tmp 
+                                       oem_tx_sim_sec_pin_status_noti(pdata, data_size);
+
+                                       sleep(3);
+
+                                       pdata[0]        =       GSM_SEC_SIM_INIT_COMPLETED;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                                       send_sim_init_msg       =       1;
+
+                               /*
+                                       oem_tx_sim_sec_pin_status_noti(pdata, data_size);
+
+                                       pdata[0]        =       GSM_SEC_PB_INIT_COMPLETED;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                               */
+#endif
+                               }
+                               break;
+
+                               case STATE_SIM_PIN :
+                               {
+                                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_PIN;
+                               }
+                               break;
+
+                               case STATE_SIM_PUK :
+                               {
+                                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_PUK;
+                               }
+                               break;
+
+                               case STATE_SIM_FRIZEN :
+                               {
+                                       pdata[0]        =       GSM_SEC_LOCK_TYPE_SC;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_PERM_BLOCKED;
+                               }
+                               break;
+
+                               case STATE_SIM_NO_SIM :
+                               {
+                                       pdata[0]        =       GSM_SEC_LOCK_TYPE_NO_SIM;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;      //to be considered...
+                               }
+                               break;
+
+                               default :
+                                       SIM_DEBUG("No handled current_state=[%d]\n",current_state);
+                                       break;
+
+                       }
+               }
+               break;
+
+               case STATE_SIM_PIN :
+               case STATE_SIM_PUK :
+               {
+                       switch(current_state)
+                       {
+                               case  STATE_SIM_PIN_OK :
+                               case  STATE_SIM_PUK_OK:
+                               {
+                                       pdata[0]        =       GSM_SEC_SIM_INIT_COMPLETED;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                                       send_sim_init_msg       =       1;
+                               /*
+                                       oem_tx_sim_sec_pin_status_noti(pdata, data_size);
+
+                                       pdata[0]        =       GSM_SEC_PB_INIT_COMPLETED;
+                                       pdata[1]        =       GSM_SEC_LOCK_KEY_UNLOCKED;
+                               */
+                               }
+                               break;
+
+                               default:
+                                       SIM_DEBUG("No handled current_state=[%d]\n",current_state);
+                                       break;
+                       }
+               }
+               break;
+
+               default:
+               {
+                       SIM_DEBUG("No handled case in before_state = [%d]\n", before_state);
+               }
+               break;
+
+       }
+
+       ret     =       oem_tx_sim_sec_pin_status_noti(pdata, data_size);
+       if( pdata )
+               free( pdata );
+
+       return ret;
+}
+
diff --git a/vmodem/server/server_tx_sms.c b/vmodem/server/server_tx_sms.c
new file mode 100644 (file)
index 0000000..e3afdf9
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <assert.h>
+
+#include "oem_tx_sms.h"
+#include "server_tx_sms.h"
+#include "server_common_call.h"
+#include "linuxtapi.h"
+#include "at_msg.h"
+#include "sms_util.h"
+#include "logmsg.h"
+#include "at_func.h"
+#include <string.h>
+#include <stdio.h>
+
+extern int smsSentStatus;
+
+void   server_tx_sms_deviceReady(LXT_MESSAGE const* packet)
+{
+       oem_tx_sms_deviceReady(NULL, 0);
+}
+
+static int sms_msg_hook_modify(void * data, int len)
+{    
+       int position;
+       unsigned char *rawdata = (unsigned char *)data;
+       TPDU_SMS_SUBMIT tpdu_submit;
+       TmDateTime SCTimeStamp;
+       time_t c_time;
+       struct tm *tmTime;
+       unsigned char timeStamp[20];
+
+       memset(&tpdu_submit, 0, sizeof(TPDU_SMS_SUBMIT));
+       TRACE(MSGL_VGSM_INFO, "sms_msg_hook_modify start with len(%d) \n", len);
+
+       /* Mobile Oriented sms (0) */
+       /* return position : start point of user data */
+       position = DecodeSmsSubmitTpdu(&tpdu_submit, len, (char *)rawdata, 0);
+       TRACE(MSGL_VGSM_INFO, "DecodeSmsSubmitTpdu => [return %d]\n", position);
+
+       TRACE(MSGL_VGSM_INFO, "[%d][%s]\n"
+                       , tpdu_submit.desAddr.dialnumLen, tpdu_submit.desAddr.diallingNum);
+       TRACE(MSGL_VGSM_INFO, "[%d][%s]\n"
+                       , tpdu_submit.udl, tpdu_submit.userData);
+
+       /* decode time stamp */
+       position = DecodeSmsSubmitTpdu(&tpdu_submit, len, (char *)rawdata, 0);
+       /* time value is located in (start point of user data) -1  */
+       SmsUtilDecodeTimeStamp( &rawdata[(position-1)], &SCTimeStamp );
+       TRACE(MSGL_VGSM_INFO, "Event Injector time [%d-%d-%d, %d:%d:%d]\n"
+                       , SCTimeStamp.year, SCTimeStamp.month, SCTimeStamp.day
+                       , SCTimeStamp.hour, SCTimeStamp.minute, SCTimeStamp.second);
+
+       /*TP-SCTS*/
+       c_time = time((time_t *)NULL);
+       /* setting utc time => check ? */
+       tmTime = gmtime(&c_time);
+       SCTimeStamp.year = tmTime->tm_year+1900;
+       SCTimeStamp.month = tmTime->tm_mon+1;
+       SCTimeStamp.day = tmTime->tm_mday;
+       SCTimeStamp.hour = tmTime->tm_hour;
+       SCTimeStamp.minute = tmTime->tm_min;
+       SCTimeStamp.second = tmTime->tm_sec;
+
+       SmsUtilEncodeTimeStamp(&SCTimeStamp, timeStamp);
+
+       TRACE(MSGL_VGSM_INFO, "Modify time [%d-%d-%d, %d:%d:%d]\n"
+                       , SCTimeStamp.year, SCTimeStamp.month, SCTimeStamp.day
+                       , SCTimeStamp.hour, SCTimeStamp.minute, SCTimeStamp.second);
+
+       /* modify time area*/
+       /* time value is located in (start point of user data) -1  */
+       memcpy(&rawdata[(position-1)], timeStamp, 7);
+
+       return 0;
+}
+
+int server_tx_sms_notiIncomingMsg(LXT_MESSAGE const* packet)
+{
+       int i = 0, len = packet->length;
+        unsigned char rawdata[0x105], *data = (unsigned char *)packet->data;
+
+        TRACE(MSGL_VGSM_INFO, "\n");
+
+        log_msg(MSGL_VGSM_INFO,"[len: %02x]\n", len);
+        for(i=0; i<len; i=i+2)
+                log_msg(MSGL_VGSM_INFO,"[%02x] [%02x]\n", data[i], data[i+1]);
+        log_msg(MSGL_VGSM_INFO,"\n");
+
+        assert(len < 0x100);
+
+        int n = 0;
+        memset(rawdata, '\0', 0x105);
+        sprintf((char*)rawdata, "%s%d", CMT, len);
+        strcat((char*)rawdata, CRLF);
+        n += strlen((char*)rawdata);
+
+        memcpy(&rawdata[n], data, len); // DATA
+        sms_msg_hook_modify(&rawdata[n], len);
+        n += len;
+
+        return oem_tx_sms_NotiIncomingMsg(rawdata, n);
+}
+
+int server_tx_sms_send_msg(unsigned char *data, unsigned char length)
+{
+       char rawdata[0x100 + 5];
+       int n = 0;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       sprintf(rawdata, "%s1%s", CMGS, CRLF);
+       n += strlen(rawdata);
+
+       return oem_tx_sms_sendMsg(rawdata, n);
+}
+
+// FIXME: check caller
+int server_tx_sms_ReceiveAckMsg(LXT_MESSAGE const* packet)
+{
+       assert(packet->data);
+       assert(packet->length >= 2);
+
+       unsigned char *report = malloc(packet->length + 1);
+       int n = 0;
+
+       report[n++] = 0x02; // GSM
+
+       memcpy(&report[n], packet->data, packet->length);
+       n += packet->length;
+
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       int r = oem_tx_sms_sendDeliverReport(report, n);
+       free(report);
+       return r;
+}
+
+
+int server_tx_sms_NotiIncomingCBMsg(LXT_MESSAGE const * packet)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       unsigned char * data = (unsigned char *)packet->data;
+       int len = packet->length;
+
+       unsigned char rawdata[510];
+       rawdata[0] = 0x02; // GSM
+       rawdata[1] = len;
+       memcpy(&rawdata[2], data, len);
+
+       return oem_tx_sms_sendCBSMsg(rawdata, len + 2);
+}
diff --git a/vmodem/server/server_tx_ss.c b/vmodem/server/server_tx_ss.c
new file mode 100644 (file)
index 0000000..de53136
--- /dev/null
@@ -0,0 +1,637 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+/////////////////////////////////////////////////////////////////////
+// server_tx_ss.c
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "vgsm_ss.h"  // for ss_state_e_type
+#include "misc.h"      // LXT_MESSAGE(), TAPIMessageInit()
+#include "vgsm_phone.h"
+#include "server_tx_call.h"
+#include "server_common_call.h"
+#include "server_common_ss.h"
+#include "server_tx_ss.h"
+#include "server_rx_ss.h"
+#include "oem_tx_ss.h"
+#include "vgsm_debug.h"
+#include "logmsg.h"
+#include "db_ss.h"
+
+// 090406 /////////////////////////////////////////////////////////////////////////////////////////
+void server_tx_ss_cw_set_req ( LXT_MESSAGE *packet)
+{
+       int *a;
+
+       call_waiting_entry_t * entry = malloc(sizeof(call_waiting_entry_t));
+       memset(entry, 0, sizeof(call_waiting_entry_t));
+
+       TRACE(MSGL_VGSM_SS,"\n");
+       a = (int*)packet->data;
+       TRACE(MSGL_VGSM_SS,"class: %d\n", a[0]);
+       TRACE(MSGL_VGSM_SS,"status: %d\n", a[1]);
+
+       if (a[1] == 0)                          // Activation
+       {
+               entry->ss_mode = SS_MODE_ACT;
+
+               switch (a[0])
+               {
+                       case 0:                         // All
+                               entry->tel_class = -1;
+
+                               break;
+                       case 1:                         // Voice
+                               entry->tel_class = 1;
+
+                               break;
+                       case 2:                         // Fax
+                               entry->tel_class = 4;
+
+                               break;
+                       case 3:                         // SMS
+                               entry->tel_class = 8;
+
+                               break;
+                       case 4:                         // async
+                               entry->tel_class = 32;
+
+                               break;
+               }
+       }
+       else if(a[1] == 1)                      // Deactivation
+       {
+               entry->ss_mode = SS_MODE_DEACT;
+
+               switch (a[0])
+               {
+                       case 0:                         // All
+                               entry->tel_class = -1;
+
+                               break;
+                       case 1:                         // Voice
+                               entry->tel_class = 1;
+
+                               break;
+                       case 2:                         // Fax
+                               entry->tel_class = 4;
+
+                               break;
+                       case 3:                         // SMS
+                               entry->tel_class = 8;
+
+                               break;
+                       case 4:                         // async
+                               entry->tel_class = 32;
+
+                               break;
+               }
+       }
+       else
+       {
+               TRACE(MSGL_VGSM_SS,"status isn't 0 or 1 : %d\n", a[1]);
+       }
+
+       vgsm_ss_database_add(SS_CMD_CW, entry);
+
+       init_ss_info_re();                                              // restore data list in EI
+}
+
+void server_tx_ss_cf_set_req ( LXT_MESSAGE *packet)
+{
+       // insert cfdata here
+       int *a;
+
+       call_forwarding_entry_t * entry = malloc(sizeof(call_forwarding_entry_t));
+       memset(entry, 0, sizeof(call_forwarding_entry_t));
+
+       TRACE(MSGL_VGSM_SS,"\n");
+       a = (int*)packet->data;
+       TRACE(MSGL_VGSM_SS,"code: %d, number: %d\n", a[0], a[1]);
+       TRACE(MSGL_VGSM_SS,"BC: %d, Timer: %d\n", a[2], a[3]);
+       TRACE(MSGL_VGSM_SS,"status: %d\n", a[4]);
+
+       if (a[4] == 0)                          // Registeration
+       {
+               entry->ss_mode = SS_MODE_REG;
+
+               switch (a[0])
+               {
+                       case 0:                         // unconditional
+                       {
+                               entry->type = 0x01;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                       }
+                       break;
+                       case 1:                         // when busy
+                       {
+                               entry->type = 0x02;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                       }
+
+                       break;
+                       case 2:                         // no rely
+                       {
+                               entry->type = 0x03;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                       }
+
+                       break;
+                       case 3:                         // Not reachable
+                       {
+                               entry->type = 0x04;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                       }
+
+                       break;
+               }
+       }
+       else if(a[4] == 1)                      // Deregisteration
+       {
+               entry->ss_mode = SS_MODE_DEREG;
+
+               switch (a[0])
+               {
+                       case 0:                         // unconditional
+                       {
+                               entry->type = 0x01;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                               log_msg(MSGL_VGSM_INFO,"uncon[ %d : %d] \n",entry->type, entry->tel_class );
+                       }
+
+                       break;
+                       case 1:                         // when busy
+                       {
+                               entry->type = 0x02;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                               log_msg(MSGL_VGSM_INFO,"when[ %d : %d] \n",entry->type, entry->tel_class );
+                       }
+
+                       break;
+                       case 2:                         // no rely
+                       {
+                               entry->type = 0x03;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                               log_msg(MSGL_VGSM_INFO,"norely[ %d : %d] \n",entry->type, entry->tel_class );
+                       }
+
+                       break;
+                       case 3:                         // Not reachable
+                       {
+                               entry->type = 0x04;
+                               switch(a[2])
+                               {
+                                       case 0:
+                                               entry->tel_class = -1;
+                                       break;
+                                       case 1:
+                                               entry->tel_class = 0x11;
+                                       break;
+                                       case 2:
+                                               entry->tel_class = 0x13;
+                                       break;
+                                       case 3:
+                                               entry->tel_class = 0x16;
+                                       break;
+                                       case 4:
+                                               entry->tel_class = 0x21;
+                                       break;
+                               }
+                               log_msg(MSGL_VGSM_INFO,"notreach[ %d : %d] \n",entry->type, entry->tel_class );
+                       }
+
+                       break;
+               }
+       }
+       else
+       {
+               TRACE(MSGL_VGSM_SS,"status isn't 0 or 1 : %d\n", a[4]);
+       }
+
+       sprintf(entry->number,"%d", a[1]);
+       entry->replyTime=a[3];
+
+       vgsm_ss_database_add(SS_CMD_CF, entry);
+
+       init_ss_info_re();                                              // restore data list in EI
+}
+
+void server_tx_ss_cb_set_req ( LXT_MESSAGE *packet)
+{
+       // insert cwdata here
+       int *a;
+
+       call_barring_entry_t * entry = malloc(sizeof(call_barring_entry_t));
+       memset(entry, 0, sizeof(call_barring_entry_t));
+
+       TRACE(MSGL_VGSM_SS,"\n");
+       a = (int*)packet->data;
+       TRACE(MSGL_VGSM_SS,"code: %d\n", a[0]);
+       TRACE(MSGL_VGSM_SS,"passwd: %d\n", a[1]);
+       TRACE(MSGL_VGSM_SS,"status: %d\n", a[2]);
+       entry->tel_class = -1;
+
+       if (a[2] == 0)                          // Activation
+       {
+               entry->ss_mode = SS_MODE_ACT;
+
+               switch (a[0])
+               {
+                       entry->tel_class = -1;
+                       case 0:
+                               entry->type = 0x01;                             // BAOC
+                       break;
+                       case 1:
+                               entry->type = 0x02;                             // BOIC
+                       break;
+                       case 2:
+                               entry->type = 0x03;                             // BAOIC
+                       break;
+                       case 3:
+                               entry->type = 0x04;                             // BAIC
+                       break;
+                       case 4:
+                               entry->type = 0x05;                             // BAIC when roam
+                       break;
+               }
+       }
+       else if(a[2] == 1)                      // Deactivation
+       {
+               entry->ss_mode = SS_MODE_DEACT;
+               switch (a[0])
+               {
+                       entry->tel_class = -1;
+                       case 0:
+                               entry->type = 0x01;                             // BAOC
+                       break;
+                       case 1:
+                               entry->type = 0x02;                             // BOIC
+                       break;
+                       case 2:
+                               entry->type = 0x03;                             // BAOIC
+                       break;
+                       case 3:
+                               entry->type = 0x04;                             // BAIC
+                       break;
+                       case 4:
+                               entry->type = 0x05;                             // BAIC when roam
+                       break;
+               }
+       }
+       else
+       {
+               TRACE(MSGL_VGSM_SS,"status isn't 0 or 1 : %d\n", a[2]);
+       }
+
+       vgsm_ss_database_add(SS_CMD_CB, entry);
+
+       init_ss_info_re();                                              // restore data list in EI
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+void server_tx_ss_ccfc_set_req ( LXT_MESSAGE *packet)
+{
+}
+
+void server_tx_ss_aoc_get_req ( LXT_MESSAGE *packet) // 090215
+{
+       TRACE(MSGL_VGSM_SS,"\n");
+
+       // a = (int*)packet->data;
+
+       // TRACE(MSGL_VGSM_SS,"data: %d\n", a[0]);
+       server_rx_ss_aoc_get();                                                         // checkpoint 090215
+}
+
+void server_tx_ss_aoc_set_req ( LXT_MESSAGE *packet) // bychang
+{
+       int *a;
+
+       TRACE(MSGL_VGSM_SS,"\n");
+       a = (int*)packet->data;
+       TRACE(MSGL_VGSM_SS,"acm: %d\n", a[0]);
+       TRACE(MSGL_VGSM_SS,"ccm: %d\n", a[1]);
+       TRACE(MSGL_VGSM_SS,"maxacm: %d\n", a[2]);
+       TRACE(MSGL_VGSM_SS,"ppu: %d\n", a[3]);
+       TRACE(MSGL_VGSM_SS,"chartype: %d\n", a[4]);
+       TRACE(MSGL_VGSM_SS,"length: %d\n", packet->length);
+
+
+       set_aoc_data(packet->data);
+
+//     TRACE(MSGL_VGSM_SS,"hdr: %d\n", a[7]);
+}
+
+void server_tx_ss_ussd_get_req ( LXT_MESSAGE *packet) // 090215
+{
+       TRACE(MSGL_VGSM_SS,"\n");
+
+       // a = (int*)packet->data;
+
+       // TRACE(MSGL_VGSM_SS,"data: %d\n", a[0]);
+       server_rx_ss_ussd_get();                                                                // checkpoint 090215
+}
+
+void server_tx_ss_ussd_set_req ( LXT_MESSAGE *packet)
+{
+       TRACE(MSGL_VGSM_SS,"\n");
+
+       set_ussd_data(packet->data);
+
+//     TRACE(MSGL_VGSM_SS,"hdr: %d\n", a[7]);
+}
+
+int server_tx_ss_state( ss_state_e_type type )
+{
+/*
+       data[0] : ss_info
+       data[1] : PI
+       data[2] : Cause of No CLI
+       data[3] : CUG_INDEX
+       data[4] : NUMBER_LEN
+       data[5] : NUMBER_TYPE
+       data[6] : NUMBER[]
+       data[7+] : NAME_LEN // 0
+       data[7+] : DCS   // 0
+ */
+       TRACE(MSGL_VGSM_INFO,"\n");
+
+       unsigned char *data = 0;
+       //LXT_MESSAGE packet;
+       gsm_call_list_t list;
+       //int CallCount = 0;
+       int length = 0, call_id = 0;
+
+       get_call_list( &list );
+       call_id = get_call_id();
+       length = 8 + list.CallInfo[call_id].num_len;
+       data = malloc(sizeof(unsigned char)*length);
+       memset( data, 0, sizeof(unsigned char)*length );
+
+       if( list.CallCount <= 0 )
+               return 0;
+
+       if( type == SS_STATE_HOLD || type == SS_STATE_UNHOLD )
+       {
+               if( list.CallCount > 1 )
+               {
+                       VGSM_DEBUG("Call Count is not 1. \n");
+                       return 0;
+               }
+       }
+       else if( type == SS_STATE_CONFERENCE )
+       {
+               if( list.CallCount == 1 )
+                       return 0;
+       }
+
+       if( is_prev_ss_state(SS_RX_HOLD) )
+       {
+               VGSM_DEBUG("prev ss state is SS_RX_HOLD\n");
+               return 0;
+       }
+
+       switch( type ) {
+           case SS_STATE_HOLD:
+               data[0] = 0x61; // GSM_SS_INFO_CALL_ON_HOLD
+               if( is_prev_ss_state(SS_TX_ACTIVATE) ||is_prev_ss_state(SS_NONE) || is_prev_ss_state(SS_RX_ACTIVATE) )
+               {
+                       swap_call();
+                       set_ss_state(SS_TX_HOLD);
+               }
+               else
+               {
+                       VGSM_DEBUG("\n");
+                       free(data);
+                       return 0;
+               }
+               break;
+
+           case SS_STATE_UNHOLD:
+               data[0] = 0x62; // GSM_SS_INFO_CALL_RETRIEVED
+               if( is_prev_ss_state(SS_TX_HOLD) )
+               {
+                       swap_call();
+                       set_ss_state(SS_TX_ACTIVATE);
+               }
+               else
+               {
+                       VGSM_DEBUG("\n");
+                       free(data);
+                       return 0;
+               }
+               break;
+
+           case SS_STATE_CONFERENCE: // not used.
+               data[0] = 0x63; // GSM_SS_INFO_MPTY_ENTERED
+               join_call();
+               break;
+
+           default:
+               return 0;
+       }
+
+       data[1] = 0x00;          // PI : Allowed
+       data[2] = 0x00;         // no cli cause
+       data[3] = 0;             // cug index
+       data[4] = list.CallInfo[call_id].num_len;
+       data[5] = 0x01;         //GSM_NUM_TYPE_INTERNATIONAL
+       memcpy(&data[6], list.CallInfo[call_id].number, list.CallInfo[call_id].num_len);
+       //data[6+list.CallInfo[call_id].num_len] = 0x01;
+       //data[6+list.CallInfo[call_id].num_len+1] = 'a';
+
+       oem_tx_ss_ssinfo_noti(data,length);
+
+       free(data);
+
+       server_tx_call_list_noti();
+
+       return 1;
+}
+
+int server_tx_ss_cli(unsigned char ss_call_type,unsigned char ss_present_indi, unsigned char ss_no_cli_cause)
+{
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       gsm_call_list_t list;
+       int CallCount = 0;
+       int length = 0, call_id = 0;
+       unsigned char *data = NULL;
+
+       get_call_list( &list );
+       CallCount = list.CallCount;
+       if( CallCount == 0 )
+       return 0;
+
+       call_id = get_call_id();
+       length = 8 + list.CallInfo[call_id].num_len;
+       data = malloc(sizeof(unsigned char)*length);
+       memset( data, 0, sizeof(unsigned char)*length );
+
+       //data[0] = 0x01;
+       data[0] = ss_call_type;         // GSM_SS_INFO_CLI; //0x31;
+       data[1] = ss_present_indi;       // PI : Allowed  // check...!!
+       data[2] = ss_no_cli_cause;      // cause of no cli
+       data[3] = 0;             // cug index
+       data[4] = list.CallInfo[call_id].num_len;
+       data[5] = 0x01; //GSM_NUM_TYPE_INTERNATIONAL
+       //list.CallInfo[call_id].number[0] = '0'+call_id;
+       memcpy(&data[6], list.CallInfo[call_id].number, list.CallInfo[call_id].num_len);
+       //data[6+list.CallInfo[call_id].num_len] = 0x01;
+       //data[6+list.CallInfo[call_id].num_len+1] = 'a';
+
+       //log_msg(MSGL_VGSM_INFO,"call id %d\n", call_id);
+
+       oem_tx_ss_ssinfo_noti(data,length);
+
+       free(data);
+
+       return 1;
+}
+
diff --git a/vmodem/server/state.c b/vmodem/server/state.c
new file mode 100644 (file)
index 0000000..9573502
--- /dev/null
@@ -0,0 +1,583 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "at_rx_func.h"
+#include "at_tx_func.h"
+#include "logmsg.h"
+#include "state.h"
+#include "misc.h"
+#include "phoneserver.h"
+//#include "db_network.h"
+#include "db_gprs.h"
+//#include "db_ss.h"
+
+#include "server_tx_call.h"
+#include "server_rx_call.h"
+//#include "server_common_ss.h" // for init_ss_info()
+//#include "server_common_network.h"
+
+//#include "server_tx_security.h"
+//#include "server_common_security.h"
+
+#define MAX_STATE_COUNT                        100
+
+
+int g_hdlc_mode = 0;
+int g_general_response_error = 0x8000;
+
+int g_ss_hold_response_error = 0x8000;
+int g_ss_retrieve_response_error = 0x8000;
+int g_ss_join_response_error = 0x8000;
+int g_ss_split_response_error = 0x8000;
+int g_ss_transfer_response_error = 0x8000;
+
+int g_call_status_error = 0x00;
+int g_current_general_response_error = 0x8000;
+int g_current_call_status_error = 0x00;
+
+SmsAddressInfo g_sca = { 0x01, 0x01, 10, "8210911111" };
+
+STATE_MACHINE state_machine_call =
+    { {STATE_ON, 0, 0, 0}, {STATE_STANDBY, 0, 0, 0} };
+
+STATE_MACHINE state_machine_sim =
+    { {STATE_ON, 0, 0, 0}, {STATE_ON, 0, 0, 0} };
+
+/* Call - end */
+
+/* Supplementary Service - begin */
+int g_ss_general_response_error = 0x8000;
+int g_ss_current_general_response_error = 0x8000;
+/* Supplementary Service - end */
+
+STATE_MACHINE *state_machine = &state_machine_sim;
+//STATE_MACHINE *state_machine = &state_machine_call;
+
+/* GPRS - begin */
+GprsDbEntry g_gprs_ipconf = {"", "", {0xFF, 0, {0,}, {0,}, {0,}, {0,}, {0,}}};
+GprsConfList g_gprs_conflist = {0, 0};
+/* GPRS - end */
+
+STATE_TABLE state_table[MAX_STATE_COUNT] = {
+/* Call - begin */
+    { {STATE_STANDBY, GSM_CALL_CMD, GSM_CALL_OUTGOING, 0},     // set by server_rx_call_originate_exec()
+      {STATE_CALL_WAITING_OUTGOING, GSM_CALL_CMD, GSM_CALL_STATUS, &server_tx_call_msg} },
+
+    { {STATE_CALL_WAITING_OUTGOING, GSM_CALL_CMD, GSM_CALL_ANSWER, 0}, // set by server_tx_call_answer_exec()
+      {STATE_CALL_CONVERSATION, GSM_CALL_CMD, GSM_CALL_STATUS, &server_tx_call_msg} },
+
+/*    In call status msg, incoming msg do not exist.  Incoming noti msg is replaced.
+    { {STATE_STANDBY, GSM_CALL_CMD, GSM_CALL_INCOMING, 0},
+      {STATE_CALL_WAITING_INCOMING, GSM_CALL_CMD, GSM_CALL_STATUS, &TxCall_Msg} },
+*/
+    { {STATE_CALL_WAITING_INCOMING, GSM_CALL_CMD, GSM_CALL_ANSWER, 0}, //set by server_rx_call_answer_exec()
+      {STATE_CALL_CONVERSATION, GSM_CALL_CMD, GSM_CALL_STATUS, &server_tx_call_msg} },
+
+    { {STATE_CALL_CONVERSATION, GSM_CALL_CMD, GSM_CALL_RELEASE, 0},
+      {STATE_CALL_RELEASED, GSM_CALL_CMD, GSM_CALL_STATUS, &server_tx_call_msg} },
+
+    { {STATE_CALL_RELEASED, GSM_CALL_CMD, GSM_CALL_RELEASE, 0},        // set by server_tx_call_release_internal()
+      {STATE_STANDBY, GSM_CALL_CMD, GSM_CALL_STATUS, &server_tx_call_msg} },
+/* Call - end */
+
+/* SIM - start */
+
+/* SIM - end */
+    { {0,0,0},
+      {0,0,0} }
+};
+
+#define TABLE_CURRENT_STATE_TYPE(x)    state_table[x].current_state.state_type
+#define TABLE_CURRENT_STATE_MAIN_CMD(x)        state_table[x].current_state.main_cmd
+#define TABLE_CURRENT_STATE_SUB_CMD(x) state_table[x].current_state.sub_cmd
+#define TABLE_CURRENT_STATE_FUNCTION(x)        state_table[x].current_state.state_function
+
+#define TABLE_NEXT_STATE_TYPE(x)       state_table[x].next_state.state_type
+#define TABLE_NEXT_STATE_MAIN_CMD(x)   state_table[x].next_state.main_cmd
+#define TABLE_NEXT_STATE_SUB_CMD(x)    state_table[x].next_state.sub_cmd
+#define TABLE_NEXT_STATE_FUNCTION(x)   state_table[x].next_state.state_function
+
+//080227 - move to server_common.c
+#if 0
+void init_vgsm()
+{
+       // initialize network db
+       vgsm_network_database_init();
+       init_plmn_list();
+       init_network_registration();
+
+       // initialize sim security & phonebook db
+       server_sim_db_init();
+
+
+       // initialize gprs db
+       vgsm_gprs_database_init();
+       init_gprs_info();
+
+       // initialize ss db
+       vgsm_ss_database_init();
+       init_ss_info();
+}
+#endif
+
+#ifdef _DEBUG
+void print_state_table(void)
+{
+    int i = 0;
+
+    for( i=0; TABLE_CURRENT_STATE_TYPE(i)!=0; ++i ) {
+       log_msg(MSGL_VGSM_INFO, "CURRENT_STATE: %d, %d, %d, %p ",
+               TABLE_CURRENT_STATE_TYPE(i),
+               TABLE_CURRENT_STATE_MAIN_CMD(i),
+               TABLE_CURRENT_STATE_SUB_CMD(i),
+               TABLE_CURRENT_STATE_FUNCTION(i) );
+       log_msg(MSGL_VGSM_INFO, "NEXT_STATE: %d, %d, %d, %p\n",
+               TABLE_NEXT_STATE_TYPE(i),
+               TABLE_NEXT_STATE_MAIN_CMD(i),
+               TABLE_NEXT_STATE_SUB_CMD(i),
+               TABLE_NEXT_STATE_FUNCTION(i) );
+    }
+}
+char *string_state[]={
+    "STATE_NONE",
+    "STATE_OFF",
+    "STATE_ON",
+    "STATE_STANDBY",
+/* Call - begin */
+    "STATE_CALL_WAITING_INCOMING",
+    "STATE_CALL_WAITING_OUTGOING",
+    "STATE_CALL_CONVERSATION",
+    "STATE_CALL_RELEASED",
+/* Call - end */
+
+/* SIM -start */
+
+    "STATE_SIM_READY",
+    "STATE_SIM_PIN",
+    "STATE_SIM_FDN", // 0x10
+    "STATE_SIM_PUK",
+
+"STATE_SIM_FRIZEN",
+    "STATE_SIM_PUK2",
+    "STATE_SIM_PIN2",
+
+    "STATE_SIM_PIN_WRONG",
+    "STATE_SIM_PUK_WRONG",
+    "STATE_SIM_PUK2_WRONG",
+    "STATE_SIM_PIN2_WRONG",
+
+    "STATE_SIM_PIN_OK",
+    "STATE_SIM_PUK_OK", //0x20
+    "STATE_SIM_PUK2_OK",
+    "STATE_SIM_PIN2_OK",
+   
+    "STATE_SIM_PIN_WRONG_ALL",
+    "STATE_SIM_PUK_WRONG_ALL",
+    "STATE_SIM_PUK2_WRONG_ALL",
+    "STATE_SIM_PIN2_WRONG_ALL",
+
+       //STATE_SIM_PIN_LOCK_DISABLE,
+       //0215
+       "STATE_SIM_NO_SIM",
+       "STATE_ANY"
+};
+
+void print_state( STATE state )
+{
+    log_msg(MSGL_VGSM_INFO, "STATE: %d, %d, %d\n",
+           STATE_TYPE(state),
+           STATE_MAIN_CMD(state),
+           STATE_SUB_CMD(state) );
+}
+
+void print_state_machine2(void)
+{
+    log_msg(MSGL_VGSM_INFO,"===========================================\n");
+   log_msg(MSGL_VGSM_INFO, "PREV_STATE: %d, %d, %d, %p \n",
+           STATE_TYPE(state_machine->prev_state),
+           STATE_MAIN_CMD(state_machine->prev_state),
+           STATE_SUB_CMD(state_machine->prev_state),
+           STATE_FUNCTION(state_machine->prev_state) );
+    log_msg(MSGL_VGSM_INFO, "CURRENT_STATE: %d, %d, %d, %p\n",
+           STATE_TYPE(state_machine->current_state),
+           STATE_MAIN_CMD(state_machine->current_state),
+           STATE_SUB_CMD(state_machine->current_state),
+           STATE_FUNCTION(state_machine->current_state) );
+    log_msg(MSGL_VGSM_INFO,"=============================================\n");
+}
+
+void print_state_machine(void)
+{
+    log_msg(MSGL_VGSM_INFO,"==========================\n");
+   log_msg(MSGL_VGSM_INFO, "PREV_STATE: %s, %d, %d, %p \n",
+           string_state[STATE_TYPE(state_machine->prev_state)],
+           STATE_MAIN_CMD(state_machine->prev_state),
+           STATE_SUB_CMD(state_machine->prev_state),
+           STATE_FUNCTION(state_machine->prev_state) );
+    log_msg(MSGL_VGSM_INFO, "CURRENT_STATE: %s, %d, %d, %p\n",
+           string_state[STATE_TYPE(state_machine->current_state)],
+           STATE_MAIN_CMD(state_machine->current_state),
+           STATE_SUB_CMD(state_machine->current_state),
+           STATE_FUNCTION(state_machine->current_state) );
+    log_msg(MSGL_VGSM_INFO,"==========================\n");
+}
+#endif
+
+int find_next_state_for_state( STATE current, STATE *next, int flag )
+{
+    int i = 0;
+
+    for( i=0; TABLE_CURRENT_STATE_TYPE(i)!=0; ++i ) {
+       if( flag == STATE_FLAG_ALL ) {
+           if( ( ( STATE_TYPE(current) == TABLE_CURRENT_STATE_TYPE(i) ) ||
+                       ( TABLE_CURRENT_STATE_TYPE(i) == STATE_ANY ) ) &&
+                   ( STATE_MAIN_CMD(current) == TABLE_CURRENT_STATE_MAIN_CMD(i) ) &&
+                   ( STATE_SUB_CMD(current) == TABLE_CURRENT_STATE_SUB_CMD(i) ) ) {
+               memcpy( next, &state_table[i].next_state, sizeof( STATE ) );
+
+               return 1;
+           }
+       }
+       else if( ( flag & STATE_FLAG_TYPE ) &&
+                 ( ( STATE_TYPE(current) == TABLE_CURRENT_STATE_TYPE(i) ) ||
+                   ( TABLE_CURRENT_STATE_TYPE(i) == STATE_ANY )
+                ) &&
+                ( flag & STATE_FLAG_MAIN_CMD ) &&
+                ( STATE_MAIN_CMD(current) == TABLE_CURRENT_STATE_MAIN_CMD(i) )
+              ) {
+           memcpy( next, &state_table[i].next_state, sizeof( STATE ) );
+
+           return 1;
+       }
+       else if( ( ( flag == STATE_FLAG_TYPE ) &&
+                  ( ( STATE_TYPE(current) == TABLE_CURRENT_STATE_TYPE(i) ) ||
+                    ( TABLE_CURRENT_STATE_TYPE(i) == STATE_ANY )
+                  )
+                )
+              ) {
+           memcpy( next, &state_table[i].next_state, sizeof( STATE ) );
+
+           return 1;
+       }
+       else if( ( flag == STATE_FLAG_MAIN_CMD ) &&
+                ( STATE_MAIN_CMD(current) == TABLE_CURRENT_STATE_MAIN_CMD(i) )
+              ) {
+           memcpy( next, &state_table[i].next_state, sizeof( STATE ) );
+
+           return 1;
+       }
+       else if( ( flag == STATE_FLAG_SUB_CMD ) &&
+                ( STATE_SUB_CMD(current) == TABLE_CURRENT_STATE_SUB_CMD(i) )
+              ) {
+           memcpy( next, &state_table[i].next_state, sizeof( STATE ) );
+
+           return 1;
+       }
+    }
+
+    return 0;
+}
+
+int find_next_state( STATE *next, int flag )
+{
+    STATE state;
+    int ret = 0;
+
+    _ENTER();
+
+    get_current_state_machine( &state );
+    ret = find_next_state_for_state( state, next, flag );
+
+#ifdef _DEBUG
+    if( ret )
+       print_state(*next);
+#endif /* _DEBUG */
+
+    _LEAVE();
+
+    return ret;
+}
+
+void set_state_machine( STATE state )
+{
+    int type = STATE_TYPE(state_machine->current_state);
+
+    _ENTER();
+
+    memcpy( &state_machine->prev_state, &state_machine->current_state, sizeof( STATE ) );
+    memcpy( &state_machine->current_state, &state, sizeof( STATE ) );
+
+    if( ( STATE_TYPE(state) == STATE_NONE ) || ( STATE_TYPE(state) == STATE_ANY ) )
+       STATE_TYPE(state_machine->current_state) = type;
+
+#ifdef _DEBUG
+    print_state_machine();
+#endif /* _DEBUG */
+
+    _LEAVE();
+}
+
+int change_state_machine( int main_cmd )
+{
+       _ENTER();
+
+       switch( main_cmd ) {
+       case GSM_CALL_CMD:  /* 0x02 : Call Control Commands */
+       case GSM_SS_CMD:    /* 0x0C : Supplementary Service Control Command */
+               state_machine = &state_machine_call;
+               break;
+       case GSM_SEC_CMD:   /* 0x05 : Security - SIM control Commands */
+               state_machine = &state_machine_sim;
+               break;
+
+       case GSM_PWR_CMD:   /* 0x01 : Power Control Commands */
+               break;
+       case GSM_DATA_CMD:  /* 0x03 : Data Control Commands */
+               break;
+       case GSM_SMS_CMD:   /* 0x04 : Short Message Service Commands */
+               break;
+       case GSM_PB_CMD:    /* 0x06 : Phonebook Control Commands */
+       case GSM_DISP_CMD:  /* 0x07 : Display Control Commands */
+       case GSM_NET_CMD:   /* 0x08 : Network Commands */
+       case GSM_SND_CMD:   /* 0x09 : Sound Control Commands */
+       case GSM_MISC_CMD:  /* 0x0A : Miscellaneous Control Commands */
+       case GSM_SVC_CMD:   /* 0x0B : Service Mode Control Commands - Factory Test or Debug Screen Control */
+       case GSM_GPRS_CMD:  /* 0x0D : GPRS Commands */
+       case GSM_SAT_CMD:   /* 0x0E : SIM Toolkit Commands */
+       case GSM_CFG_CMD:   /* 0x0F : Configuration Commands */
+       case GSM_GEN_CMD:   /* 0x80 : General Response Commands */
+       default:
+               break;
+       }
+
+       _LEAVE();
+
+       return 1;
+}
+
+void send_msg( void)
+{
+       STATE state;
+
+       _ENTER();
+
+       get_current_state_machine( &state );
+       log_msg(MSGL_VGSM_INFO," exe state_type %d, state main_cmd=%d sub_cmd =%d\n", state.state_type,state.main_cmd,state.sub_cmd);
+
+       if( state.state_function )
+       {
+               log_msg(MSGL_VGSM_CALL,"state.function exe !! \n");
+
+               state.state_function();
+       }
+
+       _LEAVE();
+}
+
+void get_current_state_machine( STATE *state )
+{
+    _ENTER();
+
+    memcpy( state, &state_machine->current_state, sizeof( STATE ) );
+
+    _LEAVE();
+}
+
+void get_prev_state_machine( STATE *state )
+{
+    _ENTER();
+
+    memcpy( state, &state_machine->prev_state, sizeof( STATE ) );
+
+    _LEAVE();
+}
+
+void set_current_state( int state, int main_cmd, int sub_cmd)
+{
+    _ENTER();
+
+       STATE st;
+    STATE_TYPE(st) = state;
+    STATE_MAIN_CMD(st) = main_cmd;
+    STATE_SUB_CMD(st) = sub_cmd;
+    //STATE_FUNCTION(st) = func;
+    set_state_machine( st );
+           _LEAVE();
+}
+
+void set_hdlc_mode( int mode )
+{
+    g_hdlc_mode = mode;
+}
+
+int get_hdlc_mode()
+{
+    return g_hdlc_mode;
+}
+
+void set_ss_transfer_response_error( int error ,int ss_error_type)
+{
+
+       log_msg(MSGL_VGSM_INFO,"---<set_ss_response_error>--- error : %x type : %d\n", error,ss_error_type);
+       switch ( ss_error_type)
+       {
+               case GSM_EMULATOR_SET_SS_HOLD_RESPONSE_ERROR :
+                       g_ss_hold_response_error = error;
+                       break;
+               case GSM_EMULATOR_SET_SS_RETRIEVE_RESPONSE_ERROR:
+                       g_ss_retrieve_response_error = error;
+                       break;
+               case GSM_EMULATOR_SET_SS_JOIN_RESPONSE_ERROR:
+                       g_ss_join_response_error = error;
+                       break;
+               case GSM_EMULATOR_SET_SS_SPLIT_RESPONSE_ERROR:
+                       g_ss_split_response_error = error;
+                       break;
+               case GSM_EMULATOR_SET_SS_TRANSFER_RESPONSE_ERROR :
+                       g_ss_transfer_response_error = error;
+                       break;
+               case GSM_EMULATOR_SET_SS_GENERAL_RESPONSE_ERROR:
+                       g_ss_general_response_error = error;
+                       break;
+               }
+}
+
+void set_general_response_error( int error )
+{
+       log_msg(MSGL_VGSM_INFO,"---<set_general_response_error>---general response error : %x \n", error);
+       g_general_response_error = error;
+}
+
+int get_general_response_error()
+{
+       log_msg(MSGL_VGSM_INFO,"---<get_general_response_error>---general response error : %x \n", g_general_response_error);
+       return g_general_response_error;
+}
+
+void set_ss_general_response_error( int error )
+{
+    g_ss_general_response_error = error;
+}
+
+int get_ss_general_response_error()
+{
+    return g_ss_general_response_error;
+}
+
+void set_call_status_error( int error )
+{
+    g_call_status_error = error;
+}
+
+int get_call_status_error()
+{
+    return g_call_status_error;
+}
+
+void set_current_general_response_error( int error )
+{
+    g_current_general_response_error = error;
+}
+
+int get_current_general_response_error()
+{
+    return g_current_general_response_error;
+}
+
+void set_ss_current_general_response_error( int error )
+{
+    g_ss_current_general_response_error = error;
+}
+
+int get_ss_current_general_response_error()
+{
+    return g_ss_current_general_response_error;
+}
+
+void set_current_call_status_error( int error )
+{
+    g_current_call_status_error = error;
+}
+
+int get_current_call_status_error()
+{
+    return g_current_call_status_error;
+}
+
+#if 0
+void set_sca( SmsAddressInfo SCA )
+{
+    memcpy( &g_sca, &SCA, sizeof( SmsAddressInfo ) );
+}
+
+int get_sca( SmsAddressInfo *SCA )
+{
+    memcpy( SCA, &g_sca, sizeof( SmsAddressInfo ) );
+
+    return 1;
+}
+#endif
+
+static void int_to_string(char *res, unsigned int s_value, int s_radix)
+{
+       static const char c_base_ascii[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+       static char s_buffer[64] = {0, };
+       size_t s_offset = sizeof(s_buffer) - 1;
+
+       do {
+               s_buffer[--s_offset] = c_base_ascii[ s_value % s_radix ];
+               s_value /= s_radix;
+       } while (s_value != 0u);
+
+       strcpy(res, (char *)(&s_buffer[s_offset]));
+
+       return;
+}
+
+/*UNUSED! */ int change_ip_to_ipstring(unsigned char *ip_addr, char* message, int msg_len);
+int change_ip_to_ipstring(unsigned char *ip_addr, char* message, int msg_len)
+{
+       int i = 0;                                      //, j = 0;
+       char temp[20];                  //, ret;
+
+       memset(message, 0, msg_len);
+
+       for (i = 0; i < 4; i++) {
+               int_to_string(temp, ip_addr[i], 10);
+
+               strcat(message, temp);
+
+               if (i != 3)
+                       strcat(message, ".");
+       }
+
+       return 0;
+}
diff --git a/vmodem/server/state_sim.c b/vmodem/server/state_sim.c
new file mode 100644 (file)
index 0000000..41e2043
--- /dev/null
@@ -0,0 +1,592 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "state.h"
+#include "state_sim.h"
+#include "db_security.h"
+
+char g_pin_value[9];
+char g_puk_value[9];
+char g_pin2_value[9];
+char g_puk2_value[9];
+int g_pin_cnt;
+int g_pin2_cnt;
+int g_puk_cnt;
+int g_puk2_cnt;
+int g_sim_state;
+int g_facility_pin;
+int g_facility_fdn;
+int g_lock_sc2_state;
+int g_sim_sec_general_response_error = 0x8000;
+
+/*     ++ 2008-08-05
+       ++ This file is not used any more.
+       ++ This file will be removed.
+*/
+//init
+int server_sim_db_init()
+{
+       int ret =       0;
+
+       SIM_DEBUG("\n");
+
+       ret     =       db_sim_sec_create();
+
+       // return value '1' means that sim db already exists. so, we don`t need to put new record.
+       if(ret != 1)
+       {
+               db_sim_sec_add();
+       }
+
+       db_sim_sec_restore(VGSM_SIMTypeLoad);
+
+       return 1;
+}
+
+
+void state_sim_set_sec_db_info(SimSecurity *sim_sec,int  ncol)
+{
+       SIM_DEBUG("\n");
+//init
+       memset(g_pin_value,0,9);
+       memset(g_puk_value,0,9);
+       memset(g_pin2_value,0,9);
+       memset(g_puk2_value,0,9);
+
+       g_pin_cnt               =       0;
+       g_pin2_cnt              =       0;
+       g_puk_cnt               =       0;
+       g_puk2_cnt              =       0;
+       g_sim_state             =       0;
+       g_facility_pin  =       0;
+       g_facility_fdn  =       0;
+       g_lock_sc2_state        =       0;
+
+//load
+       memcpy(g_pin_value,sim_sec->pin_value, strlen(sim_sec->pin_value));
+       memcpy(g_puk_value,sim_sec->puk_value, strlen(sim_sec->puk_value));
+       memcpy(g_pin2_value,sim_sec->pin2_value,strlen(sim_sec->puk_value));
+       memcpy(g_puk2_value,sim_sec->puk2_value, strlen(sim_sec->puk2_value));
+
+       g_pin_cnt               =sim_sec->pin_cnt;
+       g_pin2_cnt              =sim_sec->pin2_cnt;
+       g_puk_cnt               =sim_sec->puk_cnt;
+       g_puk2_cnt              =sim_sec->puk2_cnt;
+       g_sim_state             =_trans_db_sim_state_type(sim_sec->sim_state);
+       g_facility_pin  =sim_sec->facility_pin;
+       g_facility_fdn  =sim_sec->facility_fdn;
+       g_lock_sc2_state        = _trans_db_sim_state_type(sim_sec->lock_sc2_state);
+
+       free(sim_sec);
+
+}
+
+int _trans_db_sim_state_type(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case SIM_STATE_READY:
+                       return GSM_SIM_READY;
+               case SIM_STATE_PIN_REQ:
+                       return GSM_SIM_PIN_REQ_STATE ;
+               case SIM_STATE_PUK_REQ:
+                       return GSM_SIM_PUK_REQ;
+               case SIM_STATE_PIN2_REQ:
+                       return GSM_SIM_PIN2_REQ;
+               case SIM_STATE_PUK2_REQ:
+                       return GSM_SIM_PUK2_REQ;
+               case SIM_STATE_FRIZEN:
+                       return GSM_SIM_FRIZEN;
+               case SIM_STATE_NO_SIM:
+                       return GSM_SIM_NO_SIM;
+               case SIM_STATE_FDN_STATE:
+                       return GSM_SIM_FDN_STATE;
+               case SIM_STATE_PIN2_OK:
+                       return GSM_SIM_PIN2_OK;
+
+               case GSM_SIM_READY:
+                       return SIM_STATE_READY;
+               case GSM_SIM_PIN_REQ_STATE:
+                       return SIM_STATE_PIN_REQ ;
+               case GSM_SIM_PUK_REQ:
+                       return SIM_STATE_PUK_REQ;
+               case GSM_SIM_PIN2_REQ:
+                       return SIM_STATE_PIN2_REQ;
+               case GSM_SIM_PUK2_REQ:
+                       return SIM_STATE_PUK2_REQ;
+               case GSM_SIM_FRIZEN:
+                       return SIM_STATE_FRIZEN;
+               case GSM_SIM_NO_SIM:
+                       return SIM_STATE_NO_SIM;
+               case GSM_SIM_FDN_STATE:
+                       return SIM_STATE_FDN_STATE;
+               case GSM_SIM_PIN2_OK:
+                       return SIM_STATE_PIN2_OK;
+
+               default:
+               break;
+       }
+       return 1;
+}
+
+
+
+/*
+       flag value ->
+       GSM_SEC_LOCK_MODE_UNLOCK : 0x00 : Disable
+       GSM_SEC_LOCK_MODE_LOCK  : 0x01 : Enable
+*/
+void state_sim_set_facility(int type,int flag)
+{
+       SIM_DEBUG("\n");
+
+       if(GSM_SIM_FACILITY_PIN == type )
+       {
+               g_facility_pin = flag;
+               db_sim_sec_edit(DB_F_PIN,NULL,g_facility_pin);
+       }
+
+       if(GSM_SIM_FACILITY_FDN == type )
+       {
+               g_facility_fdn = flag;
+               db_sim_sec_edit(DB_F_FDN,NULL,g_facility_fdn);
+       }
+}
+
+int state_sim_get_facility(int type)
+{
+       SIM_DEBUG("\n");
+
+       if(GSM_SIM_FACILITY_PIN == type )
+               return g_facility_pin;
+       if(GSM_SIM_FACILITY_FDN == type )
+               return g_facility_fdn;
+
+       return 1;
+}
+
+char * state_sim_get_password(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+                       SIM_DEBUG("g_pin_value = [%s]  \n",g_pin_value);
+                       return  g_pin_value;
+
+               case GSM_SIM_PIN2_REQ:
+                       return  g_pin2_value;
+
+               case GSM_SIM_PUK_REQ:
+                       return  g_puk_value;
+
+               case GSM_SIM_PUK2_REQ:
+                       return g_puk2_value;
+
+               default:
+                       break;
+       }
+
+       return 0;
+}
+
+int state_sim_change_password(char *password,int type,int length)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       memset(g_pin_value,0,8);
+                       memcpy(g_pin_value,password,length);
+                       db_sim_sec_edit(DB_PIN ,g_pin_value,0);
+                       return 1;
+               }
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       memset(g_pin2_value,0,8);
+                       memcpy(g_pin2_value,password,length);
+                       db_sim_sec_edit(DB_PIN2 ,g_pin2_value,0);
+                       return 1;
+               }
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       memset(g_puk_value,0,8);
+                       memcpy(g_puk_value,password,length);
+                       db_sim_sec_edit(DB_PUK ,g_puk_value,0);
+                       return 1;
+               }
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       memset(g_puk2_value,0,8);
+                       memcpy(g_puk2_value,password,length);
+                       db_sim_sec_edit(DB_PUK2 ,g_puk2_value,0);
+                       return 1;
+               }
+
+               default:
+                       break;
+       }
+
+       return 0;
+}
+
+
+int state_sim_verify_password(char *password,int type,int length)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       length = strlen(g_pin_value);
+
+                       if(!memcmp(g_pin_value,password,length))
+                       {
+                                g_pin_cnt      =       3;
+                                db_sim_sec_edit(DB_PIN_CNT,NULL,g_pin_cnt);
+                                return 1;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       length = strlen(g_pin2_value);
+
+                       SIM_DEBUG("g_pin2_value =[%s]\n",g_pin2_value);
+                       SIM_DEBUG("input password value=[%s]\n",password);
+
+                       if(!memcmp(g_pin2_value,password,length))
+                       {
+                                g_pin2_cnt     =       3;
+                                 db_sim_sec_edit(DB_PIN2_CNT,NULL,g_pin2_cnt);
+                               return 1;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       length = strlen(g_puk_value);
+
+                       SIM_DEBUG("g_puk_value=[%s]\n",g_puk_value);
+                       SIM_DEBUG("input password=[%s]\n",password);
+
+                       if(!memcmp(g_puk_value,password,length))
+                       {
+                                g_pin_cnt      =       3;
+                                g_puk_cnt      =       10;
+
+                               db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+                               db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+
+                               return 1;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       length = strlen(g_puk2_value);
+
+                       if(!memcmp(g_puk2_value,password,length))
+                       {
+                               g_pin2_cnt      =       3;
+                               g_puk2_cnt      =       10;
+
+                               db_sim_sec_edit(DB_PIN2_CNT,NULL,g_pin2_cnt);
+                               db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+
+                               return 1;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
+               default:
+                       break;
+
+       }
+       return 0;
+}
+
+
+char state_sim_status_mgr(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                       g_pin_cnt--;
+                       db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+
+                       if(g_pin_cnt == 0 )
+                               state_sim_set_sec_status(GSM_SIM_PUK_REQ);
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       g_pin2_cnt--;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+
+                       if(g_pin2_cnt == 0 )
+                               state_sim_set_sec2_status(GSM_SIM_PUK2_REQ);
+               }
+               break;
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       g_puk_cnt--;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+
+                       if(g_puk_cnt == 0 )
+                               state_sim_set_sec_status(GSM_SIM_FRIZEN);
+               }
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       g_puk2_cnt--;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+
+                       if(g_puk2_cnt == 0 )
+                               state_sim_set_sec2_status(GSM_SIM_FRIZEN);
+               }
+               break;
+
+               default:
+                       break;
+
+       }
+
+       return 1;
+}
+
+
+int state_sim_set_sec_status(int status)
+{
+       SIM_DEBUG("\n");
+
+       SIM_DEBUG("status is %x\n",status);
+
+       g_sim_state = status;
+
+       status=_trans_db_sim_state_type(g_sim_state);
+
+       SIM_DEBUG("after trans status is %x\n",status);
+
+       db_sim_sec_edit(DB_SIM_STATE, NULL,status);
+
+       return g_sim_state;
+}
+
+
+int state_sim_get_sec_status()
+{
+       SIM_DEBUG("\n");
+
+       return g_sim_state ;
+}
+
+
+int state_sim_set_sec2_status(int status)
+{
+       SIM_DEBUG("\n");
+
+       g_lock_sc2_state = status;
+
+       status=_trans_db_sim_state_type(g_lock_sc2_state);
+
+       db_sim_sec_edit(DB_LOCK_SC2_STATE, NULL,status);
+
+       return g_lock_sc2_state;
+}
+
+
+int  state_sim_get_sec2_status()
+{
+       SIM_DEBUG("\n");
+
+       return g_lock_sc2_state ;
+}
+
+
+void state_sim_reset_remain_cnt(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                        g_pin_cnt = 3;
+                        db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+               {
+                       g_pin2_cnt = 3;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+               }
+               break;
+
+               case GSM_SIM_PUK_REQ:
+               {
+                       g_puk_cnt = 10;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               }
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+               {
+                       g_puk2_cnt = 10;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               }
+               break;
+
+               case GSM_SIM_READY:
+               {
+                       g_pin_cnt = 3;
+                       g_puk_cnt = 10;
+                       db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_OK:
+               {
+                       g_pin2_cnt = 3;
+                       g_puk2_cnt = 10;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               }
+               break;
+
+               default:
+                       break;
+
+       }
+
+}
+
+
+void state_sim_set_cnt_zero(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+               {
+                        g_pin_cnt = 0;
+                        db_sim_sec_edit(DB_PIN_CNT, NULL,g_pin_cnt);
+               }
+               break;
+
+               case GSM_SIM_PIN2_REQ:
+                       g_pin2_cnt = 0;
+                       db_sim_sec_edit(DB_PIN2_CNT, NULL,g_pin2_cnt);
+               break;
+
+               case GSM_SIM_PUK_REQ:
+                       g_puk_cnt = 0;
+                       db_sim_sec_edit(DB_PUK_CNT, NULL,g_puk_cnt);
+               break;
+
+               case GSM_SIM_PUK2_REQ:
+                       g_puk2_cnt = 0;
+                       db_sim_sec_edit(DB_PUK2_CNT, NULL,g_puk2_cnt);
+               break;
+
+               default:
+                       break;
+       }
+}
+
+
+int state_sim_get_remain_cnt(int type)
+{
+       SIM_DEBUG("\n");
+
+       switch(type)
+       {
+               case GSM_SIM_PIN_REQ_STATE:
+                       return   g_pin_cnt;
+               case GSM_SIM_PIN2_REQ:
+                       return   g_pin2_cnt;
+               case GSM_SIM_PUK_REQ:
+                       return   g_puk_cnt;
+               case GSM_SIM_PUK2_REQ:
+                       return   g_puk2_cnt;
+       }
+       return 0;
+}
+
+
+void set_sim_sec_general_response_error( int error )
+{
+       SIM_DEBUG("\n");
+
+       g_sim_sec_general_response_error = error;
+}
+
+
+int get_sim_sec_general_response_error()
+{
+       SIM_DEBUG("\n");
+
+       return g_sim_sec_general_response_error;
+}
+
diff --git a/vmodem/transport/gsmstate.c b/vmodem/transport/gsmstate.c
new file mode 100644 (file)
index 0000000..f7f1932
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+#include "gsmstate.h"
+#include "logmsg.h"
+
+#define DEBUG_TITLE    "VGSM"
+
+GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
+{
+    GSM_Error   error;
+
+    s->ReplyNum           = ReplyNum;          
+    s->Phone.Data.CMECode              = 0;
+    s->Phone.Data.CMSCode              = 0;
+    s->Phone.Data.PhonePower   = false;
+    s->Phone.Data.RamDump              = false;
+    memset(s->Phone.Data.dumpaddr, 0x00, sizeof(s->Phone.Data.dumpaddr));
+    s->Phone.Data.ExternalMode = false;        
+    s->Phone.Data.PBReady              = false;
+    s->Phone.Data.PBMirroringDone      = false;
+    s->Phone.Data.PIN_retry            = 3;
+    s->Phone.Data.ALS                  = 0;
+    s->Phone.Data.Band                 = 3;
+    s->opened                                  = false;
+
+    s->Device.Functions                        = NULL;
+       s->Device.Functions                     = &DPRAMDevice;
+
+    if(!s->opened)
+    {
+        error=s->Device.Functions->OpenDevice(s);
+        if(error != ERR_NONE) return error;
+
+        s->opened = true;
+    }
+
+       TRACE(MSGL_VGSM_INFO, "OK\n");
+
+    return ERR_NONE;
+}
+
+
+GSM_Error GSM_TerminateConnection(GSM_StateMachine *s)
+{
+    GSM_Error error;
+
+    if (!s->opened) return ERR_UNKNOWN;
+
+    error = s->Device.Functions->CloseDevice(s);
+    if (error!=ERR_NONE) return error;
+
+    s->opened = false;
+
+    return ERR_NONE;
+}
+
+void GSM_OSErrorInfo(GSM_StateMachine *s, char const* description)
+{
+       TRACE(MSGL_VGSM_ERR,"[%s] System Error: %s\n", DEBUG_TITLE, description);
+}
+
diff --git a/vmodem/transport/transport_dpram.c b/vmodem/transport/transport_dpram.c
new file mode 100644 (file)
index 0000000..27e6aaf
--- /dev/null
@@ -0,0 +1,498 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "gsmstate.h"
+
+#include "logmsg.h"
+
+#include <sys/file.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <errno.h>
+
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include "phoneserver.h"
+
+#define DEBUG_TITLE    "VGSM"
+
+#ifdef __arm__
+#include "dpram.h"
+#endif
+
+#ifndef TIOCMODG
+#  ifdef TIOCMGET
+#    define TIOCMODG TIOCMGET
+#  else
+#    ifdef MCGETA
+#      define TIOCMODG MCGETA
+#    endif
+#  endif
+#endif
+
+#ifndef TIOCMODS
+#  ifdef TIOCMSET
+#    define TIOCMODS TIOCMSET
+#  else
+#    ifdef MCSETA
+#      define TIOCMODS MCSETA
+#    endif
+#  endif
+#endif
+
+/* Set hardware flow control. */
+static GSM_Error dpram_sethwf(GSM_StateMachine * s, int on)
+{
+    GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+    struct termios tty;
+
+    tcgetattr(d->hPhone, &tty);
+    if (on)
+        tty.c_cflag |= CRTSCTS;
+    else
+        tty.c_cflag &= ~CRTSCTS;
+    tcsetattr(d->hPhone, TCSANOW, &tty);
+
+    return ERR_NONE;
+}
+
+/* Set RTS line. */
+static GSM_Error dpram_setrts(GSM_StateMachine * s)
+{
+    GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+    int mcs;
+
+    ioctl(d->hPhone, TIOCMODG, &mcs);
+    mcs |= TIOCM_RTS;
+    ioctl(d->hPhone, TIOCMODS, &mcs);
+
+    return ERR_NONE;
+}
+
+/*
+ * Set baudrate, parity and number of bits.
+ */
+static GSM_Error dpram_setparms(GSM_StateMachine * s,
+char * baudr, char * par, char * bits, char * stop, int hwf, int swf)
+{
+    GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+
+    int spd = -1;
+    int newbaud;
+    int bit = bits[0];
+    int stop_bit = stop[0];
+
+    struct termios tty;
+
+    if  (tcgetattr(d->hPhone, &tty) < 0)
+    {
+        GSM_OSErrorInfo(s,"tcgetattr");
+        return ERR_DEVICEREADERROR;
+    }
+
+    if (tcgetattr(d->hPhone, &d->old_settings) < 0)
+    {
+        GSM_OSErrorInfo(s,"tcgetattr");
+        return ERR_DEVICEREADERROR;
+    }
+
+    fflush(stdout);
+
+    /* We generate mark and space parity ourself. */
+    if (bit == '7' && (par[0] == 'M' || par[0] == 'S'))
+        bit = '8';
+
+    /* Check if 'baudr' is really a number */
+    if ((newbaud = (atol(baudr) / 100)) == 0 && baudr[0] != '0')
+        newbaud = -1;
+
+    switch (newbaud)
+    {
+        case 0:    spd = 0;       break;
+        case 3:    spd = B300;    break;
+        case 6:    spd = B600;    break;
+        case 12:   spd = B1200;   break;
+        case 24:   spd = B2400;   break;
+        case 48:   spd = B4800;   break;
+        case 96:   spd = B9600;   break;
+        case 192:  spd = B19200;  break;
+        case 384:  spd = B38400;  break;
+        case 576:  spd = B57600;  break;
+        case 1152: spd = B115200; break;
+    }
+
+    if (spd != -1)
+    {
+        cfsetospeed(&tty, (speed_t) spd);
+        cfsetispeed(&tty, (speed_t) spd);
+    }
+
+    switch (bit)
+    {
+        case '5':
+            tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5;
+            break;
+        case '6':
+            tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6;
+            break;
+        case '7':
+            tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7;
+            break;
+        case '8':
+        default:
+            tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;
+            break;
+    }
+
+    switch (stop_bit)
+    {
+        case '1':
+            tty.c_cflag &= ~CSTOPB;
+            break;
+        case '2':
+        default :
+            tty.c_cflag |= CSTOPB;
+            break;
+    }
+
+    /* Set into raw, no echo mode */
+    tty.c_iflag = IGNBRK;
+    tty.c_lflag = 0;
+    tty.c_oflag = 0;
+    tty.c_cflag |= CLOCAL | CREAD;
+    tty.c_cc[VMIN] = 1;
+    tty.c_cc[VTIME] = 1;
+
+    if (swf)
+        tty.c_iflag |= IXON | IXOFF;
+    else
+        tty.c_iflag &= ~(IXON | IXOFF | IXANY);
+
+    tty.c_cflag &= ~(PARENB | PARODD);
+
+    if (par[0] == 'E')
+        tty.c_cflag |= PARENB;
+    else if (par[0] == 'O')
+        tty.c_cflag |= (PARENB | PARODD);
+
+    if  (tcsetattr(d->hPhone, TCSANOW, &tty) < 0)
+    {
+        GSM_OSErrorInfo(s,"tcsetattr");
+        return ERR_DEVICEPARITYERROR;
+    }
+
+    dpram_setrts(s);
+
+    dpram_sethwf(s, hwf);
+
+    return ERR_NONE;
+}
+
+static GSM_Error dpram_close(GSM_StateMachine *s)
+{
+
+       if( vgsm_server_port > 0 ){
+
+                 GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+                 close(d->hPhone);
+                 return ERR_NONE;
+
+       }else{
+
+#ifdef __arm__
+                   GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+
+                   if  (tcsetattr(d->hPhone, TCSAFLUSH, &d->old_settings) < 0)
+                       log_msg(MSGL_VGSM_INFO,"[%s] tcsetattr", DEBUG_TITLE);
+
+                   close(d->hPhone);
+
+                   return ERR_NONE;
+#else
+                   GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+
+                   close(d->hPhone);
+                   return ERR_NONE;
+#endif
+
+
+               }
+
+}
+
+#include <sys/socket.h>
+#define MAX_LISTEN_NUMBER  32
+static GSM_Error dpram_open (GSM_StateMachine *s)
+{
+       if( vgsm_server_port > 0 ){
+               GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+               d->Power = false;
+               return ERR_NONE;
+       }
+       else{
+               log_msg(MSGL_VGSM_INFO,"[%s] vdpram open\n", DEBUG_TITLE);
+#ifdef __arm__
+               GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+
+               int i;
+               int val = 1;
+
+               d->Power = false;
+               d->hPhone = open("/dev/vdpram1", O_RDWR | O_NOCTTY | O_NONBLOCK);
+               if (d->hPhone < 0) {
+                        i = errno;
+                        log_msg(MSGL_VGSM_INFO," dpram open errno = %d : %s \n", i, strerror(i));
+                        GSM_OSErrorInfo(s,"open in dpram_open");
+                        if (i ==  2) return ERR_DEVICENOTEXIST;     //no such file or directory
+                        if (i == 13) return ERR_DEVICENOPERMISSION; //permission denied
+                        return ERR_DEVICEOPENERROR;
+                }
+
+               if  (dpram_setparms(s, "115200", "N", "8", "1", 0, 0) != ERR_NONE)
+               {
+                       dpram_close(s);
+                       GSM_OSErrorInfo(s, "dpram set parameter");
+                       return ERR_DEVICEOPENERROR;
+               }
+               
+               if  (ioctl(d->hPhone, HN_DPRAM_PHONE_GETSTATUS, &val) < 0)
+               {
+                       dpram_close(s);
+                       GSM_OSErrorInfo(s, "dpram phone power status error");
+                       return ERR_DEVICEOPENERROR;
+               }
+               
+               if  (val == HN_DPRAM_PHONE_STATUS_OFF)
+                       d->Power = false;
+               else
+                       d->Power = true;
+               return ERR_NONE;
+#else
+               return ERR_NONE;
+#endif
+
+               }
+
+}
+
+static bool _IsFlightMode(void)
+{
+       char    buf[32];
+       int             fd;
+       bool    ret = false;
+#ifdef USE_SYSPATH
+       char *syspath, path[PATH_MAX];
+
+       if ((syspath = getenv("LINUETTEDIR")) == NULL)
+               return false;
+
+       sprintf(path, "%s/setting/flightmode.conf", syspath);
+
+       fd = open(path, O_RDONLY);
+       if (fd == -1) {
+#endif
+               fd = open("/setting/flightmode.conf", O_RDONLY);
+               if (fd == -1)
+                       return false;
+#ifdef USE_SYSPATH
+       }
+#endif
+
+       if (read(fd, buf, 1) == 1 && buf[0] == '1')
+               ret = true;
+
+       close(fd);
+
+       log_msg(MSGL_VGSM_INFO,"[%s] ============ Flight mode value: %d ==========\n", DEBUG_TITLE, ret);
+
+       return ret;
+}
+
+static int dpram_poweron(GSM_StateMachine * s, int first_boot)
+{
+       log_msg(MSGL_VGSM_INFO,"[VGSM] vgsm_server_port= %d\n",vgsm_server_port);
+
+       if( vgsm_server_port > 0 ){
+               GSM_Phone_Data          *Data = &s->Phone.Data;
+
+               Data->PhonePower = true;
+               return 1;
+       }
+       else{
+#ifdef __arm__
+               if (!_IsFlightMode() || first_boot) { 
+                   GSM_Device_DPRAMData        *d = &s->Device.Data.DPRAM;
+                       GSM_Phone_Data                  *Data = &s->Phone.Data;
+                   int rc = -1;
+
+                   log_msg(MSGL_VGSM_INFO,"[%s] ============ dpram_power_on ==========\n", DEBUG_TITLE);
+                       rc = ioctl(d->hPhone, HN_DPRAM_PHONE_ON, NULL);
+                       if  (rc < 0)
+                       GSM_OSErrorInfo(s,"Phone Power On failed");
+
+                   Data->PhonePower = true;
+                       return rc;
+               }
+               return 1;
+#else
+           return 1;
+#endif
+       }
+}
+
+static int dpram_poweroff(GSM_StateMachine * s)
+{
+       if( vgsm_server_port > 0 ){
+               return 1;
+       }
+       else{
+#ifdef __arm__
+           GSM_Device_DPRAMData       *d = &s->Device.Data.DPRAM;
+           int rc = -1;
+
+               rc = ioctl(d->hPhone, HN_DPRAM_PHONE_OFF, NULL);
+               if  (rc < 0)
+               GSM_OSErrorInfo(s,"Phone Power Off failed");
+
+               return rc;
+#else
+           return 1;
+#endif
+       }
+}
+
+static int dpram_read(GSM_StateMachine *s, void *buf, size_t nbytes)
+{
+       GSM_Device_DPRAMData       *d = &s->Device.Data.DPRAM;
+       struct timeval          timeout2;
+       fd_set              readfds;
+       int                 actual = 0;
+
+       FD_ZERO(&readfds);
+       FD_SET(d->hPhone, &readfds);
+
+       timeout2.tv_sec     = 0;
+       timeout2.tv_usec    = 1;
+
+       if  (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2))
+       {
+               actual = read(d->hPhone, buf, nbytes);
+               if (actual == -1)
+                       GSM_OSErrorInfo(s,"dpram_read");
+       }
+       return actual;
+}
+
+static int dpram_write(GSM_StateMachine *s, void *buf, size_t nbytes)
+{
+    GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+    int             ret;
+    size_t          actual = 0;
+        unsigned char *p = buf;
+
+    usleep(100000);
+//    log_msg(MSGL_VGSM_INFO, "%d\n", nbytes);
+
+        do {
+        ret = write(d->hPhone, p, nbytes - actual);
+
+        if (ret < 0 && errno == EAGAIN)
+            continue;
+
+        if (ret < 0) {
+            if (actual != nbytes)
+                                GSM_OSErrorInfo(s, "dpram_write");
+                        return actual;
+        }               
+
+        actual  += ret;
+        p       += ret;
+    } while (actual < nbytes);
+    
+    return actual;
+}   
+
+static bool dpram_powerstatus(GSM_StateMachine *s)
+{
+    GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+
+    TRACE(MSGL_VGSM_INFO,"power status:[%d] \n", d->Power);
+
+    return d->Power;
+}
+
+#define RAMDUMP_YES 0x00BB
+#define RAMDUMP_NO  0x00CC
+
+static int dpram_write_magic_code(GSM_StateMachine * s, unsigned char req)
+{
+
+
+#ifdef __arm__
+    GSM_Device_DPRAMData       *d = &s->Device.Data.DPRAM;
+    unsigned short magic_code;
+    int rc = -1;
+
+    if  (req == 0x01) // Yes I'd like to trace the reason about RAMDUMP
+    {
+        log_msg(MSGL_VGSM_INFO,"[%s] ## RAMDUMP Yes ##\n", DEBUG_TITLE);
+        magic_code = RAMDUMP_YES;
+    }
+    else
+    {
+        log_msg(MSGL_VGSM_INFO,"[%s] ## RAMDUMP No  ##\n", DEBUG_TITLE);
+        magic_code = RAMDUMP_NO;
+    }
+
+       rc = ioctl(d->hPhone, HN_DPRAM_PHONE_MAGICCODE, &magic_code);
+       if  (rc < 0)
+        GSM_OSErrorInfo(s,"Write Magic code failed\n");
+    else
+        log_msg(MSGL_VGSM_INFO,"[%s] Write Magic code ok\n", DEBUG_TITLE);
+
+       return rc;
+#else
+    return 1;
+#endif
+}
+
+GSM_Device_Functions DPRAMDevice = {
+    dpram_open,
+    dpram_close,
+    dpram_read,
+    dpram_write,
+    dpram_poweron,
+    dpram_poweroff,
+    dpram_powerstatus,
+    dpram_write_magic_code
+
+};
+
diff --git a/vmodem/transport/transport_onedram.c b/vmodem/transport/transport_onedram.c
new file mode 100644 (file)
index 0000000..839b5ae
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ *  telephony-emulator
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * SungMin Ha <sungmin82.ha@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+#include "gsmstate.h"
+#include "logmsg.h"
+#include <sys/file.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <errno.h>
+
+
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include "phoneserver.h"
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "onedram.h"
+
+int UART_PSI_read(int AT_socket, void *buf, int nbytes)
+{
+       struct timeval                          timeout2;
+       fd_set                                  readfds;
+       int                                                     actual = 0;
+       
+       FD_ZERO(&readfds);
+       FD_SET(AT_socket, &readfds);
+
+       timeout2.tv_sec     = 3;
+       timeout2.tv_usec    = 0;
+
+       if (select(AT_socket+1, &readfds, NULL, NULL, &timeout2))
+       {
+               actual = read(AT_socket, buf, nbytes);
+               if (actual == -1) {
+                       printf("UART_PSI_read error\n");
+               }               
+       }
+       
+       return actual;
+}
+
+int UART_PSI_write(int AT_socket, void *buf, int nbytes)
+{
+    int             ret;
+    size_t          actual = 0;
+       unsigned char *p = buf;
+
+       do {
+        ret = write(AT_socket, p, nbytes - actual);
+        if (ret < 0 && errno == EAGAIN)
+            continue;
+
+        if (ret < 0) {
+            if (actual != nbytes)
+                               printf("UART_PSI_write error\n");
+                       return actual;
+        }
+
+        actual  += ret;
+        p       += ret;
+    } while (actual < nbytes);
+
+    return actual;
+}
+
+
+int UART_PSI_load (void)
+{
+       int AT_socket;  
+       struct sockaddr_in AT_addr;
+       long sockarg;
+       struct timeval tv;
+       fd_set fdset;
+       socklen_t lon;
+       int valopt;
+       unsigned char ch;
+       int length = 0;
+       unsigned int data_len = 0;
+       unsigned char *data_buffer;
+       int i;
+       int nCRC = 0;
+       int at_num = 0;
+       unsigned char *pDataPSI;
+       unsigned char PSI_Header[InfoSize]={0,};
+       int retry = 0;
+
+       AT_socket = socket(PF_INET, SOCK_STREAM, 0);
+       if(AT_socket < 0) {
+               printf("Create AT socket failed\n");
+               goto error;
+       }
+       /* Set to non-blocking socket */
+       sockarg =  fcntl(AT_socket, F_GETFL, NULL);
+       sockarg |= O_NONBLOCK;
+       fcntl(AT_socket, F_SETFL, sockarg);                             
+
+               
+       bzero((char *)&AT_addr, sizeof(AT_addr));
+       AT_addr.sin_family = AF_INET;
+       AT_addr.sin_addr.s_addr = inet_addr(UART_PSI_IP);
+
+       AT_addr.sin_port = htons(UART_PSI_PORT);
+
+       while(connect(AT_socket, (struct sockaddr*)&AT_addr,sizeof(AT_addr)) < 0) {             
+               if(errno == EINPROGRESS) {
+                       /* Try 3 seconds more */
+                       tv.tv_sec = 3;
+                       tv.tv_usec = 0;
+                       FD_ZERO(&fdset);
+                       FD_SET(AT_socket, &fdset);
+                       if (select(AT_socket+1, NULL, &fdset, NULL, &tv) > 0) {
+                               lon = sizeof(int);
+                               getsockopt(AT_socket, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
+                       }
+
+               }
+               sleep(1);
+               if(retry ++ >= 10)
+                       goto error;;
+       }
+
+       printf("Connect with AP successfully\n");
+       
+       /* Waiting for the "AT" Command from AP */
+       while(1) {              
+               ch = 0;
+               length = UART_PSI_read(AT_socket, (void *)&ch, sizeof(unsigned char));
+               if (length < 0) {
+                       printf("AT read failed\n");
+                       goto error;
+               }
+               if(ch == 'A') {
+                       ch = 0;
+                       length = UART_PSI_read(AT_socket, (void *)&ch, sizeof(unsigned char));
+                       if (length < 0) {
+                               printf("AT read failed\n");
+                               goto error;
+                       }
+                               
+                       if(ch == 'T') {
+                               at_num ++;
+                               if(at_num == UART_PSI_RETRY)
+                               break;
+                       }
+               }
+       }                       
+
+       /* Send VERS back to AP */
+       ch = VERS;
+       length = UART_PSI_write(AT_socket, &ch, sizeof(unsigned char));
+       if (length <= 0) {
+               printf("VERS write failed\n");
+               goto error;
+       }
+       else
+               printf("Has written Version number\n");
+
+       /* Send Version version back to AP */
+       ch = InfoSize;
+       length = UART_PSI_write(AT_socket, &ch, sizeof(unsigned char));
+       if (length <= 0) {
+               printf("InfoSize write failed\n");
+               goto error;
+       }
+       else
+               printf("Has written InfoSize\n");
+
+       /* Write header to AP */        
+       for(i=0; i< InfoSize; i++) {
+               length = UART_PSI_write(AT_socket, PSI_Header, sizeof(unsigned char));
+               if(length <=0) {
+                       printf("Write header failed\n");
+                       goto error;
+               }
+       }       
+       
+       /* Read Indication from AP */
+       ch = 0;
+       length = UART_PSI_read(AT_socket, (void *)&ch, sizeof(unsigned char));
+       if (length <= 0) {
+               printf("Failed to get INDICATION from AP\n");
+               goto error;
+       }       
+       else {  
+               if(ch == IND) {
+                       printf("Get IND from AP\n");
+               }
+               else {
+                       printf("Unknow IND\n");
+                       goto error;
+               }
+                       
+       }
+
+       /* Read length from AP in little end format */
+       data_len = 0;
+       length = UART_PSI_read(AT_socket, (void *)&data_len, 2 * sizeof(unsigned char));
+       if (length <= 0) {
+               printf("Failed to get Length from AP\n");
+               goto error;
+       }               
+       else {
+               printf("Data length is %d\n", data_len);
+       }
+       
+       /* Read PSI from AP */
+       data_buffer = (unsigned char *)malloc(data_len);
+       bzero((char *)data_buffer, data_len);
+
+       nCRC = 0;
+       pDataPSI = data_buffer;
+
+       for(i=0; i< data_len; i++) {
+               length = UART_PSI_read(AT_socket, pDataPSI, sizeof(unsigned char));
+               if(length <=0) {
+                       printf("read PSI failed\n");
+                       goto error;
+               }
+               nCRC ^= *pDataPSI++;
+       }
+       
+
+       /* Read CRC of PSI */
+       ch = 0;
+       length = UART_PSI_read(AT_socket, (void *)&ch, sizeof(unsigned char));
+       if (length <= 0) {
+               printf("Failed to get CRC from AP\n");
+               goto error;
+       }               
+       else {
+               printf("CRC is %d\n", ch);
+               if(ch == nCRC)
+                       printf("CRC is correct!\n");
+               else {
+                       printf("CRC is wrong!\n");
+                       goto error;
+               }
+       }
+                       
+                       
+       /* Send ACK to AP */
+       ch = CRC_OK;
+       length = UART_PSI_write(AT_socket, &ch, sizeof(unsigned char));
+       if (length <= 0) {
+               printf("Failed to write CRC_OK to AP\n");
+               goto error;
+       }
+
+       /* Finish the downloading of PSI*/
+       close(AT_socket);       
+       return 1;
+       
+error:
+       if(AT_socket > 0)
+               close(AT_socket);
+       return 0;
+}
+
+static GSM_Error onedram_close(GSM_StateMachine *s)
+{
+       /* need to check what vgsm_server_port used for */
+       if( vgsm_server_port > 0 ) {
+                 GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+                 close(d->hPhone);
+                 return ERR_NONE;
+       }
+       else {
+               GSM_Device_DPRAMData *d = &s->Device.Data.DPRAM;
+           close(d->hPhone);
+           return ERR_NONE;
+       }
+}
+
+static GSM_Error onedram_open (GSM_StateMachine *s)
+{
+       GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+
+       struct sockaddr_in onedram_addr;
+       long sockarg;
+       struct timeval tv;
+       fd_set fdset;
+       socklen_t lon;
+       int valopt;
+       char buffer[BUFFER_SIZE];
+       unsigned int send_buf = CONNECT_AT;
+       int length = 0;
+       
+       if( vgsm_server_port > 0 ){
+               d->Power = false;
+               return ERR_NONE;
+       }
+
+       log_msg(MSGL_VGSM_INFO,"[%s] onedram open\n", DEBUG_TITLE);     
+
+       if(!UART_PSI_load()) {
+               GSM_OSErrorInfo(s,"Faile to load the PSI from AP\n");
+               goto error;
+       }
+               
+       d->hPhone = socket(PF_INET, SOCK_STREAM, 0);
+       if(d->hPhone < 0) {
+               GSM_OSErrorInfo(s,"Create vmodem socket failed\n");
+               goto error;
+       }
+       /* Set to non-blocking socket */
+       sockarg =  fcntl(d->hPhone, F_GETFL, NULL);
+       sockarg |= O_NONBLOCK;
+       fcntl(d->hPhone, F_SETFL, sockarg);                             
+
+       bzero((char *)&onedram_addr, sizeof(onedram_addr));
+       onedram_addr.sin_family = AF_INET;
+       onedram_addr.sin_addr.s_addr = inet_addr(ONEDRAM_IP);
+       
+       onedram_addr.sin_port = htons(ONEDRAM_PORT);
+
+       if(connect(d->hPhone, (struct sockaddr*)&onedram_addr,sizeof(onedram_addr)) < 0) {              
+               if(errno == EINPROGRESS) {
+                       /* Try 3 seconds more */
+                       tv.tv_sec = 3;
+                       tv.tv_usec = 0;
+                       FD_ZERO(&fdset);
+                       FD_SET(d->hPhone, &fdset);
+                       if (select(d->hPhone+1, NULL, &fdset, NULL, &tv) > 0) {
+                               lon = sizeof(int);
+                               getsockopt(d->hPhone, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
+                               if(valopt) {
+                                       GSM_OSErrorInfo(s,"Connect to onedram server failed\n");
+                                       goto error;
+                               }
+                       }
+                       else {
+                               GSM_OSErrorInfo(s,"Connect to onedram server time out\n");
+                               goto error;
+                       }
+               }
+               else {
+                       GSM_OSErrorInfo(s,"Connect to onedram server time out\n");
+                       goto error;
+               }                                               
+       }       
+       onedram_write(s, &send_buf, 4);
+
+       if((length = onedram_read(s, (void *)buffer, (size_t)BUFFER_SIZE))> 0) {
+               unsigned int CMD = (unsigned int)(buffer[0]);
+               if(CMD == CONNECT_RES)
+                       printf("Connected with onedram\n");
+               else {
+                       GSM_OSErrorInfo(s,"Unknow ACK from onedram");
+                       goto error;
+               }                       
+       }
+       else {
+               GSM_OSErrorInfo(s,"No response from onedram");
+               goto error;
+       }
+
+       d->Power = true;
+       return ERR_NONE;
+       
+error:
+       if(d->hPhone > 0)
+               close(d->hPhone);
+       d->Power = false;
+       return ERR_DEVICEOPENERROR;
+
+}
+
+static int onedram_poweron(GSM_StateMachine * s, int first_boot)
+{
+       GSM_Phone_Data          *Data = &s->Phone.Data;
+       Data->PhonePower = true;
+       return 1;
+}
+
+
+static int onedram_poweroff(GSM_StateMachine * s)
+{
+       GSM_Phone_Data          *Data = &s->Phone.Data;
+       Data->PhonePower = false;
+       return 1;
+
+}
+
+static int onedram_read(GSM_StateMachine *s, void *buf, size_t nbytes)
+{
+       GSM_Device_DPRAMData            *d = &s->Device.Data.DPRAM;
+       struct timeval                          timeout2;
+       fd_set                                  readfds;
+       int                                                     actual = 0;
+
+       FD_ZERO(&readfds);
+       FD_SET(d->hPhone, &readfds);
+
+       timeout2.tv_sec     = 1;
+       timeout2.tv_usec    = 1;
+
+       if  (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2))
+       {
+               actual = read(d->hPhone, buf, nbytes);
+               if (actual == -1)
+                       GSM_OSErrorInfo(s,"onedram_read");
+       }
+       return actual;
+}
+
+static int onedram_write(GSM_StateMachine *s, void *buf, size_t nbytes)
+{
+    GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+    int             ret;
+    size_t          actual = 0;
+       unsigned char *p = buf;
+
+       do {
+        ret = write(d->hPhone, p, nbytes - actual);
+        if (ret < 0 && errno == EAGAIN)
+            continue;
+
+        if (ret < 0) {
+            if (actual != nbytes)
+                               GSM_OSErrorInfo(s, "dpram_write");
+                       return actual;
+        }
+
+        actual  += ret;
+        p       += ret;
+    } while (actual < nbytes);
+
+    return actual;
+}
+
+static bool onedram_powerstatus(GSM_StateMachine *s)
+{
+    GSM_Device_DPRAMData   *d = &s->Device.Data.DPRAM;
+
+       log_msg(MSGL_VGSM_INFO,"\n");
+       
+    return d->Power;
+}
+
+static int onedram_write_magic_code(GSM_StateMachine * s, unsigned char req)
+{
+       return 1;
+}
+
+GSM_Device_Functions DPRAMDevice = {
+    onedram_open,
+    onedram_close,
+    onedram_read,
+    onedram_write,
+    onedram_poweron,
+    onedram_poweroff,
+    onedram_powerstatus,
+    onedram_write_magic_code
+};
+
+