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 2024

  • 1 participants
  • 1128 discussions
[S] Change in libosmocore[master]: formalize log subsys stripping for vty
by neels 09 Apr '24

09 Apr '24
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/36545?usp=email ) Change subject: formalize log subsys stripping for vty ...................................................................... formalize log subsys stripping for vty In osmocom, we historically have a leading 'D' in all of our logging subsystem names -- not only in the enum entry name, but also as the string in struct log_info_cat[]. As a result of this, our logging_vty code strips away the first character of each logging subsystem name. In the VTY, we don't enter 'dmain', but only 'main' -- the VTY strips the 'D' from "DMAIN". The intention is to make this stripping behavior optional in a subsequent patch. So far the code to do that is a magic "+ 1" thrown in here and there. Instead, introduce log_subsys_name() and use it where ever logging_vty.c does removal of the leading 'D'. I would have liked to keep this within logging_vty.c, but unfortunately it needs to be public API in logging.h, because of log_parse_category() which also strips leading D and lives in logging.c. Change-Id: I5f81343e8c7b714a4630e64ba654e391435c4244 --- M include/osmocom/core/logging.h M src/core/libosmocore.map M src/core/logging.c M src/vty/logging_vty.c 4 files changed, 42 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/36545/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 82e686f..da90d58 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -430,6 +430,8 @@ void log_set_category_filter(struct log_target *target, int category, int enable, int level); +const char *log_subsys_name(const struct log_info *log_info, int cat_idx); + /* management of the targets */ struct log_target *log_target_create(void); void log_target_destroy(struct log_target *target); diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map index c5ab6e3..3bb2abd 100644 --- a/src/core/libosmocore.map +++ b/src/core/libosmocore.map @@ -71,6 +71,7 @@ log_parse_category; log_parse_category_mask; log_parse_level; +log_subsys_name; logp_stub; log_reset_context; log_set_all_filter; diff --git a/src/core/logging.c b/src/core/logging.c index e172124..2429a0c 100644 --- a/src/core/logging.c +++ b/src/core/logging.c @@ -428,6 +428,13 @@ return get_value_string(loglevel_strs, lvl); } +/* skip the leading 'D' in category name */ +const char *log_subsys_name(const struct log_info *log_info, int cat_idx) +{ + const char *name = log_info->cat[cat_idx].name; + return name + 1; +} + /*! parse a human-readable log category into numeric form * \param[in] category human-readable log category name * \returns numeric category value, or -EINVAL otherwise @@ -441,7 +448,7 @@ for (i = 0; i < osmo_log_info->num_cat; ++i) { if (osmo_log_info->cat[i].name == NULL) continue; - if (!strcasecmp(osmo_log_info->cat[i].name+1, category)) + if (!strcasecmp(log_subsys_name(osmo_log_info, i), category)) return i; } diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 678ae68..9f38c14 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -322,8 +322,7 @@ for (i = 0; i < categories->num_cat; i++) { if (categories->cat[i].name == NULL) continue; - /* skip the leading 'D' in each category name, hence '+ 1' */ - osmo_str_tolower_buf(buf, sizeof(buf), categories->cat[i].name + 1); + osmo_str_tolower_buf(buf, sizeof(buf), log_subsys_name(categories, i)); osmo_talloc_asprintf(tall_log_ctx, *cmd_str_p, "%s%s", i ? "|" : "", buf); osmo_talloc_asprintf(tall_log_ctx, *doc_str_p, "%s\n", @@ -530,7 +529,7 @@ if (!info->cat[i].name) continue; vty_out(vty, " %-10s %-10s %-8s %s%s", - info->cat[i].name+1, log_level_str(cat->loglevel), + log_subsys_name(info, i), log_level_str(cat->loglevel), cat->enabled ? "Enabled" : "Disabled", info->cat[i].description, VTY_NEWLINE); @@ -1095,7 +1094,7 @@ if (!osmo_log_info->cat[i].name) continue; - osmo_str_tolower_buf(cat_name, sizeof(cat_name), osmo_log_info->cat[i].name + 1); + osmo_str_tolower_buf(cat_name, sizeof(cat_name), log_subsys_name(osmo_log_info, i)); level_str = get_value_string_or_null(loglevel_strs, cat->loglevel); if (!level_str) { -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36545?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I5f81343e8c7b714a4630e64ba654e391435c4244 Gerrit-Change-Number: 36545 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in libosmocore[master]: add osmo_stats_report_lock api
by neels 09 Apr '24

09 Apr '24
Attention is currently required from: fixeria, pespin. Hello Jenkins Builder, fixeria, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by fixeria, Verified+1 by Jenkins Builder Change subject: add osmo_stats_report_lock api ...................................................................... add osmo_stats_report_lock api Allow multi-threaded access to reported stats: - enable use of a stats mutex with osmo_stats_report_use_lock(true). - lock/unlock externally with osmo_stats_report_lock(true/false). Rationale: In osmo-hnbgw, we would like to collect stats from nftables, and do so in a separate thead. The most efficient way is to write the parsing results from nft directly to the rate_ctr destination. But what if the main thread reports rate counters at exactly that time? - is writing to stats atomic on a data type level? - do applications need stats to be "atomic" as a whole? In osmo-hnbgw in particular, there are two counters, 'packets' and 'total_bytes'. These correspond, and it would skew statistics if we reported them out of sync to each other. The simplest way to ensure correctness in all cases is a mutex around the stats reporting. But this mutex isn't needed in most of our programs. To completely avoid any overhead the mutex may bring, make use of it optional with a global flag. This use case is likely to also show up in other programs that would like to collect and report stats from a separate thread. Related: SYS#6773 Related: osmo-hnbgw I9dc54e6bc94c553f45adfa71ae8ad70be4afbc8f Change-Id: Ib335bea7d2a440ca284e6c439066f96456bf2c2d --- M include/osmocom/core/stats.h M src/core/libosmocore.map M src/core/stats.c M src/vty/stats_vty.c 4 files changed, 128 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/36538/2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ib335bea7d2a440ca284e6c439066f96456bf2c2d Gerrit-Change-Number: 36538 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in libosmocore[master]: add osmo_stats_report_lock api
by neels 09 Apr '24

