示例#1
0
/**
 * send a response 
 */
int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
{
	cw_init_response(conn, rawmsg);
	if (cw_put_msg(conn, conn->resp_buffer) == -1)
		return 0;
	conn_send_msg(conn, conn->resp_buffer);
	return 1;
}
示例#2
0
文件: send.c 项目: 7u83/actube
int cw_send_request(struct conn *conn,int msg_id)
{
	time_t timer;
	int i;
	int rc;
	char sock_buf[SOCK_ADDR_BUFSIZE];
	cw_init_request(conn, msg_id);
	if ( cw_put_msg(conn, conn->req_buffer) == -1 ){
		errno=ENOMSG;
		return -1;
	}
	conn_send_msg(conn, conn->req_buffer);

	

	rc=-1;
	for (i=0; i<conn->max_retransmit && rc<0; i++){
		if ( i>0 ){
			cw_log(LOG_WARNING,"Retransmitting request ... %d",i);
		}
		timer = cw_timer_start(conn->retransmit_interval);
		while (!cw_timer_timeout(timer) && rc<0){
	
        	        rc =cw_read_messages(conn);
			if(rc<0){
				if (errno!=EAGAIN)
					break;
			}

		}
		if (rc<0){
			if(errno!=EAGAIN)
				break;
			
		}

	}

	if ( rc <0 && errno != EAGAIN) {
		cw_log(LOG_ERR,"Can't read from %s: %s",sock_addr2str(&conn->addr,sock_buf),strerror(errno));
	}
	if ( rc <0 && errno == EAGAIN) {
		errno=ETIMEDOUT;
		rc=-1;
	}

	return rc;
}
示例#3
0
文件: discovery.c 项目: jhbsz/actube
static int run_discovery(struct conn *conn)
{
//      conn->incomming = mbag_create();


	conn->capwap_state = CW_STATE_DISCOVERY;
	mbag_set_byte(conn->outgoing, CW_ITEM_DISCOVERY_TYPE,
			      CW_DISCOVERY_TYPE_UNKNOWN);


	cw_init_request(conn, CW_MSG_DISCOVERY_REQUEST);
	cw_put_msg(conn, conn->req_buffer);
	conn_send_msg(conn, conn->req_buffer);


	time_t timer = cw_timer_start(0);


	while (!cw_timer_timeout(timer)
	       && conn->capwap_state == CW_STATE_DISCOVERY) {
		mavl_del_all(conn->incomming);

		int rc = cw_read_from(conn);

		if (rc<0) {
			if (errno==EAGAIN)
				continue;

			cw_log(LOG_ERROR,"Error reading messages: %s",strerror(errno));
			break;
		}
	}


	mbag_t discs;
	discs = mbag_get_mavl(conn->remote, CW_ITEM_DISCOVERIES);


	if (!discs) {
		cw_log(LOG_ERR,"No discovery responses received");
		return 0;
	}

	int i;

	cw_aciplist_t list = cw_select_ac(conn, discs);



	DEFINE_AVLITER(ii,list);
	avliter_foreach(&ii){
		cw_acip_t * ip = avliter_get(&ii);

	}

	

	mavl_del_all(conn->remote);

	mbag_set_mavl(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST,list);

	return 1;
}