2
2
3
3
use asn1_codecs_derive:: { AperCodec , UperCodec } ;
4
4
5
- #[ derive( Debug , AperCodec , UperCodec ) ]
5
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
6
6
#[ asn( type = "INTEGER" , lb = "0" , ub = "65535" ) ]
7
7
pub struct ProtocolIE_ID ( u16 ) ;
8
8
9
- #[ derive( Debug , AperCodec , UperCodec ) ]
9
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
10
10
#[ asn( type = "ENUMERATED" , lb = "0" , ub = "2" ) ]
11
11
pub struct Criticality ( u8 ) ;
12
12
impl Criticality {
@@ -15,23 +15,31 @@ impl Criticality {
15
15
const NOTIFY : u8 = 2u8 ;
16
16
}
17
17
18
- #[ derive( Debug , AperCodec , UperCodec ) ]
18
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
19
19
#[ asn( type = "INTEGER" , lb = "0" , ub = "255" ) ]
20
20
pub struct Routing_ID ( u8 ) ;
21
21
22
- #[ derive( Debug , AperCodec , UperCodec ) ]
22
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
23
23
#[ asn( type = "INTEGER" , lb = "0" , ub = "4294967295" ) ]
24
24
pub struct MME_UE_S1AP_ID ( u32 ) ;
25
25
26
- #[ derive( Debug , AperCodec , UperCodec ) ]
26
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
27
27
#[ asn( type = "OCTET-STRING" ) ]
28
28
pub struct LPPa_PDU ( Vec < u8 > ) ;
29
29
30
- #[ derive( Debug , AperCodec , UperCodec ) ]
30
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
31
31
#[ asn( type = "INTEGER" , lb = "0" , ub = "16777215" ) ]
32
32
pub struct ENB_UE_S1AP_ID ( u32 ) ;
33
33
34
- #[ derive( Debug , AperCodec , UperCodec ) ]
34
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
35
+ #[ asn( type = "ENUMERATED" , extensible = true , lb = "0" , ub = "1" ) ]
36
+ pub struct GUAMIType ( pub u8 ) ;
37
+ impl GUAMIType {
38
+ pub const NATIVE : u8 = 0u8 ;
39
+ pub const MAPPED : u8 = 1u8 ;
40
+ }
41
+
42
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
35
43
#[ asn( type = "OPEN" ) ]
36
44
pub enum UplinkUEAssociatedLPPaTransportprotocolIEsItemvalue {
37
45
#[ asn( key = 8 ) ]
@@ -42,9 +50,11 @@ pub enum UplinkUEAssociatedLPPaTransportprotocolIEsItemvalue {
42
50
MME_UE_S1AP_ID ( MME_UE_S1AP_ID ) ,
43
51
#[ asn( key = 148 ) ]
44
52
Routing_ID ( Routing_ID ) ,
53
+ #[ asn( key = 176 ) ]
54
+ Id_GUAMIType ( GUAMIType ) ,
45
55
}
46
56
47
- #[ derive( Debug , AperCodec , UperCodec ) ]
57
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
48
58
#[ asn( type = "SEQUENCE" , extensible = false ) ]
49
59
pub struct UplinkUEAssociatedLPPaTransportprotocolIEsItem {
50
60
#[ asn( key_field = true ) ]
@@ -53,6 +63,64 @@ pub struct UplinkUEAssociatedLPPaTransportprotocolIEsItem {
53
63
pub value : UplinkUEAssociatedLPPaTransportprotocolIEsItemvalue ,
54
64
}
55
65
66
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
67
+ #[ asn(
68
+ type = "SEQUENCE-OF" ,
69
+ sz_extensible = false ,
70
+ sz_lb = "1" ,
71
+ sz_ub = "256"
72
+ ) ]
73
+ pub struct UplinkUEAssociatedLPPaTransportprotocolList ( pub Vec < UplinkUEAssociatedLPPaTransportprotocolItem > ) ;
74
+
75
+ #[ derive( Debug , AperCodec , UperCodec , Eq , PartialEq ) ]
76
+ #[ asn( type = "SEQUENCE" , extensible = true , optional_fields = 1 ) ]
77
+ pub struct UplinkUEAssociatedLPPaTransportprotocolItem {
78
+ #[ asn( optional_idx = 0 ) ]
79
+ pub ie_extensions : Option < UplinkUEAssociatedLPPaTransportprotocolIEsItem > ,
80
+ }
81
+
56
82
fn main ( ) {
57
83
eprintln ! ( "Open" ) ;
58
84
}
85
+
86
+ #[ cfg( test) ]
87
+ mod tests {
88
+ use asn1_codecs:: aper:: AperCodec ;
89
+ use asn1_codecs:: PerCodecData ;
90
+ use super :: * ;
91
+
92
+ /// Test whether encoding and then decoding a list of optional extensions that include an open
93
+ /// enumeration type results in the same object.
94
+ ///
95
+ /// This function was added because of a bug that appeared in
96
+ /// #[126](https://github.com/ystero-dev/hampi/issues/126).
97
+ #[ test]
98
+ fn test_encode_decode_open_type ( ) {
99
+ let original_test_value = UplinkUEAssociatedLPPaTransportprotocolList ( vec ! [ UplinkUEAssociatedLPPaTransportprotocolItem {
100
+ ie_extensions: Some (
101
+ UplinkUEAssociatedLPPaTransportprotocolIEsItem {
102
+ id: ProtocolIE_ID ( 176 ) ,
103
+ criticality: Criticality ( 0 ) ,
104
+ value: UplinkUEAssociatedLPPaTransportprotocolIEsItemvalue :: Id_GUAMIType (
105
+ GUAMIType ( 0 )
106
+ ) ,
107
+ }
108
+ ) ,
109
+ } , UplinkUEAssociatedLPPaTransportprotocolItem {
110
+ ie_extensions: Some (
111
+ UplinkUEAssociatedLPPaTransportprotocolIEsItem {
112
+ id: ProtocolIE_ID ( 176 ) ,
113
+ criticality: Criticality ( 0 ) ,
114
+ value: UplinkUEAssociatedLPPaTransportprotocolIEsItemvalue :: Id_GUAMIType (
115
+ GUAMIType ( 0 )
116
+ ) ,
117
+ }
118
+ ) ,
119
+ } ] ) ;
120
+ let mut test_value_encoded = PerCodecData :: new_aper ( ) ;
121
+ original_test_value. aper_encode ( & mut test_value_encoded) . unwrap ( ) ;
122
+
123
+ let test_value_decoded = UplinkUEAssociatedLPPaTransportprotocolList :: aper_decode ( & mut test_value_encoded) . unwrap ( ) ;
124
+ assert_eq ! ( original_test_value, test_value_decoded) ;
125
+ }
126
+ }
0 commit comments