blob: 4b07a3bff352885893416a10ab50d51d1bc2c52a [file] [log] [blame]
Harald Welte8d602672015-08-30 19:49:16 +02001#!/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
10my $l;
11my @a;
12
13while ($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
25foreach 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}