/[lwip]/lwip/src/netif/ethernetif.c
ViewVC logotype

Diff of /lwip/src/netif/ethernetif.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by likewise, Thu Feb 20 08:42:04 2003 UTC revision 1.9 by likewise, Thu May 1 13:24:01 2003 UTC
# Line 144  low_level_input(struct ethernetif *ether Line 144  low_level_input(struct ethernetif *ether
144    /* We allocate a pbuf chain of pbufs from the pool. */    /* We allocate a pbuf chain of pbufs from the pool. */
145    p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);    p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
146        
147    if(p != NULL) {    if (p != NULL) {
148      /* We iterate over the pbuf chain until we have read the entire      /* We iterate over the pbuf chain until we have read the entire
149         packet into the pbuf. */         packet into the pbuf. */
150      for(q = p; q != NULL; q = q->next) {      for(q = p; q != NULL; q = q->next) {
# Line 192  ethernetif_output(struct netif *netif, s Line 192  ethernetif_output(struct netif *netif, s
192    ethernetif = netif->state;    ethernetif = netif->state;
193    
194    /* Make room for Ethernet header. */    /* Make room for Ethernet header. */
195    if(pbuf_header(p, 14) != 0) {    if (pbuf_header(p, 14) != 0) {
196      /* The pbuf_header() call shouldn't fail, but we allocate an extra      /* The pbuf_header() call shouldn't fail, but we allocate an extra
197         pbuf just in case. */         pbuf just in case. */
198      q = pbuf_alloc(PBUF_LINK, 14, PBUF_RAM);      q = pbuf_alloc(PBUF_LINK, 14, PBUF_RAM);
199      if(q == NULL) {      if (q == NULL) {
200  #ifdef LINK_STATS  #ifdef LINK_STATS
201        lwip_stats.link.drop++;        lwip_stats.link.drop++;
202        lwip_stats.link.memerr++;        lwip_stats.link.memerr++;
# Line 212  ethernetif_output(struct netif *netif, s Line 212  ethernetif_output(struct netif *netif, s
212       multicasts are special, all other addresses are looked up in the       multicasts are special, all other addresses are looked up in the
213       ARP table. */       ARP table. */
214    queryaddr = ipaddr;    queryaddr = ipaddr;
215    if(ip_addr_isany(ipaddr) ||    if (ip_addr_isany(ipaddr) ||
216       ip_addr_isbroadcast(ipaddr, &(netif->netmask))) {       ip_addr_isbroadcast(ipaddr, &(netif->netmask))) {
217      dest = (struct eth_addr *)&ethbroadcast;      dest = (struct eth_addr *)&ethbroadcast;
218    } else if(ip_addr_ismulticast(ipaddr)) {    } else if (ip_addr_ismulticast(ipaddr)) {
219      /* Hash IP multicast address to MAC address. */      /* Hash IP multicast address to MAC address. */
220      mcastaddr.addr[0] = 0x01;      mcastaddr.addr[0] = 0x01;
221      mcastaddr.addr[1] = 0x0;      mcastaddr.addr[1] = 0x0;
# Line 226  ethernetif_output(struct netif *netif, s Line 226  ethernetif_output(struct netif *netif, s
226      dest = &mcastaddr;      dest = &mcastaddr;
227    } else {    } else {
228    
229      if(ip_addr_maskcmp(ipaddr, &(netif->ip_addr), &(netif->netmask))) {      if (ip_addr_maskcmp(ipaddr, &(netif->ip_addr), &(netif->netmask))) {
230        /* Use destination IP address if the destination is on the same        /* Use destination IP address if the destination is on the same
231           subnet as we are. */           subnet as we are. */
232        queryaddr = ipaddr;        queryaddr = ipaddr;
# Line 241  ethernetif_output(struct netif *netif, s Line 241  ethernetif_output(struct netif *netif, s
241    
242    /* If the arp_lookup() didn't find an address, we send out an ARP    /* If the arp_lookup() didn't find an address, we send out an ARP
243       query for the IP address. */       query for the IP address. */
244    if(dest == NULL) {    if (dest == NULL) {
245      q = arp_query(netif, ethernetif->ethaddr, queryaddr);      q = arp_query(netif, ethernetif->ethaddr, queryaddr);
246      if(q != NULL) {      if (q != NULL) {
247        err = low_level_output(ethernetif, q);        err = low_level_output(ethernetif, q);
248        pbuf_free(q);        pbuf_free(q);
249        return err;        return err;
# Line 289  ethernetif_input(struct netif *netif) Line 289  ethernetif_input(struct netif *netif)
289        
290    p = low_level_input(ethernetif);    p = low_level_input(ethernetif);
291    
292    if(p != NULL) {    if (p != NULL) {
293    
294  #ifdef LINK_STATS  #ifdef LINK_STATS
295      lwip_stats.link.recv++;      lwip_stats.link.recv++;
# Line 297  ethernetif_input(struct netif *netif) Line 297  ethernetif_input(struct netif *netif)
297    
298      ethhdr = p->payload;      ethhdr = p->payload;
299            
300      switch(htons(ethhdr->type)) {      switch (htons(ethhdr->type)) {
301      case ETHTYPE_IP:      case ETHTYPE_IP:
302        arp_ip_input(netif, p);        arp_ip_input(netif, p);
303        pbuf_header(p, -14);        pbuf_header(p, -14);
# Line 305  ethernetif_input(struct netif *netif) Line 305  ethernetif_input(struct netif *netif)
305        break;        break;
306      case ETHTYPE_ARP:      case ETHTYPE_ARP:
307        p = arp_arp_input(netif, ethernetif->ethaddr, p);        p = arp_arp_input(netif, ethernetif->ethaddr, p);
308        if(p != NULL) {        if (p != NULL) {
309          low_level_output(ethernetif, p);          low_level_output(ethernetif, p);
310          pbuf_free(p);          pbuf_free(p);
311        }        }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26