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 | |
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
-rw-r--r-- | openbsc/include/openbsc/gsm_data.h | 5 | ||||
-rw-r--r-- | openbsc/include/openbsc/gsm_sup.h | 3 | ||||
-rw-r--r-- | openbsc/include/openbsc/transaction.h | 6 | ||||
-rw-r--r-- | openbsc/src/libmsc/gsm_sup.c | 17 | ||||
-rw-r--r-- | openbsc/src/libmsc/transaction.c | 13 |
5 files changed, 44 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index d27757c68..18f097c06 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -286,6 +286,11 @@ struct gsm_tz { int dst; /* daylight savings */ }; +struct charging_session_id { + uint32_t h; /* initialized to the current time */ + uint32_t l; /* incremented each time a session id is created */ +}; + struct gsm_network { /* global parameters */ uint16_t country_code; diff --git a/openbsc/include/openbsc/gsm_sup.h b/openbsc/include/openbsc/gsm_sup.h index f74bb9846..26017365d 100644 --- a/openbsc/include/openbsc/gsm_sup.h +++ b/openbsc/include/openbsc/gsm_sup.h @@ -23,4 +23,7 @@ int subscr_purge_ms(struct gsm_subscriber *subscr); int subscr_tx_sms_message(struct gsm_subscriber *subscr, struct gsm411_rp_hdr *rph); +void init_charging_session_id(struct gsm_network *network); +struct charging_session_id get_charging_session_id(struct gsm_network *network); + #endif /* _GSM_SUP_H */ diff --git a/openbsc/include/openbsc/transaction.h b/openbsc/include/openbsc/transaction.h index 234541caa..2a5a5af2a 100644 --- a/openbsc/include/openbsc/transaction.h +++ b/openbsc/include/openbsc/transaction.h @@ -34,6 +34,10 @@ struct gsm_trans { /* SMS RP message reference */ uint8_t msg_ref; + + /* Charging session id */ + struct charging_session_id session_id; + /* handle SMS local */ uint8_t sms_local; @@ -77,6 +81,8 @@ struct gsm_trans *trans_find_by_callref(struct gsm_network *net, uint32_t callref); struct gsm_trans *trans_find_by_msgref(struct gsm_subscriber_connection *conn, uint8_t msg_ref); +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_find_by_lchan(struct gsm_lchan *lchan); struct gsm_trans *trans_alloc(struct gsm_network *net, 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; |