diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2013-06-27 16:19:07 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2013-06-27 16:19:07 +0200 |
commit | a81f656e6f6109a1fb838d08235ad46d5d0a87de (patch) | |
tree | 2657101026271ed7773b8828c6578e83fcaa2bdb /samsung-ipc | |
parent | ddf605bc6186397a39320c8c9835d3b1c3edda30 (diff) | |
download | external_libsamsung-ipc-a81f656e6f6109a1fb838d08235ad46d5d0a87de.zip external_libsamsung-ipc-a81f656e6f6109a1fb838d08235ad46d5d0a87de.tar.gz external_libsamsung-ipc-a81f656e6f6109a1fb838d08235ad46d5d0a87de.tar.bz2 |
ipc util: Do not use strdup, to avoid memory leak
Change-Id: Ieee54f1a57ff76d59732c109e54cf05f90546e5e
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/ipc_util.c | 505 |
1 files changed, 317 insertions, 188 deletions
diff --git a/samsung-ipc/ipc_util.c b/samsung-ipc/ipc_util.c index 9c90e78..2eb54ef 100644 --- a/samsung-ipc/ipc_util.c +++ b/samsung-ipc/ipc_util.c @@ -33,77 +33,10 @@ #include "ipc.h" -#define IPC_STR(f) case f: return strdup(#f); - -void ipc_client_log_recv(struct ipc_client *client, - struct ipc_message_info *response, const char *prefix) -{ - switch (client->type) { - case IPC_CLIENT_TYPE_FMT: - ipc_client_log(client, "%s: RECV FMT!", prefix); - ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x) type=%s", - prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response), ipc_response_type_to_str(response->type)); -#ifdef DEBUG - if (response->length > 0) { - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_client_hex_dump(client, (void *) response->data, - response->length > 0x100 ? 0x100 : response->length); - ipc_client_log(client, "======================="); - } -#endif - break; - case IPC_CLIENT_TYPE_RFS: - ipc_client_log(client, "%s: RECV RFS!", prefix); - ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x)", - prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response)); -#ifdef DEBUG - if (response->length > 0) { - ipc_client_log(client, "==== RFS DATA DUMP ===="); - ipc_client_hex_dump(client, (void *) response->data, - response->length > 0x100 ? 0x100 : response->length); - ipc_client_log(client, "======================="); - } -#endif - break; - } -} - -void ipc_client_log_send(struct ipc_client *client, - struct ipc_message_info *request, const char *prefix) -{ - switch (client->type) { - case IPC_CLIENT_TYPE_FMT: - ipc_client_log(client, "%s: SEND FMT!", prefix); - ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x) type=%s", - prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request), ipc_request_type_to_str(request->type)); -#ifdef DEBUG - if (request->length > 0) { - ipc_client_log(client, "==== FMT DATA DUMP ===="); - ipc_client_hex_dump(client, (void *) request->data, - request->length > 0x100 ? 0x100 : request->length); - ipc_client_log(client, "======================="); - } -#endif - break; - case IPC_CLIENT_TYPE_RFS: - ipc_client_log(client, "%s: SEND RFS!", prefix); - ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x)", - prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request)); -#ifdef DEBUG - if (request->length > 0) { - ipc_client_log(client, "==== RFS DATA DUMP ===="); - ipc_client_hex_dump(client, (void *) request->data, - request->length > 0x100 ? 0x100 : request->length); - ipc_client_log(client, "======================="); - } -#endif - break; - } -} - +/* Log utils */ const char *ipc_response_type_to_str(int type) { - switch(type) { + switch (type) { case IPC_TYPE_INDI: return "INDI"; case IPC_TYPE_RESP: @@ -117,7 +50,7 @@ const char *ipc_response_type_to_str(int type) const char *ipc_request_type_to_str(int type) { - switch(type) { + switch (type) { case IPC_TYPE_EXEC: return "EXEC"; case IPC_TYPE_GET: @@ -135,125 +68,255 @@ const char *ipc_request_type_to_str(int type) const char *ipc_command_to_str(int command) { - switch(command) { - IPC_STR(IPC_CALL_OUTGOING) - IPC_STR(IPC_CALL_INCOMING) - IPC_STR(IPC_CALL_RELEASE) - IPC_STR(IPC_CALL_ANSWER) - IPC_STR(IPC_CALL_STATUS) - IPC_STR(IPC_CALL_LIST) - IPC_STR(IPC_CALL_BURST_DTMF) - IPC_STR(IPC_CALL_CONT_DTMF) - IPC_STR(IPC_CALL_WAITING) - IPC_STR(IPC_CALL_LINE_ID) - IPC_STR(IPC_DISP_ICON_INFO) - IPC_STR(IPC_DISP_HOMEZONE_INFO) - IPC_STR(IPC_DISP_RSSI_INFO) - IPC_STR(IPC_GEN_PHONE_RES) - IPC_STR(IPC_GPRS_DEFINE_PDP_CONTEXT) - IPC_STR(IPC_GPRS_QOS) - IPC_STR(IPC_GPRS_PS) - IPC_STR(IPC_GPRS_PDP_CONTEXT) - IPC_STR(IPC_GPRS_ENTER_DATA) - IPC_STR(IPC_GPRS_SHOW_PDP_ADDR) - IPC_STR(IPC_GPRS_MS_CLASS) - IPC_STR(IPC_GPRS_3G_QUAL_SERVICE_PROFILE) - IPC_STR(IPC_GPRS_IP_CONFIGURATION) - IPC_STR(IPC_GPRS_DEFINE_SEC_PDP_CONTEXT) - IPC_STR(IPC_GPRS_TFT) - IPC_STR(IPC_GPRS_HSDPA_STATUS) - IPC_STR(IPC_GPRS_CURRENT_SESSION_DATA_COUNT) - IPC_STR(IPC_GPRS_DATA_DORMANT) - IPC_STR(IPC_GPRS_DUN_PIN_CTRL) - IPC_STR(IPC_GPRS_CALL_STATUS) - IPC_STR(IPC_MISC_ME_VERSION) - IPC_STR(IPC_MISC_ME_IMSI) - IPC_STR(IPC_MISC_ME_SN) - IPC_STR(IPC_MISC_TIME_INFO) - IPC_STR(IPC_NET_PREF_PLMN) - IPC_STR(IPC_NET_PLMN_SEL) - IPC_STR(IPC_NET_CURRENT_PLMN) - IPC_STR(IPC_NET_PLMN_LIST) - IPC_STR(IPC_NET_REGIST) - IPC_STR(IPC_NET_SUBSCRIBER_NUM) - IPC_STR(IPC_NET_BAND_SEL) - IPC_STR(IPC_NET_SERVICE_DOMAIN_CONFIG) - IPC_STR(IPC_NET_POWERON_ATTACH) - IPC_STR(IPC_NET_MODE_SEL) - IPC_STR(IPC_NET_ACQ_ORDER) - IPC_STR(IPC_NET_IDENTITY) - IPC_STR(IPC_NET_CURRENT_RRC_STATUS) - IPC_STR(IPC_PWR_PHONE_PWR_UP) - IPC_STR(IPC_PWR_PHONE_PWR_OFF) - IPC_STR(IPC_PWR_PHONE_RESET) - IPC_STR(IPC_PWR_BATT_STATUS) - IPC_STR(IPC_PWR_BATT_TYPE) - IPC_STR(IPC_PWR_BATT_COMP) - IPC_STR(IPC_PWR_PHONE_STATE) - IPC_STR(IPC_RFS_NV_READ_ITEM) - IPC_STR(IPC_RFS_NV_WRITE_ITEM) - IPC_STR(IPC_SEC_SIM_STATUS) - IPC_STR(IPC_SEC_PHONE_LOCK) - IPC_STR(IPC_SEC_CHANGE_LOCKING_PW) - IPC_STR(IPC_SEC_SIM_LANG) - IPC_STR(IPC_SEC_RSIM_ACCESS) - IPC_STR(IPC_SEC_GSIM_ACCESS) - IPC_STR(IPC_SEC_SIM_ICC_TYPE) - IPC_STR(IPC_SEC_LOCK_INFO) - IPC_STR(IPC_SEC_ISIM_AUTH) - IPC_STR(IPC_SMS_SEND_MSG) - IPC_STR(IPC_SMS_INCOMING_MSG) - IPC_STR(IPC_SMS_READ_MSG) - IPC_STR(IPC_SMS_SAVE_MSG) - IPC_STR(IPC_SMS_DEL_MSG) - IPC_STR(IPC_SMS_DELIVER_REPORT) - IPC_STR(IPC_SMS_DEVICE_READY) - IPC_STR(IPC_SMS_SEL_MEM) - IPC_STR(IPC_SMS_STORED_MSG_COUNT) - IPC_STR(IPC_SMS_SVC_CENTER_ADDR) - IPC_STR(IPC_SMS_SVC_OPTION) - IPC_STR(IPC_SMS_MEM_STATUS) - IPC_STR(IPC_SMS_CBS_MSG) - IPC_STR(IPC_SMS_CBS_CONFIG) - IPC_STR(IPC_SMS_STORED_MSG_STATUS) - IPC_STR(IPC_SMS_PARAM_COUNT) - IPC_STR(IPC_SMS_PARAM) - IPC_STR(IPC_SND_SPKR_VOLUME_CTRL) - IPC_STR(IPC_SND_MIC_MUTE_CTRL) - IPC_STR(IPC_SND_AUDIO_PATH_CTRL) - IPC_STR(IPC_SND_RINGBACK_TONE_CTRL) - IPC_STR(IPC_SND_CLOCK_CTRL) - IPC_STR(IPC_PB_ACCESS) - IPC_STR(IPC_PB_STORAGE) - IPC_STR(IPC_PB_STORAGE_LIST) - IPC_STR(IPC_PB_ENTRY_INFO) - IPC_STR(IPC_PB_CAPABILITY_INFO) - IPC_STR(IPC_SS_WAITING) - IPC_STR(IPC_SS_CLI) - IPC_STR(IPC_SS_BARRING) - IPC_STR(IPC_SS_BARRING_PW) - IPC_STR(IPC_SS_FORWARDING) - IPC_STR(IPC_SS_INFO) - IPC_STR(IPC_SS_MANAGE_CALL) - IPC_STR(IPC_SS_USSD) - IPC_STR(IPC_SS_AOC) - IPC_STR(IPC_SS_RELEASE_COMPLETE) - IPC_STR(IPC_SAT_PROFILE_DOWNLOAD) - IPC_STR(IPC_SAT_ENVELOPE_CMD) - IPC_STR(IPC_SAT_PROACTIVE_CMD) - IPC_STR(IPC_SAT_TERMINATE_USAT_SESSION) - IPC_STR(IPC_SAT_EVENT_DOWNLOAD) - IPC_STR(IPC_SAT_PROVIDE_LOCAL_INFO) - IPC_STR(IPC_SAT_POLLING) - IPC_STR(IPC_SAT_REFRESH) - IPC_STR(IPC_SAT_SETUP_EVENT_LIST) - IPC_STR(IPC_SAT_CALL_CONTROL_RESULT) - IPC_STR(IPC_SAT_IMAGE_CLUT) - IPC_STR(IPC_SAT_CALL_PROCESSING) - IPC_STR(IPC_IMEI_START) - IPC_STR(IPC_IMEI_CHECK_DEVICE_INFO) + switch (command) { + case IPC_CALL_OUTGOING: + return "IPC_CALL_OUTGOING"; + case IPC_CALL_INCOMING: + return "IPC_CALL_INCOMING"; + case IPC_CALL_RELEASE: + return "IPC_CALL_RELEASE"; + case IPC_CALL_ANSWER: + return "IPC_CALL_ANSWER"; + case IPC_CALL_STATUS: + return "IPC_CALL_STATUS"; + case IPC_CALL_LIST: + return "IPC_CALL_LIST"; + case IPC_CALL_BURST_DTMF: + return "IPC_CALL_BURST_DTMF"; + case IPC_CALL_CONT_DTMF: + return "IPC_CALL_CONT_DTMF"; + case IPC_CALL_WAITING: + return "IPC_CALL_WAITING"; + case IPC_CALL_LINE_ID: + return "IPC_CALL_LINE_ID"; + case IPC_DISP_ICON_INFO: + return "IPC_DISP_ICON_INFO"; + case IPC_DISP_HOMEZONE_INFO: + return "IPC_DISP_HOMEZONE_INFO"; + case IPC_DISP_RSSI_INFO: + return "IPC_DISP_RSSI_INFO"; + case IPC_GEN_PHONE_RES: + return "IPC_GEN_PHONE_RES"; + case IPC_GPRS_DEFINE_PDP_CONTEXT: + return "IPC_GPRS_DEFINE_PDP_CONTEXT"; + case IPC_GPRS_QOS: + return "IPC_GPRS_QOS"; + case IPC_GPRS_PS: + return "IPC_GPRS_PS"; + case IPC_GPRS_PDP_CONTEXT: + return "IPC_GPRS_PDP_CONTEXT"; + case IPC_GPRS_ENTER_DATA: + return "IPC_GPRS_ENTER_DATA"; + case IPC_GPRS_SHOW_PDP_ADDR: + return "IPC_GPRS_SHOW_PDP_ADDR"; + case IPC_GPRS_MS_CLASS: + return "IPC_GPRS_MS_CLASS"; + case IPC_GPRS_3G_QUAL_SERVICE_PROFILE: + return "IPC_GPRS_3G_QUAL_SERVICE_PROFILE"; + case IPC_GPRS_IP_CONFIGURATION: + return "IPC_GPRS_IP_CONFIGURATION"; + case IPC_GPRS_DEFINE_SEC_PDP_CONTEXT: + return "IPC_GPRS_DEFINE_SEC_PDP_CONTEXT"; + case IPC_GPRS_TFT: + return "IPC_GPRS_TFT"; + case IPC_GPRS_HSDPA_STATUS: + return "IPC_GPRS_HSDPA_STATUS"; + case IPC_GPRS_CURRENT_SESSION_DATA_COUNT: + return "IPC_GPRS_CURRENT_SESSION_DATA_COUNT"; + case IPC_GPRS_DATA_DORMANT: + return "IPC_GPRS_DATA_DORMANT"; + case IPC_GPRS_DUN_PIN_CTRL: + return "IPC_GPRS_DUN_PIN_CTRL"; + case IPC_GPRS_CALL_STATUS: + return "IPC_GPRS_CALL_STATUS"; + case IPC_GPRS_PORT_LIST: + return "IPC_GPRS_PORT_LIST"; + case IPC_IMEI_START: + return "IPC_IMEI_START"; + case IPC_IMEI_CHECK_DEVICE_INFO: + return "IPC_IMEI_CHECK_DEVICE_INFO"; + case IPC_MISC_ME_VERSION: + return "IPC_MISC_ME_VERSION"; + case IPC_MISC_ME_IMSI: + return "IPC_MISC_ME_IMSI"; + case IPC_MISC_ME_SN: + return "IPC_MISC_ME_SN"; + case IPC_MISC_TIME_INFO: + return "IPC_MISC_TIME_INFO"; + case IPC_MISC_DEBUG_LEVEL: + return "IPC_MISC_DEBUG_LEVEL"; + case IPC_NET_PREF_PLMN: + return "IPC_NET_PREF_PLMN"; + case IPC_NET_PLMN_SEL: + return "IPC_NET_PLMN_SEL"; + case IPC_NET_CURRENT_PLMN: + return "IPC_NET_CURRENT_PLMN"; + case IPC_NET_PLMN_LIST: + return "IPC_NET_PLMN_LIST"; + case IPC_NET_REGIST: + return "IPC_NET_REGIST"; + case IPC_NET_SUBSCRIBER_NUM: + return "IPC_NET_SUBSCRIBER_NUM"; + case IPC_NET_BAND_SEL: + return "IPC_NET_BAND_SEL"; + case IPC_NET_SERVICE_DOMAIN_CONFIG: + return "IPC_NET_SERVICE_DOMAIN_CONFIG"; + case IPC_NET_POWERON_ATTACH: + return "IPC_NET_POWERON_ATTACH"; + case IPC_NET_MODE_SEL: + return "IPC_NET_MODE_SEL"; + case IPC_NET_ACQ_ORDER: + return "IPC_NET_ACQ_ORDER"; + case IPC_NET_IDENTITY: + return "IPC_NET_IDENTITY"; + case IPC_NET_CURRENT_RRC_STATUS: + return "IPC_NET_CURRENT_RRC_STATUS"; + case IPC_PB_ACCESS: + return "IPC_PB_ACCESS"; + case IPC_PB_STORAGE: + return "IPC_PB_STORAGE"; + case IPC_PB_STORAGE_LIST: + return "IPC_PB_STORAGE_LIST"; + case IPC_PB_ENTRY_INFO: + return "IPC_PB_ENTRY_INFO"; + case IPC_PB_CAPABILITY_INFO: + return "IPC_PB_CAPABILITY_INFO"; + case IPC_PWR_PHONE_PWR_UP: + return "IPC_PWR_PHONE_PWR_UP"; + case IPC_PWR_PHONE_PWR_OFF: + return "IPC_PWR_PHONE_PWR_OFF"; + case IPC_PWR_PHONE_RESET: + return "IPC_PWR_PHONE_RESET"; + case IPC_PWR_BATT_STATUS: + return "IPC_PWR_BATT_STATUS"; + case IPC_PWR_BATT_TYPE: + return "IPC_PWR_BATT_TYPE"; + case IPC_PWR_BATT_COMP: + return "IPC_PWR_BATT_COMP"; + case IPC_PWR_PHONE_STATE: + return "IPC_PWR_PHONE_STATE"; + case IPC_RFS_NV_READ_ITEM: + return "IPC_RFS_NV_READ_ITEM"; + case IPC_RFS_NV_WRITE_ITEM: + return "IPC_RFS_NV_WRITE_ITEM"; + case IPC_SAT_PROFILE_DOWNLOAD: + return "IPC_SAT_PROFILE_DOWNLOAD"; + case IPC_SAT_ENVELOPE_CMD: + return "IPC_SAT_ENVELOPE_CMD"; + case IPC_SAT_PROACTIVE_CMD: + return "IPC_SAT_PROACTIVE_CMD"; + case IPC_SAT_TERMINATE_USAT_SESSION: + return "IPC_SAT_TERMINATE_USAT_SESSION"; + case IPC_SAT_EVENT_DOWNLOAD: + return "IPC_SAT_EVENT_DOWNLOAD"; + case IPC_SAT_PROVIDE_LOCAL_INFO: + return "IPC_SAT_PROVIDE_LOCAL_INFO"; + case IPC_SAT_POLLING: + return "IPC_SAT_POLLING"; + case IPC_SAT_REFRESH: + return "IPC_SAT_REFRESH"; + case IPC_SAT_SETUP_EVENT_LIST: + return "IPC_SAT_SETUP_EVENT_LIST"; + case IPC_SAT_CALL_CONTROL_RESULT: + return "IPC_SAT_CALL_CONTROL_RESULT"; + case IPC_SAT_IMAGE_CLUT: + return "IPC_SAT_IMAGE_CLUT"; + case IPC_SAT_CALL_PROCESSING: + return "IPC_SAT_CALL_PROCESSING"; + case IPC_SEC_SIM_STATUS: + return "IPC_SEC_SIM_STATUS"; + case IPC_SEC_PHONE_LOCK: + return "IPC_SEC_PHONE_LOCK"; + case IPC_SEC_CHANGE_LOCKING_PW: + return "IPC_SEC_CHANGE_LOCKING_PW"; + case IPC_SEC_SIM_LANG: + return "IPC_SEC_SIM_LANG"; + case IPC_SEC_RSIM_ACCESS: + return "IPC_SEC_RSIM_ACCESS"; + case IPC_SEC_GSIM_ACCESS: + return "IPC_SEC_GSIM_ACCESS"; + case IPC_SEC_SIM_ICC_TYPE: + return "IPC_SEC_SIM_ICC_TYPE"; + case IPC_SEC_LOCK_INFO: + return "IPC_SEC_LOCK_INFO"; + case IPC_SEC_ISIM_AUTH: + return "IPC_SEC_ISIM_AUTH"; + case IPC_SMS_SEND_MSG: + return "IPC_SMS_SEND_MSG"; + case IPC_SMS_INCOMING_MSG: + return "IPC_SMS_INCOMING_MSG"; + case IPC_SMS_READ_MSG: + return "IPC_SMS_READ_MSG"; + case IPC_SMS_SAVE_MSG: + return "IPC_SMS_SAVE_MSG"; + case IPC_SMS_DEL_MSG: + return "IPC_SMS_DEL_MSG"; + case IPC_SMS_DELIVER_REPORT: + return "IPC_SMS_DELIVER_REPORT"; + case IPC_SMS_DEVICE_READY: + return "IPC_SMS_DEVICE_READY"; + case IPC_SMS_SEL_MEM: + return "IPC_SMS_SEL_MEM"; + case IPC_SMS_STORED_MSG_COUNT: + return "IPC_SMS_STORED_MSG_COUNT"; + case IPC_SMS_SVC_CENTER_ADDR: + return "IPC_SMS_SVC_CENTER_ADDR"; + case IPC_SMS_SVC_OPTION: + return "IPC_SMS_SVC_OPTION"; + case IPC_SMS_MEM_STATUS: + return "IPC_SMS_MEM_STATUS"; + case IPC_SMS_CBS_MSG: + return "IPC_SMS_CBS_MSG"; + case IPC_SMS_CBS_CONFIG: + return "IPC_SMS_CBS_CONFIG"; + case IPC_SMS_STORED_MSG_STATUS: + return "IPC_SMS_STORED_MSG_STATUS"; + case IPC_SMS_PARAM_COUNT: + return "IPC_SMS_PARAM_COUNT"; + case IPC_SMS_PARAM: + return "IPC_SMS_PARAM"; + case IPC_SND_SPKR_VOLUME_CTRL: + return "IPC_SND_SPKR_VOLUME_CTRL"; + case IPC_SND_MIC_MUTE_CTRL: + return "IPC_SND_MIC_MUTE_CTRL"; + case IPC_SND_AUDIO_PATH_CTRL: + return "IPC_SND_AUDIO_PATH_CTRL"; + case IPC_SND_AUDIO_SOURCE_CTRL: + return "IPC_SND_AUDIO_SOURCE_CTRL"; + case IPC_SND_LOOPBACK_CTRL: + return "IPC_SND_LOOPBACK_CTRL"; + case IPC_SND_VOICE_RECORDING_CTRL: + return "IPC_SND_VOICE_RECORDING_CTRL"; + case IPC_SND_VIDEO_CALL_CTRL: + return "IPC_SND_VIDEO_CALL_CTRL"; + case IPC_SND_RINGBACK_TONE_CTRL: + return "IPC_SND_RINGBACK_TONE_CTRL"; + case IPC_SND_CLOCK_CTRL: + return "IPC_SND_CLOCK_CTRL"; + case IPC_SND_WB_AMR_STATUS: + return "IPC_SND_WB_AMR_STATUS"; + case IPC_SS_WAITING: + return "IPC_SS_WAITING"; + case IPC_SS_CLI: + return "IPC_SS_CLI"; + case IPC_SS_BARRING: + return "IPC_SS_BARRING"; + case IPC_SS_BARRING_PW: + return "IPC_SS_BARRING_PW"; + case IPC_SS_FORWARDING: + return "IPC_SS_FORWARDING"; + case IPC_SS_INFO: + return "IPC_SS_INFO"; + case IPC_SS_MANAGE_CALL: + return "IPC_SS_MANAGE_CALL"; + case IPC_SS_USSD: + return "IPC_SS_USSD"; + case IPC_SS_AOC: + return "IPC_SS_AOC"; + case IPC_SS_RELEASE_COMPLETE: + return "IPC_SS_RELEASE_COMPLETE"; default: - return "IPC_UNKNOWN"; + return "UNKNOWN"; } } @@ -313,6 +376,72 @@ void ipc_client_hex_dump(struct ipc_client *client, void *data, int size) } } +void ipc_client_log_recv(struct ipc_client *client, + struct ipc_message_info *response, const char *prefix) +{ + switch (client->type) { + case IPC_CLIENT_TYPE_FMT: + ipc_client_log(client, "%s: RECV FMT!", prefix); + ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x) type=%s", + prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response), ipc_response_type_to_str(response->type)); +#ifdef DEBUG + if (response->length > 0) { + ipc_client_log(client, "==== FMT DATA DUMP ===="); + ipc_client_hex_dump(client, (void *) response->data, + response->length > 0x100 ? 0x100 : response->length); + ipc_client_log(client, "======================="); + } +#endif + break; + case IPC_CLIENT_TYPE_RFS: + ipc_client_log(client, "%s: RECV RFS!", prefix); + ipc_client_log(client, "%s: Response: aseq=0x%02x command=%s (0x%04x)", + prefix, response->aseq, ipc_command_to_str(IPC_COMMAND(response)), IPC_COMMAND(response)); +#ifdef DEBUG + if (response->length > 0) { + ipc_client_log(client, "==== RFS DATA DUMP ===="); + ipc_client_hex_dump(client, (void *) response->data, + response->length > 0x100 ? 0x100 : response->length); + ipc_client_log(client, "======================="); + } +#endif + break; + } +} + +void ipc_client_log_send(struct ipc_client *client, + struct ipc_message_info *request, const char *prefix) +{ + switch (client->type) { + case IPC_CLIENT_TYPE_FMT: + ipc_client_log(client, "%s: SEND FMT!", prefix); + ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x) type=%s", + prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request), ipc_request_type_to_str(request->type)); +#ifdef DEBUG + if (request->length > 0) { + ipc_client_log(client, "==== FMT DATA DUMP ===="); + ipc_client_hex_dump(client, (void *) request->data, + request->length > 0x100 ? 0x100 : request->length); + ipc_client_log(client, "======================="); + } +#endif + break; + case IPC_CLIENT_TYPE_RFS: + ipc_client_log(client, "%s: SEND RFS!", prefix); + ipc_client_log(client, "%s: Request: mseq=0x%02x command=%s (0x%04x)", + prefix, request->mseq, ipc_command_to_str(IPC_COMMAND(request)), IPC_COMMAND(request)); +#ifdef DEBUG + if (request->length > 0) { + ipc_client_log(client, "==== RFS DATA DUMP ===="); + ipc_client_hex_dump(client, (void *) request->data, + request->length > 0x100 ? 0x100 : request->length); + ipc_client_log(client, "======================="); + } +#endif + break; + } +} + void *ipc_client_mtd_read(struct ipc_client *client, char *mtd_name, int size, int block_size) { |