void evict( uint16_t short_addr ){ send_evict( short_addr ); remove_neighbor( short_addr ); reset_beacon_interval(); }
void process_evict( wcom_msg_evict_t *msg, wcom_mac_addr_t *addr, wcom_mac_rx_options_t *options ){ // get neighbor wcom_neighbor_t *neighbor = wcom_neighbors_p_get_neighbor( addr->source_addr ); // check if we have the neighbor if( neighbor < 0 ){ log_v_debug_P( PSTR("Evict from unknown neighbor: %s"), addr->source_addr ); return; } //log_v_debug_P( PSTR("Received evict from:%d"), addr->source_addr ); // verify message uint8_t auth_tag[CRYPT_AUTH_TAG_SIZE]; wcom_mac_sec_v_compute_auth_tag( neighbor->iv, msg, sizeof(wcom_msg_evict_t) - CRYPT_AUTH_TAG_SIZE, auth_tag ); // check message if( !memcmp( auth_tag, msg->auth_tag, sizeof(auth_tag) ) == 0 ){ log_v_debug_P( PSTR("Evict auth fail") ); return; } // not paired, we got evicted log_v_debug_P( PSTR("Evicted by:%d IP:%d.%d.%d.%d"), (uint16_t)addr->source_addr, neighbor->ip.ip3, neighbor->ip.ip2, neighbor->ip.ip1, neighbor->ip.ip0 ); // remove neighbor remove_neighbor( neighbor->short_addr ); // reset beacon interval reset_beacon_interval(); }
void rxneigh_update(void) { // update local neighbor list RipNeighbor *neigh = neighbors; while (neigh != NULL) { RipNeighbor *next = neigh->next; if (++neigh->rx_time > RIP_ROUTE_TIMEOUT) remove_neighbor(neigh); neigh = next; } // update shm neighbor list if (--shm_update_timeout <= 0) { shm_update_timeout = RIP_UPDATE_SHM_TIMEOUT; // lock http shm->stats.rip_active_locked = 1; neigh = neighbors; int i = 0; while (neigh != NULL) { RcpActiveNeighbor *an = &shm->stats.rip_active[i]; an->valid = 0; an->area = 0; an->router_id = 0; RcpInterface *intf = rcpFindInterfaceByLPM(shm, neigh->ip); if (intf) { an->network = intf->ip & intf->mask; an->netmask_cnt = mask2bits(intf->mask); an->if_ip = intf->ip; an->ip = neigh->ip; an->valid = 1; i++; } neigh = neigh->next; } // clear remaining active neighbors for (; i < RCP_ACTIVE_NEIGHBOR_LIMIT; i++) shm->stats.rip_active[i].valid = 0; } shm->stats.rip_active_locked = 0; }