[svn-commits] rmudgett: branch rmudgett/call_waiting r1509 - /team/rmudgett/call_waiting/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Feb 26 17:53:02 CST 2010
Author: rmudgett
Date: Fri Feb 26 17:52:58 2010
New Revision: 1509
URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1509
Log:
Some code clean up.
* Removed necessity for PRI_MASTER() to check its parameter for NULL.
* Replaced calls to q931_is_ptmp() with PTMP_MODE().
Modified:
team/rmudgett/call_waiting/pri.c
team/rmudgett/call_waiting/pri_cc.c
team/rmudgett/call_waiting/pri_facility.c
team/rmudgett/call_waiting/pri_internal.h
team/rmudgett/call_waiting/q921.c
team/rmudgett/call_waiting/q931.c
Modified: team/rmudgett/call_waiting/pri.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/pri.c?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/pri.c (original)
+++ team/rmudgett/call_waiting/pri.c Fri Feb 26 17:52:58 2010
@@ -825,7 +825,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* PTMP mode */
q931_notify_redirection(ctrl, call, PRI_NOTIFY_TRANSFER_ACTIVE,
&call->local_id.number);
@@ -916,7 +916,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* PTMP mode */
q931_notify_redirection(ctrl, call, PRI_NOTIFY_CALL_DIVERTING,
&call->redirecting.to.number);
@@ -1260,7 +1260,9 @@
int added_length;
va_list ap;
- ctrl = PRI_MASTER(ctrl);
+ if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
+ }
if (!ctrl || !ctrl->msg_line) {
/* Just have to do it the old way. */
va_start(ap, fmt);
@@ -1322,7 +1324,7 @@
vsnprintf(tmp, sizeof(tmp), fmt, ap);
va_end(ap);
if (__pri_error)
- __pri_error(PRI_MASTER(pri), tmp);
+ __pri_error(pri ? PRI_MASTER(pri) : NULL, tmp);
else
fputs(tmp, stderr);
}
@@ -1593,16 +1595,16 @@
void pri_transfer_enable(struct pri *ctrl, int enable)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->transfer_support = enable ? 1 : 0;
}
}
void pri_hold_enable(struct pri *ctrl, int enable)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->hold_support = enable ? 1 : 0;
}
}
@@ -1665,8 +1667,8 @@
void pri_reroute_enable(struct pri *ctrl, int enable)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->deflection_support = enable ? 1 : 0;
}
}
@@ -1717,32 +1719,32 @@
void pri_cc_enable(struct pri *ctrl, int enable)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->cc_support = enable ? 1 : 0;
}
}
void pri_cc_recall_mode(struct pri *ctrl, int mode)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->cc.option.recall_mode = mode ? 1 : 0;
}
}
void pri_cc_retain_signaling_req(struct pri *ctrl, int signaling_retention)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl && 0 <= signaling_retention && signaling_retention < 3) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->cc.option.signaling_retention_req = signaling_retention;
}
}
void pri_cc_retain_signaling_rsp(struct pri *ctrl, int signaling_retention)
{
- ctrl = PRI_MASTER(ctrl);
if (ctrl) {
+ ctrl = PRI_MASTER(ctrl);
ctrl->cc.option.signaling_retention_rsp = signaling_retention ? 1 : 0;
}
}
Modified: team/rmudgett/call_waiting/pri_cc.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/pri_cc.c?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/pri_cc.c (original)
+++ team/rmudgett/call_waiting/pri_cc.c Fri Feb 26 17:52:58 2010
@@ -535,7 +535,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
end =
enc_etsi_ptmp_cc_available(ctrl, buffer, buffer + sizeof(buffer),
cc_record);
@@ -1367,7 +1367,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
end =
enc_etsi_ptmp_remote_user_free(ctrl, buffer, buffer + sizeof(buffer),
cc_record);
@@ -1843,7 +1843,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
end =
enc_etsi_ptmp_cc_recall(ctrl, buffer, buffer + sizeof(buffer), cc_record);
} else {
@@ -2717,7 +2717,7 @@
pri_schedule_del(ctrl, cc_record->t_recall);
cc_record->t_recall = 0;
}
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
msg = pri_call_apdu_find(cc_record->signaling,
cc_record->fsm.ptmp.t_ccbs1_invoke_id);
if (msg) {
@@ -2936,7 +2936,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* ETSI PTMP mode. */
timer_id = cc_record->is_ccnr ? PRI_TIMER_T_CCNR2 : PRI_TIMER_T_CCBS2;
} else if (cc_record->is_agent) {
@@ -3433,7 +3433,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
end =
enc_etsi_ptmp_cc_request(ctrl, buffer, buffer + sizeof(buffer),
cc_record);
@@ -6734,7 +6734,7 @@
break;
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
if (cc_record->is_agent) {
cc_fsm = pri_cc_fsm_ptmp_agent;
} else {
@@ -6830,7 +6830,7 @@
break;
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
int linkage_id;
if (!BRI_NT_PTMP(ctrl)) {
@@ -6989,7 +6989,7 @@
break;
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* ETSI PTMP */
if (pri_cc_event(ctrl, cc_record->signaling, cc_record, CC_EVENT_CC_REQUEST)) {
/* Should not happen. */
@@ -7525,7 +7525,7 @@
break;
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
if (!pri_cc_req_rsp_ptmp(ctrl, cc_record, status)) {
fail = 0;
}
@@ -7750,7 +7750,7 @@
break;
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
if (cc_record->response.invoke_operation != ROSE_ETSI_CCBSStatusRequest) {
/* We no longer know how to send the response. */
break;
Modified: team/rmudgett/call_waiting/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/pri_facility.c?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/pri_facility.c (original)
+++ team/rmudgett/call_waiting/pri_facility.c Fri Feb 26 17:52:58 2010
@@ -2094,7 +2094,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
end =
enc_etsi_call_deflection(ctrl, buffer, buffer + sizeof(buffer), call,
&deflection->to);
@@ -3157,7 +3157,7 @@
switch (ctrl->switchtype) {
case PRI_SWITCH_EUROISDN_E1:
case PRI_SWITCH_EUROISDN_T1:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* PTMP mode */
break;
}
Modified: team/rmudgett/call_waiting/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/pri_internal.h?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/pri_internal.h (original)
+++ team/rmudgett/call_waiting/pri_internal.h Fri Feb 26 17:52:58 2010
@@ -943,7 +943,6 @@
const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
const char *msg2str(int msg);
-int q931_is_ptmp(const struct pri *ctrl);
int q931_master_pass_event(struct pri *ctrl, struct q931_call *subcall, int msg_type);
struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
@@ -961,71 +960,123 @@
int q931_cc_timeout(struct pri *ctrl, struct pri_cc_record *cc_record, enum CC_EVENTS event);
void q931_cc_indirect(struct pri *ctrl, struct pri_cc_record *cc_record, void (*func)(struct pri *ctrl, q931_call *call, struct pri_cc_record *cc_record));
-static inline struct pri * PRI_MASTER(struct pri *mypri)
+/*!
+ * \brief Get the master PRI control structure.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \return Master PRI control structure.
+ */
+static inline struct pri *PRI_MASTER(struct pri *ctrl)
{
- struct pri *pri = mypri;
-
- if (!pri)
- return NULL;
-
- while (pri->master)
- pri = pri->master;
-
- return pri;
+ while (ctrl->master) {
+ ctrl = ctrl->master;
+ }
+ return ctrl;
}
-static inline int BRI_NT_PTMP(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in BRI NT PTMP mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in BRI NT PTMP mode.
+ * \retval FALSE otherwise.
+ */
+static inline int BRI_NT_PTMP(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->bri && (((pri)->localtype == PRI_NETWORK) && ((pri)->tei == Q921_TEI_GROUP));
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->bri && my_ctrl->localtype == PRI_NETWORK
+ && my_ctrl->tei == Q921_TEI_GROUP;
}
-static inline int BRI_TE_PTMP(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in BRI TE PTMP mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in BRI TE PTMP mode.
+ * \retval FALSE otherwise.
+ */
+static inline int BRI_TE_PTMP(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->bri && (((pri)->localtype == PRI_CPE) && ((pri)->tei == Q921_TEI_GROUP));
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->bri && my_ctrl->localtype == PRI_CPE
+ && my_ctrl->tei == Q921_TEI_GROUP;
}
-static inline int NT_MODE(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in NT mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in NT mode.
+ * \retval FALSE otherwise.
+ */
+static inline int NT_MODE(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->localtype == PRI_NETWORK;
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->localtype == PRI_NETWORK;
}
-static inline int TE_MODE(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in TE mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in TE mode.
+ * \retval FALSE otherwise.
+ */
+static inline int TE_MODE(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->localtype == PRI_CPE;
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->localtype == PRI_CPE;
}
-static inline int PTP_MODE(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in PTP mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in PTP mode.
+ * \retval FALSE otherwise.
+ */
+static inline int PTP_MODE(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->tei == Q921_TEI_PRI;
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->tei == Q921_TEI_PRI;
}
-static inline int PTMP_MODE(struct pri *mypri)
+/*!
+ * \brief Determine if layer 2 is in PTMP mode.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \retval TRUE if in PTMP mode.
+ * \retval FALSE otherwise.
+ */
+static inline int PTMP_MODE(const struct pri *ctrl)
{
- struct pri *pri;
-
- pri = PRI_MASTER(mypri);
-
- return pri->tei == Q921_TEI_GROUP;
+ struct pri *my_ctrl = (struct pri *) ctrl;
+
+ /* Check master control structure */
+ my_ctrl = PRI_MASTER(my_ctrl);
+ return my_ctrl->tei == Q921_TEI_GROUP;
}
#define Q931_DUMMY_CALL_REFERENCE -1
Modified: team/rmudgett/call_waiting/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/q921.c?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/q921.c (original)
+++ team/rmudgett/call_waiting/q921.c Fri Feb 26 17:52:58 2010
@@ -94,8 +94,7 @@
{
int res;
- if (pri->master)
- pri = pri->master;
+ pri = PRI_MASTER(pri);
#ifdef RANDOM_DROPS
if (!(random() % 3)) {
Modified: team/rmudgett/call_waiting/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/q931.c?view=diff&rev=1509&r1=1508&r2=1509
==============================================================================
--- team/rmudgett/call_waiting/q931.c (original)
+++ team/rmudgett/call_waiting/q931.c Fri Feb 26 17:52:58 2010
@@ -320,22 +320,6 @@
}
return channelno | (ds1no << 8) | (call->ds1explicit << 16) | (call->cis_call << 17)
| held_call;
-}
-
-/*!
- * \brief Determine if layer 2 is in PTMP mode.
- *
- * \param ctrl D channel controller.
- *
- * \retval TRUE if in PTMP mode.
- * \retval FALSE otherwise.
- */
-int q931_is_ptmp(const struct pri *ctrl)
-{
- /* Check master control structure */
- for (; ctrl->master; ctrl = ctrl->master) {
- }
- return ctrl->tei == Q921_TEI_GROUP;
}
/*!
@@ -5207,7 +5191,7 @@
case Q931_CALL_STATE_CALL_RECEIVED:
case Q931_CALL_STATE_CONNECT_REQUEST:
case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* HOLD request only allowed in these states if point-to-point mode. */
break;
}
@@ -5409,7 +5393,7 @@
case Q931_CALL_STATE_CALL_RECEIVED:
case Q931_CALL_STATE_CONNECT_REQUEST:
case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* RETRIEVE request only allowed in these states if point-to-point mode. */
break;
}
@@ -7674,7 +7658,7 @@
case Q931_CALL_STATE_CALL_RECEIVED:
case Q931_CALL_STATE_CONNECT_REQUEST:
case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* HOLD request only allowed in these states if point-to-point mode. */
q931_send_hold_rej_msg(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE);
break;
@@ -7787,7 +7771,7 @@
case Q931_CALL_STATE_CALL_RECEIVED:
case Q931_CALL_STATE_CONNECT_REQUEST:
case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
- if (q931_is_ptmp(ctrl)) {
+ if (PTMP_MODE(ctrl)) {
/* RETRIEVE request only allowed in these states if point-to-point mode. */
q931_send_retrieve_rej_msg(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE);
break;
More information about the svn-commits
mailing list