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

February 2024

  • 1 participants
  • 1748 discussions
[M] Change in ...osmo-epdg[master]: WIP: Initial gtp tunnel implementation
by pespin 27 Feb '24

27 Feb '24
pespin has abandoned this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35610?usp=email ) Change subject: WIP: Initial gtp tunnel implementation ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35610?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I1cb5a88b714242d579aac22cc13a2474abb195c6 Gerrit-Change-Number: 35610 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: abandon
1 0
0 0
[M] Change in ...osmo-epdg[master]: Forward PCO from GSUP ePDG Tunnel Req to SMF CreateSessionRequest
by pespin 27 Feb '24

27 Feb '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36053?usp=email ) Change subject: Forward PCO from GSUP ePDG Tunnel Req to SMF CreateSessionRequest ...................................................................... Forward PCO from GSUP ePDG Tunnel Req to SMF CreateSessionRequest A patch in gtplib was submitted to make it possible to encode/decode PCO payload. Related: OS#6369 Change-Id: I51fba731e77c77a95b9310820ec7116f0e5abf8b --- M rebar.lock M src/epdg_gtpc_s2b.erl M src/epdg_ue_fsm.erl M src/gsup_server.erl 4 files changed, 61 insertions(+), 26 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/rebar.lock b/rebar.lock index da93a4f..79503ee 100644 --- a/rebar.lock +++ b/rebar.lock @@ -21,6 +21,10 @@ {git,"https://github.com/osmocom/gtp_u_kmod", {ref,"b3656ebb11528a2db3171dbf94f1a8bf0d6ffd00"}}, 0}, + {<<"gtplib">>, + {git,"https://github.com/osmocom/gtplib", + {ref,"526a7e5d6ba4e76aaae87c31421f26a71dd79d33"}}, + 0}, {<<"lager">>, {git,"https://github.com/erlang-lager/lager", {ref,"459a3b2cdd9eadd29e5a7ce5c43932f5ccd6eb88"}}, diff --git a/src/epdg_gtpc_s2b.erl b/src/epdg_gtpc_s2b.erl index f635036..a4ab573 100644 --- a/src/epdg_gtpc_s2b.erl +++ b/src/epdg_gtpc_s2b.erl @@ -48,7 +48,7 @@ %% gen_server Function Exports -export([init/1, handle_call/3, handle_cast/2, handle_info/2]). -export([code_change/3]). --export([create_session_req/2, delete_session_req/1]). +-export([create_session_req/3, delete_session_req/1]). %% Application Definitions -define(SERVER, ?MODULE). @@ -142,17 +142,17 @@ lager:error("GTPv2C UDP socket open error: ~w~n", [Reason]) end. -create_session_req(Imsi, Apn) -> - gen_server:call(?SERVER, {gtpc_create_session_req, {Imsi, Apn}}). +create_session_req(Imsi, Apn, APCO) -> + gen_server:call(?SERVER, {gtpc_create_session_req, {Imsi, Apn, APCO}}). delete_session_req(Imsi) -> gen_server:call(?SERVER, {gtpc_delete_session_req, {Imsi}}). -handle_call({gtpc_create_session_req, {Imsi, Apn}}, {Pid, _Tag} = _From, State0) -> +handle_call({gtpc_create_session_req, {Imsi, Apn, APCO}}, {Pid, _Tag} = _From, State0) -> {Sess0, State1} = find_or_new_gtp_session(Imsi, #gtp_session{pid = Pid, apn = list_to_binary(Apn)}, State0), - Req = gen_create_session_request(Sess0, State1), + Req = gen_create_session_request(Sess0, APCO, State1), tx_gtp(Req, State1), State2 = inc_seq_no(State1), lager:debug("Waiting for CreateSessionResponse~n", []), @@ -385,7 +385,15 @@ Sess2 = Sess1#gtp_session{remote_control_tei = RemoteTEIC}, lager:info("s2b: Updated Session after create_session_response: ~p~n", [Sess2]), State1 = update_gtp_session(Sess0, Sess2, State0), - ResInfo = #{ + case maps:find({v2_additional_protocol_configuration_options,0}, Resp#gtp.ie) of + {ok, APCO_dec} -> + lager:debug("s2b: APCO_dec: ~p~n", [APCO_dec]), + APCO = gtp_packet:encode_protocol_config_opts(APCO_dec#v2_additional_protocol_configuration_options.config); + error -> + lager:notice("s2b: APCO not found in CreateSessionResp!~n", []), + APCO = undefined + end, + ResInfo0 = #{ apn => binary_to_list(Sess0#gtp_session.apn), eua => conv:gtp2_paa_to_epdg_eua(Paa), local_teid => Bearer#gtp_bearer.local_data_tei, @@ -393,6 +401,10 @@ remote_ipv4 => IPu4, remote_ipv6 => IPu6 }, + case APCO of + undefined -> ResInfo = ResInfo0; + _ -> ResInfo = maps:put(apco, APCO, ResInfo0) + end, epdg_ue_fsm:received_gtpc_create_session_response(Sess0#gtp_session.pid, {ok, ResInfo}), {noreply, State1} end; @@ -462,6 +474,7 @@ gen_create_session_request(#gtp_session{imsi = Imsi, apn = Apn, local_control_tei = LocalCtlTEI} = Sess, + APCO, #gtp_state{laddr = LocalAddr, laddr_gtpu = LocalAddrGtpu, restart_counter = RCnt, @@ -482,6 +495,7 @@ ipv4 = conv:ip_to_bin(LocalAddrGtpu) } ], + APCO_decoded = gtp_packet:decode_protocol_config_opts(APCO), IEs = [#v2_international_mobile_subscriber_identity{imsi = Imsi}, #v2_serving_network{ plmn_id = gtp_utils:plmn_to_bin(?MCC, ?MNC, ?MNC_SIZE) @@ -497,7 +511,8 @@ #v2_selection_mode{mode = 0}, #v2_pdn_address_allocation{type = ipv4, address = <<0,0,0,0>>}, #v2_bearer_context{group = BearersIE}, - #v2_recovery{restart_counter = RCnt} + #v2_recovery{restart_counter = RCnt}, + #v2_additional_protocol_configuration_options{instance = 0, config = APCO_decoded} ], #gtp{version = v2, type = create_session_request, tei = 0, seq_no = SeqNo, ie = IEs}. diff --git a/src/epdg_ue_fsm.erl b/src/epdg_ue_fsm.erl index 188d461..cf4d280 100644 --- a/src/epdg_ue_fsm.erl +++ b/src/epdg_ue_fsm.erl @@ -41,7 +41,7 @@ -export([start_link/1, stop/1]). -export([init/1,callback_mode/0,terminate/3]). -export([get_server_name_by_imsi/1, get_pid_by_imsi/1]). --export([auth_request/2, lu_request/1, tunnel_request/1, purge_ms_request/1]). +-export([auth_request/2, lu_request/1, tunnel_request/2, purge_ms_request/1]). -export([received_swm_auth_response/2, received_swm_auth_compl_response/2, received_swm_session_termination_answer/2]). -export([received_gtpc_create_session_response/2, received_gtpc_delete_session_response/2, received_gtpc_delete_bearer_request/1]). -export([state_new/3, state_wait_auth_resp/3, state_authenticating/3, state_authenticated/3, @@ -90,10 +90,10 @@ {error, Err} end. -tunnel_request(Pid) -> - lager:info("ue_fsm tunnel_request~n", []), +tunnel_request(Pid, PCO) -> + lager:info("ue_fsm tunnel_request(~p)~n", [PCO]), try - gen_statem:call(Pid, tunnel_request) + gen_statem:call(Pid, {tunnel_request, PCO}) catch exit:Err -> {error, Err} @@ -248,9 +248,9 @@ lager:info("ue_fsm state_authenticated event=auth_request {~p, ~p}, ~p~n", [PdpTypeNr, Apn, Data]), {next_state, state_new, Data, [postpone]}; -state_authenticated({call, From}, tunnel_request, Data) -> +state_authenticated({call, From}, {tunnel_request, PCO}, Data) -> lager:info("ue_fsm state_authenticated event=tunnel_request, ~p~n", [Data]), - epdg_gtpc_s2b:create_session_req(Data#ue_fsm_data.imsi, Data#ue_fsm_data.apn), + epdg_gtpc_s2b:create_session_req(Data#ue_fsm_data.imsi, Data#ue_fsm_data.apn, PCO), {next_state, state_wait_create_session_resp, Data, [{reply,From,ok}]}; state_authenticated({call, From}, purge_ms_request, Data) -> diff --git a/src/gsup_server.erl b/src/gsup_server.erl index 0af015c..1e5173e 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -156,18 +156,21 @@ lager:info("tunnel_response for ~p: ~p~n", [Imsi, Result]), Socket = State#gsups_state.socket, case Result of - {ok, #{apn := Apn, eua := Eua}} -> + {ok, #{apn := Apn, eua := Eua} = Map} -> PdpInfo = #{pdp_context_id => 0, - pdp_address => conv:epdg_eua_to_gsup_pdp_address(Eua), - access_point_name => Apn, - quality_of_service => <<0, 0, 0>>, - pdp_charging => 0}, - Resp = #{message_type => epdg_tunnel_result, - imsi => Imsi, - message_class => 5, - pdp_info_complete => true, - pdp_info_list => [PdpInfo] - }; + pdp_address => conv:epdg_eua_to_gsup_pdp_address(Eua), + access_point_name => Apn, + quality_of_service => <<0, 0, 0>>, + pdp_charging => 0}, + Resp0 = #{message_type => epdg_tunnel_result, + imsi => Imsi, + message_class => 5, + pdp_info_complete => true, + pdp_info_list => [PdpInfo]}, + case maps:find(apco, Map) of + {ok, APCO} -> Resp = maps:put(pco, APCO, Resp0); + error -> Resp = Resp0 + end; {error, _} -> Resp = #{message_type => epdg_tunnel_error, imsi => Imsi, @@ -286,12 +289,12 @@ % epdg tunnel request / trigger the establishment to the PGW and prepares everything for the user traffic to flow % When sending a epdg_tunnel_response everything must be ready for the UE traffic -handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, GsupMsgRx = #{message_type := epdg_tunnel_request, imsi := Imsi}}, State) -> +handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, GsupMsgRx = #{message_type := epdg_tunnel_request, imsi := Imsi, pco := PCO}}, State) -> lager:info("GSUP: Rx ~p~n", [GsupMsgRx]), UE = find_gsups_ue_by_imsi(Imsi, State), case UE of #gsups_ue{imsi = Imsi} -> - case epdg_ue_fsm:tunnel_request(UE#gsups_ue.pid) of + case epdg_ue_fsm:tunnel_request(UE#gsups_ue.pid, PCO) of ok -> ok; {error, _} -> Resp = #{message_type => epdg_tunnel_error, -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36053?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I51fba731e77c77a95b9310820ec7116f0e5abf8b Gerrit-Change-Number: 36053 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in ...osmo-epdg[master]: Forward PCO from GSUP ePDG Tunnel Req to SMF CreateSessionRequest
by pespin 27 Feb '24

