The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/net/net_osdep.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*
   26  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
   27  * All rights reserved.
   28  *
   29  * Redistribution and use in source and binary forms, with or without
   30  * modification, are permitted provided that the following conditions
   31  * are met:
   32  * 1. Redistributions of source code must retain the above copyright
   33  *    notice, this list of conditions and the following disclaimer.
   34  * 2. Redistributions in binary form must reproduce the above copyright
   35  *    notice, this list of conditions and the following disclaimer in the
   36  *    documentation and/or other materials provided with the distribution.
   37  * 3. Neither the name of the project nor the names of its contributors
   38  *    may be used to endorse or promote products derived from this software
   39  *    without specific prior written permission.
   40  *
   41  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
   42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
   45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   51  * SUCH DAMAGE.
   52  */
   53 /*
   54  * glue for kernel code programming differences.
   55  */
   56 
   57 /*
   58  * OS dependencies:
   59  *
   60  * - whether the IPv4 input routine convert the byte order of some fileds
   61  *   of the IP header (x: convert to the host byte order, s: strip the header
   62  *   length for possible reassembly)
   63  *          ip_len ip_id ip_off
   64  * bsdi3:       xs     x      x
   65  * bsdi4:       xs            x
   66  * FreeBSD:     xs            x
   67  * NetBSD:       x            x
   68  * OpenBSD:     xs     x      x
   69  *
   70  * - ifa_ifwithaf()
   71  *   bsdi[34], netbsd, and openbsd define it in sys/net/if.c
   72  *   freebsd (all versions) does not have it.
   73  *  
   74  * - struct rt_addrinfo
   75  *   bsdi4, netbsd 1.5R and beyond: rti_addrs, rti_info[], rti_flags, rti_ifa,
   76  *      rti_ifp, and rti_rtm.
   77  *   others: rti_addrs and rti_info[] only.
   78  *
   79  * - ifa->ifa_rtrequest
   80  *   bsdi4, netbsd 1.5R and beyond: rt_addrinfo *
   81  *   others: sockaddr * (note that sys/net/route.c:rtrequest() has an unsafe
   82  *      typecast code, from 4.3BSD-reno)
   83  *
   84  * - side effects of rtrequest{,1}(RTM_DELETE)
   85  *      BSDI[34]: delete all cloned routes underneath the route.
   86  *      FreeBSD[234]: delete all protocol-cloned routes underneath the route.
   87  *                    note that cloned routes from an interface direct route
   88  *                    still remain.
   89  *      NetBSD: 1.5 have no side effects.  KAME/netbsd15, and post-1.5R, have
   90  *              the same effects as of BSDI.
   91  *      OpenBSD: have no side effects.  KAME/openbsd has the same effects as
   92  *              of BSDI (the change is not merged - yet).
   93  *
   94  * - privileged process
   95  *      NetBSD, FreeBSD 3
   96  *              struct proc *p;
   97  *              if (p && !suser(p->p_ucred, &p->p_acflag))
   98  *                      privileged;
   99  *      FreeBSD 4
  100  *              struct proc *p;
  101  *              if (p && !suser(p))
  102  *                      privileged;
  103  *      OpenBSD, BSDI [34], FreeBSD 2
  104  *              struct socket *so;
  105  *              if (so->so_state & SS_PRIV)
  106  *                      privileged;
  107  * - foo_control
  108  *      NetBSD, FreeBSD 3
  109  *              needs to give struct proc * as argument
  110  *      OpenBSD, BSDI [34], FreeBSD 2
  111  *              do not need struct proc *
  112  *
  113  * - bpf:
  114  *      OpenBSD, NetBSD 1.5, BSDI [34]
  115  *              need caddr_t * (= if_bpf **) and struct ifnet *
  116  *      FreeBSD 2, FreeBSD 3, NetBSD post-1.5N
  117  *              need only struct ifnet * as argument
  118  *
  119  * - struct ifnet
  120  *                      use queue.h?    member names    if name
  121  *                      ---             ---             ---
  122  *      FreeBSD 2       no              old standard    if_name+unit
  123  *      FreeBSD 3       yes             strange         if_name+unit
  124  *      OpenBSD         yes             standard        if_xname
  125  *      NetBSD          yes             standard        if_xname
  126  *      BSDI [34]       no              old standard    if_name+unit
  127  *
  128  * - usrreq
  129  *      NetBSD, OpenBSD, BSDI [34], FreeBSD 2
  130  *              single function with PRU_xx, arguments are mbuf
  131  *      FreeBSD 3
  132  *              separates functions, non-mbuf arguments
  133  *
  134  * - {set,get}sockopt
  135  *      NetBSD, OpenBSD, BSDI [34], FreeBSD 2
  136  *              manipulation based on mbuf
  137  *      FreeBSD 3
  138  *              non-mbuf manipulation using sooptcopy{in,out}()
  139  *
  140  * - timeout() and untimeout()
  141  *      NetBSD 1.4.x, OpenBSD, BSDI [34], FreeBSD 2
  142  *              timeout() is a void function
  143  *      FreeBSD 3
  144  *              timeout() is non-void, must keep returned value for untimeout()
  145  *              callout_xx is also available (sys/callout.h)
  146  *      NetBSD 1.5
  147  *              timeout() is obsoleted, use callout_xx (sys/callout.h)
  148  *      OpenBSD 2.8
  149  *              timeout_{add,set,del} is encouraged (sys/timeout.h)
  150  *
  151  * - sysctl
  152  *      NetBSD, OpenBSD
  153  *              foo_sysctl()
  154  *      BSDI [34]
  155  *              foo_sysctl() but with different style.  sysctl_int_arr() takes
  156  *              care of most of the cases.
  157  *      FreeBSD
  158  *              linker hack.  however, there are freebsd version differences
  159  *              (how wonderful!).
  160  *              on FreeBSD[23] function arg #define includes paren.
  161  *                      int foo SYSCTL_HANDLER_ARGS;
  162  *              on FreeBSD4, function arg #define does not include paren.
  163  *                      int foo(SYSCTL_HANDLER_ARGS);
  164  *              on some versions, forward reference to the tree is okay.
  165  *              on some versions, you need SYSCTL_DECL().  you need things
  166  *              like this.
  167  *                      #ifdef SYSCTL_DECL
  168  *                      SYSCTL_DECL(net_inet_ip6);
  169  *                      #endif
  170  *              it is hard to share functions between freebsd and non-freebsd.
  171  *
  172  * - if_ioctl
  173  *      NetBSD, FreeBSD 3, BSDI [34]
  174  *              2nd argument is u_long cmd
  175  *      FreeBSD 2
  176  *              2nd argument is int cmd
  177  *
  178  * - if attach routines
  179  *      NetBSD
  180  *              void xxattach(int);
  181  *      FreeBSD 2, FreeBSD 3
  182  *              void xxattach(void *);
  183  *              PSEUDO_SET(xxattach, if_xx);
  184  *
  185  * - ovbcopy()
  186  *      in NetBSD 1.4 or later, ovbcopy() is not supplied in the kernel.
  187  *      bcopy() is safe against overwrites.
  188  *
  189  * - splnet()
  190  *      NetBSD 1.4 or later requires splsoftnet().
  191  *      other operating systems use splnet().
  192  *
  193  * - dtom()
  194  *      NEVER USE IT!
  195  *
  196  * - struct ifnet for loopback interface
  197  *      BSDI3: struct ifnet loif;
  198  *      BSDI4: struct ifnet *loifp;
  199  *      NetBSD, OpenBSD 2.8, FreeBSD2: struct ifnet loif[NLOOP];
  200  *      OpenBSD 2.9: struct ifnet *lo0ifp;
  201  *
  202  *      odd thing is that many of them refers loif as ifnet *loif,
  203  *      not loif[NLOOP], from outside of if_loop.c.
  204  *
  205  * - number of bpf pseudo devices
  206  *      others: bpfilter.h, NBPFILTER
  207  *      FreeBSD4: bpf.h, NBPF
  208  *      solution:
  209  *              #if defined(__FreeBSD__) && __FreeBSD__ >= 4
  210  *              #include "bpf.h"
  211  *              #define NBPFILTER       NBPF
  212  *              #else
  213  *              #include "bpfilter.h"
  214  *              #endif
  215  *
  216  * - protosw for IPv4 (sys/netinet)
  217  *      FreeBSD4: struct ipprotosw in netinet/ipprotosw.h
  218  *      others: struct protosw in sys/protosw.h
  219  *
  220  * - protosw in general.
  221  *      NetBSD 1.5 has extra member for ipfilter (netbsd-current dropped
  222  *      it so it will go away in 1.6).
  223  *      NetBSD 1.5 requires PR_LISTEN flag bit with protocols that permit
  224  *      listen/accept (like tcp).
  225  *
  226  * - header files with defopt (opt_xx.h)
  227  *      FreeBSD3: opt_{inet,ipsec,ip6fw,altq}.h
  228  *      FreeBSD4: opt_{inet,inet6,ipsec,ip6fw,altq}.h
  229  *      NetBSD: opt_{inet,ipsec,altq}.h
  230  *      others: does not use defopt
  231  *
  232  * - (m->m_flags & M_EXT) != 0 does *not* mean that the max data length of
  233  *   the mbuf == MCLBYTES.
  234  *
  235  * - sys/kern/uipc_mbuf.c:m_dup()
  236  *      freebsd[34]: copies the whole mbuf chain.
  237  *      netbsd: similar arg with m_copym().
  238  *      others: no m_dup().
  239  *
  240  * - ifa_refcnt (struct ifaddr) management (IFAREF/IFAFREE).
  241  *      NetBSD 1.5: always use IFAREF whenever reference gets added.
  242  *              always use IFAFREE whenever reference gets freed.
  243  *              IFAFREE frees ifaddr when ifa_refcnt reaches 0.
  244  *      Darwin: always use ifaref whenever reference gets added.
  245  *              always use ifafree whenever reference gets freed.
  246  *              ifaref and ifafree are responsible for determining when to free.
  247  *      others: do not increase refcnt for ifp->if_addrlist and in_ifaddr.
  248  *              use IFAFREE once when ifaddr is disconnected from
  249  *              ifp->if_addrlist and in_ifaddr.  IFAFREE frees ifaddr when
  250  *              ifa_refcnt goes negative.
  251  */
  252 
  253 #ifndef __NET_NET_OSDEP_H_DEFINED_
  254 #define __NET_NET_OSDEP_H_DEFINED_
  255 #include <sys/appleapiopts.h>
  256 #ifdef KERNEL
  257 
  258 struct ifnet;
  259 extern const char *if_name __P((struct ifnet *));
  260 
  261 #define HAVE_OLD_BPF
  262 
  263 #define ifa_list        ifa_link
  264 #define if_addrlist     if_addrhead
  265 #define if_list         if_link
  266 
  267 /* sys/net/if.h */
  268 #ifndef __APPLE__
  269 #define IFAREF(ifa)     do { ++(ifa)->ifa_refcnt; } while (0)
  270 #endif
  271 
  272 #define WITH_CONVERT_AND_STRIP_IP_LEN
  273 
  274 #if 1                           /* at this moment, all OSes do this */
  275 #define WITH_CONVERT_IP_OFF
  276 #endif
  277 
  278 #endif /*_KERNEL*/
  279 #endif /*__NET_NET_OSDEP_H_DEFINED_ */

Cache object: 727aa146e36228d7f841f692522c37e6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.