2016-05-30 18:54:04 +08:00
|
|
|
/** @file
|
|
|
|
@brief Ethernet
|
|
|
|
|
|
|
|
This is not to be included by the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-05-30 18:54:04 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETHERNET_H
|
|
|
|
#define __ETHERNET_H
|
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-06-07 18:35:13 +08:00
|
|
|
#include <stdbool.h>
|
2016-05-30 18:54:04 +08:00
|
|
|
|
|
|
|
#include <net/net_ip.h>
|
2017-04-03 23:14:35 +08:00
|
|
|
#include <net/net_pkt.h>
|
2016-12-02 21:47:29 +08:00
|
|
|
#include <misc/util.h>
|
2016-05-30 18:54:04 +08:00
|
|
|
|
2017-04-10 19:03:41 +08:00
|
|
|
#define NET_ETH_HDR(pkt) ((struct net_eth_hdr *)net_pkt_ll(pkt))
|
2016-06-03 17:40:19 +08:00
|
|
|
|
2016-12-02 21:47:29 +08:00
|
|
|
#define NET_ETH_PTYPE_ARP 0x0806
|
|
|
|
#define NET_ETH_PTYPE_IP 0x0800
|
|
|
|
#define NET_ETH_PTYPE_IPV6 0x86dd
|
|
|
|
|
|
|
|
#define NET_ETH_MINIMAL_FRAME_SIZE 60
|
2016-05-30 18:54:04 +08:00
|
|
|
|
|
|
|
struct net_eth_addr {
|
2017-04-21 22:27:50 +08:00
|
|
|
u8_t addr[6];
|
2016-05-30 18:54:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct net_eth_hdr {
|
|
|
|
struct net_eth_addr dst;
|
|
|
|
struct net_eth_addr src;
|
2017-04-21 22:27:50 +08:00
|
|
|
u16_t type;
|
2016-05-30 18:54:04 +08:00
|
|
|
} __packed;
|
|
|
|
|
2016-06-07 18:35:13 +08:00
|
|
|
static inline bool net_eth_is_addr_broadcast(struct net_eth_addr *addr)
|
|
|
|
{
|
|
|
|
if (addr->addr[0] == 0xff &&
|
|
|
|
addr->addr[1] == 0xff &&
|
|
|
|
addr->addr[2] == 0xff &&
|
|
|
|
addr->addr[3] == 0xff &&
|
|
|
|
addr->addr[4] == 0xff &&
|
|
|
|
addr->addr[5] == 0xff) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool net_eth_is_addr_multicast(struct net_eth_addr *addr)
|
|
|
|
{
|
|
|
|
if (addr->addr[0] == 0x33 &&
|
|
|
|
addr->addr[1] == 0x33) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-08 19:13:27 +08:00
|
|
|
const struct net_eth_addr *net_eth_broadcast_addr(void);
|
|
|
|
|
2016-05-30 18:54:04 +08:00
|
|
|
#endif /* __ETHERNET_H */
|