isup: Attempt a short cut in the link bring up by sending a unblock

Attempt to unblock all circuits after the Gateway has blocked them. In
the ISUP spec we would need to go through the continuity test and such.
diff --git a/include/isup_types.h b/include/isup_types.h
index b28d73f..9ded619 100644
--- a/include/isup_types.h
+++ b/include/isup_types.h
@@ -34,6 +34,8 @@
 #define ISUP_MSG_CGBA	0x1A
 #define ISUP_MSG_RLC	0x10
 #define ISUP_MSG_RSC	0x12
+#define ISUP_MSG_CGU	0x19
+#define ISUP_MSG_CGUA	0x1B
 
 
 struct isup_msg_hdr {
diff --git a/src/isup.c b/src/isup.c
index 45d32ad..3f73029 100644
--- a/src/isup.c
+++ b/src/isup.c
@@ -68,14 +68,14 @@
 	return msg;
 }
 
-static struct msgb *isup_rlc_alloc(int cic)
+static struct msgb *isup_simple_alloc(int cic, int msg_type)
 {
 	struct isup_msg_hdr *hdr;
 	struct msgb *msg;
 
-	msg = msgb_alloc_headroom(4096, 128, "ISUP RSC");
+	msg = msgb_alloc_headroom(4096, 128, "ISUP Simple MSG");
 	if (!msg) {
-		LOGP(DISUP, LOGL_ERROR, "Allocation of GRA message failed.\n");
+		LOGP(DISUP, LOGL_ERROR, "Allocation of Simple message failed.\n");
 		return NULL;
 	}
 
@@ -84,7 +84,7 @@
 	/* write the ISUP header */
 	hdr = (struct isup_msg_hdr *) msg->l2h;
 	hdr->cic = cic;
-	hdr->msg_type = ISUP_MSG_RLC;
+	hdr->msg_type = msg_type;
 
 	msgb_v_put(msg, 0);
 	return msg;
@@ -162,12 +162,26 @@
 	return 0;
 }
 
-static int handle_circuit_reset(struct mtp_link_set *set, int sls, int cic,
-				const uint8_t *data, int size)
+static int send_cgu(struct mtp_link_set *link, int sls, int cic, int range)
+{
+	struct msgb *resp;
+	uint8_t val;
+
+	val = 0;
+	resp = isup_status_alloc(cic, ISUP_MSG_CGU, &val, range, 0);
+	if (!resp)
+		return -1;
+
+	mtp_link_set_submit_isup_data(link, sls, resp->l2h, msgb_l2len(resp));
+	msgb_free(resp);
+	return 0;
+}
+
+static int handle_simple_resp(struct mtp_link_set *set, int sls, int cic, int msg_type)
 {
 	struct msgb *resp;
 
-	resp = isup_rlc_alloc(cic);
+	resp = isup_simple_alloc(cic, msg_type);
 	if (!resp)
 		return -1;
 	mtp_link_set_submit_isup_data(set, sls, resp->l2h, msgb_l2len(resp));
@@ -200,9 +214,14 @@
 		break;
 	case ISUP_MSG_CGB:
 		rc = handle_circuit_reset_cgb(link, sls, hdr->cic, hdr->data, payload_size);
+		if (rc == 0)
+			rc = send_cgu(link, sls, hdr->cic, 28);
+		break;
+	case ISUP_MSG_CGUA:
+		LOGP(DISUP, LOGL_NOTICE, "CIC %d is now unblocked.\n", hdr->cic);
 		break;
 	case ISUP_MSG_RSC:
-		rc = handle_circuit_reset(link, sls, hdr->cic, hdr->data, payload_size);
+		rc = handle_simple_resp(link, sls, hdr->cic, ISUP_MSG_RLC);
 		break;
 	default:
 		mtp_link_set_forward_isup(link, msg, sls);