lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

April 2025

  • 1 participants
  • 1186 discussions
[M] Change in osmo-ttcn3-hacks[master]: ns: initial testenv config
by osmith 10 Apr '25

10 Apr '25
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39992?usp=email ) Change subject: ns: initial testenv config ...................................................................... ns: initial testenv config Change-Id: I7b0d81db49dae0a3bb3d4c3b36fd3f8b4b590760 --- A _testenv/data/scripts/build_osmo_ns_dummy.sh M _testenv/testenv/podman_install.py A ns/run_osmo_ns_dummy.sh A ns/testenv_sgsn_sns.cfg A ns/testenv_sns.cfg A ns/testenv_udp.cfg 6 files changed, 75 insertions(+), 0 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/_testenv/data/scripts/build_osmo_ns_dummy.sh b/_testenv/data/scripts/build_osmo_ns_dummy.sh new file mode 100755 index 0000000..12a6a43 --- /dev/null +++ b/_testenv/data/scripts/build_osmo_ns_dummy.sh @@ -0,0 +1,14 @@ +#!/bin/sh -ex +# Script used by testenv/podman_install:from_source_osmo_ns_dummy() to build +# osmo-ns-dummy in libosmocore from git when running with "--binary-repo". This +# is needed, because osmo-ns-dummy is not packaged. +MAKE="make -j$1" + +$MAKE -C include/osmocom/core all +$MAKE -C src/core libosmocore.la +$MAKE -C src/vty libosmovty.la +$MAKE -C src/isdn libosmoisdn.la +$MAKE -C src/gsm libosmogsm.la +$MAKE -C src/gb libosmogb.la +$MAKE -C src/ctrl libosmoctrl.la +$MAKE -C utils osmo-ns-dummy diff --git a/_testenv/testenv/podman_install.py b/_testenv/testenv/podman_install.py index 27b08b4..66777a6 100644 --- a/_testenv/testenv/podman_install.py +++ b/_testenv/testenv/podman_install.py @@ -166,10 +166,33 @@ testenv.cmd.run(["ln", "-s", sccp_demo_user_path, "/usr/local/bin/sccp_demo_user"]) +def from_source_osmo_ns_dummy(): + libosmocore_dir = os.path.join(git_dir, "libosmocore") + osmo_ns_dummy_path = os.path.join(libosmocore_dir, "utils/osmo-ns-dummy") + + if not os.path.exists(osmo_ns_dummy_path): + clone_project("libosmocore") + logging.info("Building osmo-ns-dummy") + testenv.cmd.run(["autoreconf", "-fi"], cwd=libosmocore_dir) + + configure_cmd = ["./configure"] + if testenv.args.binary_repo.endswith(":asan"): + configure_cmd += ["--enable-sanitize"] + testenv.cmd.run(configure_cmd, cwd=libosmocore_dir) + + testenv.cmd.run( + [os.path.join(testenv.data_dir, "scripts/build_osmo_ns_dummy.sh"), str(jobs)], cwd=libosmocore_dir + ) + + testenv.cmd.run(["ln", "-s", osmo_ns_dummy_path, "/usr/local/bin/osmo-ns-dummy"]) + + def from_source(cfg, cfg_name, section): program = cfg[section]["program"].split(" ", 1)[0] if program == "run_sccp_demo_user.sh": return from_source_sccp_demo_user() + if program == "run_osmo_ns_dummy.sh": + return from_source_osmo_ns_dummy() logging.error(f"Can't install {section}! Fix this by either:") logging.error(f"* Adding package= to [{section}] in {cfg_name}") diff --git a/ns/run_osmo_ns_dummy.sh b/ns/run_osmo_ns_dummy.sh new file mode 100755 index 0000000..5a8cc05 --- /dev/null +++ b/ns/run_osmo_ns_dummy.sh @@ -0,0 +1,11 @@ +#!/bin/sh -ex + +if [ -n "$OSMO_DEV_MAKE_DIR" ]; then + # Using osmo-dev: either with or without --podman + exec "$OSMO_DEV_MAKE_DIR"/libosmocore/utils/osmo-ns-dummy "$@" +fi + +# Using binary packages: as osmo-ns-dummy is not packaged it gets built by +# testenv/podman_install.py:from_source_osmo_ns_dummy() and symlinked to +# /usr/local/bin. +exec osmo-ns-dummy "$@" diff --git a/ns/testenv_sgsn_sns.cfg b/ns/testenv_sgsn_sns.cfg new file mode 100644 index 0000000..8037d78 --- /dev/null +++ b/ns/testenv_sgsn_sns.cfg @@ -0,0 +1,9 @@ +[testsuite] +program=NS_Tests +config=NS_Tests.sgsn.sns.cfg + +[osmo-ns-dummy] +program=run_osmo_ns_dummy.sh -p 4240 -c osmo-ns.sgsn.sns.cfg +make=libosmocore +copy=osmo-ns.sgsn.sns.cfg +vty_port=4240 diff --git a/ns/testenv_sns.cfg b/ns/testenv_sns.cfg new file mode 100644 index 0000000..c19dfba --- /dev/null +++ b/ns/testenv_sns.cfg @@ -0,0 +1,9 @@ +[testsuite] +program=NS_Tests +config=NS_Tests.sns.cfg + +[osmo-ns-dummy] +program=run_osmo_ns_dummy.sh -p 4240 -c osmo-ns.sns.cfg +make=libosmocore +copy=osmo-ns.sns.cfg +vty_port=4240 diff --git a/ns/testenv_udp.cfg b/ns/testenv_udp.cfg new file mode 100644 index 0000000..7d6e82b --- /dev/null +++ b/ns/testenv_udp.cfg @@ -0,0 +1,9 @@ +[testsuite] +program=NS_Tests +config=NS_Tests.udp.cfg + +[osmo-ns-dummy] +program=run_osmo_ns_dummy.sh -p 4240 -c osmo-ns.udp.cfg +make=libosmocore +copy=osmo-ns.udp.cfg +vty_port=4240 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39992?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I7b0d81db49dae0a3bb3d4c3b36fd3f8b4b590760 Gerrit-Change-Number: 39992 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: testenv: make clone project function generic
by osmith 10 Apr '25

