Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c286f741be | ||
|
|
183cd86a8d | ||
|
|
c955ba2510 | ||
|
|
a0c05f9908 | ||
|
|
9b5066cc78 | ||
|
|
9648194287 | ||
|
|
ff36053fdd | ||
|
|
d9276a9c5e | ||
|
|
c3cc1ed5b0 | ||
|
|
cd8d727df8 | ||
|
|
4e591eb689 | ||
|
|
eb0586daa1 | ||
|
|
7dca4921d2 | ||
|
|
b14525f475 | ||
|
|
5feca71b83 | ||
|
|
8d5be5281a | ||
|
|
ef3a4f1b5a | ||
|
|
969b121c9b | ||
|
|
b32ccb3fdd | ||
|
|
9b04f86bf6 | ||
|
|
2d986a8567 | ||
|
|
399513b13b | ||
|
|
ea17cdae4f | ||
|
|
d878403e92 | ||
|
|
12c20f0f91 | ||
|
|
fb53af3a71 | ||
|
|
585c016da8 | ||
|
|
f86ab05045 |
73
pri.c
73
pri.c
@@ -300,6 +300,7 @@ struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master,
|
||||
pri_default_timers(p, switchtype);
|
||||
if (master) {
|
||||
pri_set_debug(p, master->debug);
|
||||
pri_set_inbanddisconnect(p, master->acceptinbanddisconnect);
|
||||
if (master->sendfacility)
|
||||
pri_facility_enable(p);
|
||||
}
|
||||
@@ -433,32 +434,32 @@ char *pri_event2str(int id)
|
||||
char *name;
|
||||
} events[] = {
|
||||
/* *INDENT-OFF* */
|
||||
{ PRI_EVENT_DCHAN_UP, "D-Channel Up" },
|
||||
{ PRI_EVENT_DCHAN_DOWN, "D-channel Down" },
|
||||
{ PRI_EVENT_RESTART, "Restart channel" },
|
||||
{ PRI_EVENT_CONFIG_ERR, "Configuration Error" },
|
||||
{ PRI_EVENT_RING, "Ring" },
|
||||
{ PRI_EVENT_HANGUP, "Hangup" },
|
||||
{ PRI_EVENT_RINGING, "Ringing" },
|
||||
{ PRI_EVENT_ANSWER, "Answer" },
|
||||
{ PRI_EVENT_HANGUP_ACK, "Hangup ACK" },
|
||||
{ PRI_EVENT_RESTART_ACK, "Restart ACK" },
|
||||
{ PRI_EVENT_FACILITY, "Facility" },
|
||||
{ PRI_EVENT_INFO_RECEIVED, "Info Received" },
|
||||
{ PRI_EVENT_PROCEEDING, "Proceeding" },
|
||||
{ PRI_EVENT_SETUP_ACK, "Setup ACK" },
|
||||
{ PRI_EVENT_HANGUP_REQ, "Hangup Req" },
|
||||
{ PRI_EVENT_NOTIFY, "Notify" },
|
||||
{ PRI_EVENT_PROGRESS, "Progress" },
|
||||
{ PRI_EVENT_KEYPAD_DIGIT, "Keypad Digit" },
|
||||
{ PRI_EVENT_SERVICE, "Service" },
|
||||
{ PRI_EVENT_SERVICE_ACK, "Service ACK" },
|
||||
{ PRI_EVENT_HOLD, "Hold" },
|
||||
{ PRI_EVENT_HOLD_ACK, "Hold Ack" },
|
||||
{ PRI_EVENT_HOLD_REJ, "Hold Rej" },
|
||||
{ PRI_EVENT_RETRIEVE, "Retrieve" },
|
||||
{ PRI_EVENT_RETRIEVE_ACK, "Retrieve ACK" },
|
||||
{ PRI_EVENT_RETRIEVE_REJ, "Retrieve Rej" },
|
||||
{ PRI_EVENT_DCHAN_UP, "PRI_EVENT_DCHAN_UP" },
|
||||
{ PRI_EVENT_DCHAN_DOWN, "PRI_EVENT_DCHAN_DOWN" },
|
||||
{ PRI_EVENT_RESTART, "PRI_EVENT_RESTART" },
|
||||
{ PRI_EVENT_CONFIG_ERR, "PRI_EVENT_CONFIG_ERR" },
|
||||
{ PRI_EVENT_RING, "PRI_EVENT_RING" },
|
||||
{ PRI_EVENT_HANGUP, "PRI_EVENT_HANGUP" },
|
||||
{ PRI_EVENT_RINGING, "PRI_EVENT_RINGING" },
|
||||
{ PRI_EVENT_ANSWER, "PRI_EVENT_ANSWER" },
|
||||
{ PRI_EVENT_HANGUP_ACK, "PRI_EVENT_HANGUP_ACK" },
|
||||
{ PRI_EVENT_RESTART_ACK, "PRI_EVENT_RESTART_ACK" },
|
||||
{ PRI_EVENT_FACILITY, "PRI_EVENT_FACILITY" },
|
||||
{ PRI_EVENT_INFO_RECEIVED, "PRI_EVENT_INFO_RECEIVED" },
|
||||
{ PRI_EVENT_PROCEEDING, "PRI_EVENT_PROCEEDING" },
|
||||
{ PRI_EVENT_SETUP_ACK, "PRI_EVENT_SETUP_ACK" },
|
||||
{ PRI_EVENT_HANGUP_REQ, "PRI_EVENT_HANGUP_REQ" },
|
||||
{ PRI_EVENT_NOTIFY, "PRI_EVENT_NOTIFY" },
|
||||
{ PRI_EVENT_PROGRESS, "PRI_EVENT_PROGRESS" },
|
||||
{ PRI_EVENT_KEYPAD_DIGIT, "PRI_EVENT_KEYPAD_DIGIT" },
|
||||
{ PRI_EVENT_SERVICE, "PRI_EVENT_SERVICE" },
|
||||
{ PRI_EVENT_SERVICE_ACK, "PRI_EVENT_SERVICE_ACK" },
|
||||
{ PRI_EVENT_HOLD, "PRI_EVENT_HOLD" },
|
||||
{ PRI_EVENT_HOLD_ACK, "PRI_EVENT_HOLD_ACK" },
|
||||
{ PRI_EVENT_HOLD_REJ, "PRI_EVENT_HOLD_REJ" },
|
||||
{ PRI_EVENT_RETRIEVE, "PRI_EVENT_RETRIEVE" },
|
||||
{ PRI_EVENT_RETRIEVE_ACK, "PRI_EVENT_RETRIEVE_ACK" },
|
||||
{ PRI_EVENT_RETRIEVE_REJ, "PRI_EVENT_RETRIEVE_REJ" },
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
@@ -1018,26 +1019,6 @@ void pri_dump_event(struct pri *pri, pri_event *e)
|
||||
if (!pri || !e)
|
||||
return;
|
||||
pri_message(pri, "Event type: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
|
||||
switch(e->gen.e) {
|
||||
case PRI_EVENT_DCHAN_UP:
|
||||
case PRI_EVENT_DCHAN_DOWN:
|
||||
break;
|
||||
case PRI_EVENT_CONFIG_ERR:
|
||||
pri_message(pri, "Error: %s", e->err.err);
|
||||
break;
|
||||
case PRI_EVENT_RESTART:
|
||||
pri_message(pri, "Restart on channel %d\n", e->restart.channel);
|
||||
case PRI_EVENT_RING:
|
||||
pri_message(pri, "Calling number: %s (%s, %s)\n", e->ring.callingnum, pri_plan2str(e->ring.callingplan), pri_pres2str(e->ring.callingpres));
|
||||
pri_message(pri, "Called number: %s (%s)\n", e->ring.callednum, pri_plan2str(e->ring.calledplan));
|
||||
pri_message(pri, "Channel: %d (%s) Reference number: %d\n", e->ring.channel, e->ring.flexible ? "Flexible" : "Not Flexible", e->ring.cref);
|
||||
break;
|
||||
case PRI_EVENT_HANGUP:
|
||||
pri_message(pri, "Hangup, reference number: %d, reason: %s\n", e->hangup.cref, pri_cause2str(e->hangup.cause));
|
||||
break;
|
||||
default:
|
||||
pri_message(pri, "Don't know how to dump events of type %d\n", e->gen.e);
|
||||
}
|
||||
}
|
||||
|
||||
static void pri_sr_init(struct pri_sr *req)
|
||||
|
||||
@@ -3745,25 +3745,65 @@ void rose_handle_invoke(struct pri *ctrl, q931_call *call, int msgtype, q931_ie
|
||||
/* CallingName is put in remote_id.name */
|
||||
rose_copy_name_to_q931(ctrl, &call->remote_id.name,
|
||||
&invoke->args.qsig.CallingName.name);
|
||||
|
||||
switch (msgtype) {
|
||||
case Q931_SETUP:
|
||||
case Q931_CONNECT:
|
||||
/* The caller name will automatically be reported. */
|
||||
break;
|
||||
default:
|
||||
/* Setup connected line subcommand */
|
||||
subcmd = q931_alloc_subcommand(ctrl);
|
||||
if (!subcmd) {
|
||||
break;
|
||||
}
|
||||
subcmd->cmd = PRI_SUBCMD_CONNECTED_LINE;
|
||||
q931_party_id_copy_to_pri(&subcmd->u.connected_line.id, &call->remote_id);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ROSE_QSIG_CalledName:
|
||||
/* CalledName is put in remote_id.name */
|
||||
rose_copy_name_to_q931(ctrl, &call->remote_id.name,
|
||||
&invoke->args.qsig.CalledName.name);
|
||||
|
||||
/* Setup connected line subcommand */
|
||||
subcmd = q931_alloc_subcommand(ctrl);
|
||||
if (!subcmd) {
|
||||
switch (msgtype) {
|
||||
case Q931_SETUP:
|
||||
case Q931_CONNECT:
|
||||
/* The called name will automatically be reported. */
|
||||
pri_error(ctrl, "ERROR: Too many facility subcommands\n");
|
||||
break;
|
||||
default:
|
||||
/* Setup connected line subcommand */
|
||||
subcmd = q931_alloc_subcommand(ctrl);
|
||||
if (!subcmd) {
|
||||
break;
|
||||
}
|
||||
subcmd->cmd = PRI_SUBCMD_CONNECTED_LINE;
|
||||
q931_party_id_copy_to_pri(&subcmd->u.connected_line.id, &call->remote_id);
|
||||
break;
|
||||
}
|
||||
subcmd->cmd = PRI_SUBCMD_CONNECTED_LINE;
|
||||
q931_party_id_copy_to_pri(&subcmd->u.connected_line.id, &call->remote_id);
|
||||
break;
|
||||
case ROSE_QSIG_ConnectedName:
|
||||
/* ConnectedName is put in remote_id.name */
|
||||
rose_copy_name_to_q931(ctrl, &call->remote_id.name,
|
||||
&invoke->args.qsig.ConnectedName.name);
|
||||
|
||||
switch (msgtype) {
|
||||
case Q931_SETUP:
|
||||
case Q931_CONNECT:
|
||||
/* The connected line name will automatically be reported. */
|
||||
break;
|
||||
default:
|
||||
/* Setup connected line subcommand */
|
||||
subcmd = q931_alloc_subcommand(ctrl);
|
||||
if (!subcmd) {
|
||||
break;
|
||||
}
|
||||
subcmd->cmd = PRI_SUBCMD_CONNECTED_LINE;
|
||||
q931_party_id_copy_to_pri(&subcmd->u.connected_line.id, &call->remote_id);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#if 0 /* Not handled yet */
|
||||
case ROSE_QSIG_BusyName:
|
||||
|
||||
@@ -458,6 +458,8 @@ struct q931_call {
|
||||
* (Caller-ID for answered or connected-line for originated calls.)
|
||||
*/
|
||||
struct q931_party_id remote_id;
|
||||
/*! \brief Automatic Number Identification (ANI) */
|
||||
struct q931_party_number ani;
|
||||
|
||||
/*!
|
||||
* \brief Staging place for the Q.931 redirection number ie.
|
||||
|
||||
272
q931.c
272
q931.c
@@ -885,7 +885,12 @@ static int receive_channel_id(int full_ie, struct pri *ctrl, q931_call *call, in
|
||||
return -1;
|
||||
}
|
||||
if (ie->data[pos] & 0x10) {
|
||||
/* Expect Slot Map */
|
||||
/*
|
||||
* Expect Slot Map
|
||||
* Note that we are assuming only T1's use slot maps which is wrong
|
||||
* but oh well... We would need to know what type of line we are
|
||||
* connected with (T1 or E1) to interpret the map correctly anyway.
|
||||
*/
|
||||
call->slotmap = 0;
|
||||
pos++;
|
||||
for (x=0;x<3;x++) {
|
||||
@@ -963,22 +968,26 @@ static int transmit_channel_id(int full_ie, struct pri *ctrl, q931_call *call, i
|
||||
&& !(call->chanflags & FLAG_WHOLE_INTERFACE)) {
|
||||
/* The 3.2 and 3.3 octets need to be present */
|
||||
ie->data[pos] = 0x83;
|
||||
if (call->slotmap != -1) {
|
||||
int octet;
|
||||
|
||||
/* We have to send a channel map */
|
||||
ie->data[pos++] |= 0x10;
|
||||
for (octet = 3; octet--;) {
|
||||
ie->data[pos++] = (call->slotmap >> (8 * octet)) & 0xff;
|
||||
}
|
||||
} else {
|
||||
/* Channel number specified */
|
||||
if (0 < call->channelno && call->channelno != 0xff) {
|
||||
/* Channel number specified and preferred over slot map if we have one. */
|
||||
++pos;
|
||||
if (ctrl->chan_mapping_logical && call->channelno > 16) {
|
||||
ie->data[pos++] = 0x80 | (call->channelno - 1);
|
||||
} else {
|
||||
ie->data[pos++] = 0x80 | call->channelno;
|
||||
}
|
||||
} else if (call->slotmap != -1) {
|
||||
int octet;
|
||||
|
||||
/* We have to send a slot map */
|
||||
ie->data[pos++] |= 0x10;
|
||||
for (octet = 3; octet--;) {
|
||||
ie->data[pos++] = (call->slotmap >> (8 * octet)) & 0xff;
|
||||
}
|
||||
} else {
|
||||
pri_error(ctrl, "XXX We need either a channelno or slotmap but have neither!\n");
|
||||
/* Discard this malformed ie. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1994,26 +2003,41 @@ static int transmit_called_party_number(int full_ie, struct pri *ctrl, q931_call
|
||||
static int receive_calling_party_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
|
||||
{
|
||||
int i = 0;
|
||||
struct q931_party_number number;
|
||||
|
||||
q931_party_number_init(&number);
|
||||
number.valid = 1;
|
||||
number.presentation = PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
|
||||
|
||||
call->remote_id.number.valid = 1;
|
||||
call->remote_id.number.presentation =
|
||||
PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
|
||||
/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
|
||||
walking through all bytes until one with ext bit (8) set to 1 */
|
||||
do {
|
||||
switch (i) {
|
||||
case 0:
|
||||
call->remote_id.number.plan = ie->data[i] & 0x7f;
|
||||
number.plan = ie->data[i] & 0x7f;
|
||||
break;
|
||||
case 1:
|
||||
/* Keep only the presentation and screening fields */
|
||||
call->remote_id.number.presentation =
|
||||
number.presentation =
|
||||
ie->data[i] & (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
|
||||
break;
|
||||
}
|
||||
} while (!(ie->data[i++] & 0x80));
|
||||
q931_get_number((unsigned char *) call->remote_id.number.str,
|
||||
sizeof(call->remote_id.number.str), ie->data + i, ie->len - i);
|
||||
q931_get_number((unsigned char *) number.str, sizeof(number.str), ie->data + i,
|
||||
ie->len - i);
|
||||
|
||||
/* There can be more than one calling party number ie in the SETUP message. */
|
||||
if (number.presentation == (PRI_PRES_ALLOWED | PRI_PRES_NETWORK_NUMBER)
|
||||
|| number.presentation == (PRI_PRES_RESTRICTED | PRI_PRES_NETWORK_NUMBER)) {
|
||||
/* The number is network provided so it is an ANI number. */
|
||||
call->ani = number;
|
||||
if (!call->remote_id.number.valid) {
|
||||
/* Copy ANI to CallerID if CallerID is not already set. */
|
||||
call->remote_id.number = number;
|
||||
}
|
||||
} else {
|
||||
call->remote_id.number = number;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2401,25 +2425,28 @@ static int process_facility(struct pri *ctrl, q931_call *call, int msgtype, q931
|
||||
return -1;
|
||||
}
|
||||
|
||||
pos = rose_decode(ctrl, pos, end, &rose);
|
||||
if (!pos) {
|
||||
return -1;
|
||||
}
|
||||
switch (rose.type) {
|
||||
case ROSE_COMP_TYPE_INVOKE:
|
||||
rose_handle_invoke(ctrl, call, msgtype, ie, &header, &rose.component.invoke);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_RESULT:
|
||||
rose_handle_result(ctrl, call, msgtype, ie, &header, &rose.component.result);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_ERROR:
|
||||
rose_handle_error(ctrl, call, msgtype, ie, &header, &rose.component.error);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_REJECT:
|
||||
rose_handle_reject(ctrl, call, msgtype, ie, &header, &rose.component.reject);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
/* Process all components in the facility. */
|
||||
while (pos < end) {
|
||||
pos = rose_decode(ctrl, pos, end, &rose);
|
||||
if (!pos) {
|
||||
return -1;
|
||||
}
|
||||
switch (rose.type) {
|
||||
case ROSE_COMP_TYPE_INVOKE:
|
||||
rose_handle_invoke(ctrl, call, msgtype, ie, &header, &rose.component.invoke);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_RESULT:
|
||||
rose_handle_result(ctrl, call, msgtype, ie, &header, &rose.component.result);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_ERROR:
|
||||
rose_handle_error(ctrl, call, msgtype, ie, &header, &rose.component.error);
|
||||
break;
|
||||
case ROSE_COMP_TYPE_REJECT:
|
||||
rose_handle_reject(ctrl, call, msgtype, ie, &header, &rose.component.reject);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -3511,6 +3538,7 @@ void q931_init_call_record(struct pri *ctrl, struct q931_call *call, int cr)
|
||||
q931_party_address_init(&call->called);
|
||||
q931_party_id_init(&call->local_id);
|
||||
q931_party_id_init(&call->remote_id);
|
||||
q931_party_number_init(&call->ani);
|
||||
q931_party_redirecting_init(&call->redirecting);
|
||||
|
||||
/* PRI is set to whoever called us */
|
||||
@@ -3896,6 +3924,85 @@ static char *disc2str(int disc)
|
||||
return code2str(disc, discs, sizeof(discs) / sizeof(discs[0]));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Dump the Q.931 message header.
|
||||
*
|
||||
* \param ctrl D channel controller.
|
||||
* \param tei TEI the packet is associated with.
|
||||
* \param h Q.931 packet contents/header.
|
||||
* \param len Received length of the Q.931 packet.
|
||||
* \param c Message direction prefix character.
|
||||
*
|
||||
* \retval 0 on success.
|
||||
* \retval -1 on error.
|
||||
*/
|
||||
static int q931_dump_header(struct pri *ctrl, int tei, q931_h *h, int len, char c)
|
||||
{
|
||||
q931_mh *mh;
|
||||
int cref;
|
||||
|
||||
pri_message(ctrl, "%c Protocol Discriminator: %s (%d) len=%d\n", c, disc2str(h->pd), h->pd, len);
|
||||
|
||||
if (len < 2 || len < 2 + h->crlen) {
|
||||
pri_message(ctrl, "%c Message too short for call reference. len=%d\n",
|
||||
c, len);
|
||||
return -1;
|
||||
}
|
||||
cref = q931_cr(h);
|
||||
pri_message(ctrl, "%c TEI=%d Call Ref: len=%2d (reference %d/0x%X) (%s)\n",
|
||||
c, tei, h->crlen, cref & ~Q931_CALL_REFERENCE_FLAG,
|
||||
cref & ~Q931_CALL_REFERENCE_FLAG, (cref == Q931_DUMMY_CALL_REFERENCE)
|
||||
? "Dummy"
|
||||
: (cref & Q931_CALL_REFERENCE_FLAG)
|
||||
? "Sent to originator" : "Sent from originator");
|
||||
|
||||
if (len < 3 + h->crlen) {
|
||||
pri_message(ctrl, "%c Message too short for supported protocols. len=%d\n",
|
||||
c, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Message header begins at the end of the call reference number */
|
||||
mh = (q931_mh *)(h->contents + h->crlen);
|
||||
switch (h->pd) {
|
||||
case MAINTENANCE_PROTOCOL_DISCRIMINATOR_1:
|
||||
case MAINTENANCE_PROTOCOL_DISCRIMINATOR_2:
|
||||
pri_message(ctrl, "%c Message Type: %s (%d)\n", c, maintenance_msg2str(mh->msg, h->pd), mh->msg);
|
||||
break;
|
||||
default:
|
||||
/* Unknown protocol discriminator but we will treat it as Q.931 anyway. */
|
||||
case GR303_PROTOCOL_DISCRIMINATOR:
|
||||
case Q931_PROTOCOL_DISCRIMINATOR:
|
||||
pri_message(ctrl, "%c Message Type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Q.931 is passing this message to Q.921 debug indication.
|
||||
*
|
||||
* \param ctrl D channel controller.
|
||||
* \param tei TEI the packet is associated with.
|
||||
* \param h Q.931 packet contents/header.
|
||||
* \param len Received length of the Q.931 packet
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
static void q931_to_q921_passing_dump(struct pri *ctrl, int tei, q931_h *h, int len)
|
||||
{
|
||||
char c;
|
||||
|
||||
c = '>';
|
||||
|
||||
pri_message(ctrl, "\n");
|
||||
pri_message(ctrl, "%c DL-DATA request\n", c);
|
||||
q931_dump_header(ctrl, tei, h, len, c);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Debug dump the given Q.931 packet.
|
||||
*
|
||||
@@ -3915,46 +4022,19 @@ void q931_dump(struct pri *ctrl, int tei, q931_h *h, int len, int txrx)
|
||||
int r;
|
||||
int cur_codeset;
|
||||
int codeset;
|
||||
int cref;
|
||||
|
||||
c = txrx ? '>' : '<';
|
||||
|
||||
pri_message(ctrl, "%c Protocol Discriminator: %s (%d) len=%d\n", c, disc2str(h->pd), h->pd, len);
|
||||
|
||||
if (len < 2 || len < 2 + h->crlen) {
|
||||
pri_message(ctrl, "%c Message too short for call reference. len=%d\n",
|
||||
c, len);
|
||||
return;
|
||||
if (!(ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))) {
|
||||
/* Put out a blank line if Q.921 is not dumping. */
|
||||
pri_message(ctrl, "\n");
|
||||
}
|
||||
cref = q931_cr(h);
|
||||
pri_message(ctrl, "%c TEI=%d Call Ref: len=%2d (reference %d/0x%X) (%s)\n",
|
||||
c, tei, h->crlen, cref & ~Q931_CALL_REFERENCE_FLAG,
|
||||
cref & ~Q931_CALL_REFERENCE_FLAG, (cref == Q931_DUMMY_CALL_REFERENCE)
|
||||
? "Dummy"
|
||||
: (cref & Q931_CALL_REFERENCE_FLAG)
|
||||
? "Sent to originator" : "Sent from originator");
|
||||
|
||||
if (len < 3 + h->crlen) {
|
||||
pri_message(ctrl, "%c Message too short for supported protocols. len=%d\n",
|
||||
c, len);
|
||||
if (q931_dump_header(ctrl, tei, h, len, c)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Message header begins at the end of the call reference number */
|
||||
mh = (q931_mh *)(h->contents + h->crlen);
|
||||
switch (h->pd) {
|
||||
case MAINTENANCE_PROTOCOL_DISCRIMINATOR_1:
|
||||
case MAINTENANCE_PROTOCOL_DISCRIMINATOR_2:
|
||||
pri_message(ctrl, "%c Message Type: %s (%d)\n", c, maintenance_msg2str(mh->msg, h->pd), mh->msg);
|
||||
break;
|
||||
default:
|
||||
/* Unknown protocol discriminator but we will treat it as Q.931 anyway. */
|
||||
case GR303_PROTOCOL_DISCRIMINATOR:
|
||||
case Q931_PROTOCOL_DISCRIMINATOR:
|
||||
pri_message(ctrl, "%c Message Type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);
|
||||
break;
|
||||
}
|
||||
/* Drop length of header, including call reference */
|
||||
mh = (q931_mh *)(h->contents + h->crlen);
|
||||
len -= (h->crlen + 3);
|
||||
codeset = cur_codeset = 0;
|
||||
for (x = 0; x < len; x += r) {
|
||||
@@ -4048,19 +4128,32 @@ static void init_header(struct pri *ctrl, q931_call *call, unsigned char *buf, q
|
||||
|
||||
static int q931_xmit(struct pri *ctrl, int tei, q931_h *h, int len, int cr, int uiframe)
|
||||
{
|
||||
if (uiframe) {
|
||||
q921_transmit_uiframe(ctrl, h, len);
|
||||
} else {
|
||||
q921_transmit_iframe(ctrl, tei, h, len, cr);
|
||||
}
|
||||
/* The transmit operation might dump the q921 header, so logging the q931
|
||||
message body after the transmit puts the sections of the message in the
|
||||
right order in the log */
|
||||
if (ctrl->debug & PRI_DEBUG_Q931_DUMP)
|
||||
q931_dump(ctrl, tei, h, len, 1);
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
ctrl->q931_txcount++;
|
||||
#endif
|
||||
if (uiframe) {
|
||||
q921_transmit_uiframe(ctrl, h, len);
|
||||
if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
|
||||
/*
|
||||
* The transmit operation might dump the Q.921 header, so logging
|
||||
* the Q.931 message body after the transmit puts the sections of
|
||||
* the message in the right order in the log,
|
||||
*/
|
||||
q931_dump(ctrl, tei, h, len, 1);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Indicate passing the Q.931 message to Q.921 first. Q.921 may
|
||||
* have to request a TEI or bring the connection up before it can
|
||||
* actually send the message. Therefore, the Q.931 message may
|
||||
* actually get sent a few seconds later. Q.921 will dump the
|
||||
* Q.931 message as appropriate at that time.
|
||||
*/
|
||||
if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
|
||||
q931_to_q921_passing_dump(ctrl, tei, h, len);
|
||||
}
|
||||
q921_transmit_iframe(ctrl, tei, h, len, cr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4090,6 +4183,7 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
|
||||
int x;
|
||||
int codeset;
|
||||
int uiframe;
|
||||
int tei;
|
||||
|
||||
if (call->outboundbroadcast && call->master_call == call && msgtype != Q931_SETUP) {
|
||||
pri_error(ctrl,
|
||||
@@ -4118,6 +4212,7 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
|
||||
/* Invert the logic */
|
||||
len = sizeof(buf) - len;
|
||||
|
||||
tei = call->pri->tei;
|
||||
uiframe = 0;
|
||||
if (BRI_NT_PTMP(ctrl)) {
|
||||
/* NT PTMP is the only mode that can broadcast Q.931 messages. */
|
||||
@@ -4134,7 +4229,7 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
|
||||
uiframe = 1;
|
||||
break;
|
||||
case Q931_FACILITY:
|
||||
if (call->pri->tei == Q921_TEI_GROUP) {
|
||||
if (tei == Q921_TEI_GROUP) {
|
||||
/* Broadcast TEI. */
|
||||
if (q931_is_dummy_call(call)) {
|
||||
/*
|
||||
@@ -4159,8 +4254,14 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
|
||||
"Sending message for call %p on call->pri: %p with TEI/SAPI %d/%d\n",
|
||||
call, call->pri, call->pri->tei, call->pri->sapi);
|
||||
}
|
||||
} else if (call->pri->subchannel && BRI_TE_PTMP(ctrl)) {
|
||||
/*
|
||||
* Get the best available TEI value for the debug dump display.
|
||||
* We may not actually have a TEI assigned at the moment.
|
||||
*/
|
||||
tei = call->pri->subchannel->tei;
|
||||
}
|
||||
q931_xmit(call->pri, call->pri->tei, h, len, 1, uiframe);
|
||||
q931_xmit(call->pri, tei, h, len, 1, uiframe);
|
||||
call->acked = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -5670,6 +5771,7 @@ static int prepare_to_handle_q931_message(struct pri *ctrl, q931_mh *mh, q931_ca
|
||||
q931_party_address_init(&c->called);
|
||||
q931_party_id_init(&c->local_id);
|
||||
q931_party_id_init(&c->remote_id);
|
||||
q931_party_number_init(&c->ani);
|
||||
q931_party_redirecting_init(&c->redirecting);
|
||||
|
||||
/*
|
||||
@@ -6474,11 +6576,9 @@ static void q931_fill_ring_event(struct pri *ctrl, struct q931_call *call)
|
||||
/* Calling party information */
|
||||
ctrl->ev.ring.callingpres = q931_party_id_presentation(&call->remote_id);
|
||||
ctrl->ev.ring.callingplan = call->remote_id.number.plan;
|
||||
if (call->remote_id.number.valid
|
||||
&& (call->remote_id.number.presentation == PRES_ALLOWED_NETWORK_NUMBER
|
||||
|| call->remote_id.number.presentation == PRES_PROHIB_NETWORK_NUMBER)) {
|
||||
ctrl->ev.ring.callingplanani = call->remote_id.number.plan;
|
||||
libpri_copy_string(ctrl->ev.ring.callingani, call->remote_id.number.str,
|
||||
if (call->ani.valid) {
|
||||
ctrl->ev.ring.callingplanani = call->ani.plan;
|
||||
libpri_copy_string(ctrl->ev.ring.callingani, call->ani.str,
|
||||
sizeof(ctrl->ev.ring.callingani));
|
||||
} else {
|
||||
ctrl->ev.ring.callingplanani = -1;
|
||||
|
||||
52
rose.c
52
rose.c
@@ -470,6 +470,21 @@ static const struct rose_convert_error rose_etsi_errors[] = {
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* Note the first value in oid.values[] is really the first two
|
||||
* OID subidentifiers. They are compressed using this formula:
|
||||
* First_Value = (First_Subidentifier * 40) + Second_Subidentifier
|
||||
*/
|
||||
|
||||
/*! \brief ECMA private-isdn-signalling-domain prefix. */
|
||||
static const struct asn1_oid rose_qsig_isdn_domain = {
|
||||
/* *INDENT-OFF* */
|
||||
/* {iso(1) identified-organization(3) icd-ecma(12) private-isdn-signalling-domain(9)} */
|
||||
3, { 43, 12, 9 }
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Q.SIG specific invoke/result encode/decode message table */
|
||||
static const struct rose_convert_msg rose_qsig_msgs[] = {
|
||||
/* *INDENT-OFF* */
|
||||
@@ -479,7 +494,7 @@ static const struct rose_convert_msg rose_qsig_msgs[] = {
|
||||
* decode_invoke_args, decode_result_args
|
||||
*/
|
||||
/*
|
||||
* localValue's from Q.SIG Name-Operations
|
||||
* localValue's from Q.SIG Name-Operations 4th edition
|
||||
* { iso(1) standard(0) pss1-name(13868) name-operations(0) }
|
||||
*/
|
||||
{
|
||||
@@ -503,6 +518,34 @@ static const struct rose_convert_msg rose_qsig_msgs[] = {
|
||||
rose_dec_qsig_BusyName_ARG, NULL
|
||||
},
|
||||
|
||||
/*
|
||||
* globalValue's (OIDs) from Q.SIG Name-Operations 2nd edition
|
||||
* { iso(1) identified-organization(3) icd-ecma(12) standard(0) qsig-name(164) name-operations(0) }
|
||||
*
|
||||
* This older version of the Q.SIG switch is not supported.
|
||||
* However, we will accept receiving these messages anyway.
|
||||
*/
|
||||
{
|
||||
ROSE_QSIG_CallingName, &rose_qsig_isdn_domain, 0,
|
||||
rose_enc_qsig_CallingName_ARG, NULL,
|
||||
rose_dec_qsig_CallingName_ARG, NULL
|
||||
},
|
||||
{
|
||||
ROSE_QSIG_CalledName, &rose_qsig_isdn_domain, 1,
|
||||
rose_enc_qsig_CalledName_ARG, NULL,
|
||||
rose_dec_qsig_CalledName_ARG, NULL
|
||||
},
|
||||
{
|
||||
ROSE_QSIG_ConnectedName, &rose_qsig_isdn_domain, 2,
|
||||
rose_enc_qsig_ConnectedName_ARG, NULL,
|
||||
rose_dec_qsig_ConnectedName_ARG, NULL
|
||||
},
|
||||
{
|
||||
ROSE_QSIG_BusyName, &rose_qsig_isdn_domain, 3,
|
||||
rose_enc_qsig_BusyName_ARG, NULL,
|
||||
rose_dec_qsig_BusyName_ARG, NULL
|
||||
},
|
||||
|
||||
/*
|
||||
* localValue's from Q.SIG SS-AOC-Operations
|
||||
* { iso(1) standard(0) pss1-advice-of-charge(15050) advice-of-charge-operations(0) }
|
||||
@@ -2241,13 +2284,6 @@ const unsigned char *rose_decode(struct pri *ctrl, const unsigned char *pos,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pos < end) {
|
||||
if (ctrl->debug & PRI_DEBUG_APDU) {
|
||||
pri_message(ctrl, " %u byte(s) of trailing data not consumed.\n",
|
||||
(unsigned) (end - pos));
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -382,6 +382,7 @@ static const unsigned char *rose_dec_qsig_PartyName_ARG_Backend(struct pri *ctrl
|
||||
ASN1_CALL(pos, asn1_dec_length(pos, end, &length));
|
||||
ASN1_END_SETUP(seq_end, seq_offset, length, pos, end);
|
||||
|
||||
ASN1_CALL(pos, asn1_dec_tag(pos, seq_end, &tag));
|
||||
ASN1_CALL(pos, rose_dec_qsig_Name(ctrl, "name", tag, pos, seq_end,
|
||||
&party->name));
|
||||
|
||||
|
||||
246
rosetest.c
246
rosetest.c
@@ -994,7 +994,6 @@ static unsigned char rose_etsi_indefinite_len[] = {
|
||||
0x00, 0x00,
|
||||
0x05, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
@@ -1039,7 +1038,6 @@ static unsigned char rose_etsi_unused_indefinite_len[] = {
|
||||
0x00, 0x00,
|
||||
0x05, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
@@ -1076,45 +1074,7 @@ static unsigned char rose_etsi_unused[] = {
|
||||
0x30, 0x06,
|
||||
0x84, 0x04,
|
||||
0x31, 0x38, 0x30, 0x33,
|
||||
0x05, 0x00,
|
||||
0x00, 0x00
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
static unsigned char rose_etsi_extra[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/*
|
||||
* Context Specific/C [1 0x01] <A1> Len:24 <18>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <44>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <07>
|
||||
* Sequence/C(48 0x30) <30> Len:16 <10>
|
||||
* Enumerated(10 0x0A) <0A> Len:1 <01>
|
||||
* <01>
|
||||
* Enumerated(10 0x0A) <0A> Len:1 <01>
|
||||
* <05>
|
||||
* Sequence/C(48 0x30) <30> Len:6 <06>
|
||||
* Context Specific [4 0x04] <84> Len:4 <04>
|
||||
* <31 38 30 33>
|
||||
* NULL(5 0x05) <05> Len:0 <00>
|
||||
*/
|
||||
0x91,
|
||||
0xA1, 0x18,
|
||||
0x02, 0x01,
|
||||
0x44,
|
||||
0x02, 0x01,
|
||||
0x07,
|
||||
0x30, 0x10,
|
||||
0x0A, 0x01,
|
||||
0x01,
|
||||
0x0A, 0x01,
|
||||
0x05,
|
||||
0x30, 0x06,
|
||||
0x84, 0x04,
|
||||
0x31, 0x38, 0x30, 0x33,
|
||||
0x05, 0x00,
|
||||
0x00, 0x00
|
||||
0x05, 0x00
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
@@ -2116,6 +2076,136 @@ static const struct rose_message rose_qsig_msgs[] = {
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
static unsigned char rose_qsig_multiple_msg[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/*
|
||||
* Context Specific/C [10 0x0A] <AA> Len:6 <06>
|
||||
* Context Specific [0 0x00] <80> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [2 0x02] <82> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [11 0x0B] <8B> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific/C [1 0x01] <A1> Len:16 <10>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <01> - "~"
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <55> - "U"
|
||||
* Sequence/C(48 0x30) <30> Len:8 <08>
|
||||
* Context Specific [2 0x02] <82> Len:3 <03>
|
||||
* <01 30 40> - "~0@"
|
||||
* Context Specific [6 0x06] <86> Len:1 <01>
|
||||
* <01> - "~"
|
||||
* Context Specific/C [1 0x01] <A1> Len:19 <13>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <02> - "~"
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [0 0x00] <80> Len:11 <0B>
|
||||
* <4D 6F 64 65 6D 20 44 69-73 63 6F> - "Modem Disco"
|
||||
*/
|
||||
0x9f,
|
||||
0xaa, 0x06,
|
||||
0x80, 0x01,
|
||||
0x00,
|
||||
0x82, 0x01,
|
||||
0x00,
|
||||
0x8b, 0x01,
|
||||
0x00,
|
||||
0xa1, 0x10,
|
||||
0x02, 0x01,
|
||||
0x01,
|
||||
0x02, 0x01,
|
||||
0x55,
|
||||
0x30, 0x08,
|
||||
0x82, 0x03,
|
||||
0x01, 0x30, 0x40,
|
||||
0x86, 0x01,
|
||||
0x01,
|
||||
0xa1, 0x13,
|
||||
0x02, 0x01,
|
||||
0x02,
|
||||
0x02, 0x01,
|
||||
0x00,
|
||||
0x80, 0x0b,
|
||||
0x4d, 0x6f, 0x64, 0x65, 0x6d, 0x20, 0x44, 0x69, 0x73, 0x63, 0x6f
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
static unsigned char rose_qsig_name_alt_encode_msg[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/*
|
||||
* Context Specific/C [10 0x0A] <AA> Len:6 <06>
|
||||
* Context Specific [0 0x00] <80> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [2 0x02] <82> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [11 0x0B] <8B> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific/C [1 0x01] <A1> Len:21 <15>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <1D> - "~"
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Sequence/C(48 0x30) <30> Len:13 <0D>
|
||||
* Context Specific [0 0x00] <80> Len:11 <0B>
|
||||
* <55 54 49 4C 49 54 59 20-54 45 4C> - "UTILITY TEL"
|
||||
*/
|
||||
0x9F,
|
||||
0xAA, 0x06,
|
||||
0x80, 0x01,
|
||||
0x00,
|
||||
0x82, 0x01,
|
||||
0x00,
|
||||
0x8B, 0x01,
|
||||
0x00,
|
||||
0xA1, 0x15,
|
||||
0x02, 0x01,
|
||||
0x1D,
|
||||
0x02, 0x01,
|
||||
0x00,
|
||||
0x30, 0x0D,
|
||||
0x80, 0x0B,
|
||||
0x55, 0x54, 0x49, 0x4C, 0x49, 0x54, 0x59, 0x20, 0x54, 0x45, 0x4C
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
static unsigned char rose_qsig_name_2nd_encode_msg[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/*
|
||||
* Context Specific/C [10 0x0A] <AA> Len:6 <06>
|
||||
* Context Specific [0 0x00] <80> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [2 0x02] <82> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific [11 0x0B] <8B> Len:1 <01>
|
||||
* <00> - "~"
|
||||
* Context Specific/C [1 0x01] <A1> Len:26 <1A>
|
||||
* Integer(2 0x02) <02> Len:1 <01>
|
||||
* <40> - "@"
|
||||
* OID(6 0x06) <06> Len:4 <04>
|
||||
* <2B 0C 09 00> - "+~~~"
|
||||
* Context Specific [0 0x00] <80> Len:15 <0F>
|
||||
* <4D 6F 64 65 6D 20 44 69-73 63 6F 42 61 6C 6C> - "Modem DiscoBall"
|
||||
*/
|
||||
0x91,
|
||||
0xaa, 0x06,
|
||||
0x80, 0x01,
|
||||
0x00,
|
||||
0x82, 0x01,
|
||||
0x00,
|
||||
0x8b, 0x01,
|
||||
0x00,
|
||||
0xa1, 0x1a,
|
||||
0x02, 0x01,
|
||||
0x40,
|
||||
0x06, 0x04,
|
||||
0x2b, 0x0c, 0x09, 0x00,
|
||||
0x80, 0x0f,
|
||||
0x4d, 0x6f, 0x64, 0x65, 0x6d, 0x20, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x42, 0x61, 0x6c, 0x6c
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
|
||||
static const struct rose_message rose_dms100_msgs[] = {
|
||||
/* *INDENT-OFF* */
|
||||
@@ -2223,17 +2313,22 @@ static void rose_test_msg(struct pri *ctrl, unsigned index,
|
||||
if (!dec_pos) {
|
||||
pri_error(ctrl, "Error: Message:%u failed to decode header\n", index);
|
||||
} else {
|
||||
dec_pos = rose_decode(ctrl, dec_pos, dec_end, &decoded_msg);
|
||||
if (!dec_pos) {
|
||||
pri_error(ctrl, "Error: Message:%u failed to decode ROSE\n", index);
|
||||
} else {
|
||||
if (header
|
||||
&& memcmp(header, &decoded_header, sizeof(decoded_header))) {
|
||||
pri_error(ctrl, "Error: Message:%u Header did not match\n",
|
||||
while (dec_pos < dec_end) {
|
||||
dec_pos = rose_decode(ctrl, dec_pos, dec_end, &decoded_msg);
|
||||
if (!dec_pos) {
|
||||
pri_error(ctrl, "Error: Message:%u failed to decode ROSE\n",
|
||||
index);
|
||||
}
|
||||
if (memcmp(encode_msg, &decoded_msg, sizeof(decoded_msg))) {
|
||||
pri_error(ctrl, "Error: Message:%u ROSE did not match\n", index);
|
||||
break;
|
||||
} else {
|
||||
if (header
|
||||
&& memcmp(header, &decoded_header, sizeof(decoded_header))) {
|
||||
pri_error(ctrl, "Error: Message:%u Header did not match\n",
|
||||
index);
|
||||
}
|
||||
if (memcmp(encode_msg, &decoded_msg, sizeof(decoded_msg))) {
|
||||
pri_error(ctrl, "Error: Message:%u ROSE did not match\n",
|
||||
index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2271,9 +2366,12 @@ static void rose_test_exception(struct pri *ctrl, const char *name,
|
||||
if (!pos) {
|
||||
pri_error(ctrl, "Error: %s test: Message failed to decode header\n", name);
|
||||
} else {
|
||||
pos = rose_decode(ctrl, pos, end, &decoded_msg);
|
||||
if (!pos) {
|
||||
pri_error(ctrl, "Error: %s test: Message failed to decode ROSE\n", name);
|
||||
while (pos < end) {
|
||||
pos = rose_decode(ctrl, pos, end, &decoded_msg);
|
||||
if (!pos) {
|
||||
pri_error(ctrl, "Error: %s test: Message failed to decode ROSE\n", name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2294,6 +2392,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned index;
|
||||
unsigned offset;
|
||||
const char *str;
|
||||
static struct pri dummy_ctrl;
|
||||
|
||||
pri_set_message(rose_pri_message);
|
||||
@@ -2302,6 +2401,9 @@ int main(int argc, char *argv[])
|
||||
memset(&dummy_ctrl, 0, sizeof(dummy_ctrl));
|
||||
dummy_ctrl.debug = PRI_DEBUG_APDU;
|
||||
|
||||
/* For sanity specify what version of libpri we are testing. */
|
||||
pri_error(&dummy_ctrl, "libpri version tested: %s\n", pri_get_version());
|
||||
|
||||
offset = 0;
|
||||
pri_message(&dummy_ctrl, "Encode/decode message(s)\n");
|
||||
if (argc <= 1) {
|
||||
@@ -2382,30 +2484,37 @@ int main(int argc, char *argv[])
|
||||
|
||||
dummy_ctrl.switchtype = PRI_SWITCH_EUROISDN_E1;
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Extra bytes on end", rose_etsi_extra,
|
||||
sizeof(rose_etsi_extra));
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Indefinite length", rose_etsi_indefinite_len,
|
||||
sizeof(rose_etsi_indefinite_len) - 2);
|
||||
rose_test_exception(&dummy_ctrl, "Indefinite length (extra)",
|
||||
rose_etsi_indefinite_len, sizeof(rose_etsi_indefinite_len));
|
||||
sizeof(rose_etsi_indefinite_len));
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Unused components (indefinite length)",
|
||||
rose_etsi_unused_indefinite_len, sizeof(rose_etsi_unused_indefinite_len) - 2);
|
||||
rose_test_exception(&dummy_ctrl, "Unused components (indefinite length, extra)",
|
||||
rose_etsi_unused_indefinite_len, sizeof(rose_etsi_unused_indefinite_len));
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Unused components", rose_etsi_unused,
|
||||
sizeof(rose_etsi_unused) - 2);
|
||||
rose_test_exception(&dummy_ctrl, "Unused components (extra)", rose_etsi_unused,
|
||||
sizeof(rose_etsi_unused));
|
||||
|
||||
dummy_ctrl.switchtype = PRI_SWITCH_QSIG;
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Multiple component messages",
|
||||
rose_qsig_multiple_msg, sizeof(rose_qsig_multiple_msg));
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "Alternate name encoded messages",
|
||||
rose_qsig_name_alt_encode_msg, sizeof(rose_qsig_name_alt_encode_msg));
|
||||
|
||||
rose_test_exception(&dummy_ctrl, "2nd edition name encoded messages",
|
||||
rose_qsig_name_2nd_encode_msg, sizeof(rose_qsig_name_2nd_encode_msg));
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
pri_message(&dummy_ctrl, "\n\n"
|
||||
"List of operation codes:\n");
|
||||
for (index = 0; index < ROSE_Num_Operation_Codes; ++index) {
|
||||
pri_message(&dummy_ctrl, "%d: %s\n", index, rose_operation2str(index));
|
||||
str = rose_operation2str(index);
|
||||
if (!strncmp(str, "Invalid code:", 13)) {
|
||||
pri_error(&dummy_ctrl, "%d: %s\n", index, str);
|
||||
} else {
|
||||
pri_message(&dummy_ctrl, "%d: %s\n", index, str);
|
||||
}
|
||||
}
|
||||
pri_message(&dummy_ctrl, "\n\n"
|
||||
"************************************************************\n");
|
||||
@@ -2415,7 +2524,12 @@ int main(int argc, char *argv[])
|
||||
pri_message(&dummy_ctrl, "\n\n"
|
||||
"List of error codes:\n");
|
||||
for (index = 0; index < ROSE_ERROR_Num_Codes; ++index) {
|
||||
pri_message(&dummy_ctrl, "%d: %s\n", index, rose_error2str(index));
|
||||
str = rose_error2str(index);
|
||||
if (!strncmp(str, "Invalid code:", 13)) {
|
||||
pri_error(&dummy_ctrl, "%d: %s\n", index, str);
|
||||
} else {
|
||||
pri_message(&dummy_ctrl, "%d: %s\n", index, str);
|
||||
}
|
||||
}
|
||||
pri_message(&dummy_ctrl, "\n\n"
|
||||
"************************************************************\n");
|
||||
|
||||
Reference in New Issue
Block a user