diff -Naur libpri-1.4-2009-01-29/pri_facility.c libpri-1.4-2009-01-29.new/pri_facility.c --- libpri-1.4-2009-01-29/pri_facility.c 2009-08-11 13:35:51.000000000 +0200 +++ libpri-1.4-2009-01-29.new/pri_facility.c 2009-08-11 13:46:22.000000000 +0200 @@ -1095,13 +1095,12 @@ ASN1_FIXUP(compstk, compsp, dst, i); break; case PRES_RESTRICTED: - /* tag component [1] presentationRestricted (0x81,len) */ + /* tag component [1] presentationRestricted (0x81,0) */ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), dst, i); break; case PRES_UNAVAILABLE: - /* tag component [2] numberNotAvailableDueToInterworking (0x82,len) */ + /* tag component [2] numberNotAvailableDueToInterworking (0x82,0) */ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), dst, i); - ASN1_FIXUP(compstk, compsp, dst, i); break; default: pri_message(pri, "!! Undefined presentation value for PresentedNumberUnscreened: 0x%x\n", presentation); @@ -2374,30 +2373,30 @@ int qsig_cf_callrerouting(struct pri *pri, q931_call *c, const char* dest, const char* original, const char* reason) { /*CallRerouting ::= OPERATION - -- Sent from the Served User PINX to the Rerouting PINX - ARGUMENT SEQUENCE - { reroutingReason DiversionReason, - originalReroutingReason [0] IMPLICIT DiversionReason OPTIONAL, - calledAddress Address, - diversionCounter INTEGER (1..15), - pSS1InfoElement PSS1InformationElement, - -- The basic call information elements Bearer capability, High layer compatibility, Low - -- layer compatibity, Progress indicator and Party category can be embedded in the - -- pSS1InfoElement in accordance with 6.5.3.1.5 - lastReroutingNr [1] PresentedNumberUnscreened, - subscriptionOption [2] IMPLICIT SubscriptionOption, - - callingPartySubaddress [3] PartySubaddress OPTIONAL, - - callingNumber [4] PresentedNumberScreened, - - callingName [5] Name OPTIONAL, - originalCalledNr [6] PresentedNumberUnscreened OPTIONAL, - redirectingName [7] Name OPTIONAL, - originalCalledName [8] Name OPTIONAL, - extension CHOICE { - [9] IMPLICIT Extension , - [10] IMPLICIT SEQUENCE OF Extension } OPTIONAL } + -- Sent from the Served User PINX to the Rerouting PINX + ARGUMENT SEQUENCE + { reroutingReason DiversionReason, + originalReroutingReason [0] IMPLICIT DiversionReason OPTIONAL, + calledAddress Address, + diversionCounter INTEGER (1..15), + pSS1InfoElement PSS1InformationElement, + -- The basic call information elements Bearer capability, High layer compatibility, Low + -- layer compatibity, Progress indicator and Party category can be embedded in the + -- pSS1InfoElement in accordance with 6.5.3.1.5 + lastReroutingNr [1] PresentedNumberUnscreened, + subscriptionOption [2] IMPLICIT SubscriptionOption, + + callingPartySubaddress [3] PartySubaddress OPTIONAL, + + callingNumber [4] PresentedNumberScreened, + + callingName [5] Name OPTIONAL, + originalCalledNr [6] PresentedNumberUnscreened OPTIONAL, + redirectingName [7] Name OPTIONAL, + originalCalledName [8] Name OPTIONAL, + extension CHOICE { + [9] IMPLICIT Extension , + [10] IMPLICIT SEQUENCE OF Extension } OPTIONAL } */ int i = 0, j; @@ -2468,20 +2467,27 @@ ASN1_FIXUP(compstk, compsp, buffer, i); /* diversionCounter INTEGER (1..15) */ - ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, 1); + ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, (c->redirectingcount >= 15)?15:c->redirectingcount+1); /* pSS1InfoElement */ ASN1_ADD_SIMPLE(comp, (ASN1_APPLICATION | ASN1_TAG_0 ), buffer, i); ASN1_PUSH(compstk, compsp, comp); buffer[i++] = (0x04); /* add BC */ - buffer[i++] = (0x03); - buffer[i++] = (0x80); - buffer[i++] = (0x90); - buffer[i++] = (0xa3); + if ((c->transmoderate & 0x60) == 0) { /* circuit mode */ + buffer[i++] = (0x03); /* length */ + buffer[i++] = (0x80 | c->transcapability); /* coding standard: ETSI/CCIT; Info transfer capability: speech, unrestr., restr., 3.1kHz, audio */ + buffer[i++] = (0x90); /* transfer mode: circuit mode; info transfer rate: 64kbit/sec */ + buffer[i++] = (0xa3); /* level1 id; user information level 1 protocol = G.711 alaw */ + } else { /* packet mode */ + buffer[i++] = (0x02); /* length */ + buffer[i++] = (0x80 | c->transcapability); /* coding standard: ETSI/CCIT; Info transfer capability: speech, unrestr., restr., 3.1kHz, audio */ + buffer[i++] = (0x80); /* transfer mode: packet mode; info transfer rate: packet mode */ + } buffer[i++] = (0x95); buffer[i++] = (0x32); buffer[i++] = (0x01); buffer[i++] = (0x81); + ASN1_FIXUP(compstk, compsp, buffer, i); /* lastReroutingNr [1]*/ @@ -2508,35 +2514,43 @@ ASN1_FIXUP(compstk, compsp, buffer, i); /* subscriptionOption [2]*/ - /* implicit optional lastReroutingNr tag */ + /* implicit lastReroutingNr tag */ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* noNotification */ /* callingNumber [4]*/ - /* implicit optional callingNumber tag */ + /* implicit callingNumber tag */ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4), buffer, i); ASN1_PUSH(compstk, compsp, comp); - /* implicit choice presented number screened tag */ - ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i); - ASN1_PUSH(compstk, compsp, comp); - - /* implicit choice presentationAllowedAddress tag */ - ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i); - ASN1_PUSH(compstk, compsp, comp); - /* type of public party number = subscriber number */ - ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 4); - j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, c->callernum, strlen(c->callernum)); - if (j < 0) - return -1; + if (strlen(c->callernum) + && ((c->callerpres & 0x60) == 0x00)) { /* number presentation allowed */ + /* implicit choice presented number screened tag = presentationAllowedAddress */ + ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i); + ASN1_PUSH(compstk, compsp, comp); + /* implicit choice presentationAllowedAddress tag = publicParty Number */ + ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i); + ASN1_PUSH(compstk, compsp, comp); + /* type of public party number = unknown */ + ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0); + j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, c->callernum, strlen(c->callernum)); + if (j < 0) + return -1; + i += j; + ASN1_FIXUP(compstk, compsp, buffer, i); + /* Screeening Indicator network provided */ + ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 3); - i += j; - ASN1_FIXUP(compstk, compsp, buffer, i); + ASN1_FIXUP(compstk, compsp, buffer, i); - /* Screeening Indicator network provided */ - ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 3); + } else if ((c->callerpres & 0x60) == 0x20) { /* number presentation prohibited */ + /* implicit choice presented number screened tag = presentationRestricted */ + ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i); + } else { + /* implicit choice presented number screened tag = numberNotAvailableDueToInterworking */ + ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i); + } ASN1_FIXUP(compstk, compsp, buffer, i); - ASN1_FIXUP(compstk, compsp, buffer, i); /**/