aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/asn1enum.pl
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-08-30 19:09:55 +0200
committerHarald Welte <laforge@gnumonks.org>2015-08-30 19:09:55 +0200
commit3bd59c9d596e6ca884adfd9074cf07df69d00067 (patch)
treed55f8234dd7d6d9f53c67671185ba3e9ab9034bb /asn1/asn1enum.pl
parentf24cabee154b21d7a57d88bd180dc4f4b38cad1b (diff)
Add Procedure Codes and IEI constants to CommonDataTypes
... this is what's required for asn1c to generate nice C language enums for it. Conversion was performed semi-automatically by use of asn1enum.pl
Diffstat (limited to 'asn1/asn1enum.pl')
-rwxr-xr-xasn1/asn1enum.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/asn1/asn1enum.pl b/asn1/asn1enum.pl
new file mode 100755
index 0000000..8584e84
--- /dev/null
+++ b/asn1/asn1enum.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+use strict;
+
+# small script to extract the constants from
+# {HNBAP,RUA,RANAP}-Constants.asn and print them in an ASN.1 format that
+# will trigger asn1c to generate associated enums in C.
+#
+# Usage: ./asn1enum.pl < HNBAP-Constants.asn
+
+my $l;
+my %h;
+
+while ($l = <STDIN>) {
+ chomp($l);
+ if ($l =~ /^(\S+)\s+(\S+)\s+::=\s+(\d+)/) {
+ $h{$2}{$3} = $1;
+ }
+}
+
+foreach my $k (keys %h) {
+ if ($k eq 'INTEGER') {
+ next;
+ }
+ printf("%s ::= INTEGER {\n", $k);
+ foreach my $r (sort { $a <=> $b } keys $h{$k}) {
+ printf("\t%s(%d),\n", $h{$k}{$r}, $r);
+ }
+ printf("}\n");
+}