Commit Graph

321 Commits

Author SHA1 Message Date
Mychaela N. Falconia be8bcd30eb ctrl: add subscriber.by-*.imsi GET-able variable
There may be a need in various OsmoCNI-attached entities (for example,
external SMSC implementations) to perform a mapping from known MSISDN
to unknown IMSI, querying OsmoHLR subscriber db for it.  Querying for
subscriber.by-msisdn-*.imsi will be much more efficient (and easier on
client-side implementors) than querying for subscriber.by-msisdn-*.info
and fishing the IMSI out of the long multiline response, discarding all
other irrelevant info.

Related: OS#6312
Change-Id: Icea1a74d0c664047f46758ab4ad75508782f3d12
2023-12-17 21:47:21 +00:00
Mychaela N. Falconia e513c43857 SMS over GSUP: handle READY-FOR-SM.req from MSCs
When an MS indicates that it is ready to receive MT SMS, the MSC will
send us a READY-FOR-SM.req message.  Handle it by sending copies of
the same message to all connected SMSCs and returning OK result
to the MS that indicates its ready status.

Related: OS#6135
Change-Id: I731545a3a0d0804289e24a7769e13bfd3f645132
2023-09-21 02:06:58 +00:00
Mychaela N. Falconia f6a303c669 SMS over GSUP: implement forwarding of MT SMS
When an SMSC tries to deliver an SM to a subscriber, it will send us
an MT-forwardSM.req GSUP message.  We look up the subscriber by IMSI
and see if they are attached to a VLR.  If the subscriber is attached,
we forward the message to the MSC/VLR, otherwise return an error
to the SMSC.

Related: OS#6135
Change-Id: Ib3551bf7839690606c677461758c5cfef5f0aa7b
2023-09-21 02:06:49 +00:00
Mychaela N. Falconia 786ec5b91c SMS over GSUP: implement forwarding of MO SMS
MO-forwardSM.req messages are now forwarded to a connected SMSC
based on the SMSC address (SM-RP-DA) in the MO SM and the vty-defined
mapping from SMSC numeric addresses to IPA names.

Related: OS#6135
Depends: Iea5c29909c5be80f81dbbc2873656ff5cf590a5d (libosmocore)
Change-Id: Iaad4531922c41583d261c79f42561a1bdbe03521
2023-09-21 02:05:15 +00:00
Mychaela N. Falconia ff7c7ea085 SMS over GSUP: implement vty config of SMSC routing
At the user-visible level (advanced settings menus on phones,
GSM 07.05 AT commands, SIM programming) each SMSC is identified
by a numeric address that looks like a phone number, originally
meant to be a Global Title.  OsmoMSC passes these SMSC addresses
through as-is to MO-forwardSM.req GSUP message - however, SMSCs
that connect to OsmoHLR via GSUP identify themselves by their
IPA names instead.  Hence we need a mapping mechanism in OsmoHLR
config.

To accommodate different styles of network design ranging from
strict recreation of classic GSM architecture to guest roaming
arrangements, a two-level configuration is implemented, modeled
after EUSE/USSD configuration: first one defines which SMSCs exist
as entities, identified only by their IPA names, and then one
defines which numeric SMSC address (in SM-RP-DA) should go to which
configured SMSC, with the additional possibility of a default route.

Related: OS#6135
Change-Id: I1624dcd9d22b4efca965ccdd1c74f0063a94a33c
2023-09-21 01:56:21 +00:00
Vadim Yanitskiy fa6af8872f hlr_vty.c: drop redundant include of hlr_ussd.h
Change-Id: Ia873c3ea7fb76cb83628811f159e9d5f2de8dcbd
2023-09-17 02:04:05 +00:00
Pau Espin d052f076e3 Bump version: 1.6.0.20-37f0-dirty → 1.7.0
Change-Id: I3f169ff8f9b10a4d4b5c50286951d326fa713245
2023-09-12 14:41:34 +02:00
Alexander Couzens 37f0b3a8f3 Add support for multiple APN profiles for subscriber data
Previously the HLR sent in the Insert Subscriber Data call only the
wildcard APN as a single entry.
This violates the spec because the first entry (with the lowest context_id) is
always the default APN, but it is forbidden to have a wildcard APN as default apn.

Introduce a default template/profile which can contain multiple APNs.
This profile is always sent out to the SGSN/MME as part of Insert-Subscriber-Data.
In the future a subscriber might have a profile template name written into the
database which will resolve to a "pdp-profile premium" in the configuration.

