Back to index

glibc  2.9
if_ether.h
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef __NETINET_IF_ETHER_H
00020 
00021 #define __NETINET_IF_ETHER_H       1
00022 #include <features.h>
00023 #include <sys/types.h>
00024 
00025 /* Get definitions from kernel header file.  */
00026 #include <linux/if_ether.h>
00027 
00028 #ifdef __USE_BSD
00029 /*
00030  * Copyright (c) 1982, 1986, 1993
00031  *     The Regents of the University of California.  All rights reserved.
00032  *
00033  * Redistribution and use in source and binary forms, with or without
00034  * modification, are permitted provided that the following conditions
00035  * are met:
00036  * 1. Redistributions of source code must retain the above copyright
00037  *    notice, this list of conditions and the following disclaimer.
00038  * 2. Redistributions in binary form must reproduce the above copyright
00039  *    notice, this list of conditions and the following disclaimer in the
00040  *    documentation and/or other materials provided with the distribution.
00041  * 4. Neither the name of the University nor the names of its contributors
00042  *    may be used to endorse or promote products derived from this software
00043  *    without specific prior written permission.
00044  *
00045  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00046  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00047  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00048  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00049  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00050  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00051  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00052  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00053  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00054  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00055  * SUCH DAMAGE.
00056  *
00057  *     @(#)if_ether.h       8.3 (Berkeley) 5/2/95
00058  *     $FreeBSD$
00059  */
00060 
00061 #include <net/ethernet.h>
00062 #include <net/if_arp.h>
00063 
00064 __BEGIN_DECLS
00065 /*
00066  * Ethernet Address Resolution Protocol.
00067  *
00068  * See RFC 826 for protocol description.  Structure below is adapted
00069  * to resolving internet addresses.  Field names used correspond to
00070  * RFC 826.
00071  */
00072 struct ether_arp {
00073        struct arphdr ea_hdr;              /* fixed-size header */
00074        u_int8_t arp_sha[ETH_ALEN]; /* sender hardware address */
00075        u_int8_t arp_spa[4];        /* sender protocol address */
00076        u_int8_t arp_tha[ETH_ALEN]; /* target hardware address */
00077        u_int8_t arp_tpa[4];        /* target protocol address */
00078 };
00079 #define       arp_hrd       ea_hdr.ar_hrd
00080 #define       arp_pro       ea_hdr.ar_pro
00081 #define       arp_hln       ea_hdr.ar_hln
00082 #define       arp_pln       ea_hdr.ar_pln
00083 #define       arp_op ea_hdr.ar_op
00084 
00085 /*
00086  * Macro to map an IP multicast address to an Ethernet multicast address.
00087  * The high-order 25 bits of the Ethernet address are statically assigned,
00088  * and the low-order 23 bits are taken from the low end of the IP address.
00089  */
00090 #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
00091        /* struct in_addr *ipaddr; */ \
00092        /* u_char enaddr[ETH_ALEN];    */ \
00093 { \
00094        (enaddr)[0] = 0x01; \
00095        (enaddr)[1] = 0x00; \
00096        (enaddr)[2] = 0x5e; \
00097        (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \
00098        (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \
00099        (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \
00100 }
00101 
00102 __END_DECLS
00103 #endif /* __USE_BSD */
00104 
00105 #endif /* netinet/if_ether.h */