本文整理汇总了C++中usrloc_api_t类的典型用法代码示例。如果您正苦于以下问题:C++ usrloc_api_t类的具体用法?C++ usrloc_api_t怎么用?C++ usrloc_api_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了usrloc_api_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_dlg_data_to_contact
void add_dlg_data_to_contact(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params) {
struct impu_data *impu_data;
impurecord_t* implicit_impurecord = 0;
struct ucontact* ucontact;
str callid = {0, 0};
str path = {0, 0};
LM_DBG("dialog [%p] confirmed, lets add dlg data to contact\n", dlg);
if(_params && _params->param){
impu_data = (struct impu_data*)*_params->param;
if (!impu_data) {
LM_ERR("IMPU data object is NULL...... aborting\n");
return;
}
LM_DBG("IMPU data is present, contact: <%.*s> identity <%.*s>", impu_data->contact.len, impu_data->contact.s, impu_data->identity.len, impu_data->identity.s);
LM_DBG("IMPU data domain <%.*s>", impu_data->d->name->len, impu_data->d->name->s);
ul.lock_udomain(impu_data->d, &impu_data->identity);
if (ul.get_impurecord(impu_data->d, &impu_data->identity, &implicit_impurecord) != 0) {
LM_DBG("usrloc does not have imprecord for implicity IMPU, ignore\n");
}else {
if (ul.get_ucontact(implicit_impurecord, &impu_data->contact, &callid, &path, 0/*cseq*/, &ucontact) != 0) { //contact does not exist
LM_DBG("This contact: <%.*s> is not in usrloc, ignore - NOTE: You need S-CSCF usrloc set to match_mode CONTACT_PORT_IP_ONLY\n", impu_data->contact.len, impu_data->contact.s);
} else {//contact exists so add dialog data to it
ul.add_dialog_data_to_contact(ucontact, dlg->h_entry, dlg->h_id);
}
}
ul.unlock_udomain(impu_data->d, &impu_data->identity);
}
}
示例2: lookup_transport
/*! \brief
* Lookup contact in the database and rewrite Request-URI
* \return: 1 : contacts found and returned
* -1 : not found
* -2 : error
*/
int lookup_transport(struct sip_msg* _m, udomain_t* _d, str* _uri) {
str uri;
pcontact_t* pcontact;
char tmp[MAX_URI_SIZE];
char srcip[20];
str received_host;
str tmp_s;
int ret = 1;
if (_m->new_uri.s) uri = _m->new_uri;
else uri = _m->first_line.u.request.uri;
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
received_host.s = srcip;
//now lookup in usrloc
ul.lock_udomain(_d, &uri, &received_host, _m->rcv.src_port);
if (ul.get_pcontact(_d, &uri, &received_host, _m->rcv.src_port, &pcontact) != 0) { //need to insert new contact
LM_WARN("received request for contact that we don't know about\n");
ret = -1;
goto done;
}
if (pcontact->received_proto != _m->rcv.proto) {
reset_dst_uri(_m);
memset(tmp, 0, MAX_URI_SIZE);
switch (pcontact->received_proto) {
case PROTO_TCP:
snprintf(tmp, MAX_URI_SIZE, "%.*s;transport=tcp", pcontact->aor.len, pcontact->aor.s);
break;
case PROTO_UDP:
snprintf(tmp, MAX_URI_SIZE, "%.*s;transport=udp", pcontact->aor.len, pcontact->aor.s);
break;
default:
LM_WARN("unsupported transport [%d]\n", pcontact->received_proto);
ret = -2;
goto done;
}
tmp_s.s = tmp;
tmp_s.len = strlen(tmp);
if (set_dst_uri(_m, &tmp_s) < 0) {
LM_ERR("failed to set dst_uri for terminating UE\n");
ret = -2;
goto done;
}
LM_DBG("Changed dst URI transport for UE to [%.*s]\n", tmp_s.len, tmp_s.s);
}
done:
ul.unlock_udomain(_d, &uri, &received_host, _m->rcv.src_port);
return ret;
}
示例3: sizeof
static void
natping(unsigned int ticks, void *param)
{
int rval;
void *buf, *cp;
str c;
struct dest_info dst;
buf = NULL;
if (cblen > 0) {
buf = pkg_malloc(cblen);
if (buf == NULL) {
LOG(L_ERR, "ERROR: nathelper::natping: out of memory\n");
return;
}
}
rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
if (rval > 0) {
if (buf != NULL)
pkg_free(buf);
cblen = rval * 2;
buf = pkg_malloc(cblen);
if (buf == NULL) {
LOG(L_ERR, "ERROR: nathelper::natping: out of memory\n");
return;
}
rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
if (rval != 0) {
pkg_free(buf);
return;
}
}
if (buf == NULL)
return;
cp = buf;
while (1) {
memcpy(&(c.len), cp, sizeof(c.len));
if (c.len == 0)
break;
c.s = (char *)cp + sizeof(c.len);
cp = (char *)cp + sizeof(c.len) + c.len;
init_dest_info(&dst);
memcpy(&dst.send_sock, cp, sizeof(dst.send_sock));
cp += sizeof(dst.send_sock);
natping_contact(c, &dst);
}
pkg_free(buf);
}
示例4: assert_identity
/**
* checked if passed identity is an asserted identity
*/
int assert_identity(struct sip_msg* _m, udomain_t* _d, str identity) {
// Public identities of this contact
struct ppublic * p;
//remove <> braces if there are
if(identity.s[0]=='<' && identity.s[identity.len-1]=='>') {
identity.s++;
identity.len -= 2;
}
LM_DBG("Identity to assert: %.*s\n", identity.len, identity.s);
if (getContactP(_m, _d, PCONTACT_REGISTERED|PCONTACT_REG_PENDING_AAR|PCONTACT_REG_PENDING, 0, 0) != NULL) {
for (p = c->head; p; p = p->next) {
LM_DBG("Public identity: %.*s\n", p->public_identity.len, p->public_identity.s);
/* Check length: */
if (identity.len == p->public_identity.len) {
/* Check contents: */
if (strncasecmp(identity.s, p->public_identity.s, identity.len) == 0) {
LM_DBG("Match!\n");
return 1;
}
} else LM_DBG("Length does not match.\n");
}
}
LM_INFO("Contact not found based on Contact, trying IP/Port/Proto\n");
str received_host = {0, 0};
char srcip[50];
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
received_host.s = srcip;
if (ul.assert_identity(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &identity) == 0)
return -1;
else
return 1;
}
示例5: getContactP
/**
* get PContact-Structure for message
* (search only once per Request)
*/
pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
ppublic_t * p;
str received_host = {0, 0};
char srcip[50];
if (_m->id != current_msg_id) {
current_msg_id = _m->id;
c = NULL;
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
received_host.s = srcip;
if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1)
LM_WARN("No entry in usrloc for %.*s:%i (Proto %i) found!\n", received_host.len, received_host.s, _m->rcv.src_port, _m->rcv.proto);
}
asserted_identity = NULL;
if (c) {
p = c->head;
while (p) {
if (p->is_default == 1)
asserted_identity = &p->public_identity;
p = p->next;
}
}
return c;
}
示例6:
pcontact_t * getContactP_from_via(struct sip_msg* _m, udomain_t* _d) {
ppublic_t * p;
struct via_body *vb;
vb = cscf_get_ue_via(_m);
if (!vb) {
LM_WARN("no via header.....strange!\n");
return NULL;
}
if (vb->port == 0)
vb->port = 5060;
if (_m->id != current_msg_id) {
current_msg_id = _m->id;
c = NULL;
LM_DBG("Looking for <%d://%.*s:%d>\n", vb->proto, vb->host.len, vb->host.s, vb->port);
if (ul.get_pcontact_by_src(_d, &vb->host, vb->port, vb->proto, &c) == 1)
LM_WARN("No entry in usrloc for %.*s:%i (Proto %i) found!\n", vb->host.len, vb->host.s, vb->port, vb->proto);
}
asserted_identity = NULL;
if (c) {
p = c->head;
while (p) {
if (p->is_default == 1)
asserted_identity = &p->public_identity;
p = p->next;
}
}
return c;
}
示例7: pcscf_unregister
int pcscf_unregister(udomain_t* _d, str * uri, str * received_host, int received_port) {
int result = -1;
struct pcontact * pcontact;
struct pcontact_info ci;
memset(&ci, 0, sizeof (struct pcontact_info));
pcontact_info_t search_ci;
memset(&ci, 0, sizeof(struct pcontact_info));
sip_uri_t contact_uri;
if (parse_uri(uri->s, uri->len, &contact_uri) != 0) {
LM_WARN("Failed to parse aor [%.*s]\n", uri->len, uri->s);
return -1;
}
search_ci.received_host.s = received_host->s;
search_ci.received_host.len = received_host->len;
search_ci.received_port = received_port;
search_ci.received_proto = contact_uri.proto? contact_uri.proto : PROTO_UDP;
search_ci.searchflag = SEARCH_RECEIVED;
search_ci.via_host.s = received_host->s;
search_ci.via_host.len = received_host->len;
search_ci.via_port = received_port;
search_ci.via_prot = search_ci.received_proto;
search_ci.aor.s = uri->s;
search_ci.aor.len = uri->len;
search_ci.reg_state = PCONTACT_ANY;
if (ul.get_pcontact(_d, &search_ci, &pcontact) == 0) {
/* Lock this record while working with the data: */
ul.lock_udomain(_d, &pcontact->via_host, pcontact->via_port, pcontact->via_proto);
LM_DBG("Updating contact [%.*s]: setting state to PCONTACT_DEREG_PENDING_PUBLISH\n", pcontact->aor.len, pcontact->aor.s);
ci.reg_state = PCONTACT_DEREG_PENDING_PUBLISH;
ci.num_service_routes = 0;
if (ul.update_pcontact(_d, &ci, pcontact) == 0) result = 1;
/* Unlock domain */
ul.unlock_udomain(_d, &pcontact->via_host, pcontact->via_port, pcontact->via_proto);
}
return result;
}
示例8: domain_fixup
/* PSEUDOCODE/NOTES
* 1. What mode are we in - terminating or originating
* 2. check request type - IEC - Immediate Event Charging
* ECUR - Event Charging with Unit Reservation
* SCUR - Session Charging with Unit Reservation
* 3. probably only do SCUR in this module for now - can see event based charging in another component instead (AS for SMS for example, etc)
* 4. Check a dialog exists for call, if not we fail
* 5. make sure we dont already have an Ro Session for this dialog
* 6. create new Ro Session
* 7. register for DLG callback passing new Ro session as parameter - (if dlg torn down we know which Ro session it is associated with)
*
*
*/
int ret = RO_RETURN_TRUE;
int dir = 0;
str identity = {0, 0},
contact = {0, 0};
struct hdr_field *h=0;
cfg_action_t* cfg_action;
tm_cell_t *t;
unsigned int tindex = 0,
tlabel = 0;
struct impu_data *impu_data;
udomain_t* domain_t = (udomain_t*) _d;
char *p;
struct dlg_cell* dlg;
unsigned int len;
struct ro_session *ro_session = 0;
int free_contact = 0;
LM_DBG("Ro CCR initiated: direction:%.*s, charge_type:%.*s, unit_type:%.*s, reservation_units:%i, route_name:%.*s",
direction->len, direction->s,
charge_type->len, charge_type->s,
unit_type->len, unit_type->s,
reservation_units,
route_name->len, route_name->s);
if (msg->first_line.type != SIP_REQUEST) {
LM_ERR("Ro_CCR() called from SIP reply.");
return RO_RETURN_ERROR;;
}
//make sure we can get the dialog! if not, we can't continue
dlg = dlgb.get_dlg(msg);
if (!dlg) {
LM_ERR("Unable to find dialog and cannot do Ro charging without it\n");
return RO_RETURN_ERROR;
}
dir = get_direction_as_int(direction);
if (dir == RO_ORIG_DIRECTION) {
//get caller IMPU from asserted identity
if ((identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
identity = dlg->from_uri;
}
//get caller contact from contact header - if not present then skip this
if ((contact = cscf_get_contact(msg)).len == 0) {
LM_WARN("Can not get contact from message - will not get callbacks if this IMPU is removed to terminate call");
goto send_ccr;
}
} else if (dir == RO_TERM_DIRECTION){
//get callee IMPU from called part id - if not present then skip this
if ((identity = cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) {
LM_WARN("No P-Called-Identity hdr found - will not get callbacks if this IMPU is removed to terminate call");
goto send_ccr;
}
//get callee contact from request URI
contact = cscf_get_contact_from_requri(msg);
free_contact = 1;
} else {
LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
ret = RO_RETURN_ERROR;
goto done;
}
LM_DBG("IMPU data to pass to usrloc: contact <%.*s> identity <%.*s>\n", contact.len, contact.s, identity.len, identity.s);
//create impu_data_parcel
len = identity.len + contact.len + sizeof (struct impu_data);
impu_data = (struct impu_data*) shm_malloc(len);
if (!impu_data) {
LM_ERR("Unable to allocate memory for impu_data, trying to send CCR\n");
ret = RO_RETURN_ERROR;
goto done;
}
memset(impu_data, 0, len);
p = (char*) (impu_data + 1);
impu_data->identity.s = p;
impu_data->identity.len = identity.len;
memcpy(p, identity.s, identity.len);
p += identity.len;
impu_data->contact.s = p;
//.........这里部分代码省略.........
示例9: assert_identity
/**
* Add proper asserted identies based on registration
*/
int assert_identity(struct sip_msg* _m, udomain_t* _d, str identity) {
str received_host = {0, 0};
char srcip[50];
received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
received_host.s = srcip;
if (ul.assert_identity(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &identity) == 0)
return -1;
else
return 1;
}
示例10: domain_fixup
/*! \brief
* Convert char* parameter to udomain_t* pointer
*/
static int domain_fixup(void** param, int param_no) {
udomain_t* d;
if (param_no == 2) {
if (isc_ulb.register_udomain((char*) *param, &d) < 0) {
LM_ERR("failed to register domain\n");
return E_UNSPEC;
}
*param = (void*) d;
}
return 0;
}
示例11: unregister
int unregister(udomain_t* _d, str * uri, str * received_host, int received_port) {
int result = -1;
struct pcontact * pcontact;
struct pcontact_info ci;
memset(&ci, 0, sizeof (struct pcontact_info));
if (ul.get_pcontact(_d, uri, received_host, received_port, &pcontact) == 0) {
/* Lock this record while working with the data: */
ul.lock_udomain(_d, &pcontact->aor, received_host, received_port);
LM_DBG("Updating contact [%.*s]: setting state to PCONTACT_DEREG_PENDING_PUBLISH\n", pcontact->aor.len, pcontact->aor.s);
ci.reg_state = PCONTACT_DEREG_PENDING_PUBLISH;
ci.num_service_routes = 0;
if (ul.update_pcontact(_d, &ci, pcontact) == 0) result = 1;
// if (ul.delete_pcontact(_d, &pc->aor, received_host, received_port, pcontact) == 0) result = 1;
/* Unlock domain */
ul.unlock_udomain(_d, &pcontact->aor, received_host, received_port);
}
return result;
}
示例12: domain_fixup
/*
* Convert char* parameter to udomain_t* pointer
*/
static int domain_fixup(void** param, int param_no)
{
udomain_t* d;
if (param_no == 1) {
if (ul.register_udomain((char*)*param, &d) < 0) {
LOG(L_ERR, "domain_fixup(): Error while registering domain\n");
return E_UNSPEC;
}
*param = (void*)d;
}
return 0;
}
示例13: assert_identity
/**
* Add proper asserted identies based on registration
*/
int assert_identity(struct sip_msg* _m, udomain_t* _d, str identity) {
// Get the contact:
pcontact_t * c = getContactP(_m, _d);
// Public identities of this contact
ppublic_t * p;
// Contact not found => Identity not asserted.
if (c == NULL) return -2;
/* Lock this record while working with the data: */
ul.lock_udomain(_d, &c->aor);
LM_DBG("Checking identity: %.*s\n", identity.len, identity.s);
LM_DBG("AOR of contact: %.*s\n", c->aor.len, c->aor.s);
for (p = c->head; p; p = p->next) {
LM_DBG("Public identity: %.*s\n", p->public_identity.len, p->public_identity.s);
/* Check length: */
if (identity.len == p->public_identity.len) {
/* Check contents: */
if (strncasecmp(identity.s, p->public_identity.s, identity.len) != 0) {
LM_DBG("Match!\n");
goto success;
}
} else LM_DBG("Length does not match.\n");
}
// We should only get here, if we failed:
/* Unlock domain */
ul.unlock_udomain(_d, &c->aor);
return -1;
success:
/* Unlock domain */
ul.unlock_udomain(_d, &c->aor);
return 1;
}
示例14: fixup_aar_register
static int fixup_aar_register(void** param, int param_no) {
// udomain_t* d;
// aar_param_t *ap;
//
// if (param_no != 1)
// return 0;
// ap = (aar_param_t*) pkg_malloc(sizeof (aar_param_t));
// if (ap == NULL) {
// LM_ERR("no more pkg\n");
// return -1;
// }
// memset(ap, 0, sizeof (aar_param_t));
// ap->paction = get_action_from_param(param, param_no);
//
// if (ul.register_udomain((char*) *param, &d) < 0) {
// LM_ERR("failed to register domain\n");
// return E_UNSPEC;
// }
// ap->domain = d;
//
// *param = (void*) ap;
// return 0;
if (strlen((char*) *param) <= 0) {
LM_ERR("empty parameter %d not allowed\n", param_no);
return -1;
}
if (param_no == 1) { //route name - static or dynamic string (config vars)
if (fixup_spve_null(param, param_no) < 0)
return -1;
return 0;
} else if (param_no == 2) {
udomain_t* d;
if (ul.register_udomain((char*) *param, &d) < 0) {
LM_ERR("Error doing fixup on assign save");
return -1;
}
*param = (void*) d;
}
return 0;
}
示例15: remove_dlg_data_from_contact
void remove_dlg_data_from_contact(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params) {
struct impu_data *impu_data;
impurecord_t* implicit_impurecord = 0;
struct ucontact* ucontact;
str callid = {0, 0};
str path = {0, 0};
udomain_t* domain_t;
LM_DBG("dialog [%p] terminated, lets remove dlg data from contact\n", dlg);
if (ul.register_udomain(domain, &domain_t) < 0) {
LM_ERR("Unable to register usrloc domain....aborting\n");
return;
}
if(_params && _params->param){
impu_data = (struct impu_data*)*_params->param;
if (!impu_data) {
LM_ERR("IMPU data object is NULL...... aborting\n");
return;
}
LM_DBG("IMPU data is present, contact: <%.*s> identity <%.*s>", impu_data->contact.len, impu_data->contact.s, impu_data->identity.len, impu_data->identity.s);
LM_DBG("IMPU data domain <%.*s>", domain_t->name->len, domain_t->name->s);
ul.lock_udomain(domain_t, &impu_data->identity);
if (ul.get_impurecord(domain_t, &impu_data->identity, &implicit_impurecord) != 0) {
LM_DBG("usrloc does not have imprecord for implicity IMPU, ignore\n");
}else {
if (ul.get_ucontact(&impu_data->contact, &callid, &path, 0/*cseq*/, &ucontact) != 0) { //contact does not exist
LM_DBG("This contact: <%.*s> is not in usrloc, ignore - NOTE: You need S-CSCF usrloc set to match_mode CONTACT_PORT_IP_ONLY\n", impu_data->contact.len, impu_data->contact.s);
} else {//contact exists so add dialog data to it
ul.remove_dialog_data_from_contact(ucontact, dlg->h_entry, dlg->h_id);
ul.release_ucontact(ucontact);
}
}
ul.unlock_udomain(domain_t, &impu_data->identity);
free_impu_data(impu_data);
}
//we referenced the dialog when we registered for callbacks on it...
dlgb.release_dlg(dlg);
}