To be backward compatible, if the pdp-profile default section is missing,
the HLR will send out only a wildcard APN.

Config example:

hlr
 ps
  pdp-profile default
   profile 1
    apn internet
   profile 2
    apn *

Changes to the apn list will be only handed out to subscribers
when the subscriber do a location update.

Related: SYS#6391
Change-Id: I540132ee5dcfd09f4816e02e702927e1074ca50f
2023-09-12 09:48:02 +00:00
Harald Welte 7a763aa012 Add VTY support for TUAK algorithm
Change-Id: If2611658f7cb990b484d7429ab2f944f56fd2eb6
Depends: libosmocore.git Ib905b8d8bdf248e8299bf50666ee1bca8298433d
2023-08-29 13:42:41 +00:00
Harald Welte 626f5eb740 db: extend database schema to support 256bit K and/or OP[c] values
Other UMTS AKA algorithms than MILENAGE (notably TUAK) support K sizes
of up to 256bit, or mandate a OP/OPc size of 256 bit.

Let's extend our database schema to accommodate such larger sizes.

Change-Id: Ibbde68484c904507a15c35cbfdf88cd47d0c7039
2023-08-29 13:42:41 +00:00
Vadim Yanitskiy 5800f3add5 USSD: fix handling of ussd-DataCodingScheme != 0x0f
The usual Data Coding Scheme value in the mobile-originated USSD
request (processUnstructuredSS-Request) is 0x0f, which means:

  0000 .... = Coding Group: Coding Group 0 (Language using the GSM 7 bit default alphabet)
  .... 1111 = Language: unspecified

However some modems are known to use a different default value, if
not specified explicitly (AT+CUSD has optional DCS parameter):

  0000 .... = Coding Group: Coding Group 0 (Language using the GSM 7 bit default alphabet)
  .... 0000 = Language: German (0)

In function rx_proc_ss_req(), we should not be using req.ussd_text,
because this field has been deprecated and may contain unexpected
data.  For example, in the abovementioned case it would contain the
7 bit encoded ussd-String 'aa510c061b01'O and osmo-hlr would indeed
fail to find a matching route for a non-ASCII string.

Instead of relaying on gsm0480_parse_facility_ie(), let's check the
Data Coding Scheme value and decode the request string ourselves.
Expect the Coding Group 0, but be more tolerant to the indicated
language: print a warning and treat it as '1111'B (unspecified).

Change-Id: Ib7bac660b1a7942adcfbe7b14f162c95061a25db
Related: OS#6075
2023-07-21 12:49:20 +00:00
Vadim Yanitskiy f8b73f0682 gsup_server: fix msgb memleak in osmo_gsup_server_read_cb()
I noticed that inability to send IPA PONG in response to IPA PING
from osmo-{msc,sgsn} results in an "IPA Multiplex" chunk being leaked.

No matter what's returned from ipa_server_conn_ccm(), we need to free
the msgb containing the incoming IPA message.

Change-Id: I5c5acbffc2913f78db4894ae3633b5eca9c2e8d6
2023-07-05 01:10:43 +07:00
Vadim Yanitskiy f4223f5b53 ussd: fix GSUP memleaks in rx_proc_ss_{req,error}()
Also take a chance to use a more suitable error cause value.

Change-Id: I22ba5ad470989b7e8ba8fe2be170eac4adcb48c5
2023-07-05 00:24:19 +07:00
Vadim Yanitskiy 1c23f304d1 lu_fsm: fix memleak in lu_fsm_wait_insert_data_result()
Currently osmo-hlr leaks memory (msgb holding 1203 bytes of data and
a struct osmo_gsup_req) on receipt of OSMO_GSUP_MSGT_INSERT_DATA_ERROR.

Change-Id: I4c70a06169158c869360707a7a62436dbf13b9b3
2023-07-05 00:15:17 +07:00
Harald Welte f4159bd54c src/db.c: Switch from "const char *statements" to "const char * const"
This is primarily to make the linter happy, which spews "static const
char * array should probably be static const char * const" errors in
gerrit when adding similar new code to this existing file.  So let's
first convert the old code and then add new code that makes the linter
happy.  I guess it does have a point, as both the individual string
pointers as well as the array of the pointers are constant.

