aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/asn1msgs.pl
blob: 4b07a3bff352885893416a10ab50d51d1bc2c52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
#use strict;

# small script to extract the types used in elementary procedures
# {HNBAP,RUA,RANAP}-PDU-Descriptions.asn and print them in an ASN.1
# format that will trigger asn1c to generate associated structures
#
# Usage: ./asn1enum.pl < HNBAP-PDU-Descriptions.asn

my $l;
my @a;

while ($l = <STDIN>) {
	chomp($l);
	if ($l =~ /^\s*(\S+\s*\S+)\s+(\S+)\s*$/) {
		if ($1 eq 'INITIATING MESSAGE' ||
		    $1 eq 'SUCCESSFUL OUTCOME' ||
		    $1 eq 'UNSUCCESSFUL OUTCOME' ||
	    	    $1 eq 'OUTCOME') {
			push(@a, $2);
		}
	}
}

foreach my $k (@a) {
	my $lk = $k;
	my $firstchar = substr($lk, 0, 1);
	if ($firstchar =~ /^[A-Z]/) {
		substr($lk, 0, 1, lc($firstchar));
	}
	printf("%s ::= SEQUENCE {\n", $k);
	printf("    %s-ies SEQUENCE (SIZE (0..maxProtocolIEs)) OF IE,\n", $lk);
	printf("    ...\n");
	printf("}\n\n");
}