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
[L] Change in osmo-ttcn3-hacks[master]: Asterisk: Initial AMI support
by fixeria 18 Apr '24

18 Apr '24
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email ) Change subject: Asterisk: Initial AMI support ...................................................................... Patch Set 2: (1 comment) File asterisk/AMI_Functions.ttcn: https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594/comment/fbca309d_39ff… PS2, Line 109: var integer pos := f_strstr(str, ": ", 0); Looks like you could use TITAN's TEXT encoder for doing this: ``` type record AMI_Field { charstring key, charstring val } with { encode "TEXT" variant "SEPARATOR(':')" }; type set of AMI_Field AMI_Msg with { encode "TEXT" variant "SEPARATOR('\r\n')" variant "END('\r\n')" }; external function enc_AMI_Msg(in AMI_Msg msg) return charstring with { extension "prototype(convert) encode(TEXT)" } external function dec_AMI_Msg(in charstring stream) return AMI_Msg with { extension "prototype(convert) decode(TEXT)" } ``` See https://gitlab.eclipse.org/eclipse/titan/titan.core/-/blob/master/usrguide/…. Not saying you have to do it this way, but if we can offload some work to TITAN - why not. I have a small self-test: ``` private type component dummy_CT { }; testcase TC_tuwat() runs on dummy_CT { var AMI_Msg msg := { { "field1", "value1" }, { "field2", "value2" }, { "field3", "value3" } }; var charstring text := enc_AMI_Msg(msg); log("AMI msg encoded: ", text); var AMI_Msg msg_dec := dec_AMI_Msg(text); log("AMI msg decoded: ", msg_dec); } ``` and here is the output it produces: ``` MTC@LEGION: AMI msg encoded: "field1:value1\r\nfield2:value2\r\nfield3:value3\r\n" MTC@LEGION: AMI msg decoded: { { key := "field1", val := "value1" }, { key := "field2", val := "value2" }, { key := "field3", val := "value3" } } ``` -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?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: I2c570e4d04e7ab8c44962cf484e4bbc946209aee Gerrit-Change-Number: 36594 Gerrit-PatchSet: 2 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: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 16:31:38 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in docker-playground[master]: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests
by fixeria 18 Apr '24

18 Apr '24
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email ) Change subject: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ibb6af1cbfb652214b2fdd2a6eb9a4887c9a9cfb0 Gerrit-Change-Number: 36595 Gerrit-PatchSet: 1 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: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 16:07:54 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[XL] Change in osmo-ttcn3-hacks[master]: asterisk: Split SIPConnHdlr to its own file
by osmith 18 Apr '24

18 Apr '24
Attention is currently required from: fixeria, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36596?usp=email ) Change subject: asterisk: Split SIPConnHdlr to its own file ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36596?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: I168920887bfd05c0a1785c5cb7ac485edaef0df2 Gerrit-Change-Number: 36596 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 13:49:28 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in docker-playground[master]: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests
by pespin 18 Apr '24

18 Apr '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email ) Change subject: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests ...................................................................... ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests The Asterisk_tests testsuite recently gained initial AMI support. Configure it with the proper IP address. Depends: osmo-ttcn3-hacks.git Change-Id I2c570e4d04e7ab8c44962cf484e4bbc946209aee Change-Id: Ibb6af1cbfb652214b2fdd2a6eb9a4887c9a9cfb0 --- M ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg 1 file changed, 14 insertions(+), 0 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg b/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg index c8744bb..a734c22 100644 --- a/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg +++ b/ttcn3-asterisk-ims-ue-test/Asterisk_Tests.cfg @@ -5,6 +5,7 @@ [LOGGING] [TESTPORT_PARAMETERS] +*.AMI.CTRL_HOSTNAME := "172.18.11.10" *.SIP.default_local_address := "172.18.11.103" *.SIP.local_sip_port := "5060" *.SIP.default_dest_address := "172.18.11.10" -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ibb6af1cbfb652214b2fdd2a6eb9a4887c9a9cfb0 Gerrit-Change-Number: 36595 Gerrit-PatchSet: 1 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: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in docker-playground[master]: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests
by pespin 18 Apr '24

