Miscellaneous changes:
* Removed unnecessary Q931_IE_CONNECTED_NUM ie from setup_ack_ies[]. * Added internal state Q931_CALL_STATE_NOT_SET to Q.931 state enum. * Made q931_is_ptmp() take a const pointer. * pri_facility.c: Some preparations for subaddressing. * pri.c: Eliminate use of a magic number. git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1177 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
ab1580de67
commit
296c64df23
4
pri.c
4
pri.c
@ -223,7 +223,7 @@ static int __pri_write(struct pri *pri, void *buf, int buflen)
|
||||
/* Pass in the master for this function */
|
||||
void __pri_free_tei(struct pri * p)
|
||||
{
|
||||
free (p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri)
|
||||
@ -841,7 +841,7 @@ int pri_hangup(struct pri *pri, q931_call *call, int cause)
|
||||
return -1;
|
||||
if (cause == -1)
|
||||
/* normal clear cause */
|
||||
cause = 16;
|
||||
cause = PRI_CAUSE_NORMAL_CLEARING;
|
||||
return q931_hangup(pri, call, cause);
|
||||
}
|
||||
|
||||
|
@ -514,6 +514,7 @@ static void rose_copy_number_to_q931(struct pri *ctrl,
|
||||
sizeof(q931_number->str));
|
||||
q931_number->plan = numbering_plan_for_q931(ctrl, rose_number->plan)
|
||||
| typeofnumber_for_q931(ctrl, rose_number->ton);
|
||||
q931_number->valid = 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -580,28 +581,29 @@ static void rose_copy_presented_number_unscreened_to_q931(struct pri *ctrl,
|
||||
* \brief Copy the given rose presented screened party address to the q931_party_number
|
||||
*
|
||||
* \param ctrl D channel controller for diagnostic messages or global options.
|
||||
* \param q931_number Q.931 party number structure
|
||||
* \param q931_address Q.931 party id structure to fill the address
|
||||
* \param rose_presented ROSE presented screened party address structure
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
static void rose_copy_presented_address_screened_to_q931(struct pri *ctrl,
|
||||
struct q931_party_number *q931_number,
|
||||
struct q931_party_id *q931_address,
|
||||
const struct rosePresentedAddressScreened *rose_presented)
|
||||
{
|
||||
q931_party_number_init(q931_number);
|
||||
q931_number->valid = 1;
|
||||
q931_number->presentation = presentation_for_q931(ctrl, rose_presented->presentation);
|
||||
q931_party_number_init(&q931_address->number);
|
||||
q931_address->number.valid = 1;
|
||||
q931_address->number.presentation = presentation_for_q931(ctrl,
|
||||
rose_presented->presentation);
|
||||
switch (rose_presented->presentation) {
|
||||
case 0: /* presentationAllowedAddress */
|
||||
case 3: /* presentationRestrictedAddress */
|
||||
q931_number->presentation |=
|
||||
q931_address->number.presentation |=
|
||||
(rose_presented->screened.screening_indicator & PRI_PRES_NUMBER_TYPE);
|
||||
rose_copy_number_to_q931(ctrl, q931_number,
|
||||
rose_copy_number_to_q931(ctrl, &q931_address->number,
|
||||
&rose_presented->screened.number);
|
||||
break;
|
||||
default:
|
||||
q931_number->presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
|
||||
q931_address->number.presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -703,20 +705,22 @@ static void q931_copy_presented_number_unscreened_to_rose(struct pri *ctrl,
|
||||
*
|
||||
* \param ctrl D channel controller for diagnostic messages or global options.
|
||||
* \param rose_presented ROSE presented screened party address structure
|
||||
* \param q931_number Q.931 party number structure
|
||||
* \param q931_address Q.931 party id structure to get the address
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
static void q931_copy_presented_address_screened_to_rose(struct pri *ctrl,
|
||||
struct rosePresentedAddressScreened *rose_presented,
|
||||
const struct q931_party_number *q931_number)
|
||||
const struct q931_party_id *q931_address)
|
||||
{
|
||||
if (q931_number->valid) {
|
||||
if (q931_address->number.valid) {
|
||||
rose_presented->presentation =
|
||||
presentation_from_q931(ctrl, q931_number->presentation, q931_number->str[0]);
|
||||
presentation_from_q931(ctrl, q931_address->number.presentation,
|
||||
q931_address->number.str[0]);
|
||||
rose_presented->screened.screening_indicator =
|
||||
q931_number->presentation & PRI_PRES_NUMBER_TYPE;
|
||||
q931_copy_number_to_rose(ctrl, &rose_presented->screened.number, q931_number);
|
||||
q931_address->number.presentation & PRI_PRES_NUMBER_TYPE;
|
||||
q931_copy_number_to_rose(ctrl, &rose_presented->screened.number,
|
||||
&q931_address->number);
|
||||
rose_presented->screened.subaddress.length = 0;
|
||||
} else {
|
||||
rose_presented->presentation = 2;/* numberNotAvailableDueToInterworking */
|
||||
@ -2868,8 +2872,8 @@ void rose_handle_invoke(struct pri *ctrl, q931_call *call, q931_ie *ie,
|
||||
case ROSE_QSIG_CallTransferActive:
|
||||
call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
|
||||
|
||||
/* connectedAddress is put in remote_id.number */
|
||||
rose_copy_presented_address_screened_to_q931(ctrl, &call->remote_id.number,
|
||||
/* connectedAddress is put in remote_id */
|
||||
rose_copy_presented_address_screened_to_q931(ctrl, &call->remote_id,
|
||||
&invoke->args.qsig.CallTransferActive.connected);
|
||||
|
||||
/* connectedName is put in remote_id.name */
|
||||
@ -2953,7 +2957,6 @@ void rose_handle_invoke(struct pri *ctrl, q931_call *call, q931_ie *ie,
|
||||
break;
|
||||
case QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR:
|
||||
q931_party_number_init(&call->redirecting.to.number);
|
||||
call->redirecting.to.number.valid = 1;
|
||||
rose_copy_number_to_q931(ctrl, &call->redirecting.to.number,
|
||||
&invoke->args.qsig.DivertingLegInformation1.nominated_number);
|
||||
if (call->redirecting.to.number.str[0]) {
|
||||
|
@ -505,9 +505,9 @@ void q931_party_redirecting_copy_to_pri(struct pri_party_redirecting *pri_redire
|
||||
void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id);
|
||||
int q931_party_id_presentation(const struct q931_party_id *id);
|
||||
|
||||
const char *q931_call_state_str(int callstate);
|
||||
const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
|
||||
|
||||
int q931_is_ptmp(struct pri *ctrl);
|
||||
int q931_is_ptmp(const struct pri *ctrl);
|
||||
struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
|
||||
|
||||
int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number);
|
||||
|
@ -413,9 +413,16 @@ enum Q931_CALL_STATE {
|
||||
Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE = 31,
|
||||
Q931_CALL_STATE_RESTART_REQUEST = 61,
|
||||
Q931_CALL_STATE_RESTART = 62,
|
||||
/*!
|
||||
* \details
|
||||
* Call state has not been set.
|
||||
* Call state does not exist.
|
||||
* Call state not initialized.
|
||||
* Call state internal use only.
|
||||
*/
|
||||
Q931_CALL_STATE_NOT_SET = 0xFF,
|
||||
};
|
||||
|
||||
|
||||
/* EuroISDN */
|
||||
#define Q931_SENDING_COMPLETE 0xa1
|
||||
|
||||
|
19
q931.c
19
q931.c
@ -281,7 +281,7 @@ static int q931_encode_channel(const q931_call *call)
|
||||
* \retval TRUE if in PTMP mode.
|
||||
* \retval FALSE otherwise.
|
||||
*/
|
||||
int q931_is_ptmp(struct pri *ctrl)
|
||||
int q931_is_ptmp(const struct pri *ctrl)
|
||||
{
|
||||
/* Check master control structure */
|
||||
for (; ctrl->master; ctrl = ctrl->master) {
|
||||
@ -2136,7 +2136,7 @@ static int receive_call_state(int full_ie, struct pri *ctrl, q931_call *call, in
|
||||
*
|
||||
* \return String equivalent of the given Q.931 call state.
|
||||
*/
|
||||
const char *q931_call_state_str(int callstate)
|
||||
const char *q931_call_state_str(enum Q931_CALL_STATE callstate)
|
||||
{
|
||||
static struct msgtype callstates[] = {
|
||||
/* *INDENT-OFF* */
|
||||
@ -2160,9 +2160,10 @@ const char *q931_call_state_str(int callstate)
|
||||
{ Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE, "Call Independent Service" },
|
||||
{ Q931_CALL_STATE_RESTART_REQUEST, "Restart Request" },
|
||||
{ Q931_CALL_STATE_RESTART, "Restart" },
|
||||
{ Q931_CALL_STATE_NOT_SET, "Not set. Internal use only." },
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
return code2str(callstate, callstates, sizeof(callstates) / sizeof(callstates[0]));
|
||||
return code2str(callstate, callstates, ARRAY_LEN(callstates));
|
||||
}
|
||||
|
||||
static void dump_call_state(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
|
||||
@ -3069,7 +3070,7 @@ static q931_call *q931_getcall(struct pri *ctrl, int cr)
|
||||
cur->newcall = 1;
|
||||
cur->ourcallstate = Q931_CALL_STATE_NULL;
|
||||
cur->peercallstate = Q931_CALL_STATE_NULL;
|
||||
cur->sugcallstate = -1;
|
||||
cur->sugcallstate = Q931_CALL_STATE_NOT_SET;
|
||||
cur->ri = -1;
|
||||
cur->transcapability = -1;
|
||||
cur->transmoderate = -1;
|
||||
@ -3702,7 +3703,7 @@ int q931_alerting(struct pri *ctrl, q931_call *c, int channel, int info)
|
||||
return send_message(ctrl, c, Q931_ALERTING, alerting_ies);
|
||||
}
|
||||
|
||||
static int setup_ack_ies[] = { Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_IE_CONNECTED_NUM, -1 };
|
||||
static int setup_ack_ies[] = { Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, -1 };
|
||||
|
||||
int q931_setup_ack(struct pri *ctrl, q931_call *c, int channel, int nonisdn)
|
||||
{
|
||||
@ -4273,7 +4274,7 @@ static int prepare_to_handle_q931_message(struct pri *ctrl, q931_mh *mh, q931_ca
|
||||
c->cause = -1;
|
||||
c->causecode = -1;
|
||||
c->causeloc = -1;
|
||||
c->sugcallstate = -1;
|
||||
c->sugcallstate = Q931_CALL_STATE_NOT_SET;
|
||||
c->aoc_units = -1;
|
||||
break;
|
||||
case Q931_RESTART_ACKNOWLEDGE:
|
||||
@ -4361,6 +4362,7 @@ int q931_receive(struct pri *ctrl, q931_h *h, int len)
|
||||
q931_xmit(ctrl, h, len, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cref = q931_cr(h);
|
||||
c = q931_getcall(ctrl, cref);
|
||||
if (!c) {
|
||||
@ -4531,7 +4533,7 @@ static int post_handle_maintenance_message(struct pri *ctrl, int protodisc, stru
|
||||
* \brief Fill in the FACILITY event fields.
|
||||
*
|
||||
* \param ctrl D channel controller.
|
||||
* \param call Q.931 call leg
|
||||
* \param call Q.931 call leg.
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
@ -4920,6 +4922,7 @@ static int post_handle_q931_message(struct pri *ctrl, struct q931_mh *mh, struct
|
||||
pri_hangup(ctrl, c, c->cause);
|
||||
} else
|
||||
res = 0;
|
||||
|
||||
if (res)
|
||||
return res;
|
||||
else
|
||||
@ -5148,7 +5151,7 @@ static int pri_internal_clear(void *data)
|
||||
c->cause = -1;
|
||||
c->causecode = -1;
|
||||
c->causeloc = -1;
|
||||
c->sugcallstate = -1;
|
||||
c->sugcallstate = Q931_CALL_STATE_NOT_SET;
|
||||
c->aoc_units = -1;
|
||||
|
||||
UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user