Change-Id: I39e9fb6bd8052f4878cfc95061775bf940631ae5
2023-06-14 14:53:07 +02:00
Harald Welte a854b48762 Port to new libosmogsm 'struct osmo_sub_auth_data2'
libosmogsm has recently introdcued a 'struct osmo_sub_auth_data2' as
successor to 'struct osmo_sub_auth_data', together with updated
osmo_auth_gen_vec2/osmo_auth_gen_vec_auts2 API.

The rationale of this new API is to enable
* support for AKA algorithms which use K and/or OP[c] values of 256bit
  (instead of the classic 128bit)
* support for RES length sizes of 4 and 16 bytes (instead of the classic
  8 bytes)

This commit just jumps over to the new API without adding any related
functionality to osmo-hlr.  The latter is left for subsequent commits.

Change-Id: I3207c7bfb73e9ff5471e5c26b66639549e4d48a2
Depends: libosmocore.git Ie775fedba4a3fa12314c0f7c8a369662ef6a40df
2023-06-14 14:53:04 +02:00
Harald Welte 829713a69d Introduce support for XOR-2G algorithm
So far we supported a "xor" algorithm in osmo-hlr, without specifying
whether it's the XOR-3G or the (different) XOR-2G algorithm.

Furthermore, it was buggy in the sense that it permitted the XOR[-3G]
for 2G authentication data in the database.

This patch
* renames existing "xor" to "xor-3g"
* disallows "xor-3g" usage with 2G authentication data
* introduces support for XOR-2G as "xor-2g" in the VTY

Change-Id: I039a1f84fda54a908a82fe621e7fd078cb85e4c6
Depends: libosmocore.git I0ee0565382c1e4515d44ff9b1752685c0a66ae39
2023-05-30 21:43:14 +02:00
Alexander Couzens 2989873a68 hlr: use talloc for memory allocation in osmo_gsup_create_insert_subscriber_data_msg
Don't use static buffers for APN and MSISDN.
When encoding multiple APNs the static buffer might be too small.
In prepration to support multiple APNs in subscriber data

Change-Id: I00b5c2dfadcf6e0740e93b4c3292d2654d22e80c
2023-05-10 07:58:57 +00:00
Pau Espin cf535dbcbd mslookup: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I26bba0dd092ad5fd6b4959b173fae93b542a93f1
2023-03-14 11:42:24 +01:00
Pau Espin ed939154f8 Bump version: 1.5.0.19-268a-dirty → 1.6.0
Change-Id: Ide480a902bbfadefa396f3a0cb925f5dceab4f9c
2023-02-07 16:49:15 +01:00
Alexander Couzens 268a33e58b Add vty `reject-cause` to set the reject cause
Allow to set the LU reject cause independently for both of the
following cases; either when an IMSI is unknown to the HLR or
when the mslookup client does not a receive a timely response
to a GSUP request for the remote home HLR.

Original patchset modified by <keith@rhizomatica.org>

Change-Id: Icea39020c23fbbea9e92847df76af8986fdbf48a
2023-01-20 14:03:01 +00:00
Neels Hofmeyr 8804a2335a fix memleak of proxy_subscr_listentry
Patch-by: whytek
Related: OS#5854
Change-Id: Ic1ec4911fa5ae91cc75aa865c8201edd83af41ed
2023-01-15 22:45:31 +01:00
Keith Whyte c27bc90ae6 Vty: Fixup config shown/written from vty
This commit fixes the following errors:
Missing timeout param for mslookup.
Fails to start reading a written config if an msc node
is configured in the mslookup server.
Places the individual msc node services in the
top-level wildcard node due to incorrect indentation.

* Add missing timeout param.
* Add missing "ipa-name" part to mslookup-server-msc section.
* Add one extra space indentation for msc services.

This commit also adds a DEFINE for the default timeout value.

Change-Id: Ibb60e74a0803f05f37ac13ca529d77b4cb736025
2022-12-27 17:03:08 +00:00
Oliver Smith f80ab768d0 osmo_mdns_rfc_record/question_encode: remove ctx
Remove the ctx argument to both functions, as it's not used anymore.

Related: OS#5821
Change-Id: I5e3dd18bf08f7aa42f49c262e13250778ea0c6a2
2022-12-23 13:51:28 +01:00
Oliver Smith 5decd49713 mslookup: use apn functions from libosmocore
Use the apn functions from libosmocore to encode and decode qnames to
avoid code duplication and to avoid unnecessary dynamic allocation.

The unit tests for encoding and decoding rfc_question / rfc_record are
still passing and have the same output.

