예제 #1
0
파일: uac.c 프로젝트: AndreiPlesa/opensips
/*
 * Initialize UAC
 */
int uac_init(void)
{
	str src[3];
	struct socket_info *si;

	if (RAND_MAX < TM_TABLE_ENTRIES) {
		LM_WARN("uac does not spread across the whole hash table\n");
	}
	/* on tcp/tls bind_address is 0 so try to get the first address we listen
	 * on no matter the protocol */
	si=bind_address?bind_address:get_first_socket();
	if (si==0){
		LM_CRIT("null socket list\n");
		return -1;
	}

	/* calculate the initial From tag */
	src[0].s = "Long live SER server";
	src[0].len = strlen(src[0].s);
	src[1].s = si->address_str.s;
	src[1].len = strlen(src[1].s);
	src[2].s = si->port_no_str.s;
	src[2].len = strlen(src[2].s);

	MD5StringArray(from_tag, src, 3);
	from_tag[MD5_LEN] = '-';
	return 1;
}
예제 #2
0
static void gen_call_id_ftag(str *aor, str *now, str *call_id_ftag)
{
	int i = 0;
	str src[2];

	call_id_ftag->len = MD5_LEN;
	call_id_ftag->s = call_id_ftag_buf;

	src[i++] = *aor;
	if(now->s && now->len)
		src[i++] = *now;

	MD5StringArray(call_id_ftag->s, src, i);
	return;
}
예제 #3
0
static void generate_tag(str* tag, str* src, str* callid)
{
	int len;

	MD5StringArray(from_tag, src, 1);
	len = MD5_LEN;

	/* calculate from tag from callid */
	if(callid)
	{
		from_tag[len++] = '-';
		crcitt_string_array(&from_tag[MD5_LEN + 1], callid, 1);
		len+= CRC16_LEN;
	}
	tag->s = from_tag;
	tag->len = len;
	LM_DBG("from_tag = %.*s\n", tag->len, tag->s);
}