mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2025-02-22 23:28:57 +00:00
Made compliant with API changes in CVS HEAD.
This commit is contained in:
parent
80bf73178b
commit
5acf6d24d5
@ -328,6 +328,11 @@ static err_t cs8900_output(struct netif *netif, struct pbuf *p)
|
||||
if ((PPDATA & 0x0080U/*LinkOK*/) == 0) return ERR_CONN; // no Ethernet link
|
||||
|
||||
result = ERR_OK;
|
||||
/* TODO: should this occur AFTER setting TXLENGTH??? */
|
||||
/* drop the padding word */
|
||||
#if ETH_PAD_SIZE
|
||||
pbuf_header(p, -ETH_PAD_SIZE);
|
||||
#endif
|
||||
|
||||
/* issue 'transmit' command to CS8900 */
|
||||
TXCMD = 0x00C9U;
|
||||
@ -387,6 +392,10 @@ static err_t cs8900_output(struct netif *netif, struct pbuf *p)
|
||||
/* return not connected */
|
||||
result = ERR_IF;
|
||||
}
|
||||
#if ETH_PAD_SIZE
|
||||
/* reclaim the padding word */
|
||||
pbuf_header(p, ETH_PAD_SIZE);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -436,14 +445,19 @@ static struct pbuf *cs8900_input(struct netif *netif)
|
||||
// positive length?
|
||||
if (len > 0)
|
||||
{
|
||||
// allocate a pbuf chain with total length 'len'
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
|
||||
// allocate a pbuf chain with total length 'len + ETH_PAD_SIZE'
|
||||
p = pbuf_alloc(PBUF_RAW, len + ETH_PAD_SIZE, PBUF_POOL);
|
||||
if (p != NULL)
|
||||
{
|
||||
#if ETH_PAD_SIZE
|
||||
/* drop the padding word */
|
||||
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
|
||||
#endif
|
||||
|
||||
for (q = p; q != 0; q = q->next)
|
||||
{
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: pbuf @%p tot_len %u len %u\n", q, q->tot_len, q->len));
|
||||
ptr = q->payload;
|
||||
{
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: pbuf @%p tot_len %u len %u\n", q, q->tot_len, q->len));
|
||||
ptr = q->payload;
|
||||
// TODO: CHECK: what if q->len is odd? we don't use the last byte?
|
||||
for (i = 0; i < (q->len + 1) / 2; i++)
|
||||
{
|
||||
@ -451,6 +465,10 @@ static struct pbuf *cs8900_input(struct netif *netif)
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
#if ETH_PAD_SIZE
|
||||
/* reclaim the padding word */
|
||||
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||
#endif
|
||||
}
|
||||
// could not allocate a pbuf
|
||||
else
|
||||
@ -623,25 +641,8 @@ void cs8900if_service(struct netif *netif)
|
||||
*/
|
||||
err_t cs8900if_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
||||
{
|
||||
struct cs8900if *cs8900if = netif->state;
|
||||
err_t result;
|
||||
/* resolve the link destination hardware address */
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
/* network hardware address obtained? */
|
||||
if (p != NULL)
|
||||
{
|
||||
/* send out the packet */
|
||||
result = cs8900_output(netif, p);
|
||||
p = NULL;
|
||||
}
|
||||
/* { p == NULL } */
|
||||
else
|
||||
{
|
||||
/* we cannot tell if the packet was sent, the packet could have been queued */
|
||||
/* on an ARP entry that was already pending. */
|
||||
return ERR_OK;
|
||||
}
|
||||
return result;
|
||||
return etharp_output(netif, ipaddr, p);
|
||||
}
|
||||
/**
|
||||
* Read a received packet from the CS8900.
|
||||
@ -659,9 +660,8 @@ err_t cs8900if_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipadd
|
||||
*/
|
||||
void cs8900if_input(struct netif *netif)
|
||||
{
|
||||
struct cs8900if *cs8900if = netif->state;
|
||||
struct eth_hdr *ethhdr = NULL;
|
||||
struct pbuf *p = NULL, *q = NULL;
|
||||
struct pbuf *p = NULL;
|
||||
|
||||
/* move received packet into a new pbuf */
|
||||
p = cs8900_input(netif);
|
||||
@ -673,22 +673,21 @@ void cs8900if_input(struct netif *netif)
|
||||
/* points to packet payload, which starts with an Ethernet header */
|
||||
ethhdr = p->payload;
|
||||
|
||||
q = NULL;
|
||||
switch (htons(ethhdr->type)) {
|
||||
/* IP packet? */
|
||||
case ETHTYPE_IP:
|
||||
/* update ARP table, obtain first queued packet */
|
||||
q = etharp_ip_input(netif, p);
|
||||
/* update ARP table */
|
||||
etharp_ip_input(netif, p);
|
||||
/* skip Ethernet header */
|
||||
pbuf_header(p, -14);
|
||||
pbuf_header(p, -sizeof(struct eth_hdr));
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: passing packet up to IP\n"));
|
||||
/* pass to network layer */
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
/* ARP packet? */
|
||||
case ETHTYPE_ARP:
|
||||
/* pass p to ARP module, get ARP reply or ARP queued packet */
|
||||
q = etharp_arp_input(netif, (struct eth_addr *)&netif->hwaddr, p);
|
||||
/* pass p to ARP module */
|
||||
etharp_arp_input(netif, (struct eth_addr *)&netif->hwaddr, p);
|
||||
break;
|
||||
/* unsupported Ethernet packet type */
|
||||
default:
|
||||
@ -697,21 +696,6 @@ void cs8900if_input(struct netif *netif)
|
||||
p = NULL;
|
||||
break;
|
||||
}
|
||||
/* send out the ARP reply or ARP queued packet */
|
||||
if (q != NULL) {
|
||||
/* q pbuf has been succesfully sent? */
|
||||
if (cs8900_output(netif, q) == ERR_OK)
|
||||
{
|
||||
pbuf_free(q);
|
||||
q = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: re-queue packet in the ARP cache here (?) */
|
||||
pbuf_free(q);
|
||||
q = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,12 +422,7 @@ static err_t
|
||||
mcf5272fecif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if (p != NULL) {
|
||||
low_level_output(netif, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
|
||||
return etharp_output(netif, ipaddr, p);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -437,27 +432,22 @@ eth_input(struct pbuf *p, struct netif *netif)
|
||||
/* Ethernet protocol layer */
|
||||
struct eth_hdr *ethhdr;
|
||||
mcf5272if_t *mcf5272 = netif->state;
|
||||
struct pbuf *q = NULL;
|
||||
|
||||
ethhdr = p->payload;
|
||||
|
||||
switch (htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
q = etharp_ip_input(netif, p);
|
||||
etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
q = etharp_arp_input(netif, mcf5272->ethaddr, p);
|
||||
etharp_arp_input(netif, mcf5272->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
if (q != NULL) {
|
||||
low_level_output(netif, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -239,11 +239,7 @@ static err_t
|
||||
ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if (p != NULL) {
|
||||
return low_level_output(netif, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
return etharp_output(netif, ipaddr, p);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
@ -280,16 +276,10 @@ ethernetif_input(struct netif *netif)
|
||||
case ETHTYPE_IP:
|
||||
etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
//if (ip_lookup(p->payload, netif)) {
|
||||
netif->input(p, netif);
|
||||
//}
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
p = etharp_arp_input(netif, ethernetif->ethaddr, p);
|
||||
if (p != NULL) {
|
||||
low_level_output(netif, p);
|
||||
pbuf_free(p);
|
||||
}
|
||||
etharp_arp_input(netif, ethernetif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
|
@ -130,15 +130,11 @@ timeout(void *arg)
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
p = etharp_arp_input(netif, pcapif->ethaddr, p);
|
||||
if (p != NULL) {
|
||||
printf("ARP outout\n");
|
||||
pbuf_free(p);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
etharp_arp_input(netif, pcapif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -272,12 +272,7 @@ static err_t
|
||||
tapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if(p != NULL) {
|
||||
low_level_output(netif, p);
|
||||
p = NULL;
|
||||
}
|
||||
return ERR_OK;
|
||||
return etharp_output(netif, ipaddr, p);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
@ -295,7 +290,7 @@ tapif_input(struct netif *netif)
|
||||
{
|
||||
struct tapif *tapif;
|
||||
struct eth_hdr *ethhdr;
|
||||
struct pbuf *p, *q;
|
||||
struct pbuf *p;
|
||||
|
||||
|
||||
tapif = netif->state;
|
||||
@ -308,11 +303,10 @@ tapif_input(struct netif *netif)
|
||||
}
|
||||
ethhdr = p->payload;
|
||||
|
||||
q = NULL;
|
||||
switch(htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: IP packet\n"));
|
||||
q = etharp_ip_input(netif, p);
|
||||
etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
#if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP)
|
||||
tcpdump(p);
|
||||
@ -321,17 +315,12 @@ tapif_input(struct netif *netif)
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: ARP packet\n"));
|
||||
q = etharp_arp_input(netif, tapif->ethaddr, p);
|
||||
etharp_arp_input(netif, tapif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
if(q != NULL) {
|
||||
low_level_output(netif, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -228,11 +228,7 @@ static err_t
|
||||
mintapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if (p != NULL) {
|
||||
return low_level_output(netif, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
return etharp_output(netif, ipaddr, p);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
@ -250,7 +246,7 @@ mintapif_input(struct netif *netif)
|
||||
{
|
||||
struct mintapif *mintapif;
|
||||
struct eth_hdr *ethhdr;
|
||||
struct pbuf *p, *q;
|
||||
struct pbuf *p;
|
||||
|
||||
|
||||
mintapif = netif->state;
|
||||
@ -265,25 +261,19 @@ mintapif_input(struct netif *netif)
|
||||
|
||||
ethhdr = p->payload;
|
||||
|
||||
q = NULL;
|
||||
switch (htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
q = etharp_ip_input(netif, p);
|
||||
etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
q = etharp_arp_input(netif, mintapif->ethaddr, p);
|
||||
etharp_arp_input(netif, mintapif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
if (q != NULL) {
|
||||
low_level_output(netif, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -302,13 +302,7 @@ static err_t xemacif_output(struct netif *netif_ptr,
|
||||
{
|
||||
XEmacIf_Config *xemacif_ptr = xemacif_ptr = netif_ptr->state;
|
||||
|
||||
p = etharp_output(netif_ptr, ipaddr, p);
|
||||
|
||||
if (p != NULL) {
|
||||
/* send the frame */
|
||||
low_level_output(netif_ptr, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
return etharp_output(netif_ptr, ipaddr, p);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -324,7 +318,7 @@ err_t xemacif_input(void *CallBackRef)
|
||||
struct netif * netif_ptr = (struct netif *) CallBackRef;
|
||||
XEmacIf_Config * xemacif_ptr;
|
||||
struct eth_hdr * ethernet_header;
|
||||
struct pbuf *p, *q;
|
||||
struct pbuf *p;
|
||||
|
||||
xemacif_ptr = netif_ptr->state;
|
||||
|
||||
@ -336,22 +330,17 @@ err_t xemacif_input(void *CallBackRef)
|
||||
q = NULL;
|
||||
switch (htons(ethernet_header->type)) {
|
||||
case ETHTYPE_IP:
|
||||
q = etharp_ip_input(netif_ptr, p);
|
||||
etharp_ip_input(netif_ptr, p);
|
||||
pbuf_header(p, -14);
|
||||
netif_ptr->input(p, netif_ptr);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
q = etharp_arp_input(netif_ptr, &(xemacif_ptr->ethaddr), p);
|
||||
etharp_arp_input(netif_ptr, &(xemacif_ptr->ethaddr), p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (q != NULL) {
|
||||
low_level_output(netif_ptr, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user