diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-10 03:53:28 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-10 13:22:46 +0100 |
commit | c21cfaa023686c0c4ff041199ed6a04e48f79d15 (patch) | |
tree | 2ffbf5e5d29723238b26aa8a173db967b294e72f | |
parent | 03ba4f485bdbf79b9efce862940fd871e7b3dc72 (diff) |
isup: Start parsing the ISUP messages
Introduce a ISUP debug category, parse the reset circuit
message, add a test case for this easy parsing.
-rw-r--r-- | contrib/TestSender.st | 5 | ||||
-rw-r--r-- | include/cellmgr_debug.h | 1 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/debug.c | 5 | ||||
-rw-r--r-- | src/isup.c | 51 | ||||
-rw-r--r-- | tests/isup/Makefile.am | 6 | ||||
-rw-r--r-- | tests/isup/isup_parse_test.c | 15 |
7 files changed, 78 insertions, 9 deletions
diff --git a/contrib/TestSender.st b/contrib/TestSender.st index d32348f..4913416 100644 --- a/contrib/TestSender.st +++ b/contrib/TestSender.st @@ -34,9 +34,4 @@ Eval [ msg := #(2 0 0 1 0 0 0 0 0 0 0 6 192 232 197 7 0 23) asByteArray. datagram data: msg. socket nextPut: datagram. - - "ISUP GSR" - msg := #(2 0 0 1 0 0 0 0 0 0 0 11 197 8 197 7 224 3 0 23 1 1 28) asByteArray. - datagram data: msg. - socket nextPut: datagram. ] diff --git a/include/cellmgr_debug.h b/include/cellmgr_debug.h index 3d22cab..c3edd8a 100644 --- a/include/cellmgr_debug.h +++ b/include/cellmgr_debug.h @@ -10,6 +10,7 @@ enum { DMSC, DSCCP, DMGCP, + DISUP, }; extern const struct log_info log_info; diff --git a/src/Makefile.am b/src/Makefile.am index e1e69b7..4ca99f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,12 +11,12 @@ mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS) cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \ bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c \ - msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c + msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c isup.c cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \ -lpthread -lnetsnmp -lcrypto udt_relay_SOURCES = main_udt.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \ msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c \ - bss_patch.c + bss_patch.c isup.c udt_relay_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \ -lpthread -lnetsnmp -lcrypto diff --git a/src/debug.c b/src/debug.c index 4382a47..93f4160 100644 --- a/src/debug.c +++ b/src/debug.c @@ -45,6 +45,11 @@ static const struct log_info_cat default_categories[] = { .description = "Media Gateway Control Protocol", .enabled = 1, .loglevel = LOGL_NOTICE, }, + [DISUP] = { + .name = "DISUP", + .description = "ISUP", + .enabled = 1, .loglevel = LOGL_NOTICE, + }, }; static int filter_fn(const struct log_context *ctx, diff --git a/src/isup.c b/src/isup.c new file mode 100644 index 0000000..a98e4b5 --- /dev/null +++ b/src/isup.c @@ -0,0 +1,51 @@ +/* + * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> + * (C) 2010 by On-Waves + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <isup_types.h> +#include <cellmgr_debug.h> + +/* this message contains the range */ +int isup_parse_grs(const uint8_t *data, uint8_t in_length) +{ + uint8_t ptr; + uint8_t length; + + if (in_length > 3) { + LOGP(DISUP, LOGL_ERROR, "This needs three bytes.\n"); + return -1; + } + + ptr = data[0]; + if (1 + ptr > in_length) { + LOGP(DISUP, LOGL_ERROR, "Pointing outside the packet.\n"); + return -1; + } + + length = data[0 + ptr]; + + if (1 + ptr + 1 > in_length) { + LOGP(DISUP, LOGL_ERROR, "No space for the data.\n"); + return -1; + } + + return data[0 + ptr + 1]; +} + diff --git a/tests/isup/Makefile.am b/tests/isup/Makefile.am index 4c51d25..d8ba492 100644 --- a/tests/isup/Makefile.am +++ b/tests/isup/Makefile.am @@ -1,4 +1,6 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) noinst_PROGRAMS = isup_parse_test -isup_parse_test_SOURCES = isup_parse_test.c +isup_parse_test_SOURCES = isup_parse_test.c $(top_srcdir)/src/isup.c +isup_parse_test_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/tests/isup/isup_parse_test.c b/tests/isup/isup_parse_test.c index 8f99cdb..721e9ce 100644 --- a/tests/isup/isup_parse_test.c +++ b/tests/isup/isup_parse_test.c @@ -41,8 +41,23 @@ static void test_cic_parsing() ASSERT(hdr->msg_type, ISUP_MSG_GRS); } +static void test_grs_parsing() +{ + static const uint8_t isup_grs[] = {3, 0, 23, 1, 1, 28}; + struct isup_msg_hdr *hdr; + int range; + + hdr = (struct isup_msg_hdr *) isup_grs; + range = isup_parse_grs(&hdr->data[0], 3); + + ASSERT(range, 28); +} + int main(int argc, char **argv) { test_cic_parsing(); + test_grs_parsing(); + + printf("All tests passed.\n"); return 0; } |