27 Feb '24
Attention is currently required from: laforge, lynxis lazus. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36053?usp=email ) Change subject: Forward PCO from GSUP ePDG Tunnel Req to SMF CreateSessionRequest ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/36053?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I51fba731e77c77a95b9310820ec7116f0e5abf8b Gerrit-Change-Number: 36053 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Tue, 27 Feb 2024 13:04:40 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in docker-playground[master]: ttcn3-pgw-test: Configure open5gs-smfd S2b/S6b/P-CSCF related bits
by pespin 27 Feb '24

27 Feb '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/36088?usp=email ) Change subject: ttcn3-pgw-test: Configure open5gs-smfd S2b/S6b/P-CSCF related bits ...................................................................... ttcn3-pgw-test: Configure open5gs-smfd S2b/S6b/P-CSCF related bits Depends: osmo-ttcn3-hacks.git Change-Id I38e469edf0e00feca5a648035b64645e2c905937 Change-Id: I3ff503990167f52ddb94a7719e2773db3f889a39 --- M ttcn3-pgw-test/PGW_Tests.cfg M ttcn3-pgw-test/freeDiameter-smf.conf M ttcn3-pgw-test/open5gs-smf-latest.yaml M ttcn3-pgw-test/open5gs-smf-master.yaml 4 files changed, 20 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/88/36088/1 diff --git a/ttcn3-pgw-test/PGW_Tests.cfg b/ttcn3-pgw-test/PGW_Tests.cfg index d17e782..5d3ff45 100644 --- a/ttcn3-pgw-test/PGW_Tests.cfg +++ b/ttcn3-pgw-test/PGW_Tests.cfg @@ -17,6 +17,7 @@ PGW_Tests.mp_ping_hostname := "10.45.0.1" PGW_Tests.mp_pcrf_local_ip:= "172.18.18.202" PGW_Tests.mp_ocs_local_ip:= "172.18.18.202" +PGW_Tests.mp_aaa_local_ip:= "172.18.18.202" GTPv2_Emulation.mp_uecups_host := "172.18.18.20" [MAIN_CONTROLLER] diff --git a/ttcn3-pgw-test/freeDiameter-smf.conf b/ttcn3-pgw-test/freeDiameter-smf.conf index afa9298..207d1cc 100644 --- a/ttcn3-pgw-test/freeDiameter-smf.conf +++ b/ttcn3-pgw-test/freeDiameter-smf.conf @@ -261,5 +261,5 @@ #ConnectPeer = "old.diameter.serv" { TcTimer = 60; TLS_old_method; No_SCTP; Port=3868; } ; ConnectPeer = "pcrf.localdomain" { ConnectTo = "172.18.18.202"; No_TLS; TcTimer = 2; }; ConnectPeer = "ocs.localdomain" { ConnectTo = "172.18.18.202"; Port = 3869; No_TLS; TcTimer = 2; }; - +ConnectPeer = "aaa.localdomain" { ConnectTo = "172.18.18.202"; Port = 3870; No_TLS; TcTimer = 2; }; ############################################################## diff --git a/ttcn3-pgw-test/open5gs-smf-latest.yaml b/ttcn3-pgw-test/open5gs-smf-latest.yaml index 622618b..0f80467 100644 --- a/ttcn3-pgw-test/open5gs-smf-latest.yaml +++ b/ttcn3-pgw-test/open5gs-smf-latest.yaml @@ -1,7 +1,7 @@ # See https://github.com/open5gs/open5gs/blob/main/configs/open5gs/smf.yaml.in logger: - level: info + level: debug sbi: server: @@ -39,6 +39,9 @@ - 2001:4860:4860::8888 - 2001:4860:4860::8844 mtu: 1400 + p-cscf: + - 172.18.18.7 + - fd02:db8:18::7 ctf: enabled: auto freeDiameter: /data/freeDiameter-smf.conf diff --git a/ttcn3-pgw-test/open5gs-smf-master.yaml b/ttcn3-pgw-test/open5gs-smf-master.yaml index 3448aba..db91145 100644 --- a/ttcn3-pgw-test/open5gs-smf-master.yaml +++ b/ttcn3-pgw-test/open5gs-smf-master.yaml @@ -1,7 +1,7 @@ # See https://github.com/open5gs/open5gs/blob/main/configs/open5gs/smf.yaml.in logger: - level: info + level: debug global: max: @@ -56,6 +56,9 @@ - 2001:4860:4860::8888 - 2001:4860:4860::8844 mtu: 1400 + p-cscf: + - 172.18.18.7 + - fd02:db8:18::7 ctf: enabled: auto freeDiameter: /data/freeDiameter-smf.conf -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/36088?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: I3ff503990167f52ddb94a7719e2773db3f889a39 Gerrit-Change-Number: 36088 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmocore[master]: gsup.h: define newly added PCO IE
by pespin 27 Feb '24

27 Feb '24
Attention is currently required from: lynxis lazus. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36024?usp=email ) Change subject: gsup.h: define newly added PCO IE ...................................................................... Patch Set 3: (2 comments) This change is ready for review. File include/osmocom/gsm/gsup.h: https://gerrit.osmocom.org/c/libosmocore/+/36024/comment/a89bfc8b_a32296d6 PS3, Line 412: const uint8_t *pco; > Should I check for the PCO lenght? I would keep the pointer+length as we do it in most cases in the […] Done File src/gsm/gsup.c: https://gerrit.osmocom.org/c/libosmocore/+/36024/comment/1843b3cc_d3377d8c PS3, Line 881: msgb_tlv_put(msg, OSMO_GSUP_PCO_IE, gsup_msg->pco_len, gsup_msg->pco); Yeah I think we can check for pco_len <= 251 here. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36024?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: I0f9de90c7c67fe194b441a9d118eba70f09afb5e Gerrit-Change-Number: 36024 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Tue, 27 Feb 2024 12:33:26 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Comment-In-Reply-To: lynxis lazus <lynxis(a)fe80.eu> Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-gsm-manuals[master]: gsup: Introduce a new PCO IE
by pespin 27 Feb '24

27 Feb '24
Attention is currently required from: fixeria, laforge, lynxis lazus. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/36023?usp=email ) Change subject: gsup: Introduce a new PCO IE ...................................................................... Patch Set 2: This change is ready for review. -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/36023?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Change-Id: Id912ead4e1205f84a40af6505a5ddf050d1e086d Gerrit-Change-Number: 36023 Gerrit-PatchSet: 2 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: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Tue, 27 Feb 2024 12:29:36 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmo-sccp[master]: osmo_ss7_asp_find_by_name(): improve docs and coding style
by fixeria 27 Feb '24

27 Feb '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/36087?usp=email ) Change subject: osmo_ss7_asp_find_by_name(): improve docs and coding style ...................................................................... osmo_ss7_asp_find_by_name(): improve docs and coding style Change-Id: Ia90776c9c3efc3402d59c4f10e5f2cf26274b3f8 Related: SYS#5424 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c 2 files changed, 18 insertions(+), 7 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve osmith: Looks good to me, approved diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index a8a624f..fc323a8 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -476,9 +476,9 @@ struct osmo_ss7_asp * osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name); -struct osmo_ss7_asp -*osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as, - enum osmo_ss7_asp_protocol proto); +struct osmo_ss7_asp * +osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as, + enum osmo_ss7_asp_protocol proto); struct osmo_ss7_asp * osmo_ss7_asp_find(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index dadb68e..50ad172 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -998,12 +998,13 @@ return NULL; } -/*! \brief Find an ASP that matches the given protocol. +/*! \brief Find an ASP that matches the given ASP protocol (xUA variant). * \param[in] as Application Server in which to look for \ref asp + * \param[in] proto ASP protocol (xUA variant) to match * \returns SS7 ASP in case a matching one is found; NULL otherwise */ -struct osmo_ss7_asp -*osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as, - enum osmo_ss7_asp_protocol proto) +struct osmo_ss7_asp * +osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as, + enum osmo_ss7_asp_protocol proto) { unsigned int i; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/36087?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: Ia90776c9c3efc3402d59c4f10e5f2cf26274b3f8 Gerrit-Change-Number: 36087 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(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> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmo-sccp[master]: VTY: rename 'sctp-role' to 'transport-role', add an alias
by fixeria 27 Feb '24