Fixes: OS#5821
Change-Id: I09d3c617fd6eb4075084ee106d3f3c5803861d2f
2022-12-23 13:51:22 +01:00
Oliver Smith c5f034b13d osmo_mdns_rfc_record_decode: proper free on err
Free the whole talloc tree of ret if we can't allocate memory for
ret->rdata.

Related: OS#5821
Change-Id: Iefc89e3c75a4bf4ffee3871c7b551a2a608f7d5f
2022-12-23 13:38:19 +01:00
Oliver Smith 01155eaee6 osmo_mdns_rfc_record_decode: check ret of talloc
Related: OS#5821
Change-Id: Icd0f54a8eb80ca50976f248e017f6e5c727385f3
2022-12-23 13:38:15 +01:00
arehbein e4143234c8 osmo-hlr: Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: I5cee719a9c4437712915f0f9760d606f6ec2dd43
2022-12-23 11:13:19 +00:00
Max 6263cf350a ctrl: take both address and port from vty config
Change-Id: Iecae15333a4e77b38d9bce8c8e591af3d5fcf347
2022-12-17 20:59:00 +03:00
Harald Welte 7a4765325d Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I861be39275b40c522c02f553074c5a4489e87127
2022-11-03 12:56:24 +01:00
Max 53f6067e97 hlr_vty.c: fix typo
Change-Id: If79ebd9a8998e64be55e52af43e426f37e3972af
2022-09-24 01:55:46 +00:00
Vadim Yanitskiy 6156950634 db_auc: hexparse_stmt(): check value returned by osmo_hexparse()
Change-Id: I78bb3aff9dd57a38278bb34113ea764e0a54c439
Fixes: CID#272997
2022-06-29 11:30:12 +00:00
Pau Espin 777860ddb5 ctrl: Introduce CTRL command subscriber.by-*.aud3g <algo[,KI,(op|opc),OP_C[,ind_bitlen]]>
This command provides getter and setter to set and retrieve the
authentication data for 3g subscribers.

Change-Id: Ibe7aeec3cabab0406eb7a84ecd24e529ef1696c2
Related: SYS#5993
2022-06-21 10:35:40 +02:00
Pau Espin 1d0a030aa4 ctrl: Introduce CTRL command subscriber.by-*.aud2g <algo[,ki]>
This command provides getter and setter to set and retrieve the
authentication data for 2g subscribers.

Change-Id: Ibebac232fa173bce8a075cacf477214d5bdb590f
Related: SYS#5993
2022-06-21 10:35:18 +02:00
Pau Espin 3ca9a1fd4f ctrl: Introduce cmd SET subscriber.delete <imsi>
On success SET_REPLY contains the ID of the deleted subscriber.

Related: SYS#5993
Change-Id: I24c6149d7c223a12549d712a7929666220c0210f
2022-06-20 18:05:36 +02:00
Pau Espin b74769f1b4 cosmetic: hlr_vty_subscr.c: Fix trailing whitespace
Change-Id: Id751d227a52f39e3a8874d8b78c633b8d3eb9e74
2022-06-20 18:05:36 +02:00
Pau Espin 140dffd8f7 ctrl: Introduce CTRL command subscriber.by-*.msisdn
This command provides getter and setter to set and retrieve the MSISDN
of a subscriber.

Related: SYS#5993
Change-Id: I5f2e807859f7e28e0984c8dc37edc69319fd8e10
2022-06-20 13:37:59 +02:00
Pau Espin d63ec88dba ctrl: Introduce cmd SET subscriber.create <imsi>
Create a new subscriber from CTRL, similar to VTY command
"imsi IDENT create".

On success SET_REPLY contains the ID of the newly created subscriber.

Related: SYS#5993
Change-Id: Id1b760cd07712245a0eeabaac7891bce93c1fe8e
2022-06-20 13:37:53 +02:00
Pau Espin d456fced21 Fix db_subscr_create() not returning -EEXIST expected by VTY subscriber create cmd
As a result, the -EEXIST code path printing a specific error for
inserting already existing subscribers was not being triggered.

Change-Id: Id24dc6e0ff5115c8c9025404dd7296250d2b03ee
2022-06-17 19:09:39 +02:00
Pau Espin b4f25a0d1a ctrl: Mark function as static
Also move it more towards the end, where it is more expected as usually
done in ctrl/vty code.

