sync with private git
authorJunghwan Song <jump.song@samsung.com>
Fri, 24 Aug 2012 12:50:51 +0000 (21:50 +0900)
committerJunghwan Song <jump.song@samsung.com>
Fri, 24 Aug 2012 12:50:51 +0000 (21:50 +0900)
14 files changed:
include/at.h
include/co_sim.h
include/queue.h
include/type/call.h
include/type/sat.h
include/type/sms.h
packaging/libtcore.spec
src/at.c
src/co_sat.c
src/co_sim.c
src/hal.c
src/queue.c
src/user_request.c
src/util.c

index 952d34a..8c9ad81 100644 (file)
@@ -11,7 +11,8 @@ enum tcore_at_command_type {
     TCORE_AT_NO_RESULT,   /* no intermediate response expected */
     TCORE_AT_NUMERIC,     /* a single intermediate response starting with a 0-9 */
     TCORE_AT_SINGLELINE,  /* a single intermediate response starting with a prefix */
-    TCORE_AT_MULTILINE    /* multiple line intermediate response starting with a prefix */
+    TCORE_AT_MULTILINE,   /* multiple line intermediate response starting with a prefix */
+    TCORE_AT_PDU
 };
 
 enum ATCMEError{
index a41ae8d..df0d346 100644 (file)
@@ -63,9 +63,9 @@ void*                tcore_sim_ref_userdata(CoreObject *o);
 
 gboolean             tcore_sim_decode_iccid(struct tel_sim_iccid *p_out, unsigned char *p_in, int in_length);
 gboolean             tcore_sim_decode_lp(struct tel_sim_language *p_out, unsigned char *p_in, int in_length);
-gboolean             tcore_sim_encode_lp(char *p_out, int out_length, struct tel_sim_language *p_in);
+char*             tcore_sim_encode_lp(int *out_length, struct tel_sim_language *p_in);
 gboolean             tcore_sim_decode_li(enum tel_sim_file_id file_id, struct tel_sim_language *p_out, unsigned char *p_in, int in_length);
-gboolean             tcore_sim_encode_li(char *p_out, int out_length, struct tel_sim_language *p_in);
+char*             tcore_sim_encode_li(int *out_length, struct tel_sim_language *p_in);
 gboolean             tcore_sim_decode_imsi(struct tel_sim_imsi *p_out, unsigned char *p_in, int in_length);
 gboolean             tcore_sim_decode_sst(struct tel_sim_sst *p_sst, unsigned char *p_in, int in_length);
 gboolean             tcore_sim_decode_spn(struct tel_sim_spn *p_spn, unsigned char *p_in, int in_length);
index 1d99547..796da23 100644 (file)
@@ -89,6 +89,8 @@ TcorePending* tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id);
 TcorePending* tcore_queue_ref_next_pending(TcoreQueue *queue);
 unsigned int  tcore_queue_get_length(TcoreQueue *queue);
 TcoreHal*     tcore_queue_ref_hal(TcoreQueue *queue);
+TReturn       tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command);
+TcorePending* tcore_queue_search_by_command(TcoreQueue *queue, enum tcore_request_command command, gboolean flag_sent);
 
 __END_DECLS
 
index 6bb213f..25f4ade 100644 (file)
@@ -449,11 +449,11 @@ struct treq_call_sound_set_recording {
        gboolean state;
 };
 
