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

Function ospGetFromUser

modules/osp/sipheader.c:250–282  ·  view source on GitHub ↗

* Get user part from From header * param msg SIP message * param fromuser User part of From header * param bufsize Size of fromuser buffer * return 0 success, -1 failure */

Source from the content-addressed store, hash-verified

248 * return 0 success, -1 failure
249 */
250int ospGetFromUser(
251 struct sip_msg* msg,
252 char* fromuser,
253 int bufsize)
254{
255 struct to_body* from;
256 struct sip_uri uri;
257 int result = -1;
258
259 if ((fromuser != NULL) && (bufsize > 0)) {
260 fromuser[0] = '\0';
261 if (msg->from != NULL) {
262 if (parse_from_header(msg) == 0) {
263 from = get_from(msg);
264 if (parse_uri(from->uri.s, from->uri.len, &uri) == 0) {
265 ospCopyStrToBuffer(&uri.user, fromuser, bufsize);
266 ospSkipUserParam(fromuser);
267 result = 0;
268 } else {
269 LM_ERR("failed to parse From uri\n");
270 }
271 } else {
272 LM_ERR("failed to parse From header\n");
273 }
274 } else {
275 LM_ERR("failed to find From header\n");
276 }
277 } else {
278 LM_ERR("bad parameters to parse user part from From header\n");
279 }
280
281 return result;
282}
283
284/*
285 * Get From header

Callers 3

ospReportUsageFromCookieFunction · 0.85
ospValidateHeaderFunction · 0.85
ospRequestRoutingFunction · 0.85

Calls 4

parse_from_headerFunction · 0.85
parse_uriFunction · 0.85
ospCopyStrToBufferFunction · 0.85
ospSkipUserParamFunction · 0.85

Tested by

no test coverage detected