1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2001-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19 20%%%------------------------------------------------------------------- 21-module(extensionAdditionGroup). 22-include("Extension-Addition-Group.hrl"). 23-export([run/1]). 24 25-compile(export_all). 26 27run(Erule) -> 28 Val = #'Ax'{a=253,b=true,c={e,true},g="123",h=true}, 29 Enc = hex_to_binary(encoded_ax(Erule)), 30 roundtrip('Ax', Val, Enc), 31 32 Val2 = #'Ax3'{a=253,b=true,s=#'Ax3_s'{sa=11,sb=true,sextaddgroup=17}}, 33 roundtrip('Ax3', Val2), 34 35 run3(), 36 run3(Erule), 37 38 roundtrip('InlinedSeq', #'InlinedSeq'{s=#'InlinedSeq_s'{a=42,b=true}}), 39 roundtrip('ExtAddGroup1', #'ExtAddGroup1'{x=42,y=1023}), 40 41 ok. 42 43%% From X.691 (07/2002) A.4. 44encoded_ax(per) -> "9E000180 010291A4"; 45encoded_ax(uper) -> "9E000600 040A4690"; 46encoded_ax(ber) -> none; 47encoded_ax(jer) -> none. 48 49hex_to_binary(none) -> 50 none; 51hex_to_binary(L) -> 52 << <<(hex_digit_to_binary(D)):4>> || D <- L, D =/= $\s >>. 53 54hex_digit_to_binary(D) -> 55 if 56 $0 =< D, D =< $9 -> D - $0; 57 $A =< D, D =< $F -> D - ($A-10) 58 end. 59run3(Erule) -> 60 Val = 61{'RRC-DL-DCCH-Message', 62 {c1, 63 {rrcConnectionReconfiguration, 64 {'RRC-RRCConnectionReconfiguration',0, 65 {c1, 66 {'rrcConnectionReconfiguration-r8', 67 {'RRC-RRCConnectionReconfiguration-r8-IEs', 68 {'RRC-MeasConfig',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, 69 asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, 70 asn1_NOVALUE,asn1_NOVALUE}, 71 asn1_NOVALUE, 72 [<<80,66,0,5,10,0,5,0,24,11,7,84,54,33,0,1,1,0,0,0,1,39,5,66,127,0,0,1>>, 73 <<>>], 74 {'RRC-RadioResourceConfigDedicated', 75 [{'RRC-SRB-ToAddMod',1, 76 {explicitValue, 77 {am, 78 {'RRC-RLC-Config_am', 79 {'RRC-UL-AM-RLC',ms45,pInfinity,kBinfinity,t4}, 80 {'RRC-DL-AM-RLC',ms35,ms0}}}}, 81 {explicitValue, 82 {'RRC-LogicalChannelConfig', 83 {'RRC-LogicalChannelConfig_ul-SpecificParameters',3,infinity, 84 ms50,0}, 85 asn1_NOVALUE}}}], 86 [{'RRC-DRB-ToAddMod',3,3, 87 {'RRC-PDCP-Config',infinity, 88 {'RRC-PDCP-Config_rlc-AM',false}, 89 asn1_NOVALUE, 90 {notUsed,'NULL'}}, 91 {am, 92 {'RRC-RLC-Config_am', 93 {'RRC-UL-AM-RLC',ms70,p256,kBinfinity,t4}, 94 {'RRC-DL-AM-RLC',ms35,ms40}}}, 95 3, 96 {'RRC-LogicalChannelConfig', 97 {'RRC-LogicalChannelConfig_ul-SpecificParameters',5,infinity,ms50, 98 1}, 99 asn1_NOVALUE}}, 100 {'RRC-DRB-ToAddMod',4,4, 101 {'RRC-PDCP-Config',infinity, 102 {'RRC-PDCP-Config_rlc-AM',false}, 103 asn1_NOVALUE, 104 {notUsed,'NULL'}}, 105 {am, 106 {'RRC-RLC-Config_am', 107 {'RRC-UL-AM-RLC',ms70,p256,kBinfinity,t4}, 108 {'RRC-DL-AM-RLC',ms35,ms40}}}, 109 4, 110 {'RRC-LogicalChannelConfig', 111 {'RRC-LogicalChannelConfig_ul-SpecificParameters',5,infinity,ms50, 112 1}, 113 asn1_NOVALUE}}], 114 asn1_NOVALUE, 115 {explicitValue, 116 {'RRC-MAC-MainConfig', 117 {'RRC-MAC-MainConfig_ul-SCH-Config',n4,sf10,sf10240,false}, 118 asn1_NOVALUE,sf500, 119 {setup,{'RRC-MAC-MainConfig_phr-Config_setup',sf200,sf200,dB3}}, 120 asn1_NOVALUE}}, 121 asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}, 122 asn1_NOVALUE,asn1_NOVALUE}}}}}}}, 123 io:format("~p:~p~n",[Erule,Val]), 124 {ok,List}= 'EUTRA-RRC-Definitions':encode('DL-DCCH-Message',Val), 125 Enc = iolist_to_binary(List), 126 io:format("Result from encode:~n~p~n",[Enc]), 127 {ok,Val2} = 'EUTRA-RRC-Definitions':decode('DL-DCCH-Message', Enc), 128 io:format("Result from decode:~n~p~n",[Val2]), 129 case Val2 of 130 Val -> ok; 131 _ -> exit({expected,Val, got, Val2}) 132 end. 133 134run3() -> 135 SI = #'SystemInformationBlockType2'{ 136 timeAlignmentTimerCommon = sf500, 137 lateNonCriticalExtension = asn1_NOVALUE, 138 'ssac-BarringForMMTEL-Voice-r9' = asn1_NOVALUE, 139 'ssac-BarringForMMTEL-Video-r9' = asn1_NOVALUE, 140 'ac-BarringForCSFB-r10' = asn1_NOVALUE}, 141 Barring = #'AC-BarringConfig'{ 142 'ac-BarringFactor' = p00, 143 'ac-BarringTime' = s4, 144 'ac-BarringForSpecialAC' = <<0:5>>}, 145 T = 'SystemInformationBlockType2', 146 roundtrip(T, SI), 147 roundtrip(T, SI#'SystemInformationBlockType2'{ 148 'ssac-BarringForMMTEL-Voice-r9'=Barring}), 149 roundtrip(T, SI#'SystemInformationBlockType2'{ 150 'ssac-BarringForMMTEL-Video-r9'=Barring}), 151 roundtrip(T, SI#'SystemInformationBlockType2'{ 152 'ac-BarringForCSFB-r10'=Barring}). 153 154roundtrip(T, V) -> 155 roundtrip(T, V, none). 156 157roundtrip(T, V, Expected) -> 158 Mod = 'Extension-Addition-Group', 159 {ok,E} = Mod:encode(T, V), 160 {ok,V} = Mod:decode(T, E), 161 case Expected of 162 none -> ok; 163 E -> ok 164 end. 165