-#define MAX_SOUND_EQ_PARAMETER_SIZE 13
+#define MAX_SOUND_EQ_PARAMETER_SIZE 6
 struct treq_call_sound_set_equalization {
        gboolean mode;
        enum telephony_call_sound_direction direction;
-       char parameter[ MAX_SOUND_EQ_PARAMETER_SIZE ];
+       unsigned short parameter[ MAX_SOUND_EQ_PARAMETER_SIZE ];
 };
 
 struct treq_call_sound_set_noise_reduction {
index 5a8a185..98cd456 100644 (file)
@@ -50,7 +50,7 @@ __BEGIN_DECLS
 #define SAT_SUB_ADDR_LEN_MAX 30
 #define SAT_CCP_DATA_LEN_MAX 30         /**<   max length of ccp data          */
 #define SAT_URL_LEN_MAX 129     /**<   max length of url               */
-#define SAT_BEARER_LIST_MAX_COUNT 50    /**<   max count of bearer list                */
+#define SAT_BEARER_LIST_MAX_COUNT 5     /**<   max count of bearer list                */
 #define SAT_PROVISIONING_REF_MAX_COUNT 10      /**<    max count of sat provisioning reference */
 #define SAT_PROVISIONING_FILE_PATH_LEN_MAX 50   /**<   max length of provisioning file path    */
 #define SAT_BEARER_PARAMS_LEN_MAX 10    /**<   max length of bearer parameters                 */
index aaaa024..eacd7b8 100644 (file)
@@ -359,7 +359,7 @@ struct telephony_sms_CbMsg {
 
        enum telephony_sms_CbMsgType    cbMsgType;                                                      /**< Cell Broadcast  message type */
        unsigned short                                  length;                                                                 /**<Size of array szMsgData (which is actual TPDU message) */
-       char                                                    msgData[SMS_CB_PAGE_SIZE_MAX + 1]; /**<Cell broadcast message data[Refer 3GPP TS 23.041 9.4.1]*/
+       char                                                    msgData[SMS_CB_SIZE_MAX + 1]; /**<Cell broadcast message data[Refer 3GPP TS 23.041 9.4.1]*/
 };
 
 /**
index 37e374b..a4a24b7 100644 (file)
@@ -1,7 +1,7 @@
 #sbs-git:slp/pkgs/l/libtcore
 Name: libtcore
 Summary: Telephony-core library
-Version: 0.1.44
+Version: 0.1.50
 Release:    1
 Group:      System/Libraries
 License:    Apache
index 589bbee..ee98332 100644 (file)
--- a/src/at.c
+++ b/src/at.c
@@ -158,7 +158,7 @@ static void _emit_pending_response(TcoreAT *at)
        }
 
        tcore_pending_emit_response_callback(p, sizeof(TcoreATResponse *), at->resp);
-       tcore_user_request_free(tcore_pending_ref_user_request(p));
+       tcore_user_request_unref(tcore_pending_ref_user_request(p));
        tcore_pending_free(p);
 
        _response_free(at->resp);
@@ -658,6 +658,25 @@ gboolean tcore_at_process(TcoreAT *at, unsigned int data_len, const char *data)
                                                }
                                                break;
 
+                                       case TCORE_AT_PDU:
+                                               if (at->req->prefix) {
+                                                       if (g_str_has_prefix(pos, at->req->prefix)) {
+                                                               _response_add(at->resp, pos);
+                                                       }
+                                                       else {
+                                                               if (at->resp->lines != NULL) {
+                                                                       _response_add(at->resp, pos);
+                                                               }
+                                                               else {
+                                                                       _emit_unsolicited_message(at, pos);
+                                                               }
+                                                       }
+                                               }
+                                               else {
+                                                       _response_add(at->resp, pos);
+                                               }
+                                               break;
+
                                        default:
                                                dbg("unknown");
                                                _emit_unsolicited_message(at, pos);
index 4e1bffc..96ffcd2 100644 (file)
@@ -471,8 +471,8 @@ static enum tcore_sat_result _sat_decode_address_tlv(unsigned char* tlv_str, int
                _sat_decode_ton_npi(src_data[index++], &address_obj->ton, &address_obj->npi);
                str_ascii = tcore_util_convert_bcd2ascii((const char*)&src_data[index], address_len-1, SAT_DIALING_NUMBER_LEN_MAX);
                if(str_ascii){
-                       memcpy(address_obj->dialing_number, str_ascii, sizeof(str_ascii));
-                       address_obj->dialing_number_len = sizeof(str_ascii);
+                       memcpy(address_obj->dialing_number, str_ascii, strlen(str_ascii));
+                       address_obj->dialing_number_len = strlen(str_ascii);
                        g_free(str_ascii);
                }
        }
index 7694633..8c0b967 100644 (file)
@@ -580,19 +580,24 @@ gboolean tcore_sim_decode_lp(struct tel_sim_language *p_out, unsigned char *p_in
 /**
  * This function is used to encode EFLP (2G)
  */
-gboolean tcore_sim_encode_lp(char *p_out, int out_length, struct tel_sim_language *p_in)
+char* tcore_sim_encode_lp( int *out_length, struct tel_sim_language *p_in)
 {
-       int i;
+    int i = 0;
+    char *tmp_out = NULL;
 
-       if (p_in->language_count > out_length)
-               return FALSE;
+    if ( out_length == NULL || p_in == NULL ){
+        dbg("out_length or p_in is null");
+        return NULL;
+    }
 
-       memset((void*) p_out, 0xff, out_length);
+    tmp_out = (char*)malloc(p_in->language_count);
+    memset((void*) tmp_out, 0xff, p_in->language_count);
 
-       for (i = 0; i < p_in->language_count; i++)
-               p_out[i] = p_in->language[i];
+    for (i = 0; i < p_in->language_count; i++)
+        tmp_out[i] = p_in->language[i];
 
-       return TRUE;
+    *out_length = i;
+    return tmp_out;
 }
 
 /**
@@ -713,24 +718,29 @@ gboolean tcore_sim_decode_li(enum tel_sim_file_id file_id, struct tel_sim_langua
 /**
  * This function is used to encode EFLI (3G)
  */
-gboolean tcore_sim_encode_li(char *p_out, int out_length, struct tel_sim_language *p_in)
+char* tcore_sim_encode_li( int *out_length, struct tel_sim_language *p_in)
 {
        int i = 0;
+    char *tmp_out = NULL;
        char *LanguageCode[] = { "de", "en", "it", "fr", "es", "nl", "sv", "da", "pt", "fi", "no", "el",
                                                                                                        "tr", "hu", "pl", "ko", "zh", "ru", "ja" };
 
-       if (p_in->language_count > out_length)
-               return FALSE;
+    if ( out_length == NULL || p_in == NULL ){
+        dbg("out_length or p_in is null");
+        return NULL;
+    }
 
-       memset((void*) p_out, 0xFF, out_length);
+    tmp_out = (char*)malloc((p_in->language_count) *2);
+    memset((void*) tmp_out, 0xff, (p_in->language_count)*2);
 
        for (i = 0; i < p_in->language_count; i++) {
                if (p_in->language[i] < SIM_LANG_UNSPECIFIED) {
-                       strncpy((char *) &p_out[i * 2], LanguageCode[p_in->language[i]], 2);
-                       dbg( "sim_encode_li: p_out[%s]:[%x][%x]", p_out, p_out[i*2], p_out[(i*2)+1]);
+                       strncpy((char *) &tmp_out[i * 2], LanguageCode[p_in->language[i]], 2);
+                       dbg( "sim_encode_li: p_out[%s]:[%x][%x]", tmp_out, tmp_out[i*2], tmp_out[(i*2)+1]);
                }
        }
-       return TRUE;
+       *out_length = i*2;
+       return tmp_out;
 }
 
 gboolean tcore_sim_decode_imsi(struct tel_sim_imsi *p_out, unsigned char *p_in, int in_length)
@@ -2149,8 +2159,8 @@ gboolean tcore_sim_decode_opl(struct tel_sim_opl *p_opl, unsigned char *p_in, in
 
 gboolean tcore_sim_decode_pnn(struct tel_sim_pnn *p_pnn, unsigned char* p_in, int in_length)
 {
-       int f_name_length = 0, s_name_length = 0;
-       int i, cvt_leng = 0;
+       int f_name_len = 0, s_name_len = 0;
+       int cvt_leng = 0, s_name_base = 0;
 
        if (_is_empty(p_in, in_length) == TRUE) {
                memset(p_pnn, 0x00, sizeof(struct tel_sim_pnn));
@@ -2160,12 +2170,8 @@ gboolean tcore_sim_decode_pnn(struct tel_sim_pnn *p_pnn, unsigned char* p_in, in
        /*Full name for network IEI(Information Element Identifier),0x43*/
        if (p_in[0] == 0x43) {
                dbg( " Full name of network IEI exist");
-               /*Assigning the variable 'f_name_length' with the Full name network length*/
-               f_name_length = p_in[1];
-
-               /* current telephony supports 40 bytes network name string */
-               if (f_name_length > SIM_NW_FULL_NAME_LEN_MAX)
-                       f_name_length = SIM_NW_FULL_NAME_LEN_MAX;
+               //f_name_part includes information byte.
+               f_name_len =  (int)p_in[1] - 1;
 
                /* 3rd byte information element(according to TS 24.008 for Network Name)
                 8 :ext1
@@ -2181,38 +2187,54 @@ gboolean tcore_sim_decode_pnn(struct tel_sim_pnn *p_pnn, unsigned char* p_in, in
                 */
                if ((p_in[2] & 0x01110000) >> 4 == 0) {
                        dbg( "DCS:GSM7");
-                       //f_name_length includes information byte.
-                       _unpack_7bit28bit(p_in + 3, f_name_length - 1,
-                                       (unsigned char *) (p_pnn->full_name));
-               }
-               else if ((p_in[2] & 0x01110000) >> 4 == 1) {
+                       // In case of GSM7, 35byte packing data will be converted 40 bytes unpacking string.
+                       if (f_name_len > (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8)
+                               f_name_len = (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8;
+
+                       _unpack_7bit28bit(p_in + 3, f_name_len, (unsigned char *) (p_pnn->full_name));
+               } else if ((p_in[2] & 0x01110000) >> 4 == 1) {
                        dbg( "DCS:UCS2");
-                       _ucs2_to_utf8(f_name_length, p_in + 3, (int*) &cvt_leng,
-                                       (unsigned char *) (p_pnn->full_name));
-               }
-               else {
+                       /* current telephony supports 40 bytes network name string */
+                       if (f_name_len > SIM_NW_FULL_NAME_LEN_MAX)
+                               f_name_len = SIM_NW_FULL_NAME_LEN_MAX;
+
+                       _ucs2_to_utf8(f_name_len, p_in + 3, (int*) &cvt_leng, (unsigned char *) (p_pnn->full_name));
+               } else {
                        dbg( "DCS:unknown");
                        return FALSE;
                }
                dbg( " Full name of network contents[%s]", p_pnn->full_name);
 
+               s_name_base = (int)p_in[1] +2;
+               dbg( " short name base byte [0x%02x]", s_name_base);
+
                /*Short Name for network IEI(Information Element Identifier), 0x45*/
-               if (p_in[f_name_length + 2] == 0x45) {
+               if (p_in[s_name_base] == 0x45) {
                        dbg( " Short name of network IEI exist");
-                       /*Assigning the variable 's_name_length' with the short name network length*/
-                       s_name_length = p_in[f_name_length + 3];
-
-                       if (s_name_length > SIM_NW_FULL_NAME_LEN_MAX)
-                               s_name_length = SIM_NW_FULL_NAME_LEN_MAX;
-
-                       for (i = 0; i < s_name_length; i++)
-                               p_pnn->short_name[i] =  p_in[f_name_length + 4 + i];
-
+                       //s_name_part includes information byte.
+                       s_name_len = p_in[s_name_base +1] -1;
+
+                       if ((p_in[s_name_base + 2] & 0x01110000) >> 4 == 0) {
+                               dbg( "DCS:GSM7");
+                               // In case of GSM7, 35byte packing data will be converted 40 bytes unpacking string.
+                               if (s_name_len > (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8)
+                                       s_name_len = (SIM_NW_FULL_NAME_LEN_MAX * 7) / 8;
+
+                               _unpack_7bit28bit(p_in + s_name_base + 3, s_name_len, (unsigned char *) (p_pnn->short_name));
+                       } else if ((p_in[s_name_base +2] & 0x01110000) >> 4 == 1) {
+                               dbg( "DCS:UCS2");
+                               if (s_name_len > SIM_NW_FULL_NAME_LEN_MAX)
+                                       s_name_len = SIM_NW_FULL_NAME_LEN_MAX;
+
+                               _ucs2_to_utf8(s_name_len, p_in + s_name_base+ 3, (int*) &cvt_leng, (unsigned char *) (p_pnn->short_name));
+                       } else {
+                               dbg( "DCS:unknown");
+                               return FALSE;
+                       }
                        dbg( " Short name of network contents[%s]", p_pnn->short_name);
                }
                return TRUE;
        }
-
        return FALSE;
 }
 
index a52acee..872f578 100644 (file)
--- a/src/hal.c
+++ b/src/hal.c
@@ -323,7 +323,7 @@ TReturn tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
                }
 
                tcore_pending_emit_response_callback(p, data_len, data);
-               tcore_user_request_free(tcore_pending_ref_user_request(p));
+               tcore_user_request_unref(tcore_pending_ref_user_request(p));
                tcore_pending_free(p);
 
                /* Send next request in queue */
index 0b8bcba..3d1a555 100644 (file)
@@ -70,19 +70,28 @@ struct tcore_pending_type {
        TcoreQueue *queue;
 };
 
+enum search_field {
+       SEARCH_FIELD_ID_ALL = 0x01,
+       SEARCH_FIELD_ID_WAIT = 0x11,
+       SEARCH_FIELD_ID_SENT = 0x21,
+       SEARCH_FIELD_COMMAND_ALL = 0x02,
+       SEARCH_FIELD_COMMAND_WAIT = 0x12,
+       SEARCH_FIELD_COMMAND_SENT = 0x22,
+};
+
 static gboolean _on_pending_timeout(gpointer user_data)
 {
        TcorePending *p = user_data;
 
+       dbg("pending timeout!!");
+
        if (!p)
                return FALSE;
 
        tcore_pending_emit_timeout_callback(p);
 
-       p = tcore_queue_pop(p->queue);
-       tcore_pending_free(p);
-
-       p->timer_src = 0;
+       p->on_response = NULL;
+       tcore_hal_dispatch_response_data(p->queue->hal, p->id, 0, NULL);
 
        return FALSE;
 }
@@ -289,9 +298,10 @@ TReturn tcore_pending_emit_send_callback(TcorePending *pending, gboolean result)
        if (pending->on_send)
                pending->on_send(pending, result, pending->on_send_user_data);
 
-       if (result == TCORE_RETURN_SUCCESS) {
+       if (result == TRUE) {
                if (pending->flag_auto_free_after_sent == FALSE && pending->timeout > 0) {
                        /* timer */
+                       dbg("start pending timer! (%d secs)", pending->timeout);
                        pending->timer_src = g_timeout_add_seconds(pending->timeout, _on_pending_timeout, pending);
                }
        }
@@ -520,11 +530,12 @@ TcorePending *tcore_queue_ref_tail(TcoreQueue *queue)
 }
 
 
-static TcorePending *_tcore_queue_search(TcoreQueue *queue, unsigned int id,
-               gboolean flag_pop)
+static TcorePending *_tcore_queue_search_full(TcoreQueue *queue, unsigned int id,
+               enum tcore_request_command command, enum search_field field, gboolean flag_pop)
 {
        TcorePending *pending = NULL;
        int i = 0;
+       UserRequest *ur;
 
        if (!queue)
                return NULL;
@@ -534,11 +545,37 @@ static TcorePending *_tcore_queue_search(TcoreQueue *queue, unsigned int id,
                if (!pending)
                        return NULL;
 
-               if (pending->id == id) {
-                       if (flag_pop == TRUE) {
-                               pending = g_queue_pop_nth(queue->gq, i);
+               if ((field & 0xF0) == 0x10) {
+                       /* search option is wait pending */
+                       if (pending->flag_sent) {
+                               i++;
+                               continue;
+                       }
+               }
+               else if ((field & 0xF0) == 0x20) {
+                       /* search option is sent pending */
+                       if (pending->flag_sent == FALSE) {
+                               i++;
+                               continue;
+                       }
+               }
+
+               if ((field & 0x0F) == SEARCH_FIELD_ID_ALL) {
+                       if (pending->id == id) {
+                               if (flag_pop == TRUE) {
+                                       pending = g_queue_pop_nth(queue->gq, i);
+                               }
+                               break;
+                       }
+               }
+               else if ((field & 0x0F) == SEARCH_FIELD_COMMAND_ALL) {
+                       ur = tcore_pending_ref_user_request(pending);
+                       if (tcore_user_request_get_command(ur) == command) {
+                               if (flag_pop == TRUE) {
+                                       pending = g_queue_pop_nth(queue->gq, i);
+                               }
+                               break;
                        }
-                       break;
                }
 
                i++;
@@ -547,12 +584,21 @@ static TcorePending *_tcore_queue_search(TcoreQueue *queue, unsigned int id,
        return pending;
 }
 
+TcorePending *tcore_queue_search_by_command(TcoreQueue *queue,
+               enum tcore_request_command command, gboolean flag_sent)
+{
+       if (flag_sent)
+               return _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_SENT, FALSE);
+
+       return _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_WAIT, FALSE);
+}
+
 TcorePending *tcore_queue_pop_by_id(TcoreQueue *queue, unsigned int id)
 {
        if (!queue)
                return NULL;
 
-       return _tcore_queue_search(queue, id, TRUE);
+       return _tcore_queue_search_full(queue, id, 0, SEARCH_FIELD_ID_ALL, TRUE);
 }
 
 TcorePending *tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id)
@@ -560,7 +606,7 @@ TcorePending *tcore_queue_ref_pending_by_id(TcoreQueue *queue, unsigned int id)
        if (!queue)
                return NULL;
 
-       return _tcore_queue_search(queue, id, FALSE);
+       return _tcore_queue_search_full(queue, id, 0, SEARCH_FIELD_ID_ALL, FALSE);
 }
 
 TcorePending *tcore_queue_ref_next_pending(TcoreQueue *queue)
@@ -616,3 +662,31 @@ TcoreHal *tcore_queue_ref_hal(TcoreQueue *queue)
 
        return queue->hal;
 }
+
+TReturn tcore_queue_cancel_pending_by_command(TcoreQueue *queue, enum tcore_request_command command)
+{
+       TcorePending *pending;
+
+       if (!queue)
+               return TCORE_RETURN_EINVAL;
+
+       while (1) {
+               pending = _tcore_queue_search_full(queue, 0, command, SEARCH_FIELD_COMMAND_ALL, FALSE);
+               if (!pending)
+                       break;
+
+               dbg("pending(0x%x) cancel", pending);
+
+               if (queue->hal) {
+                       tcore_hal_dispatch_response_data(queue->hal, pending->id, 0, NULL);
+               }
+               else {
+                       pending = tcore_queue_pop_by_pending(queue, pending);
+                       tcore_pending_emit_response_callback(pending, 0, NULL);
+                       tcore_user_request_unref(tcore_pending_ref_user_request(pending));
+                       tcore_pending_free(pending);
+               }
+       }
+
+       return TCORE_RETURN_SUCCESS;
+}
index f86e8f9..edd10e2 100644 (file)
@@ -72,9 +72,9 @@ void tcore_user_request_free(UserRequest *ur)
        if (!ur)
                return;
 
-       if ( ur->ref > 0 ) {
+       if (ur->ref > 0) {
                ur->ref--;
-               return ;
+               return;
        }
 
        if (ur->free_hook)
@@ -107,17 +107,16 @@ UserRequest *tcore_user_request_ref(UserRequest *ur)
 void tcore_user_request_unref(UserRequest *ur)
 {
        if (!ur)
-               return ;
+               return;
 
-       if ( ur->ref > 0 )
+       if (ur->ref > 0)
                ur->ref--;
        else
-               tcore_user_request_free( ur );
+               tcore_user_request_free(ur);
 
-       return ;
+       return;
 }
 
-
 TReturn tcore_user_request_set_free_hook(UserRequest *ur,
                UserRequestFreeHook free_hook)
 {
@@ -176,6 +175,7 @@ TReturn tcore_user_request_set_user_info(UserRequest *ur,
        if (ur->ui.appname) {
                dbg("free old appname (%s)", ur->ui.appname);
                free(ur->ui.appname);
+               ur->ui.appname = NULL;
        }
 
        if (ui->appname) {
@@ -263,17 +263,17 @@ TReturn tcore_user_request_set_metainfo(UserRequest *ur,
        if (!ur)
                return TCORE_RETURN_EINVAL;
 
-       ur->metainfo_len = metainfo_len;
-
        if (metainfo_len > 0 && metainfo != NULL) {
                ur->metainfo = calloc(metainfo_len, 1);
                if (!ur->metainfo)
                        return TCORE_RETURN_ENOMEM;
 
+               ur->metainfo_len = metainfo_len;
                memcpy(ur->metainfo, metainfo, metainfo_len);
        }
        else {
                ur->metainfo = NULL;
+               ur->metainfo_len = 0;
        }
 
        return TCORE_RETURN_SUCCESS;
index dc438a5..cfdd355 100644 (file)
@@ -280,6 +280,7 @@ TReturn tcore_util_netif_set(const char *name, const char *ipaddr,
                return TCORE_RETURN_FAILURE;
        }
 
+       memset(&sai, 0, sizeof(struct sockaddr_in));
        sai.sin_family = AF_INET;
        sai.sin_port = 0;
        memset(&ifr, 0, sizeof(struct ifreq));
@@ -520,7 +521,8 @@ unsigned char *tcore_util_pack_gsm7bit(const unsigned char *src, unsigned int sr
                return NULL;
 
        for (pos = 0, i = 0; i < src_len; pos++, i++) {
-               if ( pos >= outlen ) {
+               if (pos >= outlen) {
+                       free(dest);
                        return NULL;
                }