27 Feb '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35978?usp=email ) Change subject: VTY: rename 'sctp-role' to 'transport-role', add an alias ...................................................................... VTY: rename 'sctp-role' to 'transport-role', add an alias Now that we're adding support for M3UA-over-TCP, the transport layer role is no longer an SCTP specific paremeter, but rather a generic one. This is also the case for the OSMO_SS7_ASP_PROT_IPA, which employs TCP, and for which we can also choose between the client and server role. The 'sctp-role' now becomes an alias to 'transport-role', so that we keep backwards compatibility with old config files. Change-Id: Iab6c898181d79a5ed2bea767ee90e55bc3af16a5 Related: SYS#5424 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7_vty.c M src/sccp_user.c M tests/vty/ss7_asp_test.vty 4 files changed, 53 insertions(+), 27 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve osmith: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 2324532..155e05a 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -433,7 +433,7 @@ bool is_server; enum osmo_ss7_asp_role role; bool role_set_by_vty; - bool sctp_role_set_by_vty; + bool trans_role_set_by_vty; struct osmo_ss7_asp_peer local; struct osmo_ss7_asp_peer remote; diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 42a3383..890dded 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1054,11 +1054,11 @@ return CMD_SUCCESS; } -DEFUN_ATTR(sctp_role, asp_sctp_role_cmd, - "sctp-role (client|server)", - "Specify the SCTP role for this ASP\n" - "Operate as SCTP client; connect to a server\n" - "Operate as SCTP server; wait for client connections\n", +DEFUN_ATTR(asp_transport_role, asp_transport_role_cmd, + "transport-role (client|server)", + "Specify the transport layer role for this ASP\n" + "Operate as a client; connect to a server\n" + "Operate as a server; wait for client connections\n", CMD_ATTR_NODE_EXIT) { struct osmo_ss7_asp *asp = vty->index; @@ -1070,10 +1070,17 @@ else OSMO_ASSERT(0); - asp->cfg.sctp_role_set_by_vty = true; + asp->cfg.trans_role_set_by_vty = true; return CMD_SUCCESS; } +ALIAS_ATTR(asp_transport_role, asp_sctp_role_cmd, + "sctp-role (client|server)", + "Specify the SCTP role for this ASP\n" + "Operate as SCTP client; connect to a server\n" + "Operate as SCTP server; wait for client connections\n", + CMD_ATTR_HIDDEN | CMD_ATTR_NODE_EXIT); + #define ASP_SCTP_PARAM_INIT_DESC \ "Configure SCTP parameters\n" \ "Configure INIT related parameters\n" \ @@ -1719,7 +1726,7 @@ vty_out(vty, " qos-class %u%s", asp->cfg.qos_class, VTY_NEWLINE); vty_out(vty, " role %s%s", osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)), VTY_NEWLINE); - vty_out(vty, " sctp-role %s%s", asp->cfg.is_server ? "server" : "client", VTY_NEWLINE); + vty_out(vty, " transport-role %s%s", asp->cfg.is_server ? "server" : "client", VTY_NEWLINE); if (asp->cfg.sctp_init.num_ostreams_present) vty_out(vty, " sctp-param init num-ostreams %u%s", asp->cfg.sctp_init.num_ostreams_value, VTY_NEWLINE); if (asp->cfg.sctp_init.max_instreams_present) @@ -2984,6 +2991,7 @@ install_lib_element(L_CS7_ASP_NODE, &asp_no_local_ip_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_qos_class_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_role_cmd); + install_lib_element(L_CS7_ASP_NODE, &asp_transport_role_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_sctp_role_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_sctp_param_init_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_no_sctp_param_init_cmd); diff --git a/src/sccp_user.c b/src/sccp_user.c index b72b2a6..1dd3b30 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -636,7 +636,7 @@ if (!asp) goto out_rt; asp_created = true; - /* Ensure that the ASP we use is set to sctp-role client. */ + /* Ensure that the ASP we use is set to operate as a client. */ asp->cfg.is_server = false; /* Ensure that the ASP we use is set to role ASP. */ asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP; @@ -655,7 +655,7 @@ /* Extra sanity checks if the ASP asp-clnt-* was pre-configured over VTY: */ if (!asp->simple_client_allocated) { /* Forbid ASPs defined through VTY that are not entirely - * configured. "role" and "sctp-role" must be explicitly provided: + * configured. "role" and "transport-role" must be explicitly provided: */ if (!asp->cfg.role_set_by_vty) { LOGP(DLSCCP, LOGL_ERROR, @@ -663,9 +663,9 @@ name, asp->cfg.name); goto out_asp; } - if (!asp->cfg.sctp_role_set_by_vty) { + if (!asp->cfg.trans_role_set_by_vty) { LOGP(DLSCCP, LOGL_ERROR, - "%s: ASP %s defined in VTY but 'sctp-role' was not set there, please set it.\n", + "%s: ASP %s defined in VTY but 'transport-role' was not set there, please set it.\n", name, asp->cfg.name); goto out_asp; } @@ -673,19 +673,19 @@ /* If ASP was configured through VTY it may be explicitly configured as * SCTP server. It may be a bit confusing since this function is to create * a "SCCP simple client", but this allows users of this API such as - * osmo-hnbgw to support SCTP-role server if properly configured through VTY. + * osmo-hnbgw to support transport-role server if properly configured through VTY. */ if (asp->cfg.is_server) { struct osmo_xua_server *xs; LOGP(DLSCCP, LOGL_NOTICE, - "%s: Requesting an SCCP simple client on ASP %s configured with 'sctp-role server'\n", + "%s: Requesting an SCCP simple client on ASP %s configured with 'transport-role server'\n", name, asp->cfg.name); xs = osmo_ss7_xua_server_find2(ss7, asp->cfg.trans_proto, prot, asp->cfg.local.port); if (!xs) { LOGP(DLSCCP, LOGL_ERROR, "%s: Requesting an SCCP simple client on ASP %s configured " - "with 'sctp-role server' but no matching xUA server was configured!\n", + "with 'transport-role server' but no matching xUA server was configured!\n", name, asp->cfg.name); goto out_asp; } diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index 7b36009..b8df809 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -257,7 +257,7 @@ no local-ip (A.B.C.D|X:X::X:X) qos-class <0-255> role (sg|asp|ipsp) - sctp-role (client|server) + transport-role (client|server) sctp-param init (num-ostreams|max-instreams|max-attempts|timeout) <0-65535> no sctp-param init (num-ostreams|max-instreams|max-attempts|timeout) block @@ -266,16 +266,16 @@ ss7_asp_vty_test(config-cs7-asp)# ? ... - description Save human-readable description of the object - remote-ip Specify Remote IP Address of ASP - no Negate a command or set its defaults - local-ip Specify Local IP Address from which to contact ASP - qos-class Specify QoS Class of ASP - role Specify the xUA role for this ASP - sctp-role Specify the SCTP role for this ASP - sctp-param Configure SCTP parameters - block Allows a SCTP Association with ASP, but doesn't let it become active - shutdown Terminates SCTP association; New associations will be rejected + description Save human-readable description of the object + remote-ip Specify Remote IP Address of ASP + no Negate a command or set its defaults + local-ip Specify Local IP Address from which to contact ASP + qos-class Specify QoS Class of ASP + role Specify the xUA role for this ASP + transport-role Specify the transport layer role for this ASP + sctp-param Configure SCTP parameters + block Allows a SCTP Association with ASP, but doesn't let it become active + shutdown Terminates SCTP association; New associations will be rejected ... ss7_asp_vty_test(config-cs7-asp)# no ? @@ -423,7 +423,7 @@ remote-ip 127.0.0.200 remote-ip 127.0.0.201 role sg - sctp-role server + transport-role server as my-ass m3ua asp my-asp routing-key 0 3.2.1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35978?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: Iab6c898181d79a5ed2bea767ee90e55bc3af16a5 Gerrit-Change-Number: 35978 Gerrit-PatchSet: 6 Gerrit-Owner: fixeria <vyanitskiy(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> Gerrit-MessageType: merged
1 0
0 0
[L] Change in libosmo-sccp[master]: Implement M3UA-over-TCP (in addition to SCTP)
by fixeria 27 Feb '24