18 Apr '24
Attention is currently required from: fixeria, jolly. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email ) Change subject: ttcn3-asterisk: Set Asterisk AMI IP address in Asterisk_Tests ...................................................................... Patch Set 1: Code-Review+2 (1 comment) Patchset: PS1: Merging together with osmo-ttcn3-hacks.git patch which got merged. -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/36595?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ibb6af1cbfb652214b2fdd2a6eb9a4887c9a9cfb0 Gerrit-Change-Number: 36595 Gerrit-PatchSet: 1 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: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 13:47:48 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmo-ttcn3-hacks[master]: Asterisk: Initial AMI support
by pespin 18 Apr '24

18 Apr '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email ) Change subject: Asterisk: Initial AMI support ...................................................................... Asterisk: Initial AMI support Introduce config and functions around TELNETasp_PT to implement an AMI interface client to interact with Asterisk. So far only the "Action: Login" case is implemented. Change-Id: I2c570e4d04e7ab8c44962cf484e4bbc946209aee --- A asterisk/AMI_Functions.ttcn M asterisk/Asterisk_Tests.default M asterisk/Asterisk_Tests.ttcn M asterisk/gen_links.sh M asterisk/regen_makefile.sh 5 files changed, 257 insertions(+), 1 deletion(-) Approvals: osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified jolly: Looks good to me, but someone else must approve diff --git a/asterisk/AMI_Functions.ttcn b/asterisk/AMI_Functions.ttcn new file mode 100644 index 0000000..53a7964 --- /dev/null +++ b/asterisk/AMI_Functions.ttcn @@ -0,0 +1,212 @@ +/* Asterisk's AMI interface functions in TTCN-3 + * (C) 2024 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Pau Espin Pedrol <pespin(a)sysmocom.de> + * All rights reserved. + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +/* + * https://docs.asterisk.org/Configuration/Interfaces/Asterisk-Manager-Interfa… + */ +module AMI_Functions { + +import from Misc_Helpers all; +import from TELNETasp_PortType all; +import from Osmocom_Types all; +import from TCCConversion_Functions all; +import from Socket_API_Definitions all; + +modulepar { + float mp_ami_prompt_timeout := 10.0; +} + +const charstring AMI_FIELD_ACTION := "Action"; +const charstring AMI_FIELD_USERNAME := "Username"; +const charstring AMI_FIELD_SECRET := "Secret"; +const charstring AMI_FIELD_RESPONSE := "Response"; + +type record AMI_Field { + charstring key, + charstring val +}; +type set of AMI_Field AMI_Msg; + +template (value) AMI_Field +ts_AMI_Field(template (value) charstring key, + template (value) charstring val) := { + key := key, + val := val +}; + +template (present) AMI_Field +tr_AMI_Field(template (present) charstring key := ?, + template (present) charstring val := ?) := { + key := key, + val := val +}; + +/* + * Field Templates: + */ + +template (value) AMI_Field +ts_AMI_Field_Action(template (value) charstring val) := ts_AMI_Field(AMI_FIELD_ACTION, val); +template (value) AMI_Field +ts_AMI_Field_Username(template (value) charstring val) := ts_AMI_Field(AMI_FIELD_USERNAME, val); +template (value) AMI_Field +ts_AMI_Field_Secret(template (value) charstring val) := ts_AMI_Field(AMI_FIELD_SECRET, val); + +template (present) AMI_Field +tr_AMI_Field_Action(template (present) charstring val := ?) := tr_AMI_Field(AMI_FIELD_ACTION, val); +template (present) AMI_Field +tr_AMI_Field_Username(template (present) charstring val := ?) := tr_AMI_Field(AMI_FIELD_USERNAME, val); +template (present) AMI_Field +tr_AMI_Field_Secret(template (present) charstring val := ?) := tr_AMI_Field(AMI_FIELD_SECRET, val); +template (present) AMI_Field +tr_AMI_Field_Response(template (present) charstring val := ?) := tr_AMI_Field(AMI_FIELD_RESPONSE, val); + + +template (present) AMI_Field +tr_AMI_Field_ResponseSuccess := tr_AMI_Field(AMI_FIELD_RESPONSE, "Success"); + + +/* + * Message Templates: + */ + +template (value) AMI_Msg +ts_AMI_Action_Login(charstring username, charstring secret) := { + ts_AMI_Field_Action("Login"), + ts_AMI_Field_Username(username), + ts_AMI_Field_Secret(secret) +}; + +template (present) AMI_Msg +tr_AMI_Action_Login(template(present) charstring username := ?, + template(present) charstring secret := ?) := superset( + tr_AMI_Field_Action("Login"), + tr_AMI_Field_Username(username), + tr_AMI_Field_Secret(secret) +); + +template (present) AMI_Msg +tr_AMI_Response_Success := superset( + tr_AMI_Field_ResponseSuccess +); + +/* + * Functions: + */ + +function f_AMI_Field_from_str(charstring str) return AMI_Field { + var AMI_Field field; + /* "each field is a key value pair delineated by a ':'. + * A single space MUST follow the ':' and precede the value. "*/ + var integer pos := f_strstr(str, ": ", 0); + if (pos < 0) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Failed parsing AMI_Field: ", str)); + } + field.key := substr(str, 0, pos); + /* skip ": " */ + pos := pos + 2; + field.val := substr(str, pos, lengthof(str) - pos); + return field; +} + +function f_AMI_Msg_from_str(charstring str) return AMI_Msg { + var AMI_Msg msg := {}; + var Misc_Helpers.ro_charstring lines := f_str_split(str, "\n"); + + for (var integer i := 0; i < lengthof(lines); i := i + 1) { + var charstring line := lines[i]; + var AMI_Field field := f_AMI_Field_from_str(lines[i]); + msg := msg & { field }; + } + return msg; +} + +function f_AMI_Field_to_str(AMI_Field field) return charstring { + return field.key & ": " & field.val; +} + +function f_AMI_Msg_to_str(AMI_Msg msg) return charstring { + var charstring str := ""; + + for (var integer i := 0; i < lengthof(msg); i := i + 1) { + str := str & f_AMI_Field_to_str(msg[i]) & "\r\n"; + } + + str := str & "\r\n"; + return str; +} + +private function f_ami_wait_for_prompt_str(TELNETasp_PT pt, charstring log_label := "(?)") +return charstring { + var charstring rx, buf := ""; + var integer fd; + timer T; + + T.start(mp_ami_prompt_timeout); + alt { + [] pt.receive(pattern "\n") { }; + [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat }; + [] pt.receive(integer:?) -> value fd { + if (fd == -1) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + "AMI Telnet Connection Failure: " & log_label); + } else { + repeat; /* telnet connection succeeded */ + } + } + [] T.timeout { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + "AMI Timeout for prompt: " & log_label); + }; + } + T.stop; + return buf; +} + +function f_ami_wait_for_prompt(TELNETasp_PT pt, charstring log_label := "(?)") return AMI_Msg { + var charstring buf := f_ami_wait_for_prompt_str(pt, log_label); + var AMI_Msg msg := f_AMI_Msg_from_str(buf); + return msg; +} + +/* send a AMI command and obtain response until prompt is received */ +private function f_ami_transceive_ret_str(TELNETasp_PT pt, charstring tx) return charstring { + pt.send(tx); + return f_ami_wait_for_prompt_str(pt, tx); +} + +function f_ami_transceive_ret(TELNETasp_PT pt, template (value) AMI_Msg tx_msg) return AMI_Msg { + var charstring tx_txt := f_AMI_Msg_to_str(valueof(tx_msg)); + var charstring resp_txt := f_ami_transceive_ret_str(pt, tx_txt); + return f_AMI_Msg_from_str(resp_txt); +} + +function f_ami_transceive_match(TELNETasp_PT pt, + template (value) AMI_Msg tx_msg, + template (present) AMI_Msg exp_ret := ?) { + var AMI_Msg ret := f_ami_transceive_ret(pt, tx_msg); + if (not match(ret, exp_ret)) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Non-matching AMI response: ", ret, " vs exp: ", exp_ret)); + } +} + +function f_ami_transceive_match_response_success(TELNETasp_PT pt, + template (value) AMI_Msg tx_msg) { + f_ami_transceive_match(pt, tx_msg, tr_AMI_Response_Success); +} + +function f_ami_action_login(TELNETasp_PT pt, charstring username, charstring secret) { + f_ami_transceive_match_response_success(pt, ts_AMI_Action_Login(username, secret)); +} + +} diff --git a/asterisk/Asterisk_Tests.default b/asterisk/Asterisk_Tests.default index a2fda0f..0996545 100644 --- a/asterisk/Asterisk_Tests.default +++ b/asterisk/Asterisk_Tests.default @@ -4,13 +4,24 @@ mtc.FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; [TESTPORT_PARAMETERS] +*.*.DEBUG := "yes" +*.AMI.PROMPT1 := "Asterisk Call Manager/9.0.0\n" +*.AMI.PROMPT2 := "\n" +#*.AMI.REGEX_PROMPT1 := "^Asterisk Call Manager.*$" +*.AMI.CTRL_MODE := "client" +*.AMI.CTRL_HOSTNAME := "127.0.0.1" +*.AMI.CTRL_PORTNUM := "5038" +*.AMI.CTRL_LOGIN_SKIPPED := "yes" +*.AMI.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.AMI.CTRL_READMODE := "buffered" +*.AMI.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.AMI.CTRL_CRLF := "yes" *.SIP.local_sip_port := "5060" *.SIP.default_local_address := "127.0.0.2" *.SIP.default_sip_protocol := "UDP" *.SIP.default_dest_port := "5060" *.SIP.default_dest_address := "127.0.0.1" - [MODULE_PARAMETERS] [MAIN_CONTROLLER] diff --git a/asterisk/Asterisk_Tests.ttcn b/asterisk/Asterisk_Tests.ttcn index 151041d..c883bac 100644 --- a/asterisk/Asterisk_Tests.ttcn +++ b/asterisk/Asterisk_Tests.ttcn @@ -16,6 +16,8 @@ import from Osmocom_Types all; import from Native_Functions all; import from Misc_Helpers all; +import from TELNETasp_PortType all; +import from AMI_Functions all; import from SDP_Types all; import from SDP_Templates all; @@ -29,6 +31,10 @@ integer mp_local_sip_port := 5060; charstring mp_remote_sip_host := "127.0.0.1"; integer mp_remote_sip_port := 5060; + + /* Asterisk AMI: */ + charstring mp_ami_user := "test_user"; + charstring mp_ami_secret := "1234"; } type port Coord_PT message @@ -44,6 +50,7 @@ type component test_CT { var SIP_Emulation_CT vc_SIP; + port TELNETasp_PT AMI; port Coord_PT COORD; } @@ -159,7 +166,14 @@ mt := t_CallParsMT } +/* Initialize connection towards Asterisk AMI */ +private function f_init_ami() runs on test_CT { + map(self:AMI, system:AMI); + f_ami_action_login(AMI, mp_ami_user, mp_ami_secret); +} + function f_init() runs on test_CT { + f_init_ami(); f_init_sip(vc_SIP, "Asterisk_Test"); log("end of f_init"); } diff --git a/asterisk/gen_links.sh b/asterisk/gen_links.sh index 7394b64..97df3a2 100755 --- a/asterisk/gen_links.sh +++ b/asterisk/gen_links.sh @@ -18,6 +18,10 @@ FILES="IPL4asp_Functions.ttcn IPL4asp_PT.cc IPL4asp_PT.hh IPL4asp_PortType.ttcn IPL4asp_Types.ttcn IPL4asp_discovery.cc IPL4asp_protocol_L234.hh" gen_links $DIR $FILES +DIR=$BASEDIR/titan.TestPorts.TELNETasp/src +FILES="TELNETasp_PT.cc TELNETasp_PT.hh TELNETasp_PortType.ttcn" +gen_links $DIR $FILES + DIR=$BASEDIR/titan.ProtocolModules.SDP/src FILES="SDP_EncDec.cc SDP_Types.ttcn SDP_parse_.tab.c SDP_parse_.tab.h SDP_parse_parser.h SDP_parser.l SDP_parser.y lex.SDP_parse_.c" diff --git a/asterisk/regen_makefile.sh b/asterisk/regen_makefile.sh index 3cd0a66..1aa18ae 100755 --- a/asterisk/regen_makefile.sh +++ b/asterisk/regen_makefile.sh @@ -15,6 +15,7 @@ TCCConversion.cc TCCInterface.cc TCCOpenSecurity.cc + TELNETasp_PT.cc " ../regen-makefile.sh -e $NAME $FILES -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?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: I2c570e4d04e7ab8c44962cf484e4bbc946209aee Gerrit-Change-Number: 36594 Gerrit-PatchSet: 2 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: Initial AMI support
by pespin 18 Apr '24