Change-Id: Ieb956fb855752cfbe83d11aa0326685229a115e3
2022-06-17 15:56:27 +02:00
Oliver Smith 37a5b70195 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I4b20c685b6370bf5dc472a42664e2665eb0d8f8c
2021-12-14 12:15:54 +01:00
Neels Hofmeyr 3f9d1977df db v6: determine 3G AUC IND from VLR name
Each VLR requesting auth tuples should use a distinct IND pool for 3G
auth.  So far we tied the IND to the GSUP peer connection; MSC and SGSN
were always distinct GSUP peers, they ended up using distinct INDs.

However, we have implemented a GSUP proxy, so that, in a distributed
setup, a remotely roaming subscriber has only one direct GSUP peer
proxying for both remote MSC and SGSN. That means as soon as a
subscriber roams to a different site, we would use the GSUP proxy name
to determine the IND instead of the separate MSC and SGSN. The site's
MSC and SGSN appear as the same client, get the same IND bucket, waste
SQNs rapidly and cause auth tuple generation load.

So instead of using the local client as IND, persistently keep a list of
VLR names and assign a different IND to each. Use the
gsup_req->source_name as indicator, which reflects the actual remote
VLR's name (remote MSC or SGSN).

Persist the site <-> IND assignments in the database.

Add an IND test to db_test.c

There was an earlier patch version that separated the IND pools by
cn_domain, but it turned out to add complex semantics, while only
solving one aspect of the "adjacent VLR" problem. We need a solution not
only for CS vs PS, but also for 2,3G vs 4G, and for sites that are
physically adjacent to each other. This patch version does not offer any
automatic solution for that -- as soon as more than 2^IND_bitlen
(usually 32) VLRs show up, it is the responsibility of the admin to
ensure the 'ind' table in the hlr.db does not have unfortunate IND
assignments. So far no VTY commands exist for that, they may be added in
the future.

Related: OS#4319
Change-Id: I6f0a6bbef3a27507605c3b4a0e1a89bdfd468374
2021-07-19 09:01:06 +00:00
Pau Espin 608e2e483f db: Avoid use uninitialized rc if running 0 statements
Caught by new gcc 11.1.0:
/git/osmo-hlr/src/db.c:257:16: error: ‘rc’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  257 |         return rc;
      |                ^~

Change-Id: I45e1fede234cd4446a7061fb908bf344eee72f5a
2021-07-15 13:33:16 +02:00
Keith Whyte ca8e6efca6 vty: enable show subscribers filtered by IMEI
In 89fda3024a I added a
vty command to show a summary of filtered subscribers by imsi
or msisdn. In practice there is a also need to be able to
filter on IMEI.

The idea here is not to replace every operation that could be
done directly on the sql database in the vty, but this one
is useful.

Change-Id: Ic4a11d3ebcf8909c68e9f4617e94dc822491e008
2021-05-13 18:00:43 +00:00
Keith Whyte 649c335602 Correct configuration written from vty
osmo-hlr would not read back written configuration due to
bad indentation in the mslookup->server->service section.

Also ipa-name was missing.

Change-Id: Ied4b9504f06a51c3895054a8b9d07a67eda3aeeb
2021-02-26 01:21:41 +01:00
Pau Espin 6240465503 Bump version: 1.2.0.78-8c90-dirty → 1.3.0
Change-Id: Iffdee17c1f70f472fb9cfe722b77967c2634ea37
2021-02-23 18:13:54 +01:00
Harald Welte 2bd1a45553 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: I939f75d6c03145dbe185d849b95b2dd99782f35c
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: OS#5041
2021-02-23 16:48:36 +00:00
Keith Whyte b5a5676cff Fix Coverity Warnings
Explicitly check filter_type is not NULL even though the current code
never passed a NULL filter_type unless filter was also NULL.

Remove unreachable code.

Change-Id: Ib2bd9b2d6e9e559e61a895a25235669dae05fdf6
Related: coverity CID#216865
Related: coverity CID#216867
2021-01-30 07:35:26 +01:00
Keith Whyte 89fda3024a Add vty command to show summary of all or filtered subscribers
Adds the following commands:

show subscribers all - Display summary of all entries in HLR
show subscribers (imsi|msisdn|cs|ps) ... As above but filter on search field/string
show subscribers last seen - Display only subscribers with data in
Last LU update field, and sorts by Last LU.

Change-Id: I7f0573381a6d0d13841ac6d42d50f0e8389decf4
2021-01-29 21:26:08 +00:00
Keith Whyte cc90bfd0f4 Correct vty inline help for show subscriber
Change-Id: I035435859b60ce6d54da307c0d6397d4bd515439
2021-01-19 07:18:50 +00:00