From 9b5066cc782d94774d2a9bed3665c137448b9f1c Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Mon, 30 Aug 2010 22:25:33 +0000 Subject: [PATCH] Merged revisions 1878,1883-1884,1894 via svnmerge from https://origsvn.digium.com/svn/libpri/branches/1.4 ........ r1878 | mattf | 2010-08-23 17:13:44 -0500 (Mon, 23 Aug 2010) | 1 line Add silly fake MDL error Z for kicking L2 to reactivate if a DISC or DM is received in proper states on PTP links. ........ r1883 | rmudgett | 2010-08-25 11:38:29 -0500 (Wed, 25 Aug 2010) | 2 lines Don't silently fail to post our fake MDL-ERROR(Z). ........ r1884 | rmudgett | 2010-08-25 12:17:09 -0500 (Wed, 25 Aug 2010) | 2 lines Added gripe check to rosetest for invalid operation and error codes. ........ r1894 | rmudgett | 2010-08-26 18:26:16 -0500 (Thu, 26 Aug 2010) | 1 line Make pri_dump_event() only print the event name. ........ git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.4.11.4@1946 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- pri.c | 72 ++++++++++++++++++++---------------------------------- q921.c | 14 +++++++++++ rosetest.c | 15 ++++++++++-- 3 files changed, 53 insertions(+), 48 deletions(-) diff --git a/pri.c b/pri.c index ba3ea84..b319cc8 100644 --- a/pri.c +++ b/pri.c @@ -434,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* */ }; @@ -1019,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) diff --git a/q921.c b/q921.c index 66a4f58..fd45518 100644 --- a/q921.c +++ b/q921.c @@ -61,6 +61,7 @@ static void q921_dump_pri(struct pri *ctrl, char direction_tag); static void q921_establish_data_link(struct pri *ctrl); static void q921_mdl_error(struct pri *ctrl, char error); static void q921_mdl_remove(struct pri *ctrl); +static void q921_restart_ptp_link_if_needed(struct pri *ctrl); /*! * \internal @@ -1168,6 +1169,7 @@ static pri_event *q921_disc_rx(struct pri *ctrl, q921_h *h) if (ctrl->q921_state == Q921_MULTI_FRAME_ESTABLISHED) stop_t203(ctrl); q921_setstate(ctrl, Q921_TEI_ASSIGNED); + q921_restart_ptp_link_if_needed(ctrl); break; default: pri_error(ctrl, "Don't know what to do with DISC in state %d(%s)\n", @@ -1284,6 +1286,10 @@ static int q921_mdl_handle_ptp_error(struct pri *ctrl, char error) /* This is where we act a bit like L3 instead of L2, since we've got an L3 that depends on us * keeping L2 automatically alive and happy for point to point links */ switch (error) { + case 'Z': + /* This is a special MDL error that actually isn't a spec error, but just so we + * have an asynchronous context from the state machine to kick a PTP link back + * up after being requested to drop politely (using DISC or DM) */ case 'G': /* We pick it back up and put it back together for this case */ q921_discard_iqueue(ctrl); @@ -1304,6 +1310,13 @@ static int q921_mdl_handle_ptp_error(struct pri *ctrl, char error) return handled; } +static void q921_restart_ptp_link_if_needed(struct pri *ctrl) +{ + if (PTP_MODE(ctrl)) { + q921_mdl_error(ctrl, 'Z'); + } +} + static void q921_mdl_handle_error(struct pri *ctrl, char error, int errored_state) { int handled = 0; @@ -1816,6 +1829,7 @@ static pri_event *q921_dm_rx(struct pri *ctrl, q921_h *h) q931_dl_indication(ctrl, PRI_EVENT_DCHAN_DOWN); stop_t200(ctrl); q921_setstate(ctrl, Q921_TEI_ASSIGNED); + q921_restart_ptp_link_if_needed(ctrl); break; case Q921_AWAITING_RELEASE: if (!h->u.p_f) diff --git a/rosetest.c b/rosetest.c index 5063a4d..0b43dc3 100644 --- a/rosetest.c +++ b/rosetest.c @@ -2356,6 +2356,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); @@ -2469,7 +2470,12 @@ int main(int argc, char *argv[]) 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"); @@ -2479,7 +2485,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");