1111 * SPDX-License-Identifier: Apache-2.0
1212 ********************************************************************************/
1313
14- use crate :: { ClientId , UeId } ;
15- use up_rust:: { UCode , UStatus , UUri } ;
14+ use log :: trace ;
15+ use up_rust:: { UStatus , UUri } ;
1616
1717/// Registration type containing the [ClientId] of the [vsomeip_sys::vsomeip::application]
1818/// which should be used for this message
1919#[ derive( Clone , Debug , PartialEq ) ]
2020pub ( crate ) enum RegistrationType {
21- Publish ( ClientId ) ,
22- Request ( ClientId ) ,
23- Response ( ClientId ) ,
24- AllPointToPoint ( ClientId ) ,
25- }
26-
27- impl RegistrationType {
28- /// Get the [ClientId] of the [vsomeip_sys::vsomeip::application]
29- /// which should be used for this message
30- pub fn client_id ( & self ) -> ClientId {
31- match self {
32- RegistrationType :: Publish ( client_id) => * client_id,
33- RegistrationType :: Request ( client_id) => * client_id,
34- RegistrationType :: Response ( client_id) => * client_id,
35- RegistrationType :: AllPointToPoint ( client_id) => * client_id,
36- }
37- }
38- }
39-
40- /// infer the type of message desired based on the filters provided in a registration / unregistration
41- pub ( crate ) fn determine_registration_type (
42- source_filter : & UUri ,
43- sink_filter : & Option < UUri > ,
44- my_ue_id : UeId ,
45- ) -> Result < RegistrationType , UStatus > {
46- determine_type (
47- source_filter,
48- sink_filter,
49- Some ( my_ue_id) ,
50- DeterminationType :: Register ,
51- )
52- }
53-
54- /// infer the type of message desired based on the source and sink contained in a message
55- pub ( crate ) fn determine_send_type (
56- source_filter : & UUri ,
57- sink_filter : & Option < UUri > ,
58- ) -> Result < RegistrationType , UStatus > {
59- determine_type ( source_filter, sink_filter, None , DeterminationType :: Send )
60- }
61-
62- /// Whether the [determine_type] function should treat this as a registration / unregistration or send
63- enum DeterminationType {
64- Register ,
65- Send ,
21+ Publish ,
22+ Request ,
23+ Response ,
24+ AllPointToPoint ,
6625}
6726
6827/// Determines [RegistrationType] of a source and sink filter [UUri]
69- fn determine_type (
28+ pub fn determine_type (
7029 source_filter : & UUri ,
7130 sink_filter : & Option < UUri > ,
72- my_ue_id : Option < UeId > ,
73- determination_type : DeterminationType ,
7431) -> Result < RegistrationType , UStatus > {
7532 if let Some ( sink_filter) = & sink_filter {
7633 // determine if we're in the uStreamer use-case of capturing all point-to-point messages
34+ trace ! ( "source_filter: {source_filter:?}" ) ;
35+ trace ! ( "sink_filter: {sink_filter:?}" ) ;
7736 let streamer_use_case = {
7837 source_filter. authority_name == "*"
7938 && source_filter. ue_id == 0x0000_FFFF
@@ -86,33 +45,16 @@ fn determine_type(
8645 } ;
8746
8847 if streamer_use_case {
89- return Ok ( RegistrationType :: AllPointToPoint ( 0xFFFF ) ) ;
48+ return Ok ( RegistrationType :: AllPointToPoint ) ;
9049 }
9150
92- let client_id = match determination_type {
93- DeterminationType :: Register => sink_filter. ue_id as ClientId ,
94- DeterminationType :: Send => source_filter. ue_id as ClientId ,
95- } ;
96-
9751 if sink_filter. resource_id == 0 {
98- Ok ( RegistrationType :: Response ( client_id ) )
52+ Ok ( RegistrationType :: Response )
9953 } else {
100- Ok ( RegistrationType :: Request ( client_id ) )
54+ Ok ( RegistrationType :: Request )
10155 }
10256 } else {
103- let client_id = match determination_type {
104- DeterminationType :: Register => match my_ue_id {
105- None => {
106- return Err ( UStatus :: fail_with_code (
107- UCode :: INTERNAL ,
108- "Should have been an own ue_id available in this path" ,
109- ) ) ;
110- }
111- Some ( ue_id) => ue_id,
112- } ,
113- DeterminationType :: Send => source_filter. ue_id ,
114- } ;
115- Ok ( RegistrationType :: Publish ( client_id as ClientId ) )
57+ Ok ( RegistrationType :: Publish )
11658 }
11759}
11860
0 commit comments