diff options
author | Anders Broman <anders.broman@ericsson.com> | 2009-01-07 19:57:51 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2009-01-07 19:57:51 +0000 |
commit | 9d86f2759a4abfd381d0356a9af7e0b4b40d970e (patch) | |
tree | b23e17308c6cd3d7b13e39333bc16e78e1226739 /tools/extract_asn1_from_spec.pl | |
parent | dbb9f54e4f5a14198c869532ba15ad31a4096dfe (diff) | |
download | wireshark-9d86f2759a4abfd381d0356a9af7e0b4b40d970e.tar.gz |
From Vincent Helfre:
To make it possible to extract the ASN1 files directly from the spec, I wrote a small script.
svn path=/trunk/; revision=27178
Diffstat (limited to 'tools/extract_asn1_from_spec.pl')
-rw-r--r-- | tools/extract_asn1_from_spec.pl | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tools/extract_asn1_from_spec.pl b/tools/extract_asn1_from_spec.pl new file mode 100644 index 0000000000..971fe2a266 --- /dev/null +++ b/tools/extract_asn1_from_spec.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# This script extracts the ASN1 definition from and TS 36.331 and generates 3 output files that can be processed by asn2wrs +# First download the specification from 3gpp.org as a word document and open it +# Then in "view" menu, select normal or web layout (needed to removed page header and footers) +# Finally save the document as a text file +# Call the script: "perl extract_asn1 36331-xxx.txt" +# It should generate: EUTRA-RRC-Definitions.asn, EUTRA-UE-Variables.asn and EUTRA-InterNodeDefinitions +use warnings; +$input_file = $ARGV[0]; +$def_output_file = "EUTRA-RRC-Definitions.asn"; +$var_output_file = "EUTRA-UE-Variables.asn"; +$internode_output_file = "EUTRA-InterNodeDefinitions.asn"; + +sub extract_asn1; + +open(INPUT_FILE, "< $input_file") or die "Can not open file $input_file"; + +while (<INPUT_FILE>) { + # Process the EUTRA-RRC-Definitions section + if( m/EUTRA-RRC-Definitions DEFINITIONS AUTOMATIC TAGS ::=/){ + open(OUTPUT_FILE, "> $def_output_file") or die "Can not open file $def_output_file"; + syswrite OUTPUT_FILE,"$_ \n"; + syswrite OUTPUT_FILE,"BEGIN\n\n"; + + # Get all the text delimited by -- ASN1START and -- ASN1STOP + extract_asn1(); + + syswrite OUTPUT_FILE,"END\n\n"; + close(OUTPUT_FILE); + } + + # Process the EUTRA-RRC-Variables section + if( m/EUTRA-UE-Variables DEFINITIONS AUTOMATIC TAGS ::=/){ + open(OUTPUT_FILE, "> $var_output_file") or die "Can not open file $def_output_file"; + syswrite OUTPUT_FILE,"$_ \n"; + syswrite OUTPUT_FILE,"BEGIN\n\n"; + + # Get all the text delimited by -- ASN1START and -- ASN1STOP + extract_asn1(); + + syswrite OUTPUT_FILE,"END\n\n"; + close(OUTPUT_FILE); + } + # Process the EUTRA-InterNodeDefinitions section + if( m/EUTRA-InterNodeDefinitions DEFINITIONS AUTOMATIC TAGS ::=/){ + open(OUTPUT_FILE, "> $internode_output_file") or die "Can not open file $def_output_file"; + syswrite OUTPUT_FILE,"$_ \n"; + syswrite OUTPUT_FILE,"BEGIN\n\n"; + + # Get all the text delimited by -- ASN1START and -- ASN1STOP + extract_asn1(); + + syswrite OUTPUT_FILE,"END\n\n"; + close(OUTPUT_FILE); + } +} + +close(INPUT_FILE); + +# This subroutine copies the text delimited by -- ASN1START and -- ASN1STOP in INPUT_FILE +# and copies it into OUTPUT_FILE. +# It stops when it meets the keyword "END" +sub extract_asn1 { + my $line = <INPUT_FILE>; + my $is_asn1 = 0; + + while(($line ne "END\n") && ($line ne "END\r\n")){ + if ($line =~ m/-- ASN1STOP/) { + $is_asn1 = 0; + } + if ($is_asn1 == 1){ + syswrite OUTPUT_FILE,"$line"; + } + if ($line =~ m/-- ASN1START/) { + $is_asn1 = 1; + } + $line = <INPUT_FILE>; + } +} |