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

Function ospGetRouteParam

modules/osp/sipheader.c:1255–1301  ·  view source on GitHub ↗

* Get route parameters from the 1st Route or Request-Line * param msg SIP message * param routeparameters Route parameters * param bufsize Size of routeparameters * return 0 success, -1 failure */

Source from the content-addressed store, hash-verified

1253 * return 0 success, -1 failure
1254 */
1255int ospGetRouteParam(
1256 struct sip_msg* msg,
1257 char* routeparameters,
1258 int bufsize)
1259{
1260 struct hdr_field* hf;
1261 rr_t* rt;
1262 struct sip_uri uri;
1263 int result = -1;
1264
1265 if ((routeparameters != NULL) && (bufsize > 0)) {
1266 LM_DBG("parsed uri host '%.*s' port '%d' vars '%.*s'\n",
1267 msg->parsed_uri.host.len,
1268 msg->parsed_uri.host.s,
1269 msg->parsed_uri.port_no,
1270 msg->parsed_uri.params.len,
1271 msg->parsed_uri.params.s);
1272
1273 if (!(hf = msg->route)) {
1274 LM_DBG("there is no Route headers\n");
1275 } else if (!(rt = (rr_t*)hf->parsed)) {
1276 LM_ERR("route headers are not parsed\n");
1277 } else if (parse_uri(rt->nameaddr.uri.s, rt->nameaddr.uri.len, &uri) != 0) {
1278 LM_ERR("failed to parse the Route uri '%.*s'\n", rt->nameaddr.uri.len, rt->nameaddr.uri.s);
1279 } else if (check_self(&uri.host, uri.port_no ? uri.port_no : SIP_PORT, PROTO_NONE) != 1) {
1280 LM_DBG("the Route uri is NOT mine\n");
1281 LM_DBG("host '%.*s' port '%d'\n", uri.host.len, uri.host.s, uri.port_no);
1282 LM_DBG("params '%.*s'\n", uri.params.len, uri.params.s);
1283 } else {
1284 LM_DBG("the Route uri IS mine - '%.*s'\n", uri.params.len, uri.params.s);
1285 LM_DBG("host '%.*s' port '%d'\n", uri.host.len, uri.host.s, uri.port_no);
1286 ospCopyStrToBuffer(&uri.params, routeparameters, bufsize);
1287 result = 0;
1288 }
1289
1290 if ((result == -1) && (msg->parsed_uri.params.len > 0)) {
1291 LM_DBG("using route parameters from Request-Line uri\n");
1292 ospCopyStrToBuffer(&msg->parsed_uri.params, routeparameters, bufsize);
1293 routeparameters[msg->parsed_uri.params.len] = '\0';
1294 result = 0;
1295 }
1296 } else {
1297 LM_ERR("bad parameters to parse parameters from Route header\n");
1298 }
1299
1300 return result;
1301}
1302
1303/*
1304 * Rebuild URI

Callers 1

ospReportUsageFunction · 0.85

Calls 3

parse_uriFunction · 0.85
check_selfFunction · 0.85
ospCopyStrToBufferFunction · 0.85

Tested by

no test coverage detected