3 # This script extracts the ASN1 definition from and TS 36.331 and generates 3 output files that can be processed by asn2wrs
4 # First download the specification from 3gpp.org as a word document and open it
5 # Then in "view" menu, select normal or web layout (needed to removed page header and footers)
6 # Finally save the document as a text file
7 # Call the script: "perl extract_asn1 36331-xxx.txt"
8 # It should generate: EUTRA-RRC-Definitions.asn, EUTRA-UE-Variables.asn and EUTRA-InterNodeDefinitions
10 $input_file = $ARGV[0];
11 $def_output_file = "EUTRA-RRC-Definitions.asn";
12 $var_output_file = "EUTRA-UE-Variables.asn";
13 $internode_output_file = "EUTRA-InterNodeDefinitions.asn";
17 open(INPUT_FILE, "< $input_file") or die "Can not open file $input_file";
19 while (<INPUT_FILE>) {
20 # Process the EUTRA-RRC-Definitions section
21 if( m/EUTRA-RRC-Definitions DEFINITIONS AUTOMATIC TAGS ::=/){
22 open(OUTPUT_FILE, "> $def_output_file") or die "Can not open file $def_output_file";
23 syswrite OUTPUT_FILE,"$_ \n";
24 syswrite OUTPUT_FILE,"BEGIN\n\n";
26 # Get all the text delimited by -- ASN1START and -- ASN1STOP
29 syswrite OUTPUT_FILE,"END\n\n";
33 # Process the EUTRA-RRC-Variables section
34 if( m/EUTRA-UE-Variables DEFINITIONS AUTOMATIC TAGS ::=/){
35 open(OUTPUT_FILE, "> $var_output_file") or die "Can not open file $def_output_file";
36 syswrite OUTPUT_FILE,"$_ \n";
37 syswrite OUTPUT_FILE,"BEGIN\n\n";
39 # Get all the text delimited by -- ASN1START and -- ASN1STOP
42 syswrite OUTPUT_FILE,"END\n\n";
45 # Process the EUTRA-InterNodeDefinitions section
46 if( m/EUTRA-InterNodeDefinitions DEFINITIONS AUTOMATIC TAGS ::=/){
47 open(OUTPUT_FILE, "> $internode_output_file") or die "Can not open file $def_output_file";
48 syswrite OUTPUT_FILE,"$_ \n";
49 syswrite OUTPUT_FILE,"BEGIN\n\n";
51 # Get all the text delimited by -- ASN1START and -- ASN1STOP
54 syswrite OUTPUT_FILE,"END\n\n";
61 # This subroutine copies the text delimited by -- ASN1START and -- ASN1STOP in INPUT_FILE
62 # and copies it into OUTPUT_FILE.
63 # It stops when it meets the keyword "END"
65 my $line = <INPUT_FILE>;
68 while(($line ne "END\n") && ($line ne "END\r\n")){
69 if ($line =~ m/-- ASN1STOP/) {
73 syswrite OUTPUT_FILE,"$line";
75 if ($line =~ m/-- ASN1START/) {