10 Apr '25
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39990?usp=email ) Change subject: testenv: make clone project function generic ...................................................................... testenv: make clone project function generic Prepare to use the same code for cloning libosmocore in order to build osmo-ns-dummy in a follow-up patch, which isn't in the binary packages either. Change-Id: Id19ed229545b22751c810b647e9be24f955f348d --- M _testenv/testenv/podman_install.py 1 file changed, 9 insertions(+), 12 deletions(-) Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/_testenv/testenv/podman_install.py b/_testenv/testenv/podman_install.py index a27abd8..1eaf7e8 100644 --- a/_testenv/testenv/podman_install.py +++ b/_testenv/testenv/podman_install.py @@ -11,13 +11,11 @@ import testenv.podman git_dir = None -sccp_dir = None jobs = None def init(): global git_dir - global sccp_dir global jobs # Make the git dir we clone into specific to the repository we build @@ -26,7 +24,6 @@ # errors. git_dir = os.path.join(testenv.args.cache, "git", f"build_against_{testenv.args.binary_repo}".replace(":", "_")) - sccp_dir = os.path.join(git_dir, "libosmo-sigtran") jobs = multiprocessing.cpu_count() + 1 os.makedirs(git_dir, exist_ok=True) @@ -97,19 +94,18 @@ testenv.cmd.run(["apt-get", "-q", "install", "-y", "--no-install-recommends"] + pkgs) -def clone_libosmo_sigtran(): - if os.path.exists(sccp_dir): - logging.debug("libosmo-sigtran: already cloned") +def clone_project(project): + if os.path.exists(os.path.join(git_dir, project)): + logging.debug(f"{project}: already cloned") return branch = "master" + url = f"https://gerrit.osmocom.org/{project}" if testenv.args.binary_repo.endswith(":latest"): - ls_remote = testenv.cmd.run( - ["git", "ls-remote", "--tags", "https://gerrit.osmocom.org/libosmo-sigtran"], capture_output=True, text=True - ) + ls_remote = testenv.cmd.run(["git", "ls-remote", "--tags", url], capture_output=True, text=True) branch = ls_remote.stdout.split("\n")[-2].split("refs/tags/")[1].split("^")[0] - logging.info(f"libosmo-sigtran: cloning {branch}") + logging.info(f"{project}: cloning {branch}") testenv.cmd.run( [ "git", @@ -120,12 +116,13 @@ "1", "--branch", branch, - "https://gerrit.osmocom.org/libosmo-sigtran", + url, ] ) def from_source_sccp_demo_user(): + sccp_dir = os.path.join(git_dir, "libosmo-sigtran") sccp_demo_user_path = os.path.join(sccp_dir, "examples/sccp_demo_user") # Install libraries even if not building sccp_demo_user, because it gets @@ -138,7 +135,7 @@ ) if not os.path.exists(sccp_demo_user_path): - clone_libosmo_sigtran() + clone_project("libosmo-sigtran") logging.info("Building sccp_demo_user") testenv.cmd.run(["autoreconf", "-fi"], cwd=sccp_dir) -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39990?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Id19ed229545b22751c810b647e9be24f955f348d Gerrit-Change-Number: 39990 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-pcap[master]: client: Process up to 10 recorded pkts per poll iteration
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email ) Change subject: client: Process up to 10 recorded pkts per poll iteration ...................................................................... client: Process up to 10 recorded pkts per poll iteration This should decrease CPU use of lipcap capturing under high capturing load, which is welcome now that we support osmo_io with io-uring backend on the Tx side towards osmo-pcap-server. The processing number is kept low in order to avoid starving the event loop, as well as avoid filling up the msgb queue of the Tx side towards osmo-pcap-server. Related: SYS#7290 Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68 --- M src/osmo_client_core.c 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index e58439b..daa5fd6 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -175,7 +175,9 @@ struct osmo_pcap_handle *ph = fd->data; int rc; - rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph); + /* Read up to 10 packets at once, to avoid starving the event loop and + * filling up transmit queue towards peer. */ + rc = pcap_dispatch(ph->handle, 10, pcap_read_one_cb, (u_char *)ph); if (rc < 0) { rate_ctr_inc2(ph->ctrg, PH_CTR_PERR); rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68 Gerrit-Change-Number: 39949 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: client: use pcap_dispatch to avoid extra pkt buffer copy
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email ) Change subject: client: use pcap_dispatch to avoid extra pkt buffer copy ...................................................................... client: use pcap_dispatch to avoid extra pkt buffer copy pcap_next() allows use of returned buffer until next time the same API is called. In order to do so, it internally calls pcap_dispatch() with an internal handler (in the case of linux pcapint_oneshot_linux()). That handler basically memcpy()s the pkt buffer obtained in the pcap_dispatch callback into a temporary static buffer which is then returned. We don't need any of that here, and by using pcap_dispatch() directly (as recommended in pcapint_oneshot_linux() function documentation) we can skip an extra memcpy() of each packet buffer captured. Furthermore, it will allow us processing multiple packets from the captured queue (RA_SOCKET+mmap implementation in linux) in one poll iteration if several packets have been captured. This will be done in a follow-up patch. pcap handle is marked non-blocking to allow polling from it without ending up blocked. Applying filter is moved beforehand, as seen in libpcap capturetest example. Related: SYS#7290 Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838 --- M src/osmo_client_core.c 1 file changed, 28 insertions(+), 14 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 62b2c3c..e58439b 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -152,27 +152,36 @@ return check_gprs(payload_data, payload_len); } +static void pcap_read_one_cb(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data) +{ + struct osmo_pcap_handle *ph = (struct osmo_pcap_handle *)user; + struct osmo_pcap_client *client = ph->client; + struct osmo_pcap_client_conn *conn; + + /* NOTE: hdr & data are only available during the call of this callback, + * and should be copied somewhere else if need be accessed later. + * In here we are fine since we generate a msgb and copy over the + * content on each loop iteration below. */ + + if (!can_forward_packet(client, ph, hdr, data)) + return; + + llist_for_each_entry(conn, &client->conns, entry) + osmo_client_conn_send_data(conn, ph, hdr, data); +} static int pcap_read_cb(struct osmo_fd *fd, unsigned int what) { struct osmo_pcap_handle *ph = fd->data; - struct osmo_pcap_client *client = ph->client; - struct osmo_pcap_client_conn *conn; - struct pcap_pkthdr hdr; - const u_char *data; + int rc; - data = pcap_next(ph->handle, &hdr); - if (!data) { + rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph); + if (rc < 0) { rate_ctr_inc2(ph->ctrg, PH_CTR_PERR); - rate_ctr_inc2(client->ctrg, CLIENT_CTR_PERR); + rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR); return -1; } - if (!can_forward_packet(client, ph, &hdr, data)) - return 0; - - llist_for_each_entry(conn, &client->conns, entry) - osmo_client_conn_send_data(conn, ph, &hdr, data); return 0; } @@ -448,6 +457,13 @@ return -2; } + if (client->filter_string) + osmo_pcap_handle_install_filter(ph); + + errbuf[0] = '\0'; + if (pcap_setnonblock(ph->handle, 1, errbuf) != 0) + LOGPH(ph, LOGL_ERROR, "Failed pcap_setnonblock(): %s\n", errbuf); + fd = pcap_fileno(ph->handle); if (fd == -1) { LOGPH(ph, LOGL_ERROR, "No file descriptor provided.\n"); @@ -463,7 +479,5 @@ osmo_timer_setup(&ph->pcap_stat_timer, pcap_check_stats_cb, ph); pcap_check_stats_cb(ph); - if (client->filter_string) - osmo_pcap_handle_install_filter(ph); return 0; } -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838 Gerrit-Change-Number: 39948 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-pcap[master]: client: use pcap_dispatch to avoid extra pkt buffer copy
by pespin 10 Apr '25

