Print this page
*** NO COMMENTS ***


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 1990 Mentat Inc.

  25  */
  26 
  27 #include <sys/types.h>
  28 #include <sys/stream.h>
  29 #include <sys/dlpi.h>
  30 #include <sys/stropts.h>
  31 #include <sys/sysmacros.h>
  32 #include <sys/strsubr.h>
  33 #include <sys/strlog.h>
  34 #include <sys/strsun.h>
  35 #include <sys/zone.h>
  36 #define _SUN_TPI_VERSION 2
  37 #include <sys/tihdr.h>
  38 #include <sys/xti_inet.h>
  39 #include <sys/ddi.h>
  40 #include <sys/suntpi.h>
  41 #include <sys/cmn_err.h>
  42 #include <sys/debug.h>
  43 #include <sys/kobj.h>
  44 #include <sys/modctl.h>


7815 ip_mdata_to_mhi(ill_t *ill, mblk_t *mp, struct mac_header_info_s *mhip)
7816 {
7817         mblk_t *bmp;
7818         struct ether_header *pether;
7819 
7820         bzero(mhip, sizeof (struct mac_header_info_s));
7821 
7822         mhip->mhi_dsttype = MAC_ADDRTYPE_UNICAST;
7823 
7824         pether = (struct ether_header *)((char *)mp->b_rptr
7825             - sizeof (struct ether_header));
7826 
7827         /*
7828          * Make sure the interface is an ethernet type, since we don't
7829          * know the header format for anything but Ethernet. Also make
7830          * sure we are pointing correctly above db_base.
7831          */
7832         if (ill->ill_type != IFT_ETHER)
7833                 return;
7834 










7835 retry:
7836         if ((uchar_t *)pether < mp->b_datap->db_base)
7837                 return;
7838 
7839         /* Is there a VLAN tag? */
7840         if (ill->ill_isv6) {
7841                 if (pether->ether_type != htons(ETHERTYPE_IPV6)) {
7842                         pether = (struct ether_header *)((char *)pether - 4);
7843                         goto retry;
7844                 }
7845         } else {
7846                 if (pether->ether_type != htons(ETHERTYPE_IP)) {
7847                         pether = (struct ether_header *)((char *)pether - 4);
7848                         goto retry;
7849                 }
7850         }
7851         mhip->mhi_daddr = (uchar_t *)&pether->ether_dhost;
7852         mhip->mhi_saddr = (uchar_t *)&pether->ether_shost;
7853 
7854         if (!(mhip->mhi_daddr[0] & 0x01))




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 1990 Mentat Inc.
  25  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 #include <sys/types.h>
  29 #include <sys/stream.h>
  30 #include <sys/dlpi.h>
  31 #include <sys/stropts.h>
  32 #include <sys/sysmacros.h>
  33 #include <sys/strsubr.h>
  34 #include <sys/strlog.h>
  35 #include <sys/strsun.h>
  36 #include <sys/zone.h>
  37 #define _SUN_TPI_VERSION 2
  38 #include <sys/tihdr.h>
  39 #include <sys/xti_inet.h>
  40 #include <sys/ddi.h>
  41 #include <sys/suntpi.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/debug.h>
  44 #include <sys/kobj.h>
  45 #include <sys/modctl.h>


7816 ip_mdata_to_mhi(ill_t *ill, mblk_t *mp, struct mac_header_info_s *mhip)
7817 {
7818         mblk_t *bmp;
7819         struct ether_header *pether;
7820 
7821         bzero(mhip, sizeof (struct mac_header_info_s));
7822 
7823         mhip->mhi_dsttype = MAC_ADDRTYPE_UNICAST;
7824 
7825         pether = (struct ether_header *)((char *)mp->b_rptr
7826             - sizeof (struct ether_header));
7827 
7828         /*
7829          * Make sure the interface is an ethernet type, since we don't
7830          * know the header format for anything but Ethernet. Also make
7831          * sure we are pointing correctly above db_base.
7832          */
7833         if (ill->ill_type != IFT_ETHER)
7834                 return;
7835 
7836         /*
7837          * PPP (including PPPoE) interfaces lie about being an ethernet, but
7838          * have other clues to indicate we should just bail now.  We exploit
7839          * the 0 broadcast address length.
7840          *
7841          * XXX KEBE ASKS --> what about IP multicast packets?
7842          */
7843         if (ill->ill_bcast_addr_length == 0)
7844                 return;
7845 
7846 retry:
7847         if ((uchar_t *)pether < mp->b_datap->db_base)
7848                 return;
7849 
7850         /* Is there a VLAN tag? */
7851         if (ill->ill_isv6) {
7852                 if (pether->ether_type != htons(ETHERTYPE_IPV6)) {
7853                         pether = (struct ether_header *)((char *)pether - 4);
7854                         goto retry;
7855                 }
7856         } else {
7857                 if (pether->ether_type != htons(ETHERTYPE_IP)) {
7858                         pether = (struct ether_header *)((char *)pether - 4);
7859                         goto retry;
7860                 }
7861         }
7862         mhip->mhi_daddr = (uchar_t *)&pether->ether_dhost;
7863         mhip->mhi_saddr = (uchar_t *)&pether->ether_shost;
7864 
7865         if (!(mhip->mhi_daddr[0] & 0x01))