18 Apr '24
Attention is currently required from: fixeria, laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email ) Change subject: Asterisk: Initial AMI support ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?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: I2c570e4d04e7ab8c44962cf484e4bbc946209aee Gerrit-Change-Number: 36594 Gerrit-PatchSet: 2 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: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 13:46:52 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmo-netif[master]: stream_{cli,srv}: Add 'res' param to read_cb2
by pespin 18 Apr '24

18 Apr '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36574?usp=email ) Change subject: stream_{cli,srv}: Add 'res' param to read_cb2 ...................................................................... stream_{cli,srv}: Add 'res' param to read_cb2 Notify user about read errors, similar to what is supported in the earlier ofd cb backend of osmo_stream_cli/srv: https://osmocom.org/issues/6405#note-15 Related: OS#6405 Fixes: 5fec34a9f20c3b8769373d1b28ae2062e5e2bdd6 Fixes: 0245cf5e07855abea72693272c55b50b5a93aff4 Change-Id: I395c75ff1e9904757ce1d767a9ac2f779593c4c8 --- M examples/ipa-stream-client.c M examples/ipa-stream-server.c M examples/stream-client.c M examples/stream-server.c M include/osmocom/netif/stream.h M src/stream_cli.c M src/stream_srv.c M tests/stream/stream_test.c 8 files changed, 176 insertions(+), 58 deletions(-) Approvals: jolly: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c index 720fe66..b58370e 100644 --- a/examples/ipa-stream-client.c +++ b/examples/ipa-stream-client.c @@ -102,13 +102,19 @@ return 0; } -static int read_cb(struct osmo_stream_cli *conn, struct msgb *msg) +static int read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg) { int num; struct msg_sent *cur, *tmp, *found = NULL; LOGP(DIPATEST, LOGL_DEBUG, "received message from stream (payload len=%d)\n", msgb_length(msg)); + if (res <= 0) { + LOGP(DIPATEST, LOGL_ERROR, "Event with no data! %d\n", res); + msgb_free(msg); + return 0; + } + if (osmo_ipa_process_msg(msg) < 0) { LOGP(DIPATEST, LOGL_ERROR, "bad IPA message\n"); msgb_free(msg); diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c index 5317921..e87eab4 100644 --- a/examples/ipa-stream-server.c +++ b/examples/ipa-stream-server.c @@ -47,8 +47,15 @@ exit(EXIT_SUCCESS); } -int read_cb(struct osmo_stream_srv *conn, struct msgb *msg) +int read_cb(struct osmo_stream_srv *conn, int res, struct msgb *msg) { + if (res <= 0) { + LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message (%d)\n", res); + msgb_free(msg); + osmo_stream_srv_destroy(conn); + return -EBADF; + } + LOGP(DSTREAMTEST, LOGL_DEBUG, "received message from stream (payload len=%d)\n", msgb_length(msg)); osmo_ipa_msg_push_headers(msg, osmo_ipa_msgb_cb_proto(msg), osmo_ipa_msgb_cb_proto_ext(msg)); diff --git a/examples/stream-client.c b/examples/stream-client.c index cae0153..6d20263 100644 --- a/examples/stream-client.c +++ b/examples/stream-client.c @@ -54,10 +54,17 @@ return 0; } -static int read_cb(struct osmo_stream_cli *conn, struct msgb *msg) +static int read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg) { LOGP(DSTREAMTEST, LOGL_NOTICE, "receiving message from stream... "); + if (res < 0) { + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message (res = %d)\n", res); + msgb_free(msg); + return 0; + } + + LOGPC(DSTREAMTEST, LOGL_NOTICE, "got %d bytes: %s\n", msg->len, msgb_hexdump(msg)); msgb_free(msg); diff --git a/examples/stream-server.c b/examples/stream-server.c index f6332dc..5295c2b 100644 --- a/examples/stream-server.c +++ b/examples/stream-server.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include <osmocom/core/select.h> #include <osmocom/core/socket.h> @@ -44,10 +45,20 @@ signal(SIGINT, SIG_DFL); } -int read_cb(struct osmo_stream_srv *conn, struct msgb *msg) +int read_cb(struct osmo_stream_srv *conn, int res, struct msgb *msg) { LOGP(DSTREAMTEST, LOGL_NOTICE, "receiving message from stream... "); + if (res <= 0) { + if (res < 0) + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message: %s\n", strerror(-res)); + else + LOGPC(DSTREAMTEST, LOGL_ERROR, "client closed connection\n"); + msgb_free(msg); + osmo_stream_srv_destroy(conn); + return -EBADF; + } + LOGPC(DSTREAMTEST, LOGL_NOTICE, "got %d bytes: %s\n", msg->len, msgb_hexdump(msg)); msgb_free(msg); diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 398b277..3c4ec7e 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -102,7 +102,14 @@ typedef int (*osmo_stream_srv_read_cb_t)(struct osmo_stream_srv *conn); typedef int (*osmo_stream_srv_closed_cb_t)(struct osmo_stream_srv *conn); -typedef int (*osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, struct msgb *msg); + +/*! Completion call-back function when something was read from from the stream client socket. + * \param[in] conn Stream Server that got receive event. + * \param[in] res return value of the read()/recvmsg()/... call, or -errno in case of error. + * \param[in] msg message buffer containing the read data. Ownership is transferred to the + * call-back, and it must make sure to msgb_free() it eventually! */ +typedef int (*osmo_stream_srv_read_cb2_t)(struct osmo_stream_srv *conn, int res, struct msgb *msg); + typedef int (*osmo_stream_srv_segmentation_cb_t)(struct msgb *msg); struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, @@ -172,7 +179,14 @@ typedef int (*osmo_stream_cli_connect_cb_t)(struct osmo_stream_cli *cli); typedef int (*osmo_stream_cli_disconnect_cb_t)(struct osmo_stream_cli *cli); typedef int (*osmo_stream_cli_read_cb_t)(struct osmo_stream_cli *cli); -typedef int (*osmo_stream_cli_read_cb2_t)(struct osmo_stream_cli *cli, struct msgb *msg); + +/*! Completion call-back function when something was read from from the stream client socket. + * \param[in] cli Stream Client that got receive event. + * \param[in] res return value of the read()/recvmsg()/... call, or -errno in case of error. + * \param[in] msg message buffer containing the read data. Ownership is transferred to the + * call-back, and it must make sure to msgb_free() it eventually! */ +typedef int (*osmo_stream_cli_read_cb2_t)(struct osmo_stream_cli *cli, int res, struct msgb *msg); + typedef int (*osmo_stream_cli_segmentation_cb_t)(struct msgb *msg); void osmo_stream_cli_set_name(struct osmo_stream_cli *cli, const char *name); diff --git a/src/stream_cli.c b/src/stream_cli.c index 62ea03e..d4067d6 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -448,14 +448,23 @@ stream_cli_handle_connecting(cli, res); break; case STREAM_CLI_STATE_CONNECTED: - if (res <= 0) { - LOGSCLI(cli, LOGL_NOTICE, "received result %d in response to read\n", res); + switch (res) { + case -EPIPE: + case -ECONNRESET: + LOGSCLI(cli, LOGL_ERROR, "lost connection with srv (%d)\n", res); osmo_stream_cli_reconnect(cli); - msgb_free(msg); + break; + case 0: + LOGSCLI(cli, LOGL_NOTICE, "connection closed with srv\n"); + osmo_stream_cli_reconnect(cli); + break; + default: + LOGSCLI(cli, LOGL_DEBUG, "received %d bytes from srv\n", res); break; } + /* Notify user of new data or error: */ if (cli->iofd_read_cb) - cli->iofd_read_cb(cli, msg); + cli->iofd_read_cb(cli, res, msg); else msgb_free(msg); break; @@ -503,15 +512,22 @@ stream_cli_handle_connecting(cli, res); break; case STREAM_CLI_STATE_CONNECTED: - if (res <= 0) { - LOGSCLI(cli, LOGL_NOTICE, "received result %d in response to recvmsg\n", res); + switch (res) { + case -EPIPE: + case -ECONNRESET: + LOGSCLI(cli, LOGL_ERROR, "lost connection with srv (%d)\n", res); osmo_stream_cli_reconnect(cli); - msgb_free(msg); + break; + case 0: + LOGSCLI(cli, LOGL_NOTICE, "connection closed with srv\n"); + osmo_stream_cli_reconnect(cli); + break; + default: break; } - /* Forward message to read callback, also if the connection failed. */ + /* Notify user of new data or error: */ if (cli->iofd_read_cb) - cli->iofd_read_cb(cli, msg); + cli->iofd_read_cb(cli, res, msg); else msgb_free(msg); break; diff --git a/src/stream_srv.c b/src/stream_srv.c index 74193a4..dad6b7a 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -611,26 +611,31 @@ static void stream_srv_iofd_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { struct osmo_stream_srv *conn = osmo_iofd_get_data(iofd); - LOGSSRV(conn, LOGL_DEBUG, "message received (res=%d)\n", res); - if (OSMO_UNLIKELY(res <= 0)) { - /* This connection is dead, destroy it. */ - msgb_free(msg); - osmo_stream_srv_destroy(conn); - } else { - if (conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY) { - LOGSSRV(conn, LOGL_INFO, "Connection is being flushed and closed; ignoring received message\n"); - msgb_free(msg); - if (osmo_iofd_txqueue_len(iofd) == 0) - osmo_stream_srv_destroy(conn); - return; - } - - if (conn->iofd_read_cb) - conn->iofd_read_cb(conn, msg); - else - msgb_free(msg); + switch (res) { + case -EPIPE: + case -ECONNRESET: + LOGSSRV(conn, LOGL_ERROR, "lost connection with client (%d)\n", res); + break; + case 0: + LOGSSRV(conn, LOGL_NOTICE, "connection closed with client\n"); + break; + default: + LOGSSRV(conn, LOGL_DEBUG, "received %d bytes from client\n", res); + break; } + if (OSMO_UNLIKELY(conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY)) { + LOGSSRV(conn, LOGL_INFO, "Connection is being flushed and closed; ignoring received message\n"); + msgb_free(msg); + if (osmo_iofd_txqueue_len(iofd) == 0) + osmo_stream_srv_destroy(conn); + return; + } + + if (conn->iofd_read_cb) + conn->iofd_read_cb(conn, res, msg); + else + msgb_free(msg); } static void stream_srv_iofd_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) @@ -658,27 +663,32 @@ LOGSSRV(conn, LOGL_DEBUG, "message received (res=%d)\n", res); res = stream_iofd_sctp_recvmsg_trailer(iofd, msg, res, msgh); - if (res == -EAGAIN) - return; - if (OSMO_UNLIKELY(res <= 0)) { - /* This connection is dead, destroy it. */ - msgb_free(msg); - osmo_stream_srv_destroy(conn); - } else { - if (conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY) { - LOGSSRV(conn, LOGL_INFO, "Connection is being flushed and closed; ignoring received message\n"); - msgb_free(msg); - if (osmo_iofd_txqueue_len(iofd) == 0) - osmo_stream_srv_destroy(conn); - return; - } - - if (conn->iofd_read_cb) - conn->iofd_read_cb(conn, msg); - else - msgb_free(msg); + switch (res) { + case -EPIPE: + case -ECONNRESET: + LOGSSRV(conn, LOGL_ERROR, "lost connection with client (%d)\n", res); + break; + case 0: + LOGSSRV(conn, LOGL_NOTICE, "connection closed with client\n"); + break; + default: + if (OSMO_LIKELY(res > 0)) + LOGSSRV(conn, LOGL_DEBUG, "received %u bytes from client\n", res); + break; } + if (OSMO_UNLIKELY(conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY)) { + LOGSSRV(conn, LOGL_INFO, "Connection is being flushed and closed; ignoring received message\n"); + msgb_free(msg); + if (osmo_iofd_txqueue_len(iofd) == 0) + osmo_stream_srv_destroy(conn); + return; + } + + if (conn->iofd_read_cb) + conn->iofd_read_cb(conn, res, msg); + else + msgb_free(msg); } static const struct osmo_io_ops srv_ioops_sctp = { diff --git a/tests/stream/stream_test.c b/tests/stream/stream_test.c index d73dd1d..6e849ca 100644 --- a/tests/stream/stream_test.c +++ b/tests/stream/stream_test.c @@ -502,12 +502,19 @@ static struct osmo_timer_list fragmented_send_tl_cli; -static int test_segm_ipa_stream_srv_cli_read_cb(struct osmo_stream_cli *osc, struct msgb *msg) +static int test_segm_ipa_stream_srv_cli_read_cb(struct osmo_stream_cli *osc, int res, struct msgb *msg) { unsigned char *data; struct ipa_head *h = (struct ipa_head *) msg->l1h; uint8_t ipac_msg_type = *msg->data; struct msgb *reply; + + if (res < 0) { + fprintf(stderr, "cannot receive message (res = %d)\n", res); + msgb_free(msg); + return -ENOMSG; + } + LOGCLI(osc, "Received message from stream (payload len = %" PRIu16 ")\n", msgb_length(msg)); if (ipac_msg_type < 0 || 5 < ipac_msg_type) { fprintf(stderr, "Received unexpected IPAC message type %"PRIu8"\n", ipac_msg_type); @@ -566,7 +573,7 @@ return osc; } -int test_segm_ipa_stream_srv_srv_read_cb(struct osmo_stream_srv *conn, struct msgb *msg) +int test_segm_ipa_stream_srv_srv_read_cb(struct osmo_stream_srv *conn, int res, struct msgb *msg) { static unsigned msgnum_srv = 0; struct ipa_head *ih = (struct ipa_head *)msg->l1h; @@ -574,6 +581,16 @@ struct msgb *m; uint8_t msgt; + if (res <= 0) { + if (res < 0) + LOGSRV(conn, "cannot receive message: %s\n", strerror(-res)); + else + LOGSRV(conn, "client closed connection\n"); + msgb_free(msg); + osmo_stream_srv_destroy(conn); + return -EBADF; + } + LOGSRV(conn, "[%u-srv] Received IPA message from stream (payload len = %" PRIu16 ")\n", ++msgnum_srv, msgb_length(msg)); LOGSRV(conn, "\tmsg buff data (including stripped headers): %s\n", @@ -699,12 +716,26 @@ osmo_timer_schedule(&fragmented_send_tl_srv_destroy, 0, 2); } -int test_segm_ipa_stream_cli_srv_read_cb(struct osmo_stream_srv *conn, struct msgb *msg) +int test_segm_ipa_stream_cli_srv_read_cb(struct osmo_stream_srv *conn, int res, struct msgb *msg) { unsigned char *data; struct ipa_head *h = (struct ipa_head *) msg->l1h; - uint8_t ipa_msg_type = ((uint8_t *)h)[sizeof(struct ipa_head)]; - struct msgb *reply = msgb_alloc_headroom(128, 0, "IPA reply"); + uint8_t ipa_msg_type; + struct msgb *reply; + + if (res <= 0) { + if (res < 0) + LOGSRV(conn, "cannot receive message: %s\n", strerror(-res)); + else + LOGSRV(conn, "client closed connection\n"); + msgb_free(msg); + osmo_stream_srv_destroy(conn); + return -EBADF; + } + + ipa_msg_type = ((uint8_t *)h)[sizeof(struct ipa_head)]; + + reply = msgb_alloc_headroom(128, 0, "IPA reply"); if (reply == NULL) { fprintf(stderr, "Cannot allocate message\n"); return -ENOMEM; @@ -778,7 +809,7 @@ static bool test_segm_ipa_stream_cli_all_msgs_processed = false; -static int test_segm_ipa_stream_cli_cli_read_cb(struct osmo_stream_cli *osc, struct msgb *msg) +static int test_segm_ipa_stream_cli_cli_read_cb(struct osmo_stream_cli *osc, int res, struct msgb *msg) { static unsigned msgnum_cli = 0; unsigned char *data; -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36574?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I395c75ff1e9904757ce1d767a9ac2f779593c4c8 Gerrit-Change-Number: 36574 Gerrit-PatchSet: 5 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
[M] Change in libosmo-netif[master]: stream_{cli,srv}: Add 'res' param to read_cb2
by pespin 18 Apr '24

18 Apr '24
Attention is currently required from: laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36574?usp=email ) Change subject: stream_{cli,srv}: Add 'res' param to read_cb2 ...................................................................... Patch Set 5: Code-Review+2 (1 comment) Patchset: PS5: MSC_Tests also passed fine (216 success, 1 more than last nightly in jenkins). I'm merging this one now and I'll retrigger the dependant patches gerrit-jenkins job after OBS have built them. -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36574?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I395c75ff1e9904757ce1d767a9ac2f779593c4c8 Gerrit-Change-Number: 36574 Gerrit-PatchSet: 5 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: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 18 Apr 2024 13:45:58 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmo-sccp[master]: ss7_asp: Update osmo_stream read_cb2 functions to accommodate for new...
by jolly 18 Apr '24

18 Apr '24
Attention is currently required from: fixeria, pespin. jolly has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/36575?usp=email ) Change subject: ss7_asp: Update osmo_stream read_cb2 functions to accommodate for new API param ...................................................................... Patch Set 6: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/36575?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: I579f4101a9e2874e310ff78e4571f38cfe8dfab0 Gerrit-Change-Number: 36575 Gerrit-PatchSet: 6 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: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 18 Apr 2024 13:39:40 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • ...
  • 113
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.