diff options
author | Ivan Klyuchnikov <kluchnikovi@gmail.com> | 2018-05-21 18:38:54 +0300 |
---|---|---|
committer | Ivan Kluchnikov <kluchnikovi@gmail.com> | 2018-05-21 19:39:07 +0300 |
commit | 34fda429e97f2ac35e0e8a154bd222def9aa2d58 (patch) | |
tree | 568b1d6a4853624bda7706b77d96407035c48b21 /openbsc/src | |
parent | 2b23b83def1cd91b2cdb968f25b11fed8e2067ed (diff) |
sms charging: Implement Session Id to support charging sessions
Session Id:
- identify specific charging session
- must be globally and eternally unique
- h and l are decimal representations of the high and low 32 bits of a monotonically increasing 64-bit value
Change-Id: I986d62c34be849f3911cf2e4c83ead0ac8044571
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/libmsc/gsm_sup.c | 17 | ||||
-rw-r--r-- | openbsc/src/libmsc/transaction.c | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/openbsc/src/libmsc/gsm_sup.c b/openbsc/src/libmsc/gsm_sup.c index 1c33b447a..21e42adf1 100644 --- a/openbsc/src/libmsc/gsm_sup.c +++ b/openbsc/src/libmsc/gsm_sup.c @@ -247,6 +247,23 @@ static int rx_sms_message(struct gsup_client *sup_client, return gsm411_send_rp_msg_subscr(subscr, msg); } +void init_charging_session_id(struct gsm_network *network) +{ + network->session_id.h = (uint32_t)time(NULL); + network->session_id.l = 0; +} +struct charging_session_id get_charging_session_id(struct gsm_network *network) +{ + struct charging_session_id id; + + if (++network->session_id.l == 0) /* overflow */ + ++network->session_id.h; + id.h = network->session_id.h; + id.l = network->session_id.l; + + return id; +} + static int subscr_tx_sup_message(struct gsup_client *sup_client, struct gsm_subscriber *subscr, struct osmo_gsup_message *gsup_msg) diff --git a/openbsc/src/libmsc/transaction.c b/openbsc/src/libmsc/transaction.c index 0c1d08db1..077130868 100644 --- a/openbsc/src/libmsc/transaction.c +++ b/openbsc/src/libmsc/transaction.c @@ -77,6 +77,19 @@ struct gsm_trans *trans_find_by_msgref(struct gsm_subscriber_connection *conn, return NULL; } +struct gsm_trans *trans_find_by_session_id(struct gsm_network *net, + uint8_t proto, struct charging_session_id session_id) +{ + struct gsm_trans *trans; + llist_for_each_entry(trans, &net->trans_list, entry) { + if (trans->protocol == proto && + trans->session_id.h == session_id.h && + trans->session_id.l == session_id.l) + return trans; + } + return NULL; +} + struct gsm_trans *trans_find_by_lchan(struct gsm_lchan *lchan) { struct gsm_trans *temp; |