diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-11 14:28:16 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-11 14:28:16 +0000 |
commit | 5aa10a765807c59b4ba7e8bc546723125992eacc (patch) | |
tree | 37f83fc854c9a8e5330849b89cda2bf06ce76edf /nuttx/net | |
parent | b01a17e3235e9cbe98a11ff3095e6792b8e6eb9c (diff) | |
download | px4-nuttx-5aa10a765807c59b4ba7e8bc546723125992eacc.tar.gz px4-nuttx-5aa10a765807c59b4ba7e8bc546723125992eacc.tar.bz2 px4-nuttx-5aa10a765807c59b4ba7e8bc546723125992eacc.zip |
Moved MAC and ethernet definitions to include/net/ethernet.h
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@443 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/netdev-ioctl.c | 5 | ||||
-rw-r--r-- | nuttx/net/netdev-register.c | 6 | ||||
-rw-r--r-- | nuttx/net/uip/uip-arp.c | 38 | ||||
-rw-r--r-- | nuttx/net/uip/uip-neighbor.c | 14 | ||||
-rw-r--r-- | nuttx/net/uip/uip-neighbor.h | 3 |
5 files changed, 36 insertions, 30 deletions
diff --git a/nuttx/net/netdev-ioctl.c b/nuttx/net/netdev-ioctl.c index 81cfce689..00ddd6e31 100644 --- a/nuttx/net/netdev-ioctl.c +++ b/nuttx/net/netdev-ioctl.c @@ -51,6 +51,7 @@ #include <nuttx/net.h> #include <net/if.h> +#include <net/ethernet.h> #include <net/uip/uip-arch.h> #include <net/uip/uip.h> @@ -221,12 +222,12 @@ int netdev_ioctl(int sockfd, int cmd, struct ifreq *req) case SIOCGIFHWADDR: /* Get hardware address */ req->ifr_hwaddr.sa_family = AF_INETX; - memcpy(req->ifr_hwaddr.sa_data, dev->d_mac.addr, IFHWADDRLEN); + memcpy(req->ifr_hwaddr.sa_data, dev->d_mac.ether_addr_octet, IFHWADDRLEN); break; case SIOCSIFHWADDR: /* Set hardware address */ req->ifr_hwaddr.sa_family = AF_INETX; - memcpy(dev->d_mac.addr, req->ifr_hwaddr.sa_data, IFHWADDRLEN); + memcpy(dev->d_mac.ether_addr_octet, req->ifr_hwaddr.sa_data, IFHWADDRLEN); break; case SIOCDIFADDR: /* Delete IP address */ diff --git a/nuttx/net/netdev-register.c b/nuttx/net/netdev-register.c index b1ab57a44..5f06b665b 100644 --- a/nuttx/net/netdev-register.c +++ b/nuttx/net/netdev-register.c @@ -50,6 +50,7 @@ #include <debug.h> #include <net/if.h> +#include <net/ethernet.h> #include <net/uip/uip-arch.h> #include "net-internal.h" @@ -143,8 +144,9 @@ int netdev_register(FAR struct uip_driver_s *dev) netdev_semgive(); nlldbg("Registered MAC: %02x:%02x:%02x:%02x:%02x:%02x as dev: %s\n", - dev->d_mac.addr[0], dev->d_mac.addr[1], dev->d_mac.addr[2], - dev->d_mac.addr[3], dev->d_mac.addr[4], dev->d_mac.addr[5], + dev->d_mac.ether_addr_octet[0], dev->d_mac.ether_addr_octet[1], + dev->d_mac.ether_addr_octet[2], dev->d_mac.ether_addr_octet[3], + dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5], dev->d_ifname); return OK; diff --git a/nuttx/net/uip/uip-arp.c b/nuttx/net/uip/uip-arp.c index 838d99b72..0c33eabfe 100644 --- a/nuttx/net/uip/uip-arp.c +++ b/nuttx/net/uip/uip-arp.c @@ -62,7 +62,7 @@ #include <debug.h> #include <netinet/in.h> -#include <net/if.h> +#include <net/ethernet.h> #include <net/uip/uip-arch.h> #include <net/uip/uip-arp.h> @@ -117,16 +117,16 @@ struct ethip_hdr struct arp_entry { - in_addr_t at_ipaddr; - struct uip_eth_addr at_ethaddr; - uint8 at_time; + in_addr_t at_ipaddr; + struct ether_addr at_ethaddr; + uint8 at_time; }; /**************************************************************************** * Private Data ****************************************************************************/ -static const struct uip_eth_addr broadcast_ethaddr = +static const struct ether_addr broadcast_ethaddr = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; static const uint16 broadcast_ipaddr[2] = {0xffff, 0xffff}; @@ -186,7 +186,7 @@ static void uip_arp_update(uint16 *pipaddr, uint8 *ethaddr) if (uip_ipaddr_cmp(ipaddr, tabptr->at_ipaddr)) { /* An old entry found, update this and return. */ - memcpy(tabptr->at_ethaddr.addr, ethaddr, IFHWADDRLEN); + memcpy(tabptr->at_ethaddr.ether_addr_octet, ethaddr, ETHER_ADDR_LEN); tabptr->at_time = g_arptime; return; @@ -234,7 +234,7 @@ static void uip_arp_update(uint16 *pipaddr, uint8 *ethaddr) */ tabptr->at_ipaddr = ipaddr; - memcpy(tabptr->at_ethaddr.addr, ethaddr, IFHWADDRLEN); + memcpy(tabptr->at_ethaddr.ether_addr_octet, ethaddr, ETHER_ADDR_LEN); tabptr->at_time = g_arptime; } @@ -327,10 +327,10 @@ void uip_arp_arpin(struct uip_driver_s *dev) ARPBUF->ah_opcode = HTONS(2); - memcpy(ARPBUF->ah_dhwaddr, ARPBUF->ah_shwaddr, IFHWADDRLEN); - memcpy(ARPBUF->ah_shwaddr, dev->d_mac.addr, IFHWADDRLEN); - memcpy(ETHBUF->src, dev->d_mac.addr, IFHWADDRLEN); - memcpy(ETHBUF->dest, ARPBUF->ah_dhwaddr, IFHWADDRLEN); + memcpy(ARPBUF->ah_dhwaddr, ARPBUF->ah_shwaddr, ETHER_ADDR_LEN); + memcpy(ARPBUF->ah_shwaddr, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN); + memcpy(ETHBUF->src, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN); + memcpy(ETHBUF->dest, ARPBUF->ah_dhwaddr, ETHER_ADDR_LEN); ARPBUF->ah_dipaddr[0] = ARPBUF->ah_sipaddr[0]; ARPBUF->ah_dipaddr[1] = ARPBUF->ah_sipaddr[1]; @@ -399,7 +399,7 @@ void uip_arp_out(struct uip_driver_s *dev) if (uiphdr_ipaddr_cmp(IPBUF->eh_destipaddr, broadcast_ipaddr)) { - memcpy(ETHBUF->dest, broadcast_ethaddr.addr, IFHWADDRLEN); + memcpy(ETHBUF->dest, broadcast_ethaddr.ether_addr_octet, ETHER_ADDR_LEN); } else { @@ -439,10 +439,10 @@ void uip_arp_out(struct uip_driver_s *dev) * overwrite the IP packet with an ARP request. */ - memset(ETHBUF->dest, 0xff, IFHWADDRLEN); - memset(ARPBUF->ah_dhwaddr, 0x00, IFHWADDRLEN); - memcpy(ETHBUF->src, dev->d_mac.addr, IFHWADDRLEN); - memcpy(ARPBUF->ah_shwaddr, dev->d_mac.addr, IFHWADDRLEN); + memset(ETHBUF->dest, 0xff, ETHER_ADDR_LEN); + memset(ARPBUF->ah_dhwaddr, 0x00, ETHER_ADDR_LEN); + memcpy(ETHBUF->src, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN); + memcpy(ARPBUF->ah_shwaddr, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN); uiphdr_ipaddr_copy(ARPBUF->ah_dipaddr, &ipaddr); uiphdr_ipaddr_copy(ARPBUF->ah_sipaddr, &dev->d_ipaddr); @@ -450,7 +450,7 @@ void uip_arp_out(struct uip_driver_s *dev) ARPBUF->ah_opcode = HTONS(ARP_REQUEST); ARPBUF->ah_hwtype = HTONS(ARP_HWTYPE_ETH); ARPBUF->ah_protocol = HTONS(UIP_ETHTYPE_IP); - ARPBUF->ah_hwlen = IFHWADDRLEN; + ARPBUF->ah_hwlen = ETHER_ADDR_LEN; ARPBUF->ah_protolen = 4; uip_arp_dump(ARPBUF); @@ -461,12 +461,12 @@ void uip_arp_out(struct uip_driver_s *dev) /* Build an ethernet header. */ - memcpy(ETHBUF->dest, tabptr->at_ethaddr.addr, IFHWADDRLEN); + memcpy(ETHBUF->dest, tabptr->at_ethaddr.ether_addr_octet, ETHER_ADDR_LEN); } /* Finish populating the ethernet header */ - memcpy(ETHBUF->src, dev->d_mac.addr, IFHWADDRLEN); + memcpy(ETHBUF->src, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN); ETHBUF->type = HTONS(UIP_ETHTYPE_IP); dev->d_len += UIP_LLH_LEN; } diff --git a/nuttx/net/uip/uip-neighbor.c b/nuttx/net/uip/uip-neighbor.c index 353fd11cf..a864178b4 100644 --- a/nuttx/net/uip/uip-neighbor.c +++ b/nuttx/net/uip/uip-neighbor.c @@ -32,11 +32,11 @@ * SUCH DAMAGE. */ -#include "uip-neighbor.h" - #include <string.h> #include <debug.h> +#include "uip-neighbor.h" + #define MAX_TIME 128 #ifdef UIP_NEIGHBOR_CONF_ENTRIES @@ -82,8 +82,9 @@ void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr) uint8 oldest_time; ndbg("Add neighbor: %02x:%02x:%02x:%02x:%02x:%02x\n", - addr->addr.addr[0], addr->addr.addr[1], addr->addr.addr[2], - addr->addr.addr[3], addr->addr.addr[4], addr->addr.addr[5]); + addr->addr.ether_addr_octet[0], addr->addr.ether_addr_octet[1], + addr->addr.ether_addr_octet[2], addr->addr.ether_addr_octet[3], + addr->addr.ether_addr_octet[4], addr->addr.ether_addr_octet[5]); /* Find the first unused entry or the oldest used entry. */ @@ -150,8 +151,9 @@ struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr) if (e != NULL) { ndbg("Lookup neighbor: %02x:%02x:%02x:%02x:%02x:%02x\n", - e->addr.addr.addr[0], e->addr.addr.addr[1], e->addr.addr.addr[2], - e->addr.addr.addr[3], e->addr.addr.addr[4], e->addr.addr.addr[5]); + e->addr.addr.ether_addr_octet[0], e->addr.addr.ether_addr_octet[1], + e->addr.addr.ether_addr_octet[2], e->addr.addr.ether_addr_octet[3], + e->addr.addr.ether_addr_octet[4], e->addr.addr.ether_addr_octet[5]); return &e->addr; } diff --git a/nuttx/net/uip/uip-neighbor.h b/nuttx/net/uip/uip-neighbor.h index 277b5f848..f939b1710 100644 --- a/nuttx/net/uip/uip-neighbor.h +++ b/nuttx/net/uip/uip-neighbor.h @@ -35,13 +35,14 @@ #define __UIP_NEIGHBOR_H__ #include <net/uip/uip.h> +#include <net/ethernet.h> struct uip_neighbor_addr { #if UIP_NEIGHBOR_CONF_ADDRTYPE UIP_NEIGHBOR_CONF_ADDRTYPE addr; #else - struct uip_eth_addr addr; + struct ether_addr addr; #endif }; |