From 25cb0b745758c87ba452858a5ffe4186c388d9db Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Tue, 12 Jul 2005 02:33:25 +0000 Subject: [PATCH] forward more ANI information to users of libpri (bug #4571) git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@239 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- libpri.h | 14 ++++++++------ pri_internal.h | 11 ++++++----- q931.c | 44 ++++++++++++++++++++++---------------------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/libpri.h b/libpri.h index c042d34..097f309 100755 --- a/libpri.h +++ b/libpri.h @@ -294,10 +294,12 @@ typedef struct pri_event_facname { q931_call *call; } pri_event_facname; +#define PRI_CALLINGPLANANI typedef struct pri_event_ring { int e; int channel; /* Channel requested */ int callingpres; /* Presentation of Calling CallerID */ + int callingplanani; /* Dialing plan of Calling entity ANI */ int callingplan; /* Dialing plan of Calling entity */ char callingani[256]; /* Calling ANI */ char callingnum[256]; /* Calling number */ @@ -305,17 +307,17 @@ typedef struct pri_event_ring { int calledplan; /* Dialing plan of Called number */ int ani2; /* ANI II */ char callednum[256]; /* Called number */ - char redirectingnum[256]; /* Redirecting number */ - char redirectingname[256]; /* Redirecting name */ - int redirectingreason; /* Reason for redirect */ - char useruserinfo[256]; /* User->User info */ + char redirectingnum[256]; /* Redirecting number */ + char redirectingname[256]; /* Redirecting name */ + int redirectingreason; /* Reason for redirect */ + char useruserinfo[256]; /* User->User info */ int flexible; /* Are we flexible with our channel selection? */ int cref; /* Call Reference Number */ int ctype; /* Call type (see PRI_TRANS_CAP_* */ - int layer1; /* User layer 1 */ + int layer1; /* User layer 1 */ int complete; /* Have we seen "Complete" i.e. no more number? */ q931_call *call; /* Opaque call pointer */ - char callingsubaddr[256]; /* Calling parties subaddress */ + char callingsubaddr[256]; /* Calling parties subaddress */ int progress; int progressmask; char origcalledname[256]; diff --git a/pri_internal.h b/pri_internal.h index 0f58a45..d075c83 100755 --- a/pri_internal.h +++ b/pri_internal.h @@ -199,16 +199,17 @@ struct q931_call { int sugcallstate; /* Status call state */ int callerplan; + int callerplanani; int callerpres; /* Caller presentation */ char callerani[256]; /* Caller */ char callernum[256]; char callername[256]; - char digitbuf[64]; /* Buffer for digits that come in KEYPAD_FACILITY */ + char digitbuf[64]; /* Buffer for digits that come in KEYPAD_FACILITY */ int ani2; /* ANI II */ - int calledplan; + int calledplan; int nonisdn; char callednum[256]; /* Called Number */ int complete; /* no more digits coming */ @@ -226,11 +227,11 @@ struct q931_call { /* Filled in cases of multiple diversions */ int origcalledplan; int origcalledpres; - int origredirectingreason; /* Original reason for redirect (in cases of multiple redirects) */ + int origredirectingreason; /* Original reason for redirect (in cases of multiple redirects) */ char origcalledname[256]; /* Original name of person being called */ - char origcallednum[256]; /* Orignal number of person being called */ + char origcallednum[256]; /* Orignal number of person being called */ - int useruserprotocoldisc; + int useruserprotocoldisc; char useruserinfo[256]; char callingsubaddr[256]; /* Calling parties sub address */ diff --git a/q931.c b/q931.c index 9a7fda6..f031630 100755 --- a/q931.c +++ b/q931.c @@ -913,18 +913,12 @@ static FUNC_RECV(receive_calling_party_number) { u_int8_t *data; size_t length; - int extbit; - call->callerplan = ie->data[0] & 0x7f; - extbit = (ie->data[0] >> 7) & 0x01; - - if (extbit) { + if (ie->data[0] & 0x80) { data = ie->data + 1; length = len - 3; - call->callerpres = 0; /* PI presentation allowed - SI user-provided, not screened */ - } - else { + call->callerpres = 0; /* PI presentation allowed SI user-provided, not screened */ + } else { data = ie->data + 2; length = len - 4; call->callerpres = ie->data[1] & 0x7f; @@ -933,15 +927,17 @@ static FUNC_RECV(receive_calling_party_number) if (call->callerpres == PRES_ALLOWED_NETWORK_NUMBER || call->callerpres == PRES_PROHIB_NETWORK_NUMBER) { q931_get_number((u_int8_t *)call->callerani, sizeof(call->callerani), data, length); + call->callerplanani = ie->data[0] & 0x7f; - /* - * Copy ANI to Caller*ID if Caller*ID is not already set - */ - if (!*call->callernum) + if (!*call->callernum) { /*Copy ANI to CallerID if CallerID is not already set */ libpri_copy_string(call->callernum, call->callerani, sizeof(call->callernum)); - } - else + call->callerplan = call->callerplanani; + } + + } else { q931_get_number((u_int8_t *)call->callernum, sizeof(call->callernum), data, length); + call->callerplan = ie->data[0] & 0x7f; + } return 0; } @@ -3000,20 +2996,23 @@ int q931_receive(struct pri *pri, q931_h *h, int len) c->callernum[0] = '\0'; c->callednum[0] = '\0'; c->callername[0] = '\0'; - c->redirectingplan = -1; - c->redirectingpres = -1; - c->redirectingreason = -1; - c->origcalledplan = -1; - c->origcalledpres = -1; - c->origredirectingreason = -1; + c->callerani[0] = '\0'; + c->callerplanani = -1; + c->redirectingplan = -1; + c->redirectingpres = -1; + c->redirectingreason = -1; + c->origcalledplan = -1; + c->origcalledpres = -1; + c->origredirectingreason = -1; c->redirectingnum[0] = '\0'; c->origcallednum[0] = '\0'; c->redirectingname[0] = '\0'; c->origcalledname[0] = '\0'; - c->useruserprotocoldisc = -1; + c->useruserprotocoldisc = -1; c->useruserinfo[0] = '\0'; c->complete = 0; c->nonisdn = 0; + c->aoc_units = -1; /* Fall through */ case Q931_CONNECT: case Q931_ALERTING: @@ -3210,6 +3209,7 @@ int q931_receive(struct pri *pri, q931_h *h, int len) pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.ring.callingpres = c->callerpres; pri->ev.ring.callingplan = c->callerplan; + pri->ev.ring.callingplanani = c->callerplanani; pri->ev.ring.ani2 = c->ani2; libpri_copy_string(pri->ev.ring.callingani, c->callerani, sizeof(pri->ev.ring.callingani)); libpri_copy_string(pri->ev.ring.callingnum, c->callernum, sizeof(pri->ev.ring.callingnum));