Пример #1
0
static void queue_message(belle_sip_channel_t *obj, belle_sip_message_t *msg){
	belle_sip_object_ref(msg);
	channel_push_outgoing(obj,msg);
	if (obj->state==BELLE_SIP_CHANNEL_INIT){
		belle_sip_channel_prepare(obj);
	}else if (obj->state==BELLE_SIP_CHANNEL_READY) {
		channel_process_queue(obj);
	}
}
Пример #2
0
int belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revents){
	int ret=BELLE_SIP_CONTINUE;
	if (revents & BELLE_SIP_EVENT_READ) {
		int rret=belle_sip_channel_process_read_data(obj);
		if (rret==BELLE_SIP_STOP) ret=BELLE_SIP_STOP;
	}
	if (revents & BELLE_SIP_EVENT_WRITE){
		/*if we are here, this is because we had an EWOULDBLOCK while sending a message*/
		channel_process_queue(obj);
	}
	return ret;
}
Пример #3
0
int belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revents){
	int ret=BELLE_SIP_CONTINUE;
	if (revents & BELLE_SIP_EVENT_READ) {
		int rret=belle_sip_channel_process_read_data(obj);
		if (rret==BELLE_SIP_STOP) ret=BELLE_SIP_STOP;
	}
	if (revents & BELLE_SIP_EVENT_WRITE){
		/*if we are here, this is because we had an EWOULDBLOCK while sending a message*/
		/*continue to send pending messages but before check the channel is still alive because it may have been closed by belle_sip_channel_process_read_data() above.*/
		if (obj->state == BELLE_SIP_CHANNEL_READY){
			channel_process_queue(obj);
		}
	}
	return ret;
}
Пример #4
0
static void channel_prepare_continue(belle_sip_channel_t *obj){
	switch(obj->state){
		case BELLE_SIP_CHANNEL_INIT:
			channel_begin_send_background_task(obj);
			belle_sip_channel_resolve(obj);
		break;
		case BELLE_SIP_CHANNEL_RES_DONE:
			belle_sip_channel_connect(obj);
		break;
		case BELLE_SIP_CHANNEL_READY:
			channel_process_queue(obj);
		break;
		default:
		break;
	}
}
Пример #5
0
void belle_sip_channel_set_ready(belle_sip_channel_t *obj, const struct sockaddr *addr, socklen_t slen){
	char name[NI_MAXHOST];
	char serv[NI_MAXSERV];

	if (obj->local_ip==NULL){
		struct sockaddr_storage saddr;
		socklen_t slen2=sizeof(saddr);
		int err;
		
		belle_sip_address_remove_v4_mapping(addr,(struct sockaddr*) &saddr,&slen2);
		
		err=getnameinfo((struct sockaddr*)&saddr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
		if (err!=0){
			belle_sip_error("belle_sip_channel_set_ready(): getnameinfo() failed: %s",gai_strerror(err));
		}else{
			obj->local_ip=belle_sip_strdup(name);
			obj->local_port=atoi(serv);
			belle_sip_message("Channel has local address %s:%s",name,serv);
		}
	}
	channel_set_state(obj,BELLE_SIP_CHANNEL_READY);
	channel_process_queue(obj);
	channel_end_send_background_task(obj);
}