From 1e81b32beada20d0b05c2e59e35962710648544b Mon Sep 17 00:00:00 2001 From: "Bi-Ruei, Chiu" Date: Thu, 2 Nov 2017 15:05:30 +0800 Subject: [PATCH] Add sample.source.S1AP --- examples/Makefile.am | 1 + examples/README | 3 + examples/sample.source.S1AP/Makefile | 106 ++++++++++++++++++ examples/sample.source.S1AP/README | 35 ++++++ examples/sample.source.S1AP/config.h | 10 ++ .../sample-DownlinkNASTransport.aper | Bin 0 -> 74 bytes .../sample-S1AP-InitialContextSetup.aper | Bin 0 -> 293 bytes .../sample-S1AP-InitialUEMessage.aper | Bin 0 -> 88 bytes .../sample-S1AP-InitialUEMessage2.aper | Bin 0 -> 155 bytes .../sample-S1AP-InitiatingMessage.aper | Bin 0 -> 78 bytes .../sample-S1AP-UplinkNASTransport.aper | Bin 0 -> 59 bytes 11 files changed, 155 insertions(+) create mode 100644 examples/sample.source.S1AP/Makefile create mode 100644 examples/sample.source.S1AP/README create mode 100644 examples/sample.source.S1AP/config.h create mode 100644 examples/sample.source.S1AP/sample-DownlinkNASTransport.aper create mode 100644 examples/sample.source.S1AP/sample-S1AP-InitialContextSetup.aper create mode 100644 examples/sample.source.S1AP/sample-S1AP-InitialUEMessage.aper create mode 100644 examples/sample.source.S1AP/sample-S1AP-InitialUEMessage2.aper create mode 100644 examples/sample.source.S1AP/sample-S1AP-InitiatingMessage.aper create mode 100644 examples/sample.source.S1AP/sample-S1AP-UplinkNASTransport.aper diff --git a/examples/Makefile.am b/examples/Makefile.am index fd861e7f8..db831a475 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -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 diff --git a/examples/README b/examples/README index 49821c3dd..c86a8c9f4 100644 --- a/examples/README +++ b/examples/README @@ -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). diff --git a/examples/sample.source.S1AP/Makefile b/examples/sample.source.S1AP/Makefile new file mode 100644 index 000000000..d3a58c5ef --- /dev/null +++ b/examples/sample.source.S1AP/Makefile @@ -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 diff --git a/examples/sample.source.S1AP/README b/examples/sample.source.S1AP/README new file mode 100644 index 000000000..26fc6ad8e --- /dev/null +++ b/examples/sample.source.S1AP/README @@ -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 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 + diff --git a/examples/sample.source.S1AP/config.h b/examples/sample.source.S1AP/config.h new file mode 100644 index 000000000..2dda9297a --- /dev/null +++ b/examples/sample.source.S1AP/config.h @@ -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) + diff --git a/examples/sample.source.S1AP/sample-DownlinkNASTransport.aper b/examples/sample.source.S1AP/sample-DownlinkNASTransport.aper new file mode 100644 index 0000000000000000000000000000000000000000..8dba884785ab4b52c3e99cad842b9c42dd364633 GIT binary patch literal 74 zcmV-Q0JZ-B00RI300qDS0B~0T2ml0t8%F&A8UQjeCxm#D?*V*Nh_TdC704ah7$O8k gNn?uZXN4r_2c2L6GNqTk2YMoVnBCNUm*$`xJ^Yp#$N&HU literal 0 HcmV?d00001 diff --git a/examples/sample.source.S1AP/sample-S1AP-InitialContextSetup.aper b/examples/sample.source.S1AP/sample-S1AP-InitialContextSetup.aper new file mode 100644 index 0000000000000000000000000000000000000000..266d47b253f892b19d7c6eea6feb6eadb01f6b96 GIT binary patch literal 293 zcmZSJWN1`iVBlb2U|?ck1ky|l#tcpjToSCYUJVH>N4799NH8=^XJ9a4Xqf2Az{<|w zutr4b5KuW|L!)}gua$3@*qxa4*%XYvdNSBD_y;i_WMq|NOGzv$&&*>^&d+7b%}X}0 zG-1n4PBt<&Wl1k6DrRK_8u1~H?ccvm^B5S^r5hR)xtJIkxEk3GtYBn>a+*OLrU345 zK!Y2AE(2O9t`q6$#oYQs+=PW$Uhq>2qdh}51FHlB4^YyRK|$r>I`unt37?zY#h=C8 zjr+gxtfaz8?sW>g)5HHv-df_rpy^;(0dgkL1OdU1fC7#Ok~ G7#RS@+)0H1 literal 0 HcmV?d00001 diff --git a/examples/sample.source.S1AP/sample-S1AP-InitialUEMessage.aper b/examples/sample.source.S1AP/sample-S1AP-InitialUEMessage.aper new file mode 100644 index 0000000000000000000000000000000000000000..f5b9ac6bfe674d24b649bc4af9dc2ac6538c7abb GIT binary patch literal 88 zcmZSJaR^~xU}fN7U}7+4kYdo$W_K*&{$}*mvw?w;fq{XMt<8 literal 0 HcmV?d00001 diff --git a/examples/sample.source.S1AP/sample-S1AP-UplinkNASTransport.aper b/examples/sample.source.S1AP/sample-S1AP-UplinkNASTransport.aper new file mode 100644 index 0000000000000000000000000000000000000000..d2de17b3a92454a22674a97124b35ec6b11f6895 GIT binary patch literal 59 zcmZSJbuedOU}a!nU}9io-~f`w3{nhyyz0wXbQ77_of(*e7!EO{IB+l+ef4Bu5MW?% Jc3=auZ2_