|
|
|
|
@ -223,29 +223,35 @@ static err_t
|
|
|
|
|
low_level_output(struct netif *netif, struct pbuf *p) |
|
|
|
|
{ |
|
|
|
|
struct tapif *tapif = (struct tapif *)netif->state; |
|
|
|
|
char buf[1514]; |
|
|
|
|
char buf[1518]; /* max packet size including VLAN excluding CRC */ |
|
|
|
|
ssize_t written; |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
if (((double)rand()/(double)RAND_MAX) < 0.2) { |
|
|
|
|
printf("drop output\n"); |
|
|
|
|
return ERR_OK; |
|
|
|
|
return ERR_OK; /* ERR_OK because we simulate packet loss on cable */ |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (p->tot_len > sizeof(buf)) { |
|
|
|
|
MIB2_STATS_NETIF_INC(netif, ifoutdiscards); |
|
|
|
|
perror("tapif: packet too large"); |
|
|
|
|
return ERR_IF; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* initiate transfer(); */ |
|
|
|
|
pbuf_copy_partial(p, buf, p->tot_len, 0); |
|
|
|
|
|
|
|
|
|
/* signal that packet should be sent(); */ |
|
|
|
|
written = write(tapif->fd, buf, p->tot_len); |
|
|
|
|
if (written < 0) { |
|
|
|
|
if (written < p->tot_len) { |
|
|
|
|
MIB2_STATS_NETIF_INC(netif, ifoutdiscards); |
|
|
|
|
perror("tapif: write"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return ERR_IF; |
|
|
|
|
} else { |
|
|
|
|
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, (u32_t)written); |
|
|
|
|
return ERR_OK; |
|
|
|
|
} |
|
|
|
|
return ERR_OK; |
|
|
|
|
} |
|
|
|
|
/*-----------------------------------------------------------------------------------*/ |
|
|
|
|
/*
|
|
|
|
|
@ -262,7 +268,7 @@ low_level_input(struct netif *netif)
|
|
|
|
|
struct pbuf *p; |
|
|
|
|
u16_t len; |
|
|
|
|
ssize_t readlen; |
|
|
|
|
char buf[1514]; |
|
|
|
|
char buf[1518]; /* max packet size including VLAN excluding CRC */ |
|
|
|
|
struct tapif *tapif = (struct tapif *)netif->state; |
|
|
|
|
|
|
|
|
|
/* Obtain the size of the packet and put it into the "len"
|
|
|
|
|
|