예제 #1
0
void TftpdStart(void)
{
	 ptr=0x80201000;  //only for RT6855/RT6856/RT63365   
#if defined(CONFIG_NET_MULTI)
	printf("Using %s device\n", eth_get_name());
#endif
	//puts(" \nTFTP from server ");	print_IPaddr(NetServerIP);
	puts("\nOur IP address is:(");	
	print_IPaddr(NetOurIP);
	puts(")\nWait for TFTP request...\n");
	/* Check if we need to send across this subnet */
	if (NetOurGatewayIP && NetOurSubnetMask) 
	{
		IPaddr_t OurNet 	= NetOurIP    & NetOurSubnetMask;
		IPaddr_t ServerNet 	= NetServerIP & NetOurSubnetMask;
		
		if (OurNet != ServerNet)
		{
			puts("; sending through gateway ");
			print_IPaddr(NetOurGatewayIP) ;
		}
	}

	memset(ptr,0,sizeof(ptr));
	_tftpd_open();
}
예제 #2
0
void ping_start(void)
{
	printf("Using %s device\n", eth_get_name());
	net_set_timeout_handler(10000UL, ping_timeout_handler);

	ping_send();
}
예제 #3
0
void ping_start(void)
{
	printf("Using %s device\n", eth_get_name());
	NetSetTimeout(10000UL, ping_timeout);

	ping_send();
}
예제 #4
0
파일: link_local.c 프로젝트: harayz/n900
static void configure_wait(void)
{
	if (timeout_ms == -1)
		return;

	/* poll, being ready to adjust current timeout */
	if (!timeout_ms)
		timeout_ms = random_delay_ms(PROBE_WAIT);

	/* set deadline_ms to the point in time when we timeout */
	deadline_ms = MONOTONIC_MS() + timeout_ms;

	debug_cond(DEBUG_DEV_PKT, "...wait %d %s nprobes=%u, nclaims=%u\n",
			timeout_ms, eth_get_name(), nprobes, nclaims);

	NetSetTimeout(timeout_ms, link_local_timeout);
}
예제 #5
0
__maybe_unused
static void print_eths(void)
{
	struct eth_device *dev;
	int i = 0;

	do {
		dev = eth_get_dev_by_index(i);
		if (dev) {
			printf("eth%dname    = %s\n", i, dev->name);
			print_eth(i);
			i++;
		}
	} while (dev);

	printf("current eth = %s\n", eth_get_name());
	printf("ip_addr     = %s\n", getenv("ipaddr"));
}
예제 #6
0
파일: link_local.c 프로젝트: harayz/n900
void link_local_receive_arp(struct arp_hdr *arp, int len)
{
	int source_ip_conflict;
	int target_ip_conflict;

	if (state == DISABLED)
		return;

	/* We need to adjust the timeout in case we didn't receive a
	   conflicting packet. */
	if (timeout_ms > 0) {
		unsigned diff = deadline_ms - MONOTONIC_MS();
		if ((int)(diff) < 0) {
			/* Current time is greater than the expected timeout
			   time. This should never happen */
			debug_cond(DEBUG_LL_STATE,
				"missed an expected timeout\n");
			timeout_ms = 0;
		} else {
			debug_cond(DEBUG_INT_STATE, "adjusting timeout\n");
			timeout_ms = diff | 1; /* never 0 */
		}
	}
/*
 * XXX Don't bother with ethernet link just yet
	if ((fds[0].revents & POLLIN) == 0) {
		if (fds[0].revents & POLLERR) {
			// FIXME: links routinely go down;
			// this shouldn't necessarily exit.
			bb_error_msg("iface %s is down", eth_get_name());
			if (ready) {
				run(argv, "deconfig", &ip);
			}
			return EXIT_FAILURE;
		}
		continue;
	}
*/

	debug_cond(DEBUG_INT_STATE, "%s recv arp type=%d, op=%d,\n",
		eth_get_name(), ntohs(arp->ar_pro),
		ntohs(arp->ar_op));
	debug_cond(DEBUG_INT_STATE, "\tsource=%pM %pI4\n",
		&arp->ar_sha,
		&arp->ar_spa);
	debug_cond(DEBUG_INT_STATE, "\ttarget=%pM %pI4\n",
		&arp->ar_tha,
		&arp->ar_tpa);

	if (arp->ar_op != htons(ARPOP_REQUEST)
	 && arp->ar_op != htons(ARPOP_REPLY)
	) {
		configure_wait();
		return;
	}

	source_ip_conflict = 0;
	target_ip_conflict = 0;

	if (memcmp(&arp->ar_spa, &ip, ARP_PLEN) == 0
	 && memcmp(&arp->ar_sha, NetOurEther, ARP_HLEN) != 0
	) {
		source_ip_conflict = 1;
	}
	if (arp->ar_op == htons(ARPOP_REQUEST)
	 && memcmp(&arp->ar_tpa, &ip, ARP_PLEN) == 0
	 && memcmp(&arp->ar_tha, NetOurEther, ARP_HLEN) != 0
	) {
		target_ip_conflict = 1;
	}

	debug_cond(DEBUG_NET_PKT,
		"state = %d, source ip conflict = %d, target ip conflict = "
		"%d\n", state, source_ip_conflict, target_ip_conflict);
	switch (state) {
	case PROBE:
	case ANNOUNCE:
		/* When probing or announcing, check for source IP conflicts
		   and other hosts doing ARP probes (target IP conflicts). */
		if (source_ip_conflict || target_ip_conflict) {
			conflicts++;
			state = PROBE;
			if (conflicts >= MAX_CONFLICTS) {
				debug("%s ratelimit\n", eth_get_name());
				timeout_ms = RATE_LIMIT_INTERVAL * 1000;
				state = RATE_LIMIT_PROBE;
			}

			/* restart the whole protocol */
			ip = pick();
			timeout_ms = 0;
			nprobes = 0;
			nclaims = 0;
		}
		break;
	case MONITOR:
		/* If a conflict, we try to defend with a single ARP probe */
		if (source_ip_conflict) {
			debug("monitor conflict -- defending\n");
			state = DEFEND;
			timeout_ms = DEFEND_INTERVAL * 1000;
			arp_raw_request(ip, NetOurEther, ip);
		}
		break;
	case DEFEND:
		/* Well, we tried.  Start over (on conflict) */
		if (source_ip_conflict) {
			state = PROBE;
			debug("defend conflict -- starting over\n");
			ready = 0;
			NetOurIP = 0;

			/* restart the whole protocol */
			ip = pick();
			timeout_ms = 0;
			nprobes = 0;
			nclaims = 0;
		}
		break;
	default:
		/* Invalid, should never happen.  Restart the whole protocol */
		debug("invalid state -- starting over\n");
		state = PROBE;
		ip = pick();
		timeout_ms = 0;
		nprobes = 0;
		nclaims = 0;
		break;
	}
	configure_wait();
}
예제 #7
0
파일: link_local.c 프로젝트: harayz/n900
static void link_local_timeout(void)
{
	switch (state) {
	case PROBE:
		/* timeouts in the PROBE state mean no conflicting ARP packets
		   have been received, so we can progress through the states */
		if (nprobes < PROBE_NUM) {
			nprobes++;
			debug_cond(DEBUG_LL_STATE, "probe/%u %s@%pI4\n",
					nprobes, eth_get_name(), &ip);
			arp_raw_request(0, NetEtherNullAddr, ip);
			timeout_ms = PROBE_MIN * 1000;
			timeout_ms += random_delay_ms(PROBE_MAX - PROBE_MIN);
		} else {
			/* Switch to announce state */
			state = ANNOUNCE;
			nclaims = 0;
			debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n",
					nclaims, eth_get_name(), &ip);
			arp_raw_request(ip, NetOurEther, ip);
			timeout_ms = ANNOUNCE_INTERVAL * 1000;
		}
		break;
	case RATE_LIMIT_PROBE:
		/* timeouts in the RATE_LIMIT_PROBE state mean no conflicting
		   ARP packets have been received, so we can move immediately
		   to the announce state */
		state = ANNOUNCE;
		nclaims = 0;
		debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n",
				nclaims, eth_get_name(), &ip);
		arp_raw_request(ip, NetOurEther, ip);
		timeout_ms = ANNOUNCE_INTERVAL * 1000;
		break;
	case ANNOUNCE:
		/* timeouts in the ANNOUNCE state mean no conflicting ARP
		   packets have been received, so we can progress through
		   the states */
		if (nclaims < ANNOUNCE_NUM) {
			nclaims++;
			debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n",
					nclaims, eth_get_name(), &ip);
			arp_raw_request(ip, NetOurEther, ip);
			timeout_ms = ANNOUNCE_INTERVAL * 1000;
		} else {
			/* Switch to monitor state */
			state = MONITOR;
			printf("Successfully assigned %pI4\n", &ip);
			NetCopyIP(&NetOurIP, &ip);
			ready = 1;
			conflicts = 0;
			timeout_ms = -1;
			/* Never timeout in the monitor state */
			NetSetTimeout(0, NULL);

			/* NOTE: all other exit paths should deconfig ... */
			net_set_state(NETLOOP_SUCCESS);
			return;
		}
		break;
	case DEFEND:
		/* We won!  No ARP replies, so just go back to monitor */
		state = MONITOR;
		timeout_ms = -1;
		conflicts = 0;
		break;
	default:
		/* Invalid, should never happen.  Restart the whole protocol */
		state = PROBE;
		ip = pick();
		timeout_ms = 0;
		nprobes = 0;
		nclaims = 0;
		break;
	}
	configure_wait();
}