10 Apr '25
Attention is currently required from: daniel, fixeria. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email ) Change subject: client: use pcap_dispatch to avoid extra pkt buffer copy ...................................................................... Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-pcap Gerrit-Branch: master Gerrit-Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838 Gerrit-Change-Number: 39948 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Wed, 09 Apr 2025 23:09:15 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in osmo-hnbgw[master]: Add function helper hnbgw_decode_ranap_ran_co()
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email ) Change subject: Add function helper hnbgw_decode_ranap_ran_co() ...................................................................... Add function helper hnbgw_decode_ranap_ran_co() Similar to already existing counterpart hnbgw_decode_ranap_cn_co(). This helps simplifying logic into smaller chunks, and will make both UL and DL look more similar. Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1 --- M src/osmo-hnbgw/context_map_sccp.c 1 file changed, 22 insertions(+), 5 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index c933e8d..fc82426 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -193,10 +193,29 @@ return 0; } +/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. + * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls + * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ +static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg) +{ + int rc; + ranap_message *message; + + if (!msg_has_l2_data(ranap_msg)) + return NULL; + message = talloc_zero(OTC_SELECT, ranap_message); + rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); + if (rc != 0) { + talloc_free(message); + return NULL; + } + talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); + return message; +} + static int handle_rx_sccp(struct osmo_fsm_inst *fi, struct msgb *ranap_msg) { struct hnbgw_context_map *map = fi->priv; - int rc; /* If the FSM instance has already terminated, don't dispatch anything. */ if (fi->proc.terminating) @@ -208,10 +227,8 @@ /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane * information, for RTP mapping via MGW, or GTP mapping via UPF. */ - ranap_message *message; - message = talloc_zero(OTC_SELECT, ranap_message); - rc = ranap_ran_rx_co_decode(message, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); - if (rc == 0) { + ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg); + if (message) { talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); LOGPFSML(fi, LOGL_DEBUG, "rx from SCCP: RANAP %s\n", -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1 Gerrit-Change-Number: 39984 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-hnbgw[master]: Rename function s/hnbgw_decode_ranap_co/hnbgw_decode_ranap_cn_co/g
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39983?usp=email ) Change subject: Rename function s/hnbgw_decode_ranap_co/hnbgw_decode_ranap_cn_co/g ...................................................................... Rename function s/hnbgw_decode_ranap_co/hnbgw_decode_ranap_cn_co/g This function is only used to decode UL RANAP messages. Mark it as "CN" like most other related APIs. Change-Id: Ia4e5a21a9724ebf759b62c13759a776189b09e91 --- M include/osmocom/hnbgw/hnbgw_rua.h M src/osmo-hnbgw/context_map_rua.c M src/osmo-hnbgw/hnbgw_l3.c 3 files changed, 5 insertions(+), 5 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/hnbgw/hnbgw_rua.h b/include/osmocom/hnbgw/hnbgw_rua.h index b7e7ee6..55e90c0 100644 --- a/include/osmocom/hnbgw/hnbgw_rua.h +++ b/include/osmocom/hnbgw/hnbgw_rua.h @@ -13,4 +13,4 @@ int rua_tx_disc(struct hnb_context *hnb, int is_ps, uint32_t context_id, const RUA_Cause_t *cause, const uint8_t *data, unsigned int len); -ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg); +ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg); diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c index 2d9fd8d..f73b8e2 100644 --- a/src/osmo-hnbgw/context_map_rua.c +++ b/src/osmo-hnbgw/context_map_rua.c @@ -134,10 +134,10 @@ return 0; } -/* Decode RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. +/* Decode UL RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ -ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg) +ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg) { int rc; ranap_message *message; @@ -166,7 +166,7 @@ if (!msg_has_l2_data(ranap_msg)) return 0; - ranap_message *message = hnbgw_decode_ranap_co(ranap_msg); + ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg); if (message) { LOGPFSML(fi, LOGL_DEBUG, "rx from RUA: RANAP %s\n", get_value_string(ranap_procedure_code_vals, message->procedureCode)); diff --git a/src/osmo-hnbgw/hnbgw_l3.c b/src/osmo-hnbgw/hnbgw_l3.c index a6c44f7..65d9eff 100644 --- a/src/osmo-hnbgw/hnbgw_l3.c +++ b/src/osmo-hnbgw/hnbgw_l3.c @@ -314,7 +314,7 @@ * This is relevant for CN pooling, to decide which CN link to map the RUA context to. */ int hnbgw_peek_l3_ul(struct hnbgw_context_map *map, struct msgb *ranap_msg) { - ranap_message *message = hnbgw_decode_ranap_co(ranap_msg); + ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg); if (!message) { LOGP(DCN, LOGL_ERROR, "Failed to decode RANAP PDU\n"); return -EINVAL; -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39983?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ia4e5a21a9724ebf759b62c13759a776189b09e91 Gerrit-Change-Number: 39983 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-hnbgw[master]: Move paging logic to its own file
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39986?usp=email ) Change subject: Move paging logic to its own file ...................................................................... Move paging logic to its own file Paging logic contains quite a lot of logic which is really specific to paging topic and which can be put together and encapsulated easily. Furthermore, this logic will mostly grow in the future since right now we only offer minimal paging features by broadcasting to all HNBs. Finally, this also simplifies hnbgw_cn.c Change-Id: I402fdcdc261626798904e7ee2eb5db80d30c4c34 --- M include/osmocom/hnbgw/hnbgw_cn.h M src/osmo-hnbgw/Makefile.am A src/osmo-hnbgw/cnlink_paging.c M src/osmo-hnbgw/hnbgw_cn.c 4 files changed, 245 insertions(+), 187 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/include/osmocom/hnbgw/hnbgw_cn.h b/include/osmocom/hnbgw/hnbgw_cn.h index 9b26e6e..0c99b26 100644 --- a/include/osmocom/hnbgw/hnbgw_cn.h +++ b/include/osmocom/hnbgw/hnbgw_cn.h @@ -1,6 +1,10 @@ #pragma once #include <osmocom/core/rate_ctr.h> +#include <osmocom/gsm/gsm48.h> + +#include <osmocom/ranap/ranap_ies_defs.h> + #include <osmocom/hnbgw/hnbgw.h> struct hnbgw_cnlink *cnlink_alloc(struct hnbgw_cnpool *cnpool, int nr); @@ -21,6 +25,9 @@ void cnlink_resend_reset(struct hnbgw_cnlink *cnlink); void cnlink_set_disconnected(struct hnbgw_cnlink *cnlink); +const char *cnlink_paging_add_ranap(struct hnbgw_cnlink *cnlink, RANAP_InitiatingMessage_t *imsg); +struct hnbgw_cnlink *cnlink_find_by_paging_mi(struct hnbgw_cnpool *cnpool, const struct osmo_mobile_identity *mi); + enum hnbgw_cnpool_ctr { /* TODO: basic counters completely missing * ... diff --git a/src/osmo-hnbgw/Makefile.am b/src/osmo-hnbgw/Makefile.am index dc6a9a4..e108906 100644 --- a/src/osmo-hnbgw/Makefile.am +++ b/src/osmo-hnbgw/Makefile.am @@ -43,6 +43,7 @@ context_map_sccp.c \ hnbgw_cn.c \ cnlink.c \ + cnlink_paging.c \ ranap_rab_ass.c \ mgw_fsm.c \ kpi_dtap.c \ diff --git a/src/osmo-hnbgw/cnlink_paging.c b/src/osmo-hnbgw/cnlink_paging.c new file mode 100644 index 0000000..e5ef2c2 --- /dev/null +++ b/src/osmo-hnbgw/cnlink_paging.c @@ -0,0 +1,237 @@ +/* RANAP Paging of HNB-GW */ +/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org> + * (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include <errno.h> +#include <sys/types.h> + +#include <asn1c/asn1helpers.h> + +#include <osmocom/core/logging.h> +#include <osmocom/core/timer.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/gsm/gsm48.h> + +#include <osmocom/ranap/ranap_ies_defs.h> +#include <osmocom/ranap/iu_helpers.h> + +#include <osmocom/hnbgw/hnbgw.h> +#include <osmocom/hnbgw/hnbgw_cn.h> +#include <osmocom/hnbgw/context_map.h> +#include <osmocom/hnbgw/tdefs.h> + +/*************** + * This module manages the list of "struct cnlink_paging" items in (struct + * hnbgw_cnlink *)->paging. + * Every time a new RANAP Paging Cmd arrives from some cnlink, + * cnlink_paging_add_ranap() is called to potentially store the paging command + * for a while. + * When a paging response is received from HNB, cnlink_find_by_paging_mi() is + * called to obtain the cnlink it should be routed back to. + */ + +struct cnlink_paging { + struct llist_head entry; + + struct osmo_mobile_identity mi; + struct osmo_mobile_identity mi2; + time_t timestamp; +}; + +static int cnlink_paging_destructor(struct cnlink_paging *p) +{ + llist_del(&p->entry); + return 0; +} + + +/* Return current timestamp in *timestamp, and the oldest still valid timestamp according to T3113 timeout. */ +static const char *cnlink_paging_gettime(time_t *timestamp_p, time_t *timeout_p) +{ + struct timespec now; + time_t timestamp; + + /* get timestamp */ + if (osmo_clock_gettime(CLOCK_MONOTONIC, &now) != 0) + return "cannot get timestamp"; + timestamp = now.tv_sec; + + if (timestamp_p) + *timestamp_p = timestamp; + if (timeout_p) + *timeout_p = timestamp - osmo_tdef_get(hnbgw_T_defs, 3113, OSMO_TDEF_S, 15); + return NULL; +} + +static const char *cnlink_paging_add(struct hnbgw_cnlink *cnlink, const struct osmo_mobile_identity *mi, + const struct osmo_mobile_identity *mi2) +{ + struct cnlink_paging *p, *p2; + time_t timestamp; + time_t timeout; + const char *errmsg; + + errmsg = cnlink_paging_gettime(&timestamp, &timeout); + if (errmsg) + return errmsg; + + /* Prune all paging records that are older than the configured timeout. */ + llist_for_each_entry_safe(p, p2, &cnlink->paging, entry) { + if (p->timestamp >= timeout) + continue; + talloc_free(p); + } + + /* Add new entry */ + p = talloc_zero(cnlink, struct cnlink_paging); + *p = (struct cnlink_paging){ + .timestamp = timestamp, + .mi = *mi, + .mi2 = *mi2, + }; + llist_add_tail(&p->entry, &cnlink->paging); + talloc_set_destructor(p, cnlink_paging_destructor); + + LOG_CNLINK(cnlink, DCN, LOGL_INFO, "Rx Paging from CN for %s %s\n", + osmo_mobile_identity_to_str_c(OTC_SELECT, mi), + osmo_mobile_identity_to_str_c(OTC_SELECT, mi2)); + return NULL; +} + +static const char *omi_from_ranap_ue_id(struct osmo_mobile_identity *mi, const RANAP_PermanentNAS_UE_ID_t *ranap_mi) +{ + if (!ranap_mi) + return "null UE ID"; + + if (ranap_mi->present != RANAP_PermanentNAS_UE_ID_PR_iMSI) + return talloc_asprintf(OTC_SELECT, "unsupported UE ID type %u in RANAP Paging", ranap_mi->present); + + if (ranap_mi->choice.iMSI.size > sizeof(mi->imsi)) + return talloc_asprintf(OTC_SELECT, "invalid IMSI size %d > %zu", + ranap_mi->choice.iMSI.size, sizeof(mi->imsi)); + + *mi = (struct osmo_mobile_identity){ + .type = GSM_MI_TYPE_IMSI, + }; + ranap_bcd_decode(mi->imsi, sizeof(mi->imsi), ranap_mi->choice.iMSI.buf, ranap_mi->choice.iMSI.size); + LOGP(DCN, LOGL_DEBUG, "ranap MI %s = %s\n", osmo_hexdump(ranap_mi->choice.iMSI.buf, ranap_mi->choice.iMSI.size), + mi->imsi); + return NULL; +} + +static const char *omi_from_ranap_temp_ue_id(struct osmo_mobile_identity *mi, const RANAP_TemporaryUE_ID_t *ranap_tmsi) +{ + const OCTET_STRING_t *tmsi_str; + + if (!ranap_tmsi) + return "null UE ID"; + + switch (ranap_tmsi->present) { + case RANAP_TemporaryUE_ID_PR_tMSI: + tmsi_str = &ranap_tmsi->choice.tMSI; + break; + case RANAP_TemporaryUE_ID_PR_p_TMSI: + tmsi_str = &ranap_tmsi->choice.p_TMSI; + break; + default: + return talloc_asprintf(OTC_SELECT, "unsupported Temporary UE ID type %u in RANAP Paging", ranap_tmsi->present); + } + + *mi = (struct osmo_mobile_identity){ + .type = GSM_MI_TYPE_TMSI, + .tmsi = asn1str_to_u32(tmsi_str), + }; + LOGP(DCN, LOGL_DEBUG, "ranap temp UE ID = %s\n", osmo_mobile_identity_to_str_c(OTC_SELECT, mi)); + return NULL; +} + +const char *cnlink_paging_add_ranap(struct hnbgw_cnlink *cnlink, RANAP_InitiatingMessage_t *imsg) +{ + RANAP_PagingIEs_t ies; + struct osmo_mobile_identity mi = {}; + struct osmo_mobile_identity mi2 = {}; + RANAP_CN_DomainIndicator_t domain; + const char *errmsg; + + if (ranap_decode_pagingies(&ies, &imsg->value) < 0) + return "decoding RANAP IEs failed"; + + domain = ies.cN_DomainIndicator; + errmsg = omi_from_ranap_ue_id(&mi, &ies.permanentNAS_UE_ID); + + if (!errmsg && (ies.presenceMask & PAGINGIES_RANAP_TEMPORARYUE_ID_PRESENT)) + errmsg = omi_from_ranap_temp_ue_id(&mi2, &ies.temporaryUE_ID); + + ranap_free_pagingies(&ies); + LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "Decoded Paging: %s %s %s%s%s\n", + ranap_domain_name(domain), osmo_mobile_identity_to_str_c(OTC_SELECT, &mi), + mi2.type ? osmo_mobile_identity_to_str_c(OTC_SELECT, &mi2) : "-", + errmsg ? " -- MI error: " : "", + errmsg ? : ""); + + if (cnlink->pool->domain != domain) + return talloc_asprintf(OTC_SELECT, "message indicates domain %s, but this is %s on domain %s\n", + ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); + + if (errmsg) + return errmsg; + + return cnlink_paging_add(cnlink, &mi, &mi2); +} + +/* If this cnlink has a recent Paging for the given MI, return true and drop the Paging record. + * Else return false. */ +static bool cnlink_match_paging_mi(struct hnbgw_cnlink *cnlink, const struct osmo_mobile_identity *mi, time_t timeout) +{ + struct cnlink_paging *p, *p2; + llist_for_each_entry_safe(p, p2, &cnlink->paging, entry) { + if (p->timestamp < timeout) { + talloc_free(p); + continue; + } + if (osmo_mobile_identity_cmp(&p->mi, mi) + && osmo_mobile_identity_cmp(&p->mi2, mi)) + continue; + talloc_free(p); + return true; + } + return false; +} + +struct hnbgw_cnlink *cnlink_find_by_paging_mi(struct hnbgw_cnpool *cnpool, const struct osmo_mobile_identity *mi) +{ + struct hnbgw_cnlink *cnlink; + time_t timeout = 0; + const char *errmsg; + + errmsg = cnlink_paging_gettime(NULL, &timeout); + if (errmsg) + LOGP(DCN, LOGL_ERROR, "%s\n", errmsg); + + llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { + if (!cnlink_match_paging_mi(cnlink, mi, timeout)) + continue; + return cnlink; + } + return NULL; +} + diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index e7df788..743d9b4 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -27,7 +27,6 @@ #include <osmocom/core/msgb.h> #include <osmocom/core/utils.h> -#include <osmocom/core/timer.h> #include <osmocom/core/stats.h> #include <osmocom/gsm/gsm23236.h> @@ -40,7 +39,6 @@ #include <osmocom/hnbgw/hnbgw.h> #include <osmocom/hnbgw/hnbgw_rua.h> #include <osmocom/hnbgw/hnbgw_cn.h> -#include <osmocom/hnbgw/tdefs.h> #include <osmocom/ranap/ranap_ies_defs.h> #include <osmocom/ranap/ranap_msg_factory.h> #include <osmocom/ranap/iu_helpers.h> @@ -103,191 +101,6 @@ return 0; } -struct cnlink_paging { - struct llist_head entry; - - struct osmo_mobile_identity mi; - struct osmo_mobile_identity mi2; - time_t timestamp; -}; - -static int cnlink_paging_destructor(struct cnlink_paging *p) -{ - llist_del(&p->entry); - return 0; -} - -/* Return current timestamp in *timestamp, and the oldest still valid timestamp according to T3113 timeout. */ -static const char *cnlink_paging_gettime(time_t *timestamp_p, time_t *timeout_p) -{ - struct timespec now; - time_t timestamp; - - /* get timestamp */ - if (osmo_clock_gettime(CLOCK_MONOTONIC, &now) != 0) - return "cannot get timestamp"; - timestamp = now.tv_sec; - - if (timestamp_p) - *timestamp_p = timestamp; - if (timeout_p) - *timeout_p = timestamp - osmo_tdef_get(hnbgw_T_defs, 3113, OSMO_TDEF_S, 15); - return NULL; -} - -static const char *cnlink_paging_add(struct hnbgw_cnlink *cnlink, const struct osmo_mobile_identity *mi, - const struct osmo_mobile_identity *mi2) -{ - struct cnlink_paging *p, *p2; - time_t timestamp; - time_t timeout; - const char *errmsg; - - errmsg = cnlink_paging_gettime(&timestamp, &timeout); - if (errmsg) - return errmsg; - - /* Prune all paging records that are older than the configured timeout. */ - llist_for_each_entry_safe(p, p2, &cnlink->paging, entry) { - if (p->timestamp >= timeout) - continue; - talloc_free(p); - } - - /* Add new entry */ - p = talloc_zero(cnlink, struct cnlink_paging); - *p = (struct cnlink_paging){ - .timestamp = timestamp, - .mi = *mi, - .mi2 = *mi2, - }; - llist_add_tail(&p->entry, &cnlink->paging); - talloc_set_destructor(p, cnlink_paging_destructor); - - LOG_CNLINK(cnlink, DCN, LOGL_INFO, "Rx Paging from CN for %s %s\n", - osmo_mobile_identity_to_str_c(OTC_SELECT, mi), - osmo_mobile_identity_to_str_c(OTC_SELECT, mi2)); - return NULL; -} - -static const char *omi_from_ranap_ue_id(struct osmo_mobile_identity *mi, const RANAP_PermanentNAS_UE_ID_t *ranap_mi) -{ - if (!ranap_mi) - return "null UE ID"; - - if (ranap_mi->present != RANAP_PermanentNAS_UE_ID_PR_iMSI) - return talloc_asprintf(OTC_SELECT, "unsupported UE ID type %u in RANAP Paging", ranap_mi->present); - - if (ranap_mi->choice.iMSI.size > sizeof(mi->imsi)) - return talloc_asprintf(OTC_SELECT, "invalid IMSI size %d > %zu", - ranap_mi->choice.iMSI.size, sizeof(mi->imsi)); - - *mi = (struct osmo_mobile_identity){ - .type = GSM_MI_TYPE_IMSI, - }; - ranap_bcd_decode(mi->imsi, sizeof(mi->imsi), ranap_mi->choice.iMSI.buf, ranap_mi->choice.iMSI.size); - LOGP(DCN, LOGL_DEBUG, "ranap MI %s = %s\n", osmo_hexdump(ranap_mi->choice.iMSI.buf, ranap_mi->choice.iMSI.size), - mi->imsi); - return NULL; -} - -static const char *omi_from_ranap_temp_ue_id(struct osmo_mobile_identity *mi, const RANAP_TemporaryUE_ID_t *ranap_tmsi) -{ - const OCTET_STRING_t *tmsi_str; - - if (!ranap_tmsi) - return "null UE ID"; - - switch (ranap_tmsi->present) { - case RANAP_TemporaryUE_ID_PR_tMSI: - tmsi_str = &ranap_tmsi->choice.tMSI; - break; - case RANAP_TemporaryUE_ID_PR_p_TMSI: - tmsi_str = &ranap_tmsi->choice.p_TMSI; - break; - default: - return talloc_asprintf(OTC_SELECT, "unsupported Temporary UE ID type %u in RANAP Paging", ranap_tmsi->present); - } - - *mi = (struct osmo_mobile_identity){ - .type = GSM_MI_TYPE_TMSI, - .tmsi = asn1str_to_u32(tmsi_str), - }; - LOGP(DCN, LOGL_DEBUG, "ranap temp UE ID = %s\n", osmo_mobile_identity_to_str_c(OTC_SELECT, mi)); - return NULL; -} - -static const char *cnlink_paging_add_ranap(struct hnbgw_cnlink *cnlink, RANAP_InitiatingMessage_t *imsg) -{ - RANAP_PagingIEs_t ies; - struct osmo_mobile_identity mi = {}; - struct osmo_mobile_identity mi2 = {}; - RANAP_CN_DomainIndicator_t domain; - const char *errmsg; - - if (ranap_decode_pagingies(&ies, &imsg->value) < 0) - return "decoding RANAP IEs failed"; - - domain = ies.cN_DomainIndicator; - errmsg = omi_from_ranap_ue_id(&mi, &ies.permanentNAS_UE_ID); - - if (!errmsg && (ies.presenceMask & PAGINGIES_RANAP_TEMPORARYUE_ID_PRESENT)) - errmsg = omi_from_ranap_temp_ue_id(&mi2, &ies.temporaryUE_ID); - - ranap_free_pagingies(&ies); - LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "Decoded Paging: %s %s %s%s%s\n", - ranap_domain_name(domain), osmo_mobile_identity_to_str_c(OTC_SELECT, &mi), - mi2.type ? osmo_mobile_identity_to_str_c(OTC_SELECT, &mi2) : "-", - errmsg ? " -- MI error: " : "", - errmsg ? : ""); - - if (cnlink->pool->domain != domain) - return talloc_asprintf(OTC_SELECT, "message indicates domain %s, but this is %s on domain %s\n", - ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); - - if (errmsg) - return errmsg; - - return cnlink_paging_add(cnlink, &mi, &mi2); -} - -/* If this cnlink has a recent Paging for the given MI, return true and drop the Paging record. - * Else return false. */ -static bool cnlink_match_paging_mi(struct hnbgw_cnlink *cnlink, const struct osmo_mobile_identity *mi, time_t timeout) -{ - struct cnlink_paging *p, *p2; - llist_for_each_entry_safe(p, p2, &cnlink->paging, entry) { - if (p->timestamp < timeout) { - talloc_free(p); - continue; - } - if (osmo_mobile_identity_cmp(&p->mi, mi) - && osmo_mobile_identity_cmp(&p->mi2, mi)) - continue; - talloc_free(p); - return true; - } - return false; -} - -static struct hnbgw_cnlink *cnlink_find_by_paging_mi(struct hnbgw_cnpool *cnpool, const struct osmo_mobile_identity *mi) -{ - struct hnbgw_cnlink *cnlink; - time_t timeout = 0; - const char *errmsg; - - errmsg = cnlink_paging_gettime(NULL, &timeout); - if (errmsg) - LOGP(DCN, LOGL_ERROR, "%s\n", errmsg); - - llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { - if (!cnlink_match_paging_mi(cnlink, mi, timeout)) - continue; - return cnlink; - } - return NULL; -} - static int cn_ranap_rx_paging_cmd(struct hnbgw_cnlink *cnlink, RANAP_InitiatingMessage_t *imsg, const uint8_t *data, unsigned int len) -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39986?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I402fdcdc261626798904e7ee2eb5db80d30c4c34 Gerrit-Change-Number: 39986 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-hnbgw[master]: Move DL CO RANAP processing to its proper layer file
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39988?usp=email ) Change subject: Move DL CO RANAP processing to its proper layer file ...................................................................... Move DL CO RANAP processing to its proper layer file Change-Id: Ifcb8a23becb57ccad6c9aa4769b6f27d31a71c96 --- M include/osmocom/hnbgw/hnbgw_ranap.h M src/osmo-hnbgw/context_map_sccp.c M src/osmo-hnbgw/hnbgw_ranap.c 3 files changed, 100 insertions(+), 87 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve diff --git a/include/osmocom/hnbgw/hnbgw_ranap.h b/include/osmocom/hnbgw/hnbgw_ranap.h index 4317ece..2e77246 100644 --- a/include/osmocom/hnbgw/hnbgw_ranap.h +++ b/include/osmocom/hnbgw/hnbgw_ranap.h @@ -8,5 +8,6 @@ int hnbgw_ranap_rx_udt_ul(struct msgb *msg, uint8_t *data, size_t len); int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, const struct osmo_scu_unitdata_param *unitdata, const uint8_t *data, unsigned int len); +int hnbgw_ranap_rx_data_dl(struct hnbgw_context_map *map, struct msgb *ranap_msg); int hnbgw_ranap_init(void); diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index fc82426..42a0e49 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -27,18 +27,10 @@ #include <osmocom/sigtran/sccp_helpers.h> -#include <osmocom/ranap/ranap_common_ran.h> - -#if ENABLE_PFCP -#include <osmocom/pfcp/pfcp_cp_peer.h> -#endif - #include <osmocom/hnbgw/hnbgw_cn.h> #include <osmocom/hnbgw/context_map.h> +#include <osmocom/hnbgw/hnbgw_ranap.h> #include <osmocom/hnbgw/tdefs.h> -#include <osmocom/hnbgw/mgw_fsm.h> -#include <osmocom/hnbgw/ps_rab_ass_fsm.h> -#include <osmocom/hnbgw/kpi.h> enum map_sccp_fsm_state { MAP_SCCP_ST_INIT, @@ -187,32 +179,6 @@ return osmo_sccp_tx_disconn(map->cnlink->hnbgw_sccp_user->sccp_user, map->scu_conn_id, NULL, 0); } -static int destruct_ranap_ran_rx_co_ies(ranap_message *ranap_message_p) -{ - ranap_ran_rx_co_free(ranap_message_p); - return 0; -} - -/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. - * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls - * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ -static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg) -{ - int rc; - ranap_message *message; - - if (!msg_has_l2_data(ranap_msg)) - return NULL; - message = talloc_zero(OTC_SELECT, ranap_message); - rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); - if (rc != 0) { - talloc_free(message); - return NULL; - } - talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); - return message; -} - static int handle_rx_sccp(struct osmo_fsm_inst *fi, struct msgb *ranap_msg) { struct hnbgw_context_map *map = fi->priv; @@ -225,58 +191,7 @@ if (!msg_has_l2_data(ranap_msg)) return 0; - /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane - * information, for RTP mapping via MGW, or GTP mapping via UPF. */ - ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg); - if (message) { - talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); - - LOGPFSML(fi, LOGL_DEBUG, "rx from SCCP: RANAP %s\n", - get_value_string(ranap_procedure_code_vals, message->procedureCode)); - - kpi_ranap_process_dl(map, message); - - if (!map->is_ps) { - /* Circuit-Switched. Set up mapping of RTP ports via MGW */ - - switch (message->procedureCode) { - case RANAP_ProcedureCode_id_RAB_Assignment: - /* mgw_fsm_alloc_and_handle_rab_ass_req() takes ownership of (ranap) message */ - return handle_cs_rab_ass_req(map, ranap_msg, message); - case RANAP_ProcedureCode_id_Iu_Release: - /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the - * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */ - mgw_fsm_release(map); - break; - } -#if ENABLE_PFCP - } else { - switch (message->procedureCode) { - case RANAP_ProcedureCode_id_RAB_Assignment: - /* If a UPF is configured, handle the RAB Assignment via ps_rab_ass_fsm, and replace the - * GTP F-TEIDs in the RAB Assignment message before passing it on to RUA. */ - if (hnb_gw_is_gtp_mapping_enabled()) { - LOGP(DMAIN, LOGL_DEBUG, - "RAB Assignment: setting up GTP tunnel mapping via UPF %s\n", - osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_cp_peer_get_remote_addr(g_hnbgw->pfcp.cp_peer))); - return hnbgw_gtpmap_rx_rab_ass_req(map, ranap_msg, message); - } - /* If no UPF is configured, directly forward the message as-is (no GTP mapping). */ - LOGP(DMAIN, LOGL_DEBUG, "RAB Assignment: no UPF configured, forwarding as-is\n"); - break; - - case RANAP_ProcedureCode_id_Iu_Release: - /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the - * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */ - hnbgw_gtpmap_release(map); - break; - } -#endif - } - } - - /* It was not a RAB Assignment Request that needed to be intercepted. Forward as-is to RUA. */ - return map_rua_dispatch(map, MAP_RUA_EV_TX_DIRECT_TRANSFER, ranap_msg); + return hnbgw_ranap_rx_data_dl(map, ranap_msg); } static void map_sccp_init_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) diff --git a/src/osmo-hnbgw/hnbgw_ranap.c b/src/osmo-hnbgw/hnbgw_ranap.c index d795264..666560c 100644 --- a/src/osmo-hnbgw/hnbgw_ranap.c +++ b/src/osmo-hnbgw/hnbgw_ranap.c @@ -18,6 +18,8 @@ * */ +#include "config.h" + #include <unistd.h> #include <errno.h> #include <string.h> @@ -28,12 +30,21 @@ #include <osmocom/core/utils.h> #include <osmocom/ranap/ranap_common.h> +#include <osmocom/ranap/ranap_common_ran.h> #include <osmocom/ranap/ranap_ies_defs.h> #include <osmocom/ranap/ranap_msg_factory.h> +#if ENABLE_PFCP +#include <osmocom/pfcp/pfcp_cp_peer.h> +#endif + #include <osmocom/hnbgw/hnbgw.h> #include <osmocom/hnbgw/hnbgw_rua.h> #include <osmocom/hnbgw/hnbgw_cn.h> +#include <osmocom/hnbgw/context_map.h> +#include <osmocom/hnbgw/mgw_fsm.h> +#include <osmocom/hnbgw/ps_rab_ass_fsm.h> +#include <osmocom/hnbgw/kpi.h> /***************************************************************************** * Processing of RANAP from the endpoint towards RAN (hNodeB), acting as CN @@ -410,6 +421,92 @@ return rc; } +static int destruct_ranap_ran_rx_co_ies(ranap_message *ranap_message_p) +{ + ranap_ran_rx_co_free(ranap_message_p); + return 0; +} + +/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. + * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls + * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ +static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg) +{ + int rc; + ranap_message *message; + + if (!msg_has_l2_data(ranap_msg)) + return NULL; + message = talloc_zero(OTC_SELECT, ranap_message); + rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); + if (rc != 0) { + talloc_free(message); + return NULL; + } + talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); + return message; +} + +/* Process a received RANAP PDU through SCCP DATA.ind coming from CN (MSC/SGSN) + * Takes ownership of ranap_msg? */ +int hnbgw_ranap_rx_data_dl(struct hnbgw_context_map *map, struct msgb *ranap_msg) +{ + OSMO_ASSERT(map); + OSMO_ASSERT(msg_has_l2_data(ranap_msg)); + + /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane + * information, for RTP mapping via MGW, or GTP mapping via UPF. */ + ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg); + if (message) { + talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies); + + LOG_MAP(map, DCN, LOGL_DEBUG, "rx from SCCP: RANAP %s\n", + get_value_string(ranap_procedure_code_vals, message->procedureCode)); + + kpi_ranap_process_dl(map, message); + + if (!map->is_ps) { + /* Circuit-Switched. Set up mapping of RTP ports via MGW */ + switch (message->procedureCode) { + case RANAP_ProcedureCode_id_RAB_Assignment: + /* mgw_fsm_alloc_and_handle_rab_ass_req() takes ownership of (ranap) message */ + return handle_cs_rab_ass_req(map, ranap_msg, message); + case RANAP_ProcedureCode_id_Iu_Release: + /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the + * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */ + mgw_fsm_release(map); + break; + } +#if ENABLE_PFCP + } else { + switch (message->procedureCode) { + case RANAP_ProcedureCode_id_RAB_Assignment: + /* If a UPF is configured, handle the RAB Assignment via ps_rab_ass_fsm, and replace the + * GTP F-TEIDs in the RAB Assignment message before passing it on to RUA. */ + if (hnb_gw_is_gtp_mapping_enabled()) { + LOG_MAP(map, DCN, LOGL_DEBUG, + "RAB Assignment: setting up GTP tunnel mapping via UPF %s\n", + osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_cp_peer_get_remote_addr(g_hnbgw->pfcp.cp_peer))); + return hnbgw_gtpmap_rx_rab_ass_req(map, ranap_msg, message); + } + /* If no UPF is configured, directly forward the message as-is (no GTP mapping). */ + LOG_MAP(map, DCN, LOGL_DEBUG, "RAB Assignment: no UPF configured, forwarding as-is\n"); + break; + + case RANAP_ProcedureCode_id_Iu_Release: + /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the + * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */ + hnbgw_gtpmap_release(map); + break; + } +#endif + } + } + + /* It was not a RAB Assignment Request that needed to be intercepted. Forward as-is to RUA. */ + return map_rua_dispatch(map, MAP_RUA_EV_TX_DIRECT_TRANSFER, ranap_msg); +} + int hnbgw_ranap_init(void) { return 0; -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39988?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ifcb8a23becb57ccad6c9aa4769b6f27d31a71c96 Gerrit-Change-Number: 39988 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-hnbgw[master]: Move DL CL RANAP processing logic to its proper layer file
by pespin 10 Apr '25

