home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / net / net_osdep.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  5.4 KB  |  170 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /*
  23.  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  24.  * All rights reserved.
  25.  * 
  26.  * Redistribution and use in source and binary forms, with or without
  27.  * modification, are permitted provided that the following conditions
  28.  * are met:
  29.  * 1. Redistributions of source code must retain the above copyright
  30.  *    notice, this list of conditions and the following disclaimer.
  31.  * 2. Redistributions in binary form must reproduce the above copyright
  32.  *    notice, this list of conditions and the following disclaimer in the
  33.  *    documentation and/or other materials provided with the distribution.
  34.  * 3. Neither the name of the project nor the names of its contributors
  35.  *    may be used to endorse or promote products derived from this software
  36.  *    without specific prior written permission.
  37.  * 
  38.  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  39.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  40.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  41.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  42.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  43.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  44.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  45.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  46.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  47.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  48.  * SUCH DAMAGE.
  49.  */
  50. /*
  51.  * glue for kernel code programming differences.
  52.  */
  53.  
  54. /*
  55.  * OS dependencies:
  56.  *
  57.  * - privileged process
  58.  *    NetBSD, FreeBSD 3
  59.  *        struct proc *p;
  60.  *        if (p && !suser(p->p_ucred, &p->p_acflag))
  61.  *            privileged;
  62.  *    OpenBSD, BSDI [34], FreeBSD 2
  63.  *        struct socket *so;
  64.  *        if (so->so_state & SS_PRIV)
  65.  *            privileged;
  66.  * - foo_control
  67.  *    NetBSD, FreeBSD 3
  68.  *        needs to give struct proc * as argument
  69.  *    OpenBSD, BSDI [34], FreeBSD 2
  70.  *        do not need struct proc *
  71.  * - bpf:
  72.  *    OpenBSD, NetBSD, BSDI [34]
  73.  *        need caddr_t * (= if_bpf **) and struct ifnet *
  74.  *    FreeBSD 2, FreeBSD 3
  75.  *        need only struct ifnet * as argument
  76.  * - struct ifnet
  77.  *            use queue.h?    member names    if name
  78.  *            ---        ---        ---
  79.  *    FreeBSD 2    no        old standard    if_name+unit
  80.  *    FreeBSD 3    yes        strange        if_name+unit
  81.  *    OpenBSD        yes        standard    if_xname
  82.  *    NetBSD        yes        standard    if_xname
  83.  *    BSDI [34]    no        old standard    if_name+unit
  84.  * - usrreq
  85.  *    NetBSD, OpenBSD, BSDI [34], FreeBSD 2
  86.  *        single function with PRU_xx, arguments are mbuf 
  87.  *    FreeBSD 3
  88.  *        separates functions, non-mbuf arguments
  89.  * - {set,get}sockopt
  90.  *    NetBSD, OpenBSD, BSDI [34], FreeBSD 2
  91.  *        manipulation based on mbuf
  92.  *    FreeBSD 3
  93.  *        non-mbuf manipulation using sooptcopy{in,out}()
  94.  * - timeout() and untimeout()
  95.  *    NetBSD, OpenBSD, BSDI [34], FreeBSD 2
  96.  *        timeout() is a void function
  97.  *    FreeBSD 3
  98.  *        timeout() is non-void, must keep returned value for untimeuot()
  99.  * - sysctl
  100.  *    NetBSD, OpenBSD
  101.  *        foo_sysctl()
  102.  *    BSDI [34]
  103.  *        foo_sysctl() but with different style
  104.  *    FreeBSD 2, FreeBSD 3
  105.  *        linker hack
  106.  *
  107.  * - if_ioctl
  108.  *    NetBSD, FreeBSD 3, BSDI [34]
  109.  *        2nd argument is u_long cmd
  110.  *    FreeBSD 2
  111.  *        2nd argument is int cmd
  112.  * - if attach routines
  113.  *    NetBSD
  114.  *        void xxattach(int);
  115.  *    FreeBSD 2, FreeBSD 3
  116.  *        void xxattach(void *);
  117.  *        PSEUDO_SET(xxattach, if_xx);
  118.  *
  119.  * - ovbcopy()
  120.  *    in NetBSD 1.4 or later, ovbcopy() is not supplied in the kernel.
  121.  *    bcopy() is safe against overwrites.
  122.  * - splnet()
  123.  *    NetBSD 1.4 or later requires splsoftnet().
  124.  *    other operating systems use splnet().
  125.  *
  126.  * - dtom()
  127.  *    NEVER USE IT!
  128.  *
  129.  * - struct ifnet for loopback interface
  130.  *    BSDI3: struct ifnet loif;
  131.  *    BSDI4: struct ifnet *loifp;
  132.  *    NetBSD, OpenBSD, FreeBSD2: struct ifnet loif[NLOOP];
  133.  *
  134.  *    odd thing is that many of them refers loif as ifnet *loif,
  135.  *    not loif[NLOOP], from outside of if_loop.c.
  136.  */
  137.  
  138. #ifndef __NET_NET_OSDEP_H_DEFINED_
  139. #define __NET_NET_OSDEP_H_DEFINED_
  140. #ifdef KERNEL
  141.  
  142. #if defined(__NetBSD__) || defined(__OpenBSD__)
  143. #define if_name(ifp)    ((ifp)->if_xname)
  144. #else
  145. struct ifnet;
  146. extern char *if_name __P((struct ifnet *));
  147. #endif
  148.  
  149. #if defined (__APPLE__)
  150. #define HAVE_OLD_BPF
  151. #endif
  152.  
  153. //#if defined(__FreeBSD__) && __FreeBSD__ >= 3
  154. #if defined (__APPLE__)
  155. #define ifa_list    ifa_link
  156. #define if_addrlist    if_addrhead
  157. #define if_list        if_link
  158. #endif
  159.  
  160. #if defined(__NetBSD__) && __NetBSD_Version__ >= 104000000
  161. #define ovbcopy        bcopy
  162. #endif
  163.  
  164. #if defined(__OpenBSD__) || (defined(__bsdi__) && _BSDI_VERSION >= 199802)
  165. #define HAVE_NRL_INPCB
  166. #endif
  167.  
  168. #endif /*_KERNEL*/
  169. #endif /*__NET_NET_OSDEP_H_DEFINED_ */
  170.