BOOL dispatch_frame (OS_FRAME *frame, U8 netif) { /* Dispatch the outgoing frame to selected network interface. */ switch (netif) { #if ETH_ENABLE == 1 case NETIF_ETH: return (eth_send_frame (frame)); #endif #if PPP_ENABLE == 1 case NETIF_PPP: return (ppp_send_frame (frame, PPP_PROT_IP)); #endif #if SLIP_ENABLE == 1 case NETIF_SLIP: return (slip_send_frame (frame)); #endif } return (__FALSE); }
static void target_write_ethernet(target_context_t *tc, const void *data, size_t count) { size_t remain, nsent; assert(tc->mtu == ETHERNET_MTU); assert(count <= tc->mtu); for (remain = count; remain; remain -= nsent) { char c; nsent = remain; if (nsent > ETH_DOWNLOAD_BLOCK) nsent = ETH_DOWNLOAD_BLOCK; eth_send_frame(tc, data, nsent, 1); /* wait for ack */ xread(tc->portfd, &c, 1); assert(c == 'K'); data += nsent; } }