From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [SMS D-Bus 03/19] sms: implement SHA256-based message IDs [incomplete]
Date: Thu, 05 Aug 2010 12:20:34 -0500 [thread overview]
Message-ID: <4C5AF2E2.2090009@gmail.com> (raw)
In-Reply-To: <91ce0be38ecd281e810284966d0f285ad187db23.1280879410.git.inaky.perez-gonzalez@intel.com>
[-- Attachment #1: Type: text/plain, Size: 8021 bytes --]
Hi Inaky,
On 08/03/2010 06:50 PM, Inaky Perez-Gonzalez wrote:
> From: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
>
> This patch removes the sequential SMS message identification gig and
> replaces it with a 16-bit hash cookie based off message contents.
>
> FIXME: [incomplete] need to figure out how to do so that identical
> messages sent to different or the same numbers also have a different
> ID.
> ---
> src/ofono.h | 9 +++++----
> src/sms.c | 55 +++++++++++++++++++++++--------------------------------
> src/stk.c | 5 +++--
> 3 files changed, 31 insertions(+), 38 deletions(-)
>
> diff --git a/src/ofono.h b/src/ofono.h
> index aaa01d9..b73797b 100644
> --- a/src/ofono.h
> +++ b/src/ofono.h
> @@ -185,10 +185,11 @@ enum ofono_sms_submit_flag {
>
> typedef void (*ofono_sms_txq_submit_cb_t)(gboolean ok, void *data);
>
> -unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
> - unsigned int flags,
> - ofono_sms_txq_submit_cb_t cb,
> - void *data, ofono_destroy_func destroy);
> +struct tx_queue_entry *__ofono_sms_txq_submit(
> + struct ofono_sms *sms, GSList *list,
> + unsigned int flags, unsigned ref,
> + ofono_sms_txq_submit_cb_t cb,
> + void *data, ofono_destroy_func destroy);
As I said before, please don't mess with this function.
>
> #include <ofono/sim.h>
> #include <ofono/stk.h>
> diff --git a/src/sms.c b/src/sms.c
> index 35364db..39d4a32 100644
> --- a/src/sms.c
> +++ b/src/sms.c
> @@ -55,7 +55,6 @@ struct ofono_sms {
> DBusMessage *pending;
> struct ofono_phone_number sca;
> struct sms_assembly *assembly;
> - unsigned int next_msg_id;
> guint ref;
> GQueue *txq;
> gint tx_source;
> @@ -589,7 +588,8 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
> int ref_offset;
> struct ofono_modem *modem;
> unsigned int flags;
> - unsigned int msg_id;
> + guint16 msg_id;
> + struct tx_queue_entry *sms_msg;
>
> if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &to,
> DBUS_TYPE_STRING, &text,
> @@ -605,24 +605,19 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
> if (!msg_list)
> return __ofono_error_invalid_format(msg);
>
> - set_ref_and_to(msg_list, sms->ref, ref_offset, to);
> - DBG("ref: %d, offset: %d", sms->ref, ref_offset);
> -
> - if (ref_offset != 0) {
> - if (sms->ref == 65536)
> - sms->ref = 1;
> - else
> - sms->ref = sms->ref + 1;
> - }
> + msg_id = sms_uuid_from_pdu_list(msg_list);
You're calculating the ID before setting the ref and to? That is pretty
silly ;)
> + set_ref_and_to(msg_list, msg_id, ref_offset, to);
> + DBG("SMS ID: 0x%04x", msg_id);
>
> flags = OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY;
> flags |= OFONO_SMS_SUBMIT_FLAG_RETRY;
> if (sms->use_delivery_reports)
> flags |= OFONO_SMS_SUBMIT_FLAG_REQUEST_SR;
>
> - msg_id = __ofono_sms_txq_submit(sms, msg_list, flags, send_message_cb,
> - dbus_message_ref(msg),
> - send_message_destroy);
> + sms_msg = __ofono_sms_txq_submit(sms, msg_list, flags, msg_id,
> + send_message_cb,
> + dbus_message_ref(msg),
> + send_message_destroy);
Make the ID calculation happen inside tx_queue_entry_new. That function
already converts all the SMS objects into a PDU. So simply hashing the
PDUs there would be very easy.
>
> g_slist_foreach(msg_list, (GFunc)g_free, NULL);
> g_slist_free(msg_list);
> @@ -659,7 +654,7 @@ static void dispatch_app_datagram(struct ofono_sms *sms, int dst, int src,
> }
>
> static void dispatch_text_message(struct ofono_sms *sms,
> - const char *message,
> + const char *message, guint16 msg_id,
> enum sms_class cls,
> const struct sms_address *addr,
> const struct sms_scts *scts)
> @@ -717,11 +712,9 @@ static void dispatch_text_message(struct ofono_sms *sms,
>
> g_dbus_send_message(conn, signal);
>
> - if (cls != SMS_CLASS_0) {
> - __ofono_history_sms_received(modem, sms->next_msg_id, str,
> + if (cls != SMS_CLASS_0)
> + __ofono_history_sms_received(modem, msg_id, str,
> &remote, &local, message);
> - sms->next_msg_id += 1;
> - }
> }
>
> static void sms_dispatch(struct ofono_sms *sms, GSList *sms_list)
> @@ -732,6 +725,7 @@ static void sms_dispatch(struct ofono_sms *sms, GSList *sms_list)
> enum sms_class cls;
> int srcport = -1;
> int dstport = -1;
> + guint16 msg_id;
>
> if (sms_list == NULL)
> return;
> @@ -749,6 +743,7 @@ static void sms_dispatch(struct ofono_sms *sms, GSList *sms_list)
> * used, the addresses are the same across all segments.
> */
>
> + msg_id = sms_uuid_from_pdu_list(sms_list);
> for (l = sms_list; l; l = l->next) {
> guint8 dcs;
> gboolean comp = FALSE;
> @@ -825,8 +820,8 @@ static void sms_dispatch(struct ofono_sms *sms, GSList *sms_list)
>
> s = sms_list->data;
>
> - dispatch_text_message(sms, message, cls, &s->deliver.oaddr,
> - &s->deliver.scts);
> + dispatch_text_message(sms, message, msg_id, cls,
> + &s->deliver.oaddr, &s->deliver.scts);
> g_free(message);
> }
> }
> @@ -1104,8 +1099,6 @@ static void sms_remove(struct ofono_atom *atom)
>
> if (sms->settings) {
> g_key_file_set_integer(sms->settings, SETTINGS_GROUP,
> - "NextMessageId", sms->next_msg_id);
> - g_key_file_set_integer(sms->settings, SETTINGS_GROUP,
> "NextReference", sms->ref);
> g_key_file_set_boolean(sms->settings, SETTINGS_GROUP,
> "UseDeliveryReports",
> @@ -1201,9 +1194,6 @@ static void sms_load_settings(struct ofono_sms *sms, const char *imsi)
>
> sms->imsi = g_strdup(imsi);
>
> - sms->next_msg_id = g_key_file_get_integer(sms->settings, SETTINGS_GROUP,
> - "NextMessageId", NULL);
> -
> sms->ref = g_key_file_get_integer(sms->settings, SETTINGS_GROUP,
> "NextReference", NULL);
> if (sms->ref >= 65536)
> @@ -1306,10 +1296,11 @@ void *ofono_sms_get_data(struct ofono_sms *sms)
> return sms->driver_data;
> }
>
> -unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
> - unsigned int flags,
> - ofono_sms_txq_submit_cb_t cb,
> - void *data, ofono_destroy_func destroy)
> +struct tx_queue_entry *__ofono_sms_txq_submit(
> + struct ofono_sms *sms, GSList *list,
> + unsigned int flags, unsigned msg_id,
> + ofono_sms_txq_submit_cb_t cb,
> + void *data, ofono_destroy_func destroy)
> {
> struct tx_queue_entry *entry = tx_queue_entry_new(list);
>
> @@ -1320,7 +1311,7 @@ unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
> sizeof(entry->receiver));
> }
>
> - entry->msg_id = sms->next_msg_id++;
> + entry->msg_id = msg_id;
> entry->flags = flags;
> entry->cb = cb;
> entry->data = data;
> @@ -1331,5 +1322,5 @@ unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
> if (g_queue_get_length(sms->txq) == 1)
> sms->tx_source = g_timeout_add(0, tx_next, sms);
>
> - return entry->msg_id;
> + return entry;
> }
> diff --git a/src/stk.c b/src/stk.c
> index 556dc68..620811b 100644
> --- a/src/stk.c
> +++ b/src/stk.c
> @@ -323,6 +323,7 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
> struct ofono_atom *sms_atom;
> struct ofono_sms *sms;
> GSList msg_list;
> + guint16 msg_id;
>
> sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);
>
> @@ -338,8 +339,8 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
>
> msg_list.data = (void *) &cmd->send_sms.gsm_sms;
> msg_list.next = NULL;
> -
> - __ofono_sms_txq_submit(sms, &msg_list, 0, send_sms_submit_cb,
> + msg_id = sms_uuid_from_pdu_list(&msg_list);
> + __ofono_sms_txq_submit(sms, &msg_list, 0, msg_id, send_sms_submit_cb,
> stk->sms_submit_req, g_free);
>
> stk->cancel_cmd = send_sms_cancel;
Regards,
-Denis
next prev parent reply other threads:[~2010-08-05 17:20 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 23:50 [SMS D-Bus 00/19] pull request Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 01/19] write_file: make transaction-safe Inaky Perez-Gonzalez
2010-08-05 17:03 ` Denis Kenzior
2010-08-03 23:50 ` [SMS D-Bus 02/19] sms: introduce message ID API Inaky Perez-Gonzalez
2010-08-05 17:10 ` Denis Kenzior
2010-08-05 17:18 ` Inaky Perez-Gonzalez
2010-08-05 18:02 ` Denis Kenzior
2010-08-05 18:07 ` Inaky Perez-Gonzalez
2010-08-05 18:21 ` Denis Kenzior
2010-08-05 18:37 ` Inaky Perez-Gonzalez
2010-08-05 23:34 ` Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 03/19] sms: implement SHA256-based message IDs [incomplete] Inaky Perez-Gonzalez
2010-08-05 17:20 ` Denis Kenzior [this message]
2010-08-05 18:17 ` Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 04/19] sms: document the org.ofono.SmsMessage interface Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 05/19] sms: document handle_sms_status_report() Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 06/19] struct tx_queue_entry: add a destructor Inaky Perez-Gonzalez
2010-08-05 17:04 ` Denis Kenzior
2010-08-03 23:50 ` [SMS D-Bus 07/19] sms: introduce bare state machine and transitions Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 08/19] sms: introduce the Wait-for-Status-Report state Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 09/19] sms: introduce a state change callback for messages Inaky Perez-Gonzalez
2010-08-03 23:50 ` [SMS D-Bus 10/19] sms: export outgoing messages over D-Bus Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 11/19] sms: send PropertyChanged signals on state change Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 12/19] sms: introduce sms_msg_cancel and its D-Bus wrapper Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 13/19] sms: Implement D-Bus SMS-MSG::GetProperties Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 14/19] sms: document SMS Message's D-Bus 'To' property Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 15/19] sms: test code for message's D-Bus GetProperties Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 16/19] automake: fix generation of symlinks for headers Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 17/19] sms: document variable usage in sms_msg_send() Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 18/19] sms: add test case for message cancel Inaky Perez-Gonzalez
2010-08-03 23:51 ` [SMS D-Bus 19/19] sms: add test case for state change signals Inaky Perez-Gonzalez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C5AF2E2.2090009@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.