static int get_direction(struct sip_msg* msg)
{
	int ret;
	if (parse_orig_ruri(msg) < 0) {
		return -1;
	}

	if (!msg->parsed_orig_ruri_ok) {
		ERR("Error while parsing original Request-URI\n");
		return -1;
	}

	ret = check_self(&msg->parsed_orig_ruri.host,
			 msg->parsed_orig_ruri.port_no ? msg->parsed_orig_ruri.port_no : SIP_PORT, 0);/* match all protos*/
	if (ret < 0) return -1;
	if (ret > 0) {
		     /* Route is in ruri */
		return check_ftag(msg, &msg->first_line.u.request.uri);
	} else {
		if (msg->route) {
			if (parse_rr(msg->route) < 0) {
				ERR("Error while parsing Route HF\n");
				return -1;
			}
		        ret = check_ftag(msg, &((rr_t*)msg->route->parsed)->nameaddr.uri);
			if (msg->route->parsed) free_rr((rr_t**)(void*)&msg->route->parsed);
			return ret;
		} else {
			DBG("No Route headers found\n");
			return -1;
		}
	}
}
static inline void acc_preparse_req(struct sip_msg *rq)
{
	/* try to parse from for From-tag for accounted transactions; 
	 * don't be worried about parsing outcome -- if it failed, 
	 * we will report N/A
	 */
	parse_headers(rq, HDR_CALLID| HDR_FROM| HDR_TO, 0 );
	parse_from_header(rq);
	parse_orig_ruri(rq);
}
Beispiel #3
0
/** 
 * Delivers the Realm from request URI
 * @param msg sip message 
 * @returns realm as String on success 0 on fail
 */
str cscf_get_realm_from_ruri(struct sip_msg *msg)
{
	str realm={0,0};
	if (!msg || msg->first_line.type!=SIP_REQUEST){
		LM_DBG("cscf_get_realm_from_ruri: This is not a request!!!\n");
		return realm;
	}
	if (!msg->parsed_orig_ruri_ok)
		if (parse_orig_ruri(msg) < 0) 
			return realm;

	realm = msg->parsed_orig_ruri.host;
	return realm;	
}