Beispiel #1
0
/* This is called when we stop receiveing hello messages from a
   node. For now this is basically the same as a route timeout. */
void NS_CLASS hello_timeout(void *arg)
{
    rt_table_t *rt;
    struct timeval now;

    rt = (rt_table_t *) arg;

    if (!rt)
        return;

    gettimeofday(&now, NULL);

    DEBUG(LOG_DEBUG, 0, "LINK/HELLO FAILURE %s last HELLO: %d",
          ip_to_str(rt->dest_addr), timeval_diff(&now, &rt->last_hello_time));

    if (rt && rt->state == VALID && !(rt->flags & RT_UNIDIR)) {

        /* If the we can repair the route, then mark it to be
           repaired.. */
        if (local_repair && rt->hcnt <= MAX_REPAIR_TTL) {
            rt->flags |= RT_REPAIR;
            DEBUG(LOG_DEBUG, 0, "Marking %s for REPAIR",
                  ip_to_str(rt->dest_addr));
#ifdef NS_PORT
            /* Buffer pending packets from interface queue */
            interfaceQueue((nsaddr_t) rt->dest_addr.s_addr, IFQ_BUFFER);
#endif
        }
        neighbor_link_break(rt);
    }
}
Beispiel #2
0
static inline int llf_print_event(struct iw_event *event,
				  struct iw_range *iwrange, int has_iwrange)
{
    char buffer[128];
    struct in_addr ip;
    rt_table_t *rt;

    /* Now, let's decode the event */
    switch (event->cmd) {

    case IWEVTXDROP:
	DEBUG(LOG_DEBUG, 0, "Tx packet dropped:%s",
	      iw_pr_ether(buffer, event->u.addr.sa_data));


	if (mac_to_ip(&event->u.addr, &ip, this_host.devs[0].ifname) != 0) {
	    DEBUG(LOG_DEBUG, 0, "failed mac_to_ip");
	    return 0;
	}
	//printf("IP=%s\n", ip_to_str(ip));

	rt = rt_table_find(ip);

	if (rt)
	    neighbor_link_break(rt);
	else
	    DEBUG(LOG_DEBUG, 0, "no route for ip=%s", ip_to_str(ip));
	break;

    default:
	DEBUG(LOG_DEBUG, 0, "(Unknown Wireless event 0x%04X)", event->cmd);
    }

    return 0;
}
Beispiel #3
0
void NS_CLASS rrep_send(RREP * rrep, rt_table_t * rev_rt,
			rt_table_t * fwd_rt, int size)
{
	u_int8_t rrep_flags = 0;
	struct in_addr dest;

	if (!rev_rt) {
		DEBUG(LOG_WARNING, 0, "Can't send RREP, rev_rt = NULL!");
		return;
	}

	dest.s_addr = rrep->dest_addr;

	/* Check if we should request a RREP-ACK */
	if ((rev_rt->state == VALID && rev_rt->flags & RT_UNIDIR) ||
	    (rev_rt->hcnt == 1 && unidir_hack)) {
		rt_table_t *neighbor = rt_table_find(rev_rt->next_hop);

		if (neighbor && neighbor->state == VALID
		    && !neighbor->ack_timer.used) {
			/* If the node we received a RREQ for is a neighbor we are
			   probably facing a unidirectional link... Better request a
			   RREP-ack */
			rrep_flags |= RREP_ACK;
			neighbor->flags |= RT_UNIDIR;

			/* Must remove any pending hello timeouts when we set the
			   RT_UNIDIR flag, else the route may expire after we begin to
			   ignore hellos... */
			timer_remove(&neighbor->hello_timer);
			neighbor_link_break(neighbor);

			DEBUG(LOG_DEBUG, 0, "Link to %s is unidirectional!",
			      ip_to_str(neighbor->dest_addr));

			timer_set_timeout(&neighbor->ack_timer, NEXT_HOP_WAIT);
		}
	}

	DEBUG(LOG_DEBUG, 0, "Sending RREP to next hop %s about %s->%s",
	      ip_to_str(rev_rt->next_hop), ip_to_str(rev_rt->dest_addr),
	      ip_to_str(dest));

	aodv_socket_send((AODV_msg *) rrep, rev_rt->next_hop, size, MAXTTL,
			 &DEV_IFINDEX(rev_rt->ifindex));

	/* Update precursor lists */
	if (fwd_rt) {
		precursor_add(fwd_rt, rev_rt->next_hop);
		precursor_add(rev_rt, fwd_rt->next_hop);
	}

	if (!llfeedback && optimized_hellos)
		hello_start();
}
Beispiel #4
0
void NS_CLASS route_expire_timeout(void *arg)
{
    rt_table_t *rt;

    rt = (rt_table_t *) arg;

    if (!rt) {
        alog(LOG_WARNING, 0, __FUNCTION__, "arg was NULL, ignoring timeout!");
        return;
    }

    DEBUG(LOG_DEBUG, 0, "Route %s DOWN, seqno=%d",
          ip_to_str(rt->dest_addr), rt->dest_seqno);

    if (rt->hcnt == 1)
        neighbor_link_break(rt);
    else {
        rt_table_invalidate(rt);
        precursor_list_destroy(rt);
    }

    return;
}