09 Apr '24
Attention is currently required from: pespin. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email ) Change subject: add osmo_stats_report_lock api ...................................................................... Patch Set 1: (2 comments) File src/core/stats.c: https://gerrit.osmocom.org/c/libosmocore/+/36538/comment/059126a4_431954e5 PS1, Line 794: * Calling osmo_stats_report_use_lock(true) */ unfinished comment https://gerrit.osmocom.org/c/libosmocore/+/36538/comment/6abcec23_ce7baf8d PS1, Line 831: pthread_mutex_t *lock = g_report_lock; > brevity; […] I remember now, it was a useless precaution against a changing g_report_lock. Not actually important, it hardly helps, and if the caller fails to avoid races as required by the (new) API doc, it's all mayhem anyway. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ib335bea7d2a440ca284e6c439066f96456bf2c2d Gerrit-Change-Number: 36538 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 09 Apr 2024 03:21:11 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: add osmo_stats_report_lock api
by neels 09 Apr '24

09 Apr '24
Attention is currently required from: pespin. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email ) Change subject: add osmo_stats_report_lock api ...................................................................... Patch Set 1: (4 comments) Patchset: PS1: > I think with this you are only sorting out one of the concurrency problems when using rate_ctr/stats […] How the caller chooses to use this remains very specialized for an application, the main aim is to allow a hook to mutex around the stats reporting. The way this is used in my hnbgw patch: The main thread simply also holds a osmo_stats_report_lock() while groups are added/removed. Because the counter-retrieving thread acquires osmo_stats_report_lock() when updating counters, things are guarded. File src/core/stats.c: https://gerrit.osmocom.org/c/libosmocore/+/36538/comment/4578fe90_562cc039 PS1, Line 808: pthread_mutex_destroy(g_report_lock); > What happens if a pthread_mutex is destroyed while used? […] good point https://gerrit.osmocom.org/c/libosmocore/+/36538/comment/37dcc5d3_51ee4c81 PS1, Line 819: void osmo_stats_report_lock(bool lock) > I'd definetly have 2 APIs here, one for lock and one for unlock. […] easier to trace: good point https://gerrit.osmocom.org/c/libosmocore/+/36538/comment/ada84510_dddd3e86 PS1, Line 831: pthread_mutex_t *lock = g_report_lock; > what's the point of this local variable? brevity; but in fact looks like leftovers from evolution of the patch, thx -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36538?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ib335bea7d2a440ca284e6c439066f96456bf2c2d Gerrit-Change-Number: 36538 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 09 Apr 2024 02:28:53 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: SIP_Emulation: Match empty port as default port 5060
by pespin 08 Apr '24

08 Apr '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36544?usp=email ) Change subject: SIP_Emulation: Match empty port as default port 5060 ...................................................................... SIP_Emulation: Match empty port as default port 5060 Change-Id: I8415571a5bdc99e8cc007bb4b57bcb73b7afd4fb --- M library/SIP_Emulation.ttcn 1 file changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/44/36544/1 diff --git a/library/SIP_Emulation.ttcn b/library/SIP_Emulation.ttcn index 5c00c4d..4aef536 100644 --- a/library/SIP_Emulation.ttcn +++ b/library/SIP_Emulation.ttcn @@ -380,6 +380,9 @@ } if (not ispresent(t_exp.hostPort.portField)) { t_exp.hostPort.portField := *; + } else if (valueof(t_exp.hostPort.portField) == 5060) { + /* if the port number is 5060, it may be omitted */ + t_exp.hostPort.portField := 5060 ifpresent; } if (not ispresent(t_exp.urlParameters)) { t_exp.urlParameters := *; -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36544?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I8415571a5bdc99e8cc007bb4b57bcb73b7afd4fb Gerrit-Change-Number: 36544 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: SIP_Emulation: Fix SIPEM_register when several conns are active
by pespin 08 Apr '24

08 Apr '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36543?usp=email ) Change subject: SIP_Emulation: Fix SIPEM_register when several conns are active ...................................................................... SIP_Emulation: Fix SIPEM_register when several conns are active "Dynamic test case error: Port CLIENT_PROC has more than one active connections. Message can be sent on it only with explicit addressing.". Change-Id: Ibf868394ce2c495a78ab943ddec278a45bf71088 --- M library/SIP_Emulation.ttcn 1 file changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/43/36543/1 diff --git a/library/SIP_Emulation.ttcn b/library/SIP_Emulation.ttcn index 41e6975..5c00c4d 100644 --- a/library/SIP_Emulation.ttcn +++ b/library/SIP_Emulation.ttcn @@ -326,9 +326,9 @@ SIP.send(sip_resp); } - [] CLIENT_PROC.getcall(SIPEM_register:{?,?}) -> param(sip_to, vc_hdlr) { + [] CLIENT_PROC.getcall(SIPEM_register:{?,?}) -> param(sip_to, vc_hdlr) sender vc_conn { f_create_expect(sip_to, vc_hdlr); - CLIENT_PROC.reply(SIPEM_register:{sip_to, vc_hdlr}); + CLIENT_PROC.reply(SIPEM_register:{sip_to, vc_hdlr}) to vc_conn; } } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36543?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ibf868394ce2c495a78ab943ddec278a45bf71088 Gerrit-Change-Number: 36543 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: WIP: asterisk: Introduce test TC_internal_call_momt
by pespin 08 Apr '24

