Skip to content

Commit

Permalink
Add sample.source.S1AP
Browse files Browse the repository at this point in the history
  • Loading branch information
brchiu committed Nov 14, 2017
1 parent 85de922 commit 1e81b32
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ EXTRA_DIST = \
sample.source.MHEG5 \
sample.source.PKIX1 \
sample.source.RRC \
sample.source.S1AP \
sample.source.TAP3 \
sample.source.ULP \
sample.makefile.regen
Expand Down
3 changes: 3 additions & 0 deletions examples/README
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ This directory contains a few examples.
Before trying to compile, read the README file in that directory.
WARNING WARNING WARNING: WORK IN PROGRESS. Not supposed to work yet.

11. The ./sample.source.S1AP directory contain the 3GPP S1AP decoder for
S1AP version 14.4.0. Read the README file in that directory.

The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
from the corresponding RFC texts (rfc3280.txt, rfc3525.txt, rfc4211.txt).
Expand Down
106 changes: 106 additions & 0 deletions examples/sample.source.S1AP/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
ASN_PROGRAM = s1ap-dump
CFLAGS += -DJUNKTEST -D_DEFAULT_SOURCE
begin: S1AP-PDU.c maybe-wip-pause all

-include Makefile.am.example

S1AP-PDU.c: ../sample.makefile.regen ../s1ap-14.4.0.asn1
make regen-makefile
@touch S1AP-PDU.c
make

regen-makefile:
ASN_CMDOPTS="-pdu=auto -fcompound-names -fno-include-deps -gen-PER" \
ASN_MODULES="../s1ap-14.4.0.asn1" \
ASN_PDU=S1AP-PDU \
ASN_PROGRAM=s1ap-dump \
../sample.makefile.regen

check: ${ASN_PROGRAM} check-ber check-xer check-oer check-per
@echo ================
@echo All tests passed
@echo ================

check-ber:
@if test -f sample-S1AP-PDU-1.[db]er ; then \
for f in sample-*-*.[db]er; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
for b in 1 17 33 980 8192; do \
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
done; done; fi

check-xer:
@if test -f sample-S1AP-PDU-1.xer ; then \
for f in sample-*-*.xer; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
for b in 1 17 33 980 8192; do \
echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
diff $$f ./.tmp.2.$$$$ || exit 4; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
done; done; fi

check-oer:
@if test -f sample-S1AP-PDU-1.*oer ; then \
for f in sample-*-*.*oer; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
for b in 1 17 33 980 8192; do \
echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
diff $$f ./.tmp.2.$$$$ || exit 4; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait) ($$b) ..."; \
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
done; done; fi

check-per:
@if test -f sample-S1AP-PDU-1-nopad.per ; then \
for f in sample-*-[1-9]-nopad.per; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
for b in 1 17 33 980 8192; do \
echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
./${ASN_PROGRAM} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
done; done; fi
@if test -f sample-S1AP-PDU-1.per ; then \
for f in sample-*-[1-9].per; do \
pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
for b in 1 17 33 980 8192; do \
echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
./${ASN_PROGRAM} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
./${ASN_PROGRAM} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
./${ASN_PROGRAM} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
diff $$f ./.tmp.1.$$$$ || exit 6; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${ASN_PROGRAM} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
./${ASN_PROGRAM} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
done; done; fi

maybe-wip-pause:
@if [ -f WIP ]; then cat WIP; sleep 2; fi

distclean: clean
rm -f $(ASN_MODULE_SOURCES)
rm -f $(ASN_MODULE_HEADERS)
rm -f $(ASN_PROGRAM_SOURCES) $(ASN_PROGRAM_HEADERS)
rm -f Makefile.am.example
35 changes: 35 additions & 0 deletions examples/sample.source.S1AP/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

GENERAL INFORMATION
===================

The 3GPP TS 36.413 version 14.4.0 S1 Application Protocol (S1AP) APER decoder.
Invoking `make` will compile the ASN.1 specifications from the
../s1ap-14.4.0.asn1 file.

OBTAINING THE S1AP SPECIFICATION
================================

To obtain a different version of S1AP ASN.1 specification, you should go to
http://www.3gpp.org/ftp/Specs/html-info/36413.htm
and download any version of S1AP specification you like.

A .ZIP file with a Microsoft Word .DOC files will download shortly.

You should extract the ASN.1 modules from the chapter 9 of that .DOC file.
Be careful not to copy any preambles, chapter titles and other non-ASN.1 text.

s1ap-dump USAGE
===============

The s1ap-dump utility may be used to dump the contents of a APER-encoded
S1AP protocol data unit. Since S1AP specification contains multiple PDUs,
a PDU must be selected manually using -p <PDU> command line option:

./s1ap-dump -iaper -p S1AP-PDU message.per

The list of recognized PDUs may be obtained using `-p list`.

The full list of recognized command line options may be obtained with

> ./s1ap-dump -h

10 changes: 10 additions & 0 deletions examples/sample.source.S1AP/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

extern int opt_debug;

#define ASN_DEBUG(fmt, args...) do { \
if(opt_debug < 2) break; \
fprintf(stderr, fmt, ##args); \
fprintf(stderr, " (%s:%d)\n", \
__FILE__, __LINE__); \
} while(0)

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 comments on commit 1e81b32

Please sign in to comment.