gisi: Refactor indication subscriptions

Handle different message types for IND subscriptions based on the
presence of the GISI_MODEM_FLAG_USE_LEGACY_SUBSCRIBE flag. This
enables building modem plugins for modems that only support one or the
other available IND types.

Based on patches from:
Jessica Nilsson <jessica.j.nilsson@stericsson.com>
This commit is contained in:
Aki Niemi 2011-02-04 14:58:04 +02:00
parent d957dbece5
commit 090dc92b68
2 changed files with 21 additions and 7 deletions

View File

@ -35,6 +35,7 @@ enum message_id {
PNS_NAME_ADD_REQ = 0x05,
PNS_NAME_REMOVE_REQ = 0x07,
PNS_SUBSCRIBED_RESOURCES_IND = 0x10,
PNS_SUBSCRIBED_RESOURCES_EXTEND_IND = 0x12,
COMM_ISI_VERSION_GET_REQ = 0x12,
COMM_ISI_VERSION_GET_RESP = 0x13,
COMM_ISA_ENTITY_NOT_REACHABLE_RESP = 0x14,

View File

@ -341,16 +341,21 @@ static gboolean modem_subs_update(gpointer data)
gpointer keyptr, value;
GIsiModem *modem = data;
gboolean legacy = modem->flags & GISI_MODEM_FLAG_USE_LEGACY_SUBSCRIBE;
struct sockaddr_pn commgr = {
.spn_family = AF_PHONET,
.spn_resource = PN_COMMGR,
.spn_dev = modem->device,
};
uint8_t msg[3 + 256] = {
0, PNS_SUBSCRIBED_RESOURCES_IND,
0,
uint8_t msg[4 + 1024] = {
0, /* UTID */
legacy ? PNS_SUBSCRIBED_RESOURCES_IND :
PNS_SUBSCRIBED_RESOURCES_EXTEND_IND,
0, /* Count */
0, /* Filler */
};
uint8_t count = 0;
size_t len;
modem->subs_source = 0;
@ -359,14 +364,22 @@ static gboolean modem_subs_update(gpointer data)
while (g_hash_table_iter_next(&iter, &keyptr, &value)) {
GIsiServiceMux *mux = value;
if (mux->subscriptions > 0) {
if (mux->subscriptions == 0)
continue;
if (legacy)
msg[3 + count] = mux->resource;
count++;
}
else
/* Resource field is 32bit and Little-endian */
msg[4 + count * 4 + 3] = mux->resource;
count++;
}
len = legacy ? 3 + count : 4 + count * 4;
msg[2] = count;
sendto(modem->ind_fd, msg, 3 + msg[2], MSG_NOSIGNAL, (void *)&commgr,
sendto(modem->ind_fd, msg, len, MSG_NOSIGNAL, (void *) &commgr,
sizeof(commgr));
return FALSE;