Ejemplo n.º 1
0
int osip_via_clone(CVia* via, CVia** dest)
{
	int i;
	CVia* vi;
	
	*dest = NULL;
	if (via == NULL)
		return -1;
	if (via->m_pcVersion == NULL)
		return -1;
	if (via->m_pcProtocol == NULL)
		return -1;
	if (via->m_pcHost == NULL)
		return -1;
	
	vi = new CVia();
	if (vi == NULL)
		return -1;
	vi->m_pcVersion = zstr_strdup(via->m_pcVersion);
	vi->m_pcProtocol = zstr_strdup(via->m_pcProtocol);
	vi->m_pcHost = zstr_strdup(via->m_pcHost);
	if (via->m_pcPort != NULL)
		vi->m_pcPort = zstr_strdup(via->m_pcPort);
	if (via->m_pcComment != NULL)
		vi->m_pcComment = zstr_strdup(via->m_pcComment);

	i = via->m_listVia_params.Clone(&vi->m_listVia_params,(int * (*) (void *, void *)) & osip_generic_param_clone);
	if (i != 0)
	{
		delete (vi);
		return -1;
	}
	*dest = vi;
	return 0;
}
Ejemplo n.º 2
0
int osip_from_clone(CFrom* from, CFrom** dest)
{
	int i;
	CFrom* fr;
	
	*dest = NULL;
	if (from == NULL)
		return -1;
	
	fr = new CFrom();
	if (fr == NULL) 				  /* allocation failed */
		return -1;
	if (from->displayname != NULL)
		fr->displayname = zstr_strdup(from->displayname);
	
	if (from->url != NULL)
	{
		i = from->url->Clone(&(fr->url));
		if (i != 0)
		{
			delete (fr);
			return -1;
		}
	}
	
	i = from->gen_params.Clone(&(fr->gen_params),(int * (*) (void *, void *)) & osip_generic_param_clone);
	if (i != 0)
	{
		delete (fr);
		return -1;
	}
	*dest = fr;
	return 0;
}
Ejemplo n.º 3
0
int CCallId::Clone( CCallId** dest )
{
	CCallId* ci;
	
	*dest = NULL;

	if (this->number == NULL)
		return -1;
	
	ci = new CCallId;
	if (ci == NULL)				  /* allocation failed */
		return -1;
	ci->number = zstr_strdup(this->number);
	if (this->host != NULL)
		ci->host = zstr_strdup(this->host);
	
	*dest = ci;
	return 0;	
}
Ejemplo n.º 4
0
int CFrom::Clone( CFrom** dest )
{
	int i;
	CFrom* fr;
	
	*dest = NULL;
	
	fr = new CFrom;
	if (fr == NULL)
	{
		return -1;
	}

	if (this->displayname != NULL)
		fr->displayname = zstr_strdup(this->displayname);
	
	if (this->url != NULL)
	{
		i = this->url->Clone(&(fr->url));
		if (i != 0)
		{
			delete(fr);
			fr = NULL;
			return -1;
		}
	}
	
	i = this->gen_params.Clone(&fr->gen_params,(int * (*) (void *, void *)) & osip_generic_param_clone);
	if (i != 0)
	{
		delete(fr);
		fr = NULL;
		return -1;
	}
	*dest = fr;
	return 0;
}
Ejemplo n.º 5
0
int zmap_open_mysql(ZMAP * zm, ZDICT * args)
{
	ZMAP_MYSQL *db;
	char *path, *host, *p;
	int port;
	int ret = Z_OK;

	db = zcalloc(1, sizeof(ZMAP_MYSQL));
	path = zdict_get_str(args, "main_arg", "");
	path = zstr_strdup(path);
	port = 0;
	p = strchr(path, ':');
	host = path;
	if (p) {
		*p++ = 0;
		port = atoi(p);
	} else {
		port = 3306;
	}
	db->host = zstr_strdup(host);
	db->port = port;
	db->qb = zbuf_create(1024);
	db->query_expand = zbuf_create(128);
	db->query_format = zstr_strdup(zdict_get_str(args, "query", "%s"));
	db->dbname = zstr_strdup(zdict_get_str(args, "dbname", ""));
	db->dbuser = zstr_strdup(zdict_get_str(args, "user", "root"));
	db->dbpass = zstr_strdup(zdict_get_str(args, "pass", ""));

	zm->db = db;
	zm->query = _query;
	zm->query2 = _query2;
	zm->close = _close;

	zstr_free(path);

	return ret;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int CIctTransaction::CIct::Init(CSipMessage* invite)
{
	CRoute* route;
	int i;
	time_t now;

	now = time(NULL);
	/* for INVITE retransmissions */
	{
		CVia* via;
		char* proto;

		i = invite->GetVia(0,&via); /* get top via */
		if (i != 0 || via == NULL)
		{
			return -1;
		}
		proto = via->m_pcProtocol;
		if (proto == NULL)
		{
			return -1;
		}

		if (zstr_strcasecmp(proto, "TCP") != 0 && zstr_strcasecmp(proto, "TLS") != 0 &&	zstr_strcasecmp(proto,"SCTP") != 0)
		{
			/* for other reliable protocol than TCP, the timer
					   must be desactived by the external application */
			if (64 * DEFAULT_T1 < 32000)
				m_TimerD.SetTimer(32000,false);
			else
				m_TimerD.SetTimer(64 * DEFAULT_T1,false);

			m_TimerA.SetTimer(DEFAULT_T1,true);
		}
		else
		{
			/* reliable protocol is used: */
			m_TimerA.ReSetTimer();
			m_TimerD.ReSetTimer();
		}
	}

	/* for PROXY, the destination MUST be set by the application layer,
	   this one may not be correct. */
	invite->GetRoute(0,&route);
	if (route != NULL && route->url != NULL)
	{
		CUrlParam* lr_param;

		osip_uri_uparam_get_byname(route->url, "lr", &lr_param);
		if (lr_param == NULL)
		{
			/* using uncompliant proxy: destination is the request-uri */
			route = NULL;
		}
	}

	if (route != NULL)
	{
		int port = 5060;

		if (route->url->port != NULL)
			port = zstr_atoi(route->url->port);
		this->SetDestination(zstr_strdup(route->url->host), port);
	}
	else
	{
		int port = 5060;
		/* search for maddr parameter */
		CUrlParam* maddr_param = NULL;

		port = 5060;
		if (invite->m_pRequestUrl->port != NULL)
		{
			port = zstr_atoi(invite->m_pRequestUrl->port);
		}

		osip_uri_uparam_get_byname(invite->m_pRequestUrl, "maddr", &maddr_param);
		if (maddr_param != NULL && maddr_param->gvalue != NULL)
		{
			this->SetDestination(zstr_strdup(maddr_param->gvalue),port);
		}
		else
		{
			this->SetDestination(zstr_strdup(invite->m_pRequestUrl->host), port);
		}
	}
	
	m_TimerB.SetTimer(64 * DEFAULT_T1,true);
	/* Oups! A bug! */
	/*  ict_context->port  = 5060; */

	return 0;
}
int osip_authorization_clone(const CAuthorization* auth,
	CAuthorization** dest)
{
	CAuthorization* au;

	*dest = NULL;
	if (auth == NULL)
		return -1;
	/* to be removed?
	   if (auth->auth_type==NULL) return -1;
	   if (auth->username==NULL) return -1;
	   if (auth->realm==NULL) return -1;
	   if (auth->nonce==NULL) return -1;
	   if (auth->uri==NULL) return -1;
	   if (auth->response==NULL) return -1;
	   if (auth->opaque==NULL) return -1;
	 */

	au = new CAuthorization();
	if (au == NULL)				  /* allocation failed */
		return -1;
	if (auth->auth_type != NULL)
	{
		au->auth_type = zstr_strdup(auth->auth_type);
		if (au->auth_type == NULL)
			goto ac_error;
	}
	if (auth->username != NULL)
	{
		au->username = zstr_strdup(auth->username);
		if (au->username == NULL)
			goto ac_error;
	}
	if (auth->realm != NULL)
	{
		au->realm = zstr_strdup(auth->realm);
		if (auth->realm == NULL)
			goto ac_error;
	}
	if (auth->nonce != NULL)
	{
		au->nonce = zstr_strdup(auth->nonce);
		if (auth->nonce == NULL)
			goto ac_error;
	}
	if (auth->uri != NULL)
	{
		au->uri = zstr_strdup(auth->uri);
		if (au->uri == NULL)
			goto ac_error;
	}
	if (auth->response != NULL)
	{
		au->response = zstr_strdup(auth->response);
		if (auth->response == NULL)
			goto ac_error;
	}
	if (auth->digest != NULL)
	{
		au->digest = zstr_strdup(auth->digest);
		if (au->digest == NULL)
			goto ac_error;
	}
	if (auth->algorithm != NULL)
	{
		au->algorithm = zstr_strdup(auth->algorithm);
		if (auth->algorithm == NULL)
			goto ac_error;
	}
	if (auth->cnonce != NULL)
	{
		au->cnonce = zstr_strdup(auth->cnonce);
		if (au->cnonce == NULL)
			goto ac_error;
	}
	if (auth->opaque != NULL)
	{
		au->opaque = zstr_strdup(auth->opaque);
		if (auth->opaque == NULL)
			goto ac_error;
	}
	if (auth->message_qop != NULL)
	{
		au->message_qop = zstr_strdup(auth->message_qop);
		if (auth->message_qop == NULL)
			goto ac_error;
	}
	if (auth->nonce_count != NULL)
	{
		au->nonce_count = zstr_strdup(auth->nonce_count);
		if (auth->nonce_count == NULL)
			goto ac_error;
	}

	*dest = au;
	return 0;

	ac_error : delete(au);
	return -1;
}