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
This commit is contained in:
patacongo
2007-12-11 14:28:16 +00:00
parent ea50c50b47
commit 23e67efbbd
16 changed files with 137 additions and 52 deletions
+5
View File
@@ -272,3 +272,8 @@
* Found and fixed several problems in uIP when compiled for ARM with optimization.
0.3.5 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Added inet_ntoa() and ether_ntoa()
* Added netdev_foreach() to support traversal of registered network devices
* Added support for 'ifconfig' command to NSH (examples/nsh)
* Moved MAC and ethernet definitions to net/ethernet.h
+7 -2
View File
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: December 10, 2007</p>
<p>Last Updated: December 11, 2007</p>
</td>
</tr>
</table>
@@ -471,7 +471,7 @@
<td><br></td>
<td>
<p>
<b>TI TMS320C5471</b> (also called a <b>C5471</b> or <b>TMS320DM180</b>).
<b>TI TMS320C5471</b> (also called <b>C5471</b> or <b>TMS320DA180</b> or <b>DA180</a>).
NuttX operates on the ARM7 of this dual core processor.
This port uses the <a href="http://www.spectrumdigital.com/">Spectrum Digital</a>
evaluation board with a GNU arm-elf toolchain*.
@@ -966,6 +966,11 @@ Other memory:
<pre><ul>
0.3.5 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Added inet_ntoa() and ether_ntoa()
* Added netdev_foreach() to support traversal of registered network devices
* Added support for 'ifconfig' command to NSH (examples/nsh)
* Moved MAC and ethernet definitions to net/ethernet.h
</pre></ul>
<table width ="100%">
+2 -1
View File
@@ -57,6 +57,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <net/ethernet.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arp.h>
#include <net/uip/uip-arch.h>
@@ -2054,7 +2055,7 @@ static void c5471_reset(struct c5471_driver_s *c5471)
static void c5471_macassign(struct c5471_driver_s *c5471)
{
struct uip_driver_s *dev = &c5471->c_dev;
uint8 *mptr = dev->d_mac.addr;
uint8 *mptr = dev->d_mac.ether_addr_octet;
register uint32 tmp;
ndbg("MAC: %0x:%0x:%0x:%0x:%0x:%0x\n",
+4 -3
View File
@@ -50,6 +50,7 @@
#include <sched.h>
#include <nuttx/net.h>
#include <net/ethernet.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#include <net/uip/uip-arp.h>
@@ -106,9 +107,9 @@ void timer_reset(struct timer *t)
#ifdef CONFIG_NET_PROMISCUOUS
# define up_comparemac(a,b) (0)
#else
static inline int up_comparemac(struct uip_eth_addr *paddr1, struct uip_eth_addr *paddr2)
static inline int up_comparemac(struct ether_addr *paddr1, struct ether_addr *paddr2)
{
return memcmp(paddr1, paddr2, sizeof(struct uip_eth_addr));
return memcmp(paddr1, paddr2, sizeof(struct ether_addr));
}
#endif
@@ -212,7 +213,7 @@ int uipdriver_init(void)
timer_set(&g_periodic_timer, 500);
tapdev_init();
(void)tapdev_getmacaddr(g_sim_dev.d_mac.addr);
(void)tapdev_getmacaddr(g_sim_dev.d_mac.ether_addr_octet);
/* Register the device with the OS so that socket IOCTLs can be performed */
+4 -4
View File
@@ -283,10 +283,10 @@ configs/sim
configs/c5471evm
This is a port to the Spectrum Digital C5471 evaluation board. The
C5471 is a dual core processor from TI with an ARM7TDMI general purpose
processor and a c54 SDP. NuttX runs on the ARM core and is built with
with a GNU arm-elf toolchain*. This port is complete, verified, and
included in the NuttX release.
TMS320C5471 is a dual core processor from TI with an ARM7TDMI general
purpose processor and a c54 DSP. It is also known as TMS320DA180 or just DA180.
NuttX runs on the ARM core and is built with with a GNU arm-elf toolchain*.
This port is complete, verified, and included in the NuttX release.
configs/mcu123-lpc214x
This is a port to the mcu123.com lpc214x development board.
+3 -2
View File
@@ -61,6 +61,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <net/ethernet.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arp.h>
#include <net/uip/uip-arch.h>
@@ -1725,8 +1726,8 @@ int dm9x_initialize(void)
/* Read the MAC address */
mptr = g_dm9x[0].dm_dev.d_mac.addr;
for (i = 0, j = DM9X_PAB0; i < 6; i++, j++)
mptr = g_dm9x[0].dm_dev.d_mac.ether_addr_octet;
for (i = 0, j = DM9X_PAB0; i < ETHER_ADDR_LEN; i++, j++)
{
mptr[i] = getreg(j);
}
+1 -1
View File
@@ -581,7 +581,7 @@ int skel_initialize(void)
g_skel[0].sk_txpoll = wd_create(); /* Create periodic poll timer */
g_skel[0].sk_txtimeout = wd_create(); /* Create TX timeout timer */
/* Read the MAC address from the hardware into g_skel[0].sk_dev.d_mac.addr */
/* Read the MAC address from the hardware into g_skel[0].sk_dev.d_mac.ether_addr_octet */
/* Register the device with the OS so that socket IOCTLs can be performed */
+71
View File
@@ -0,0 +1,71 @@
/****************************************************************************
* net/ethernet.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __NET_ETHERNET_H
#define __NET_ETHERNET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
/****************************************************************************
* Definitions
****************************************************************************/
#define ETHER_ADDR_LEN 6
/****************************************************************************
* Type Definitions
****************************************************************************/
struct ether_addr
{
uint8 ether_addr_octet[6]; /* 48-bit Ethernet address */
};
struct ether_header
{
uint8 ether_dhost[ETHER_ADDR_LEN]; /* Destination Ethernet address */
uint8 ether_shost[ETHER_ADDR_LEN]; /* Source Ethernet address */
uint16 ether_type; /* Ethernet packet type*/
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#endif /* __NET_ETHERNET_H */
+2 -1
View File
@@ -53,6 +53,7 @@
****************************************************************************/
#include <net/uip/uipopt.h>
#include <net/ethernet.h>
/****************************************************************************
* Definitions
@@ -86,7 +87,7 @@ struct uip_driver_s
/* Device identitity */
struct uip_eth_addr d_mac; /* Device MAC address */
struct ether_addr d_mac; /* Device MAC address */
/* Network identity */
+2 -1
View File
@@ -36,10 +36,11 @@
#include <sys/types.h>
#include <nuttx/compiler.h>
#include <net/ethernet.h>
#include <net/uip/uip.h>
/* The Ethernet header -- 14 bytes. The first two fields are type 'struct
* uip_eth_addr but are represented as a simple byte array here because
* ether_addr but are represented as a simple byte array here because
* some compilers refuse to pack 6 byte structures.
*/
-7
View File
@@ -210,13 +210,6 @@ struct uip_stats
};
#endif /* CONFIG_NET_STATISTICS */
/* Representation of a 48-bit Ethernet address */
struct uip_eth_addr
{
uint8 addr[6];
};
/****************************************************************************
* Public Data
****************************************************************************/
+3 -2
View File
@@ -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 */
+4 -2
View File
@@ -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;
+19 -19
View File
@@ -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;
}
+8 -6
View File
@@ -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;
}
+2 -1
View File
@@ -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
};