int run() { struct conn *conn = get_conn(); conn->capwap_state = CW_STATE_RUN; do { int echo_interval = mbag_get_word(conn->config,CW_ITEM_CAPWAP_TIMERS,CAPWAP_TIMERS)&0xff; time_t timer = cw_timer_start(echo_interval); int rc; while (!cw_timer_timeout(timer) && conn->capwap_state == CW_STATE_RUN) { rc = cw_read_messages(conn); if (rc < 0 && errno == EAGAIN) { continue; } if ( !cw_rcok(rc)) break; } if (rc<0 && errno == EAGAIN){ rc = cw_send_request(conn,CW_MSG_ECHO_REQUEST); if (!cw_rcok(rc)) { cw_log(LOG_ERR,"Error in run state: %d %s",rc,cw_strrc(rc)); break; } continue; } if (!cw_rcok(rc)) { cw_log(LOG_ERR,"Error in run state: %d %s",rc,cw_strrc(rc)); break; } } while (conn->capwap_state == CW_STATE_RUN); // int rc = cw_send_request(conn,CW_MSG_CHANGE_STATE_EVENT_REQUEST); // if ( !cw_rcok(rc) ) { // cw_strresult(rc); // } return 0; }
static void reset_echointerval_timer(struct wtpman *wtpman) { uint16_t ct = mbag_get_word(wtpman->conn->local, CW_ITEM_CAPWAP_TIMERS, CAPWAP_MAX_DISCOVERY_INTERVAL << 8 | CAPWAP_ECHO_INTERVAL); /* start echinterval timer and put 2 seconds for "safety" on it */ wtpman->echointerval_timer = cw_timer_start(2+ (ct & 0xff)); db_ping_wtp(sock_addr2str_p(&wtpman->conn->addr), conf_acname); // cw_dbg(DBG_X, "Starting capwap timer: %d", wtpman->echointerval_timer); }