mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-hlr.git
synced 2025-10-27 18:23:44 +00:00
Compare commits
4 Commits
1.3.0
...
osmith/aut
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41ee4e8534 | ||
|
|
ca8e6efca6 | ||
|
|
ed2e36316b | ||
|
|
649c335602 |
66
README.md
Normal file
66
README.md
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
osmo-hlr - Osmocom HLR Implementation
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
This repository contains a C-language implementation of a GSM Home
|
||||||
|
Location Register (HLR). It is part of the
|
||||||
|
[Osmocom](https://osmocom.org/) Open Source Mobile Communications
|
||||||
|
project.
|
||||||
|
|
||||||
|
Warning: While the HLR logical functionality is implemented, OsmoHLR
|
||||||
|
does not use the ETSI/3GPP TCAP/MAP protocol stack. Instead, a much
|
||||||
|
simpler custom protocol (GSUP) is used. This means, OsmoHLR is of
|
||||||
|
no use outside the context of an Osmocom core network. You can use
|
||||||
|
it with OsmoMSC, OsmoSGSN etc. - but not with third party components.
|
||||||
|
|
||||||
|
Homepage
|
||||||
|
--------
|
||||||
|
|
||||||
|
The official homepage of the project is
|
||||||
|
https://osmocom.org/projects/osmo-hlr/wiki
|
||||||
|
|
||||||
|
GIT Repository
|
||||||
|
--------------
|
||||||
|
|
||||||
|
You can clone from the official osmo-hlr.git repository using
|
||||||
|
|
||||||
|
git clone git://git.osmocom.org/osmo-hlr.git
|
||||||
|
git clone https://git.osmocom.org/osmo-hlr.git
|
||||||
|
|
||||||
|
There is a cgit interface at https://git.osmocom.org/osmo-hlr/
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
User Manuals and VTY reference manuals are [optionally] built in PDF form
|
||||||
|
as part of the build process.
|
||||||
|
|
||||||
|
Pre-rendered PDF version of the current "master" can be found at
|
||||||
|
[User Manual](https://ftp.osmocom.org/docs/latest/osmohlr-usermanual.pdf)
|
||||||
|
as well as the VTY reference manuals
|
||||||
|
* [VTY Reference Manual for osmo-hlr](https://ftp.osmocom.org/docs/latest/osmohlr-vty-reference.pdf)
|
||||||
|
|
||||||
|
Mailing List
|
||||||
|
------------
|
||||||
|
|
||||||
|
Discussions related to osmo-hlr are happening on the
|
||||||
|
openbsc@lists.osmocom.org mailing list, please see
|
||||||
|
https://lists.osmocom.org/mailman/listinfo/openbsc for subscription
|
||||||
|
options and the list archive.
|
||||||
|
|
||||||
|
Please observe the [Osmocom Mailing List
|
||||||
|
Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules)
|
||||||
|
when posting.
|
||||||
|
|
||||||
|
Contributing
|
||||||
|
------------
|
||||||
|
|
||||||
|
Our coding standards are described at
|
||||||
|
https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards
|
||||||
|
|
||||||
|
We us a gerrit based patch submission/review process for managing
|
||||||
|
contributions. Please see
|
||||||
|
https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit for
|
||||||
|
more details
|
||||||
|
|
||||||
|
The current patch queue for osmo-hlr can be seen at
|
||||||
|
https://gerrit.osmocom.org/#/q/project:osmo-hlr+status:open
|
||||||
@@ -2,3 +2,13 @@ SUBDIRS = \
|
|||||||
systemd \
|
systemd \
|
||||||
dgsm \
|
dgsm \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
EXTRA_DIST = osmo-hlr-post-upgrade.sh
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
install -Dm755 $(srcdir)/osmo-hlr-post-upgrade.sh \
|
||||||
|
-t $(DESTDIR)$(datadir)/osmocom/
|
||||||
|
|
||||||
|
uninstall-hook:
|
||||||
|
@$(PRE_UNINSTALL)
|
||||||
|
$(RM) $(DESTDIR)$(datadir)/osmocom/osmo-hlr-post-upgrade.sh
|
||||||
|
|||||||
95
contrib/osmo-hlr-post-upgrade.sh
Normal file
95
contrib/osmo-hlr-post-upgrade.sh
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright 2021 sysmocom s.f.m.c GmbH <info@sysmocom.de>
|
||||||
|
#
|
||||||
|
# Packagers are supposed to call this script in post-upgrade, so it can safely
|
||||||
|
# upgrade the database scheme if required.
|
||||||
|
|
||||||
|
DB="/var/lib/osmocom/hlr.db"
|
||||||
|
IS_ACTIVE=0
|
||||||
|
|
||||||
|
msg() {
|
||||||
|
echo "osmo-hlr-post-upgrade: $@"
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
msg "ERROR: $@"
|
||||||
|
}
|
||||||
|
|
||||||
|
open_db() {
|
||||||
|
# Attempt to open the database with osmo-hlr-db-tool, it will fail if
|
||||||
|
# upgrading the schema is required
|
||||||
|
osmo-hlr-db-tool -s -l "$DB" create
|
||||||
|
}
|
||||||
|
|
||||||
|
check_upgrade_required() {
|
||||||
|
if ! [ -e "$DB" ]; then
|
||||||
|
msg "nothing to do (no existing database)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if open_db 2>/dev/null; then
|
||||||
|
msg "nothing to do (database version is up to date)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "database upgrade is required"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
if systemctl is-active -q osmo-hlr; then
|
||||||
|
IS_ACTIVE=1
|
||||||
|
msg "stopping osmo-hlr service"
|
||||||
|
systemctl stop osmo-hlr
|
||||||
|
|
||||||
|
# Verify that it stopped
|
||||||
|
for i in $(seq 1 100); do
|
||||||
|
if ! systemctl is-active -q osmo-hlr; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
|
||||||
|
err "failed to stop osmo-hlr service"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
msg "osmo-hlr service is not running"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_backup() {
|
||||||
|
backup="$DB.$(date +%Y%m%d%H%M%S).bak"
|
||||||
|
msg "creating backup: $backup"
|
||||||
|
if [ -e "$backup" ]; then
|
||||||
|
err "backup already exists: $backup"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cp "$DB" "$backup"
|
||||||
|
}
|
||||||
|
|
||||||
|
upgrade() {
|
||||||
|
msg "performing database upgrade"
|
||||||
|
osmo-hlr-db-tool -s -U -l "$DB" create
|
||||||
|
|
||||||
|
if ! open_db 2>/dev/null; then
|
||||||
|
err "failed to open the database after upgrade"
|
||||||
|
err "osmo-hlr-db-tool output:"
|
||||||
|
open_db
|
||||||
|
# exit because of "set -e"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "database upgrade successful"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
if [ "$IS_ACTIVE" = "1" ]; then
|
||||||
|
msg "starting osmo-hlr service"
|
||||||
|
systemctl start osmo-hlr
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_upgrade_required
|
||||||
|
stop_service
|
||||||
|
create_backup
|
||||||
|
upgrade
|
||||||
|
start_service
|
||||||
@@ -136,10 +136,13 @@ make %{?_smp_mflags} check || (find . -name testsuite.log -exec cat {} +)
|
|||||||
|
|
||||||
%pre
|
%pre
|
||||||
%service_add_pre %{name}.service
|
%service_add_pre %{name}.service
|
||||||
|
%endif
|
||||||
|
|
||||||
%post
|
%post
|
||||||
|
%if 0%{?suse_version}
|
||||||
%service_add_post %{name}.service
|
%service_add_post %{name}.service
|
||||||
%endif
|
%endif
|
||||||
|
/usr/share/osmocom/osmo-hlr-post-upgrade.sh
|
||||||
|
|
||||||
%post -n libosmo-gsup-client0 -p /sbin/ldconfig
|
%post -n libosmo-gsup-client0 -p /sbin/ldconfig
|
||||||
%postun -n libosmo-gsup-client0 -p /sbin/ldconfig
|
%postun -n libosmo-gsup-client0 -p /sbin/ldconfig
|
||||||
@@ -162,6 +165,8 @@ make %{?_smp_mflags} check || (find . -name testsuite.log -exec cat {} +)
|
|||||||
%dir %{_sysconfdir}/osmocom
|
%dir %{_sysconfdir}/osmocom
|
||||||
%config %{_sysconfdir}/osmocom/osmo-hlr.cfg
|
%config %{_sysconfdir}/osmocom/osmo-hlr.cfg
|
||||||
%{_unitdir}/osmo-hlr.service
|
%{_unitdir}/osmo-hlr.service
|
||||||
|
%dir %{_datadir}/osmocom
|
||||||
|
%{_datadir}/osmocom/osmo-hlr-post-upgrade.sh
|
||||||
|
|
||||||
%files -n libosmo-gsup-client0
|
%files -n libosmo-gsup-client0
|
||||||
%{_libdir}/libosmo-gsup-client.so.0*
|
%{_libdir}/libosmo-gsup-client.so.0*
|
||||||
|
|||||||
1
debian/osmo-hlr.install
vendored
1
debian/osmo-hlr.install
vendored
@@ -5,4 +5,5 @@
|
|||||||
/usr/share/doc/osmo-hlr/sql/hlr.sql
|
/usr/share/doc/osmo-hlr/sql/hlr.sql
|
||||||
/usr/share/doc/osmo-hlr/sql/hlr_data.sql
|
/usr/share/doc/osmo-hlr/sql/hlr_data.sql
|
||||||
/usr/share/doc/osmo-hlr/examples/osmo-hlr.cfg
|
/usr/share/doc/osmo-hlr/examples/osmo-hlr.cfg
|
||||||
|
/usr/share/osmocom/osmo-hlr-post-upgrade.sh
|
||||||
/var/lib/osmocom
|
/var/lib/osmocom
|
||||||
|
|||||||
5
debian/postinst
vendored
Executable file
5
debian/postinst
vendored
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
# Debian's postinst script is called on both installation and upgrade. Call the
|
||||||
|
# post-upgrade script in both cases, it won't do anything if there is nothing
|
||||||
|
# to do.
|
||||||
|
/usr/share/osmocom/osmo-hlr-post-upgrade.sh
|
||||||
@@ -12,6 +12,7 @@ enum stmt_idx {
|
|||||||
DB_STMT_SEL_ALL_ORDER_LAST_SEEN,
|
DB_STMT_SEL_ALL_ORDER_LAST_SEEN,
|
||||||
DB_STMT_SEL_FILTER_MSISDN,
|
DB_STMT_SEL_FILTER_MSISDN,
|
||||||
DB_STMT_SEL_FILTER_IMSI,
|
DB_STMT_SEL_FILTER_IMSI,
|
||||||
|
DB_STMT_SEL_FILTER_IMEI,
|
||||||
DB_STMT_SEL_FILTER_CS,
|
DB_STMT_SEL_FILTER_CS,
|
||||||
DB_STMT_SEL_FILTER_PS,
|
DB_STMT_SEL_FILTER_PS,
|
||||||
DB_STMT_SEL_BY_IMSI,
|
DB_STMT_SEL_BY_IMSI,
|
||||||
|
|||||||
1
src/db.c
1
src/db.c
@@ -56,6 +56,7 @@ static const char *stmt_sql[] = {
|
|||||||
"WHERE last_lu_seen IS NOT NULL ORDER BY last_lu_seen;",
|
"WHERE last_lu_seen IS NOT NULL ORDER BY last_lu_seen;",
|
||||||
[DB_STMT_SEL_FILTER_MSISDN] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE msisdn LIKE $search ORDER BY msisdn",
|
[DB_STMT_SEL_FILTER_MSISDN] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE msisdn LIKE $search ORDER BY msisdn",
|
||||||
[DB_STMT_SEL_FILTER_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi LIKE $search ORDER BY imsi",
|
[DB_STMT_SEL_FILTER_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi LIKE $search ORDER BY imsi",
|
||||||
|
[DB_STMT_SEL_FILTER_IMEI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imei LIKE $search ORDER BY imei",
|
||||||
[DB_STMT_SEL_FILTER_CS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_cs = $search ORDER BY last_lu_seen",
|
[DB_STMT_SEL_FILTER_CS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_cs = $search ORDER BY last_lu_seen",
|
||||||
[DB_STMT_SEL_FILTER_PS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_ps = $search ORDER BY last_lu_seen",
|
[DB_STMT_SEL_FILTER_PS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_ps = $search ORDER BY last_lu_seen",
|
||||||
[DB_STMT_SEL_BY_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi = ?",
|
[DB_STMT_SEL_BY_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi = ?",
|
||||||
|
|||||||
@@ -648,6 +648,8 @@ int db_subscrs_get(struct db_context *dbc, const char *filter_type, const char *
|
|||||||
|
|
||||||
if (!filter_type) {
|
if (!filter_type) {
|
||||||
stmt = dbc->stmt[DB_STMT_SEL_ALL];
|
stmt = dbc->stmt[DB_STMT_SEL_ALL];
|
||||||
|
} else if (strcmp(filter_type, "imei") == 0) {
|
||||||
|
stmt = dbc->stmt[DB_STMT_SEL_FILTER_IMEI];
|
||||||
} else if (strcmp(filter_type, "imsi") == 0) {
|
} else if (strcmp(filter_type, "imsi") == 0) {
|
||||||
stmt = dbc->stmt[DB_STMT_SEL_FILTER_IMSI];
|
stmt = dbc->stmt[DB_STMT_SEL_FILTER_IMSI];
|
||||||
} else if (strcmp(filter_type, "msisdn") == 0) {
|
} else if (strcmp(filter_type, "msisdn") == 0) {
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ int config_write_mslookup(struct vty *vty)
|
|||||||
|
|
||||||
msc = mslookup_server_msc_get(&mslookup_server_msc_wildcard, false);
|
msc = mslookup_server_msc_get(&mslookup_server_msc_wildcard, false);
|
||||||
if (msc)
|
if (msc)
|
||||||
config_write_msc_services(vty, " ", msc);
|
config_write_msc_services(vty, " ", msc);
|
||||||
|
|
||||||
llist_for_each_entry(msc, &g_hlr->mslookup.server.local_site_services, entry) {
|
llist_for_each_entry(msc, &g_hlr->mslookup.server.local_site_services, entry) {
|
||||||
if (!osmo_ipa_name_cmp(&mslookup_server_msc_wildcard, &msc->name))
|
if (!osmo_ipa_name_cmp(&mslookup_server_msc_wildcard, &msc->name))
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ static int config_write_hlr_gsup(struct vty *vty)
|
|||||||
vty_out(vty, " gsup%s", VTY_NEWLINE);
|
vty_out(vty, " gsup%s", VTY_NEWLINE);
|
||||||
if (g_hlr->gsup_bind_addr)
|
if (g_hlr->gsup_bind_addr)
|
||||||
vty_out(vty, " bind ip %s%s", g_hlr->gsup_bind_addr, VTY_NEWLINE);
|
vty_out(vty, " bind ip %s%s", g_hlr->gsup_bind_addr, VTY_NEWLINE);
|
||||||
|
if (g_hlr->gsup_unit_name.serno)
|
||||||
|
vty_out(vty, " ipa-name %s%s", g_hlr->gsup_unit_name.serno, VTY_NEWLINE);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ static int get_subscrs(struct vty *vty, const char *filter_type, const char *fil
|
|||||||
#define SUBSCRS_SHOW_HELP "Show all subscribers (with filter possibility)\n"
|
#define SUBSCRS_SHOW_HELP "Show all subscribers (with filter possibility)\n"
|
||||||
|
|
||||||
#define SUBSCR_ID "(imsi|msisdn|id|imei) IDENT"
|
#define SUBSCR_ID "(imsi|msisdn|id|imei) IDENT"
|
||||||
#define SUBSCR_FILTER "(imsi|msisdn) FILTER"
|
#define SUBSCR_FILTER "(imei|imsi|msisdn) FILTER"
|
||||||
|
|
||||||
#define SUBSCR_ID_HELP \
|
#define SUBSCR_ID_HELP \
|
||||||
"Identify subscriber by IMSI\n" \
|
"Identify subscriber by IMSI\n" \
|
||||||
@@ -307,7 +307,8 @@ DEFUN(show_subscriber_filtered,
|
|||||||
show_subscriber_filtered_cmd,
|
show_subscriber_filtered_cmd,
|
||||||
"show subscribers " SUBSCR_FILTER,
|
"show subscribers " SUBSCR_FILTER,
|
||||||
SHOW_STR SUBSCRS_SHOW_HELP
|
SHOW_STR SUBSCRS_SHOW_HELP
|
||||||
"Filter Subscribers by IMSI\n" "Filter Subscribers by MSISDN\n" "String to match in msisdn or imsi\n")
|
"Filter Subscribers by IMEI\n" "Filter Subscribers by IMSI\n" "Filter Subscribers by MSISDN\n"
|
||||||
|
"String to match in imei, imsi or msisdn\n")
|
||||||
{
|
{
|
||||||
const char *filter_type = argv[0];
|
const char *filter_type = argv[0];
|
||||||
const char *filter = argv[1];
|
const char *filter = argv[1];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ OsmoHLR> list
|
|||||||
...
|
...
|
||||||
show gsup-connections
|
show gsup-connections
|
||||||
show subscribers all
|
show subscribers all
|
||||||
show subscribers (imsi|msisdn) FILTER
|
show subscribers (imei|imsi|msisdn) FILTER
|
||||||
show subscribers (cs|ps) (on|off)
|
show subscribers (cs|ps) (on|off)
|
||||||
show subscribers last-seen
|
show subscribers last-seen
|
||||||
subscriber (imsi|msisdn|id|imei) IDENT show
|
subscriber (imsi|msisdn|id|imei) IDENT show
|
||||||
@@ -107,6 +107,7 @@ hlr
|
|||||||
database hlr_vty_test.db
|
database hlr_vty_test.db
|
||||||
gsup
|
gsup
|
||||||
bind ip 127.0.0.1
|
bind ip 127.0.0.1
|
||||||
|
ipa-name unnamed-HLR
|
||||||
ussd route prefix *#100# internal own-msisdn
|
ussd route prefix *#100# internal own-msisdn
|
||||||
ussd route prefix *#101# internal own-imsi
|
ussd route prefix *#101# internal own-imsi
|
||||||
end
|
end
|
||||||
@@ -345,9 +346,9 @@ OsmoHLR(config-mslookup-server-msc)# show running-config
|
|||||||
mslookup
|
mslookup
|
||||||
server
|
server
|
||||||
mdns bind 239.192.23.42 4266
|
mdns bind 239.192.23.42 4266
|
||||||
service foo.bar at 123.45.67.89 1011
|
service foo.bar at 123.45.67.89 1011
|
||||||
service baz.bar at 121.31.41.5 1617
|
service baz.bar at 121.31.41.5 1617
|
||||||
service baz.bar at a:b:c::d 1819
|
service baz.bar at a:b:c::d 1819
|
||||||
msc MSC-1
|
msc MSC-1
|
||||||
msc msc-901-70-23
|
msc msc-901-70-23
|
||||||
service foo.bar at 76.54.32.10 1234
|
service foo.bar at 76.54.32.10 1234
|
||||||
@@ -401,8 +402,8 @@ OsmoHLR(config-mslookup-client)# show running-config
|
|||||||
mslookup
|
mslookup
|
||||||
server
|
server
|
||||||
mdns bind 239.192.23.42 4266
|
mdns bind 239.192.23.42 4266
|
||||||
service foo.bar at 123.45.67.89 1011
|
service foo.bar at 123.45.67.89 1011
|
||||||
service baz.bar at 121.31.41.5 1617
|
service baz.bar at 121.31.41.5 1617
|
||||||
msc MSC-1
|
msc MSC-1
|
||||||
msc msc-901-70-23
|
msc msc-901-70-23
|
||||||
service foo.bar at 76.54.32.10 1234
|
service foo.bar at 76.54.32.10 1234
|
||||||
@@ -433,9 +434,9 @@ OsmoHLR(config-mslookup-server)# show running-config
|
|||||||
mslookup
|
mslookup
|
||||||
server
|
server
|
||||||
mdns bind 239.192.23.42 4266
|
mdns bind 239.192.23.42 4266
|
||||||
service foo.bar at 123.45.67.89 1011
|
service foo.bar at 123.45.67.89 1011
|
||||||
service baz.bar at 121.31.41.5 1617
|
service baz.bar at 121.31.41.5 1617
|
||||||
service gsup.hlr at 23.42.17.11 4223
|
service gsup.hlr at 23.42.17.11 4223
|
||||||
msc MSC-1
|
msc MSC-1
|
||||||
msc msc-901-70-23
|
msc msc-901-70-23
|
||||||
service foo.bar at 76.54.32.10 1234
|
service foo.bar at 76.54.32.10 1234
|
||||||
|
|||||||
Reference in New Issue
Block a user