static void ril_sms_notify(GRilIoChannel *io, guint ril_event, const void *data, guint len, void *user_data) { struct ril_sms *sd = user_data; GRilIoParser rilp; char *ril_pdu; int ril_pdu_len; unsigned int smsc_len; long ril_buf_len; guchar *ril_data; ril_pdu = NULL; ril_data = NULL; DBG("event: %d; data_len: %d", ril_event, len); grilio_parser_init(&rilp, data, len); ril_pdu = grilio_parser_get_utf8(&rilp); if (ril_pdu == NULL) goto error; ril_pdu_len = strlen(ril_pdu); DBG("ril_pdu_len is %d", ril_pdu_len); ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1); if (ril_data == NULL) goto error; /* The first octect in the pdu contains the SMSC address length * which is the X following octects it reads. We add 1 octet to * the read length to take into account this read octet in order * to calculate the proper tpdu length. */ smsc_len = ril_data[0] + 1; ofono_info("sms received, smsc_len is %d", smsc_len); DBG("(%s)", ril_pdu); if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) { /* Last parameter is 'tpdu_len' ( substract SMSC length ) */ ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len, ril_buf_len - smsc_len); } else { GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT); ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len, ril_buf_len - smsc_len); } g_free(ril_pdu); g_free(ril_data); ril_ack_delivery(sd, TRUE); return; error: g_free(ril_pdu); g_free(ril_data); ril_ack_delivery(sd, FALSE); ofono_error("Unable to parse NEW_SMS notification"); }
static void ril_sms_notify(struct ril_msg *message, gpointer user_data) { struct ofono_sms *sms = user_data; struct sms_data *sd = ofono_sms_get_data(sms); struct parcel rilp; char *ril_pdu; int ril_pdu_len; unsigned int smsc_len; long ril_buf_len; guchar *ril_data; DBG("req: %d; data_len: %d", message->req, message->buf_len); switch (message->req) { case RIL_UNSOL_RESPONSE_NEW_SMS: case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: break; default: goto error; } ril_util_init_parcel(message, &rilp); ril_pdu = parcel_r_string(&rilp); if (ril_pdu == NULL) goto error; ril_pdu_len = strlen(ril_pdu); DBG("ril_pdu_len is %d", ril_pdu_len); ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1); if (ril_data == NULL) goto error; /* The first octect in the pdu contains the SMSC address length * which is the X following octects it reads. We add 1 octet to * the read length to take into account this read octet in order * to calculate the proper tpdu length. */ smsc_len = ril_data[0] + 1; DBG("smsc_len is %d", smsc_len); g_ril_append_print_buf(sd->ril, "(%s)", ril_pdu); g_ril_print_unsol(sd->ril, message); if (message->req == RIL_UNSOL_RESPONSE_NEW_SMS) { /* Last parameter is 'tpdu_len' ( substract SMSC length ) */ ofono_sms_deliver_notify(sms, ril_data, ril_buf_len, ril_buf_len - smsc_len); } else if (message->req == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT) { ofono_sms_status_notify(sms, ril_data, ril_buf_len, ril_buf_len - smsc_len); } ril_ack_delivery(sms); return; error: ofono_error("Unable to parse NEW_SMS notification"); }