diff options
author | Simon Busch <morphis@gravedo.de> | 2012-08-29 12:33:25 +0200 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2012-08-29 12:33:25 +0200 |
commit | 3baa91e5ca8b5c5e7d6fe52023d6bd7d98e1b672 (patch) | |
tree | da8b8ed7b63d9132bd29b02f8ed2567d6e456eb9 | |
parent | c2509569de22560f8bd5eabdbdebf40eba030a29 (diff) | |
download | external_libsamsung-ipc-3baa91e5ca8b5c5e7d6fe52023d6bd7d98e1b672.zip external_libsamsung-ipc-3baa91e5ca8b5c5e7d6fe52023d6bd7d98e1b672.tar.gz external_libsamsung-ipc-3baa91e5ca8b5c5e7d6fe52023d6bd7d98e1b672.tar.bz2 |
sec: refactor type naming to be clean and not misleading
-rw-r--r-- | include/sec.h | 129 | ||||
-rw-r--r-- | samsung-ipc/sec.c | 10 | ||||
-rw-r--r-- | tools/modemctrl.c | 22 | ||||
-rw-r--r-- | vapi/samsung-ipc-1.0.vapi | 42 |
4 files changed, 126 insertions, 77 deletions
diff --git a/include/sec.h b/include/sec.h index 5c7b90b..a85d563 100644 --- a/include/sec.h +++ b/include/sec.h @@ -24,53 +24,69 @@ struct ipc_message_info; -#define IPC_SEC_PIN_STATUS 0x0501 -#define IPC_SEC_PHONE_LOCK 0x0502 -#define IPC_SEC_CHANGE_LOCKING_PW 0x0503 -#define IPC_SEC_SIM_LANG 0x0504 -#define IPC_SEC_RSIM_ACCESS 0x0505 -#define IPC_SEC_GSIM_ACCESS 0x0506 -#define IPC_SEC_SIM_ICC_TYPE 0x0507 -#define IPC_SEC_LOCK_INFO 0x0508 -#define IPC_SEC_ISIM_AUTH 0x0509 - -#define IPC_SEC_PIN_SIM_INITIALIZING 0x00 -#define IPC_SEC_PIN_SIM_SIM_LOCK_REQUIRED 0x01 -#define IPC_SEC_PIN_SIM_INSIDE_PF_ERROR 0x02 -#define IPC_SEC_PIN_SIM_LOCK_SC 0x03 -#define IPC_SEC_PIN_SIM_LOCK_FD 0x04 -#define IPC_SEC_PIN_SIM_LOCK_PN 0x05 -#define IPC_SEC_PIN_SIM_LOCK_PU 0x06 -#define IPC_SEC_PIN_SIM_LOCK_PP 0x07 -#define IPC_SEC_PIN_SIM_LOCK_PC 0x08 -#define IPC_SEC_PIN_SIM_CARD_NOT_PRESENT 0x80 -#define IPC_SEC_PIN_SIM_CARD_ERROR 0x81 -#define IPC_SEC_PIN_SIM_INIT_COMPLETE 0x82 -#define IPC_SEC_PIN_SIM_PB_INIT_COMPLETE 0x83 - -/* Key types for the SIM card (SC) facility */ -#define IPC_SEC_PIN_SIM_LOCK_SC_PIN1_REQ 0x01 -#define IPC_SEC_PIN_SIM_LOCK_SC_PUK_REQ 0x02 -#define IPC_SEC_PIN_SIM_LOCK_SC_CARD_BLOCKED 0x05 - -#define IPC_SEC_PIN_TYPE_PIN1 0x03 -#define IPC_SEC_PIN_TYPE_PIN2 0x09 - -#define IPC_SEC_SIM_CARD_TYPE_UNKNOWN 0x00 -#define IPC_SEC_SIM_CARD_TYPE_SIM 0x01 -#define IPC_SEC_SIM_CARD_TYPE_USIM 0x02 - -#define IPC_SEC_RSIM_COMMAND_READ_BINARY 0xb0 -#define IPC_SEC_RSIM_COMMAND_READ_RECORD 0xc0 -#define IPC_SEC_RSIM_COMMAND_UPDATE_BINARY 0xd6 -#define IPC_SEC_RSIM_COMMAND_STATUS 0xf2 +/* Possible SEC related IPC message types */ +#define IPC_SEC_PIN_STATUS 0x0501 +#define IPC_SEC_PHONE_LOCK 0x0502 +#define IPC_SEC_CHANGE_LOCKING_PW 0x0503 +#define IPC_SEC_SIM_LANG 0x0504 +#define IPC_SEC_RSIM_ACCESS 0x0505 +#define IPC_SEC_GSIM_ACCESS 0x0506 +#define IPC_SEC_SIM_ICC_TYPE 0x0507 +#define IPC_SEC_LOCK_INFO 0x0508 +#define IPC_SEC_ISIM_AUTH 0x0509 + +/* SIM status */ +#define IPC_SEC_SIM_STATUS_INITIALIZING 0x00 +#define IPC_SEC_SIM_STATUS_SIM_LOCK_REQUIRED 0x01 +#define IPC_SEC_SIM_STATUS_INSIDE_PF_ERROR 0x02 +#define IPC_SEC_SIM_STATUS_LOCK_SC 0x03 +#define IPC_SEC_SIM_STATUS_LOCK_FD 0x04 +#define IPC_SEC_SIM_STATUS_LOCK_PN 0x05 +#define IPC_SEC_SIM_STATUS_LOCK_PU 0x06 +#define IPC_SEC_SIM_STATUS_LOCK_PP 0x07 +#define IPC_SEC_SIM_STATUS_LOCK_PC 0x08 +#define IPC_SEC_SIM_STATUS_CARD_NOT_PRESENT 0x80 +#define IPC_SEC_SIM_STATUS_CARD_ERROR 0x81 +#define IPC_SEC_SIM_STATUS_INIT_COMPLETE 0x82 +#define IPC_SEC_SIM_STATUS_PB_INIT_COMPLETE 0x83 + +/* SIM/Network facility types */ +#define IPC_SEC_FACILITY_TYPE_SC 0x03 +#define IPC_SEC_FACILITY_TYPE_FD 0x04 +#define IPC_SEC_FACILITY_TYPE_PN 0x05 +#define IPC_SEC_FACILITY_TYPE_PU 0x06 +#define IPC_SEC_FACILITY_TYPE_PP 0x07 +#define IPC_SEC_FACILITY_TYPE_PC 0x08 + +/* SIM card (SC) facility lock types */ +#define IPC_SEC_FACILITY_LOCK_TYPE_SC_PIN1_REQ 0x01 +#define IPC_SEC_FACILITY_LOCK_TYPE_SC_PUK_REQ 0x02 +#define IPC_SEC_FACILITY_LOCK_TYPE_SC_CARD_BLOCKED 0x05 + +/* PIN type */ +#define IPC_SEC_PIN_TYPE_PIN1 0x03 +#define IPC_SEC_PIN_TYPE_PIN2 0x09 + +/* Type of the used SIM card */ +#define IPC_SEC_SIM_CARD_TYPE_UNKNOWN 0x00 +#define IPC_SEC_SIM_CARD_TYPE_SIM 0x01 +#define IPC_SEC_SIM_CARD_TYPE_USIM 0x02 + +/* Possible RSIM commads */ +#define IPC_SEC_RSIM_COMMAND_READ_BINARY 0xb0 +#define IPC_SEC_RSIM_COMMAND_READ_RECORD 0xc0 +#define IPC_SEC_RSIM_COMMAND_UPDATE_BINARY 0xd6 +#define IPC_SEC_RSIM_COMMAND_STATUS 0xf2 struct ipc_sec_pin_status_response { - unsigned char type; - unsigned char key; + /* IPC_SEC_SIM_STATUS_... */ + unsigned char status; + /* IPC_SEC_FACILITY_LOCK_TYPE_... */ + unsigned char facility_lock; } __attribute__((__packed__)); struct ipc_sec_pin_status_set { + /* IPC_SEC_PIN_TYPE_... */ unsigned char type; unsigned char length1; unsigned char length2; @@ -79,30 +95,35 @@ struct ipc_sec_pin_status_set { } __attribute__((__packed__)); struct ipc_sec_phone_lock_set { - unsigned char type; // IPC_SEC_PIN_SIM_LOCK_... - unsigned char lock; + /* IPC_SEC_PIN_... */ + unsigned char type; + unsigned char lock; /* 1: lock, 0: unlock */ unsigned char length; unsigned char password[39]; } __attribute__((__packed__)); struct ipc_sec_phone_lock_get { - unsigned char type; // IPC_SEC_PIN_SIM_LOCK_... + /* IPC_SEC_FACILITY_TYPE_... */ + unsigned char facility; } __attribute__((__packed__)); struct ipc_sec_phone_lock_response { - unsigned char type; - unsigned char status; + /* IPC_SEC_FACILITY_TYPE_... */ + unsigned char facility; + unsigned char status; /* 1: active, 0: not active */ } __attribute__((__packed__)); struct ipc_sec_change_locking_pw { - unsigned char type; // IPC_SEC_PIN_SIM_LOCK_... + /* IPC_SEC_FACILITY_TYPE_... */ + unsigned char facility; unsigned char length_old; unsigned char length_new; unsigned char password_old[39]; unsigned char password_new[39]; } __attribute__((__packed__)); -struct ipc_sec_rsim_access_request { +struct ipc_sec_rsim_access_get { + /* IPC_SEC_RSIM_COMMAND_... */ unsigned char command; unsigned short fileid; unsigned char p1, p2, p3; @@ -113,25 +134,31 @@ struct ipc_sec_rsim_access_response { unsigned char len; } __attribute__((__packed__)); -struct ipc_sec_lock_info_request { - unsigned char unk0; +struct ipc_sec_lock_info_get { + unsigned char unk0; /* needs to be "1" */ + /* IPC_SEC_PIN_TYPE_... */ unsigned char pin_type; } __attribute__((__packed__)); struct ipc_sec_lock_info_response { unsigned char num; + /* IPC_SEC_PIN_TYPE_... */ unsigned char type; unsigned char key; unsigned char attempts; } __attribute__((__packed__)); struct ipc_sec_sim_icc_type { + /* unknown */ unsigned char type; } __attribute__((__packed__)); void ipc_sec_pin_status_set_setup(struct ipc_sec_pin_status_set *message, unsigned char pin_type, char *pin1, char *pin2); +void ipc_sec_lock_info_get_setup(struct ipc_sec_lock_info_get *message, + unsigned char pin_type); + char* ipc_sec_rsim_access_response_get_file_data(struct ipc_message_info *response); #endif diff --git a/samsung-ipc/sec.c b/samsung-ipc/sec.c index 2f3a3cb..ddc2097 100644 --- a/samsung-ipc/sec.c +++ b/samsung-ipc/sec.c @@ -46,6 +46,16 @@ void ipc_sec_pin_status_set_setup(struct ipc_sec_pin_status_set *message, } } +void ipc_sec_lock_info_get_setup(struct ipc_sec_lock_info_get *message, + unsigned char pin_type) +{ + if (message == NULL) + return; + + message->unk0 = 1; + message->pin_type = pin_type; +} + char* ipc_sec_rsim_access_response_get_file_data(struct ipc_message_info *response) { int n = 0; diff --git a/tools/modemctrl.c b/tools/modemctrl.c index 089375a..e1e27d8 100644 --- a/tools/modemctrl.c +++ b/tools/modemctrl.c @@ -139,7 +139,7 @@ void modem_set_sms_device_ready(struct ipc_client *client) void modem_set_sec_pin_status(struct ipc_client *client, char *pin1, char *pin2) { struct ipc_sec_pin_status_set pin_status; - struct ipc_sec_lock_info_request lock_info_req; + struct ipc_sec_lock_info_get lock_info_req; printf("[I] Sending PIN1 unlock request\n"); @@ -159,18 +159,18 @@ void modem_response_sec(struct ipc_client *client, struct ipc_message_info *resp case IPC_SEC_PIN_STATUS : pin_status = (struct ipc_sec_pin_status_response *)resp->data; - switch(pin_status->type) + switch(pin_status->status) { - case IPC_SEC_PIN_SIM_INITIALIZING: + case IPC_SEC_SIM_STATUS_INITIALIZING: printf("[I] SIM is initializing\n"); break; - case IPC_SEC_PIN_SIM_CARD_NOT_PRESENT: + case IPC_SEC_SIM_STATUS_CARD_NOT_PRESENT: printf("[I] SIM card is definitely absent\n"); break; - case IPC_SEC_PIN_SIM_LOCK_SC: - switch(pin_status->key) + case IPC_SEC_SIM_STATUS_LOCK_SC: + switch(pin_status->facility_lock) { - case IPC_SEC_PIN_SIM_LOCK_SC_PIN1_REQ: + case IPC_SEC_FACILITY_LOCK_TYPE_SC_PIN1_REQ: printf("[I] We need the PIN1 to unlock the card!\n"); if(strlen(sim_pin) > 0) { modem_set_sec_pin_status(client, sim_pin, NULL); @@ -178,21 +178,21 @@ void modem_response_sec(struct ipc_client *client, struct ipc_message_info *resp printf("[E] No SIM Pin, use --pin\n"); } break; - case IPC_SEC_PIN_SIM_LOCK_SC_PUK_REQ: + case IPC_SEC_FACILITY_LOCK_TYPE_SC_PUK_REQ: printf("[I] Please provide the SIM card PUK!\n"); break; - case IPC_SEC_PIN_SIM_LOCK_SC_CARD_BLOCKED: + case IPC_SEC_FACILITY_LOCK_TYPE_SC_CARD_BLOCKED: printf("[I] Ouch, the SIM Card is blocked.\n"); break; } break; - case IPC_SEC_PIN_SIM_INIT_COMPLETE: + case IPC_SEC_SIM_STATUS_INIT_COMPLETE: printf("[3] SIM init complete\n"); if(state == MODEM_STATE_NORMAL) state = MODEM_STATE_SIM_OK; break; - case IPC_SEC_PIN_SIM_PB_INIT_COMPLETE: + case IPC_SEC_SIM_STATUS_PB_INIT_COMPLETE: printf("[I] SIM Phone Book init complete\n"); break; } diff --git a/vapi/samsung-ipc-1.0.vapi b/vapi/samsung-ipc-1.0.vapi index ee8aa98..c13e499 100644 --- a/vapi/samsung-ipc-1.0.vapi +++ b/vapi/samsung-ipc-1.0.vapi @@ -212,7 +212,7 @@ namespace SamsungIpc namespace Security { - [CCode (cname = "gint8", cprefix = "IPC_SEC_PIN_SIM_", has_type_id = false)] + [CCode (cname = "gint8", cprefix = "IPC_SEC_SIM_STATUS_", has_type_id = false)] public enum SimStatus { INITIALIZING, @@ -230,12 +230,23 @@ namespace SamsungIpc PB_INIT_COMPLETE, } - [CCode (cname = "gint8", cprefix = "IPC_SEC_PIN_SIM_LOCK_SC_", has_type_id = false)] - public enum SimLockStatus + [CCode (cname = "gint8", cprefix = "IPC_SEC_FACILITY_TYPE_", has_type_id = false)] + public enum FacilityType { - PIN1_REQ, - PUK_REQ, - CARD_BLOCKED, + SC, + FD, + PN, + PU, + PP, + PC, + } + + [CCode (cname = "gint8", cprefix = "IPC_SEC_FACILITY_LOCK_TYPE_", has_type_id = false)] + public enum FacilityLockType + { + SC_PIN1_REQ, + SC_PUK_REQ, + SC_CARD_BLOCKED, } [CCode (cname = "gint8", cprefix = "IPC_SEC_PIN_TYPE_", has_type_id = false)] @@ -265,10 +276,8 @@ namespace SamsungIpc [CCode (cname = "struct ipc_sec_pin_status_response", destroy_function = "")] public struct SimStatusMessage { - [CCode (cname = "type")] public SimStatus status; - [CCode (cname = "key")] - public SimLockStatus lock_status; + public FacilityLockType facility_lock; public unowned uint8[] data { @@ -309,7 +318,7 @@ namespace SamsungIpc [CCode (cname = "struct ipc_sec_phone_lock_get", destroy_function = "")] public struct PhoneLockGetMessage { - public SimStatus lock_type; // FIXME refactor log type from SimStatus in own enum + public FacilityType facility; public unowned uint8[] data { @@ -325,8 +334,8 @@ namespace SamsungIpc [CCode (cname = "struct ipc_sec_phone_lock_response", destroy_function = "")] public struct PhoneLockGetResponseMessage { - public uint8 type; - public SimLockStatus status; + public FacilityType facility; + public bool status; public unowned uint8[] data { @@ -339,7 +348,7 @@ namespace SamsungIpc } } - [CCode (cname = "struct ipc_sec_rsim_access_request", destroy_function = "")] + [CCode (cname = "struct ipc_sec_rsim_access_get", destroy_function = "")] public struct RSimAccessRequestMessage { public RSimCommandType command; @@ -380,12 +389,15 @@ namespace SamsungIpc public static string get_file_data( Response response ); } - [CCode (cname = "struct ipc_sec_lock_info_request", destroy_function = "")] + [CCode (cname = "struct ipc_sec_lock_info_get", destroy_function = "")] public struct LockInfoRequestMessage { public uint8 unk0; public PinType pin_type; + [CCode (cname = "ipc_sec_lock_info_get_setup")] + public void setup(PinType pin_type); + public unowned uint8[] data { get @@ -401,7 +413,7 @@ namespace SamsungIpc public struct LockInfoResponseMessage { public uint8 num; - public uint8 type; + public PinType type; public uint8 key; public uint8 attempts; |