08 Apr '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36541?usp=email ) Change subject: WIP: asterisk: Introduce test TC_internal_call_momt ...................................................................... WIP: asterisk: Introduce test TC_internal_call_momt Related: SYS#6782 Change-Id: I7621ee867202b74a40e40516cdca673781cb1f51 --- M asterisk/Asterisk_Tests.ttcn 1 file changed, 61 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/41/36541/1 diff --git a/asterisk/Asterisk_Tests.ttcn b/asterisk/Asterisk_Tests.ttcn index dab9400..a0b3756 100644 --- a/asterisk/Asterisk_Tests.ttcn +++ b/asterisk/Asterisk_Tests.ttcn @@ -31,8 +31,16 @@ integer mp_remote_sip_port := 5060; } +type port Coord_PT message +{ + inout charstring; +} with { extension "internal" }; +private const charstring COORD_CMD_REGISTERED := "COORD_CMD_REGISTERED"; +private const charstring COORD_CMD_START := "COORD_CMD_START"; + type component test_CT { var SIP_Emulation_CT vc_SIP; + port Coord_PT COORD; } type component ConnHdlr extends SIP_ConnHdlr { @@ -40,6 +48,8 @@ timer g_Tguard; var PDU_SIP_Request g_rx_sip_req; var PDU_SIP_Response g_rx_sip_resp; + + port Coord_PT COORD; } type record ConnHdlrPars { @@ -138,6 +148,8 @@ connect(vc_conn:SIP, vc_SIP:CLIENT); connect(vc_conn:SIP_PROC, vc_SIP:CLIENT_PROC); + connect(vc_conn:COORD, self:COORD); + vc_conn.start(f_handler_init(fn, id, pars)); return vc_conn; } @@ -276,7 +288,6 @@ // f_SIP_deregister(); setverdict(pass); } - testcase TC_internal_registration() runs on test_CT { var ConnHdlrPars pars; var ConnHdlr vc_conn; @@ -286,6 +297,44 @@ vc_conn.done; } +/* Successful SIP MO-MT Call between local clients: */ +private function f_TC_internal_call_mo(charstring id) runs on ConnHdlr { + + f_SIP_register(); + + COORD.send(COORD_CMD_REGISTERED); + + setverdict(pass); +} +private function f_TC_internal_call_mt(charstring id) runs on ConnHdlr { + + f_SIP_register(); + + COORD.send(COORD_CMD_REGISTERED); + + setverdict(pass); +} +testcase TC_internal_call_momt() runs on test_CT { + var ConnHdlrPars pars[2]; + var ConnHdlr vc_conn[2]; + f_init(); + pars[0] := f_init_ConnHdlrPars(idx := 1); + pars[1] := f_init_ConnHdlrPars(idx := 2); + + vc_conn[0] := f_start_handler(refers(f_TC_internal_call_mo), pars[0]); + vc_conn[1] := f_start_handler(refers(f_TC_internal_call_mt), pars[1]); + + interleave { + [] COORD.receive(COORD_CMD_REGISTERED) from vc_conn[0]; + [] COORD.receive(COORD_CMD_REGISTERED) from vc_conn[1]; + } + + COORD.send(COORD_CMD_START) to vc_conn[0]; + + vc_conn[0].done; + vc_conn[1].done; +} + testcase TC_selftest() runs on test_CT { f_sip_digest_selftest(); setverdict(pass); @@ -293,6 +342,7 @@ control { execute( TC_internal_registration() ); + execute( TC_internal_call_momt() ); } } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36541?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I7621ee867202b74a40e40516cdca673781cb1f51 Gerrit-Change-Number: 36541 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: library/SIP_Templates: Fix wrong method name in tr_SIP_REGISTER
by pespin 08 Apr '24

08 Apr '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36542?usp=email ) Change subject: library/SIP_Templates: Fix wrong method name in tr_SIP_REGISTER ...................................................................... library/SIP_Templates: Fix wrong method name in tr_SIP_REGISTER Change-Id: Ieec2124417a3294cfb469180f44285e880a46177 --- M library/SIP_Templates.ttcn 1 file changed, 10 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/42/36542/1 diff --git a/library/SIP_Templates.ttcn b/library/SIP_Templates.ttcn index 7cb9d68..7de2d27 100644 --- a/library/SIP_Templates.ttcn +++ b/library/SIP_Templates.ttcn @@ -516,7 +516,7 @@ requestLine := tr_SIP_ReqLine(REGISTER_E, sip_url_host_port), msgHeader := tr_SIP_msgh_std(call_id, from_addr, to_addr, contact, tr_Via_from(tr_HostPort(from_addr.addr.nameAddr.addrSpec.hostPort)), - "INVITE", *, seq_nr, + "REGISTER", *, seq_nr, expires := expires), messageBody := body, payload := omit -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36542?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ieec2124417a3294cfb469180f44285e880a46177 Gerrit-Change-Number: 36542 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in osmo-ttcn3-hacks[master]: asterisk: Implement and test SIP Digest Authorization
by pespin 08 Apr '24

