Add ability to send redirecting number (bug #2760)
git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@155 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
1
libpri.h
1
libpri.h
@@ -449,6 +449,7 @@ extern int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int
|
||||
extern int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1);
|
||||
extern int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
|
||||
extern int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
|
||||
extern int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
|
||||
|
||||
extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
|
||||
|
||||
|
||||
8
pri.c
8
pri.c
@@ -639,3 +639,11 @@ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int cal
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason)
|
||||
{
|
||||
sr->redirectingnum = num;
|
||||
sr->redirectingplan = plan;
|
||||
sr->redirectingpres = pres;
|
||||
sr->redirectingreason = reason;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ struct pri_sr {
|
||||
int calledplan;
|
||||
int userl1;
|
||||
int numcomplete;
|
||||
char *redirectingnum;
|
||||
int redirectingplan;
|
||||
int redirectingpres;
|
||||
int redirectingreason;
|
||||
};
|
||||
|
||||
/* Internal switch types */
|
||||
|
||||
32
q931.c
32
q931.c
@@ -818,6 +818,17 @@ static FUNC_RECV(receive_redirecting_number)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FUNC_SEND(transmit_redirecting_number)
|
||||
{
|
||||
if (call->redirectingnum && strlen(call->redirectingnum)) {
|
||||
ie->data[0] = call->redirectingplan;
|
||||
ie->data[1] = call->redirectingpres;
|
||||
ie->data[2] = (call->redirectingreason & 0x0f) | 0x80;
|
||||
memcpy(ie->data + 3, call->redirectingnum, strlen(call->redirectingnum));
|
||||
return strlen(call->redirectingnum) + 3 + 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FUNC_DUMP(dump_redirecting_subaddr)
|
||||
{
|
||||
@@ -1458,7 +1469,7 @@ struct ie ies[] = {
|
||||
{ Q931_CALLING_PARTY_SUBADDR, "Calling Party Subaddress", dump_calling_party_subaddr, receive_calling_party_subaddr },
|
||||
{ Q931_CALLED_PARTY_NUMBER, "Called Party Number", dump_called_party_number, receive_called_party_number, transmit_called_party_number },
|
||||
{ Q931_CALLED_PARTY_SUBADDR, "Called Party Subaddress", dump_called_party_subaddr },
|
||||
{ Q931_REDIRECTING_NUMBER, "Redirecting Number", dump_redirecting_number, receive_redirecting_number },
|
||||
{ Q931_REDIRECTING_NUMBER, "Redirecting Number", dump_redirecting_number, receive_redirecting_number, transmit_redirecting_number },
|
||||
{ Q931_REDIRECTING_SUBADDR, "Redirecting Subaddress", dump_redirecting_subaddr },
|
||||
{ Q931_TRANSIT_NET_SELECT, "Transit Network Selection" },
|
||||
{ Q931_RESTART_INDICATOR, "Restart Indicator", dump_restart_indicator, receive_restart_indicator, transmit_restart_indicator },
|
||||
@@ -2191,7 +2202,7 @@ int q931_disconnect(struct pri *pri, q931_call *c, int cause)
|
||||
}
|
||||
|
||||
static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY,
|
||||
Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, -1 };
|
||||
Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, -1 };
|
||||
|
||||
static int gr303_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 };
|
||||
|
||||
@@ -2241,6 +2252,23 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
|
||||
c->callerplan = PRI_UNKNOWN;
|
||||
c->callerpres = PRES_NUMBER_NOT_AVAILABLE;
|
||||
}
|
||||
if (req->redirectingnum) {
|
||||
strncpy(c->redirectingnum, req->redirectingnum, sizeof(c->redirectingnum) - 1);
|
||||
c->redirectingplan = req->redirectingplan;
|
||||
if ((pri->switchtype == PRI_SWITCH_DMS100) ||
|
||||
(pri->switchtype == PRI_SWITCH_ATT4ESS)) {
|
||||
/* Doesn't like certain presentation types */
|
||||
if (!(req->redirectingpres & 0x7c))
|
||||
req->redirectingpres = PRES_ALLOWED_NETWORK_NUMBER;
|
||||
}
|
||||
c->redirectingpres = req->redirectingpres;
|
||||
c->redirectingreason = req->redirectingreason;
|
||||
} else {
|
||||
strcpy(c->redirectingnum, "");
|
||||
c->redirectingplan = PRI_UNKNOWN;
|
||||
c->redirectingpres = PRES_NUMBER_NOT_AVAILABLE;
|
||||
c->redirectingreason = PRI_REDIR_UNKNOWN;
|
||||
}
|
||||
if (req->called) {
|
||||
strncpy(c->callednum, req->called, sizeof(c->callednum) - 1);
|
||||
c->calledplan = req->calledplan;
|
||||
|
||||
Reference in New Issue
Block a user