27 Feb '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35796?usp=email ) Change subject: Implement M3UA-over-TCP (in addition to SCTP) ...................................................................... Implement M3UA-over-TCP (in addition to SCTP) RFC 4666 section 1.3.1 states that "TCP MAY be used as the underlying common transport protocol" under certain scenarios. There is even IANA-allocated TCP port 2905 for that purpose (see section 1.4.8). Since TCP is a stream oriented protocol, so we need to handle message boundaries ourselves by reading the M3UA header to know the PDU length. Change-Id: I8c76d271472befacbeb998a93bbdc9e8660d9b5d Related: SYS#5424 --- M TODO-RELEASE M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c M src/osmo_ss7_asp.c M src/osmo_ss7_vty.c M src/osmo_ss7_xua_srv.c M src/sccp_user.c M src/ss7_internal.h M tests/ss7/ss7_test.c M tests/vty/ss7_asp_test.vty 10 files changed, 597 insertions(+), 115 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve diff --git a/TODO-RELEASE b/TODO-RELEASE index 25eeb6e..7785711 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -12,3 +12,8 @@ libosmocore >1.9.0 osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf() libosmocore >1.9.0 osmo_sock_sctp_get_peer_addr_info() libosmo-netif >1.4.0 osmo_sctp_spinfo_state_str(), osmo_sctp_sstat_state_str() +libosmo-sigtran ABI change struct osmo_ss7_asp: new field(s) at the end +libosmo-sigtran ABI change struct osmo_xua_server: new field(s) at the end +libosmo-sigtran API added osmo_ss7_asp_get_trans_proto() +libosmo-sigtran API added osmo_ss7_asp_{find2,find_or_create2}() +libosmo-sigtran API added osmo_ss7_xua_server_{find2,create2}() diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index fc323a8..2324532 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -453,6 +453,9 @@ uint16_t max_attempts_value; uint16_t max_init_timeo_value; /* ms */ } sctp_init; + + /*! The underlaying transport protocol (one of IPPROTO_*) */ + int trans_proto; } cfg; }; @@ -482,11 +485,21 @@ struct osmo_ss7_asp * osmo_ss7_asp_find(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, - enum osmo_ss7_asp_protocol proto); + enum osmo_ss7_asp_protocol proto) + OSMO_DEPRECATED("Use osmo_ss7_asp_find2() instead"); +struct osmo_ss7_asp * +osmo_ss7_asp_find2(struct osmo_ss7_instance *inst, const char *name, + uint16_t remote_port, uint16_t local_port, + int trans_proto, enum osmo_ss7_asp_protocol proto); struct osmo_ss7_asp * osmo_ss7_asp_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, - enum osmo_ss7_asp_protocol proto); + enum osmo_ss7_asp_protocol proto) + OSMO_DEPRECATED("Use osmo_ss7_asp_find_or_create2() instead"); +struct osmo_ss7_asp * +osmo_ss7_asp_find_or_create2(struct osmo_ss7_instance *inst, const char *name, + uint16_t remote_port, uint16_t local_port, + int trans_proto, enum osmo_ss7_asp_protocol proto); void osmo_ss7_asp_destroy(struct osmo_ss7_asp *asp); int osmo_ss7_asp_send(struct osmo_ss7_asp *asp, struct msgb *msg); int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp); @@ -495,6 +508,7 @@ int osmo_ss7_asp_get_log_subsys(const struct osmo_ss7_asp *asp); const char *osmo_ss7_asp_get_name(const struct osmo_ss7_asp *asp); enum osmo_ss7_asp_protocol osmo_ss7_asp_get_proto(const struct osmo_ss7_asp *asp); +int osmo_ss7_asp_get_trans_proto(const struct osmo_ss7_asp *asp); /*! Weak function to handle payload for unknown/unsupported PPID or IPA StreamID. * This function can be overridden by application code to implement whatever handling @@ -543,16 +557,32 @@ uint16_t num_ostreams_value; uint16_t max_instreams_value; } sctp_init; + + /*! The underlaying transport protocol (one of IPPROTO_*) */ + int trans_proto; } cfg; }; struct osmo_xua_server * -osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, - uint16_t local_port); +osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port) + OSMO_DEPRECATED("Use osmo_ss7_xua_server_find2() instead"); +struct osmo_xua_server * +osmo_ss7_xua_server_find2(struct osmo_ss7_instance *inst, + int trans_proto, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port); struct osmo_xua_server * -osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, - uint16_t local_port, const char *local_host); +osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port, const char *local_host) + OSMO_DEPRECATED("Use osmo_ss7_xua_server_create2() instead"); +struct osmo_xua_server * +osmo_ss7_xua_server_create2(struct osmo_ss7_instance *inst, + int trans_proto, enum osmo_ss7_asp_protocol proto, + uint16_t local_port, const char *local_host); int osmo_ss7_xua_server_bind(struct osmo_xua_server *xs); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 50ad172..74b0f50 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -1017,9 +1017,9 @@ } struct osmo_ss7_asp * -osmo_ss7_asp_find(struct osmo_ss7_instance *inst, const char *name, - uint16_t remote_port, uint16_t local_port, - enum osmo_ss7_asp_protocol proto) +osmo_ss7_asp_find2(struct osmo_ss7_instance *inst, const char *name, + uint16_t remote_port, uint16_t local_port, + int trans_proto, enum osmo_ss7_asp_protocol proto) { struct osmo_ss7_asp *asp; @@ -1028,47 +1028,107 @@ if (!asp) return NULL; - if ((asp->cfg.remote.port != remote_port || asp->cfg.local.port != local_port || asp->cfg.proto != proto)) + if (asp->cfg.remote.port != remote_port || asp->cfg.local.port != local_port) + return NULL; + if (asp->cfg.trans_proto != trans_proto) + return NULL; + if (asp->cfg.proto != proto) return NULL; return asp; } struct osmo_ss7_asp * +osmo_ss7_asp_find(struct osmo_ss7_instance *inst, const char *name, + uint16_t remote_port, uint16_t local_port, + enum osmo_ss7_asp_protocol proto) +{ + const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + + return osmo_ss7_asp_find2(inst, name, + remote_port, local_port, + trans_proto, proto); +} + +struct osmo_ss7_asp * +osmo_ss7_asp_find_or_create2(struct osmo_ss7_instance *inst, const char *name, + uint16_t remote_port, uint16_t local_port, + int trans_proto, enum osmo_ss7_asp_protocol proto) +{ + struct osmo_ss7_asp *asp; + + OSMO_ASSERT(ss7_initialized); + asp = osmo_ss7_asp_find_by_name(inst, name); + if (asp) { + if (asp->cfg.remote.port != remote_port || asp->cfg.local.port != local_port) + return NULL; + if (asp->cfg.trans_proto != trans_proto) + return NULL; + if (asp->cfg.proto != proto) + return NULL; + return asp; + } + + return ss7_asp_alloc(inst, name, remote_port, local_port, trans_proto, proto); +} + +struct osmo_ss7_asp * osmo_ss7_asp_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, enum osmo_ss7_asp_protocol proto) { - struct osmo_ss7_asp *asp; + const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto); - OSMO_ASSERT(ss7_initialized); - asp = osmo_ss7_asp_find_by_name(inst, name); - if (asp) { - if (asp->cfg.remote.port != remote_port || - asp->cfg.local.port != local_port || - asp->cfg.proto != proto) - return NULL; - return asp; - } - - return ss7_asp_alloc(inst, name, remote_port, local_port, proto); + return osmo_ss7_asp_find_or_create2(inst, name, + remote_port, local_port, + trans_proto, proto); } +/*! \brief find an xUA server with the given parameters + * \param[in] inst SS7 Instance on which we operate + * \param[in] trans_proto transport protocol in use (one of IPPROTO_*) + * \param[in] proto protocol (xUA variant) in use + * \param[in] local_port local port of the server + * \returns \ref osmo_xua_server or NULL (not found) + */ struct osmo_xua_server * -osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, - uint16_t local_port) +osmo_ss7_xua_server_find2(struct osmo_ss7_instance *inst, + int trans_proto, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port) { struct osmo_xua_server *xs; OSMO_ASSERT(ss7_initialized); llist_for_each_entry(xs, &inst->xua_servers, list) { - if (proto == xs->cfg.proto && - local_port == xs->cfg.local.port) - return xs; + if (trans_proto != xs->cfg.trans_proto) + continue; + if (proto != xs->cfg.proto) + continue; + if (local_port != xs->cfg.local.port) + continue; + return xs; } + return NULL; } +/*! \brief find an xUA server with the given parameters + * \param[in] inst SS7 Instance on which we operate + * \param[in] proto protocol (xUA variant) in use + * \param[in] local_port local port of the server + * \returns \ref osmo_xua_server or NULL (not found) + */ +struct osmo_xua_server * +osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port) +{ + const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + + return osmo_ss7_xua_server_find2(inst, trans_proto, proto, local_port); +} + bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc) { OSMO_ASSERT(ss7_initialized); diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index a36d385..f211872 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -127,7 +127,32 @@ { 0, NULL } }; -int ss7_asp_proto_to_ip_proto(enum osmo_ss7_asp_protocol proto) +/* check if the given transport and ASP protocols are compatible (and implemented) */ +bool ss7_asp_protocol_check_trans_proto(enum osmo_ss7_asp_protocol proto, int trans_proto) +{ + switch (proto) { + case OSMO_SS7_ASP_PROT_IPA: + if (trans_proto == IPPROTO_TCP) + return true; + return false; + case OSMO_SS7_ASP_PROT_SUA: + if (trans_proto == IPPROTO_SCTP) + return true; + return false; + case OSMO_SS7_ASP_PROT_M3UA: + if (trans_proto == IPPROTO_SCTP) + return true; + if (trans_proto == IPPROTO_TCP) + return true; + return false; + case OSMO_SS7_ASP_PROT_NONE: + default: + return false; + } +} + +/* get _default_ transport protocol for the given ASP protocol */ +int ss7_default_trans_proto_for_asp_proto(enum osmo_ss7_asp_protocol proto) { switch (proto) { case OSMO_SS7_ASP_PROT_IPA: @@ -503,9 +528,18 @@ struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, - enum osmo_ss7_asp_protocol proto) + int trans_proto, enum osmo_ss7_asp_protocol proto) { - struct osmo_ss7_asp *asp = talloc_zero(inst, struct osmo_ss7_asp); + struct osmo_ss7_asp *asp; + + if (!ss7_asp_protocol_check_trans_proto(proto, trans_proto)) { + LOGP(DLSCCP, LOGL_ERROR, + "ASP protocol '%s' with transport protocol %d is not supported", + osmo_ss7_asp_protocol_name(proto), trans_proto); + return NULL; + } + + asp = talloc_zero(inst, struct osmo_ss7_asp); asp->ctrg = rate_ctr_group_alloc(asp, &ss7_asp_rcgd, g_ss7_asp_rcg_idx++); if (!asp->ctrg) { talloc_free(asp); @@ -517,6 +551,7 @@ asp->cfg.remote.port = remote_port; osmo_ss7_asp_peer_init(&asp->cfg.local); asp->cfg.local.port = local_port; + asp->cfg.trans_proto = trans_proto; asp->cfg.proto = proto; asp->cfg.name = talloc_strdup(asp, name); @@ -566,6 +601,7 @@ static int xua_cli_read_cb(struct osmo_stream_cli *conn); static int ipa_cli_read_cb(struct osmo_stream_cli *conn); +static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn); static int xua_cli_connect_cb(struct osmo_stream_cli *cli); int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp) @@ -601,13 +637,27 @@ osmo_stream_cli_set_port(asp->client, asp->cfg.remote.port); osmo_stream_cli_set_local_addrs(asp->client, (const char **)asp->cfg.local.host, asp->cfg.local.host_cnt); osmo_stream_cli_set_local_port(asp->client, asp->cfg.local.port); - osmo_stream_cli_set_proto(asp->client, ss7_asp_proto_to_ip_proto(asp->cfg.proto)); + osmo_stream_cli_set_proto(asp->client, asp->cfg.trans_proto); osmo_stream_cli_set_reconnect_timeout(asp->client, 5); osmo_stream_cli_set_connect_cb(asp->client, xua_cli_connect_cb); - if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA) + switch (asp->cfg.proto) { + case OSMO_SS7_ASP_PROT_IPA: + OSMO_ASSERT(asp->cfg.trans_proto == IPPROTO_TCP); osmo_stream_cli_set_read_cb(asp->client, ipa_cli_read_cb); - else + break; + case OSMO_SS7_ASP_PROT_M3UA: + if (asp->cfg.trans_proto == IPPROTO_SCTP) + osmo_stream_cli_set_read_cb(asp->client, xua_cli_read_cb); + else if (asp->cfg.trans_proto == IPPROTO_TCP) + osmo_stream_cli_set_read_cb(asp->client, m3ua_tcp_cli_read_cb); + else + OSMO_ASSERT(0); + break; + default: + OSMO_ASSERT(asp->cfg.trans_proto == IPPROTO_SCTP); osmo_stream_cli_set_read_cb(asp->client, xua_cli_read_cb); + break; + } osmo_stream_cli_set_data(asp->client, asp); byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH can't be enabled */ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte)); @@ -838,6 +888,78 @@ return rc; } +/* netif code tells us we can read something from the socket */ +int ss7_asp_m3ua_tcp_srv_conn_cb(struct osmo_stream_srv *conn) +{ + struct osmo_ss7_asp *asp = osmo_stream_srv_get_data(conn); + int fd = osmo_stream_srv_get_fd(conn); + struct msgb *msg = asp->pending_msg; + const struct xua_common_hdr *hdr; + size_t msg_length; + int rc; + + OSMO_ASSERT(fd >= 0); + + if (msg == NULL) { + msg = m3ua_msgb_alloc(__func__); + asp->pending_msg = msg; + } + + /* read message header first */ + if (msg->len < sizeof(*hdr)) { + errno = 0; + rc = recv(fd, msg->tail, sizeof(*hdr) - msg->len, 0); + if (rc <= 0) { + if (errno == EAGAIN || errno == EINTR) + return 0; /* need more data */ + osmo_stream_srv_destroy(conn); + asp->pending_msg = NULL; + msgb_free(msg); + return rc; + } + + msgb_put(msg, rc); + if (msg->len < sizeof(*hdr)) + return 0; /* need more data */ + } + + hdr = (const struct xua_common_hdr *)msg->data; + msg_length = ntohl(hdr->msg_length); /* includes sizeof(*hdr) */ + + /* read the rest of the message */ + if (msg->len < msg_length) { + errno = 0; + rc = recv(fd, msg->tail, msg_length - msg->len, 0); + if (rc <= 0) { + if (errno == EAGAIN || errno == EINTR) + return 0; /* need more data */ + osmo_stream_srv_destroy(conn); + asp->pending_msg = NULL; + msgb_free(msg); + return rc; + } + + msgb_put(msg, rc); + if (msg->len < msg_length) + return 0; /* need more data */ + } + + msg->dst = asp; + rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL); + + /* spoof SCTP Stream ID */ + if (hdr->msg_class == M3UA_MSGC_XFER) + msgb_sctp_stream(msg) = 1; + else + msgb_sctp_stream(msg) = 0; + + rc = m3ua_rx_msg(asp, msg); + asp->pending_msg = NULL; + msgb_free(msg); + + return rc; +} + /* client has established SCTP connection to server */ static int xua_cli_connect_cb(struct osmo_stream_cli *cli) { @@ -858,7 +980,7 @@ * fed and the local port is known for sure. Apply SCTP Primary addresses * if needed: */ - if (asp->cfg.proto != OSMO_SS7_ASP_PROT_IPA) { + if (asp->cfg.trans_proto == IPPROTO_SCTP) { rc = ss7_asp_apply_peer_primary_address(asp); rc = ss7_asp_apply_primary_address(asp); } @@ -926,6 +1048,78 @@ return ipa_rx_msg(asp, msg, fd & 0xf); } +/* read call-back for M3UA-over-TCP socket */ +static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn) +{ + struct osmo_ss7_asp *asp = osmo_stream_cli_get_data(conn); + int fd = osmo_stream_cli_get_fd(conn); + struct msgb *msg = asp->pending_msg; + const struct xua_common_hdr *hdr; + size_t msg_length; + int rc; + + OSMO_ASSERT(fd >= 0); + + if (msg == NULL) { + msg = m3ua_msgb_alloc(__func__); + asp->pending_msg = msg; + } + + /* read message header first */ + if (msg->len < sizeof(*hdr)) { + errno = 0; + rc = recv(fd, msg->tail, sizeof(*hdr) - msg->len, 0); + if (rc <= 0) { + if (errno == EAGAIN || errno == EINTR) + return 0; /* need more data */ + xua_cli_close_and_reconnect(conn); + asp->pending_msg = NULL; + msgb_free(msg); + return rc; + } + + msgb_put(msg, rc); + if (msg->len < sizeof(*hdr)) + return 0; /* need more data */ + } + + hdr = (const struct xua_common_hdr *)msg->data; + msg_length = ntohl(hdr->msg_length); /* includes sizeof(*hdr) */ + + /* read the rest of the message */ + if (msg->len < msg_length) { + errno = 0; + rc = recv(fd, msg->tail, msg_length - msg->len, 0); + if (rc <= 0) { + if (errno == EAGAIN || errno == EINTR) + return 0; /* need more data */ + xua_cli_close_and_reconnect(conn); + asp->pending_msg = NULL; + msgb_free(msg); + return rc; + } + + msgb_put(msg, rc); + if (msg->len < msg_length) + return 0; /* need more data */ + } + + msg->dst = asp; + rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL); + + /* spoof SCTP Stream ID */ + if (hdr->msg_class == M3UA_MSGC_XFER) + msgb_sctp_stream(msg) = 1; + else + msgb_sctp_stream(msg) = 0; + + rc = m3ua_rx_msg(asp, msg); + asp->pending_msg = NULL; + msgb_free(msg); + + return rc; +} + static int xua_cli_read_cb(struct osmo_stream_cli *conn) { struct osmo_ss7_asp *asp = osmo_stream_cli_get_data(conn); @@ -1135,6 +1329,15 @@ return asp->cfg.proto; } +/*! \brief Get the transport proto of a given ASP + * \param[in] asp The ASP for which the transport proto is requested + * \returns The transport proto of the ASP (one of IPPROTO_*) + */ +int osmo_ss7_asp_get_trans_proto(const struct osmo_ss7_asp *asp) +{ + return asp->cfg.trans_proto; +} + /*! \brief Get the fd of a given ASP * \param[in] asp The ASP for which the fd is requested * \returns The fd of the ASP if acailable, negative otherwise diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 33e6e56..42a3383 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -62,6 +62,11 @@ "MTP3 User Adaptation\n" \ "IPA Multiplex (SCCP Lite)\n" +#define IPPROTO_VAR_STR "(sctp|tcp)" +#define IPPROTO_VAR_HELP_STR \ + "SCTP (Stream Control Transmission Protocol)\n" \ + "TCP (Transmission Control Protocol)\n" + /* netinet/tcp.h */ static const struct value_string tcp_info_state_values[] = { { TCP_ESTABLISHED, "ESTABLISHED" }, @@ -465,6 +470,17 @@ * xUA Listener Configuration (SG) ***********************************************************************/ +static const struct value_string ipproto_vals[] = { + { IPPROTO_SCTP, "sctp" }, + { IPPROTO_TCP, "tcp" }, + { 0, NULL }, +}; + +static int parse_trans_proto(const char *protocol) +{ + return get_string_value(ipproto_vals, protocol); +} + static enum osmo_ss7_asp_protocol parse_asp_proto(const char *protocol) { return get_string_value(osmo_ss7_asp_protocol_vals, protocol); @@ -477,19 +493,29 @@ }; DEFUN_ATTR(cs7_xua, cs7_xua_cmd, - "listen " XUA_VAR_STR " <0-65534>", + "listen " XUA_VAR_STR " <0-65534> [" IPPROTO_VAR_STR "]", "Configure/Enable xUA Listener\n" - XUA_VAR_HELP_STR "SCTP Port number\n", + XUA_VAR_HELP_STR + "Port number\n" + IPPROTO_VAR_HELP_STR, CMD_ATTR_IMMEDIATE) { struct osmo_ss7_instance *inst = vty->index; struct osmo_xua_server *xs; enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[0]); uint16_t port = atoi(argv[1]); + int trans_proto; - xs = osmo_ss7_xua_server_find(inst, proto, port); + if (argc > 2) + trans_proto = parse_trans_proto(argv[2]); + else /* default transport protocol */ + trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + if (trans_proto < 0) + return CMD_WARNING; + + xs = osmo_ss7_xua_server_find2(inst, trans_proto, proto, port); if (!xs) { - xs = osmo_ss7_xua_server_create(inst, proto, port, NULL); + xs = osmo_ss7_xua_server_create2(inst, trans_proto, proto, port, NULL); if (!xs) return CMD_WARNING; /* Drop first dummy address created automatically by _create(): */ @@ -502,17 +528,27 @@ } DEFUN_ATTR(no_cs7_xua, no_cs7_xua_cmd, - "no listen " XUA_VAR_STR " <0-65534>", - NO_STR "Disable xUA Listener on given SCTP Port\n" - XUA_VAR_HELP_STR "SCTP Port number\n", + "no listen " XUA_VAR_STR " <0-65534> [" IPPROTO_VAR_STR "]", + NO_STR "Disable xUA Listener on given port\n" + XUA_VAR_HELP_STR + "Port number\n" + IPPROTO_VAR_HELP_STR, CMD_ATTR_IMMEDIATE) { struct osmo_ss7_instance *inst = vty->index; struct osmo_xua_server *xs; enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[0]); uint16_t port = atoi(argv[1]); + int trans_proto; - xs = osmo_ss7_xua_server_find(inst, proto, port); + if (argc > 2) + trans_proto = parse_trans_proto(argv[2]); + else /* default transport protocol */ + trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + if (trans_proto < 0) + return CMD_WARNING; + + xs = osmo_ss7_xua_server_find2(inst, trans_proto, proto, port); if (!xs) { vty_out(vty, "No xUA server for port %u found%s", port, VTY_NEWLINE); return CMD_WARNING; @@ -616,9 +652,13 @@ static void write_one_xua(struct vty *vty, struct osmo_xua_server *xs) { int i; - vty_out(vty, " listen %s %u%s", + + vty_out(vty, " listen %s %u", get_value_string(osmo_ss7_asp_protocol_vals, xs->cfg.proto), - xs->cfg.local.port, VTY_NEWLINE); + xs->cfg.local.port); + if (xs->cfg.trans_proto != ss7_default_trans_proto_for_asp_proto(xs->cfg.proto)) + vty_out(vty, " %s", get_value_string(ipproto_vals, xs->cfg.trans_proto)); + vty_out(vty, "%s", VTY_NEWLINE); for (i = 0; i < xs->cfg.local.host_cnt; i++) { if (xs->cfg.local.host[i]) @@ -646,7 +686,7 @@ size_t num_hostbuf = ARRAY_SIZE(hostbuf); char portbuf[6]; int rc; - rc = osmo_sock_multiaddr_get_ip_and_port(fd, ss7_asp_proto_to_ip_proto(xs->cfg.proto), + rc = osmo_sock_multiaddr_get_ip_and_port(fd, xs->cfg.trans_proto, &hostbuf[0][0], &num_hostbuf, sizeof(hostbuf[0]), portbuf, sizeof(portbuf), true); if (rc < 0) { @@ -659,37 +699,60 @@ portbuf); } } - vty_out(vty, "xUA server for %s on %s is %s%s", - proto, buf, fd >= 0 ? "listening" : "inactive", VTY_NEWLINE); + vty_out(vty, "xUA server for %s/%s on %s is %s%s", + proto, get_value_string(ipproto_vals, xs->cfg.trans_proto), + buf, fd >= 0 ? "listening" : "inactive", VTY_NEWLINE); } -DEFUN(show_cs7_xua, show_cs7_xua_cmd, - "show cs7 "XUA_VAR_STR" [<0-65534>]", - SHOW_STR CS7_STR XUA_VAR_HELP_STR "Port Number") +static int _show_cs7_xua(struct vty *vty, + enum osmo_ss7_asp_protocol proto, + int trans_proto, int local_port) { - struct osmo_ss7_instance *inst; - struct osmo_xua_server *xs; - enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[0]); + const struct osmo_ss7_instance *inst; llist_for_each_entry(inst, &osmo_ss7_instances, list) { - if (argc > 1) { - int port = atoi(argv[1]); - xs = osmo_ss7_xua_server_find(inst, proto, port); - if (!xs) { - vty_out(vty, "%% No matching server found%s", VTY_NEWLINE); - return CMD_WARNING; - } + struct osmo_xua_server *xs; + + llist_for_each_entry(xs, &inst->xua_servers, list) { + if (xs->cfg.proto != proto) + continue; + if (local_port >= 0 && xs->cfg.local.port != local_port) /* optional */ + continue; + if (trans_proto >= 0 && xs->cfg.trans_proto != trans_proto) /* optional */ + continue; vty_dump_xua_server(vty, xs); - } else { - llist_for_each_entry(xs, &inst->xua_servers, list) { - if (xs->cfg.proto == proto) - vty_dump_xua_server(vty, xs); - } } } + return CMD_SUCCESS; } +#define SHOW_CS7_XUA_CMD \ + "show cs7 " XUA_VAR_STR +#define SHOW_CS7_XUA_CMD_HELP \ + SHOW_STR CS7_STR XUA_VAR_HELP_STR + +DEFUN(show_cs7_xua, show_cs7_xua_cmd, + SHOW_CS7_XUA_CMD " [<0-65534>]", + SHOW_CS7_XUA_CMD_HELP "Local Port Number\n") +{ + enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[0]); + int local_port = (argc > 1) ? atoi(argv[1]) : -1; + + return _show_cs7_xua(vty, proto, -1, local_port); +} + +DEFUN(show_cs7_xua_trans_proto, show_cs7_xua_trans_proto_cmd, + SHOW_CS7_XUA_CMD " " IPPROTO_VAR_STR " [<0-65534>]", + SHOW_CS7_XUA_CMD_HELP IPPROTO_VAR_HELP_STR "Local Port Number\n") +{ + enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[0]); + int trans_proto = parse_trans_proto(argv[1]); + int local_port = (argc > 2) ? atoi(argv[2]) : -1; + + return _show_cs7_xua(vty, proto, trans_proto, local_port); +} + DEFUN(show_cs7_config, show_cs7_config_cmd, "show cs7 config", SHOW_STR CS7_STR "Currently running cs7 configuration") @@ -738,8 +801,8 @@ "asp NAME <0-65535> <0-65535> " XUA_VAR_STR, "Configure Application Server Process\n" "Name of ASP\n" - "Remote SCTP port number\n" - "Local SCTP port number\n" + "Remote port number\n" + "Local port number\n" XUA_VAR_HELP_STR, CMD_ATTR_NODE_EXIT) { @@ -747,17 +810,30 @@ const char *name = argv[0]; uint16_t remote_port = atoi(argv[1]); uint16_t local_port = atoi(argv[2]); - enum osmo_ss7_asp_protocol protocol = parse_asp_proto(argv[3]); + enum osmo_ss7_asp_protocol proto = parse_asp_proto(argv[3]); struct osmo_ss7_asp *asp; + int trans_proto; - if (protocol == OSMO_SS7_ASP_PROT_NONE) { + if (proto == OSMO_SS7_ASP_PROT_NONE) { vty_out(vty, "invalid protocol '%s'%s", argv[3], VTY_NEWLINE); return CMD_WARNING; } - asp = osmo_ss7_asp_find(inst, name, remote_port, local_port, protocol); + /* argv[4] can be supplied by an alias (see below) */ + if (argc > 4) + trans_proto = parse_trans_proto(argv[4]); + else /* default transport protocol */ + trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + if (trans_proto < 0) + return CMD_WARNING; + + asp = osmo_ss7_asp_find2(inst, name, + remote_port, local_port, + trans_proto, proto); if (!asp) { - asp = osmo_ss7_asp_find_or_create(inst, name, remote_port, local_port, protocol); + asp = osmo_ss7_asp_find_or_create2(inst, name, + remote_port, local_port, + trans_proto, proto); if (!asp) { vty_out(vty, "cannot create ASP '%s'%s", name, VTY_NEWLINE); return CMD_WARNING; @@ -772,6 +848,18 @@ return CMD_SUCCESS; } +/* XXX: workaround for https://osmocom.org/issues/6360, can be removed once it's fixed. + * Currently we hit an assert if we make the IPPROTO_VAR_STR optional in cs7_asp_cmd. */ +ALIAS_ATTR(cs7_asp, cs7_asp_trans_proto_cmd, + "asp NAME <0-65535> <0-65535> " XUA_VAR_STR " " IPPROTO_VAR_STR, + "Configure Application Server Process\n" + "Name of ASP\n" + "Remote port number\n" + "Local port number\n" + XUA_VAR_HELP_STR + IPPROTO_VAR_HELP_STR, + CMD_ATTR_NODE_EXIT); + DEFUN_ATTR(no_cs7_asp, no_cs7_asp_cmd, "no asp NAME", NO_STR "Disable Application Server Process\n" @@ -1217,10 +1305,10 @@ int fd = ss7_asp_get_fd(asp); if (fd > 0) { - int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto); - if (!get_sockname_buf(buf_loc, sizeof(buf_loc), fd, proto, true)) + const int trans_proto = asp->cfg.trans_proto; + if (!get_sockname_buf(buf_loc, sizeof(buf_loc), fd, trans_proto, true)) OSMO_STRLCPY_ARRAY(buf_loc, "<sockname-error>"); - if (!get_sockname_buf(buf_rem, sizeof(buf_rem), fd, proto, false)) + if (!get_sockname_buf(buf_rem, sizeof(buf_rem), fd, trans_proto, false)) OSMO_STRLCPY_ARRAY(buf_rem, "<sockname-error>"); } else { osmo_ss7_asp_peer_snprintf(buf_loc, sizeof(buf_loc), &asp->cfg.local); @@ -1374,9 +1462,7 @@ static void show_one_asp_remaddr(struct vty *vty, struct osmo_ss7_asp *asp) { - int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto); - - switch (proto) { + switch (asp->cfg.trans_proto) { case IPPROTO_TCP: show_one_asp_remaddr_tcp(vty, asp); break; @@ -1386,7 +1472,8 @@ break; #endif default: - vty_out(vty, "%-12s %-46s unknown proto %u%s", asp->cfg.name, "", proto, VTY_NEWLINE); + vty_out(vty, "%-12s %-46s unknown proto %d%s", + asp->cfg.name, "", asp->cfg.trans_proto, VTY_NEWLINE); break; } } @@ -1530,9 +1617,7 @@ static void show_one_asp_assoc_status(struct vty *vty, struct osmo_ss7_asp *asp) { - int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto); - - switch (proto) { + switch (asp->cfg.trans_proto) { case IPPROTO_TCP: show_one_asp_assoc_status_tcp(vty, asp); break; @@ -1542,7 +1627,8 @@ break; #endif default: - vty_out(vty, "%-12s unknown proto %u%s", asp->cfg.name, proto, VTY_NEWLINE); + vty_out(vty, "%-12s unknown proto %d%s", + asp->cfg.name, asp->cfg.trans_proto, VTY_NEWLINE); break; } } @@ -1611,9 +1697,12 @@ && !show_dyn_config) return; - vty_out(vty, " asp %s %u %u %s%s", + vty_out(vty, " asp %s %u %u %s", asp->cfg.name, asp->cfg.remote.port, asp->cfg.local.port, - osmo_ss7_asp_protocol_name(asp->cfg.proto), VTY_NEWLINE); + osmo_ss7_asp_protocol_name(asp->cfg.proto)); + if (asp->cfg.trans_proto != ss7_default_trans_proto_for_asp_proto(asp->cfg.proto)) + vty_out(vty, " %s", get_value_string(ipproto_vals, asp->cfg.trans_proto)); + vty_out(vty, "%s", VTY_NEWLINE); if (asp->cfg.description) vty_out(vty, " description %s%s", asp->cfg.description, VTY_NEWLINE); for (i = 0; i < asp->cfg.local.host_cnt; i++) { @@ -2862,6 +2951,7 @@ install_lib_element_ve(&show_cs7_user_cmd); install_lib_element_ve(&show_cs7_xua_cmd); + install_lib_element_ve(&show_cs7_xua_trans_proto_cmd); install_lib_element_ve(&show_cs7_config_cmd); install_lib_element(ENABLE_NODE, &cs7_asp_disconnect_cmd); @@ -2885,6 +2975,7 @@ install_lib_element_ve(&show_cs7_asp_assoc_status_cmd); install_lib_element_ve(&show_cs7_asp_assoc_status_name_cmd); install_lib_element(L_CS7_NODE, &cs7_asp_cmd); + install_lib_element(L_CS7_NODE, &cs7_asp_trans_proto_cmd); install_lib_element(L_CS7_NODE, &no_cs7_asp_cmd); install_lib_element(L_CS7_ASP_NODE, &cfg_description_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_remote_ip_cmd); diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c index 32266ff..0b83b19 100644 --- a/src/osmo_ss7_xua_srv.c +++ b/src/osmo_ss7_xua_srv.c @@ -67,19 +67,32 @@ struct osmo_ss7_asp *asp; char *sock_name = osmo_sock_get_name(link, fd); const char *proto_name = get_value_string(osmo_ss7_asp_protocol_vals, oxs->cfg.proto); + int (*read_cb)(struct osmo_stream_srv *conn) = NULL; int rc = 0; LOGP(DLSS7, LOGL_INFO, "%s: New %s connection accepted\n", sock_name, proto_name); - if (oxs->cfg.proto == OSMO_SS7_ASP_PROT_IPA) { - srv = osmo_stream_srv_create(oxs, link, fd, - ss7_asp_ipa_srv_conn_cb, - ss7_asp_xua_srv_conn_closed_cb, NULL); - } else { - srv = osmo_stream_srv_create(oxs, link, fd, - ss7_asp_xua_srv_conn_cb, - ss7_asp_xua_srv_conn_closed_cb, NULL); + switch (oxs->cfg.proto) { + case OSMO_SS7_ASP_PROT_IPA: + OSMO_ASSERT(oxs->cfg.trans_proto == IPPROTO_TCP); + read_cb = &ss7_asp_ipa_srv_conn_cb; + break; + case OSMO_SS7_ASP_PROT_M3UA: + if (oxs->cfg.trans_proto == IPPROTO_SCTP) + read_cb = &ss7_asp_xua_srv_conn_cb; + else if (oxs->cfg.trans_proto == IPPROTO_TCP) + read_cb = &ss7_asp_m3ua_tcp_srv_conn_cb; + else + OSMO_ASSERT(0); + break; + default: + OSMO_ASSERT(oxs->cfg.trans_proto == IPPROTO_SCTP); + read_cb = &ss7_asp_xua_srv_conn_cb; + break; } + + srv = osmo_stream_srv_create(oxs, link, fd, read_cb, + &ss7_asp_xua_srv_conn_closed_cb, NULL); if (!srv) { LOGP(DLSS7, LOGL_ERROR, "%s: Unable to create stream server " "for connection\n", sock_name); @@ -112,8 +125,9 @@ char namebuf[32]; static uint32_t dyn_asp_num = 0; snprintf(namebuf, sizeof(namebuf), "asp-dyn-%u", dyn_asp_num++); - asp = osmo_ss7_asp_find_or_create(oxs->inst, namebuf, 0, 0, - oxs->cfg.proto); + asp = osmo_ss7_asp_find_or_create2(oxs->inst, namebuf, 0, 0, + oxs->cfg.trans_proto, + oxs->cfg.proto); if (asp) { char hostbuf[INET6_ADDRSTRLEN]; const char *hostbuf_ptr = &hostbuf[0]; @@ -157,7 +171,7 @@ * data */ osmo_stream_srv_set_data(srv, asp); - if (oxs->cfg.proto != OSMO_SS7_ASP_PROT_IPA) { + if (oxs->cfg.trans_proto == IPPROTO_SCTP) { rc = ss7_asp_apply_peer_primary_address(asp); rc = ss7_asp_apply_primary_address(asp); } @@ -170,19 +184,29 @@ } /*! \brief create a new xUA server configured with given ip/port - * \param[in] ctx talloc allocation context + * \param[in] inst SS7 Instance on which we operate + * \param[in] trans_proto transport protocol to use (one of IPPROTO_*) * \param[in] proto protocol (xUA variant) to use * \param[in] local_port local SCTP port to bind/listen to * \param[in] local_host local IP address to bind/listen to (optional) * \returns callee-allocated \ref osmo_xua_server in case of success */ struct osmo_xua_server * -osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, - uint16_t local_port, const char *local_host) +osmo_ss7_xua_server_create2(struct osmo_ss7_instance *inst, + int trans_proto, enum osmo_ss7_asp_protocol proto, + uint16_t local_port, const char *local_host) { - struct osmo_xua_server *oxs = talloc_zero(inst, struct osmo_xua_server); + struct osmo_xua_server *oxs; + + if (!ss7_asp_protocol_check_trans_proto(proto, trans_proto)) { + LOGP(DLSCCP, LOGL_ERROR, + "ASP protocol '%s' with transport protocol %d is not supported", + osmo_ss7_asp_protocol_name(proto), trans_proto); + return NULL; + } OSMO_ASSERT(ss7_initialized); + oxs = talloc_zero(inst, struct osmo_xua_server); if (!oxs) return NULL; @@ -191,6 +215,7 @@ INIT_LLIST_HEAD(&oxs->asp_list); + oxs->cfg.trans_proto = trans_proto; oxs->cfg.proto = proto; oxs->cfg.local.port = local_port; @@ -201,7 +226,7 @@ osmo_stream_srv_link_set_nodelay(oxs->server, true); osmo_stream_srv_link_set_port(oxs->server, oxs->cfg.local.port); - osmo_stream_srv_link_set_proto(oxs->server, ss7_asp_proto_to_ip_proto(proto)); + osmo_stream_srv_link_set_proto(oxs->server, trans_proto); osmo_ss7_xua_server_set_local_host(oxs, local_host); @@ -218,6 +243,24 @@ return oxs; } +/*! \brief create a new xUA server configured with given ip/port + * \param[in] ctx talloc allocation context + * \param[in] proto protocol (xUA variant) to use + * \param[in] local_port local SCTP port to bind/listen to + * \param[in] local_host local IP address to bind/listen to (optional) + * \returns callee-allocated \ref osmo_xua_server in case of success + */ +struct osmo_xua_server * +osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst, + enum osmo_ss7_asp_protocol proto, + uint16_t local_port, const char *local_host) +{ + const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto); + + return osmo_ss7_xua_server_create2(inst, trans_proto, proto, + local_port, local_host); +} + /*! \brief Set the xUA server to bind/listen to the currently configured ip/port * \param[in] xs xUA server to operate * \returns 0 on success, negative value on error. diff --git a/src/sccp_user.c b/src/sccp_user.c index 94b6d02..b72b2a6 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -515,6 +515,9 @@ struct osmo_ss7_asp *asp; bool asp_created = false; char *as_name, *asp_name = NULL; + int trans_proto; + + trans_proto = ss7_default_trans_proto_for_asp_proto(prot); /*! The function will examine the given CS7 instance and its sub * components (as, asp, etc.). If necessary it will allocate @@ -625,11 +628,10 @@ asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name); LOGP(DLSCCP, LOGL_NOTICE, "%s: No unassociated ASP for %s, creating new ASP %s\n", name, osmo_ss7_asp_protocol_name(prot), asp_name); - asp = - osmo_ss7_asp_find_or_create(ss7, asp_name, - default_remote_port, - default_local_port, - prot); + asp = osmo_ss7_asp_find_or_create2(ss7, asp_name, + default_remote_port, + default_local_port, + trans_proto, prot); talloc_free(asp_name); if (!asp) goto out_rt; @@ -678,7 +680,9 @@ LOGP(DLSCCP, LOGL_NOTICE, "%s: Requesting an SCCP simple client on ASP %s configured with 'sctp-role server'\n", name, asp->cfg.name); - xs = osmo_ss7_xua_server_find(ss7, prot, asp->cfg.local.port); + xs = osmo_ss7_xua_server_find2(ss7, + asp->cfg.trans_proto, prot, + asp->cfg.local.port); if (!xs) { LOGP(DLSCCP, LOGL_ERROR, "%s: Requesting an SCCP simple client on ASP %s configured " "with 'sctp-role server' but no matching xUA server was configured!\n", @@ -755,8 +759,11 @@ { struct osmo_ss7_instance *ss7; struct osmo_xua_server *xs; + int trans_proto; int rc; + trans_proto = ss7_default_trans_proto_for_asp_proto(prot); + if (local_port < 0) local_port = osmo_ss7_asp_protocol_port(prot); @@ -766,7 +773,7 @@ return NULL; ss7->cfg.primary_pc = pc; - xs = osmo_ss7_xua_server_create(ss7, prot, local_port, local_ip); + xs = osmo_ss7_xua_server_create2(ss7, trans_proto, prot, local_port, local_ip); if (!xs) goto out_ss7; @@ -811,6 +818,9 @@ struct osmo_ss7_asp *asp; struct osmo_xua_server *oxs; char *as_name, *asp_name; + int trans_proto; + + trans_proto = ss7_default_trans_proto_for_asp_proto(prot); if (local_port < 0) local_port = osmo_ss7_asp_protocol_port(prot); @@ -831,10 +841,12 @@ if (!rt) goto out_as; - asp = osmo_ss7_asp_find_or_create(ss7, asp_name, remote_port, local_port, prot); + asp = osmo_ss7_asp_find_or_create2(ss7, asp_name, + remote_port, local_port, + trans_proto, prot); if (!asp) goto out_rt; - oxs = osmo_ss7_xua_server_find(ss7, prot, local_port); + oxs = osmo_ss7_xua_server_find2(ss7, asp->cfg.trans_proto, prot, local_port); if (!oxs) goto out_asp; if (osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, diff --git a/src/ss7_internal.h b/src/ss7_internal.h index fd01ca4..ed4fae7 100644 --- a/src/ss7_internal.h +++ b/src/ss7_internal.h @@ -16,15 +16,17 @@ struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, - enum osmo_ss7_asp_protocol proto); + int trans_proto, enum osmo_ss7_asp_protocol proto); bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp); bool ss7_asp_is_started(const struct osmo_ss7_asp *asp); int ss7_asp_get_fd(const struct osmo_ss7_asp *asp); struct osmo_ss7_asp *ss7_asp_find_by_socket_addr(int fd); -int ss7_asp_proto_to_ip_proto(enum osmo_ss7_asp_protocol proto); +bool ss7_asp_protocol_check_trans_proto(enum osmo_ss7_asp_protocol proto, int trans_proto); +int ss7_default_trans_proto_for_asp_proto(enum osmo_ss7_asp_protocol proto); int ss7_asp_ipa_srv_conn_cb(struct osmo_stream_srv *conn); int ss7_asp_xua_srv_conn_cb(struct osmo_stream_srv *conn); +int ss7_asp_m3ua_tcp_srv_conn_cb(struct osmo_stream_srv *conn); int ss7_asp_xua_srv_conn_closed_cb(struct osmo_stream_srv *srv); int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp); int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp); diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c index cf48b89..ad8dc77 100644 --- a/tests/ss7/ss7_test.c +++ b/tests/ss7/ss7_test.c @@ -248,7 +248,8 @@ OSMO_ASSERT(osmo_ss7_as_find_by_rctx(s7i, 2342) == as); OSMO_ASSERT(osmo_ss7_as_add_asp(as, "asp1") == -ENODEV); - asp = osmo_ss7_asp_find_or_create(s7i, "asp1", 0, M3UA_PORT, OSMO_SS7_ASP_PROT_M3UA); + asp = osmo_ss7_asp_find_or_create2(s7i, "asp1", 0, M3UA_PORT, + IPPROTO_SCTP, OSMO_SS7_ASP_PROT_M3UA); OSMO_ASSERT(asp); OSMO_ASSERT(osmo_ss7_as_has_asp(as, asp) == false); diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index d91df24..7b36009 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -2,6 +2,7 @@ ... !show cs7 show cs7 instance <0-15> users show cs7 (sua|m3ua|ipa) [<0-65534>] + show cs7 (sua|m3ua|ipa) (sctp|tcp) [<0-65534>] show cs7 config show cs7 instance <0-15> asp show cs7 instance <0-15> asp name ASP_NAME @@ -23,6 +24,7 @@ ... !show cs7 show cs7 instance <0-15> users show cs7 (sua|m3ua|ipa) [<0-65534>] + show cs7 (sua|m3ua|ipa) (sctp|tcp) [<0-65534>] show cs7 config cs7 instance <0-15> asp NAME disconnect show cs7 instance <0-15> asp @@ -53,7 +55,18 @@ config Currently running cs7 configuration ss7_asp_vty_test# show cs7 m3ua ? - [<0-65534>] Port Number + [<0-65534>] Local Port Number + sctp SCTP (Stream Control Transmission Protocol) + tcp TCP (Transmission Control Protocol) + +ss7_asp_vty_test# show cs7 m3ua 2905 ? + <cr> + +ss7_asp_vty_test# show cs7 m3ua sctp ? + [<0-65534>] Local Port Number + +ss7_asp_vty_test# show cs7 m3ua sctp 2905 ? + <cr> ss7_asp_vty_test# show cs7 instance ? <0-15> An instance of the SS7 stack @@ -96,6 +109,7 @@ point-code delimiter (default|dash) xua rkm routing-key-allocation (static-only|dynamic-permitted) asp NAME <0-65535> <0-65535> (sua|m3ua|ipa) + asp NAME <0-65535> <0-65535> (sua|m3ua|ipa) (sctp|tcp) no asp NAME as NAME (sua|m3ua|ipa) no as NAME @@ -154,13 +168,17 @@ ss7_asp_vty_test(config-cs7)# asp ? NAME Name of ASP ss7_asp_vty_test(config-cs7)# asp foo ? - <0-65535> Remote SCTP port number + <0-65535> Remote port number ss7_asp_vty_test(config-cs7)# asp foo 0 ? - <0-65535> Local SCTP port number + <0-65535> Local port number ss7_asp_vty_test(config-cs7)# asp foo 0 0 ? sua SCCP User Adaptation m3ua MTP3 User Adaptation ipa IPA Multiplex (SCCP Lite) +ss7_asp_vty_test(config-cs7)# asp foo 0 0 m3ua ? + sctp SCTP (Stream Control Transmission Protocol) + tcp TCP (Transmission Control Protocol) + <cr> ss7_asp_vty_test(config-cs7)# as ? NAME Name of the Application Server -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35796?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: I8c76d271472befacbeb998a93bbdc9e8660d9b5d Gerrit-Change-Number: 35796 Gerrit-PatchSet: 9 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: jolly <andreas(a)eversberg.eu> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmo-sccp[master]: cosmetic: xua_cli_connect_cb(): fix typo in a comment
by fixeria 27 Feb '24

27 Feb '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/36007?usp=email ) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: cosmetic: xua_cli_connect_cb(): fix typo in a comment ...................................................................... cosmetic: xua_cli_connect_cb(): fix typo in a comment Change-Id: I8fb57dc60c34ed3db2ea5394c3c452604217de91 --- M src/osmo_ss7_asp.c 1 file changed, 10 insertions(+), 1 deletion(-) Approvals: pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index f867ce5..a36d385 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -868,7 +868,7 @@ * established */ xua_asp_send_xlm_prim_simple(asp, OSMO_XLM_PRIM_M_SCTP_ESTABLISH, PRIM_OP_INDICATION); } else { - /* directly as the ASP FSM to start by sending an ASP-UP ... */ + /* directly ask the ASP FSM to start by sending an ASP-UP ... */ osmo_fsm_inst_dispatch(asp->fi, XUA_ASP_E_M_ASP_UP_REQ, NULL); } -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/36007?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: I8fb57dc60c34ed3db2ea5394c3c452604217de91 Gerrit-Change-Number: 36007 Gerrit-PatchSet: 3 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • ...
  • 175
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.