Пример #1
0
/**
 * Creates and Adds a new r_contact 
 * \note When calling be sure that get_r_contact(p,uri) returns 0, to avoid unreachable duplicates.
 * @param p - the r_public to add to
 * @param uri - the uri of the contact
 * @param expires - the expiration time
 * @param ua - the user agent string
 * @param path - Path header received at registration
 * @returns the newly added r_contact or NULL on error
 */
r_contact* add_r_contact(r_public *p,str uri,int expires,str ua,str path)
{
	r_contact *c;
	if (!p) return 0;
	c = new_r_contact(uri,expires,ua,path);
	if (!c) return 0;
	c->next=0;
	c->prev=p->tail;
	if (p->tail) {
		p->tail->next = c;
		p->tail = c;
	}
	else p->tail = c;
	if (!p->head) p->head=c;
	
	return c;
}
Пример #2
0
/**
 * Creates and Adds a new r_contact 
 * \note Aquires the lock on the hash_slot on success, so release it when you are done.
 * \note When calling be sure that get_r_contact(...) returns 0, to avoid unreachable duplicates
 * @param host - the host part of the contact, in string
 * @param port - the port number of the contact
 * @param transport - the transport of the contact
 * @param uri - URI of the contact
 * @param reg_state - Registration state
 * @param expires - expires in
 * @param service_route - array of service routes
 * @param service_route_cnt - the size of the array above
 * @param pinhole - NAT pin hole
 * @param sos_flag - type of registration: Emergency or Normal
 * @returns the newly added r_contact, 0 on error
 */
r_contact* add_r_contact(str host,int port,int transport,str uri,
	enum Reg_States reg_state,int expires,str *service_route,int service_route_cnt, r_nat_dest *pinhole, r_reg_type sos_flag)
{
	r_contact *c;

	if (!registrar) return 0;
	c = new_r_contact(host,port,transport,uri,reg_state, expires, service_route, service_route_cnt, sos_flag);
	if (!c) return 0;
	c->next=0;
	r_lock(c->hash);
		c->prev=registrar[c->hash].tail;
		if (c->prev) c->prev->next = c;
		registrar[c->hash].tail = c;
		if (!registrar[c->hash].head) registrar[c->hash].head=c;
		c->pinhole = pinhole;
		c->sos_flag = sos_flag;
	return c;
}
Пример #3
0
/**
 * Creates and Adds a new r_contact 
 * \note When calling be sure that get_r_contact(p,uri) returns 0, to avoid unreachable duplicates.
 * @param p - the r_public to add to
 * @param uri - the uri of the contact
 * @param expires - the expiration time
 * @param ua - the user agent string
 * @param path - Path header received at registration
 * @returns the newly added r_contact or NULL on error
 */
r_contact* add_r_contact(struct sip_msg* msg, r_public *p,str uri,int expires,str ua,str path)
{
	r_contact *c;
	if (!p) return 0;
	
	c = new_r_contact(uri,expires,ua,path);
	if (!c) return 0;

	create_user_pref(msg, c) ;

	c->next=0;
	c->prev=p->tail;
	if (p->tail) {
		p->tail->next = c;
		p->tail = c;
	}
	else p->tail = c;
	if (!p->head) p->head=c;
	
	return c;
}