10 Apr '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39987?usp=email ) Change subject: Move DL CL RANAP processing logic to its proper layer file ...................................................................... Move DL CL RANAP processing logic to its proper layer file This way we effectively split lower layers (SCCP and below) related to the link towards CN from the RANAP payload we need to process and forward. Change-Id: Icf18fe66d0483165fe487fe850b25830faf90150 --- M include/osmocom/hnbgw/hnbgw_ranap.h M src/osmo-hnbgw/hnbgw_cn.c M src/osmo-hnbgw/hnbgw_ranap.c 3 files changed, 215 insertions(+), 205 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/hnbgw/hnbgw_ranap.h b/include/osmocom/hnbgw/hnbgw_ranap.h index 31f2f57..4317ece 100644 --- a/include/osmocom/hnbgw/hnbgw_ranap.h +++ b/include/osmocom/hnbgw/hnbgw_ranap.h @@ -3,5 +3,10 @@ #include <osmocom/hnbgw/hnbgw.h> +struct osmo_scu_unitdata_param; + int hnbgw_ranap_rx_udt_ul(struct msgb *msg, uint8_t *data, size_t len); +int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, const struct osmo_scu_unitdata_param *unitdata, + const uint8_t *data, unsigned int len); int hnbgw_ranap_init(void); + diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 743d9b4..692196f 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -38,210 +38,14 @@ #include <osmocom/hnbgw/hnbgw.h> #include <osmocom/hnbgw/hnbgw_rua.h> +#include <osmocom/hnbgw/hnbgw_ranap.h> #include <osmocom/hnbgw/hnbgw_cn.h> -#include <osmocom/ranap/ranap_ies_defs.h> -#include <osmocom/ranap/ranap_msg_factory.h> -#include <osmocom/ranap/iu_helpers.h> #include <osmocom/hnbgw/context_map.h> /*********************************************************************** * Incoming primitives from SCCP User SAP ***********************************************************************/ -static int cn_ranap_rx_reset_cmd(struct hnbgw_cnlink *cnlink, - const struct osmo_scu_unitdata_param *unitdata, - RANAP_InitiatingMessage_t *imsg) -{ - RANAP_CN_DomainIndicator_t domain; - RANAP_ResetIEs_t ies; - int rc; - - rc = ranap_decode_reseties(&ies, &imsg->value); - domain = ies.cN_DomainIndicator; - ranap_free_reseties(&ies); - - if (rc) { - LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET: cannot decode IEs\n"); - return -1; - } - - if (cnlink->pool->domain != domain) { - LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET indicates domain %s, but this is %s on domain %s\n", - ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); - return -1; - } - - cnlink_rx_reset_cmd(cnlink); - return 0; -} - -static int cn_ranap_rx_reset_ack(struct hnbgw_cnlink *cnlink, - RANAP_SuccessfulOutcome_t *omsg) -{ - RANAP_CN_DomainIndicator_t domain; - RANAP_ResetAcknowledgeIEs_t ies; - int rc; - - rc = ranap_decode_resetacknowledgeies(&ies, &omsg->value); - domain = ies.cN_DomainIndicator; - ranap_free_resetacknowledgeies(&ies); - - if (rc) { - LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET ACK: cannot decode IEs\n"); - return -1; - } - - if (cnlink->pool->domain != domain) { - LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET ACK indicates domain %s, but this is %s on domain %s\n", - ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); - return -1; - } - - cnlink_rx_reset_ack(cnlink); - return 0; -} - -static int cn_ranap_rx_paging_cmd(struct hnbgw_cnlink *cnlink, - RANAP_InitiatingMessage_t *imsg, - const uint8_t *data, unsigned int len) -{ - const char *errmsg; - struct hnb_context *hnb; - bool is_ps = cnlink->pool->domain == DOMAIN_PS; - - errmsg = cnlink_paging_add_ranap(cnlink, imsg); - if (errmsg) { - LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx Paging from CN: %s. Dropping paging record." - " Later on, the Paging Response may be forwarded to the wrong CN peer.\n", - errmsg); - return -1; - } - - /* FIXME: determine which HNBs to send this Paging command, - * rather than broadcasting to all HNBs */ - llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { - if (!hnb->hnb_registered) - continue; - if (is_ps) - HNBP_CTR_INC(hnb->persistent, HNB_CTR_PS_PAGING_ATTEMPTED); - else - HNBP_CTR_INC(hnb->persistent, HNB_CTR_CS_PAGING_ATTEMPTED); - rua_tx_udt(hnb, data, len); - } - - return 0; -} - -static int ranap_rx_udt_dl_initiating_msg(struct hnbgw_cnlink *cnlink, - const struct osmo_scu_unitdata_param *unitdata, - RANAP_InitiatingMessage_t *imsg, - const uint8_t *data, unsigned int len) -{ - switch (imsg->procedureCode) { - case RANAP_ProcedureCode_id_Reset: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_RESET); - return cn_ranap_rx_reset_cmd(cnlink, unitdata, imsg); - case RANAP_ProcedureCode_id_Paging: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_PAGING); - return cn_ranap_rx_paging_cmd(cnlink, imsg, data, len); - case RANAP_ProcedureCode_id_OverloadControl: /* Overload ind */ - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_OVERLOAD_IND); - break; - case RANAP_ProcedureCode_id_ErrorIndication: /* Error ind */ - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_ERROR_IND); - break; - case RANAP_ProcedureCode_id_ResetResource: /* request */ - case RANAP_ProcedureCode_id_InformationTransfer: - case RANAP_ProcedureCode_id_DirectInformationTransfer: - case RANAP_ProcedureCode_id_UplinkInformationExchange: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNSUPPORTED); - LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %ld from CN, ignoring\n", imsg->procedureCode); - break; - default: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNKNOWN); - LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %ld from CN, ignoring\n", imsg->procedureCode); - break; - } - return 0; -} - -static int ranap_rx_udt_dl_successful_msg(struct hnbgw_cnlink *cnlink, - RANAP_SuccessfulOutcome_t *omsg) -{ - switch (omsg->procedureCode) { - case RANAP_ProcedureCode_id_Reset: /* Reset acknowledge */ - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_RESET); - return cn_ranap_rx_reset_ack(cnlink, omsg); - case RANAP_ProcedureCode_id_ResetResource: /* response */ - case RANAP_ProcedureCode_id_InformationTransfer: - case RANAP_ProcedureCode_id_DirectInformationTransfer: - case RANAP_ProcedureCode_id_UplinkInformationExchange: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNSUPPORTED); - LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %ld from CN, ignoring\n", omsg->procedureCode); - break; - default: - CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNKNOWN); - LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %ld from CN, ignoring\n", omsg->procedureCode); - break; - } - return 0; -} - - -static int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, - const struct osmo_scu_unitdata_param *unitdata, - RANAP_RANAP_PDU_t *pdu, const uint8_t *data, unsigned int len) -{ - int rc; - - switch (pdu->present) { - case RANAP_RANAP_PDU_PR_initiatingMessage: - rc = ranap_rx_udt_dl_initiating_msg(cnlink, unitdata, &pdu->choice.initiatingMessage, data, len); - break; - case RANAP_RANAP_PDU_PR_successfulOutcome: - rc = ranap_rx_udt_dl_successful_msg(cnlink, &pdu->choice.successfulOutcome); - break; - case RANAP_RANAP_PDU_PR_unsuccessfulOutcome: - LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "unsuccessful outcome procedure %ld from CN, ignoring\n", - pdu->choice.unsuccessfulOutcome.procedureCode); - rc = -ENOTSUP; - break; - default: - LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "presence %u from CN, ignoring\n", pdu->present); - rc = -EINVAL; - break; - } - - return rc; -} - -static int handle_cn_ranap(struct hnbgw_cnlink *cnlink, const struct osmo_scu_unitdata_param *unitdata, - const uint8_t *data, unsigned int len) -{ - RANAP_RANAP_PDU_t _pdu, *pdu = &_pdu; - asn_dec_rval_t dec_ret; - int rc; - - memset(pdu, 0, sizeof(*pdu)); - dec_ret = aper_decode(NULL, &asn_DEF_RANAP_RANAP_PDU, (void **) &pdu, - data, len, 0, 0); - if (dec_ret.code != RC_OK) { - LOGP(DRANAP, LOGL_ERROR, "Error in RANAP ASN.1 decode\n"); - return -1; - } - - rc = hnbgw_ranap_rx_udt_dl(cnlink, unitdata, pdu, data, len); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, pdu); - - return rc; -} - static struct hnbgw_cnlink *cnlink_from_addr(struct hnbgw_sccp_user *hsu, const struct osmo_sccp_addr *calling_addr, const struct osmo_prim_hdr *oph) { @@ -283,7 +87,7 @@ return -1; } - return handle_cn_ranap(cnlink, param, msgb_l2(oph->msg), msgb_l2len(oph->msg)); + return hnbgw_ranap_rx_udt_dl(cnlink, param, msgb_l2(oph->msg), msgb_l2len(oph->msg)); } static int handle_cn_conn_conf(struct hnbgw_sccp_user *hsu, diff --git a/src/osmo-hnbgw/hnbgw_ranap.c b/src/osmo-hnbgw/hnbgw_ranap.c index 83215f7..d795264 100644 --- a/src/osmo-hnbgw/hnbgw_ranap.c +++ b/src/osmo-hnbgw/hnbgw_ranap.c @@ -18,23 +18,27 @@ * */ - - -#include <osmocom/core/msgb.h> -#include <osmocom/core/utils.h> - #include <unistd.h> #include <errno.h> #include <string.h> #include "asn1helpers.h" -#include <osmocom/hnbgw/hnbgw.h> -#include <osmocom/hnbgw/hnbgw_rua.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/utils.h> + #include <osmocom/ranap/ranap_common.h> #include <osmocom/ranap/ranap_ies_defs.h> #include <osmocom/ranap/ranap_msg_factory.h> +#include <osmocom/hnbgw/hnbgw.h> +#include <osmocom/hnbgw/hnbgw_rua.h> +#include <osmocom/hnbgw/hnbgw_cn.h> + +/***************************************************************************** + * Processing of RANAP from the endpoint towards RAN (hNodeB), acting as CN + *****************************************************************************/ + static int ranap_tx_udt_dl_reset_ack(struct hnb_context *hnb, RANAP_CN_DomainIndicator_t domain) { struct msgb *msg; @@ -209,6 +213,203 @@ return rc; } +/***************************************************************************** + * Processing of RANAP from the endpoint towards CN (MSC/SGSN), acting as RAN + *****************************************************************************/ + +static int cn_ranap_rx_reset_cmd(struct hnbgw_cnlink *cnlink, + const struct osmo_scu_unitdata_param *unitdata, + RANAP_InitiatingMessage_t *imsg) +{ + RANAP_CN_DomainIndicator_t domain; + RANAP_ResetIEs_t ies; + int rc; + + rc = ranap_decode_reseties(&ies, &imsg->value); + domain = ies.cN_DomainIndicator; + ranap_free_reseties(&ies); + + if (rc) { + LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET: cannot decode IEs\n"); + return -1; + } + + if (cnlink->pool->domain != domain) { + LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET indicates domain %s, but this is %s on domain %s\n", + ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); + return -1; + } + + cnlink_rx_reset_cmd(cnlink); + return 0; +} + +static int cn_ranap_rx_paging_cmd(struct hnbgw_cnlink *cnlink, + RANAP_InitiatingMessage_t *imsg, + const uint8_t *data, unsigned int len) +{ + const char *errmsg; + struct hnb_context *hnb; + bool is_ps = cnlink->pool->domain == DOMAIN_PS; + + errmsg = cnlink_paging_add_ranap(cnlink, imsg); + if (errmsg) { + LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx Paging from CN: %s. Dropping paging record." + " Later on, the Paging Response may be forwarded to the wrong CN peer.\n", + errmsg); + return -1; + } + + /* FIXME: determine which HNBs to send this Paging command, + * rather than broadcasting to all HNBs */ + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { + if (!hnb->hnb_registered) + continue; + if (is_ps) + HNBP_CTR_INC(hnb->persistent, HNB_CTR_PS_PAGING_ATTEMPTED); + else + HNBP_CTR_INC(hnb->persistent, HNB_CTR_CS_PAGING_ATTEMPTED); + rua_tx_udt(hnb, data, len); + } + + return 0; +} + +static int ranap_rx_udt_dl_initiating_msg(struct hnbgw_cnlink *cnlink, + const struct osmo_scu_unitdata_param *unitdata, + RANAP_InitiatingMessage_t *imsg, + const uint8_t *data, unsigned int len) +{ + switch (imsg->procedureCode) { + case RANAP_ProcedureCode_id_Reset: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_RESET); + return cn_ranap_rx_reset_cmd(cnlink, unitdata, imsg); + case RANAP_ProcedureCode_id_Paging: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_PAGING); + return cn_ranap_rx_paging_cmd(cnlink, imsg, data, len); + case RANAP_ProcedureCode_id_OverloadControl: /* Overload ind */ + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_OVERLOAD_IND); + break; + case RANAP_ProcedureCode_id_ErrorIndication: /* Error ind */ + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_ERROR_IND); + break; + case RANAP_ProcedureCode_id_ResetResource: /* request */ + case RANAP_ProcedureCode_id_InformationTransfer: + case RANAP_ProcedureCode_id_DirectInformationTransfer: + case RANAP_ProcedureCode_id_UplinkInformationExchange: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNSUPPORTED); + LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " + "Procedure %ld from CN, ignoring\n", imsg->procedureCode); + break; + default: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNKNOWN); + LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " + "Procedure %ld from CN, ignoring\n", imsg->procedureCode); + break; + } + return 0; +} + +static int cn_ranap_rx_reset_ack(struct hnbgw_cnlink *cnlink, + RANAP_SuccessfulOutcome_t *omsg) +{ + RANAP_CN_DomainIndicator_t domain; + RANAP_ResetAcknowledgeIEs_t ies; + int rc; + + rc = ranap_decode_resetacknowledgeies(&ies, &omsg->value); + domain = ies.cN_DomainIndicator; + ranap_free_resetacknowledgeies(&ies); + + if (rc) { + LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET ACK: cannot decode IEs\n"); + return -1; + } + + if (cnlink->pool->domain != domain) { + LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Rx RESET ACK indicates domain %s, but this is %s on domain %s\n", + ranap_domain_name(domain), cnlink->name, ranap_domain_name(cnlink->pool->domain)); + return -1; + } + + cnlink_rx_reset_ack(cnlink); + return 0; +} + +static int ranap_rx_udt_dl_successful_msg(struct hnbgw_cnlink *cnlink, + RANAP_SuccessfulOutcome_t *omsg) +{ + switch (omsg->procedureCode) { + case RANAP_ProcedureCode_id_Reset: /* Reset acknowledge */ + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_RESET); + return cn_ranap_rx_reset_ack(cnlink, omsg); + case RANAP_ProcedureCode_id_ResetResource: /* response */ + case RANAP_ProcedureCode_id_InformationTransfer: + case RANAP_ProcedureCode_id_DirectInformationTransfer: + case RANAP_ProcedureCode_id_UplinkInformationExchange: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNSUPPORTED); + LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " + "Procedure %ld from CN, ignoring\n", omsg->procedureCode); + break; + default: + CNLINK_CTR_INC(cnlink, CNLINK_CTR_RANAP_RX_UDT_UNKNOWN); + LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " + "Procedure %ld from CN, ignoring\n", omsg->procedureCode); + break; + } + return 0; +} + +static int _hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, + const struct osmo_scu_unitdata_param *unitdata, + RANAP_RANAP_PDU_t *pdu, const uint8_t *data, unsigned int len) +{ + int rc; + + switch (pdu->present) { + case RANAP_RANAP_PDU_PR_initiatingMessage: + rc = ranap_rx_udt_dl_initiating_msg(cnlink, unitdata, &pdu->choice.initiatingMessage, data, len); + break; + case RANAP_RANAP_PDU_PR_successfulOutcome: + rc = ranap_rx_udt_dl_successful_msg(cnlink, &pdu->choice.successfulOutcome); + break; + case RANAP_RANAP_PDU_PR_unsuccessfulOutcome: + LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " + "unsuccessful outcome procedure %ld from CN, ignoring\n", + pdu->choice.unsuccessfulOutcome.procedureCode); + rc = -ENOTSUP; + break; + default: + LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " + "presence %u from CN, ignoring\n", pdu->present); + rc = -EINVAL; + break; + } + + return rc; +} + +int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, const struct osmo_scu_unitdata_param *unitdata, + const uint8_t *data, unsigned int len) +{ + RANAP_RANAP_PDU_t _pdu, *pdu = &_pdu; + asn_dec_rval_t dec_ret; + int rc; + + memset(pdu, 0, sizeof(*pdu)); + dec_ret = aper_decode(NULL, &asn_DEF_RANAP_RANAP_PDU, (void **) &pdu, + data, len, 0, 0); + if (dec_ret.code != RC_OK) { + LOGP(DRANAP, LOGL_ERROR, "Error in RANAP ASN.1 decode\n"); + return -1; + } + + rc = _hnbgw_ranap_rx_udt_dl(cnlink, unitdata, pdu, data, len); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, pdu); + + return rc; +} + int hnbgw_ranap_init(void) { return 0; -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39987?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Icf18fe66d0483165fe487fe850b25830faf90150 Gerrit-Change-Number: 39987 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • ...
  • 119
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.