Harald Welte | 8d60267 | 2015-08-30 19:49:16 +0200 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | #use strict; |
| 3 | |
| 4 | # small script to extract the types used in elementary procedures |
| 5 | # {HNBAP,RUA,RANAP}-PDU-Descriptions.asn and print them in an ASN.1 |
| 6 | # format that will trigger asn1c to generate associated structures |
| 7 | # |
| 8 | # Usage: ./asn1enum.pl < HNBAP-PDU-Descriptions.asn |
| 9 | |
| 10 | my $l; |
| 11 | my @a; |
| 12 | |
| 13 | while ($l = <STDIN>) { |
| 14 | chomp($l); |
| 15 | if ($l =~ /^\s*(\S+\s*\S+)\s+(\S+)\s*$/) { |
| 16 | if ($1 eq 'INITIATING MESSAGE' || |
| 17 | $1 eq 'SUCCESSFUL OUTCOME' || |
| 18 | $1 eq 'UNSUCCESSFUL OUTCOME' || |
| 19 | $1 eq 'OUTCOME') { |
| 20 | push(@a, $2); |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | foreach my $k (@a) { |
| 26 | my $lk = $k; |
| 27 | my $firstchar = substr($lk, 0, 1); |
| 28 | if ($firstchar =~ /^[A-Z]/) { |
| 29 | substr($lk, 0, 1, lc($firstchar)); |
| 30 | } |
| 31 | printf("%s ::= SEQUENCE {\n", $k); |
| 32 | printf(" %s-ies SEQUENCE (SIZE (0..maxProtocolIEs)) OF IE,\n", $lk); |
| 33 | printf(" ...\n"); |
| 34 | printf("}\n\n"); |
| 35 | } |