From 3f78370c92d794126ffaebcc98a72587193aab49 Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Thu, 19 Jan 2006 21:56:10 +0000 Subject: [PATCH] More fixes for RLT git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@301 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- q931.c | 70 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/q931.c b/q931.c index 0ae1a83..66989c8 100644 --- a/q931.c +++ b/q931.c @@ -1174,27 +1174,57 @@ static FUNC_RECV(receive_facility) if (ie->len < 1) return -1; - if ((ie->data[i] & 0xe0) != 0x80) { - pri_error(pri, "!! Invalid Protocol Profile field 0x%X\n", ie->data[i]); - return -1; + if (pri->switchtype != PRI_SWITCH_DMS100) { + if ((ie->data[i] & 0xe0) != 0x80) { + pri_error(pri, "!! Invalid Protocol Profile field 0x%X\n", ie->data[i]); + return -1; + } + switch(next_protocol = protocol = (ie->data[i] & 0x1f)) { + case Q932_PROTOCOL_CMIP: + case Q932_PROTOCOL_ACSE: + if (pri->debug & PRI_DEBUG_APDU) + pri_message(pri, "!! Don't know how to handle Q.932 Protocol Profile of type 0x%X\n", protocol); + return -1; + case Q932_PROTOCOL_EXTENSIONS: + state = Q932_STATE_NFE; + next_protocol = Q932_PROTOCOL_ROSE; + break; + case Q932_PROTOCOL_ROSE: + break; + default: + pri_error(pri, "!! Invalid Q.932 Protocol Profile of type 0x%X received\n", protocol); + return -1; + } + i++; + } else { /* Silly DMS100s */ + switch(next_protocol = protocol = (ie->data[i] & 0x1f)) { + case Q932_PROTOCOL_CMIP: + case Q932_PROTOCOL_ACSE: + if (pri->debug & PRI_DEBUG_APDU) + pri_message(pri, "!! Don't know how to handle Q.932 Protocol Profile of type 0x%X\n", protocol); + return -1; + case Q932_PROTOCOL_EXTENSIONS: + state = Q932_STATE_NFE; + next_protocol = Q932_PROTOCOL_ROSE; + break; + case Q932_PROTOCOL_ROSE: + break; + default: + pri_error(pri, "!! Invalid Q.932 Protocol Profile of type 0x%X received\n", protocol); + return -1; + } + if (!(ie->data[i] & 0x80)) { + i++; + if (((ie->data[i] & 0x7f) != RLT_OPERATION_IND) || !(ie->data[i] & 0x80)) { + pri_error(pri, "!! Do not support operation 0x%x\n", ie->data[i] & 0xff); + return -1; + } + } + i++; } - switch(next_protocol = protocol = (ie->data[i] & 0x1f)) { - case Q932_PROTOCOL_CMIP: - case Q932_PROTOCOL_ACSE: - if (pri->debug & PRI_DEBUG_APDU) - pri_message(pri, "!! Don't know how to handle Q.932 Protocol Profile of type 0x%X\n", protocol); - return -1; - case Q932_PROTOCOL_EXTENSIONS: - state = Q932_STATE_NFE; - next_protocol = Q932_PROTOCOL_ROSE; - break; - case Q932_PROTOCOL_ROSE: - break; - default: - pri_error(pri, "!! Invalid Q.932 Protocol Profile of type 0x%X received\n", protocol); - return -1; - } - i++; + + + if (ie->len < 3) return -1;