From 433ea2f037effc600543823e5b3fa8ec540b989a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 10 Dec 2010 07:34:01 +0100 Subject: isup: Implement handling GRS and GRA messages for ISUP. --- src/isup.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/mtp_layer3.c | 4 +++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/isup.c b/src/isup.c index a98e4b5..8cb91a9 100644 --- a/src/isup.c +++ b/src/isup.c @@ -22,6 +22,8 @@ #include #include +#include + /* this message contains the range */ int isup_parse_grs(const uint8_t *data, uint8_t in_length) { @@ -49,3 +51,44 @@ int isup_parse_grs(const uint8_t *data, uint8_t in_length) return data[0 + ptr + 1]; } + +/* Handle incoming ISUP data */ +static int handle_circuit_reset_grs(struct mtp_link *link, int sls, + const uint8_t *data, int size) +{ + int range; + + range = isup_parse_grs(data, size); + if (range < 0) + return -1; + + printf("ASKED to reset range: %d\n", range); + + return 0; +} + +int mtp_link_forward_isup(struct mtp_link *link, struct msgb *msg, int sls) +{ + int rc = -1; + int payload_size; + struct isup_msg_hdr *hdr; + + if (msgb_l3len(msg) < sizeof(*hdr)) { + LOGP(DISUP, LOGL_ERROR, "ISUP header is too short.\n"); + return -1; + } + + hdr = (struct isup_msg_hdr *) msg->l3h; + payload_size = msgb_l3len(msg) - sizeof(*hdr); + + switch (hdr->msg_type) { + case ISUP_MSG_GRS: + rc = handle_circuit_reset_grs(link, sls, hdr->data, payload_size); + break; + default: + LOGP(DISUP, LOGL_NOTICE, "ISUP msg not handled: 0x%x\n", hdr->msg_type); + break; + } + + return rc; +} diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c index 7dd3a7f..4490c8b 100644 --- a/src/mtp_layer3.c +++ b/src/mtp_layer3.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -486,7 +487,8 @@ int mtp_link_data(struct mtp_link *link, struct msgb *msg) rc = mtp_link_sccp_data(link, hdr, msg, l3_len); break; case MTP_SI_MNT_ISUP: - LOGP(DINP, LOGL_ERROR, "ISUP handling not implemented.\n"); + msg->l3h = &hdr->data[0]; + rc = mtp_link_forward_isup(link, msg, MTP_LINK_SLS(hdr->addr)); break; default: fprintf(stderr, "Unhandled: %u\n", hdr->ser_ind); -- cgit v1.2.3