1*0a6a1f1dSLionel Sambuc /* $NetBSD: if_ether.h,v 1.64 2014/07/28 14:24:48 ozaki-r Exp $ */
2f6aac1c3SLionel Sambuc
3f6aac1c3SLionel Sambuc /*
4f6aac1c3SLionel Sambuc * Copyright (c) 1982, 1986, 1993
5f6aac1c3SLionel Sambuc * The Regents of the University of California. All rights reserved.
6f6aac1c3SLionel Sambuc *
7f6aac1c3SLionel Sambuc * Redistribution and use in source and binary forms, with or without
8f6aac1c3SLionel Sambuc * modification, are permitted provided that the following conditions
9f6aac1c3SLionel Sambuc * are met:
10f6aac1c3SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
11f6aac1c3SLionel Sambuc * notice, this list of conditions and the following disclaimer.
12f6aac1c3SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
13f6aac1c3SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
14f6aac1c3SLionel Sambuc * documentation and/or other materials provided with the distribution.
15f6aac1c3SLionel Sambuc * 3. Neither the name of the University nor the names of its contributors
16f6aac1c3SLionel Sambuc * may be used to endorse or promote products derived from this software
17f6aac1c3SLionel Sambuc * without specific prior written permission.
18f6aac1c3SLionel Sambuc *
19f6aac1c3SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20f6aac1c3SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21f6aac1c3SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22f6aac1c3SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23f6aac1c3SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24f6aac1c3SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25f6aac1c3SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26f6aac1c3SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27f6aac1c3SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28f6aac1c3SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29f6aac1c3SLionel Sambuc * SUCH DAMAGE.
30f6aac1c3SLionel Sambuc *
31f6aac1c3SLionel Sambuc * @(#)if_ether.h 8.1 (Berkeley) 6/10/93
32f6aac1c3SLionel Sambuc */
33f6aac1c3SLionel Sambuc
34f6aac1c3SLionel Sambuc #ifndef _NET_IF_ETHER_H_
35f6aac1c3SLionel Sambuc #define _NET_IF_ETHER_H_
36f6aac1c3SLionel Sambuc
376cf86998SBen Gras #ifdef _KERNEL
386cf86998SBen Gras #ifdef _KERNEL_OPT
396cf86998SBen Gras #include "opt_mbuftrace.h"
406cf86998SBen Gras #endif
416cf86998SBen Gras #include <sys/mbuf.h>
426cf86998SBen Gras #endif
436cf86998SBen Gras
446cf86998SBen Gras #ifndef _STANDALONE
456cf86998SBen Gras #include <net/if.h>
466cf86998SBen Gras #endif
476cf86998SBen Gras
48f6aac1c3SLionel Sambuc /*
49f6aac1c3SLionel Sambuc * Some basic Ethernet constants.
50f6aac1c3SLionel Sambuc */
51f6aac1c3SLionel Sambuc #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
52f6aac1c3SLionel Sambuc #define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */
53f6aac1c3SLionel Sambuc #define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */
54f6aac1c3SLionel Sambuc #define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
55f6aac1c3SLionel Sambuc #define ETHER_MIN_LEN 64 /* minimum frame length, including CRC */
56f6aac1c3SLionel Sambuc #define ETHER_MAX_LEN 1518 /* maximum frame length, including CRC */
57f6aac1c3SLionel Sambuc #define ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including CRC */
58f6aac1c3SLionel Sambuc
59f6aac1c3SLionel Sambuc /*
60f6aac1c3SLionel Sambuc * Some Ethernet extensions.
61f6aac1c3SLionel Sambuc */
62f6aac1c3SLionel Sambuc #define ETHER_VLAN_ENCAP_LEN 4 /* length of 802.1Q VLAN encapsulation */
63f6aac1c3SLionel Sambuc #define ETHER_PPPOE_ENCAP_LEN 8 /* length of PPPoE encapsulation */
64f6aac1c3SLionel Sambuc
65f6aac1c3SLionel Sambuc /*
66f6aac1c3SLionel Sambuc * Ethernet address - 6 octets
67f6aac1c3SLionel Sambuc * this is only used by the ethers(3) functions.
68f6aac1c3SLionel Sambuc */
69f6aac1c3SLionel Sambuc struct ether_addr {
70f6aac1c3SLionel Sambuc uint8_t ether_addr_octet[ETHER_ADDR_LEN];
71f6aac1c3SLionel Sambuc } __packed;
72f6aac1c3SLionel Sambuc
7384d9c625SLionel Sambuc #if defined(__minix)
746cf86998SBen Gras #define ea_addr ether_addr_octet
756cf86998SBen Gras typedef struct ether_addr ether_addr_t;
7684d9c625SLionel Sambuc #endif /* defined(__minix) */
776cf86998SBen Gras
78f6aac1c3SLionel Sambuc /*
79f6aac1c3SLionel Sambuc * Structure of a 10Mb/s Ethernet header.
80f6aac1c3SLionel Sambuc */
81f6aac1c3SLionel Sambuc struct ether_header {
82f6aac1c3SLionel Sambuc uint8_t ether_dhost[ETHER_ADDR_LEN];
83f6aac1c3SLionel Sambuc uint8_t ether_shost[ETHER_ADDR_LEN];
84f6aac1c3SLionel Sambuc uint16_t ether_type;
85f6aac1c3SLionel Sambuc } __packed;
86f6aac1c3SLionel Sambuc
87f6aac1c3SLionel Sambuc #include <net/ethertypes.h>
88f6aac1c3SLionel Sambuc
89f6aac1c3SLionel Sambuc #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
90f6aac1c3SLionel Sambuc #define ETHER_IS_LOCAL(addr) (*(addr) & 0x02) /* is address local? */
91f6aac1c3SLionel Sambuc
92f6aac1c3SLionel Sambuc #define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
93f6aac1c3SLionel Sambuc #define ETHERMTU (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
94f6aac1c3SLionel Sambuc #define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
95f6aac1c3SLionel Sambuc
96f6aac1c3SLionel Sambuc /*
97f6aac1c3SLionel Sambuc * Compute the maximum frame size based on ethertype (i.e. possible
98f6aac1c3SLionel Sambuc * encapsulation) and whether or not an FCS is present.
99f6aac1c3SLionel Sambuc */
100f6aac1c3SLionel Sambuc #define ETHER_MAX_FRAME(ifp, etype, hasfcs) \
101f6aac1c3SLionel Sambuc ((ifp)->if_mtu + ETHER_HDR_LEN + \
102f6aac1c3SLionel Sambuc ((hasfcs) ? ETHER_CRC_LEN : 0) + \
103f6aac1c3SLionel Sambuc (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0) + \
104f6aac1c3SLionel Sambuc (((etype) == ETHERTYPE_PPPOE) ? ETHER_PPPOE_ENCAP_LEN : 0))
105f6aac1c3SLionel Sambuc
106f6aac1c3SLionel Sambuc /*
107f6aac1c3SLionel Sambuc * Ethernet CRC32 polynomials (big- and little-endian verions).
108f6aac1c3SLionel Sambuc */
109f6aac1c3SLionel Sambuc #define ETHER_CRC_POLY_LE 0xedb88320
110f6aac1c3SLionel Sambuc #define ETHER_CRC_POLY_BE 0x04c11db6
111f6aac1c3SLionel Sambuc
1126cf86998SBen Gras #ifndef _STANDALONE
1136cf86998SBen Gras
1146cf86998SBen Gras /*
1156cf86998SBen Gras * Ethernet-specific mbuf flags.
1166cf86998SBen Gras */
1176cf86998SBen Gras #define M_HASFCS M_LINK0 /* FCS included at end of frame */
1186cf86998SBen Gras #define M_PROMISC M_LINK1 /* this packet is not for us */
1196cf86998SBen Gras
1206cf86998SBen Gras #ifdef _KERNEL
1216cf86998SBen Gras /*
1226cf86998SBen Gras * Macro to map an IP multicast address to an Ethernet multicast address.
1236cf86998SBen Gras * The high-order 25 bits of the Ethernet address are statically assigned,
1246cf86998SBen Gras * and the low-order 23 bits are taken from the low end of the IP address.
1256cf86998SBen Gras */
1266cf86998SBen Gras #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
1276cf86998SBen Gras /* const struct in_addr *ipaddr; */ \
1286cf86998SBen Gras /* uint8_t enaddr[ETHER_ADDR_LEN]; */ \
1296cf86998SBen Gras do { \
1306cf86998SBen Gras (enaddr)[0] = 0x01; \
1316cf86998SBen Gras (enaddr)[1] = 0x00; \
1326cf86998SBen Gras (enaddr)[2] = 0x5e; \
1336cf86998SBen Gras (enaddr)[3] = ((const uint8_t *)ipaddr)[1] & 0x7f; \
1346cf86998SBen Gras (enaddr)[4] = ((const uint8_t *)ipaddr)[2]; \
1356cf86998SBen Gras (enaddr)[5] = ((const uint8_t *)ipaddr)[3]; \
1366cf86998SBen Gras } while (/*CONSTCOND*/0)
1376cf86998SBen Gras /*
1386cf86998SBen Gras * Macro to map an IP6 multicast address to an Ethernet multicast address.
1396cf86998SBen Gras * The high-order 16 bits of the Ethernet address are statically assigned,
1406cf86998SBen Gras * and the low-order 32 bits are taken from the low end of the IP6 address.
1416cf86998SBen Gras */
1426cf86998SBen Gras #define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \
1436cf86998SBen Gras /* struct in6_addr *ip6addr; */ \
1446cf86998SBen Gras /* uint8_t enaddr[ETHER_ADDR_LEN]; */ \
1456cf86998SBen Gras { \
1466cf86998SBen Gras (enaddr)[0] = 0x33; \
1476cf86998SBen Gras (enaddr)[1] = 0x33; \
1486cf86998SBen Gras (enaddr)[2] = ((const uint8_t *)ip6addr)[12]; \
1496cf86998SBen Gras (enaddr)[3] = ((const uint8_t *)ip6addr)[13]; \
1506cf86998SBen Gras (enaddr)[4] = ((const uint8_t *)ip6addr)[14]; \
1516cf86998SBen Gras (enaddr)[5] = ((const uint8_t *)ip6addr)[15]; \
1526cf86998SBen Gras }
1536cf86998SBen Gras #endif
1546cf86998SBen Gras
1556cf86998SBen Gras struct mii_data;
1566cf86998SBen Gras
1576cf86998SBen Gras struct ethercom;
1586cf86998SBen Gras
1596cf86998SBen Gras typedef int (*ether_cb_t)(struct ethercom *);
1606cf86998SBen Gras
1616cf86998SBen Gras /*
1626cf86998SBen Gras * Structure shared between the ethernet driver modules and
1636cf86998SBen Gras * the multicast list code. For example, each ec_softc or il_softc
1646cf86998SBen Gras * begins with this structure.
1656cf86998SBen Gras */
1666cf86998SBen Gras struct ethercom {
1676cf86998SBen Gras struct ifnet ec_if; /* network-visible interface */
1686cf86998SBen Gras LIST_HEAD(, ether_multi) ec_multiaddrs; /* list of ether multicast
1696cf86998SBen Gras addrs */
1706cf86998SBen Gras int ec_multicnt; /* length of ec_multiaddrs
1716cf86998SBen Gras list */
1726cf86998SBen Gras int ec_capabilities; /* capabilities, provided by
1736cf86998SBen Gras driver */
1746cf86998SBen Gras int ec_capenable; /* tells hardware which
1756cf86998SBen Gras capabilities to enable */
1766cf86998SBen Gras
1776cf86998SBen Gras int ec_nvlans; /* # VLANs on this interface */
1786cf86998SBen Gras /* The device handle for the MII bus child device. */
1796cf86998SBen Gras struct mii_data *ec_mii;
1806cf86998SBen Gras /* Called after a change to ec_if.if_flags. Returns
1816cf86998SBen Gras * ENETRESET if the device should be reinitialized with
1826cf86998SBen Gras * ec_if.if_init, 0 on success, not 0 on failure.
1836cf86998SBen Gras */
1846cf86998SBen Gras ether_cb_t ec_ifflags_cb;
1856cf86998SBen Gras #ifdef MBUFTRACE
1866cf86998SBen Gras struct mowner ec_rx_mowner; /* mbufs received */
1876cf86998SBen Gras struct mowner ec_tx_mowner; /* mbufs transmitted */
1886cf86998SBen Gras #endif
1896cf86998SBen Gras };
1906cf86998SBen Gras
1916cf86998SBen Gras #define ETHERCAP_VLAN_MTU 0x00000001 /* VLAN-compatible MTU */
1926cf86998SBen Gras #define ETHERCAP_VLAN_HWTAGGING 0x00000002 /* hardware VLAN tag support */
1936cf86998SBen Gras #define ETHERCAP_JUMBO_MTU 0x00000004 /* 9000 byte MTU supported */
194*0a6a1f1dSLionel Sambuc #define ETHERCAP_MASK 0x00000007
1956cf86998SBen Gras
19684d9c625SLionel Sambuc #define ECCAPBITS \
19784d9c625SLionel Sambuc "\020" \
19884d9c625SLionel Sambuc "\1VLAN_MTU" \
19984d9c625SLionel Sambuc "\2VLAN_HWTAGGING" \
20084d9c625SLionel Sambuc "\3JUMBO_MTU"
20184d9c625SLionel Sambuc
20284d9c625SLionel Sambuc /* ioctl() for Ethernet capabilities */
20384d9c625SLionel Sambuc struct eccapreq {
20484d9c625SLionel Sambuc char eccr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
20584d9c625SLionel Sambuc int eccr_capabilities; /* supported capabiliites */
20684d9c625SLionel Sambuc int eccr_capenable; /* capabilities enabled */
20784d9c625SLionel Sambuc };
20884d9c625SLionel Sambuc
2096cf86998SBen Gras #ifdef _KERNEL
2106cf86998SBen Gras extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN];
2116cf86998SBen Gras extern const uint8_t ethermulticastaddr_slowprotocols[ETHER_ADDR_LEN];
2126cf86998SBen Gras extern const uint8_t ether_ipmulticast_min[ETHER_ADDR_LEN];
2136cf86998SBen Gras extern const uint8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
2146cf86998SBen Gras
2156cf86998SBen Gras void ether_set_ifflags_cb(struct ethercom *, ether_cb_t);
2166cf86998SBen Gras int ether_ioctl(struct ifnet *, u_long, void *);
2176cf86998SBen Gras int ether_addmulti(const struct sockaddr *, struct ethercom *);
2186cf86998SBen Gras int ether_delmulti(const struct sockaddr *, struct ethercom *);
2196cf86998SBen Gras int ether_multiaddr(const struct sockaddr *, uint8_t[], uint8_t[]);
22084d9c625SLionel Sambuc void ether_input(struct ifnet *, struct mbuf *);
2216cf86998SBen Gras #endif /* _KERNEL */
2226cf86998SBen Gras
2236cf86998SBen Gras /*
2246cf86998SBen Gras * Ethernet multicast address structure. There is one of these for each
2256cf86998SBen Gras * multicast address or range of multicast addresses that we are supposed
2266cf86998SBen Gras * to listen to on a particular interface. They are kept in a linked list,
2276cf86998SBen Gras * rooted in the interface's ethercom structure.
2286cf86998SBen Gras */
2296cf86998SBen Gras struct ether_multi {
2306cf86998SBen Gras uint8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */
2316cf86998SBen Gras uint8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
2326cf86998SBen Gras u_int enm_refcount; /* no. claims to this addr/range */
2336cf86998SBen Gras LIST_ENTRY(ether_multi) enm_list;
2346cf86998SBen Gras };
235*0a6a1f1dSLionel Sambuc
236*0a6a1f1dSLionel Sambuc struct ether_multi_sysctl {
237*0a6a1f1dSLionel Sambuc u_int enm_refcount;
238*0a6a1f1dSLionel Sambuc uint8_t enm_addrlo[ETHER_ADDR_LEN];
239*0a6a1f1dSLionel Sambuc uint8_t enm_addrhi[ETHER_ADDR_LEN];
240*0a6a1f1dSLionel Sambuc };
2416cf86998SBen Gras
2426cf86998SBen Gras /*
2436cf86998SBen Gras * Structure used by macros below to remember position when stepping through
2446cf86998SBen Gras * all of the ether_multi records.
2456cf86998SBen Gras */
2466cf86998SBen Gras struct ether_multistep {
2476cf86998SBen Gras struct ether_multi *e_enm;
2486cf86998SBen Gras };
2496cf86998SBen Gras
2506cf86998SBen Gras /*
2516cf86998SBen Gras * Macro for looking up the ether_multi record for a given range of Ethernet
2526cf86998SBen Gras * multicast addresses connected to a given ethercom structure. If no matching
2536cf86998SBen Gras * record is found, "enm" returns NULL.
2546cf86998SBen Gras */
2556cf86998SBen Gras #define ETHER_LOOKUP_MULTI(addrlo, addrhi, ec, enm) \
2566cf86998SBen Gras /* uint8_t addrlo[ETHER_ADDR_LEN]; */ \
2576cf86998SBen Gras /* uint8_t addrhi[ETHER_ADDR_LEN]; */ \
2586cf86998SBen Gras /* struct ethercom *ec; */ \
2596cf86998SBen Gras /* struct ether_multi *enm; */ \
2606cf86998SBen Gras { \
2616cf86998SBen Gras for ((enm) = LIST_FIRST(&(ec)->ec_multiaddrs); \
2626cf86998SBen Gras (enm) != NULL && \
2636cf86998SBen Gras (memcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
2646cf86998SBen Gras memcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
2656cf86998SBen Gras (enm) = LIST_NEXT((enm), enm_list)); \
2666cf86998SBen Gras }
2676cf86998SBen Gras
2686cf86998SBen Gras /*
2696cf86998SBen Gras * Macro to step through all of the ether_multi records, one at a time.
2706cf86998SBen Gras * The current position is remembered in "step", which the caller must
2716cf86998SBen Gras * provide. ETHER_FIRST_MULTI(), below, must be called to initialize "step"
2726cf86998SBen Gras * and get the first record. Both macros return a NULL "enm" when there
2736cf86998SBen Gras * are no remaining records.
2746cf86998SBen Gras */
2756cf86998SBen Gras #define ETHER_NEXT_MULTI(step, enm) \
2766cf86998SBen Gras /* struct ether_multistep step; */ \
2776cf86998SBen Gras /* struct ether_multi *enm; */ \
2786cf86998SBen Gras { \
2796cf86998SBen Gras if (((enm) = (step).e_enm) != NULL) \
2806cf86998SBen Gras (step).e_enm = LIST_NEXT((enm), enm_list); \
2816cf86998SBen Gras }
2826cf86998SBen Gras
2836cf86998SBen Gras #define ETHER_FIRST_MULTI(step, ec, enm) \
2846cf86998SBen Gras /* struct ether_multistep step; */ \
2856cf86998SBen Gras /* struct ethercom *ec; */ \
2866cf86998SBen Gras /* struct ether_multi *enm; */ \
2876cf86998SBen Gras { \
2886cf86998SBen Gras (step).e_enm = LIST_FIRST(&(ec)->ec_multiaddrs); \
2896cf86998SBen Gras ETHER_NEXT_MULTI((step), (enm)); \
2906cf86998SBen Gras }
2916cf86998SBen Gras
2926cf86998SBen Gras #ifdef _KERNEL
2936cf86998SBen Gras
2946cf86998SBen Gras /*
2956cf86998SBen Gras * Ethernet 802.1Q VLAN structures.
2966cf86998SBen Gras */
2976cf86998SBen Gras
2986cf86998SBen Gras /* add VLAN tag to input/received packet */
2996cf86998SBen Gras static inline int vlan_input_tag(struct ifnet *, struct mbuf *, u_int);
3006cf86998SBen Gras static inline int
vlan_input_tag(struct ifnet * ifp,struct mbuf * m,u_int vlanid)3016cf86998SBen Gras vlan_input_tag(struct ifnet *ifp, struct mbuf *m, u_int vlanid)
3026cf86998SBen Gras {
3036cf86998SBen Gras struct m_tag *mtag;
3046cf86998SBen Gras mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), M_NOWAIT);
3056cf86998SBen Gras if (mtag == NULL) {
3066cf86998SBen Gras ifp->if_ierrors++;
3076cf86998SBen Gras printf("%s: unable to allocate VLAN tag\n", ifp->if_xname);
3086cf86998SBen Gras m_freem(m);
3096cf86998SBen Gras return 1;
3106cf86998SBen Gras }
3116cf86998SBen Gras *(u_int *)(mtag + 1) = vlanid;
3126cf86998SBen Gras m_tag_prepend(m, mtag);
3136cf86998SBen Gras return 0;
3146cf86998SBen Gras }
3156cf86998SBen Gras
3166cf86998SBen Gras #define VLAN_INPUT_TAG(ifp, m, vlanid, _errcase) \
3176cf86998SBen Gras if (vlan_input_tag(ifp, m, vlanid) != 0) { \
3186cf86998SBen Gras _errcase; \
3196cf86998SBen Gras }
3206cf86998SBen Gras
3216cf86998SBen Gras /* extract VLAN tag from output/trasmit packet */
3226cf86998SBen Gras #define VLAN_OUTPUT_TAG(ec, m0) \
3236cf86998SBen Gras (VLAN_ATTACHED(ec) ? m_tag_find((m0), PACKET_TAG_VLAN, NULL) : NULL)
3246cf86998SBen Gras
3256cf86998SBen Gras /* extract VLAN ID value from a VLAN tag */
3266cf86998SBen Gras #define VLAN_TAG_VALUE(mtag) \
3276cf86998SBen Gras ((*(u_int *)(mtag + 1)) & 4095)
3286cf86998SBen Gras
3296cf86998SBen Gras /* test if any VLAN is configured for this interface */
3306cf86998SBen Gras #define VLAN_ATTACHED(ec) ((ec)->ec_nvlans > 0)
3316cf86998SBen Gras
332*0a6a1f1dSLionel Sambuc void etherinit(void);
3336cf86998SBen Gras void ether_ifattach(struct ifnet *, const uint8_t *);
3346cf86998SBen Gras void ether_ifdetach(struct ifnet *);
3356cf86998SBen Gras int ether_mediachange(struct ifnet *);
3366cf86998SBen Gras void ether_mediastatus(struct ifnet *, struct ifmediareq *);
3376cf86998SBen Gras
3386cf86998SBen Gras char *ether_sprintf(const uint8_t *);
3396cf86998SBen Gras char *ether_snprintf(char *, size_t, const uint8_t *);
3406cf86998SBen Gras
3416cf86998SBen Gras uint32_t ether_crc32_le(const uint8_t *, size_t);
3426cf86998SBen Gras uint32_t ether_crc32_be(const uint8_t *, size_t);
3436cf86998SBen Gras
3446cf86998SBen Gras int ether_aton_r(u_char *, size_t, const char *);
3456cf86998SBen Gras #else
346f6aac1c3SLionel Sambuc /*
347f6aac1c3SLionel Sambuc * Prototype ethers(3) functions.
348f6aac1c3SLionel Sambuc */
349f6aac1c3SLionel Sambuc #include <sys/cdefs.h>
350f6aac1c3SLionel Sambuc __BEGIN_DECLS
351f6aac1c3SLionel Sambuc char * ether_ntoa(const struct ether_addr *);
352f6aac1c3SLionel Sambuc struct ether_addr *
353f6aac1c3SLionel Sambuc ether_aton(const char *);
354f6aac1c3SLionel Sambuc int ether_ntohost(char *, const struct ether_addr *);
355f6aac1c3SLionel Sambuc int ether_hostton(const char *, struct ether_addr *);
356f6aac1c3SLionel Sambuc int ether_line(const char *, struct ether_addr *, char *);
357f6aac1c3SLionel Sambuc __END_DECLS
3586cf86998SBen Gras #endif
3596cf86998SBen Gras
3606cf86998SBen Gras #endif /* _STANDALONE */
361f6aac1c3SLionel Sambuc
362f6aac1c3SLionel Sambuc #endif /* !_NET_IF_ETHER_H_ */
363