isup: Start parsing the ISUP messages
Introduce a ISUP debug category, parse the reset circuit message, add a test case for this easy parsing.
This commit is contained in:
parent
03ba4f485b
commit
c21cfaa023
|
@ -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.
|
||||
]
|
||||
|
|
|
@ -10,6 +10,7 @@ enum {
|
|||
DMSC,
|
||||
DSCCP,
|
||||
DMGCP,
|
||||
DISUP,
|
||||
};
|
||||
|
||||
extern const struct log_info log_info;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Reference in New Issue