[libpri-commits] rmudgett: branch group/ccss r1535 - /team/group/ccss/
SVN commits to the libpri project
libpri-commits at lists.digium.com
Wed Mar 17 13:10:41 CDT 2010
Author: rmudgett
Date: Wed Mar 17 13:10:37 2010
New Revision: 1535
URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1535
Log:
Merged revisions 1534 via svnmerge from
https://origsvn.digium.com/svn/libpri/branches/1.4
........
r1534 | rmudgett | 2010-03-17 12:47:53 -0500 (Wed, 17 Mar 2010) | 12 lines
Miscellaneous simple reorganization.
1) Make PRI_MASTER() no longer check for a NULL parameter. It is the
caller's responsibility. Not many callers could have passed a NULL
without crashing before or after anyway.
2) Replace calls to q931_is_ptmp() with PTMP_MODE(). They were
equivalent.
3) Made the following boolean config options bit fields: sendfacility,
overlapdial, chan_mapping_logical, and service_message_support.
........
Modified:
team/group/ccss/ (props changed)
team/group/ccss/pri.c
team/group/ccss/pri_cc.c
team/group/ccss/pri_facility.c
team/group/ccss/pri_internal.h
team/group/ccss/q921.c
team/group/ccss/q931.c
Propchange: team/group/ccss/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 17 13:10:37 2010
@@ -1,1 +1,1 @@
-/branches/1.4:1-1511
+/branches/1.4:1-1534
Modified: team/group/ccss/pri.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri.c?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/pri.c (original)
+++ team/group/ccss/pri.c Wed Mar 17 13:10:37 2010
@@ -241,7 +241,7 @@
if (!pri) {
return -1;
}
- pri->service_message_support = supportflag;
+ pri->service_message_support = supportflag ? 1 : 0;
return 0;
}
@@ -824,7 +824,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);
@@ -915,7 +915,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);
@@ -1255,7 +1255,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);
@@ -1317,7 +1319,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);
}
@@ -1325,18 +1327,23 @@
/* Set overlap mode */
void pri_set_overlapdial(struct pri *pri,int state)
{
- pri->overlapdial = state;
+ if (pri) {
+ pri->overlapdial = state ? 1 : 0;
+ }
}
void pri_set_chan_mapping_logical(struct pri *pri, int state)
{
- if (pri->switchtype == PRI_SWITCH_QSIG)
- pri->chan_mapping_logical = state;
+ if (pri && pri->switchtype == PRI_SWITCH_QSIG) {
+ pri->chan_mapping_logical = state ? 1 : 0;
+ }
}
void pri_set_inbanddisconnect(struct pri *pri, unsigned int enable)
{
- pri->acceptinbanddisconnect = (enable != 0);
+ if (pri) {
+ pri->acceptinbanddisconnect = (enable != 0);
+ }
}
int pri_fd(struct pri *pri)
@@ -1588,8 +1595,8 @@
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;
}
}
@@ -1652,8 +1659,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;
}
}
@@ -1704,32 +1711,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/group/ccss/pri_cc.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri_cc.c?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/pri_cc.c (original)
+++ team/group/ccss/pri_cc.c Wed Mar 17 13:10:37 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/group/ccss/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri_facility.c?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/pri_facility.c (original)
+++ team/group/ccss/pri_facility.c Wed Mar 17 13:10:37 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);
@@ -2894,7 +2894,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/group/ccss/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri_internal.h?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/pri_internal.h (original)
+++ team/group/ccss/pri_internal.h Wed Mar 17 13:10:37 2010
@@ -98,6 +98,10 @@
int protodisc;
unsigned int bri:1;
unsigned int acceptinbanddisconnect:1; /* Should we allow inband progress after DISCONNECT? */
+ unsigned int sendfacility:1;
+ unsigned int overlapdial:1;/* TRUE if we do overlap dialing */
+ unsigned int chan_mapping_logical:1;/* TRUE if do not skip channel 16 (Q.SIG) */
+ unsigned int service_message_support:1;/* TRUE if upper layer supports SERVICE messages */
unsigned int hold_support:1;/* TRUE if upper layer supports call hold. */
unsigned int deflection_support:1;/* TRUE if upper layer supports call deflection/rerouting. */
unsigned int cc_support:1;/* TRUE if upper layer supports call completion. */
@@ -154,15 +158,6 @@
*/
q931_call *dummy_call;
- /* do we do overlap dialing */
- int overlapdial;
-
- /* do we support SERVICE messages */
- int service_message_support;
-
- /* do not skip channel 16 */
- int chan_mapping_logical;
-
#ifdef LIBPRI_COUNTERS
/* q921/q931 packet counters */
unsigned int q921_txcount;
@@ -172,7 +167,6 @@
#endif
short last_invoke; /* Last ROSE invoke ID (Valid in master record only) */
- unsigned char sendfacility;
/*! Call completion (Valid in master record only) */
struct {
@@ -935,7 +929,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);
@@ -950,71 +943,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/group/ccss/q921.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/q921.c?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/q921.c (original)
+++ team/group/ccss/q921.c Wed Mar 17 13:10:37 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/group/ccss/q931.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/q931.c?view=diff&rev=1535&r1=1534&r2=1535
==============================================================================
--- team/group/ccss/q931.c (original)
+++ team/group/ccss/q931.c Wed Mar 17 13:10:37 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;
}
/*!
@@ -5163,7 +5147,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;
}
@@ -5365,7 +5349,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;
}
@@ -7584,7 +7568,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;
@@ -7697,7 +7681,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 libpri-commits
mailing list