Index: pri_facility.c =================================================================== RCS file: /usr/cvsroot/libpri/pri_facility.c,v retrieving revision 1.22 diff -u -r1.22 pri_facility.c --- pri_facility.c 16 Sep 2005 17:15:57 -0000 1.22 +++ pri_facility.c 21 Sep 2005 18:37:52 -0000 @@ -33,6 +33,78 @@ #include #include +static void rose_debug(struct pri *pri, struct rose_component *comp, int len) +{ + int i, j; + char *data = (unsigned char *)comp; + char *data2 = alloca(len * 3), *pos1, *pos2; + unsigned char ascii; + + if (data2) { + pos1 = data; + pos2 = data2; + for (i=0; i=0;j--) { + if (ascii >= j * 16) { + if (j > 9) { + pos2[0] = 96 + j - 9; + } else { + pos2[0] = 48 + j; + } + ascii -= (j * 16); + if (ascii > 9) { + pos2[1] = 96 + ascii - 9; + } else { + pos2[1] = 48 + ascii; + } + break; + } + } + pos2[2] = ' '; + pos2 += 3; + pos1++; + } + pos2[0] = '\0'; + pri_message(pri, "PRI RAW [%s]\n", data2 + 1); + } +} + +static char *asn1id2text(int id) +{ + static char *strings[] = { + "none", + "Boolean", + "Integer", + "Bit String", + "Octet String", + "NULL", + "Object Identifier", + "Object Descriptor", + "External Reference", + "Real Number", + "Enumerated", + "Embedded PDV", + "UTF-8 String", + "Relative Object ID", + "Reserved (0e)", + "Reserved (0f)", + "Sequence", + "Set", + "Numberic String", + "Printable String", + "Tele-Text String", + "IA-5 String", + "UTC Time", + "Generalized Time", + }; + if (id > 0 && id <= 0x18) { + return strings[id]; + } else { + return "Unknown"; + } +} + static unsigned char get_invokeid(struct pri *pri) { return ++pri->last_invoke; @@ -261,7 +333,7 @@ do { GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, ASN1_NUMERICSTRING, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x\n"); + CHECK_COMPONENT(comp, ASN1_NUMERICSTRING, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x (%s)\n"); if(comp->len > 20 && comp->len != ASN1_LEN_INDEF) { pri_message(pri, "!! Oversized NumberDigits component (%d)\n", comp->len); return -1; @@ -295,7 +367,7 @@ do { GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x\n"); + CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x (%s)\n"); ASN1_GET_INTEGER(comp, ton); NEXT_COMPONENT(comp, i); ton = typeofnumber_for_q931(pri, ton); @@ -463,13 +535,13 @@ do { /* diversionCounter stuff */ GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do it diversionCounter is of type 0x%x\n"); + CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do it diversionCounter is of type 0x%x (%s)\n"); ASN1_GET_INTEGER(comp, diversion_counter); NEXT_COMPONENT(comp, i); /* diversionReason stuff */ GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid diversionReason type 0x%X of ROSE divertingLegInformation2 component received\n"); + CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid diversionReason type 0x%X (%s) of ROSE divertingLegInformation2 component received\n"); ASN1_GET_INTEGER(comp, diversion_reason); NEXT_COMPONENT(comp, i); @@ -933,7 +1005,7 @@ do { GET_COMPONENT(comp, pos1, vdata, len); - CHECK_COMPONENT(comp, ASN1_ENUMERATED, "!! Invalid AOC Charging Request argument. Expected Enumerated (0x0A) but Received 0x%02X\n"); + CHECK_COMPONENT(comp, ASN1_ENUMERATED, "!! Invalid AOC Charging Request argument. Expected 0x0A (Enumerated) but Received 0x%02X (%s)\n"); ASN1_GET_INTEGER(comp, chargingcase); if (chargingcase >= 0 && chargingcase <= 2) { if (pri->debug & PRI_DEBUG_APDU) @@ -967,7 +1039,7 @@ do { GET_COMPONENT(comp1, pos1, vdata, len); /* AOCEChargingUnitInfo */ - CHECK_COMPONENT(comp1, ASN1_SEQUENCE, "!! Invalid AOC-E Charging Unit argument. Expected Sequence (0x30) but Received 0x%02X\n"); + CHECK_COMPONENT(comp1, ASN1_SEQUENCE, "!! Invalid AOC-E Charging Unit argument. Expected 0x30 (Sequence) but Received 0x%02X (%s)\n"); SUB_COMPONENT(comp1, pos1); GET_COMPONENT(comp1, pos1, vdata, len); switch (comp1->type) { @@ -982,7 +1054,7 @@ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* RecordedUnitsList (0xA1) */ SUB_COMPONENT(comp2, pos2); GET_COMPONENT(comp2, pos2, vdata, len); - CHECK_COMPONENT(comp2, ASN1_SEQUENCE, "!! Invalid AOC-E Charging Unit argument. Expected Sequence (0x30) but received 0x02%X\n"); /* RecordedUnits */ + CHECK_COMPONENT(comp2, ASN1_SEQUENCE, "!! Invalid AOC-E Charging Unit argument. Expected 0x30 (Sequence) but received 0x02%X (%s)\n"); /* RecordedUnits */ sublen3 = pos2 + comp2->len; pos3 = pos2; comp3 = comp2; @@ -1136,13 +1208,13 @@ do { /* Invoke ID stuff */ GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n"); + CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x (%s)\n"); invokeid = comp; NEXT_COMPONENT(comp, i); /* Operation Tag */ GET_COMPONENT(comp, i, vdata, len); - CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second ROSE component is of type 0x%x\n"); + CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second ROSE component is of type 0x%x (%s)\n"); operationid = comp; ASN1_GET_INTEGER(comp, operation_tag); NEXT_COMPONENT(comp, i); Index: pri_facility.h =================================================================== RCS file: /usr/cvsroot/libpri/pri_facility.h,v retrieving revision 1.9 diff -u -r1.9 pri_facility.h --- pri_facility.h 12 Jul 2005 20:15:20 -0000 1.9 +++ pri_facility.h 21 Sep 2005 18:37:52 -0000 @@ -168,7 +168,8 @@ #define CHECK_COMPONENT(component, comptype, message) \ if ((component)->type && ((component)->type & ASN1_TYPE_MASK) != (comptype)) { \ - pri_message(pri, (message), (component)->type); \ + pri_message(pri, (message), (component)->type, asn1id2text((component)->type)); \ + rose_debug(pri, component, (component)->len); \ break; \ }