isup: Start parsing the ISUP messages

Introduce a ISUP debug category, parse the reset circuit
message, add a test case for this easy parsing.
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 @@
 
 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 @@
 		.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];
+}
+