ethernet.h revision ff3aea39f71c371be25b08deb9efed41f1c95983
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ethernet.h header for common Ethernet declarations.
*/
#ifndef _SYS_ETHERNET_H
#define _SYS_ETHERNET_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Ethernet address - 6 octets
*/
/*
* Ethernet address - 6 octets
*/
struct ether_addr {
};
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
struct ether_addr ether_dhost;
struct ether_addr ether_shost;
};
#define ETHER_CFI 0
struct ether_vlan_header {
struct ether_addr ether_dhost;
struct ether_addr ether_shost;
};
/*
* The VLAN tag. Available for applications that cannot make use of struct
* ether_vlan_header because they assume Ethernet encapsulation.
*/
struct ether_vlan_extinfo {
};
/* under IEEE 802.3 rules */
/*
* The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
* (type-ETHERTYPE_TRAIL)*512 bytes of data followed
* by an ETHER type (as given above) and then the (variable-length) header.
*/
#define ETHERTYPE_NTRAILER (16)
/*
* Compare two Ethernet addresses - assumes that the two given
* pointers can be referenced as shorts. On architectures
* where this is not the case, use bcmp instead. Note that like
* bcmp, we return zero if they are the SAME.
*/
((short *)b)[1] != ((short *)a)[1] || \
((short *)b)[0] != ((short *)a)[0])
#else
#endif
/*
* Copy Ethernet addresses from a to b - assumes that the two given
* pointers can be referenced as shorts. On architectures
* where this is not the case, use bcopy instead.
*/
#define ether_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \
((short *)b)[1] = ((short *)a)[1]; ((short *)b)[2] = ((short *)a)[2]; }
#else
#endif
#ifdef _KERNEL
extern char *ether_sprintf(struct ether_addr *);
extern int ether_aton(char *, uchar_t *);
#else /* _KERNEL */
extern char *ether_ntoa(const struct ether_addr *);
extern char *ether_ntoa_r(const struct ether_addr *, char *);
extern struct ether_addr *ether_aton(const char *);
extern int ether_ntohost(char *, const struct ether_addr *);
extern int ether_hostton(const char *, struct ether_addr *);
extern int ether_line(const char *, struct ether_addr *, char *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ETHERNET_H */