08 Apr '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36532?usp=email ) Change subject: asterisk: Implement and test SIP Digest Authorization ...................................................................... asterisk: Implement and test SIP Digest Authorization Related: SYS#6782 Change-Id: Ib469f1906927a3f246876040086ff115fbf4c032 --- M asterisk/Asterisk_Tests.ttcn M asterisk/gen_links.sh M asterisk/regen_makefile.sh M library/SIP_Templates.ttcn M sip/SIP_Tests.ttcn M sip/gen_links.sh M sip/regen_makefile.sh 7 files changed, 609 insertions(+), 22 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/asterisk/Asterisk_Tests.ttcn b/asterisk/Asterisk_Tests.ttcn index 9402f0d..dab9400 100644 --- a/asterisk/Asterisk_Tests.ttcn +++ b/asterisk/Asterisk_Tests.ttcn @@ -11,6 +11,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +import from TCCOpenSecurity_Functions all; import from General_Types all; import from Osmocom_Types all; import from Native_Functions all; @@ -44,6 +45,7 @@ type record ConnHdlrPars { float t_guard, charstring user, + charstring password, SipUrl registrar_sip_url, SipAddr registrar_sip_record, CallidString registrar_sip_call_id, @@ -55,9 +57,11 @@ } template (value) ConnHdlrPars t_Pars(charstring user, - charstring displayname := "\"Anonymous\"") := { + charstring displayname := "\"Anonymous\"", + charstring password := "secret") := { t_guard := 30.0, user := user, + password := password, registrar_sip_url := valueof(ts_SipUrlHost(mp_remote_sip_host)), registrar_sip_record := ts_SipAddr(ts_HostPort(mp_remote_sip_host), ts_UserInfo(user), @@ -188,38 +192,87 @@ via_resp_params); } +private function f_tr_To_response(SipAddr to_req) return template (present) SipAddr { + return tr_SipAddr_from_val(to_req); +} + function f_SIP_register() runs on ConnHdlr return PDU_SIP_Response { var template (present) PDU_SIP_Response exp; + var Authorization authorization; + var Via via := g_pars.registrar_via; + var SipAddr from_sipaddr := g_pars.registrar_sip_record; + var charstring branch_value; + branch_value := f_sip_gen_branch(f_sip_SipAddr_to_str(g_pars.registrar_sip_record), + f_sip_SipAddr_to_str(g_pars.registrar_sip_record), + g_pars.registrar_sip_call_id, + g_pars.registrar_sip_seq_nr); + + via.viaBody[0].viaParams := f_sip_param_set(via.viaBody[0].viaParams, "branch", branch_value); + from_sipaddr.params := f_sip_param_set(from_sipaddr.params, "tag", f_sip_rand_tag()); SIP.send(ts_SIP_REGISTER(g_pars.registrar_sip_url, g_pars.registrar_sip_call_id, + from_sipaddr, g_pars.registrar_sip_record, - g_pars.registrar_sip_record, - g_pars.registrar_via, + via, g_pars.registrar_sip_seq_nr, g_pars.local_contact, ts_Expires("7200"))); exp := tr_SIP_Response_REGISTER_Unauthorized( g_pars.registrar_sip_call_id, - g_pars.registrar_sip_record, - g_pars.registrar_sip_record, - f_tr_Via_response(g_pars.registrar_via), + from_sipaddr, + f_tr_To_response(g_pars.registrar_sip_record), + f_tr_Via_response(via), *, + tr_WwwAuthenticate({tr_Challenge_digestCln(?)}), g_pars.registrar_sip_seq_nr); as_SIP_expect_resp(exp); - /* Do the registering after calculating the md5 hash, etc. */ + /* Digest Auth: RFC 2617 */ + authorization := f_sip_digest_gen_Authorization(g_rx_sip_resp.msgHeader.wwwAuthenticate, + g_pars.user, g_pars.password, + "REGISTER", "sip:" & mp_remote_sip_host) + + /* New transaction: */ + g_pars.registrar_sip_seq_nr := g_pars.registrar_sip_seq_nr + 1; + branch_value := f_sip_gen_branch(f_sip_SipAddr_to_str(g_pars.registrar_sip_record), + f_sip_SipAddr_to_str(g_pars.registrar_sip_record), + g_pars.registrar_sip_call_id, + g_pars.registrar_sip_seq_nr); + via.viaBody[0].viaParams := f_sip_param_set(via.viaBody[0].viaParams, "branch", branch_value); + + SIP.send(ts_SIP_REGISTER(g_pars.registrar_sip_url, + g_pars.registrar_sip_call_id, + from_sipaddr, + g_pars.registrar_sip_record, + via, + g_pars.registrar_sip_seq_nr, + g_pars.local_contact, + ts_Expires("7200"), + authorization := authorization)); + + /* Wait for OK answer */ + exp := tr_SIP_Response( + g_pars.registrar_sip_call_id, + from_sipaddr, + f_tr_To_response(g_pars.registrar_sip_record), + f_tr_Via_response(via), + *, + "REGISTER", 200, + g_pars.registrar_sip_seq_nr, "OK"); + as_SIP_expect_resp(exp); + + /* Prepare for next use: */ + g_pars.registrar_sip_seq_nr := g_pars.registrar_sip_seq_nr + 1; return g_rx_sip_resp; } -/* Successful MO Call, which is subsequently released by SIP side */ +/* Test SIP registration of local clients */ private function f_TC_internal_registration(charstring id) runs on ConnHdlr { f_SIP_register(); - /* now call is fully established */ - f_sleep(2.0); // f_SIP_deregister(); setverdict(pass); } @@ -233,6 +286,11 @@ vc_conn.done; } +testcase TC_selftest() runs on test_CT { + f_sip_digest_selftest(); + setverdict(pass); +} + control { execute( TC_internal_registration() ); } diff --git a/asterisk/gen_links.sh b/asterisk/gen_links.sh index 1fd6ecc..7394b64 100755 --- a/asterisk/gen_links.sh +++ b/asterisk/gen_links.sh @@ -5,7 +5,8 @@ . ../gen_links.sh.inc DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src -FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h" +FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h " +FILES+="TCCOpenSecurity_Functions.ttcn TCCOpenSecurity.cc TCCOpenSecurity_Functions.hh " gen_links $DIR $FILES DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src diff --git a/asterisk/regen_makefile.sh b/asterisk/regen_makefile.sh index 3995b3d..3cd0a66 100755 --- a/asterisk/regen_makefile.sh +++ b/asterisk/regen_makefile.sh @@ -14,6 +14,7 @@ SIPmsg_PT.cc TCCConversion.cc TCCInterface.cc + TCCOpenSecurity.cc " ../regen-makefile.sh -e $NAME $FILES diff --git a/library/SIP_Templates.ttcn b/library/SIP_Templates.ttcn index fc8e23f..7cb9d68 100644 --- a/library/SIP_Templates.ttcn +++ b/library/SIP_Templates.ttcn @@ -1,7 +1,11 @@ module SIP_Templates { import from SIPmsg_Types all; +import from TCCConversion_Functions all; +import from TCCOpenSecurity_Functions all; +import from Native_Functions all; import from Osmocom_Types all; +import from Misc_Helpers all; /* wrapper type to encapsulate the Addr_Union + parameter list used in From, To. ... */ type record SipAddr { @@ -11,6 +15,26 @@ const charstring c_SIP_VERSION := "SIP/2.0"; +template (value) GenericParam ts_Param(template (value) charstring id, + template (omit) charstring paramValue := omit) := { + id := id, + paramValue := paramValue +} +template (present) GenericParam tr_Param(template (present) charstring id := ?, + template charstring paramValue := *) := { + id := id, + paramValue := paramValue +} +function f_ts_Param_omit(template (value) charstring id, + template (omit) charstring paramValue := omit) + return template (omit) GenericParam +{ + if (istemplatekind(paramValue, "omit")) { + return omit; + } + return ts_Param(id, paramValue); +} + template (value) SipUrl ts_SipUrl(template (value) HostPort host_port, template (omit) UserInfo user_info := omit) := { scheme := "sip", @@ -31,6 +55,49 @@ template (value) SipUrl ts_SipUrlHost(template (value) charstring host) := ts_SipUrl(ts_HostPort(host)); +template (value) Credentials ts_Credentials_DigestResponse(template (value) CommaParam_List digestResponse) := { + digestResponse := digestResponse +} + +template (value) Credentials ts_Credentials_DigestResponseMD5( + template (value) charstring username, + template (value) charstring realm, + template (value) charstring nonce, + template (value) charstring uri, + template (value) charstring response, + template (value) charstring opaque, + template (value) charstring algorithm := "MD5", + template (value) charstring qop := "auth", + template (omit) charstring cnonce := omit, + template (omit) charstring nc := omit + ) := { + digestResponse := { + // Already added by digestResponse automatically: + //ts_Param("Digest", omit), + ts_Param("username", f_sip_str_quote(username)), + ts_Param("realm", f_sip_str_quote(realm)), + ts_Param("nonce", f_sip_str_quote(nonce)), + ts_Param("uri", f_sip_str_quote(uri)), + ts_Param("response", f_sip_str_quote(response)), + ts_Param("opaque", f_sip_str_quote(opaque)), + ts_Param("algorithm", algorithm), + ts_Param("qop", qop), + // FIXME: If "omit" is passed, these below end up in; + // "Dynamic test case error: Performing a valueof or send operation on a non-specific template of type @SIPmsg_Types.GenericParam" + f_ts_Param_omit("cnonce", f_sip_str_quote(cnonce)), + f_ts_Param_omit("nc", nc) + } +} + +template (value) Credentials ts_Credentials_OtherAuth(template (value) OtherAuth otherResponse) := { + otherResponse := otherResponse +} + +template (value) Authorization ts_Authorization(template (value) Credentials body) := { + fieldName := AUTHORIZATION_E, + body := body +} + // [20.10] template (present) NameAddr tr_NameAddr(template (present) SipUrl addrSpec := ?, template charstring displayName := *) := { @@ -262,7 +329,53 @@ viaParams := viaParams } } - } +} + +template (present) OtherAuth +tr_OtherAuth(template (present) charstring authScheme := ?, + template (present) CommaParam_List authParams := ?) := { + authScheme := authScheme, + authParams := authParams +} + +template (value) OtherAuth +ts_OtherAuth(template (value) charstring authScheme, + template (value) CommaParam_List authParams) := { + authScheme := authScheme, + authParams := authParams +} + +template (present) Challenge +tr_Challenge_digestCln(template (present) CommaParam_List digestCln := ?) := { + digestCln := digestCln +} + +template (value) Challenge +ts_Challenge_digestCln(template (value) CommaParam_List digestCln) := { + digestCln := digestCln +} + +template (present) Challenge +tr_Challenge_otherChallenge(template (present) OtherAuth otherChallenge := ?) := { + otherChallenge := otherChallenge +} + +template (value) Challenge +ts_Challenge_otherChallenge(template (value) OtherAuth otherChallenge) := { + otherChallenge := otherChallenge +} + +template (present) WwwAuthenticate +tr_WwwAuthenticate(template (present) Challenge_list challenge := ?) := { + fieldName := WWW_AUTHENTICATE_E, + challenge := challenge +} + +template (value) WwwAuthenticate +ts_WwwAuthenticate(template (value) Challenge_list challenge) := { + fieldName := WWW_AUTHENTICATE_E, + challenge := challenge +} template (value) MessageHeader ts_SIP_msgHeader_empty := c_SIP_msgHeader_empty; template (value) MessageHeader @@ -274,6 +387,7 @@ template (value) integer seq_nr, template (value) Via via, template (omit) ContentType content_type := omit, + template (omit)Authorization authorization := omit, template (value) Method_List allow_methods := c_SIP_defaultMethods, template (omit) Expires expires := omit ) modifies ts_SIP_msgHeader_empty := { @@ -281,6 +395,7 @@ fieldName := ALLOW_E, methods := allow_methods }, + authorization := authorization, callId := { fieldName := CALL_ID_E, callid := call_id @@ -337,7 +452,8 @@ template ContentType content_type := *, template integer seq_nr := ?, template Method_List allow_methods := *, - template Expires expires := * + template Expires expires := *, + template WwwAuthenticate wwwAuthenticate := * ) modifies t_SIP_msgHeader_any := { allow := tr_AllowMethods(allow_methods), callId := { @@ -363,7 +479,8 @@ toParams := to_addr.params }, userAgent := *, - via := via + via := via, + wwwAuthenticate := wwwAuthenticate } @@ -376,11 +493,13 @@ integer seq_nr, template (omit) Contact contact, template (omit) Expires expires, + template (omit) Authorization authorization := omit, template (omit) charstring body := omit) := { requestLine := ts_SIP_ReqLine(REGISTER_E, sip_url_host_port), msgHeader := ts_SIP_msgh_std(call_id, from_addr, to_addr, contact, "REGISTER", seq_nr, via, f_ContentTypeOrOmit(ts_CT_SDP, body), + authorization := authorization, expires := expires), messageBody := body, payload := omit @@ -511,15 +630,16 @@ tr_SIP_Response(template CallidString call_id, template SipAddr from_addr, template SipAddr to_addr, + template (present) Via via := tr_Via_from(?), template Contact contact, template charstring method, template integer status_code, template integer seq_nr := ?, template charstring reason := ?, - template charstring body := ?) := { + template charstring body := *) := { statusLine := tr_SIP_StatusLine(status_code, reason), msgHeader := tr_SIP_msgh_std(call_id, from_addr, to_addr, contact, - tr_Via_from(tr_HostPort(from_addr.addr.nameAddr.addrSpec.hostPort)), + via, method, *, seq_nr), messageBody := body, payload := omit @@ -533,6 +653,7 @@ template SipAddr to_addr, template (present) Via via := tr_Via_from(?), template Contact contact := *, + template (present) WwwAuthenticate wwwAuthenticate := ?, template integer seq_nr := ?, template charstring method := "REGISTER", template integer status_code := 401, @@ -541,11 +662,333 @@ statusLine := tr_SIP_StatusLine(status_code, reason), msgHeader := tr_SIP_msgh_std(call_id, from_addr, to_addr, contact, via, - method, *, seq_nr), + method, *, seq_nr, + wwwAuthenticate := wwwAuthenticate), messageBody := body, payload := omit } +function f_sip_param_find(GenericParam_List li, + template (present) charstring id := ?) +return template (omit) GenericParam { + var integer i; + + for (i := 0; i < lengthof(li); i := i + 1) { + if (not ispresent(li[i])) { + continue; + } + if (match(li[i].id, id)) { + return li[i]; + } + } + return omit; +} + +function f_sip_param_find_or_fail(GenericParam_List li, + template (present) charstring id := ?) +return GenericParam { + var template (omit) GenericParam parameter; + parameter := f_sip_param_find(li, id); + if (istemplatekind(parameter, "omit")) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Param ", id, " not found in ", li)); + } + return valueof(parameter); +} + +function f_sip_param_get_value(GenericParam_List li, + template (present) charstring id := ?) +return template (omit) charstring { + var template (omit) GenericParam parameter; + parameter := f_sip_param_find(li, id); + if (istemplatekind(parameter, "omit")) { + return omit; + } + return parameter.paramValue; +} + +function f_sip_param_get_value_or_fail(GenericParam_List li, + template (present) charstring id := ?) +return template (omit) charstring { + var GenericParam parameter; + parameter := f_sip_param_find_or_fail(li, id); + return parameter.paramValue; +} + +function f_sip_param_get_value_present_or_fail(GenericParam_List li, + template (present) charstring id := ?) +return charstring { + var GenericParam parameter; + parameter := f_sip_param_find_or_fail(li, id); + if (not ispresent(parameter.paramValue)) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Param ", id, " value not present in ", li)); + } + return parameter.paramValue; +} + +function f_sip_param_match_value(GenericParam_List li, + template (present) charstring id := ?, + template charstring exp_paramValue := *) +return boolean { + var template (omit) charstring val; + val := f_sip_param_get_value_or_fail(li, id); + if (istemplatekind(val, "omit")) { + return istemplatekind(val, "omit") or istemplatekind(val, "*"); + } + return match(valueof(val), exp_paramValue); +} + +function f_sip_param_match_value_or_fail(GenericParam_List li, + template (present) charstring id := ?, + template charstring exp_paramValue := *) +{ + var template (omit) charstring val := f_sip_param_get_value_or_fail(li, id); + if (istemplatekind(val, "omit")) { + if (istemplatekind(val, "omit") or istemplatekind(val, "*")) { + return; + } else { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Param ", id, " match failed: val ", val, + " vs exp ", exp_paramValue)); + } + } + if (not match(valueof(val), exp_paramValue)) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Param ", id, " match failed: val ", val, + " vs exp ", exp_paramValue)); + } +} + +function f_sip_param_remove(template (omit) GenericParam_List li_tpl, charstring id) +return GenericParam_List { + var integer i; + var GenericParam_List li; + var GenericParam_List new_li := {}; + + if (istemplatekind(li_tpl, "omit")) { + return {}; + } + + li := valueof(li_tpl); + for (i := 0; i < lengthof(li); i := i + 1) { + if (not ispresent(li[i]) or + not match(li[i].id, id)) { + new_li := new_li & {li[i]}; + } + } + return new_li; +} + +function f_sip_param_set(template (omit) GenericParam_List li_tpl, charstring id, charstring val) +return GenericParam_List { + var integer i; + var GenericParam_List li; + var GenericParam_List new_li := {}; + var boolean found := false; + + if (istemplatekind(li_tpl, "omit")) { + return { valueof(ts_Param(id, val)) }; + } + + li := valueof(li_tpl); + for (i := 0; i < lengthof(li); i := i + 1) { + if (not ispresent(li[i]) or + not match(li[i].id, id)) { + new_li := new_li & {li[i]}; + continue; + } + new_li := new_li & { valueof(ts_Param(li[i].id, val)) }; + found := true; + } + + if (not found) { + new_li := new_li & { valueof(ts_Param(id, val)) }; + } + return new_li; +} + +/* Make sure string is quoted. */ +function f_sip_str_quote(template (value) charstring val) return charstring { + var charstring str := valueof(val); + if (lengthof(str) == 0) { + return ""; + } + + if (str[0] != "\"") { + return "\"" & str & "\""; + } + return str; +} + +/* Make sure string is unquoted. + * Similar to unq() in RFC 2617 */ +function f_sip_str_unquote(template (value) charstring val) return charstring { + var charstring str := valueof(val); + var integer len := lengthof(str); + + if (len <= 1) { + return str; + } + + if (str[0] == "\"" and str[len - 1] == "\"") { + return substr(str, 1, len - 2); + } + return str; +} + +/* RFC 2617 3.2.2.2 A1 */ +function f_sip_digest_A1(charstring user, charstring realm, charstring password) return charstring { + + /* RFC 2617 3.2.2.2 A1 */ + var charstring A1 := f_sip_str_unquote(user) & ":" & + f_sip_str_unquote(realm) & ":" & + password; + var charstring digestA1 := f_str_tolower(f_calculateMD5(A1)); + log("A1: md5('", A1, "') = ", digestA1); + return digestA1; +} + +/* RFC 2617 3.2.2.2 A2 */ +function f_sip_digest_A2(charstring method, charstring uri) return charstring { + + var charstring A2 := method & ":" & uri + var charstring digestA2 := f_str_tolower(f_calculateMD5(A2)); + log("A2: md5('", A2, "') = ", digestA2); + return digestA2; +} + +/* RFC 2617 3.2.2.1 Request-Digest */ +function f_sip_digest_RequestDigest(charstring digestA1, charstring nonce, + charstring nc, charstring cnonce, + charstring qop, charstring digestA2) return charstring { + var charstring digest_data := f_sip_str_unquote(nonce) & ":" & + nc & ":" & + cnonce & ":" & + f_sip_str_unquote(qop) & ":" & + digestA2; + var charstring req_digest := f_sip_digest_KD(digestA1, digest_data); + log("Request-Digest: md5('", digestA1, ":", digest_data ,"') = ", req_digest); + return req_digest; +} + +/* RFC 2617 3.2.1 The WWW-Authenticate Response Header + * KD(secret, data) = H(concat(secret, ":", data)) + */ +function f_sip_digest_KD(charstring secret, charstring data) return charstring { + return f_str_tolower(f_calculateMD5(secret & ":" & data)); +} + +/* Digest Auth: RFC 2617 */ +function f_sip_digest_gen_Authorization(WwwAuthenticate www_authenticate, + charstring user, charstring password, + charstring method, charstring uri, + charstring cnonce := "0a4f113b", integer nc_int := 1) return Authorization { + var CommaParam_List digestCln; + var template (value) Authorization authorization; + var template (value) Credentials cred; + var template (omit) GenericParam rx_param; + + digestCln := www_authenticate.challenge[0].digestCln; + + var charstring algorithm; + rx_param := f_sip_param_find(digestCln, "algorithm"); + if (istemplatekind(rx_param, "omit")) { + /* Assume MD5 if not set */ + algorithm := "MD5" + } else { + algorithm := valueof(rx_param.paramValue); + if (f_strstr(algorithm, "MD5") == -1) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Unexpected algorithm: ", algorithm)); + } + } + + var charstring realm := f_sip_param_get_value_present_or_fail(digestCln, "realm"); + var charstring nonce := f_sip_param_get_value_present_or_fail(digestCln, "nonce"); + var charstring opaque := f_sip_param_get_value_present_or_fail(digestCln, "opaque"); + var charstring qop := f_sip_param_get_value_present_or_fail(digestCln, "qop"); + + if (f_strstr(qop, "auth") == -1) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected qop: ", qop)); + } + var charstring selected_qop := "auth"; + + /* RFC 2617 3.2.2.2 A1 */ + var charstring digestA1 := f_sip_digest_A1(user, realm, password); + /* RFC 2617 3.2.2.3 A2 */ + var charstring digestA2 := f_sip_digest_A2(method, uri); + + /* RFC 2617 3.2.2.1 Request-Digest */ + var charstring nc := f_str_tolower(hex2str(int2hex(nc_int, 8))); + var charstring req_digest := f_sip_digest_RequestDigest(digestA1, nonce, + nc, cnonce, + selected_qop, digestA2); + + cred := ts_Credentials_DigestResponseMD5(user, realm, nonce, + uri, req_digest, + opaque, algorithm, selected_qop, cnonce, nc); + + authorization := ts_Authorization(cred); + return valueof(authorization); +} + +/* RFC 2617 3.5 Example */ +function f_sip_digest_selftest() { +/* +The following example assumes that an access-protected document is +being requested from the server via a GET request. The URI of the +document is "http://www.nowhere.org/dir/index.html". Both client and +server know that the username for this document is "Mufasa", and the +password is "Circle Of Life" (with one space between each of the +three words). + +HTTP/1.1 401 Unauthorized +WWW-Authenticate: Digest + realm="testrealm(a)host.com", + qop="auth,auth-int", + nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", + opaque="5ccc069c403ebaf9f0171e9517f40e41" + +Authorization: Digest username="Mufasa", + realm="testrealm(a)host.com", + nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", + uri="/dir/index.html", + qop=auth, + nc=00000001, + cnonce="0a4f113b", + response="6629fae49393a05397450978507c4ef1", + opaque="5ccc069c403ebaf9f0171e9517f40e41" +*/ + var template (value) CommaParam_List digestCln := { + ts_Param("realm", f_sip_str_quote("testrealm(a)host.com")), + ts_Param("qop", f_sip_str_quote("auth,auth-int")), + ts_Param("nonce", f_sip_str_quote("dcd98b7102dd2f0e8b11d0f600bfb0c093")), + ts_Param("opaque", f_sip_str_quote("5ccc069c403ebaf9f0171e9517f40e41")) + }; + var template (value) WwwAuthenticate www_authenticate := + ts_WwwAuthenticate( { ts_Challenge_digestCln(digestCln) } ) + + var Authorization authorization := + f_sip_digest_gen_Authorization(valueof(www_authenticate), + "Mufasa", + "Circle Of Life", + "GET", + "/dir/index.html", + cnonce := "0a4f113b", + nc_int := 1); + + var CommaParam_List digestResp := authorization.body.digestResponse; + f_sip_param_match_value_or_fail(digestResp, "realm", f_sip_str_quote("testrealm(a)host.com")); + f_sip_param_match_value_or_fail(digestResp, "nonce", f_sip_str_quote("dcd98b7102dd2f0e8b11d0f600bfb0c093")); + f_sip_param_match_value_or_fail(digestResp, "uri", f_sip_str_quote("/dir/index.html")); + f_sip_param_match_value_or_fail(digestResp, "qop", "auth"); + f_sip_param_match_value_or_fail(digestResp, "nc", "00000001"); + f_sip_param_match_value_or_fail(digestResp, "cnonce", f_sip_str_quote("0a4f113b")); + f_sip_param_match_value_or_fail(digestResp, "response", f_sip_str_quote("6629fae49393a05397450978507c4ef1")); + f_sip_param_match_value_or_fail(digestResp, "opaque", f_sip_str_quote("5ccc069c403ebaf9f0171e9517f40e41")); +} + /* RFC 3261 8.1.1.5: * "The sequence number value MUST be expressible as a 32-bit unsigned integer * and MUST be less than 2**31." @@ -555,4 +998,68 @@ return f_rnd_int(2147483648) } +/* Tags shall have at least 32 bit of randomness */ +function f_sip_rand_tag() return charstring { + var integer rnd_int := f_rnd_int(4294967296); + return hex2str(int2hex(rnd_int, 8)); +} + +/* Generate a "branch" tag value. + * RFC 3261 p.105 section 8: + * "A common way to create this value is to compute a + * cryptographic hash of the To tag, From tag, Call-ID header + * field, the Request-URI of the request received (before + * translation), the topmost Via header, and the sequence number + * from the CSeq header field, in addition to any Proxy-Require + * and Proxy-Authorization header fields that may be present. The + * algorithm used to compute the hash is implementation-dependent, + * but MD5 (RFC 1321 [35]),expressed in hexadecimal, is a reasonable + * choice." + * See also Section 8.1.1.7: + * "The branch ID inserted by an element compliant with this + * specification MUST always begin with the characters "z9hG4bK"." + */ +const charstring sip_magic_cookie := "z9hG4bK"; +function f_sip_gen_branch(charstring tag_to, + charstring tag_from, + charstring tag_call_id, + integer cseq) return charstring { + var charstring str := tag_to & tag_from & tag_call_id & int2str(cseq); + var charstring hash := f_calculateMD5(str); + var charstring branch := sip_magic_cookie & hash; + return branch; +} + +function f_sip_HostPort_to_str(HostPort host_port) return charstring { + var charstring str := ""; + if (ispresent(host_port.host)) { + str := host_port.host; + } + if (ispresent(host_port.portField)) { + str := str & ":" & int2str(host_port.portField); + } + return str; +} + +function f_sip_SipUrl_to_str(SipUrl uri) return charstring { + var charstring str := uri.scheme & f_sip_HostPort_to_str(uri.hostPort); + return str; +} + +function f_sip_NameAddr_to_str(NameAddr naddr) return charstring { + if (ispresent(naddr.displayName)) { + return naddr.displayName & " <" & f_sip_SipUrl_to_str(naddr.addrSpec) & ">"; + } else { + return f_sip_SipUrl_to_str(naddr.addrSpec); + } +} + +function f_sip_SipAddr_to_str(SipAddr sip_addr) return charstring { + if (ischosen(sip_addr.addr.nameAddr)) { + return f_sip_NameAddr_to_str(sip_addr.addr.nameAddr); + } else { + return f_sip_SipUrl_to_str(sip_addr.addr.addrSpecUnion); + } +} + } diff --git a/sip/SIP_Tests.ttcn b/sip/SIP_Tests.ttcn index aee1a82..4c6be1c 100644 --- a/sip/SIP_Tests.ttcn +++ b/sip/SIP_Tests.ttcn @@ -274,7 +274,9 @@ } /* OSC -> SIP */ - as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, + as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, + tr_Via_from(tr_HostPort(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)), + *, "INVITE", 100, ?, "Trying", *)); alt { @@ -328,7 +330,9 @@ SIP.clear; /* 180 Ringing should not contain any SDP. */ - as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, + as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, + tr_Via_from(tr_HostPort(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)), + *, "INVITE", 180, ?, "Ringing", omit)); /* MSC -> OSC: After MT user has picked up and sent CC CONNECT */ @@ -342,7 +346,9 @@ } /* OSC -> SIP: OSC confirms call establishment to SIP side */ - as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, contact := ?, + as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, + tr_Via_from(tr_HostPort(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)), + contact := ?, method := "INVITE", status_code := 200, seq_nr := ?, reason := "OK", body := expect_sdp_to_sip)); @@ -506,7 +512,9 @@ /* MSC -> OSC: Indicate GSM side release */ MNCC.send(ts_MNCC_REL_ind(cp.mncc_call_id, ts_MNCC_cause(0))); /* OSC -> SIP: Confirmation to SIP side */ - as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *, + as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, + tr_Via_from(tr_HostPort(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)), + *, "BYE", 200, cp.comp.sip_seq_nr, "OK", omit)); } diff --git a/sip/gen_links.sh b/sip/gen_links.sh index 81c1578..d12e23c 100755 --- a/sip/gen_links.sh +++ b/sip/gen_links.sh @@ -9,7 +9,8 @@ gen_links $DIR $FILES DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src -FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h" +FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h " +FILES+="TCCOpenSecurity_Functions.ttcn TCCOpenSecurity.cc TCCOpenSecurity_Functions.hh " gen_links $DIR $FILES DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src diff --git a/sip/regen_makefile.sh b/sip/regen_makefile.sh index c7a645d..ecec62b 100755 --- a/sip/regen_makefile.sh +++ b/sip/regen_makefile.sh @@ -17,6 +17,7 @@ SIPmsg_PT.cc TCCConversion.cc TCCInterface.cc + TCCOpenSecurity.cc TELNETasp_PT.cc UD_PT.cc " -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36532?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ib469f1906927a3f246876040086ff115fbf4c032 Gerrit-Change-Number: 36532 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[L] Change in osmo-ttcn3-hacks[master]: asterisk: Implement and test SIP Digest Authorization
by pespin 08 Apr '24

08 Apr '24
Attention is currently required from: fixeria, laforge, osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36532?usp=email ) Change subject: asterisk: Implement and test SIP Digest Authorization ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36532?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ib469f1906927a3f246876040086ff115fbf4c032 Gerrit-Change-Number: 36532 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 08 Apr 2024 15:45:02 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • ...
  • 113
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.