aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2019-05-07hlr.c: fix possible msgb memleaks in read_cb()Vadim Yanitskiy1-4/+8
Change-Id: I1226eeb24d7657e2782760fab1b49d5581ab53e2
2019-05-07hlr.c: check the presence of msgb->l2h in read_cb()Vadim Yanitskiy1-6/+6
Checking the presence of msgb->l2h in read_cb_forward() doesn't make sense, since in read_cb() we pass it to osmo_gsup_decode(). Let's rather do this before calling osmo_gsup_decode(). Fix for Change-Id: Ia4f345abc877baaf0a8f73b8988e6514d9589bf5 Change-Id: I69a3d31aacbbb1abef3d83e42e46c899fe2f914b
2019-05-07hlr.c: fix: properly print the original message type in read_cb_forward()Vadim Yanitskiy1-1/+2
Printing 'OSMO_GSUP_MSGT_E_ROUTING_ERROR' in routing error messages instead of the original message type may be confusing. Let's store the original message type, and change just before sending. Fix for Change-Id: Ia4f345abc877baaf0a8f73b8988e6514d9589bf5 Change-Id: Ic1db1e089fc0f8e03653a9f05058e95d2adaee39
2019-05-07hlr.c: fix: also store the session state in read_cb_forward()Vadim Yanitskiy1-0/+1
If the session state is not set (OSMO_GSUP_SESSION_STATE_NONE), osmo_gsup_encode() would omit the OSMO_GSUP_SESSION_ID_IE. Fix for Change-Id: Ia4f345abc877baaf0a8f73b8988e6514d9589bf5 Change-Id: Idcd209a59d1ee5230104f3101740140d366b0646
2019-04-18hlr.c: forward GSUP messages between clientsOliver Smith1-0/+79
Allow clients to forward any GSUP message between clients. Determine the sender and receiver from the new {source,dest}_name{,_len} IEs. Reject messages with a forged source name. This will be used for the inter-MSC handover. Depends: Ic00b0601eacff6d72927cea51767801142ee75db (libosmocore.git) Related: OS#3793 Change-Id: Ia4f345abc877baaf0a8f73b8988e6514d9589bf5
2019-04-18add missing error log: invalid IMSINeels Hofmeyr1-1/+3
Change-Id: I65e9ecac06dc6d1abb9802d621c385d3b4fab83a
2019-04-18fix error logging for GSUP routeNeels Hofmeyr1-1/+1
The addr may not be nul terminated. Change-Id: Ie4def16008af573ed2e1367d9da50c3d2b5a71ef
2019-04-11USSD: don't use gsm0480_msgb_alloc_name()Oliver Smith1-1/+1
We have nothing to do with GSM 04.80 at the HLR - it's only used to encapsulate the SS payload between MS and MSC. This is not that critical, but may be misleading. Also, gsm0480_msgb_alloc_name() allocates a smaller buffer: return msgb_alloc_headroom(1024, 128, name); than osmo_gsup_client_msgb_alloc() does: return msgb_alloc_headroom(4000, 64, __func__); Change-Id: Icdab40c6a933888eb9f51bee9c5264c8919dbf7b
2019-04-09USSD: save MO USSD's originating MSC's vlr_numberOliver Smith3-14/+53
Save the source IPA name in ss_session, so we can send "invalid IMSI" messages to the originating MSC. Remove the fixed size from ss->vlr_number (we don't know the size of the IPA name when it does not come from the database). Add ss->vlr_number_len to give osmo_gsup_addr_send() the format it expects, and to have one less place in the code where the IPA names are not stored as blob. Looking up the IPA name from struct osmo_gsup_conn could either be done like in osmo_gsup_server_ccm_cb() by reading the IPA IEs (which has a FIXME comment), or by finding the route associated with conn. I went with the latter approach, because it seems cleaner to me. Related: OS#3710 Change-Id: If5a65f471672949192061c5fe396603611123bc1
2019-04-09USSD: fix routing to multiple MSCNeels Hofmeyr1-4/+33
hlr_ussd.c so far hardcoded osmo-msc's default IPA-name and hence was only able to negotiate USSD sessions to - a single osmo-msc - that has no custom IPA-name set. Fix: correctly route USSD to any number of MSC with any custom IPA names. Resolve the right MSC's IPA name from the USSD session's IMSI, using hlr_subscriber->vlr_number to determine the right GSUP peer. Cache it in ss_session->vlr_number to have at most one db hit for routing per session. Related: OS#3710 Change-Id: I18067bfadd33a6bc59a9ee336b6937313826fce3
2019-04-08Cosmetic: gsup_route_find: comment addr, addrlenOliver Smith2-2/+15
Describe the addr, addrlen parameters in gsup_route_find() and (more commonly used) osmo_gsup_addr_send(). Without this description, it is easy to get the parameters wrong and have routes not being found, as shown with debug prints like these: gsup_route_find: addr, addrlen: "MSC-13-37-00-00-00-00", 21 gsup_route_find: comparing with: "MSC-13-37-00-00-00-00\0", 22 Change-Id: Ib79878970bd07caac6eb921af8ae95403b90a4cb
2019-03-19hlr.c: properly terminate the process on SIGTERMVadim Yanitskiy1-1/+3
As per the systemd.kill manual, when a service is going to be stopped by systemd, the process will first be terminated via SIGTERM. If then, after a delay, processes still remain, the the termination request is repeated with the SIGKILL. It was observed that osmo-hlr immediately terminates on SIGTERM, leaving the SQLite database open. As a result, several temporary files (such as hlr.db-shm, hlr.db-wal) remain, allowing the further recovery: DDB ERROR <0001> db.c:86 (283) recovered 10 frames from WAL file Let's properly handle SIGTERM in the same way as we handle SIGINT. Change-Id: I1a4a48b95bbaed74ff5a03fb5797a44bdb1fcd3a
2019-02-26hlr.c: move hlr_ctx to the topOliver Smith1-2/+1
Allow all functions to use hlr_ctx, so it can be used by the upcoming read_cb_forward() function in [1]. That new function is placed next to the existing read_cb() function, which is above the current hlr_ctx declaration. [1]: Change-Id: Ia4f345abc877baaf0a8f73b8988e6514d9589bf5 Related: OS#3793 Change-Id: I5edf0a233ff323a63e321a1ca47736b5b212d1bb
2019-02-18Enable statsd supportMax2-0/+4
Change-Id: I00b8aa4e59028a4c1098a3bae034e8d8ddfbe681
2019-02-14Log ip:port when adding GSUP routesMax1-1/+1
Change-Id: I7202fdf59e763dbca261508685555b324ac7e4c0
2019-02-04hlr.c: replace deprecated osmo_gsup_get_err_msg_type()Oliver Smith1-7/+1
Use OSMO_GSUP_TO_MSGT_ERROR() instead. The other function has been deprecated in [1]. Remove the < 0 return check, because the macro doesn't do any error handling. It relies on all "request" messages having an appropriate "error" message, which is part of the GSUP spec now (see [2]). [1] change-id I46d9f2327791978710e2f90b4d28a3761d723d8f (libosmocore) [2] change-id Iec1b4ce4b7d8eb157406f006e1c4241e8fba2cd6 (osmo-gsm-manuals) Change-Id: I5435ec4c29d6acee814c33499c68d18aaa91d4fb
2019-01-24VTY: integrate IMEIOliver Smith1-2/+73
Display the IMEI in "subscriber ... show", allow showing and modifying subscribers by their IMEI with: "subscriber imei ...". For debug purposes (and to have proper VTY tests), make it possible to change the IMEI with "subscriber ... update imei". IMEIs are saved in the database without the 15th checksum number. When the checksum gets passed, verify it and cut it off. Related: OS#2541 Depends: I02b54cf01a674a1911c5c897fbec02240f88b521 (libosmocore) Change-Id: I1af7b573ca2a1cb22497052665012d9c1acf3b30
2019-01-24Optionally store IMEI in subscriber tableOliver Smith3-2/+39
Add VTY config option "store-imei". When it is set, store the IMEI sent from the VLR with CHECK-IMEI in the database. Related: OS#2541 Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57
2019-01-24Add IMEI column to subscriber tableOliver Smith3-12/+133
Extend the database scheme, add imei to the hlr_subscriber struct and create db_subscr_update_imei_by_imsi() and db_subscr_get_by_imei(). The new functions are used in db_test, and in follow-up commits [1], [2]. Upgrade DB schema to version 2. SQLite can only insert new columns at the end of the table, so this happens when upgrading the database. In new databases, the column is placed after the IMEISV column (where it makes more sense in my opinion). This should not have any effect, as we never rely on the order of the columns in the tables. Follow-up commit [1] will make use of this column to save the IMEI as received from the MSC/VLR with the Check-IMEI Procedure. It was decided to use Check-IMEI instead of the recent Automatic Device Detection Procedure (which would send the IMEISV) in OS#3733, because with Check-IMEI we don't need to rely on very recent releases of the specification. [1] change-id I09274ecbed64224f7ae305e09ede773931da2a57 "Optionally store IMEI in subscriber table" [2] change-id I1af7b573ca2a1cb22497052665012d9c1acf3b30 "VTY: integrate IMEI" Depends: Id2d2a3a93b033bafc74c62e15297034bf4aafe61 (libosmocore) Related: OS#2541 Change-Id: If232c80bea35d5c6864b889ae92d477eeaa3f45d
2019-01-15Cosmetic: fix arg desc of db_subscr_update_msisdn_by_imsi()Oliver Smith1-2/+2
Properly note that NULL can only be passed as msisdn, not imsi in that function. Change-Id: I19b6ad0cf6e9a4bfa9bffa447ebfc7bd1bcac361
2019-01-09Cosmetic: hlr.c: remove confusing indent below ifOliver Smith1-7/+6
Remove a misleading block in rx_upd_loc_req() around the call to lu_op_tx_insert_subscr_data(). At least for me, this made the block look like it belonged to the if statement above (which has no brackets), before I looked more closely at it. Change-Id: I96d3ba4108f4811279caf088a9179afce24e8112
2019-01-07Reply to CHECK-IMEI GSUP messagesOliver Smith1-0/+36
Decode the IMEI from incoming CHECK-IMEI messages, print the IMEI to the log and always send ACK back to the VLR/MSC. In the future, we will not only log the IMEI, but store it in the HLR (OS#2541). This is not the original intention of CHECK-IMEI from the 3GPP spec, but an useful side effect. Depends: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155 (libosmocore) Related: OS#3733 Change-Id: Ib240474b0c3c603ba840cf26babb38a44dfc9364
2018-12-20gsupclient: introduce osmo_gsup_client_enc_send()Vadim Yanitskiy1-0/+36
Several parts of OsmoMSC (e.g. GSM 04.11, 09.11, etc.) are dealing with GSUP message encoding and sending towards OsmoHLR. In order to avoid code duplication, let's have a shared function here. Change-Id: I0589ff27933e9bca2bcf93b8259004935778db8f
2018-12-10display last location update timestamp in vtyStefan Sperling3-0/+44
Read the subscriber's last location update timestamp from the database and display it in the output of 'show subscriber'. For example: OsmoHLR> show subscriber id 1 ID: 1 IMSI: 123456789000000 MSISDN: 543210123456789 VLR number: 712 SGSN number: 5952 last LU seen: Fri Dec 7 11:30:51 2018 UTC While the database stores the timestamp as a string, we convert the timestamp into time_t for internal use. This allows for flexible potential use of the timestamp in contexts other than the VTY in the future. The timestamp displayed in the VTY is created with ctime_r(3). It does not match the format of the raw string in the database: sqlite> select id,last_lu_seen from subscriber; 1|2018-12-07 11:30:51 Related: OS#2838 Change-Id: Ie180c434f02ffec0d4b2f651a73258a8126b2e1a
2018-12-07add whitespace around PRId64 constantsStefan Sperling4-17/+17
Avoid string concatenations without interleaving whitespace. Some compilers don't like "foo""bar", they only like "foo" "bar". Requested by: Pau https://gerrit.osmocom.org/c/osmo-hlr/+/12121/5/src/db_hlr.c#637 Change-Id: Ic7a81114f9afbefcbd62d434720854cfdd4a2dd9
2018-12-07store a timestamp of the last location update seen from a subscriberStefan Sperling3-3/+101
Timestamps are stored in the HLR DB in the new 'last_lu_seen' column of the 'subscriber' table, in UTC and in granularity of seconds. At present, osmo-hlr only records these timestamps but otherwise makes no use of them. Because the timestamps are stored in a human-readable form, they may already provide value to external processes which need this information. For example: sqlite> select imsi,last_lu_seen from subscriber; 901990000000001|2018-12-04 14:17:12 I didn't bother adding additional tests because the code added with this commit is already being exercised by several calls to db_subscr_lu() in db_test.c. This change requires a HLR DB schema update. Existing databases won't be upgraded automatically. However, osmo-hlr will refuse to operate with databases which are not upgraded. Change-Id: Ibeb49d45aec18451a260a6654b8c51b8fc3bec50 Related: OS#2838
2018-12-06introduce osmo_gsup_client_create2()Stefan Sperling1-18/+39
Add a new API which allows creating a GSUP client connection with more identification information than just a unit name. Instead of being selective about which idenfifiers callers may use, allow callers to pass a full-blown struct ipaccess_unit. This allows applications to use entirely custom identifiers on GSUP client connections. This change is a prerequisite for inter-MSC handover because MSCs will need to use unique identifiers towards the HLR, which isn't very easy to do with the old osmo_gsup_client_create() API. While it's always been possible to pass a unique unit_name, this is not as flexible as we would like. The old API remains for backwards compatibility. struct osmo_gsup_client grows in size but is allocated internally by the library; old calling code won't notice the difference. Change-Id: Ief09677e07d6e977247185b72c605f109aa091f5 Related: OS#3355
2018-12-05SS/USSD: fix: properly (re)schedule NCSS session timeoutVadim Yanitskiy1-3/+7
It may happen that either the MS or an ESME would become unresponsive, e.g. due to a bug, or a dropped message. This is why we have SS session timeout, that prevents keeping 'stalled' sessions forever. For some reason, it wasn't properly resceduled in case of subsequent SS/USSD activity, so the lifetime of a session was limited. Let's properly (re)schedule it. Change-Id: I11aeacf012b06d3d0b5cc6e64baecf857b645fda Related: OS#3717
2018-12-05SS/USSD: make NCSS session timeout configurableVadim Yanitskiy5-4/+28
It may happen that either the MS or an ESME would become unresponsive, e.g. due to a bug, or a dropped message. This is why we have SS session timeout, that prevents keeping 'stalled' sessions forever. Let's introduce a VTY option, which can be used to configure this timer (by default it's set to 30 seconds): hlr ... ! Use 0 to disable this timer ncss-guard-timeout 30 Change-Id: I971fc2cee6fd46d4d5d6dac6c634e0b22fff183d Related: OS#3717
2018-12-05SS/USSD: release IUSE sessions immediately after responseVadim Yanitskiy1-0/+2
At the moment, all available IUSE handlers do assume a single request-response operation, e.g. MS requests its MSISDN - IUSE responds. No further nor intermediate communications is required. Let's immediately terminate such SS sessions in order to avoid waiting for the session inactivity watchdog (i.e. timeout). Change-Id: Iaefe37512da79e10fbe92378236bfff0eae0f8b9
2018-12-04Rename db_bootstrap.sed to db_sql2c.sedNeels Hofmeyr2-5/+5
Side effect of the db schema patch, now a mere cosmetic change. Change-Id: I47a101e3b76b2125d786f22bf100604cf5e8eb40
2018-12-04add database schema versioning to the HLR databaseStefan Sperling4-18/+118
Make use of pragma user_version to store our database schema version. The present schema is now identitifed as 'version 0', which is also the default value for databases on which we never ran the statement 'pragma user_version' before. Only bootstrap the database if it hasn't been bootstrapped yet. Previously, bootstrap SQL statements ran every time osmo-hlr opened the database, and any errors were being ignored in SQL. Instead, we now first run a query which checks whether tables already exist, and only create them if necessary. This change will allow future schema updates to work properly. Prepare for future schema upgrades by adding a new command-line option which enables upgrades. This option defaults to 'false' in order to avoid accidental upgrades. Change-Id: I8aeaa9a404b622657cbc7138106f38aa6ad8d01b Related: OS#2838
2018-12-02implement removal of MSISDNNeels Hofmeyr4-20/+37
Add the first "official" way to remove the MSISDN from a subscriber entry, to go back to 'MSISDN: none' like just after 'subscriber create'. Add VTY command 'subscriber <ID> update msisdn none' to drop the MSISDN from the subscriber. (Like 'subscriber <ID> update aud3g none') Add DB_STMT_DELETE_MSISDN_BY_IMSI. In db_subscr_update_msisdn_by_imsi(), allow passing a NULL msisdn, and if NULL, call above delete SQL statement. Change-Id: I15419105ea461137776adb92d384d8985210c90e
2018-12-02add 'show subscriber' command, alias for 'subscriber ... show'Neels Hofmeyr1-2/+7
When I wrote the osmo-hlr subscriber command, I failed to heed the common 'show foo' scheme and instead created a 'subscriber [...] show' command. Relieve that weirdness by creating an alias that has 'show' at the start. Arrange string macros so that the 'show subscriber' cmd doesn't end in a space (the SUBSCR macro ends in a space ' ' to implicitly include the space to commands like 'create', 'show', 'update'). Add the new command to test_nodes.vty and test_subscriber.vty. Change-Id: I01ce9b0868302d40ed05c6a588316a194d6071e4
2018-10-16fix and re-enable osmo_hlr_subscriber_update_notify()Neels Hofmeyr1-23/+42
Send updated subscriber data out to exactly those GSUP clients that match the last LU operations (depending on each client sending distinct identification). As this adds logging on DLGSUP, also change adjacent GSUP related logging from DMAIN to DLGSUP. Related: OS#2785 Change-Id: I7c317de8329d9a115d072fc61ddb9abc21b7e8d8
2018-10-12hlr_ussd.c: fix: reject 'structured' SS requestsVadim Yanitskiy1-2/+9
As we don't store any SS related information (e.g. call forwarding preferences) in the database, we don't handle 'structured' SS requests at all. Let's reject them by sending error message with FACILITY_NOT_SUPPORTED code. Change-Id: Ia1317c5d372a42473cce65c0c985103e43be77fd Related: OS#3651
2018-10-05store gsup peer upon accepting LUNeels Hofmeyr1-0/+12
Store the GSUP client's IPA_IDTAG_SERNR in vlr_number or sgsn_number (depending on is_ps), just before sending the Insert Subscriber Data message after a successful LU Req. Log about it. Original patch: Ib2611421f3638eadc361787af801fffe9a34bd8a by laforge Related: OS#2796 Change-Id: If438664faa5d68404f465f8b2002c6d03bbf3ceb
2018-10-04more space for vlr_number and sgsn_numberNeels Hofmeyr1-2/+2
To be able to handle our 20 chars long IPA tags, enlarge the vlr_number and sgsn_number storage in struct hlr_subscriber. Technically, osmo-hlr should be able to store any type of Global Title, blob of arbitrary size. For our purposes, 32 is enough for now. Related: OS#2796 Change-Id: I0121f1c4dbda3a076d780a3834281b21dab85493
2018-09-28fix is_ps logic in rx_upd_loc_req(), store CS as is_ps = falseNeels Hofmeyr1-5/+6
A missing 'else' in rx_upd_loc_req() causes *all* clients to be indicated as is_ps=true regardless of the GSUP CN Domain IE that was received. Replace that odd if cascade with a switch() that fixes the flawed logic. Hence osmo-hlr now correctly indicates each client's is_ps, iff the client sends CN Domain IEs in GSUP LU Request messages. Related: OS#2796, OS#3601 Change-Id: I2c5fa9f5cae25cfd66afbf088303edff7d045a00
2018-09-03libosmo-gsup-client: License is GPLv2-or-laterHarald Welte1-4/+4
Fix the unintentional AGPLv3-or-later license header in gsup_client.c Change-Id: I6378bd59fdbe8d95cd6132a1cbc40ae29b558c42
2018-08-08USSD: Fix "ussd default-route"Harald Welte1-0/+5
Before this patch, the default route logic was not implemented. The user could specify a default-route, but it wouldn't be used by the actual routing logic. Let's fix that. Change-Id: I0b04a75dc297f088f13da413d08c52e0747e46e6
2018-08-08hlr_ussd.c: avoid using CR and NL in IUSE responsesVadim Yanitskiy1-2/+2
According to GSM TS 03.38, section 6.1.2.1, CR symbol at the end is optional, and moreover libosmogsm encoding API will carry about the bit padding itself. Change-Id: I09e8a67758698f3b7a578eab956311e269d091ee
2018-08-03hlr_ussd.c: fix: properly print a EUSE / IUSE nameVadim Yanitskiy1-2/+4
We need to distinguish between both EUSE and IUSE, and properly print their names. Otherwise, garbage is printed in case of IUSE. Change-Id: I497e7c1fe41279afdb1256ee69e166066a6462bb
2018-08-02USSD/hlr_vty.c: print error if EUSE is not foundVadim Yanitskiy1-1/+7
Change-Id: I18045c5e544a99b2414a6f0268f1343df119b9f3
2018-08-01hlr_ussd.h: drop meaningless forward declarationVadim Yanitskiy1-2/+1
Change-Id: I70a5c7c83c2356b779fb1ea7ffe07ccc1e279c22
2018-07-31hlr_ussd.h: use proper libc headersVadim Yanitskiy1-1/+2
Change-Id: I2b9485be08c6cbf188ed1f4059ff28ab65c61dbf
2018-07-31hlr_ussd.h: add #pragma once include guardVadim Yanitskiy1-0/+2
Change-Id: Iba9470e11af2f2609486b9b0b6bfa3207b883a3a
2018-07-30hlr_vty_subscr.c: fix subscriber creation command helpVadim Yanitskiy1-2/+3
Change-Id: Id8dda53cdd10aeedf5451109f9e61d6438c3e09b
2018-07-30USSD: Add support for internal USSD handlersHarald Welte5-88/+249
There are some requests that are best served inside the HLR, as it has access to subscriber information such as MSISDN and IMSI. This unfortunately required quite some restructuring of the USSD related structures including the VTY syntax for adding routes. The default config file has been updated to replicate the *#100# built-in behavior of old OsmoNITB. Closes: OS#2566 Change-Id: I1d09fab810a6bb9ab02904de72dbc9e8a414f9f9
2018-07-30Add osmo-euse-demo as minimalistic test of a External USSD (EUSE) handlerHarald Welte2-0/+253
This is a small program which simply echo's the USSD request message it gets in a quote back to the sender. Its purpose is to illustrate how EUSEs can be implemented using libosmo-gsup-client. Change-Id: I3fb8554ca329cb609c591058254117006f665e73