diff options
-rw-r--r-- | Android.mk | 20 | ||||
-rw-r--r-- | call.c | 59 | ||||
-rw-r--r-- | include/call.h | 81 | ||||
-rw-r--r-- | include/disp.h | 32 | ||||
-rw-r--r-- | include/misc.h | 40 | ||||
-rw-r--r-- | include/net.h | 87 | ||||
-rw-r--r-- | include/radio.h | 195 | ||||
-rw-r--r-- | include/sec.h | 53 | ||||
-rw-r--r-- | include/sms.h | 60 | ||||
-rw-r--r-- | include/util.h | 23 | ||||
-rw-r--r-- | misc.c | 4 | ||||
-rw-r--r-- | net.c | 2 | ||||
-rw-r--r-- | radio.c | 46 | ||||
-rw-r--r-- | radio_internal.h | 5 | ||||
-rw-r--r-- | sms.c | 33 | ||||
-rw-r--r-- | util.c | 119 |
16 files changed, 657 insertions, 202 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..57109b7 --- /dev/null +++ b/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +libmsm-h1_files := \ + radio.c \ + util.c \ + hexdump.c \ + call.c \ + sms.c \ + net.c \ + misc.c + +LOCAL_MODULE := libmsm-h1 +LOCAL_MODULE_TAGS := optional + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include + +LOCAL_SRC_FILES := $(libmsm-h1_files) +include $(BUILD_STATIC_LIBRARY) + @@ -0,0 +1,59 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <call.h> +#include "radio_internal.h" + +void msm_call_outgoing(const char *number, int identity, int request_id) +{ + struct msm_call_outgoing call; + + memset(&call, 0x00, sizeof(call)); + + if(strlen(number) > 82) { + printf("Outgoing call number too long\n"); + return; + } + + call.type = MSM_CALL_TYPE_VOICE; + call.identity = identity; + call.prefix = MSM_CALL_PREFIX_NONE; + + call.length = strlen(number); + memcpy(call.number, number, call.length); + + msm_send(MSM_CALL_OUTGOING, MSM_TYPE_EXEC, (unsigned char*)&call, sizeof(call), request_id); +} + +void msm_call_release(int request_id) +{ + msm_send_exec(MSM_CALL_RELEASE, request_id); +} + +void msm_call_answer(int request_id) +{ + msm_send_exec(MSM_CALL_ANSWER, request_id); +} + +void msm_call_list(int request_id) +{ + msm_send_get(MSM_CALL_LIST, request_id); +} + diff --git a/include/call.h b/include/call.h new file mode 100644 index 0000000..7438d1d --- /dev/null +++ b/include/call.h @@ -0,0 +1,81 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __CALL_H__ +#define __CALL_H__ + +/* Message types */ +#define MSM_CALL_OUTGOING 0x0201 +#define MSM_CALL_INCOMING 0x0202 +#define MSM_CALL_RELEASE 0x0203 +#define MSM_CALL_ANSWER 0x0204 +#define MSM_CALL_STATUS 0x0205 +#define MSM_CALL_LIST 0x0206 +#define MSM_CALL_BURST_DTMF 0x0207 +#define MSM_CALL_CONT_DTMF 0x0208 +#define MSM_CALL_WAITING 0x0209 +#define MSM_CALL_LINE_ID 0x020A + +/* Enum values */ +#define MSM_CALL_TYPE_VOICE 0x01 +#define MSM_CALL_TYPE_DATA 0x03 + +#define MSM_CALL_IDENTITY_DEFAULT 0x00 +#define MSM_CALL_IDENTITY_HIDE 0x01 +#define MSM_CALL_IDENTITY_SHOW 0x02 + +#define MSM_CALL_PREFIX_NONE 0x00 +#define MSM_CALL_PREFIX_INTL 0x11 + +#define MSM_CALL_STATE_DIALING 0x01 +#define MSM_CALL_STATE_IGNORING_INCOMING_STATUS 0x02 +#define MSM_CALL_STATE_CONNECTED 0x03 +#define MSM_CALL_STATE_RELEASED 0x04 +#define MSM_CALL_STATE_CONNECTING 0x05 + +struct msm_call_outgoing { + unsigned char type, identity; + unsigned char length, prefix; + unsigned char number[86]; +} __attribute__((__packed__)); + +struct msm_call_incoming { + unsigned char type, id, line; +} __attribute__((__packed__)); + +struct msm_call_list_entry { + unsigned char type, idx; + unsigned char term, state, unk3; + unsigned char number_len; + unsigned char unk4; +} __attribute__((__packed__)); + +struct msm_call_status { + unsigned char type, id, state; + unsigned char reason, end_cause; +} __attribute__((__packed__)); + +void msm_call_outgoing(const char *number, int identity, int request_id); +void msm_call_release(int request_id); +void msm_call_answer(int request_id); +void msm_call_list(int request_id); + +#endif + diff --git a/include/disp.h b/include/disp.h new file mode 100644 index 0000000..8b14d5c --- /dev/null +++ b/include/disp.h @@ -0,0 +1,32 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __DISP_H__ +#define __DISP_H__ + +#define MSM_DISP_ICON_INFO 0x0701 +#define MSM_DISP_HOMEZONE_INFO 0x0702 + +struct msm_disp_icon_info { + unsigned char unk, rssi, battery, act, reg; +} __attribute__((__packed__)); + +#endif + diff --git a/include/misc.h b/include/misc.h new file mode 100644 index 0000000..d964f91 --- /dev/null +++ b/include/misc.h @@ -0,0 +1,40 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __MISC_H__ +#define __MISC_H__ + +#define MSM_MISC_ME_VERSION 0x0A01 +#define MSM_MISC_ME_IMSI 0x0A02 +#define MSM_MISC_ME_SN 0x0A03 +#define MSM_MISC_TIME_INFO 0x0A07 + +struct msm_misc_time_info { + unsigned char tzv, dlv; + unsigned char year, mon, day; + unsigned char hour, min, sec; + unsigned char tz, dl, dv; + char plmn[6]; +} __attribute__((__packed__)); + +void msm_misc_me_sn(int request_id); + +#endif + diff --git a/include/net.h b/include/net.h new file mode 100644 index 0000000..84b1599 --- /dev/null +++ b/include/net.h @@ -0,0 +1,87 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __NET_H__ +#define __NET_H__ + +#define MSM_NET_PREF_PLMN 0x0801 +#define MSM_NET_PLMN_SEL 0x0802 +#define MSM_NET_CURRENT_PLMN 0x0803 +#define MSM_NET_PLMN_LIST 0x0804 +#define MSM_NET_REGIST 0x0805 +#define MSM_NET_SUBSCRIBER_NUM 0x0806 +#define MSM_NET_BAND_SEL 0x0807 +#define MSM_NET_SERVICE_DOMAIN_CONFIG 0x0808 +#define MSM_NET_POWERON_ATTACH 0x0809 +#define MSM_NET_MODE_SEL 0x080A +#define MSM_NET_ACQ_ORDER 0x080B +#define MSM_NET_IDENTITY 0x080C +#define MSM_NET_CURRENT_RRC_STATUS 0x080D + +#define MSM_NET_SERVICE_TYPE_GSM 0x01 +#define MSM_NET_SERVICE_TYPE_GSM2 0x02 +#define MSM_NET_SERVICE_TYPE_GPRS 0x03 +#define MSM_NET_SERVICE_TYPE_EDGE 0x04 +#define MSM_NET_SERVICE_TYPE_UMTS 0x05 + +#define MSM_NET_SERVICE_LEVEL_NONE 0x01 +#define MSM_NET_SERVICE_LEVEL_HOME 0x02 +#define MSM_NET_SERVICE_LEVEL_SEARCHING 0x03 +#define MSM_NET_SERVICE_LEVEL_EMERGENCY 0x04 +#define MSM_NET_SERVICE_LEVEL_NONE2 0x05 +#define MSM_NET_SERVICE_LEVEL_ROAMING 0x06 + +#define MSM_NET_PLMN_STATUS_AVAILABLE 2 +#define MSM_NET_PLMN_STATUS_CURRENT 3 +#define MSM_NET_PLMN_STATUS_FORBIDDEN 4 + +struct msm_net_current_plmn { + char unk; + unsigned char slevel; + char plmn[6]; + unsigned char type; + unsigned short lac; +} __attribute__((__packed__)); + +struct msm_net_regist { + unsigned char act, unk0, status, unk1; + unsigned short lac; + unsigned int cid; + char unk2; +} __attribute__((__packed__)); + +struct msm_net_plmn_entry { + unsigned char status; + char plmn[6]; + unsigned char type; + char unk[2]; +} __attribute__((__packed__)); + +struct msm_net_plmn_entries { + unsigned char num; + struct msm_net_plmn_entry *data; +}; + +void msm_net_current_plmn(int request_id); +void msm_net_plmn_list(int request_id); +void msm_net_identity(int request_id); + +#endif + diff --git a/include/radio.h b/include/radio.h index d2267a9..0e9534b 100644 --- a/include/radio.h +++ b/include/radio.h @@ -21,6 +21,13 @@ #ifndef __RADIO_H__ #define __RADIO_H__ +#include "call.h" +#include "disp.h" +#include "misc.h" +#include "net.h" +#include "sec.h" +#include "sms.h" + /* AP -> Baseband */ #define MSM_TYPE_EXEC 0x01 #define MSM_TYPE_GET 0x02 @@ -33,7 +40,7 @@ #define MSM_TYPE_RESP 0x02 #define MSM_TYPE_NOTI 0x03 -/* MSM message groups */ +/* Message groups */ #define MSM_GROUP_PWR 0x01 #define MSM_GROUP_CALL 0x02 #define MSM_GROUP_SMS 0x04 @@ -61,48 +68,6 @@ #define MSM_PWR_BATT_COMP 0x0106 #define MSM_PWR_PHONE_ONLINE 0x0107 -/* Call */ -#define MSM_CALL_OUTGOING 0x0201 -#define MSM_CALL_INCOMING 0x0202 -#define MSM_CALL_RELEASE 0x0203 -#define MSM_CALL_ANSWER 0x0204 -#define MSM_CALL_STATUS 0x0205 -#define MSM_CALL_LIST 0x0206 -#define MSM_CALL_BURST_DTMF 0x0207 -#define MSM_CALL_CONT_DTMF 0x0208 -#define MSM_CALL_WAITING 0x0209 -#define MSM_CALL_LINE_ID 0x020A - -/* SMS */ -#define MSM_SMS_SEND_MSG 0x0401 -#define MSM_SMS_INCOMING_MSG 0x0402 -#define MSM_SMS_READ_MSG 0x0403 -#define MSM_SMS_SAVE_MSG 0x0404 -#define MSM_SMS_DEL_MSG 0x0405 -#define MSM_SMS_DELIVER_REPORT 0x0406 -#define MSM_SMS_DEVICE_READY 0x0407 -#define MSM_SMS_SEL_MEM 0x0408 -#define MSM_SMS_STORED_MSG_COUNT 0x0409 -#define MSM_SMS_SVC_CENTER_ADDR 0x040A -#define MSM_SMS_SVC_OPTION 0x040B -#define MSM_SMS_MEM_STATUS 0x040C -#define MSM_SMS_CBS_MSG 0x040D -#define MSM_SMS_CBS_CONFIG 0x040E -#define MSM_SMS_STORED_MSG_STATUS 0x040F -#define MSM_SMS_PARAM_COUNT 0x0410 -#define MSM_SMS_PARAM 0x0411 - -/* Sec */ -#define MSM_SEC_PIN_STATUS 0x0501 -#define MSM_SEC_PHONE_LOCK 0x0502 -#define MSM_SEC_CHANGE_LOCKING_PW 0x0503 -#define MSM_SEC_SIM_LANG 0x0504 -#define MSM_SEC_RSIM_ACCESS 0x0505 -#define MSM_SEC_GSIM_ACCESS 0x0506 -#define MSM_SEC_SIM_ICC_TYPE 0x0507 -#define MSM_SEC_LOCK_INFO 0x0508 -#define MSM_SEC_ISIM_AUTH 0x0509 - /* Pb */ #define MSM_PB_ACCESS 0x0601 #define MSM_PB_STORAGE 0x0602 @@ -110,30 +75,17 @@ #define MSM_PB_ENTRY_INFO 0x0604 #define MSM_PB_CAPABILITY_INFO 0x0605 -/* Disp */ -#define MSM_DISP_ICON_INFO 0x0701 -#define MSM_DISP_HOMEZONE_INFO 0x0702 - -/* Net */ -#define MSM_NET_PREF_PLMN 0x0801 -#define MSM_NET_PLMN_SEL 0x0802 -#define MSM_NET_CURRENT_PLMN 0x0803 -#define MSM_NET_PLMN_LIST 0x0804 -#define MSM_NET_REGIST 0x0805 -#define MSM_NET_SUBSCRIBER_NUM 0x0806 -#define MSM_NET_BAND_SEL 0x0807 -#define MSM_NET_SERVICE_DOMAIN_CONFIG 0x0808 -#define MSM_NET_POWERON_ATTACH 0x0809 -#define MSM_NET_MODE_SEL 0x080A -#define MSM_NET_ACQ_ORDER 0x080B -#define MSM_NET_IDENTITY 0x080C -#define MSM_NET_CURRENT_RRC_STATUS 0x080D - -/* Misc */ -#define MSM_MISC_ME_VERSION 0x0A01 -#define MSM_MISC_ME_IMSI 0x0A02 -#define MSM_MISC_ME_SN 0x0A03 -#define MSM_MISC_TIME_INFO 0x0A07 +/* SS */ +#define MSM_SS_WAITING 0x0C01 +#define MSM_SS_CLI 0x0C02 +#define MSM_SS_BARRING 0x0C03 +#define MSM_SS_BARRING_PW 0x0C04 +#define MSM_SS_FORWARDING 0x0C05 +#define MSM_SS_INFO 0x0C06 +#define MSM_SS_MANAGE_CALL 0x0C07 +#define MSM_SS_USSD 0x0C08 +#define MSM_SS_AOC 0x0C09 +#define MSM_SS_RELEASE_COMPLETE 0x0C0A /* GPRS */ #define MSM_GPRS_DEFINE_PDP_CONTEXT 0x0D01 @@ -170,51 +122,6 @@ #define MSM_IMEI_START 0x1001 #define MSM_IMEI_CHECK_DEVICE_INFO 0x1002 -/* Call info */ -#define MSM_CALL_TYPE_VOICE 0x01 -#define MSM_CALL_TYPE_DATA 0x03 - -#define MSM_CALL_IDENTITY_DEFAULT 0x00 -#define MSM_CALL_IDENTITY_HIDE 0x01 -#define MSM_CALL_IDENTITY_SHOW 0x02 - -#define MSM_CALL_PREFIX_NONE 0x00 -#define MSM_CALL_PREFIX_INTL 0x11 - -#define MSM_CALL_STATE_DIALING 0x00 -#define MSM_CALL_STATE_IGNORING_INCOMING_STATUS 0x01 -#define MSM_CALL_STATE_CONNECTED 0x02 -#define MSM_CALL_STATE_RELEASED 0x03 -#define MSM_CALL_STATE_CONNECTING 0x04 - -/* Sec pin status */ -#define MSM_SEC_PIN_SIM_INITIALIZING 0x00 -#define MSM_SEC_PIN_SIM_NSIDE_PF_ERROR 0x02 -#define MSM_SEC_PIN_SIM_LOCK_SC 0x03 -#define MSM_SEC_PIN_SIM_LOCK_FD 0x04 -#define MSM_SEC_PIN_SIM_CARD_NOT_PRESENT 0x80 -#define MSM_SEC_PIN_SIM_CARD_ERROR 0x81 -#define MSM_SEC_PIN_SIM_INIT_COMPLETE 0x82 -#define MSM_SEC_PIN_SIM_PB_INIT_COMPLETE 0x83 - -#define MSM_SEC_PIN_SIM_LOCK_SC_PIN1_REQ 0x01 -#define MSM_SEC_PIN_SIM_LOCK_SC_PUK_REQ 0x02 -#define MSM_SEC_PIN_SIM_LOCK_SC_CARD_BLOCKED 0x05 - -/* Network info */ -#define MSM_NET_SERVICE_TYPE_GSM 0x01 -#define MSM_NET_SERVICE_TYPE_GSM2 0x02 -#define MSM_NET_SERVICE_TYPE_GPRS 0x03 -#define MSM_NET_SERVICE_TYPE_EDGE 0x04 -#define MSM_NET_SERVICE_TYPE_UMTS 0x05 - -#define MSM_NET_SERVICE_LEVEL_NONE 0x01 -#define MSM_NET_SERVICE_LEVEL_HOME 0x02 -#define MSM_NET_SERVICE_LEVEL_SEARCHING 0x03 -#define MSM_NET_SERVICE_LEVEL_EMERGENCY 0x04 -#define MSM_NET_SERVICE_LEVEL_NONE2 0x05 -#define MSM_NET_SERVICE_LEVEL_ROAMING 0x06 - #define FRAME_START 0x7f #define FRAME_END 0x7e @@ -237,65 +144,6 @@ struct msm_info { void (*on_receive)(struct msm_request_info *info); }; -struct msm_time_info { - char unk[2]; - unsigned char year, mon, day; - unsigned char hour, min, sec; - unsigned char unk2, tz, unk3; - unsigned char plmn[6]; -} __attribute__((__packed__)); - -struct msm_pin_status { - unsigned char type; - unsigned char key; -} __attribute__((__packed__)); - -struct msm_call_outgoing { - unsigned char type, identity; - unsigned char length, prefix; - unsigned char number[86]; -} __attribute__((__packed__)); - -struct msm_call_incoming { - unsigned char type, id, line; -} __attribute__((__packed__)); - -struct msm_call_status { - unsigned char type, id, state; - unsigned char reason, end_cause; -} __attribute__((__packed__)); - -struct msm_disp_icon_info { - unsigned char rssi, battery, act, reg; -} __attribute__((__packed__)); - -struct msm_net_current_plmn { - char unk; - unsigned char slevel; - unsigned char plmn[6]; - unsigned char type; - unsigned short lac; -} __attribute__((__packed__)); - -struct msm_net_regist { - unsigned char act, unk0, status, unk1; - unsigned short lac; - unsigned int cid; - char unk2; -} __attribute__((__packed__)); - -struct msm_net_plmn_entry { - unsigned char slevel; - unsigned char plmn[6]; - unsigned char type; - char unk[2]; -} __attribute__((__packed__)); - -struct msm_net_plmn_entries { - unsigned char num; - struct msm_net_plmn_entry *data; -}; - void msm_register(struct msm_info *msm); void msm_open(); void msm_close(); @@ -303,10 +151,5 @@ void msm_power_on(); void msm_power_off(); void msm_loop(); -void msm_misc_me_sn(int request_id); -void msm_net_current_plmn(int request_id); -void msm_net_plmn_list(int request_id); -void msm_net_identity(int request_id); - #endif diff --git a/include/sec.h b/include/sec.h new file mode 100644 index 0000000..9f50ca6 --- /dev/null +++ b/include/sec.h @@ -0,0 +1,53 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __SEC_H__ +#define __SEC_H__ + +#define MSM_SEC_PIN_STATUS 0x0501 +#define MSM_SEC_PHONE_LOCK 0x0502 +#define MSM_SEC_CHANGE_LOCKING_PW 0x0503 +#define MSM_SEC_SIM_LANG 0x0504 +#define MSM_SEC_RSIM_ACCESS 0x0505 +#define MSM_SEC_GSIM_ACCESS 0x0506 +#define MSM_SEC_SIM_ICC_TYPE 0x0507 +#define MSM_SEC_LOCK_INFO 0x0508 +#define MSM_SEC_ISIM_AUTH 0x0509 + +#define MSM_SEC_PIN_SIM_INITIALIZING 0x00 +#define MSM_SEC_PIN_SIM_NSIDE_PF_ERROR 0x02 +#define MSM_SEC_PIN_SIM_LOCK_SC 0x03 +#define MSM_SEC_PIN_SIM_LOCK_FD 0x04 +#define MSM_SEC_PIN_SIM_CARD_NOT_PRESENT 0x80 +#define MSM_SEC_PIN_SIM_CARD_ERROR 0x81 +#define MSM_SEC_PIN_SIM_INIT_COMPLETE 0x82 +#define MSM_SEC_PIN_SIM_PB_INIT_COMPLETE 0x83 + +#define MSM_SEC_PIN_SIM_LOCK_SC_PIN1_REQ 0x01 +#define MSM_SEC_PIN_SIM_LOCK_SC_PUK_REQ 0x02 +#define MSM_SEC_PIN_SIM_LOCK_SC_CARD_BLOCKED 0x05 + +struct msm_sec_pin_status { + unsigned char type; + unsigned char key; +} __attribute__((__packed__)); + +#endif + diff --git a/include/sms.h b/include/sms.h new file mode 100644 index 0000000..b7c3154 --- /dev/null +++ b/include/sms.h @@ -0,0 +1,60 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __SMS_H__ +#define __SMS_H__ + +#define MSM_SMS_SEND_MSG 0x0401 +#define MSM_SMS_INCOMING_MSG 0x0402 +#define MSM_SMS_READ_MSG 0x0403 +#define MSM_SMS_SAVE_MSG 0x0404 +#define MSM_SMS_DEL_MSG 0x0405 +#define MSM_SMS_DELIVER_REPORT 0x0406 +#define MSM_SMS_DEVICE_READY 0x0407 +#define MSM_SMS_SEL_MEM 0x0408 +#define MSM_SMS_STORED_MSG_COUNT 0x0409 +#define MSM_SMS_SVC_CENTER_ADDR 0x040A +#define MSM_SMS_SVC_OPTION 0x040B +#define MSM_SMS_MEM_STATUS 0x040C +#define MSM_SMS_CBS_MSG 0x040D +#define MSM_SMS_CBS_CONFIG 0x040E +#define MSM_SMS_STORED_MSG_STATUS 0x040F +#define MSM_SMS_PARAM_COUNT 0x0410 +#define MSM_SMS_PARAM 0x0411 + +#define MSM_SMS_MSG_MULTIPLE 1 +#define MSM_SMS_MSG_SINGLE 2 + +#define MSM_SMS_TYPE_POINT_TO_POINT 1 +#define MSM_SMS_TYPE_STATUS_REPORT 2 + +struct msm_sms_send_msg { + unsigned char hint, length; +} __attribute__((__packed__)); + +struct msm_sms_incoming_msg { + unsigned char type, unk, length; +} __attribute__((__packed__)); + +void msm_sms_send_msg(unsigned char *data, unsigned char length, int request_id); +void msm_sms_deliver_report(int request_id); + +#endif + diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..5d07499 --- /dev/null +++ b/include/util.h @@ -0,0 +1,23 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +const char *plmn_lookup(const char *plmn); +char *plmn_string(const char *plmn); +int android_rssi(const int rssi); @@ -44,12 +44,12 @@ void msm_rx_misc_me_sn(struct msm_request_info *info, char *data, int len) void msm_rx_misc_time_info(struct msm_request_info *info, char *data, int len) { - if(len != sizeof(struct msm_time_info)) { + if(len != sizeof(struct msm_misc_time_info)) { printf("Invalid NITZ message length\n"); return; } - struct msm_time_info *nitz = (struct msm_time_info*)data; + struct msm_misc_time_info *nitz = (struct msm_misc_time_info*)data; printf("%s: %02u-%02u-%04u %02u:%02u:%02u %02u\n", __FUNCTION__, nitz->day, nitz->mon, (2000 + nitz->year), nitz->hour, nitz->min, nitz->sec, nitz->tz); @@ -49,7 +49,7 @@ void msm_rx_net_plmn_list(struct msm_request_info *info, char *data, int len) struct msm_net_plmn_entries entries; entries.num = num_entries; - entries.data = (struct msm_net_current_plmn*)(data+1); + entries.data = (struct msm_net_plmn_entry*)(data+1); info->data = &entries; info->length = sizeof(entries); @@ -158,6 +158,16 @@ const char *msm_str(struct msm_hdr *frame) { FRAME_STR(MSM_MISC_ME_IMSI) FRAME_STR(MSM_MISC_ME_SN) FRAME_STR(MSM_MISC_TIME_INFO) + FRAME_STR(MSM_SS_WAITING) + FRAME_STR(MSM_SS_CLI) + FRAME_STR(MSM_SS_BARRING) + FRAME_STR(MSM_SS_BARRING_PW) + FRAME_STR(MSM_SS_FORWARDING) + FRAME_STR(MSM_SS_INFO) + FRAME_STR(MSM_SS_MANAGE_CALL) + FRAME_STR(MSM_SS_USSD) + FRAME_STR(MSM_SS_AOC) + FRAME_STR(MSM_SS_RELEASE_COMPLETE) FRAME_STR(MSM_GPRS_DEFINE_PDP_CONTEXT) FRAME_STR(MSM_GPRS_QOS) FRAME_STR(MSM_GPRS_PS) @@ -202,13 +212,14 @@ void msm_tx(const char *data, const int length) memcpy(hdlc+1, data, length); - printf("\n%s\n", __FUNCTION__); hex_dump(hdlc, frame_len); + printf("\n"); + write(fd, hdlc, frame_len); free(hdlc); } -void msm_send(const int type, const int method, const char *data, const int data_length, int request_id) +void msm_send(const int type, const int method, const unsigned char *data, const int data_length, int request_id) { struct msm_hdr header; unsigned int len = sizeof(header); @@ -227,6 +238,7 @@ void msm_send(const int type, const int method, const char *data, const int data memcpy(frame, &header, sizeof(header)); memcpy(frame+len, data, data_length); + printf("\n%s: %s\n", __FUNCTION__, msm_str(&header)); msm_tx(frame, frame_length); free(frame); } @@ -236,28 +248,16 @@ void msm_send_get(const int type, int request_id) msm_send(type, MSM_TYPE_GET, NULL, 0, request_id); } -void mem_pwr_phone_pwr_up(struct msm_request_info *info, const char *data, const int len) +void msm_send_exec(const int type, int request_id) { - usleep(25000); - msm_rx_callback(info); + msm_send(type, MSM_TYPE_EXEC, NULL, 0, request_id); } -void msm_call_outgoing(const char *number, int request_id) +void msm_pwr_phone_pwr_up(struct msm_request_info *info, const char *data, const int len) { - if(strlen(number) > 82) { - printf("Outgoing call number too long\n"); - return; - } - - struct msm_call_outgoing call; - memset(&call, 0x00, sizeof(call)); - call.type = MSM_CALL_TYPE_VOICE; - call.identity = MSM_CALL_IDENTITY_DEFAULT; - call.length = strlen(number); - call.prefix = MSM_CALL_PREFIX_NONE; - memcpy(call.number, number, call.length); - - msm_send(MSM_CALL_OUTGOING, MSM_TYPE_EXEC, (const char*)&call, sizeof(call), request_id); + /* Modem reports bogus IMEI if queried right after powerup */ + usleep(25000); + msm_rx_callback(info); } void msm_sec_pin_status(char *data, int len) @@ -275,13 +275,17 @@ void msm_decode_frame(char *frame, int length) { request_info.type = FRAME_ID(header); request_info.id = request_id; + /* FIXME: These args are also passed to each handler below? */ + request_info.data = data; + request_info.length = data_len; + printf("%s %s (%u/%u) seq=%d req=%d\n", msm_str(header), msm_type(header), header->frame_len, data_len, header->seqnum, header->reqid); hex_dump(frame, length); switch(request_info.type) { /* Power */ case MSM_PWR_PHONE_PWR_UP: - mem_pwr_phone_pwr_up(&request_info, data, data_len); + msm_pwr_phone_pwr_up(&request_info, data, data_len); break; /* Misc */ case MSM_MISC_ME_SN: diff --git a/radio_internal.h b/radio_internal.h index cee91ed..7ad99b9 100644 --- a/radio_internal.h +++ b/radio_internal.h @@ -42,7 +42,8 @@ void msm_rx_callback(struct msm_request_info *info); void msm_send_get(const int type, int request_id); -void msm_send(const int type, const int method, const char *data, const int data_length, int request_id); +void msm_send_exec(const int type, int request_id); +void msm_send(const int type, const int method, const unsigned char *data, const int data_length, int request_id); /* Misc */ void msm_rx_misc_me_sn(struct msm_request_info *info, char *data, int len); @@ -56,7 +57,7 @@ void msm_rx_net_regist(struct msm_request_info *info, const char *data, int len) struct msm_hdr { unsigned short frame_len; - unsigned char unk2; + unsigned char unk; unsigned short len; unsigned char seqnum, reqid, group, index, type; } __attribute__((__packed__)); @@ -0,0 +1,33 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "radio_internal.h" + +void msm_sms_send_msg(unsigned char *data, unsigned char length, int request_id) +{ + msm_send(MSM_SMS_SEND_MSG, MSM_TYPE_EXEC, data, length, request_id); +} + +void msm_sms_deliver_report(int request_id) +{ + unsigned char data[247] = { 0x00, 0x00, 0x03, 0x00, 0x02 }; + msm_send(MSM_SMS_DELIVER_REPORT, MSM_TYPE_EXEC, data, sizeof(data), request_id); +} + @@ -0,0 +1,119 @@ +/** + * This file is part of libmsm-h1. + * + * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * + * libmsm-h1 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 3 of the License, or + * (at your option) any later version. + * + * libmsm-h1 is distributed in the hope that 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 libmsm-h1. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include "hexdump.h" + +#ifdef ANDROID + +#define LOG_TAG "RIL" +#include <utils/Log.h> +#define printf LOGI + +#endif + +void hex_dump(void *data, int size) +{ + /* dumps size bytes of *data to stdout. Looks like: + * [0000] 75 6E 6B 6E 6F 77 6E 20 + * 30 FF 00 00 00 00 39 00 unknown 0.....9. + * (in a single line of course) + */ + + unsigned char *p = data; + unsigned char c; + int n; + char bytestr[4] = {0}; + char addrstr[10] = {0}; + char hexstr[ 16*3 + 5] = {0}; + char charstr[16*1 + 5] = {0}; + for(n=1;n<=size;n++) { + if (n%16 == 1) { + /* store address for this line */ + snprintf(addrstr, sizeof(addrstr), "%.4x", + ((unsigned int)p-(unsigned int)data) ); + } + + c = *p; + if (isalnum(c) == 0) { + c = '.'; + } + + /* store hex str (for left side) */ + snprintf(bytestr, sizeof(bytestr), "%02X ", *p); + strncat(hexstr, bytestr, sizeof(hexstr)-strlen(hexstr)-1); + + /* store char str (for right side) */ + snprintf(bytestr, sizeof(bytestr), "%c", c); + strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1); + + if(n%16 == 0) { + /* line completed */ + printf("[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr); + hexstr[0] = 0; + charstr[0] = 0; + } else if(n%8 == 0) { + /* half line: add whitespaces */ + strncat(hexstr, " ", sizeof(hexstr)-strlen(hexstr)-1); + strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1); + } + p++; /* next byte */ + } + + if (strlen(hexstr) > 0) { + /* print rest of buffer if not empty */ + printf("[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr); + } +} + +const char *plmn_lookup(const char *plmn) +{ + unsigned int mcc, mnc; + sscanf(plmn, "%3u%2u", &mcc, &mnc); + + switch(mcc) { + case 204: + switch(mnc) { + case 1: return "VastMobiel"; + case 2: return "Tele2"; + case 4: return "Vodafone"; + case 8: case 10: return "KPN"; + case 12: return "Telfort"; + case 16: case 20: return "T-Mobile"; + } + } + + return NULL; +} + +char *plmn_string(const char *plmn) +{ + int length = (plmn[5] == '#') ? 6 : 7; + + char *plmn_str = (char*)malloc(length); + + memcpy(plmn_str, plmn, length); + plmn_str[length-1] = '\0'; + + return plmn_str; +} + |