[svn-commits] rmudgett: branch group/ccss r1066 - /team/group/ccss/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Sep 2 15:56:15 CDT 2009
Author: rmudgett
Date: Wed Sep 2 15:56:11 2009
New Revision: 1066
URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=1066
Log:
Merged revisions 1059-1061 via svnmerge from
https://origsvn.digium.com/svn/libpri/branches/1.4
........
r1059 | rmudgett | 2009-09-02 14:49:58 -0500 (Wed, 02 Sep 2009) | 14 lines
Cleaned up scheduled events handling code.
* Fixed pri_schedule_event() to return 0 on error instead of -1. Zero is
a safer value to return. Users would not think that a timer was
scheduled.
* Fixed potential for pri_schedule_del() to write out of bounds of
pri_sched[]. The out of bounds access could occur when
pri_schedule_event() returned -1.
* Made use all pri_sched[] entries. pri_sched[0] was previously unused.
* Removed some unneeded code and recursion since scheduling only runs on
master D channel structures.
* Added doxygen comments.
* Renamed struct pri *pri variables to struct pri *ctrl in this file.
........
r1060 | rmudgett | 2009-09-02 15:04:03 -0500 (Wed, 02 Sep 2009) | 5 lines
Optimized calls to pri_schedule_del().
There is no need to test if a scheduled event is running before calling
pri_schedule_del().
........
r1061 | rmudgett | 2009-09-02 15:19:40 -0500 (Wed, 02 Sep 2009) | 2 lines
Converted Q931_CALL_STATE_xxx defines to an enum.
........
Modified:
team/group/ccss/ (props changed)
team/group/ccss/pri_internal.h
team/group/ccss/pri_q931.h
team/group/ccss/prisched.c
team/group/ccss/q921.c
team/group/ccss/q931.c
Propchange: team/group/ccss/
------------------------------------------------------------------------------
automerge = *
Propchange: team/group/ccss/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Sep 2 15:56:11 2009
@@ -1,1 +1,1 @@
-/branches/1.4:1-1052
+/branches/1.4:1-1065
Modified: team/group/ccss/pri_internal.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/ccss/pri_internal.h?view=diff&rev=1066&r1=1065&r2=1066
==============================================================================
--- team/group/ccss/pri_internal.h (original)
+++ team/group/ccss/pri_internal.h Wed Sep 2 15:56:11 2009
@@ -32,6 +32,8 @@
#include <stddef.h>
#include <sys/time.h>
+#include "pri_q921.h"
+#include "pri_q931.h"
#define ARRAY_LEN(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -44,9 +46,6 @@
void *data;
};
-struct q921_frame;
-enum q931_state;
-enum q931_mode;
struct pri_cc_record;
/*! Maximum number of scheduled events active at the same time. */
@@ -395,9 +394,9 @@
int causeloc; /* Cause Location */
int cause; /* Cause of clearing */
- int peercallstate; /* Call state of peer as reported */
- int ourcallstate; /* Our call state */
- int sugcallstate; /* Status call state */
+ enum Q931_CALL_STATE peercallstate; /* Call state of peer as reported */
+ enum Q931_CALL_STATE ourcallstate; /* Our call state */
+ enum Q931_CALL_STATE sugcallstate; /* Status call state */
/* BUGBUG These CC elements may not be retained. */
int ccoperation; /* QSIG_CCBSREQUEST/QSIG_CCNRREQUEST */
Modified: team/group/ccss/pri_q931.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/ccss/pri_q931.h?view=diff&rev=1066&r1=1065&r2=1066
==============================================================================
--- team/group/ccss/pri_q931.h (original)
+++ team/group/ccss/pri_q931.h Wed Sep 2 15:56:11 2009
@@ -139,7 +139,7 @@
#define Q931_NON_LOCKING_SHIFT 0x98
#define Q931_BEARER_CAPABILITY 0x04
#define Q931_CAUSE 0x08
-#define Q931_CALL_STATE 0x14
+#define Q931_IE_CALL_STATE 0x14
#define Q931_CHANNEL_IDENT 0x18
#define Q931_PROGRESS_INDICATOR 0x1e
#define Q931_NETWORK_SPEC_FAC 0x20
@@ -195,220 +195,222 @@
#define Q931_IE_ESCAPE_FOR_EXT 0x7F
-/* Q.931 call states */
-/*!
- * \details
- * null state (U0):
- * No call exists.
- * \details
- * null state (N0):
- * No call exists.
- */
-#define Q931_CALL_STATE_NULL 0
-/*!
- * \details
- * call initiated (U1):
- * This state exists for an outgoing call, when the user requests
- * call establishment from the network.
- * \details
- * call initiated (N1):
- * This state exists for an outgoing call when the network has received
- * a call establishment request but has not yet responded.
- */
-#define Q931_CALL_STATE_CALL_INITIATED 1
-/*!
- * \details
- * overlap sending (U2):
- * This state exists for an outgoing call when the user has
- * received acknowledgement of the call establishment request which
- * permits the user to send additional call information to the network
- * in overlap mode.
- * \details
- * overlap sending (N2):
- * This state exists for an outgoing call when the network has acknowledged
- * the call establishment request and is prepared to receive additional
- * call information (if any) in overlap mode.
- */
-#define Q931_CALL_STATE_OVERLAP_SENDING 2
-/*!
- * \details
- * outgoing call proceeding (U3):
- * This state exists for an outgoing call when the user has
- * received acknowledgement that the network has received all
- * call information necessary to effect call establishment.
- * \details
- * outgoing call proceeding (N3):
- * This state exists for an outgoing call when the network has sent
- * acknowledgement that the network has received all call information
- * necessary to effect call establishment.
- */
-#define Q931_CALL_STATE_OUTGOING_CALL_PROCEEDING 3
-/*!
- * \details
- * call delivered (U4):
- * This state exists for an outgoing call when the calling user has
- * received an indication that remote user alerting has been initiated.
- * \details
- * call delivered (N4):
- * This state exists for an outgoing call when the network has indicated
- * that remote user alerting has been initiated.
- */
-#define Q931_CALL_STATE_CALL_DELIVERED 4
-/*!
- * \details
- * call present (U6):
- * This state exists for an incoming call when the user has received a
- * call establishment request but has not yet responded.
- * \details
- * call present (N6):
- * This state exists for an incoming call when the network has sent a
- * call establishment request but has not yet received a satisfactory
- * response.
- */
-#define Q931_CALL_STATE_CALL_PRESENT 6
-/*!
- * \details
- * call received (U7):
- * This state exists for an incoming call when the user has indicated
- * alerting but has not yet answered.
- * \details
- * call received (N7):
- * This state exists for an incoming call when the network has received
- * an indication that the user is alerting but has not yet received an
- * answer.
- */
-#define Q931_CALL_STATE_CALL_RECEIVED 7
-/*!
- * \details
- * connect request (U8):
- * This state exists for an incoming call when the user has answered
- * the call and is waiting to be awarded the call.
- * \details
- * connect request (N8):
- * This state exists for an incoming call when the network has received
- * an answer but the network has not yet awarded the call.
- */
-#define Q931_CALL_STATE_CONNECT_REQUEST 8
-/*!
- * \details
- * incoming call proceeding (U9):
- * This state exists for an incoming call when the user has sent
- * acknowledgement that the user has received all call information
- * necessary to effect call establishment.
- * \details
- * incoming call proceeding (N9):
- * This state exists for an incoming call when the network has received
- * acknowledgement that the user has received all call information
- * necessary to effect call establishment.
- */
-#define Q931_CALL_STATE_INCOMING_CALL_PROCEEDING 9
-/*!
- * \details
- * active (U10):
- * This state exists for an incoming call when the user has received
- * an acknowledgement from the network that the user has been awarded
- * the call. This state exists for an outgoing call when the user has
- * received an indication that the remote user has answered the call.
- * \details
- * active (N10):
- * This state exists for an incoming call when the network has awarded
- * the call to the called user. This state exists for an outgoing call
- * when the network has indicated that the remote user has answered
- * the call.
- */
-#define Q931_CALL_STATE_ACTIVE 10
-/*!
- * \details
- * disconnect request (U11):
- * This state exists when the user has requested the network to clear
- * the end-to-end connection (if any) and is waiting for a response.
- * \details
- * disconnect request (N11):
- * This state exists when the network has received a request from the
- * user to clear the end-to-end connection (if any).
- */
-#define Q931_CALL_STATE_DISCONNECT_REQUEST 11
-/*!
- * \details
- * disconnect indication (U12):
- * This state exists when the user has received an invitation to
- * disconnect because the network has disconnected the end-to-end
- * connection (if any).
- * \details
- * disconnect indication (N12):
- * This state exists when the network has disconnected the end-to-end
- * connection (if any) and has sent an invitation to disconnect the
- * user-network connection.
- */
-#define Q931_CALL_STATE_DISCONNECT_INDICATION 12
-/*!
- * \details
- * suspend request (U15):
- * This state exists when the user has requested the network to suspend
- * the call and is waiting for a response.
- * \details
- * suspend request (N15):
- * This state exists when the network has received a request to suspend
- * the call but has not yet responded.
- */
-#define Q931_CALL_STATE_SUSPEND_REQUEST 15
-/*!
- * \details
- * resume request (U17):
- * This state exists when the user has requested the network to resume
- * a previously suspended call and is waiting for a response.
- * \details
- * resume request (N17):
- * This state exists when the network has received a request to resume
- * a previously suspended call but has not yet responded.
- */
-#define Q931_CALL_STATE_RESUME_REQUEST 17
-/*!
- * \details
- * release request (U19):
- * This state exists when the user has requested the network to release
- * and is waiting for a response.
- * \details
- * release request (N19):
- * This state exists when the network has requested the user to release
- * and is waiting for a response.
- */
-#define Q931_CALL_STATE_RELEASE_REQUEST 19
-/*!
- * \details
- * call abort (N22):
- * This state exists for an incoming call for the point-to-multipoint
- * configuration when the call is being cleared before any user has been
- * awarded the call.
- */
-#define Q931_CALL_STATE_CALL_ABORT 22
-/*!
- * \details
- * overlap receiving (U25):
- * This state exists for an incoming call when the user has acknowledged
- * the call establishment request from the network and is prepared to
- * receive additional call information (if any) in overlap mode.
- * \details
- * overlap receiving (N25):
- * This state exists for an incoming call when the network has received
- * acknowledgement of the call establishment request which permits the
- * network to send additional call information (if any) in the overlap
- * mode.
- */
-#define Q931_CALL_STATE_OVERLAP_RECEIVING 25
-/*!
- * \details
- * call independent service (U31): (From Q.932)
- * This state exists when a call independent supplementary service
- * signalling connection is established.
- * \details
- * call independent service (N31): (From Q.932)
- * This state exists when a call independent supplementary service
- * signalling connection is established.
- */
-#define Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE 31
-#define Q931_CALL_STATE_RESTART_REQUEST 61
-#define Q931_CALL_STATE_RESTART 62
+/*! Q.931 call states */
+enum Q931_CALL_STATE {
+ /*!
+ * \details
+ * null state (U0):
+ * No call exists.
+ * \details
+ * null state (N0):
+ * No call exists.
+ */
+ Q931_CALL_STATE_NULL = 0,
+ /*!
+ * \details
+ * call initiated (U1):
+ * This state exists for an outgoing call, when the user requests
+ * call establishment from the network.
+ * \details
+ * call initiated (N1):
+ * This state exists for an outgoing call when the network has received
+ * a call establishment request but has not yet responded.
+ */
+ Q931_CALL_STATE_CALL_INITIATED = 1,
+ /*!
+ * \details
+ * overlap sending (U2):
+ * This state exists for an outgoing call when the user has
+ * received acknowledgement of the call establishment request which
+ * permits the user to send additional call information to the network
+ * in overlap mode.
+ * \details
+ * overlap sending (N2):
+ * This state exists for an outgoing call when the network has acknowledged
+ * the call establishment request and is prepared to receive additional
+ * call information (if any) in overlap mode.
+ */
+ Q931_CALL_STATE_OVERLAP_SENDING = 2,
+ /*!
+ * \details
+ * outgoing call proceeding (U3):
+ * This state exists for an outgoing call when the user has
+ * received acknowledgement that the network has received all
+ * call information necessary to effect call establishment.
+ * \details
+ * outgoing call proceeding (N3):
+ * This state exists for an outgoing call when the network has sent
+ * acknowledgement that the network has received all call information
+ * necessary to effect call establishment.
+ */
+ Q931_CALL_STATE_OUTGOING_CALL_PROCEEDING = 3,
+ /*!
+ * \details
+ * call delivered (U4):
+ * This state exists for an outgoing call when the calling user has
+ * received an indication that remote user alerting has been initiated.
+ * \details
+ * call delivered (N4):
+ * This state exists for an outgoing call when the network has indicated
+ * that remote user alerting has been initiated.
+ */
+ Q931_CALL_STATE_CALL_DELIVERED = 4,
+ /*!
+ * \details
+ * call present (U6):
+ * This state exists for an incoming call when the user has received a
+ * call establishment request but has not yet responded.
+ * \details
+ * call present (N6):
+ * This state exists for an incoming call when the network has sent a
+ * call establishment request but has not yet received a satisfactory
+ * response.
+ */
+ Q931_CALL_STATE_CALL_PRESENT = 6,
+ /*!
+ * \details
+ * call received (U7):
+ * This state exists for an incoming call when the user has indicated
+ * alerting but has not yet answered.
+ * \details
+ * call received (N7):
+ * This state exists for an incoming call when the network has received
+ * an indication that the user is alerting but has not yet received an
+ * answer.
+ */
+ Q931_CALL_STATE_CALL_RECEIVED = 7,
+ /*!
+ * \details
+ * connect request (U8):
+ * This state exists for an incoming call when the user has answered
+ * the call and is waiting to be awarded the call.
+ * \details
+ * connect request (N8):
+ * This state exists for an incoming call when the network has received
+ * an answer but the network has not yet awarded the call.
+ */
+ Q931_CALL_STATE_CONNECT_REQUEST = 8,
+ /*!
+ * \details
+ * incoming call proceeding (U9):
+ * This state exists for an incoming call when the user has sent
+ * acknowledgement that the user has received all call information
+ * necessary to effect call establishment.
+ * \details
+ * incoming call proceeding (N9):
+ * This state exists for an incoming call when the network has received
+ * acknowledgement that the user has received all call information
+ * necessary to effect call establishment.
+ */
+ Q931_CALL_STATE_INCOMING_CALL_PROCEEDING = 9,
+ /*!
+ * \details
+ * active (U10):
+ * This state exists for an incoming call when the user has received
+ * an acknowledgement from the network that the user has been awarded
+ * the call. This state exists for an outgoing call when the user has
+ * received an indication that the remote user has answered the call.
+ * \details
+ * active (N10):
+ * This state exists for an incoming call when the network has awarded
+ * the call to the called user. This state exists for an outgoing call
+ * when the network has indicated that the remote user has answered
+ * the call.
+ */
+ Q931_CALL_STATE_ACTIVE = 10,
+ /*!
+ * \details
+ * disconnect request (U11):
+ * This state exists when the user has requested the network to clear
+ * the end-to-end connection (if any) and is waiting for a response.
+ * \details
+ * disconnect request (N11):
+ * This state exists when the network has received a request from the
+ * user to clear the end-to-end connection (if any).
+ */
+ Q931_CALL_STATE_DISCONNECT_REQUEST = 11,
+ /*!
+ * \details
+ * disconnect indication (U12):
+ * This state exists when the user has received an invitation to
+ * disconnect because the network has disconnected the end-to-end
+ * connection (if any).
+ * \details
+ * disconnect indication (N12):
+ * This state exists when the network has disconnected the end-to-end
+ * connection (if any) and has sent an invitation to disconnect the
+ * user-network connection.
+ */
+ Q931_CALL_STATE_DISCONNECT_INDICATION = 12,
+ /*!
+ * \details
+ * suspend request (U15):
+ * This state exists when the user has requested the network to suspend
+ * the call and is waiting for a response.
+ * \details
+ * suspend request (N15):
+ * This state exists when the network has received a request to suspend
+ * the call but has not yet responded.
+ */
+ Q931_CALL_STATE_SUSPEND_REQUEST = 15,
+ /*!
+ * \details
+ * resume request (U17):
+ * This state exists when the user has requested the network to resume
+ * a previously suspended call and is waiting for a response.
+ * \details
+ * resume request (N17):
+ * This state exists when the network has received a request to resume
+ * a previously suspended call but has not yet responded.
+ */
+ Q931_CALL_STATE_RESUME_REQUEST = 17,
+ /*!
+ * \details
+ * release request (U19):
+ * This state exists when the user has requested the network to release
+ * and is waiting for a response.
+ * \details
+ * release request (N19):
+ * This state exists when the network has requested the user to release
+ * and is waiting for a response.
+ */
+ Q931_CALL_STATE_RELEASE_REQUEST = 19,
+ /*!
+ * \details
+ * call abort (N22):
+ * This state exists for an incoming call for the point-to-multipoint
+ * configuration when the call is being cleared before any user has been
+ * awarded the call.
+ */
+ Q931_CALL_STATE_CALL_ABORT = 22,
+ /*!
+ * \details
+ * overlap receiving (U25):
+ * This state exists for an incoming call when the user has acknowledged
+ * the call establishment request from the network and is prepared to
+ * receive additional call information (if any) in overlap mode.
+ * \details
+ * overlap receiving (N25):
+ * This state exists for an incoming call when the network has received
+ * acknowledgement of the call establishment request which permits the
+ * network to send additional call information (if any) in the overlap
+ * mode.
+ */
+ Q931_CALL_STATE_OVERLAP_RECEIVING = 25,
+ /*!
+ * \details
+ * call independent service (U31): (From Q.932)
+ * This state exists when a call independent supplementary service
+ * signalling connection is established.
+ * \details
+ * call independent service (N31): (From Q.932)
+ * This state exists when a call independent supplementary service
+ * signalling connection is established.
+ */
+ Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE = 31,
+ Q931_CALL_STATE_RESTART_REQUEST = 61,
+ Q931_CALL_STATE_RESTART = 62,
+};
/* EuroISDN */
Modified: team/group/ccss/prisched.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/ccss/prisched.c?view=diff&rev=1066&r1=1065&r2=1066
==============================================================================
--- team/group/ccss/prisched.c (original)
+++ team/group/ccss/prisched.c Wed Sep 2 15:56:11 2009
@@ -33,25 +33,43 @@
#include "pri_internal.h"
+/*! \brief The maximum number of timers that were active at once. */
static int maxsched = 0;
/* Scheduler routines */
-int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data)
+
+/*!
+ * \brief Start a timer to schedule an event.
+ *
+ * \param ctrl D channel controller.
+ * \param ms Number of milliseconds to scheduled event.
+ * \param function Callback function to call when timeout.
+ * \param data Value to give callback function when timeout.
+ *
+ * \retval 0 if scheduler table is full and could not schedule the event.
+ * \retval id Scheduled event id.
+ */
+int pri_schedule_event(struct pri *ctrl, int ms, void (*function)(void *data), void *data)
{
int x;
struct timeval tv;
+
/* Scheduling runs on master channels only */
- while (pri->master)
- pri = pri->master;
- for (x=1;x<MAX_SCHED;x++)
- if (!pri->pri_sched[x].callback)
+ while (ctrl->master) {
+ ctrl = ctrl->master;
+ }
+ for (x = 0; x < MAX_SCHED; ++x) {
+ if (!ctrl->pri_sched[x].callback) {
break;
+ }
+ }
if (x == MAX_SCHED) {
- pri_error(pri, "No more room in scheduler\n");
- return -1;
+ pri_error(ctrl, "No more room in scheduler\n");
+ return 0;
}
- if (x > maxsched)
- maxsched = x;
+ if (x >= maxsched) {
+ maxsched = x + 1;
+ }
gettimeofday(&tv, NULL);
tv.tv_sec += ms / 1000;
tv.tv_usec += (ms % 1000) * 1000;
@@ -59,71 +77,110 @@
tv.tv_usec -= 1000000;
tv.tv_sec += 1;
}
- pri->pri_sched[x].when = tv;
- pri->pri_sched[x].callback = function;
- pri->pri_sched[x].data = data;
- return x;
+ ctrl->pri_sched[x].when = tv;
+ ctrl->pri_sched[x].callback = function;
+ ctrl->pri_sched[x].data = data;
+ return x + 1;
}
-struct timeval *pri_schedule_next(struct pri *pri)
+/*!
+ * \brief Determine the time of the next scheduled event to expire.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \return Time of the next scheduled event to expire or NULL if no timers active.
+ */
+struct timeval *pri_schedule_next(struct pri *ctrl)
{
struct timeval *closest = NULL;
int x;
- /* Check subchannels */
- if (pri->subchannel)
- closest = pri_schedule_next(pri->subchannel);
- for (x=1;x<MAX_SCHED;x++) {
- if (pri->pri_sched[x].callback &&
- (!closest || (closest->tv_sec > pri->pri_sched[x].when.tv_sec) ||
- ((closest->tv_sec == pri->pri_sched[x].when.tv_sec) &&
- (closest->tv_usec > pri->pri_sched[x].when.tv_usec))))
- closest = &pri->pri_sched[x].when;
+
+ /* Scheduling runs on master channels only */
+ while (ctrl->master) {
+ ctrl = ctrl->master;
+ }
+ for (x = 0; x < MAX_SCHED; ++x) {
+ if (ctrl->pri_sched[x].callback && (!closest
+ || (closest->tv_sec > ctrl->pri_sched[x].when.tv_sec)
+ || ((closest->tv_sec == ctrl->pri_sched[x].when.tv_sec)
+ && (closest->tv_usec > ctrl->pri_sched[x].when.tv_usec)))) {
+ closest = &ctrl->pri_sched[x].when;
+ }
}
return closest;
}
-static pri_event *__pri_schedule_run(struct pri *pri, struct timeval *tv)
+/*!
+ * \internal
+ * \brief Run all expired timers or return an event generated by an expired timer.
+ *
+ * \param ctrl D channel controller.
+ * \param tv Current time.
+ *
+ * \return Event for upper layer to process or NULL if all expired timers run.
+ */
+static pri_event *__pri_schedule_run(struct pri *ctrl, struct timeval *tv)
{
int x;
void (*callback)(void *);
void *data;
- pri_event *e;
- if (pri->subchannel) {
- if ((e = __pri_schedule_run(pri->subchannel, tv))) {
- return e;
+
+ /* Scheduling runs on master channels only */
+ while (ctrl->master) {
+ ctrl = ctrl->master;
+ }
+ for (x = 0; x < MAX_SCHED; ++x) {
+ if (ctrl->pri_sched[x].callback && ((ctrl->pri_sched[x].when.tv_sec < tv->tv_sec)
+ || ((ctrl->pri_sched[x].when.tv_sec == tv->tv_sec)
+ && (ctrl->pri_sched[x].when.tv_usec <= tv->tv_usec)))) {
+ /* This timer has expired. */
+ ctrl->schedev = 0;
+ callback = ctrl->pri_sched[x].callback;
+ data = ctrl->pri_sched[x].data;
+ ctrl->pri_sched[x].callback = NULL;
+ callback(data);
+ if (ctrl->schedev) {
+ return &ctrl->ev;
+ }
}
- }
- for (x=1;x<MAX_SCHED;x++) {
- if (pri->pri_sched[x].callback &&
- ((pri->pri_sched[x].when.tv_sec < tv->tv_sec) ||
- ((pri->pri_sched[x].when.tv_sec == tv->tv_sec) &&
- (pri->pri_sched[x].when.tv_usec <= tv->tv_usec)))) {
- pri->schedev = 0;
- callback = pri->pri_sched[x].callback;
- data = pri->pri_sched[x].data;
- pri->pri_sched[x].callback = NULL;
- pri->pri_sched[x].data = NULL;
- callback(data);
- if (pri->schedev)
- return &pri->ev;
- }
}
return NULL;
}
-pri_event *pri_schedule_run(struct pri *pri)
+/*!
+ * \brief Run all expired timers or return an event generated by an expired timer.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \return Event for upper layer to process or NULL if all expired timers run.
+ */
+pri_event *pri_schedule_run(struct pri *ctrl)
{
struct timeval tv;
+
gettimeofday(&tv, NULL);
- return __pri_schedule_run(pri, &tv);
+ return __pri_schedule_run(ctrl, &tv);
}
-
-void pri_schedule_del(struct pri *pri,int id)
+/*!
+ * \brief Delete a scheduled event.
+ *
+ * \param ctrl D channel controller.
+ * \param id Scheduled event id to delete.
+ * 0 is a disabled/unscheduled event id that is ignored.
+ * 1 - MAX_SCHED is a valid event id.
+ *
+ * \return Nothing
+ */
+void pri_schedule_del(struct pri *ctrl, int id)
{
- while (pri->master)
- pri = pri->master;
- if ((id >= MAX_SCHED) || (id < 0))
- pri_error(pri, "Asked to delete sched id %d???\n", id);
- pri->pri_sched[id].callback = NULL;
+ /* Scheduling runs on master channels only */
+ while (ctrl->master) {
+ ctrl = ctrl->master;
+ }
+ if (0 < id && id <= MAX_SCHED) {
+ ctrl->pri_sched[id - 1].callback = NULL;
+ } else if (id) {
+ pri_error(ctrl, "Asked to delete sched id %d???\n", id);
+ }
}
Modified: team/group/ccss/q921.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/ccss/q921.c?view=diff&rev=1066&r1=1065&r2=1066
==============================================================================
--- team/group/ccss/q921.c (original)
+++ team/group/ccss/q921.c Wed Sep 2 15:56:11 2009
@@ -139,8 +139,7 @@
#endif
pri->ri = random() % 65535;
q921_send_tei(pri, Q921_TEI_IDENTITY_REQUEST, pri->ri, Q921_TEI_GROUP, 1);
- if (pri->t202_timer)
- pri_schedule_del(pri, pri->t202_timer);
+ pri_schedule_del(pri, pri->t202_timer);
pri->t202_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T202], q921_tei_request, pri);
}
@@ -174,8 +173,8 @@
{
struct pri *pri = vpri;
q921_h h;
+
pri_schedule_del(pri, pri->sabme_timer);
- pri->sabme_timer = 0;
pri->sabme_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], q921_send_sabme_now, pri);
if (!now)
return;
@@ -253,8 +252,7 @@
{
if (pri->debug & PRI_DEBUG_Q921_DUMP)
pri_message(pri, "-- Restarting T200 timer\n");
- if (pri->t200_timer)
- pri_schedule_del(pri, pri->t200_timer);
+ pri_schedule_del(pri, pri->t200_timer);
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
}
@@ -262,8 +260,7 @@
{
if (pri->debug & PRI_DEBUG_Q921_DUMP)
pri_message(pri, "-- Restarting T203 timer\n");
- if (pri->t203_timer)
- pri_schedule_del(pri, pri->t203_timer);
+ pri_schedule_del(pri, pri->t203_timer);
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
}
@@ -311,10 +308,8 @@
if (pri->debug & PRI_DEBUG_Q921_DUMP)
pri_message(pri, "-- Since there was nothing left, stopping T200 counter\n");
/* Something was ACK'd. Stop T200 counter */
- if (pri->t200_timer) {
- pri_schedule_del(pri, pri->t200_timer);
- pri->t200_timer = 0;
- }
+ pri_schedule_del(pri, pri->t200_timer);
+ pri->t200_timer = 0;
}
if (pri->t203_timer) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
@@ -785,10 +780,8 @@
pri_event *q921_dchannel_up(struct pri *pri)
{
/* Stop any SABME retransmissions */
- if (pri->sabme_timer) {
- pri_schedule_del(pri, pri->sabme_timer);
- pri->sabme_timer = 0;
- }
+ pri_schedule_del(pri, pri->sabme_timer);
+ pri->sabme_timer = 0;
/* Reset any rejects */
pri->sentrej = 0;
@@ -833,12 +826,9 @@
pri->v_na = 0;
pri->window = pri->timers[PRI_TIMER_K];
pri->windowlen = 0;
- if (pri->sabme_timer)
- pri_schedule_del(pri, pri->sabme_timer);
- if (pri->t203_timer)
- pri_schedule_del(pri, pri->t203_timer);
- if (pri->t200_timer)
- pri_schedule_del(pri, pri->t200_timer);
+ pri_schedule_del(pri, pri->sabme_timer);
+ pri_schedule_del(pri, pri->t203_timer);
+ pri_schedule_del(pri, pri->t200_timer);
pri->sabme_timer = 0;
pri->sabme_count = 0;
pri->t203_timer = 0;
@@ -909,10 +899,8 @@
pri_message(pri, "TEI assignment received for invalid Ri %02x (our is %02x)\n", ri, pri->ri);
return NULL;
}
- if (pri->t202_timer) {
- pri_schedule_del(pri, pri->t202_timer);
- pri->t202_timer = 0;
- }
+ pri_schedule_del(pri, pri->t202_timer);
+ pri->t202_timer = 0;
if (pri->subchannel && (pri->subchannel->tei == tei)) {
pri_error(pri, "TEI already assigned (new is %d, current is %d)\n", tei, pri->subchannel->tei);
q921_tei_release_and_reacquire(pri);
@@ -1082,10 +1070,8 @@
}
}
/* Reset t200 timer if it was somehow going */
- if (pri->t200_timer) {
- pri_schedule_del(pri, pri->t200_timer);
- pri->t200_timer = 0;
- }
+ pri_schedule_del(pri, pri->t200_timer);
+ pri->t200_timer = 0;
/* Reset and restart t203 timer */
reschedule_t203(pri);
}
Modified: team/group/ccss/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/ccss/q931.c?view=diff&rev=1066&r1=1065&r2=1066
==============================================================================
--- team/group/ccss/q931.c (original)
+++ team/group/ccss/q931.c Wed Sep 2 15:56:11 2009
@@ -68,7 +68,7 @@
{ Q931_RESTART_ACKNOWLEDGE, "RESTART ACKNOWLEDGE", { Q931_RESTART_INDICATOR } },
/* Miscellaneous */
- { Q931_STATUS, "STATUS", { Q931_CAUSE, Q931_CALL_STATE } },
+ { Q931_STATUS, "STATUS", { Q931_CAUSE, Q931_IE_CALL_STATE } },
{ Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
{ Q931_USER_INFORMATION, "USER_INFORMATION" },
{ Q931_SEGMENT, "SEGMENT" },
@@ -2877,7 +2877,7 @@
{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
{ 0, Q931_CAUSE, "Cause", dump_cause, receive_cause, transmit_cause },
- { 1, Q931_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
+ { 1, Q931_IE_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
{ 0, Q931_CHANNEL_IDENT, "Channel Identification", dump_channel_id, receive_channel_id, transmit_channel_id },
{ 0, Q931_PROGRESS_INDICATOR, "Progress Indicator", dump_progress_indicator, receive_progress_indicator, transmit_progress_indicator },
{ 0, Q931_NETWORK_SPEC_FAC, "Network-Specific Facilities", dump_network_spec_fac, receive_network_spec_fac, transmit_network_spec_fac },
@@ -3204,8 +3204,7 @@
"NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",
q931_call_state_str(cur->ourcallstate),
q931_call_state_str(cur->peercallstate));
- if (cur->retranstimer)
- pri_schedule_del(ctrl, cur->retranstimer);
+ pri_schedule_del(ctrl, cur->retranstimer);
pri_call_apdu_queue_cleanup(cur);
free(cur);
return;
@@ -3507,7 +3506,7 @@
return send_message(ctrl, c, (MAINTENANCE_PROTOCOL_DISCRIMINATOR_1 << 8) | NATIONAL_SERVICE, maintenance_service_ies);
}
-static int status_ies[] = { Q931_CAUSE, Q931_CALL_STATE, -1 };
+static int status_ies[] = { Q931_CAUSE, Q931_IE_CALL_STATE, -1 };
static int q931_status(struct pri *ctrl, q931_call *c, int cause)
{
@@ -3878,8 +3877,7 @@
c->peercallstate = Q931_CALL_STATE_ACTIVE;
c->alive = 1;
/* Connect request timer */
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = 0;
if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (ctrl->bri || (!ctrl->subchannel)))
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T313], pri_connect_timeout, c);
@@ -3921,8 +3919,7 @@
c->causecode = CODE_CCITT;
c->causeloc = LOC_PRIV_NET_LOCAL_USER;
if (c->acked) {
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
if (!c->t308_timedout) {
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T308], pri_release_timeout, c);
} else {
@@ -3969,8 +3966,7 @@
c->causecode = CODE_CCITT;
c->causeloc = LOC_PRIV_NET_LOCAL_USER;
c->sendhangupack = 1;
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
return send_message(ctrl, c, Q931_DISCONNECT, disconnect_ies);
} else
@@ -4388,8 +4384,7 @@
c->progressmask = 0;
break;
case Q931_CONNECT_ACKNOWLEDGE:
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = 0;
break;
case Q931_RELEASE:
@@ -4398,14 +4393,12 @@
c->causecode = -1;
c->causeloc = -1;
c->aoc_units = -1;
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = 0;
c->useruserinfo[0] = '\0';
break;
case Q931_RELEASE_COMPLETE:
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = 0;
c->useruserinfo[0] = '\0';
/* Fall through */
@@ -5328,8 +5321,7 @@
struct pri *ctrl = c->pri;
int res;
- if (c->retranstimer)
- pri_schedule_del(ctrl, c->retranstimer);
+ pri_schedule_del(ctrl, c->retranstimer);
c->retranstimer = 0;
c->useruserinfo[0] = '\0';
c->cause = -1;
@@ -5416,8 +5408,7 @@
pri_message(ctrl, DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
cur->cr, cur->channelno, cur->ourcallstate,
q931_call_state_str(cur->ourcallstate));
- if (cur->retranstimer)
- pri_schedule_del(ctrl, cur->retranstimer);
+ pri_schedule_del(ctrl, cur->retranstimer);
cur->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall, cur);
}
cur = cur->next;
More information about the svn-commits
mailing list