1189
/* QSIG CF CallRerouting */
1190
int qsig_cf_callrerouting(struct pri *pri, q931_call *c, const char* dest, const char* original, const char* reason)
1192
/*CallRerouting ::= OPERATION
1193
-- Sent from the Served User PINX to the Rerouting PINX
1195
{ reroutingReason DiversionReason,
1196
originalReroutingReason [0] IMPLICIT DiversionReason OPTIONAL,
1197
calledAddress Address,
1198
diversionCounter INTEGER (1..15),
1199
pSS1InfoElement PSS1InformationElement,
1200
-- The basic call information elements Bearer capability, High layer compatibility, Low
1201
-- layer compatibity, Progress indicator and Party category can be embedded in the
1202
-- pSS1InfoElement in accordance with 6.5.3.1.5
1203
lastReroutingNr [1] PresentedNumberUnscreened,
1204
subscriptionOption [2] IMPLICIT SubscriptionOption,
1206
callingPartySubaddress [3] PartySubaddress OPTIONAL,
1208
callingNumber [4] PresentedNumberScreened,
1210
callingName [5] Name OPTIONAL,
1211
originalCalledNr [6] PresentedNumberUnscreened OPTIONAL,
1212
redirectingName [7] Name OPTIONAL,
1213
originalCalledName [8] Name OPTIONAL,
1215
[9] IMPLICIT Extension ,
1216
[10] IMPLICIT SEQUENCE OF Extension } OPTIONAL }
1221
unsigned char buffer[255] = "";
1223
struct rose_component *comp = NULL, *compstk[10];
1225
static unsigned char op_tag[] = {
1229
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
1230
/* Interpretation component */
1232
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
1233
ASN1_PUSH(compstk, compsp, comp);
1234
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0);
1235
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0);
1236
ASN1_FIXUP(compstk, compsp, buffer, i);
1238
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 2); /* reject - to get feedback from QSIG switch */
1240
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
1241
ASN1_PUSH(compstk, compsp, comp);
1243
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
1245
res = asn1_string_encode(ASN1_INTEGER, &buffer[i], sizeof(buffer)-i, sizeof(op_tag), op_tag, sizeof(op_tag));
1250
/* call rerouting argument */
1251
ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
1252
ASN1_PUSH(compstk, compsp, comp);
1254
/* reroutingReason DiversionReason */
1257
if (!strcasecmp(reason, "cfu"))
1258
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 1); /* cfu */
1259
else if (!strcasecmp(reason, "cfb"))
1260
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 2); /* cfb */
1261
else if (!strcasecmp(reason, "cfnr"))
1262
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 3); /* cfnr */
1264
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0); /* unknown */
1268
/* calledAddress Address */
1269
/* explicit sequence tag for Address */
1270
ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
1271
ASN1_PUSH(compstk, compsp, comp);
1272
/* implicit choice public party number tag */
1273
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
1274
ASN1_PUSH(compstk, compsp, comp);
1275
/* type of public party number = unknown */
1276
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0);
1277
/* NumberDigits of public party number */
1278
j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, (char*)dest, strlen(dest));
1283
ASN1_FIXUP(compstk, compsp, buffer, i);
1284
ASN1_FIXUP(compstk, compsp, buffer, i);
1286
/* diversionCounter INTEGER (1..15) */
1287
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, 1);
1289
/* pSS1InfoElement */
1290
ASN1_ADD_SIMPLE(comp, (ASN1_APPLICATION | ASN1_TAG_0 ), buffer, i);
1291
ASN1_PUSH(compstk, compsp, comp);
1292
buffer[i++] = (0x04); /* add BC */
1293
buffer[i++] = (0x03);
1294
buffer[i++] = (0x80);
1295
buffer[i++] = (0x90);
1296
buffer[i++] = (0xa3);
1297
buffer[i++] = (0x95);
1298
buffer[i++] = (0x32);
1299
buffer[i++] = (0x01);
1300
buffer[i++] = (0x81);
1301
ASN1_FIXUP(compstk, compsp, buffer, i);
1303
/* lastReroutingNr [1]*/
1304
/* implicit optional lastReroutingNr tag */
1305
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
1306
ASN1_PUSH(compstk, compsp, comp);
1308
/* implicit choice presented number unscreened tag */
1309
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
1310
ASN1_PUSH(compstk, compsp, comp);
1312
/* implicit choice public party number tag */
1313
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
1314
ASN1_PUSH(compstk, compsp, comp);
1315
/* type of public party number = unknown */
1316
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0);
1317
j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, original?(char*)original:c->callednum, original?strlen(original):strlen(c->callednum));
1322
ASN1_FIXUP(compstk, compsp, buffer, i);
1323
ASN1_FIXUP(compstk, compsp, buffer, i);
1324
ASN1_FIXUP(compstk, compsp, buffer, i);
1326
/* subscriptionOption [2]*/
1327
/* implicit optional lastReroutingNr tag */
1328
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* noNotification */
1330
/* callingNumber [4]*/
1331
/* implicit optional callingNumber tag */
1332
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4), buffer, i);
1333
ASN1_PUSH(compstk, compsp, comp);
1335
/* implicit choice presented number screened tag */
1336
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
1337
ASN1_PUSH(compstk, compsp, comp);
1339
/* implicit choice presentationAllowedAddress tag */
1340
ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
1341
ASN1_PUSH(compstk, compsp, comp);
1342
/* type of public party number = subscriber number */
1343
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 4);
1344
j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, c->callernum, strlen(c->callernum));
1349
ASN1_FIXUP(compstk, compsp, buffer, i);
1351
/* Screeening Indicator network provided */
1352
ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 3);
1354
ASN1_FIXUP(compstk, compsp, buffer, i);
1355
ASN1_FIXUP(compstk, compsp, buffer, i);
1359
ASN1_FIXUP(compstk, compsp, buffer, i);
1360
ASN1_FIXUP(compstk, compsp, buffer, i);
1362
res = pri_call_apdu_queue(c, Q931_FACILITY, buffer, i, NULL, NULL);
1364
pri_message(pri, "Could not queue ADPU in facility message\n");
1368
/* Remember that if we queue a facility IE for a facility message we
1369
* have to explicitly send the facility message ourselves */
1371
res = q931_facility(c->pri, c);
1373
pri_message(pri, "Could not schedule facility message for call %d\n", c->cr);
1379
/* End QSIG CC-CallRerouting */
1381
static int anfpr_pathreplacement_respond(struct pri *pri, q931_call *call, q931_ie *ie)
1385
res = pri_call_apdu_queue_cleanup(call->bridged_call);
1387
pri_message(pri, "Could not Clear queue ADPU\n");
1392
res = pri_call_apdu_queue(call->bridged_call, Q931_FACILITY, ie->data, ie->len, NULL, NULL);
1394
pri_message(pri, "Could not queue ADPU in facility message\n");
1398
/* Remember that if we queue a facility IE for a facility message we
1399
* have to explicitly send the facility message ourselves */
1401
res = q931_facility(call->bridged_call->pri, call->bridged_call);
1403
pri_message(pri, "Could not schedule facility message for call %d\n", call->bridged_call->cr);
1410
int anfpr_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
1412
/* Did all the tests to see if we're on the same PRI and
1413
* are on a compatible switchtype */
1417
unsigned char buffer[255] = "";
1418
unsigned short call_reference = c2->cr;
1419
struct rose_component *comp = NULL, *compstk[10];
1420
unsigned char buffer2[255] = "";
1422
static unsigned char op_tag[] = {
1427
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
1428
/* Interpretation component */
1430
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
1431
ASN1_PUSH(compstk, compsp, comp);
1432
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0);
1433
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0);
1434
ASN1_FIXUP(compstk, compsp, buffer, i);
1436
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 2); /* reject - to get feedback from QSIG switch */
1438
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
1439
ASN1_PUSH(compstk, compsp, comp);
1441
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
1443
res = asn1_string_encode(ASN1_INTEGER, &buffer[i], sizeof(buffer)-i, sizeof(op_tag), op_tag, sizeof(op_tag));
1448
ASN1_ADD_SIMPLE(comp, (ASN1_SEQUENCE | ASN1_CONSTRUCTOR), buffer, i);
1449
ASN1_PUSH(compstk, compsp, comp);
1450
buffer[i++] = (0x0a);
1451
buffer[i++] = (0x01);
1452
buffer[i++] = (0x00);
1453
buffer[i++] = (0x81);
1454
buffer[i++] = (0x00);
1455
buffer[i++] = (0x0a);
1456
buffer[i++] = (0x01);
1457
buffer[i++] = (0x01);
1458
ASN1_ADD_WORDCOMP(comp, ASN1_INTEGER, buffer, i, call_reference);
1459
ASN1_FIXUP(compstk, compsp, buffer, i);
1460
ASN1_FIXUP(compstk, compsp, buffer, i);
1462
res = pri_call_apdu_queue(c1, Q931_FACILITY, buffer, i, NULL, NULL);
1464
pri_message(pri, "Could not queue ADPU in facility message\n");
1468
/* Remember that if we queue a facility IE for a facility message we
1469
* have to explicitly send the facility message ourselves */
1471
res = q931_facility(c1->pri, c1);
1473
pri_message(pri, "Could not schedule facility message for call %d\n", c1->cr);
1482
buffer2[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
1483
/* Interpretation component */
1485
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer2, i);
1486
ASN1_PUSH(compstk, compsp, comp);
1487
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer2, i, 0);
1488
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer2, i, 0);
1489
ASN1_FIXUP(compstk, compsp, buffer2, i);
1491
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer2, i, 2); /* reject */
1493
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer2, i);
1494
ASN1_PUSH(compstk, compsp, comp);
1496
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer2, i, get_invokeid(pri));
1498
res = asn1_string_encode(ASN1_INTEGER, &buffer2[i], sizeof(buffer2)-i, sizeof(op_tag), op_tag, sizeof(op_tag));
1503
ASN1_ADD_SIMPLE(comp, (ASN1_SEQUENCE | ASN1_CONSTRUCTOR), buffer2, i);
1504
ASN1_PUSH(compstk, compsp, comp);
1505
buffer2[i++] = (0x0a);
1506
buffer2[i++] = (0x01);
1507
buffer2[i++] = (0x01);
1508
buffer2[i++] = (0x81);
1509
buffer2[i++] = (0x00);
1510
buffer2[i++] = (0x0a);
1511
buffer2[i++] = (0x01);
1512
buffer2[i++] = (0x01);
1513
ASN1_ADD_WORDCOMP(comp, ASN1_INTEGER, buffer2, i, call_reference);
1514
ASN1_FIXUP(compstk, compsp, buffer2, i);
1515
ASN1_FIXUP(compstk, compsp, buffer2, i);
1518
res = pri_call_apdu_queue(c2, Q931_FACILITY, buffer2, i, NULL, NULL);
1520
pri_message(pri, "Could not queue ADPU in facility message\n");
1524
/* Remember that if we queue a facility IE for a facility message we
1525
* have to explicitly send the facility message ourselves */
1527
res = q931_facility(c2->pri, c2);
1529
pri_message(pri, "Could not schedule facility message for call %d\n", c1->cr);
1138
1538
static int aoc_aoce_charging_request_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
1343
int rose_reject_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
1743
static int rose_calling_name_decode(struct pri *pri, q931_call *call, struct rose_component *choice, int len)
1746
struct rose_component *comp = NULL;
1747
unsigned char *vdata = choice->data;
1748
int characterSet = 1;
1749
switch (choice->type) {
1750
case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
1751
memcpy(call->callername, choice->data, choice->len);
1752
call->callername[choice->len] = 0;
1753
if (pri->debug & PRI_DEBUG_APDU)
1754
pri_message(pri, " Received simple calling name '%s'\n", call->callername);
1757
case ROSE_NAME_PRESENTATION_ALLOWED_EXTENDED:
1759
GET_COMPONENT(comp, i, vdata, len);
1760
CHECK_COMPONENT(comp, ASN1_OCTETSTRING, "Don't know what to do if nameData is of type 0x%x\n");
1761
memcpy(call->callername, comp->data, comp->len);
1762
call->callername[comp->len] = 0;
1763
NEXT_COMPONENT(comp, i);
1765
GET_COMPONENT(comp, i, vdata, len);
1766
CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if CharacterSet is of type 0x%x\n");
1767
ASN1_GET_INTEGER(comp, characterSet);
1771
if (pri->debug & PRI_DEBUG_APDU)
1772
pri_message(pri, " Received extended calling name '%s', characterset %d\n", call->callername, characterSet);
1774
case ROSE_NAME_PRESENTATION_RESTRICTED_SIMPLE:
1775
case ROSE_NAME_PRESENTATION_RESTRICTED_EXTENDED:
1776
case ROSE_NAME_PRESENTATION_RESTRICTED_NULL:
1777
case ROSE_NAME_NOT_AVAIL:
1779
if (pri->debug & PRI_DEBUG_APDU)
1780
pri_message(pri, "Do not handle argument of type 0x%X\n", choice->type);
1784
/* ===== Call Transfer Supplementary Service (ECMA-178) ===== */
1786
static int rose_party_number_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
1790
struct rose_component *comp = NULL;
1791
unsigned char *vdata = data;
1795
GET_COMPONENT(comp, i, vdata, len);
1797
switch(comp->type) {
1798
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT NumberDigits -- default: unknownPartyNumber */
1799
if (pri->debug & PRI_DEBUG_APDU)
1800
pri_message(pri, " PartyNumber: UnknownPartyNumber len=%d\n", len);
1801
size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
1804
value->npi = PRI_NPI_UNKNOWN;
1805
value->ton = PRI_TON_UNKNOWN;
1808
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] IMPLICIT PublicPartyNumber */
1809
if (pri->debug & PRI_DEBUG_APDU)
1810
pri_message(pri, " PartyNumber: PublicPartyNumber len=%d\n", len);
1811
size = rose_public_party_number_decode(pri, call, comp->data, comp->len, value);
1814
value->npi = PRI_NPI_E163_E164;
1817
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT NumberDigits -- not used: dataPartyNumber */
1818
pri_message(pri, "!! PartyNumber: dataPartyNumber is reserved!\n");
1819
size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
1822
value->npi = PRI_NPI_X121 /* ??? */;
1823
value->ton = PRI_TON_UNKNOWN /* ??? */;
1826
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4): /* [4] IMPLICIT NumberDigits -- not used: telexPartyNumber */
1827
pri_message(pri, "!! PartyNumber: telexPartyNumber is reserved!\n");
1828
size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
1831
value->npi = PRI_NPI_F69 /* ??? */;
1832
value->ton = PRI_TON_UNKNOWN /* ??? */;
1835
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] IMPLICIT PrivatePartyNumber */
1836
if (pri->debug & PRI_DEBUG_APDU)
1837
pri_message(pri, " PartyNumber: PrivatePartyNumber len=%d\n", len);
1838
size = rose_private_party_number_decode(pri, call, comp->data, comp->len, value);
1841
value->npi = PRI_NPI_PRIVATE;
1844
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_8): /* [8] IMPLICIT NumberDigits -- not used: nationalStandatdPartyNumber */
1845
pri_message(pri, "!! PartyNumber: nationalStandardPartyNumber is reserved!\n");
1846
size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
1849
value->npi = PRI_NPI_NATIONAL;
1850
value->ton = PRI_TON_NATIONAL;
1854
pri_message(pri, "Invalid PartyNumber component 0x%X\n", comp->type);
1857
ASN1_FIXUP_LEN(comp, size);
1858
if (pri->debug & PRI_DEBUG_APDU)
1859
pri_message(pri, " PartyNumber: '%s' size=%d len=%d\n", value->partyaddress, size, len);
1868
static int rose_number_screened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
1872
struct rose_component *comp = NULL;
1873
unsigned char *vdata = data;
1879
GET_COMPONENT(comp, i, vdata, len);
1880
size = rose_party_number_decode(pri, call, (u_int8_t *)comp, comp->len + 2, (struct addressingdataelements_presentednumberunscreened*) value);
1884
NEXT_COMPONENT(comp, i);
1886
/* Screening Indicator */
1887
GET_COMPONENT(comp, i, vdata, len);
1888
CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with NumberScreened ROSE component type 0x%x\n");
1889
ASN1_GET_INTEGER(comp, scrind);
1890
// Todo: scrind = screeningindicator_for_q931(pri, scrind);
1891
NEXT_COMPONENT(comp, i);
1893
value->scrind = scrind;
1895
if (pri->debug & PRI_DEBUG_APDU)
1896
pri_message(pri, " NumberScreened: '%s' ScreeningIndicator=%d i=%d len=%d\n", value->partyaddress, scrind, i, len);
1898
return i-2; // We do not have a sequence header here.
1906
static int rose_presented_number_screened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
1910
struct rose_component *comp = NULL;
1911
unsigned char *vdata = data;
1913
/* Fill in default values */
1914
value->ton = PRI_TON_UNKNOWN;
1915
value->npi = PRI_NPI_UNKNOWN;
1916
value->pres = -1; /* Data is not available */
1919
GET_COMPONENT(comp, i, vdata, len);
1921
switch(comp->type) {
1922
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT presentationAllowedNumber */
1923
if (pri->debug & PRI_DEBUG_APDU)
1924
pri_message(pri, " PresentedNumberScreened: presentationAllowedNumber comp->len=%d\n", comp->len);
1925
value->pres = PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
1926
size = rose_number_screened_decode(pri, call, comp->data, comp->len, value);
1929
ASN1_FIXUP_LEN(comp, size);
1932
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1): /* [1] IMPLICIT presentationRestricted */
1933
if (pri->debug & PRI_DEBUG_APDU)
1934
pri_message(pri, " PresentedNumberScreened: presentationRestricted comp->len=%d\n", comp->len);
1935
if (comp->len != 0) { /* must be NULL */
1936
pri_error(pri, "!! Invalid PresentationRestricted component received (len != 0)\n");
1939
value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
1942
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] IMPLICIT numberNotAvailableDueToInterworking */
1943
if (pri->debug & PRI_DEBUG_APDU)
1944
pri_message(pri, " PresentedNumberScreened: NumberNotAvailableDueToInterworking comp->len=%d\n", comp->len);
1945
if (comp->len != 0) { /* must be NULL */
1946
pri_error(pri, "!! Invalid NumberNotAvailableDueToInterworking component received (len != 0)\n");
1949
value->pres = PRES_NUMBER_NOT_AVAILABLE;
1950
if (pri->debug & PRI_DEBUG_APDU)
1951
pri_message(pri, " PresentedNumberScreened: numberNotAvailableDueToInterworking Type=0x%X i=%d len=%d size=%d\n", comp->type, i, len);
1954
case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT presentationRestrictedNumber */
1955
if (pri->debug & PRI_DEBUG_APDU)
1956
pri_message(pri, " PresentedNumberScreened: presentationRestrictedNumber comp->len=%d\n", comp->len);
1957
value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
1958
size = rose_number_screened_decode(pri, call, comp->data, comp->len, value);
1961
ASN1_FIXUP_LEN(comp, size);
1965
pri_message(pri, "Invalid PresentedNumberScreened component 0x%X\n", comp->type);
1975
static int rose_call_transfer_complete_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
1978
struct rose_component *comp = NULL;
1979
unsigned char *vdata = sequence->data;
1982
int end_designation = 0;
1983
struct addressingdataelements_presentednumberscreened redirection_number;
1984
char redirection_name[50] = "";
1985
int call_status = 0;
1986
redirection_number.partyaddress[0] = 0;
1987
redirection_number.partysubaddress[0] = 0;
1988
call->callername[0] = 0;
1989
call->callernum[0] = 0;
1993
if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
1994
pri_message(pri, "Invalid callTransferComplete argument. (Not a sequence)\n");
1998
if (sequence->len == ASN1_LEN_INDEF) {
1999
len -= 4; /* For the 2 extra characters at the end
2000
* and two characters of header */
2004
if (pri->debug & PRI_DEBUG_APDU)
2005
pri_message(pri, " CT-Complete: len=%d\n", len);
2008
/* End Designation */
2009
GET_COMPONENT(comp, i, vdata, len);
2010
CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid endDesignation type 0x%X of ROSE callTransferComplete component received\n");
2011
ASN1_GET_INTEGER(comp, end_designation);
2012
NEXT_COMPONENT(comp, i);
2013
if (pri->debug & PRI_DEBUG_APDU)
2014
pri_message(pri, " CT-Complete: Received endDesignation=%d\n", end_designation);
2017
/* Redirection Number */
2018
GET_COMPONENT(comp, i, vdata, len);
2019
res = rose_presented_number_screened_decode(pri, call, (u_int8_t *)comp, comp->len + 2, &redirection_number);
2024
if (pri->debug & PRI_DEBUG_APDU)
2025
pri_message(pri, " CT-Complete: Received redirectionNumber=%s\n", redirection_number.partyaddress);
2026
strncpy(call->callernum, redirection_number.partyaddress, 20);
2027
call->callernum[20] = 0;
2029
NEXT_COMPONENT(comp, i);
2032
#if 0 /* This one is optional. How do we check if it is there? */
2033
/* Basic Call Info Elements */
2034
GET_COMPONENT(comp, i, vdata, len);
2035
NEXT_COMPONENT(comp, i);
2039
/* Redirection Name */
2040
GET_COMPONENT(comp, i, vdata, len);
2041
res = asn1_name_decode((u_int8_t *)comp, comp->len + 2, redirection_name, sizeof(redirection_name));
2044
memcpy(call->callername, comp->data, comp->len);
2045
call->callername[comp->len] = 0;
2046
ASN1_FIXUP_LEN(comp, res);
2048
NEXT_COMPONENT(comp, i);
2049
if (pri->debug & PRI_DEBUG_APDU)
2050
pri_message(pri, " CT-Complete: Received redirectionName '%s'\n", redirection_name);
2054
GET_COMPONENT(comp, i, vdata, len);
2055
CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid callStatus type 0x%X of ROSE callTransferComplete component received\n");
2056
ASN1_GET_INTEGER(comp, call_status);
2057
NEXT_COMPONENT(comp, i);
2058
if (pri->debug & PRI_DEBUG_APDU)
2059
pri_message(pri, " CT-Complete: Received callStatus=%d\n", call_status);
2062
/* Argument Extension */
2063
#if 0 /* Not supported */
2064
GET_COMPONENT(comp, i, vdata, len);
2065
switch (comp->type) {
2066
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_9): /* [9] IMPLICIT Extension */
2067
res = rose_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
2070
ASN1_FIXUP_LEN(comp, res);
2073
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_10): /* [10] IMPLICIT SEQUENCE OF Extension */
2074
res = rose_sequence_of_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
2077
ASN1_FIXUP_LEN(comp, res);
2081
pri_message(pri, " CT-Complete: !! Unknown argumentExtension received 0x%X\n", comp->type);
2085
GET_COMPONENT(comp, i, vdata, len);
2086
ASN1_FIXUP_LEN(comp, res);
2087
NEXT_COMPONENT(comp, i);
2091
pri_message(pri, " CT-Complete: !! not all information is handled !! i=%d / len=%d\n", i, len);
2101
static int rose_call_transfer_update_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
2104
struct rose_component *comp = NULL;
2105
unsigned char *vdata = sequence->data;
2108
struct addressingdataelements_presentednumberscreened redirection_number;
2109
redirection_number.partyaddress[0] = 0;
2110
redirection_number.partysubaddress[0] = 0;
2111
char redirection_name[50] = "";
2112
call->callername[0] = 0;
2113
call->callernum[0] = 0;
2117
if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
2118
pri_message(pri, "Invalid callTransferComplete argument. (Not a sequence)\n");
2122
if (sequence->len == ASN1_LEN_INDEF) {
2123
len -= 4; /* For the 2 extra characters at the end
2124
* and two characters of header */
2128
if (pri->debug & PRI_DEBUG_APDU)
2129
pri_message(pri, " CT-Complete: len=%d\n", len);
2132
/* Redirection Number */
2133
GET_COMPONENT(comp, i, vdata, len);
2134
res = rose_presented_number_screened_decode(pri, call, (u_int8_t *)comp, comp->len + 2, &redirection_number);
2139
if (pri->debug & PRI_DEBUG_APDU)
2140
pri_message(pri, " CT-Complete: Received redirectionNumber=%s\n", redirection_number.partyaddress);
2141
strncpy(call->callernum, redirection_number.partyaddress, 20);
2142
call->callernum[20] = 0;
2144
NEXT_COMPONENT(comp, i);
2146
/* Redirection Name */
2147
GET_COMPONENT(comp, i, vdata, len);
2148
res = asn1_name_decode((u_int8_t *)comp, comp->len + 2, redirection_name, sizeof(redirection_name));
2151
memcpy(call->callername, comp->data, comp->len);
2152
call->callername[comp->len] = 0;
2153
ASN1_FIXUP_LEN(comp, res);
2155
NEXT_COMPONENT(comp, i);
2156
if (pri->debug & PRI_DEBUG_APDU)
2157
pri_message(pri, " CT-Complete: Received redirectionName '%s'\n", redirection_name);
2160
#if 0 /* This one is optional. How do we check if it is there? */
2161
/* Basic Call Info Elements */
2162
GET_COMPONENT(comp, i, vdata, len);
2163
NEXT_COMPONENT(comp, i);
2167
/* Argument Extension */
2168
#if 0 /* Not supported */
2169
GET_COMPONENT(comp, i, vdata, len);
2170
switch (comp->type) {
2171
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_9): /* [9] IMPLICIT Extension */
2172
res = rose_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
2175
ASN1_FIXUP_LEN(comp, res);
2178
case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_10): /* [10] IMPLICIT SEQUENCE OF Extension */
2179
res = rose_sequence_of_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
2182
ASN1_FIXUP_LEN(comp, res);
2186
pri_message(pri, " CT-Complete: !! Unknown argumentExtension received 0x%X\n", comp->type);
2190
GET_COMPONENT(comp, i, vdata, len);
2191
ASN1_FIXUP_LEN(comp, res);
2192
NEXT_COMPONENT(comp, i);
2196
pri_message(pri, " CT-Complete: !! not all information is handled !! i=%d / len=%d\n", i, len);
2206
/* ===== End Call Transfer Supplementary Service (ECMA-178) ===== */
2210
int rose_reject_decode(struct pri *pri, q931_call *call, q931_ie *ie, unsigned char *data, int len)
1346
2213
int problemtag = -1;
1574
2448
case SS_CNID_CALLINGNAME:
1575
2449
if (pri->debug & PRI_DEBUG_APDU)
1576
2450
pri_message(pri, " Handle Name display operation\n");
1577
switch (comp->type) {
1578
case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
1579
memcpy(call->callername, comp->data, comp->len);
1580
call->callername[comp->len] = 0;
1581
if (pri->debug & PRI_DEBUG_APDU)
1582
pri_message(pri, " Received caller name '%s'\n", call->callername);
1585
if (pri->debug & PRI_DEBUG_APDU)
1586
pri_message(pri, "Do not handle argument of type 0x%X\n", comp->type);
2451
return rose_calling_name_decode(pri, call, comp, len-i);
2452
case ROSE_CALL_TRANSFER_IDENTIFY:
2453
if (pri->debug & PRI_DEBUG_APDU)
2454
pri_message(pri, "ROSE %i: CallTransferIdentify - not handled!\n", operation_tag);
2455
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2457
case ROSE_CALL_TRANSFER_ABANDON:
2458
if (pri->debug & PRI_DEBUG_APDU)
2459
pri_message(pri, "ROSE %i: CallTransferAbandon - not handled!\n", operation_tag);
2460
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2462
case ROSE_CALL_TRANSFER_INITIATE:
2463
if (pri->debug & PRI_DEBUG_APDU)
2464
pri_message(pri, "ROSE %i: CallTransferInitiate - not handled!\n", operation_tag);
2465
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2467
case ROSE_CALL_TRANSFER_SETUP:
2468
if (pri->debug & PRI_DEBUG_APDU)
2469
pri_message(pri, "ROSE %i: CallTransferSetup - not handled!\n", operation_tag);
2470
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2472
case ROSE_CALL_TRANSFER_ACTIVE:
2473
if (pri->debug & PRI_DEBUG_APDU)
2474
pri_message(pri, "ROSE %i: CallTransferActive - not handled!\n", operation_tag);
2475
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2477
case ROSE_CALL_TRANSFER_COMPLETE:
2478
if (pri->debug & PRI_DEBUG_APDU)
2480
pri_message(pri, "ROSE %i: Handle CallTransferComplete\n", operation_tag);
2481
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2483
return rose_call_transfer_complete_decode(pri, call, comp, len-i);
2484
case ROSE_CALL_TRANSFER_UPDATE:
2485
if (pri->debug & PRI_DEBUG_APDU)
2487
pri_message(pri, "ROSE %i: Handle CallTransferUpdate\n", operation_tag);
2488
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
2490
return rose_call_transfer_update_decode(pri, call, comp, len-i);
2491
case ROSE_SUBADDRESS_TRANSFER:
2492
if (pri->debug & PRI_DEBUG_APDU)
2493
pri_message(pri, "ROSE %i: SubaddressTransfer - not handled!\n", operation_tag);
2494
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
1590
2496
case ROSE_DIVERTING_LEG_INFORMATION2:
1591
if (pri->debug & PRI_DEBUG_APDU)
1592
pri_message(pri, " Handle DivertingLegInformation2\n");
2497
if (pri->debug & PRI_DEBUG_APDU) {
2498
pri_message(pri, "ROSE %i: Handle CallingName\n", operation_tag);
2499
dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
1593
2501
return rose_diverting_leg_information2_decode(pri, call, comp, len-i);
1594
2502
case ROSE_AOC_NO_CHARGING_INFO_AVAILABLE:
1595
2503
if (pri->debug & PRI_DEBUG_APDU) {