Skip to content

Commit 72fc0f1

Browse files
committed
Add sample.source.S1AP
1 parent 85de922 commit 72fc0f1

11 files changed

+156
-0
lines changed

examples/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ EXTRA_DIST = \
3535
sample.source.MHEG5 \
3636
sample.source.PKIX1 \
3737
sample.source.RRC \
38+
sample.source.S1AP \
3839
sample.source.TAP3 \
3940
sample.source.ULP \
4041
sample.makefile.regen

examples/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ This directory contains a few examples.
3636
Before trying to compile, read the README file in that directory.
3737
WARNING WARNING WARNING: WORK IN PROGRESS. Not supposed to work yet.
3838

39+
11. The ./sample.source.S1AP directory contain the 3GPP S1AP decoder for
40+
S1AP version 14.4.0. Read the README file in that directory.
41+
3942
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
4043
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
4144
from the corresponding RFC texts (rfc3280.txt, rfc3525.txt, rfc4211.txt).

examples/sample.source.S1AP/Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
ASN_PROGRAM = s1ap-dump
2+
CFLAGS += -DASN_CONVERTER_TITLE="S1AP decoder" -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE
3+
begin: S1AP-PDU.c maybe-wip-pause all
4+
5+
-include Makefile.am.example
6+
7+
S1AP-PDU.c: ../sample.makefile.regen ../s1ap-14.4.0.asn1
8+
make regen-makefile
9+
@touch S1AP-PDU.c
10+
make
11+
12+
regen-makefile:
13+
TITLE="S1AP decoder" \
14+
ASN_CMDOPTS="-fcompound-names -fno-include-deps -findirect-choice -gen-PER -pdu=all" \
15+
ASN_MODULES="../s1ap-14.4.0.asn1" \
16+
ASN_PDU=S1AP-PDU \
17+
ASN_PROGRAM=s1ap-dump \
18+
../sample.makefile.regen
19+
20+
check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
21+
@echo ================
22+
@echo All tests passed
23+
@echo ================
24+
25+
check-ber:
26+
@if test -f sample-S1AP-PDU-1.[db]er ; then \
27+
for f in sample-*-*.[db]er; do \
28+
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
29+
for b in 1 17 33 980 8192; do \
30+
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
31+
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
32+
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
33+
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
34+
rm -f ./.tmp.[12].$$$$; \
35+
echo "Test junking $$f (please wait)..."; \
36+
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
37+
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
38+
done; done; fi
39+
40+
check-xer:
41+
@if test -f sample-S1AP-PDU-1.xer ; then \
42+
for f in sample-*-*.xer; do \
43+
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
44+
for b in 1 17 33 980 8192; do \
45+
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
46+
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
47+
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
48+
diff $$f ./.tmp.2.$$$$ || exit 4; \
49+
rm -f ./.tmp.[12].$$$$; \
50+
echo "Test junking $$f (please wait)..."; \
51+
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
52+
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
53+
done; done; fi
54+
55+
check-oer:
56+
@if test -f sample-S1AP-PDU-1.*oer ; then \
57+
for f in sample-*-*.*oer; do \
58+
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
59+
for b in 1 17 33 980 8192; do \
60+
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
61+
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
62+
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
63+
diff $$f ./.tmp.2.$$$$ || exit 4; \
64+
rm -f ./.tmp.[12].$$$$; \
65+
echo "Test junking $$f (please wait) ($$b) ..."; \
66+
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
67+
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
68+
done; done; fi
69+
70+
check-per:
71+
@if test -f sample-S1AP-PDU-1-nopad.per ; then \
72+
for f in sample-*-[1-9]-nopad.per; do \
73+
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
74+
for b in 1 17 33 980 8192; do \
75+
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
76+
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
77+
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
78+
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
79+
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
80+
rm -f ./.tmp.[123].$$$$; \
81+
echo "Test junking $$f (please wait)..."; \
82+
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
83+
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
84+
done; done; fi
85+
@if test -f sample-S1AP-PDU-1.per ; then \
86+
for f in sample-*-[1-9].per; do \
87+
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
88+
for b in 1 17 33 980 8192; do \
89+
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
90+
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
91+
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
92+
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
93+
diff $$f ./.tmp.1.$$$$ || exit 6; \
94+
rm -f ./.tmp.[12].$$$$; \
95+
echo "Test junking $$f (please wait)..."; \
96+
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
97+
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
98+
done; done; fi
99+
100+
maybe-wip-pause:
101+
@if [ -f WIP ]; then cat WIP; sleep 2; fi
102+
103+
distclean: clean
104+
rm -f $(ASN_MODULE_SOURCES)
105+
rm -f $(ASN_MODULE_HEADERS)
106+
rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS)
107+
rm -f Makefile.am.example

examples/sample.source.S1AP/README

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
GENERAL INFORMATION
3+
===================
4+
5+
The 3GPP TS 36.413 version 14.4.0 S1 Application Protocol (S1AP) APER decoder.
6+
Invoking `make` will compile the ASN.1 specifications from the
7+
../s1ap-14.4.0.asn1 file.
8+
9+
OBTAINING THE S1AP SPECIFICATION
10+
================================
11+
12+
To obtain a different version of S1AP ASN.1 specification, you should go to
13+
http://www.3gpp.org/ftp/Specs/html-info/36413.htm
14+
and download any version of S1AP specification you like.
15+
16+
A .ZIP file with a Microsoft Word .DOC files will download shortly.
17+
18+
You should extract the ASN.1 modules from the chapter 9 of that .DOC file.
19+
Be careful not to copy any preambles, chapter titles and other non-ASN.1 text.
20+
21+
s1ap-dump USAGE
22+
===============
23+
24+
The s1ap-dump utility may be used to dump the contents of a APER-encoded
25+
S1AP protocol data unit. Since S1AP specification contains multiple PDUs,
26+
a PDU must be selected manually using -p <PDU> command line option:
27+
28+
./s1ap-dump -iaper -p S1AP-PDU message.per
29+
30+
The list of recognized PDUs may be obtained using `-p list`.
31+
32+
The full list of recognized command line options may be obtained with
33+
34+
> ./s1ap-dump -h
35+

examples/sample.source.S1AP/config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
extern int opt_debug;
3+
4+
#define ASN_DEBUG(fmt, args...) do { \
5+
if(opt_debug < 2) break; \
6+
fprintf(stderr, fmt, ##args); \
7+
fprintf(stderr, " (%s:%d)\n", \
8+
__FILE__, __LINE__); \
9+
} while(0)
10+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)