Adding debug level for APDUs
git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@196 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
1
libpri.h
1
libpri.h
@@ -37,6 +37,7 @@
|
||||
#define PRI_DEBUG_Q931_DUMP (1 << 5) /* Show interpreted Q.931 frames */
|
||||
#define PRI_DEBUG_Q931_STATE (1 << 6) /* Debug Q.931 state machine changes */
|
||||
#define PRI_DEBUG_Q931_ANOMALY (1 << 7) /* Show unexpected events */
|
||||
#define PRI_DEBUG_APDU (1 << 8) /* Debug of APDU components such as ROSE */
|
||||
|
||||
#define PRI_DEBUG_ALL (0xffff) /* Everything */
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
static unsigned char get_invokeid(struct pri *pri)
|
||||
{
|
||||
return ++pri->last_invoke;
|
||||
@@ -359,10 +357,8 @@ static int rose_diverting_leg_information2_decode(struct pri *pri, q931_call *ca
|
||||
|
||||
diversion_reason = redirectingreason_for_q931(pri, diversion_reason);
|
||||
|
||||
#ifdef DEBUG
|
||||
if(pri->debug)
|
||||
if(pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Redirection reason: %d, total diversions: %d\n", diversion_reason, diversion_counter);
|
||||
#endif
|
||||
|
||||
for(; i < len; NEXT_COMPONENT(comp, i)) {
|
||||
GET_COMPONENT(comp, i, vdata, len);
|
||||
@@ -370,22 +366,18 @@ static int rose_diverting_leg_information2_decode(struct pri *pri, q931_call *ca
|
||||
case 0xA1: /* divertingnr: presentednumberunscreened */
|
||||
if(rose_presented_number_unscreened_decode(pri, call, comp->data, comp->len, &divertingnr) != 0)
|
||||
return -1;
|
||||
#ifdef DEBUG
|
||||
if (pri->debug) {
|
||||
if (pri->debug & PRI_DEBUG_APDU) {
|
||||
pri_message(" Received divertingNr '%s'\n", divertingnr.partyaddress);
|
||||
pri_message(" ton = %d, pres = %d, npi = %d\n", divertingnr.ton, divertingnr.pres, divertingnr.npi);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 0xA2: /* originalCalledNr: PresentedNumberUnscreened */
|
||||
if(rose_presented_number_unscreened_decode(pri, call, comp->data, comp->len, &originalcallednr) != 0)
|
||||
return -1;
|
||||
#ifdef DEBUG
|
||||
if (pri->debug) {
|
||||
if (pri->debug & PRI_DEBUG_APDU) {
|
||||
pri_message(" Received originalcallednr '%s'\n", originalcallednr.partyaddress);
|
||||
pri_message(" ton = %d, pres = %d, npi = %d\n", originalcallednr.ton, originalcallednr.pres, originalcallednr.npi);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
pri_message("!! Invalid DivertingLegInformation2 component received 0x%X\n", comp->type);
|
||||
@@ -803,23 +795,18 @@ extern int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *d
|
||||
if (!comp->type)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
pri_message(" [ Handling operation %d ]\n", operation_tag);
|
||||
#endif
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" [ Handling operation %d ]\n", operation_tag);
|
||||
switch (operation_tag) {
|
||||
case SS_CNID_CALLINGNAME:
|
||||
#ifdef DEBUG
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Handle Name display operation\n");
|
||||
#endif
|
||||
switch (comp->type) {
|
||||
switch (comp->type & PRI_DEBUG_APDU) {
|
||||
case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
|
||||
memcpy(call->callername, comp->data, comp->len);
|
||||
call->callername[comp->len] = 0;
|
||||
#ifdef DEBUG
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Received caller name '%s'\n", call->callername);
|
||||
#endif
|
||||
return 0;
|
||||
default:
|
||||
pri_message("Do not handle argument of type 0x%X\n", comp->type);
|
||||
@@ -827,10 +814,8 @@ extern int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *d
|
||||
}
|
||||
break;
|
||||
case ROSE_DIVERTING_LEG_INFORMATION2:
|
||||
#ifdef DEBUG
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message(" Handle DivertingLegInformation2\n");
|
||||
#endif
|
||||
if (comp->type != 0x30) { /* Sequence */
|
||||
pri_message("Invalid DivertingLegInformation2Type argument\n");
|
||||
return -1;
|
||||
|
||||
10
q931.c
10
q931.c
@@ -1298,7 +1298,7 @@ static FUNC_RECV(receive_facility)
|
||||
break; \
|
||||
} \
|
||||
state = my_state; \
|
||||
if (pri->debug) \
|
||||
if (pri->debug & PRI_DEBUG_APDU) \
|
||||
pri_message("Q.932 %s component is not handled\n", name); \
|
||||
break;
|
||||
|
||||
@@ -1312,7 +1312,7 @@ static FUNC_RECV(receive_facility)
|
||||
switch(next_protocol = protocol = (ie->data[i] & 0x1f)) {
|
||||
case Q932_PROTOCOL_CMIP:
|
||||
case Q932_PROTOCOL_ACSE:
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message("!! Don't know how to handle Q.932 Protocol Profile of type 0x%X\n", protocol);
|
||||
return -1;
|
||||
case Q932_PROTOCOL_EXTENSIONS:
|
||||
@@ -1351,7 +1351,7 @@ static FUNC_RECV(receive_facility)
|
||||
Q932_HANDLE_NULL(COMP_TYPE_RETURN_ERROR, Q932_STATE_SERVICE, "ROSE return error", NULL);
|
||||
Q932_HANDLE_NULL(COMP_TYPE_REJECT, Q932_STATE_SERVICE, "ROSE reject", NULL);
|
||||
default:
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message("Don't know how to handle ROSE component of type 0x%X\n", comp->type);
|
||||
break;
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ static FUNC_RECV(receive_facility)
|
||||
case Q932_PROTOCOL_CMIP:
|
||||
switch (comp->type) {
|
||||
default:
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message("Don't know how to handle CMIP component of type 0x%X\n", comp->type);
|
||||
break;
|
||||
}
|
||||
@@ -1367,7 +1367,7 @@ static FUNC_RECV(receive_facility)
|
||||
case Q932_PROTOCOL_ACSE:
|
||||
switch (comp->type) {
|
||||
default:
|
||||
if (pri->debug)
|
||||
if (pri->debug & PRI_DEBUG_APDU)
|
||||
pri_message("Don't know how to handle ACSE component of type 0x%X\n", comp->type);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user