diff --git a/configure.ac b/configure.ac index de760fd..dd2b04a 100644 --- a/configure.ac +++ b/configure.ac @@ -44,4 +44,5 @@ AC_OUTPUT( tests/Makefile tests/mtp/Makefile tests/patching/Makefile + tests/isup/Makefile Makefile) diff --git a/contrib/TestSender.st b/contrib/TestSender.st index 4913416..d32348f 100644 --- a/contrib/TestSender.st +++ b/contrib/TestSender.st @@ -34,4 +34,9 @@ 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/isup_types.h b/include/isup_types.h new file mode 100644 index 0000000..51c5e79 --- /dev/null +++ b/include/isup_types.h @@ -0,0 +1,49 @@ +/* + * (C) 2010 by Holger Hans Peter Freyther + * (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. + * + */ + +#ifndef isup_types_h +#define isup_types_h + +#include + +struct msgb; +struct mtp_link; + +/* This is from Table 4/Q.763 */ +#define ISUP_MSG_GRS 0x17 +#define ISUP_MSG_GRA 0x29 + +struct isup_msg_hdr { + uint16_t cic : 12, + spare : 4; + uint8_t msg_type; + uint8_t data[0]; +} __attribute__((packed)); + +struct isup_msg_grs { + uint8_t pointer_int; +}; + +int mtp_link_forward_isup(struct mtp_link *link, struct msgb *msg, int sls); + +int isup_parse_grs(const uint8_t *data, uint8_t length); + +#endif diff --git a/tests/Makefile.am b/tests/Makefile.am index b38aa6a..6ffa86d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1 +1 @@ -SUBDIRS = mtp patching +SUBDIRS = mtp patching isup diff --git a/tests/isup/Makefile.am b/tests/isup/Makefile.am new file mode 100644 index 0000000..4c51d25 --- /dev/null +++ b/tests/isup/Makefile.am @@ -0,0 +1,4 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall +noinst_PROGRAMS = isup_parse_test + +isup_parse_test_SOURCES = isup_parse_test.c diff --git a/tests/isup/isup_parse_test.c b/tests/isup/isup_parse_test.c new file mode 100644 index 0000000..8f99cdb --- /dev/null +++ b/tests/isup/isup_parse_test.c @@ -0,0 +1,48 @@ +/* + * (C) 2010 by Holger Hans Peter Freyther + * (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 + +#include +#include + +#define ASSERT(got,want) \ + if (got != want) { \ + fprintf(stderr, "Values should be the same 0x%x 0x%x at %s:%d\n", \ + got, want, __FILE__, __LINE__); \ + abort(); \ + } + +static void test_cic_parsing() +{ + static const uint8_t isup_grs[] = {3, 0, 23, 1, 1, 28}; + struct isup_msg_hdr *hdr; + + hdr = (struct isup_msg_hdr *) isup_grs; + ASSERT(hdr->cic, 3); + ASSERT(hdr->msg_type, ISUP_MSG_GRS); +} + +int main(int argc, char **argv) +{ + test_cic_parsing(); + return 0; +}