Skip to content

Commit

Permalink
Added RichCallData into AuthRsp.
Browse files Browse the repository at this point in the history
  • Loading branch information
di-shi committed Dec 9, 2024
1 parent beb7020 commit 92a1f7a
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 7 deletions.
3 changes: 3 additions & 0 deletions RELNOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -805,3 +805,6 @@ Version 4.29.0 - 2024-07-23
Version 4.29.1 - 2024-11-15
* Fixed compiler warning messages.
* Fixed multiple definition of OSPVBlockingFlag.

Version 4.30.0 - 2024-12-09
* Added RichCallData into AuthRsp.
7 changes: 6 additions & 1 deletion include/osp/ospauthrsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ typedef struct {
char OrigId[OSPC_SIZE_NORID];
char JurisdictionType[OSPC_SIZE_NORID];
OSPT_STATUS_HEADERS StatusHeaders;
char RcdCrn[OSPC_SIZE_NORSTR];
char RcdIcn[OSPC_SIZE_URL];
char RcdIcnDigest[OSPC_SIZE_NORSTR];
} OSPT_AUTH_RSP;

#define OSPPAuthRspDestHasNumber(ospvDest) OSPPDestHasNumber(ospvDest)
Expand Down Expand Up @@ -101,7 +104,6 @@ extern "C" {
OSPTBOOL OSPPAuthRspHasMessageId(OSPT_AUTH_RSP *);
void OSPPAuthRspSetMessageId(OSPT_AUTH_RSP *, const char *);
void OSPPAuthRspMessageIdFromElement(OSPT_XML_ELEM *, const char **);
const char *OSPPAuthRspGetMessageId(OSPT_AUTH_RSP *);
void OSPPAuthRspSetTimestamp(OSPT_AUTH_RSP *, OSPTTIME);
OSPTBOOL OSPPAuthRspHasStatus(OSPT_AUTH_RSP *);
OSPT_STATUS *OSPPAuthRspGetStatus(OSPT_AUTH_RSP *);
Expand Down Expand Up @@ -131,6 +133,9 @@ extern "C" {
void OSPPAuthRspSetOrigId(OSPT_AUTH_RSP *, const char *);
OSPTBOOL OSPPAuthRspHasJurisdictionType(OSPT_AUTH_RSP *);
void OSPPAuthRspSetJurisdictionType(OSPT_AUTH_RSP *, const char *);
unsigned OSPPRcdFromElement(OSPT_XML_ELEM *, const char **, const char **, const char **);
OSPTBOOL OSPPAuthRspHasRcd(OSPT_AUTH_RSP *);
void OSPPAuthRspSetRcd(OSPT_AUTH_RSP *, const char *, const char *, const char *);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/osp/osplibversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define _OSPLIBVERSION_H

#define OSP_CLIENT_TOOLKIT_VERSION_MAJOR 4
#define OSP_CLIENT_TOOLKIT_VERSION_MINOR 29
#define OSP_CLIENT_TOOLKIT_VERSION_BUGFIX 1
#define OSP_CLIENT_TOOLKIT_VERSION_MINOR 30
#define OSP_CLIENT_TOOLKIT_VERSION_BUGFIX 0

#endif /* _OSPLIBVERSION_H */
7 changes: 7 additions & 0 deletions include/osp/ospmsgelem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef enum {
OSPC_MELEM_CALLID,
OSPC_MELEM_CALLIDPRIVACY,
OSPC_MELEM_CALLINGPARTYINFO,
OSPC_MELEM_CALLREASON,
OSPC_MELEM_CALLTYPE,
OSPC_MELEM_CAPIND,
OSPC_MELEM_CDRPROXY,
Expand Down Expand Up @@ -84,6 +85,7 @@ typedef enum {
OSPC_MELEM_DESTVIDEOADDR,
OSPC_MELEM_DEVICEID,
OSPC_MELEM_DEVICEINFO,
OSPC_MELEM_DISPLAYNAME,
OSPC_MELEM_DIVDEVINFO,
OSPC_MELEM_DIVSRCINFO,
OSPC_MELEM_ENDPOINT,
Expand All @@ -95,6 +97,8 @@ typedef enum {
OSPC_MELEM_GROUPID,
OSPC_MELEM_HEADERNAME,
OSPC_MELEM_HEADERVALUE,
OSPC_MELEM_ICONDIGEST,
OSPC_MELEM_ICONURL,
OSPC_MELEM_ICPIF,
OSPC_MELEM_IDBYPASS,
OSPC_MELEM_IDENTITY,
Expand Down Expand Up @@ -129,12 +133,15 @@ typedef enum {
OSPC_MELEM_PRICINGCNF,
OSPC_MELEM_PRICINGIND,
OSPC_MELEM_PROTOCOL,
OSPC_MELEM_RCD,
OSPC_MELEM_RCDINTEGRITY,
OSPC_MELEM_REAUTHREQ,
OSPC_MELEM_REAUTHRSP,
OSPC_MELEM_RELATEDREASON,
OSPC_MELEM_RELEASE,
OSPC_MELEM_RESOURCES,
OSPC_MELEM_RFACTOR,
OSPC_MELEM_RICHCALLDATA,
OSPC_MELEM_ROLE,
OSPC_MELEM_ROLEFORMAT,
OSPC_MELEM_ROLEINFO,
Expand Down
1 change: 1 addition & 0 deletions include/osp/osptransapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ extern "C" {
int OSPPTransactionSetLastRedirectBehalf(OSPTTRANHANDLE, const char *);
int OSPPTransactionSetOrigRedirectReason(OSPTTRANHANDLE, const char *);
int OSPPTransactionSetLastRedirectReason(OSPTTRANHANDLE, const char *);
int OSPPTransactionGetRichCallData(OSPTTRANHANDLE, unsigned, char *, unsigned, char *, unsigned, char *);

#ifdef __cplusplus
}
Expand Down
139 changes: 139 additions & 0 deletions src/ospauthrsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ unsigned OSPPAuthRspFromElement(
const char* origid = OSPC_OSNULL;
const char* jdtype = OSPC_OSNULL;
unsigned headerIndex = 0;
const char* crn = OSPC_OSNULL;
const char* icn = OSPC_OSNULL;
const char* icnDigest = OSPC_OSNULL;

if (ospvElem == OSPC_OSNULL) {
error = OSPC_ERR_XML_NO_ELEMENT;
Expand Down Expand Up @@ -550,6 +553,16 @@ unsigned OSPPAuthRspFromElement(
OSPPAuthRspSetJurisdictionType(authrsp, jdtype);
}
break;
case OSPC_MELEM_RICHCALLDATA:
if ((error = OSPPRcdFromElement(elem, &crn, &icn, &icnDigest)) == OSPC_ERR_NO_ERROR) {
if ((crn != OSPC_OSNULL) || (icn != OSPC_OSNULL)) {
OSPPAuthRspSetRcd(authrsp, crn, icn, icnDigest);
crn = OSPC_OSNULL;
icn = OSPC_OSNULL;
icnDigest = OSPC_OSNULL;
}
}
break;
default:
/*
* This is an element we don't understand. If it's
Expand Down Expand Up @@ -840,3 +853,129 @@ void OSPPAuthRspSetJurisdictionType(
}
}

/*
* OSPPRcdFromElement() - get rich call data from an XML element
*/
unsigned OSPPRcdFromElement( /* returns error code */
OSPT_XML_ELEM *ospvElem, /* In - input is XML element */
const char **ospvCrn, /* Out - RCD crn */
const char **ospvIcn, /* Out - RCD icn */
const char **ospvIcnDigest) /* Out - RCD icn degist */
{
unsigned errcode = OSPC_ERR_NO_ERROR;
OSPT_XML_ELEM *elem = OSPC_OSNULL;
OSPT_XML_ELEM *subelem = OSPC_OSNULL;

if (ospvElem == OSPC_OSNULL) {
errcode = OSPC_ERR_XML_NO_ELEMENT;
}

if (errcode == OSPC_ERR_NO_ERROR) {
if ((ospvCrn == OSPC_OSNULL) || (ospvIcn == OSPC_OSNULL) || (ospvIcnDigest == OSPC_OSNULL)) {
errcode = OSPC_ERR_XML_INVALID_ARGS;
}
}

if (errcode == OSPC_ERR_NO_ERROR) {
*ospvCrn = OSPC_OSNULL;
*ospvIcn = OSPC_OSNULL;
*ospvIcnDigest = OSPC_OSNULL;
for (elem = (OSPT_XML_ELEM *)OSPPXMLElemFirstChild(ospvElem);
(elem != OSPC_OSNULL) && (errcode == OSPC_ERR_NO_ERROR);
elem = (OSPT_XML_ELEM *)OSPPXMLElemNextChild(ospvElem, elem))
{
switch (OSPPMsgElemGetPart(OSPPXMLElemGetName(elem))) {
case OSPC_MELEM_CALLREASON:
*ospvCrn = OSPPXMLElemGetValue(elem);
break;
case OSPC_MELEM_RCD:
for (subelem = (OSPT_XML_ELEM *)OSPPXMLElemFirstChild(elem);
(subelem != OSPC_OSNULL) && (errcode == OSPC_ERR_NO_ERROR);
subelem = (OSPT_XML_ELEM *)OSPPXMLElemNextChild(elem, subelem))
{
switch (OSPPMsgElemGetPart(OSPPXMLElemGetName(subelem))) {
case OSPC_MELEM_DISPLAYNAME:
break;
case OSPC_MELEM_ICONURL:
*ospvIcn = OSPPXMLElemGetValue(subelem);
break;
default:
/*
* This is an element we don't understand. If it's
* critical, then we have to report an error.
* Otherwise we can ignore it.
*/
if (OSPPMsgElemIsCritical(subelem)) {
errcode = OSPC_ERR_XML_BAD_ELEMENT;
}
break;
}
}
break;
case OSPC_MELEM_RCDINTEGRITY:
for (subelem = (OSPT_XML_ELEM *)OSPPXMLElemFirstChild(elem);
(subelem != OSPC_OSNULL) && (errcode == OSPC_ERR_NO_ERROR);
subelem = (OSPT_XML_ELEM *)OSPPXMLElemNextChild(elem, subelem))
{
switch (OSPPMsgElemGetPart(OSPPXMLElemGetName(subelem))) {
case OSPC_MELEM_ICONDIGEST:
*ospvIcnDigest = OSPPXMLElemGetValue(subelem);
break;
default:
/*
* This is an element we don't understand. If it's
* critical, then we have to report an error.
* Otherwise we can ignore it.
*/
if (OSPPMsgElemIsCritical(subelem)) {
errcode = OSPC_ERR_XML_BAD_ELEMENT;
}
break;
}
}
break;
default:
/*
* This is an element we don't understand. If it's
* critical, then we have to report an error.
* Otherwise we can ignore it.
*/
if (OSPPMsgElemIsCritical(elem)) {
errcode = OSPC_ERR_XML_BAD_ELEMENT;
}
break;
}
}
}

return errcode;
}

OSPTBOOL OSPPAuthRspHasRcd(
OSPT_AUTH_RSP *ospvAuthRsp)
{
if (ospvAuthRsp != OSPC_OSNULL) {
return((ospvAuthRsp->RcdCrn[0] != '\0') || (ospvAuthRsp->RcdIcn[0] != '\0'));
} else {
return OSPC_FALSE;
}
}

void OSPPAuthRspSetRcd(
OSPT_AUTH_RSP *ospvAuthRsp, /* In - pointer to AuthRsp struct */
const char *ospvCrn, /* In - RCD crn */
const char *ospvIcn, /* In - RCD icn */
const char *ospvIcnDigest) /* In - RCD icn digest */
{
if (ospvAuthRsp != OSPC_OSNULL) {
if (ospvCrn != OSPC_OSNULL) {
OSPM_STRNCPY(ospvAuthRsp->RcdCrn, ospvCrn, sizeof(ospvAuthRsp->RcdCrn));
}
if (ospvIcn != OSPC_OSNULL) {
OSPM_STRNCPY(ospvAuthRsp->RcdIcn, ospvIcn, sizeof(ospvAuthRsp->RcdIcn));
if (ospvIcnDigest != OSPC_OSNULL) {
OSPM_STRNCPY(ospvAuthRsp->RcdIcnDigest, ospvIcnDigest, sizeof(ospvAuthRsp->RcdIcnDigest));
}
}
}
}
7 changes: 7 additions & 0 deletions src/ospmsgelem.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const OSPT_MSG_DESC OSPV_MELEM_DESCS[OSPC_MELEM_NUMBER] = {
{ OSPC_MELEM_CALLID, "CallId" },
{ OSPC_MELEM_CALLIDPRIVACY, "CallIdPrivacy" },
{ OSPC_MELEM_CALLINGPARTYINFO, "CallingPartyInfo" },
{ OSPC_MELEM_CALLREASON, "CallReason" },
{ OSPC_MELEM_CALLTYPE, "CallType" },
{ OSPC_MELEM_CAPIND, "CapabilitiesIndication" },
{ OSPC_MELEM_CDRPROXY, "CDRProxy" },
Expand Down Expand Up @@ -82,6 +83,7 @@ const OSPT_MSG_DESC OSPV_MELEM_DESCS[OSPC_MELEM_NUMBER] = {
{ OSPC_MELEM_DEVICEID, "DeviceId" },
{ OSPC_MELEM_DEVICEINFO, "DeviceInfo" },
{ OSPC_MELEM_DIVDEVINFO, "DiversionDeviceInfo" },
{ OSPC_MELEM_DISPLAYNAME, "DisplayName" },
{ OSPC_MELEM_DIVSRCINFO, "DiversionSourceInfo" },
{ OSPC_MELEM_ENDPOINT, "EndPoint" },
{ OSPC_MELEM_ENDTIME, "EndTime" },
Expand All @@ -92,6 +94,8 @@ const OSPT_MSG_DESC OSPV_MELEM_DESCS[OSPC_MELEM_NUMBER] = {
{ OSPC_MELEM_GROUPID, "GroupId" },
{ OSPC_MELEM_HEADERNAME, "HeaderName" },
{ OSPC_MELEM_HEADERVALUE, "HeaderValue" },
{ OSPC_MELEM_ICONDIGEST, "IconDigest" },
{ OSPC_MELEM_ICONURL, "IconUrl" },
{ OSPC_MELEM_ICPIF, "ICPIF" },
{ OSPC_MELEM_IDBYPASS, "IdBypassSourceInfo" },
{ OSPC_MELEM_IDENTITY, "IdentitySourceInfo" },
Expand Down Expand Up @@ -126,12 +130,15 @@ const OSPT_MSG_DESC OSPV_MELEM_DESCS[OSPC_MELEM_NUMBER] = {
{ OSPC_MELEM_PRICINGCNF, "PricingConfirmation" },
{ OSPC_MELEM_PRICINGIND, "PricingIndication" },
{ OSPC_MELEM_PROTOCOL, "SignalingProtocol" },
{ OSPC_MELEM_RCD, "Rcd" },
{ OSPC_MELEM_RCDINTEGRITY, "RcdIntegrity" },
{ OSPC_MELEM_REAUTHREQ, "ReauthorizationRequest" },
{ OSPC_MELEM_REAUTHRSP, "ReauthorizationResponse" },
{ OSPC_MELEM_RELATEDREASON, "RelatedCallIdReason" },
{ OSPC_MELEM_RELEASE, "ReleaseSource" },
{ OSPC_MELEM_RESOURCES, "Resources" },
{ OSPC_MELEM_RFACTOR, "RFactor" },
{ OSPC_MELEM_RICHCALLDATA, "RichCallData" },
{ OSPC_MELEM_ROLE, "Role" },
{ OSPC_MELEM_ROLEFORMAT, "Format" },
{ OSPC_MELEM_ROLEINFO, "RoleInfo" },
Expand Down
73 changes: 69 additions & 4 deletions src/osptransapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6179,7 +6179,7 @@ int OSPPTransactionGetTCDesc(
*/
int OSPPTransactionGetVerstat(
OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */
OSPE_VERIFICATION_STATUS *ospvStatus) /* In - Verification status */
OSPE_VERIFICATION_STATUS *ospvStatus) /* Out - Verification status */
{
int errcode = OSPC_ERR_NO_ERROR;
OSPTTRANS *trans = OSPC_OSNULL;
Expand Down Expand Up @@ -6209,7 +6209,7 @@ int OSPPTransactionGetVerstat(
*/
int OSPPTransactionGetAttest(
OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */
char *ospvAttest) /* In - Attestation */
char *ospvAttest) /* Out - Attestation */
{
int errcode = OSPC_ERR_NO_ERROR;
OSPTTRANS *trans = OSPC_OSNULL;
Expand Down Expand Up @@ -6240,7 +6240,7 @@ int OSPPTransactionGetAttest(
int OSPPTransactionGetOrigId(
OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */
unsigned ospvSizeOfOrigId, /* In - Max size of origination ID */
char *ospvOrigId) /* In - origination ID */
char *ospvOrigId) /* Out - origination ID */
{
int errcode = OSPC_ERR_NO_ERROR;
OSPTTRANS *trans = OSPC_OSNULL;
Expand Down Expand Up @@ -6304,7 +6304,7 @@ int OSPPTransactionSetUserRatePlan(
int OSPPTransactionGetJurisdictionType(
OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */
unsigned ospvSizeOfJurisdictionType, /* In - Max size of origination ID */
char *ospvJurisdictionType) /* In - Jurisdiction type*/
char *ospvJurisdictionType) /* Out - Jurisdiction type*/
{
int errcode = OSPC_ERR_NO_ERROR;
OSPTTRANS *trans = OSPC_OSNULL;
Expand Down Expand Up @@ -6660,3 +6660,68 @@ int OSPPTransactionSetLastRedirectReason(

return errcode;
}

/*
* OSPPTransactionGetRichCallData() :
* Reports the rich call data as returned in AuthRsp
* returns OSPC_ERR_NO_ERROR if successful.
*/
int OSPPTransactionGetRichCallData(
OSPTTRANHANDLE ospvTransaction, /* In - Transaction handle */
unsigned ospvSizeOfCrn, /* In - RCD call reason buffer size */
char *ospvCrn, /* Out - RCD call reason */
unsigned ospvSizeOfIcn, /* In - RCD icon URL buffer size */
char *ospvIcn, /* Out - RCD icon URL */
unsigned ospvSizeOfIcnDigest, /* In - RCD icon URL digest buffer size */
char *ospvIcnDigest) /* Out - RCD icon URL digest */
{
int errcode = OSPC_ERR_NO_ERROR;
OSPTTRANS *trans = OSPC_OSNULL;

ospvCrn[0] = '\0';
ospvIcn[0] = '\0';
ospvIcnDigest[0] = '\0';
if ((trans = OSPPTransactionGetContext(ospvTransaction, &errcode)) != OSPC_OSNULL) {
if (trans->AuthReq != OSPC_OSNULL) {
if (trans->State == OSPC_AUTH_REQUEST_SUCCESS) {
char *crn = trans->AuthRsp->RcdCrn;
if (crn[0] != '\0') {
if (ospvSizeOfCrn > OSPM_STRLEN(crn)) {
OSPM_STRNCPY(ospvCrn, crn, ospvSizeOfCrn);
} else {
errcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY;
OSPM_DBGERRORLOG(errcode, "No enough buffer to copy RCD crn.");
}
}

char *icn = trans->AuthRsp->RcdIcn;
if (icn[0] != '\0') {
if (ospvSizeOfIcn > OSPM_STRLEN(icn)) {
OSPM_STRNCPY(ospvIcn, icn, ospvSizeOfIcn);
} else {
errcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY;
OSPM_DBGERRORLOG(errcode, "No enough buffer to copy RCD icn.");
}
}

char *digest = trans->AuthRsp->RcdIcnDigest;
if (digest[0] != '\0') {
if (ospvSizeOfIcnDigest > OSPM_STRLEN(digest)) {
OSPM_STRNCPY(ospvIcnDigest, digest, ospvSizeOfIcnDigest);
} else {
errcode = OSPC_ERR_TRAN_NOT_ENOUGH_SPACE_FOR_COPY;
OSPM_DBGERRORLOG(errcode, "No enough buffer to copy RCD icn digest.");
}
}
} else {
errcode = OSPC_ERR_TRAN_REQ_OUT_OF_SEQ;
OSPM_DBGERRORLOG(errcode, "Called API Not In Sequence\n");
}
} else {
errcode = OSPC_ERR_TRAN_INVALID_ENTRY;
OSPM_DBGERRORLOG(errcode, "No information available to process this report.");
}
}

return errcode;
}
Loading

0 comments on commit 92a1f7a

Please sign in to comment.