MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ospGetAVP

Function ospGetAVP

modules/osp/sipheader.c:112–134  ·  view source on GitHub ↗

* Get AVP value * param avpid AVP ID * param avptype AVP type * param avpstr AVP string * param bufsize AVP string buffer size * return 0 success, -1 failure */

Source from the content-addressed store, hash-verified

110 * return 0 success, -1 failure
111 */
112int ospGetAVP(
113 int avpid,
114 unsigned short avptype,
115 char* avpstr,
116 int bufsize)
117{
118 struct usr_avp* avp = NULL;
119 int_str avpval;
120 char tmp[OSP_STRBUF_SIZE];
121 int result = -1;
122
123 if ((avpid >= 0) &&
124 ((avp = search_first_avp(avptype, avpid, &avpval, 0)) != NULL) &&
125 (avp->flags & AVP_VAL_STR) && (avpval.s.s && avpval.s.len))
126 {
127 snprintf(tmp, sizeof(tmp), "%.*s", avpval.s.len, avpval.s.s);
128 destroy_avp(avp);
129 ospTrim(tmp, avpstr, bufsize);
130 result = 0;
131 }
132
133 return result;
134}
135
136/*
137 * Copy str to buffer and check overflow

Callers 2

ospRequestRoutingFunction · 0.85
ospGetSrcDevFunction · 0.85

Calls 3

search_first_avpFunction · 0.85
destroy_avpFunction · 0.85
ospTrimFunction · 0.85

Tested by

no test coverage detected