bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

...


From: duncan
Subject: ...
Date: Tue, 22 Jun 2004 11:12:06 +0200
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020921 Netscape/7.0

Hi (again),

while I was trying to install <net-snmp.5.1.2>, <./configure> displayed this:

...
no
checking netinet/ip.h presence...
yes
configure: WARNING: netinet/ip.h: present but cannot be compiled
configure: WARNING: netinet/ip.h: check for missing prerequisite headers?
configure: WARNING: netinet/ip.h: proceeding with the preprocessor's result
configure: WARNING:     ## ------------------------------------ ##
configure: WARNING:     ## Report this to address@hidden ##
configure: WARNING:     ## ------------------------------------ ##
checking for netinet/ip.h... yes
...
no
checking netinet/ip_icmp.h presence...
yes
configure: WARNING: netinet/ip_icmp.h: present but cannot be compiled
configure: WARNING: netinet/ip_icmp.h: check for missing prerequisite headers? configure: WARNING: netinet/ip_icmp.h: proceeding with the preprocessor's result
configure: WARNING:     ## ------------------------------------ ##
configure: WARNING:     ## Report this to address@hidden ##
configure: WARNING:     ## ------------------------------------ ##
checking for netinet/ip_icmp.h... yes
...
no
checking net/if.h presence...
yes
configure: WARNING: net/if.h: present but cannot be compiled
configure: WARNING: net/if.h: check for missing prerequisite headers?
configure: WARNING: net/if.h: proceeding with the preprocessor's result
configure: WARNING:     ## ------------------------------------ ##
configure: WARNING:     ## Report this to address@hidden ##
configure: WARNING:     ## ------------------------------------ ##
checking for net/if.h... yes
...
no
checking sys/socketvar.h presence...
yes
configure: WARNING: sys/socketvar.h: present but cannot be compiled
configure: WARNING: sys/socketvar.h: check for missing prerequisite headers?
configure: WARNING: sys/socketvar.h: proceeding with the preprocessor's result
configure: WARNING:     ## ------------------------------------ ##
configure: WARNING:     ## Report this to address@hidden ##
configure: WARNING:     ## ------------------------------------ ##
checking for sys/socketvar.h... yes
...
...
...same problem with all the attached files...
...

I attached all the matching files.

More infos:

- checking build system type... sparc-sun-solaris2.9
- checking host system type... sparc-sun-solaris2.9
- checking for non-GNU ld... /usr/ucb/ld
- checking if the linker (/usr/ucb/ld) is GNU ld... no
- checking for /usr/ucb/ld option to reload object files... -r
- SunOS protee 5.9 Generic sun4u sparc SUNW,Sun-Blade-100
- Compiler: /opt/SUNWspro/bin/cc

If it helps and that you need more information, don't hesitate to ask me...

Regards.

/*
 * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that this notice is preserved and that due credit is given
 * to the University of California at Berkeley. The name of the University
 * may not be used to endorse or promote products derived from this
 * software without specific prior written permission. This software
 * is provided ``as is'' without express or implied warranty.
 */

/*
 * Definitions for internet protocol version 4.
 * Per RFC 791, September 1981.
 */

#ifndef _NETINET_IP_H
#define _NETINET_IP_H

#pragma ident   "@(#)ip.h       1.9     01/09/25 SMI"
/* ip.h 1.13 88/08/19 SMI; from UCB 7.6.1.1 3/15/88     */

#include <sys/isa_defs.h>

#ifdef  __cplusplus
extern "C" {
#endif

#define IPVERSION       4

/*
 * Structure of an internet header, naked of options.
 *
 * We declare ip_len and ip_off to be short, rather than ushort_t
 * pragmatically since otherwise unsigned comparisons can result
 * against negative integers quite easily, and fail in subtle ways.
 */
struct ip {
#ifdef _BIT_FIELDS_LTOH
        uchar_t ip_hl:4,                /* header length */
                ip_v:4;                 /* version */
#else
        uchar_t ip_v:4,                 /* version */
                ip_hl:4;                /* header length */
#endif
        uchar_t ip_tos;                 /* type of service */
        short   ip_len;                 /* total length */
        ushort_t ip_id;                 /* identification */
        short   ip_off;                 /* fragment offset field */
#define IP_DF 0x4000                    /* dont fragment flag */
#define IP_MF 0x2000                    /* more fragments flag */
        uchar_t ip_ttl;                 /* time to live */
        uchar_t ip_p;                   /* protocol */
        ushort_t ip_sum;                /* checksum */
        struct  in_addr ip_src, ip_dst; /* source and dest address */
};

#define IP_MAXPACKET    65535           /* maximum packet size */

/*
 * Definitions for IP type of service (ip_tos)
 */
#define IPTOS_LOWDELAY          0x10
#define IPTOS_THROUGHPUT        0x08
#define IPTOS_RELIABILITY       0x04
#define IPTOS_ECT               0x02    /* ECN-Capable Transport flag */
#define IPTOS_CE                0x01    /* ECN-Congestion Experienced flag */

/*
 * Definitions for IP precedence (also in ip_tos) (hopefully unused)
 */
#define IPTOS_PREC_NETCONTROL           0xe0
#define IPTOS_PREC_INTERNETCONTROL      0xc0
#define IPTOS_PREC_CRITIC_ECP           0xa0
#define IPTOS_PREC_FLASHOVERRIDE        0x80
#define IPTOS_PREC_FLASH                0x60
#define IPTOS_PREC_IMMEDIATE            0x40
#define IPTOS_PREC_PRIORITY             0x20
#define IPTOS_PREC_ROUTINE              0x00

/*
 * Definitions for options.
 */
#define IPOPT_COPIED(o)         ((o)&0x80)
#define IPOPT_CLASS(o)          ((o)&0x60)
#define IPOPT_NUMBER(o)         ((o)&0x1f)

#define IPOPT_CONTROL           0x00
#define IPOPT_RESERVED1         0x20
#define IPOPT_DEBMEAS           0x40
#define IPOPT_RESERVED2         0x60

#define IPOPT_EOL               0               /* end of option list */
#define IPOPT_NOP               1               /* no operation */

#define IPOPT_RR                7               /* record packet route */
#define IPOPT_TS                68              /* timestamp */
#define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
#define IPOPT_LSRR              131             /* loose source route */
#define IPOPT_SATID             136             /* satnet id */
#define IPOPT_SSRR              137             /* strict source route */

/*
 * Offsets to fields in options other than EOL and NOP.
 */
#define IPOPT_OPTVAL            0               /* option ID */
#define IPOPT_OLEN              1               /* option length */
#define IPOPT_OFFSET            2               /* offset within option */
#define IPOPT_MINOFF            4               /* min value of above */

/*
 * Time stamp option structure.
 */
struct  ip_timestamp {
        uchar_t ipt_code;               /* IPOPT_TS */
        uchar_t ipt_len;                /* size of structure (variable) */
        uchar_t ipt_ptr;                /* index of current entry */
#ifdef _BIT_FIELDS_LTOH
        uchar_t ipt_flg:4,              /* flags, see below */
                ipt_oflw:4;             /* overflow counter */
#else
        uchar_t ipt_oflw:4,             /* overflow counter */
                ipt_flg:4;              /* flags, see below */
#endif
        union ipt_timestamp {
                uint32_t        ipt_time[1];
                struct  ipt_ta {
                        struct in_addr  ipt_addr;
                        uint32_t        ipt_time;
                } ipt_ta[1];
        } ipt_timestamp;
};

/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY         0               /* timestamps only */
#define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
#define IPOPT_TS_PRESPEC        2               /* specified modules only */

/* bits for security (not byte swapped) */
#define IPOPT_SECUR_UNCLASS     0x0000
#define IPOPT_SECUR_CONFID      0xf135
#define IPOPT_SECUR_EFTO        0x789a
#define IPOPT_SECUR_MMMM        0xbc4d
#define IPOPT_SECUR_RESTR       0xaf13
#define IPOPT_SECUR_SECRET      0xd788
#define IPOPT_SECUR_TOPSECRET   0x6bc5

/*
 * Internet implementation parameters.
 */
#define MAXTTL          255             /* maximum time to live (seconds) */
#define IPFRAGTTL       60              /* time to live for frags, slowhz */
#define IPTTLDEC        1               /* subtracted when forwarding */

#define IP_MSS          576             /* default maximum segment size */

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_IP_H */
/*
 * Copyright (c) 1997-1999, 2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986, 1993
 *      The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Interface Control Message Protocol Definitions.
 * Per RFC 792, September 1981.
 */

#ifndef _NETINET_IP_ICMP_H
#define _NETINET_IP_ICMP_H

#pragma ident   "@(#)ip_icmp.h  1.6     01/09/25 SMI"
/* ip_icmp.h 1.9 88/08/19 SMI; from UCB 7.3 12/7/87     */

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * Structure of an icmp header.
 */
struct icmp {
        uchar_t icmp_type;              /* type of message, see below */
        uchar_t icmp_code;              /* type sub code */
        uint16_t icmp_cksum;            /* ones complement cksum of struct */
        union {
                uchar_t ih_pptr;                /* ICMP_PARAMPROB */
                struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
                struct ih_idseq {
                        uint16_t icd_id;
                        uint16_t icd_seq;
                } ih_idseq;
                int ih_void;

                /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
                struct ih_pmtu {
                        uint16_t ipm_void;
                        uint16_t ipm_nextmtu;
                } ih_pmtu;

                struct ih_rtradv {
                        uchar_t irt_num_addrs;
                        uchar_t irt_wpa;
                        uint16_t irt_lifetime;
                } ih_rtradv;
        } icmp_hun;
#define icmp_pptr       icmp_hun.ih_pptr
#define icmp_gwaddr     icmp_hun.ih_gwaddr
#define icmp_id         icmp_hun.ih_idseq.icd_id
#define icmp_seq        icmp_hun.ih_idseq.icd_seq
#define icmp_void       icmp_hun.ih_void
#define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
#define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
        union {
                struct id_ts {
                        n_time its_otime;
                        n_time its_rtime;
                        n_time its_ttime;
                } id_ts;
                struct id_ip  {
                        struct ip idi_ip;
                        /* options and then 64 bits of data */
                } id_ip;
                uint32_t id_mask;
                char    id_data[1];
        } icmp_dun;
#define icmp_otime      icmp_dun.id_ts.its_otime
#define icmp_rtime      icmp_dun.id_ts.its_rtime
#define icmp_ttime      icmp_dun.id_ts.its_ttime
#define icmp_ip         icmp_dun.id_ip.idi_ip
#define icmp_mask       icmp_dun.id_mask
#define icmp_data       icmp_dun.id_data
};

/*
 * Lower bounds on packet lengths for various types.
 * For the error advice packets must first insure that the
 * packet is large enough to contain the returned ip header.
 * Only then can we do the check to see if 64 bits of packet
 * data have been returned, since we need to check the returned
 * ip header length.
 */
#define ICMP_MINLEN     8                               /* abs minimum */
#define ICMP_TSLEN      (8 + 3 * sizeof (n_time))       /* timestamp */
#define ICMP_MASKLEN    12                              /* address mask */
#define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
#define ICMP_ADVLEN(p)  (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
        /* N.B.: must separately check that ip_hl >= 5 */

/*
 * Definition of type and code field values.
 */
#define ICMP_ECHOREPLY          0               /* echo reply */
#define ICMP_UNREACH            3               /* dest unreachable, codes: */
#define         ICMP_UNREACH_NET                0       /* bad net */
#define         ICMP_UNREACH_HOST               1       /* bad host */
#define         ICMP_UNREACH_PROTOCOL           2       /* bad protocol */
#define         ICMP_UNREACH_PORT               3       /* bad port */
#define         ICMP_UNREACH_NEEDFRAG           4       /* IP_DF caused drop */
#define         ICMP_UNREACH_SRCFAIL            5       /* src route failed */
#define         ICMP_UNREACH_NET_UNKNOWN        6       /* unknown net */
#define         ICMP_UNREACH_HOST_UNKNOWN       7       /* unknown host */
#define         ICMP_UNREACH_ISOLATED           8       /* src host isolated */
#define         ICMP_UNREACH_NET_PROHIB         9       /* prohibited access */
#define         ICMP_UNREACH_HOST_PROHIB        10      /* ditto */
#define         ICMP_UNREACH_TOSNET             11      /* bad tos for net */
#define         ICMP_UNREACH_TOSHOST            12      /* bad tos for host */
#define         ICMP_UNREACH_FILTER_PROHIB      13      /* prohibited access */
#define         ICMP_UNREACH_HOST_PRECEDENCE    14      /* pred violationn */
#define         ICMP_UNREACH_PRECEDENCE_CUTOFF  15      /* precedence cutoff */
#define ICMP_SOURCEQUENCH       4               /* packet lost, slow down */
#define ICMP_REDIRECT           5               /* shorter route, codes: */
#define         ICMP_REDIRECT_NET       0               /* for network */
#define         ICMP_REDIRECT_HOST      1               /* for host */
#define         ICMP_REDIRECT_TOSNET    2               /* for tos and net */
#define         ICMP_REDIRECT_TOSHOST   3               /* for tos and host */
#define ICMP_ECHO               8               /* echo service */
#define ICMP_ROUTERADVERT       9               /* router advertisement */
#define ICMP_ROUTERSOLICIT      10              /* router solicitation */
#define ICMP_TIMXCEED           11              /* time exceeded, code: */
#define         ICMP_TIMXCEED_INTRANS   0               /* ttl==0 in transit */
#define         ICMP_TIMXCEED_REASS     1               /* ttl==0 in reass */
#define ICMP_PARAMPROB          12              /* ip header bad */
#define         ICMP_PARAMPROB_OPTABSENT        1       /* req. opt. absent */
#define         ICMP_PARAMPROB_BADLENGTH        2       /* Bad Length */
#define ICMP_TSTAMP             13              /* timestamp request */
#define ICMP_TSTAMPREPLY        14              /* timestamp reply */
#define ICMP_IREQ               15              /* information request */
#define ICMP_IREQREPLY          16              /* information reply */
#define ICMP_MASKREQ            17              /* address mask request */
#define ICMP_MASKREPLY          18              /* address mask reply */

#define ICMP_MAXTYPE            18

#define ICMP_INFOTYPE(type) \
        ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
        (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
        (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
        (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
        (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_IP_ICMP_H */
/*
 * Copyright (c) 1992-1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

#ifndef _NET_IF_H
#define _NET_IF_H

#pragma ident   "@(#)if.h       1.23    01/03/06 SMI"
/* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86          */

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * Structures defining a network interface, providing a packet
 * transport mechanism (ala level 0 of the PUP protocols).
 *
 * Each interface accepts output datagrams of a specified maximum
 * length, and provides higher level routines with input datagrams
 * received from its medium.
 *
 * Output occurs when the routine if_output is called, with three parameters:
 *      (*ifp->if_output)(ifp, m, dst)
 * Here m is the mbuf chain to be sent and dst is the destination address.
 * The output routine encapsulates the supplied datagram if necessary,
 * and then transmits it on its medium.
 *
 * On input, each interface unwraps the data received by it, and either
 * places it on the input queue of a internetwork datagram routine
 * and posts the associated software interrupt, or passes the datagram to a raw
 * packet input routine.
 *
 * Routines exist for locating interfaces by their addresses
 * or for locating a interface on a certain network, as well as more general
 * routing and gateway routines maintaining information used to locate
 * interfaces.  These routines live in the files if.c and route.c
 */

/*
 * Structure defining a queue for a network interface.
 *
 * (Would like to call this struct ``if'', but C isn't PL/1.)
 */
struct ifnet {
        char    *if_name;               /* name, e.g. ``en'' or ``lo'' */
        short   if_unit;                /* sub-unit for lower level driver */
        short   if_mtu;                 /* maximum transmission unit */
        short   if_flags;               /* up/down, broadcast, etc. */
        short   if_timer;               /* time 'til if_watchdog called */
        ushort_t if_promisc;            /* net # of requests for promisc mode */
        int     if_metric;              /* routing metric (external only) */
        struct  ifaddr *if_addrlist;    /* linked list of addresses per if */
        struct  ifqueue {
                struct  mbuf *ifq_head;
                struct  mbuf *ifq_tail;
                int     ifq_len;
                int     ifq_maxlen;
                int     ifq_drops;
        } if_snd;                       /* output queue */
/* procedure handles */
        int     (*if_init)();           /* init routine */
        int     (*if_output)();         /* output routine */
        int     (*if_ioctl)();          /* ioctl routine */
        int     (*if_reset)();          /* bus reset routine */
        int     (*if_watchdog)();       /* timer routine */
/* generic interface statistics */
        int     if_ipackets;            /* packets received on interface */
        int     if_ierrors;             /* input errors on interface */
        int     if_opackets;            /* packets sent on interface */
        int     if_oerrors;             /* output errors on interface */
        int     if_collisions;          /* collisions on csma interfaces */
/* end statistics */
        struct  ifnet *if_next;
        struct  ifnet *if_upper;        /* next layer up */
        struct  ifnet *if_lower;        /* next layer down */
        int     (*if_input)();          /* input routine */
        int     (*if_ctlin)();          /* control input routine */
        int     (*if_ctlout)();         /* control output routine */
        struct map *if_memmap;          /* rmap for interface specific memory */
};

/*
 * NOTE : These flags are not directly used within IP.
 * ip_if.h has definitions derived from this which is used within IP.
 * If you define a flag here, you need to define one in ip_if.h before
 * using the new flag in IP. Don't use these flags directly in IP.
 */
#define IFF_UP          0x000000001     /* interface is up */
#define IFF_BROADCAST   0x000000002     /* broadcast address valid */
#define IFF_DEBUG       0x000000004     /* turn on debugging */
#define IFF_LOOPBACK    0x000000008     /* is a loopback net */

#define IFF_POINTOPOINT 0x000000010     /* interface is point-to-point link */
#define IFF_NOTRAILERS  0x000000020     /* avoid use of trailers */
#define IFF_RUNNING     0x000000040     /* resources allocated */
#define IFF_NOARP       0x000000080     /* no address resolution protocol */

#define IFF_PROMISC     0x000000100     /* receive all packets */
#define IFF_ALLMULTI    0x000000200     /* receive all multicast packets */
#define IFF_INTELLIGENT 0x000000400     /* protocol code on board */
#define IFF_MULTICAST   0x000000800     /* supports multicast */

#define IFF_MULTI_BCAST 0x000001000     /* multicast using broadcast address */
#define IFF_UNNUMBERED  0x000002000     /* non-unique address */
#define IFF_DHCPRUNNING 0x000004000     /* DHCP controls this interface */
#define IFF_PRIVATE     0x000008000     /* do not advertise */

/*
 * The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS.
 * Should use SIOC[GS]LIFFLAGS which has a larger flags field.
 */
#define IFF_NOXMIT      0x000010000     /* Do not transmit packets */
#define IFF_NOLOCAL     0x000020000     /* No address - just on-link subnet */
#define IFF_DEPRECATED  0x000040000     /* interface address deprecated */
#define IFF_ADDRCONF    0x000080000     /* address from stateless addrconf */

#define IFF_ROUTER      0x000100000     /* router on this interface */
#define IFF_NONUD       0x000200000     /* No NUD on this interface */
#define IFF_ANYCAST     0x000400000     /* Anycast address */
#define IFF_NORTEXCH    0x000800000     /* Do not exchange routing info */

#define IFF_IPV4        0x001000000     /* IPv4 interface */
#define IFF_IPV6        0x002000000     /* IPv6 interface */
#define IFF_MIPRUNNING  0x004000000     /* Mobile IP controls this interface */
#define IFF_NOFAILOVER  0x008000000     /* Don't failover on NIC failure */

#define IFF_FAILED      0x010000000     /* NIC has failed */
#define IFF_STANDBY     0x020000000     /* Standby NIC to be used on failures */
#define IFF_INACTIVE    0x040000000     /* Standby active or not ? */
#define IFF_OFFLINE     0x080000000     /* NIC has been offlined */

/*
 * The IFF_XRESOLV flag is an evolving interface and is subject
 * to change without notice.
 */
#define IFF_XRESOLV     0x100000000     /* IPv6 external resolver */

/*
 * The IFF_MULTICAST flag indicates that the network can support the
 * transmission and reception of higher-level (e.g., IP) multicast packets.
 * It is independent of hardware support for multicasting; for example,
 * point-to-point links or pure broadcast networks may well support
 * higher-level multicasts.
 */

/* flags set internally only: */
#define IFF_CANTCHANGE \
        (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_PROMISC | \
        IFF_MULTICAST | IFF_MULTI_BCAST | IFF_UNNUMBERED | IFF_IPV4 | \
        IFF_IPV6|IFF_INACTIVE)

/*
 * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
 * input routines have queues of messages stored on ifqueue structures
 * (defined above).  Entries are added to and deleted from these structures
 * by these macros, which should be called with ipl raised to splimp().
 */
#define IF_QFULL(ifq)           ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
#define IF_DROP(ifq)            ((ifq)->ifq_drops++)
#define IF_ENQUEUE(ifq, m) { \
        (m)->m_act = 0; \
        if ((ifq)->ifq_tail == 0) \
                (ifq)->ifq_head = m; \
        else \
                (ifq)->ifq_tail->m_act = m; \
        (ifq)->ifq_tail = m; \
        (ifq)->ifq_len++; \
}
#define IF_PREPEND(ifq, m) { \
        (m)->m_act = (ifq)->ifq_head; \
        if ((ifq)->ifq_tail == 0) \
                (ifq)->ifq_tail = (m); \
        (ifq)->ifq_head = (m); \
        (ifq)->ifq_len++; \
}

/*
 * Packets destined for level-1 protocol input routines
 * have a pointer to the receiving interface prepended to the data.
 * IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet.
 * IF_ADJ should be used otherwise to adjust for its presence.
 */
#define IF_ADJ(m) { \
        (m)->m_off += sizeof (struct ifnet *); \
        (m)->m_len -= sizeof (struct ifnet *); \
        if ((m)->m_len == 0) { \
                struct mbuf *n; \
                MFREE((m), n); \
                (m) = n; \
        } \
}
#define IF_DEQUEUEIF(ifq, m, ifp) { \
        (m) = (ifq)->ifq_head; \
        if (m) { \
                if (((ifq)->ifq_head = (m)->m_act) == 0) \
                        (ifq)->ifq_tail = 0; \
                (m)->m_act = 0; \
                (ifq)->ifq_len--; \
                (ifp) = *(mtod((m), struct ifnet **)); \
                IF_ADJ(m); \
        } \
}
#define IF_DEQUEUE(ifq, m) { \
        (m) = (ifq)->ifq_head; \
        if (m) { \
                if (((ifq)->ifq_head = (m)->m_act) == 0) \
                        (ifq)->ifq_tail = 0; \
                (m)->m_act = 0; \
                (ifq)->ifq_len--; \
        } \
}

#define IFQ_MAXLEN      50
#define IFNET_SLOWHZ    1               /* granularity is 1 second */

/*
 * The ifaddr structure contains information about one address
 * of an interface.  They are maintained by the different address families,
 * are allocated and attached when an address is set, and are linked
 * together so all addresses for an interface can be located.
 */
struct ifaddr {
        struct  sockaddr ifa_addr;      /* address of interface */
        union {
                struct  sockaddr ifu_broadaddr;
                struct  sockaddr ifu_dstaddr;
        } ifa_ifu;
#define ifa_broadaddr   ifa_ifu.ifu_broadaddr   /* broadcast address */
#define ifa_dstaddr     ifa_ifu.ifu_dstaddr     /* other end of p-to-p link */
        struct  ifnet *ifa_ifp;         /* back-pointer to interface */
        struct  ifaddr *ifa_next;       /* next address for interface */
};

/*
 * The if_nameindex structure holds the interface index value about
 * a single interface. An array of this structure is used to return
 * all interfaces and indexes.
 */
struct if_nameindex {
        uint32_t        if_index;       /* positive interface index */
        char            *if_name;       /* if name, e.g. "en0" */
};

/*
 * For SIOCLIF*ND ioctls.
 *
 * The lnr_state_* fields use the ND_* neighbor reachability states.
 * The 3 different fields are for use with SIOCLIFSETND to cover the cases
 * when
 *      A new entry is created
 *      The entry already exists and the link-layer address is the same
 *      The entry already exists and the link-layer address differs
 *
 * Use ND_UNCHANGED and ND_ISROUTER_UNCHANGED to not change any state.
 */
#define ND_MAX_HDW_LEN  64
typedef struct lif_nd_req {
        struct sockaddr_storage lnr_addr;
        uint8_t                 lnr_state_create;       /* When creating */
        uint8_t                 lnr_state_same_lla;     /* Update same addr */
        uint8_t                 lnr_state_diff_lla;     /* Update w/ diff. */
        int                     lnr_hdw_len;
        int                     lnr_flags;              /* See below */
        /* padding because ia32 "long long"s are only 4-byte aligned. */
        int                     lnr_pad0;
        char                    lnr_hdw_addr[ND_MAX_HDW_LEN];
} lif_nd_req_t;

/*
 * Neighbor reachability states
 * Used with SIOCLIF*ND ioctls.
 */
#define ND_UNCHANGED    0       /* For ioctls that don't modify state */
#define ND_INCOMPLETE   1       /* addr resolution in progress */
#define ND_REACHABLE    2       /* have recently been reachable */
#define ND_STALE        3       /* may be unreachable, don't do anything */
#define ND_DELAY        4       /* wait for upper layer hint */
#define ND_PROBE        5       /* send probes */
#define ND_UNREACHABLE  6       /* delete this route */

#define ND_STATE_VALID_MIN      0
#define ND_STATE_VALID_MAX      6

/*
 * lnr_flags value of lif_nd_req.
 * Used with SIOCLIF*ND ioctls.
 */
#define NDF_ISROUTER_ON         0x1
#define NDF_ISROUTER_OFF        0x2
#define NDF_ANYCAST_ON          0x4
#define NDF_ANYCAST_OFF         0x8
#define NDF_PROXY_ON            0x10
#define NDF_PROXY_OFF           0x20

/* For SIOC[GS]LIFLNKINFO */
typedef struct lif_ifinfo_req {
        uint8_t         lir_maxhops;
        uint32_t        lir_reachtime;          /* Reachable time in msec */
        uint32_t        lir_reachretrans;       /* Retransmission timer msec */
        uint32_t        lir_maxmtu;
} lif_ifinfo_req_t;

/* Interface name size limit */
#define LIFNAMSIZ       32

/*
 * Interface request structure used for socket
 * ioctl's.  All interface ioctl's must have parameter
 * definitions which begin with ifr_name.  The
 * remainder may be interface specific.
 * Note: This data structure uses 64bit type uint64_t which is not
 *       a valid type for strict ANSI/ISO C compilation for ILP32.
 *       Applications with ioctls using this structure that insist on
 *       building with strict ANSI/ISO C (-Xc) will need to be LP64.
 */
#if defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG))
struct  lifreq {
        char    lifr_name[LIFNAMSIZ];           /* if name, e.g. "en0" */
        union {
                int     lifru_addrlen;          /* for subnet/token etc */
                uint_t  lifru_ppa;              /* SIOCSLIFNAME */
        } lifr_lifru1;
#define lifr_addrlen    lifr_lifru1.lifru_addrlen
#define lifr_ppa        lifr_lifru1.lifru_ppa   /* Driver's ppa */
        uint_t  lifr_movetoindex;               /* FAILOVER/FAILBACK ifindex */
        union {
                struct  sockaddr_storage lifru_addr;
                struct  sockaddr_storage lifru_dstaddr;
                struct  sockaddr_storage lifru_broadaddr;
                struct  sockaddr_storage lifru_token;   /* With lifr_addrlen */
                struct  sockaddr_storage lifru_subnet;  /* With lifr_addrlen */
                int     lifru_index;            /* interface index */
                uint64_t lifru_flags;           /* Flags for SIOC?LIFFLAGS */
                int     lifru_metric;
                uint_t  lifru_mtu;
                char    lifru_data[1];          /* interface dependent data */
                char    lifru_enaddr[6];
                int     lif_muxid[2];           /* mux id's for arp and ip */
                struct lif_nd_req       lifru_nd_req;
                struct lif_ifinfo_req   lifru_ifinfo_req;
                char    lifru_groupname[LIFNAMSIZ]; /* SIOC[GS]LIFGROUPNAME */
                uint_t  lifru_delay;               /* SIOC[GS]LIFNOTIFYDELAY */
        } lifr_lifru;

#define lifr_addr       lifr_lifru.lifru_addr   /* address */
#define lifr_dstaddr    lifr_lifru.lifru_dstaddr /* other end of p-to-p link */
#define lifr_broadaddr  lifr_lifru.lifru_broadaddr /* broadcast address */
#define lifr_token      lifr_lifru.lifru_token  /* address token */
#define lifr_subnet     lifr_lifru.lifru_subnet /* subnet prefix */
#define lifr_index      lifr_lifru.lifru_index  /* interface index */
#define lifr_flags      lifr_lifru.lifru_flags  /* flags */
#define lifr_metric     lifr_lifru.lifru_metric /* metric */
#define lifr_mtu        lifr_lifru.lifru_mtu    /* mtu */
#define lifr_data       lifr_lifru.lifru_data   /* for use by interface */
#define lifr_enaddr     lifr_lifru.lifru_enaddr /* ethernet address */
#define lifr_index      lifr_lifru.lifru_index  /* interface index */
#define lifr_ip_muxid   lifr_lifru.lif_muxid[0]
#define lifr_arp_muxid  lifr_lifru.lif_muxid[1]
#define lifr_nd         lifr_lifru.lifru_nd_req /* SIOCLIF*ND */
#define lifr_ifinfo     lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
#define lifr_groupname  lifr_lifru.lifru_groupname
#define lifr_delay      lifr_lifru.lifru_delay
};
#endif /* defined(_LP64) || (__STDC__ - 0 == 0 && !defined(_NO_LONGLONG)) */

/*
 * Argument structure for SIOCT* address testing ioctls.
 */
struct sioc_addrreq {
        struct sockaddr_storage sa_addr;        /* Address to test */
        int                     sa_res;         /* Result - 0/1 */
        int                     sa_pad;
};

/*
 * Argument structure used by mrouted to get src-grp pkt counts using
 * SIOCGETLSGCNT. See <netinet/ip_mroute.h>.
 */
struct sioc_lsg_req {
        struct sockaddr_storage slr_src;
        struct sockaddr_storage slr_grp;
        uint_t                  slr_pktcnt;
        uint_t                  slr_bytecnt;
        uint_t                  slr_wrong_if;
        uint_t                  slr_pad;
};

/*
 * OBSOLETE: Replaced by struct lifreq. Supported for compatibility.
 *
 * Interface request structure used for socket
 * ioctl's.  All interface ioctl's must have parameter
 * definitions which begin with ifr_name.  The
 * remainder may be interface specific.
 */
struct  ifreq {
#define IFNAMSIZ        16
        char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
        union {
                struct  sockaddr ifru_addr;
                struct  sockaddr ifru_dstaddr;
                char    ifru_oname[IFNAMSIZ];   /* other if name */
                struct  sockaddr ifru_broadaddr;
                int     ifru_index;             /* interface index */
                short   ifru_flags;
                int     ifru_metric;
                char    ifru_data[1];           /* interface dependent data */
                char    ifru_enaddr[6];
                int     if_muxid[2];            /* mux id's for arp and ip */

                /* Struct for flags/ppa */
                struct ifr_ppaflags {
                        short ifrup_flags;      /* Space of ifru_flags. */
                        short ifrup_filler;
                        uint_t ifrup_ppa;
                } ifru_ppaflags;

                /* Struct for FDDI ioctl's */
                struct ifr_dnld_reqs {
                        uint32_t        v_addr;
                        uint32_t        m_addr;
                        uint32_t        ex_addr;
                        uint32_t        size;
                } ifru_dnld_req;

                /* Struct for FDDI stats */
                struct ifr_fddi_stats {
                        uint32_t stat_size;
                        uint32_t fddi_stats;
                } ifru_fddi_stat;

                struct ifr_netmapents {
                        uint32_t map_ent_size,  /* size of netmap structure */
                                entry_number;   /* index into netmap list */
                        uint32_t fddi_map_ent;  /* pointer to user structure */
                } ifru_netmapent;

                /* Field for generic ioctl for fddi */

                struct ifr_fddi_gen_struct {
                        uint32_t ifru_fddi_gioctl; /* field for gen ioctl */
                        uint32_t ifru_fddi_gaddr;  /* Generic ptr to a field */
                } ifru_fddi_gstruct;

        } ifr_ifru;

#define ifr_addr        ifr_ifru.ifru_addr      /* address */
#define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
#define ifr_oname       ifr_ifru.ifru_oname     /* other if name */
#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags       ifr_ifru.ifru_flags     /* flags */
#define ifr_metric      ifr_ifru.ifru_metric    /* metric */
#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
#define ifr_enaddr      ifr_ifru.ifru_enaddr    /* ethernet address */
#define ifr_index       ifr_ifru.ifru_index     /* interface index */
/* For setting ppa */
#define ifr_ppa         ifr_ifru.ifru_ppaflags.ifrup_ppa

/* FDDI specific */
#define ifr_dnld_req    ifr_ifru.ifru_dnld_req
#define ifr_fddi_stat   ifr_ifru.ifru_fddi_stat
#define ifr_fddi_netmap ifr_ifru.ifru_netmapent /* FDDI network map entries */
#define ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct

#define ifr_ip_muxid    ifr_ifru.if_muxid[0]
#define ifr_arp_muxid   ifr_ifru.if_muxid[1]
};

/* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */
struct lifnum {
        sa_family_t     lifn_family;
        int             lifn_flags;     /* request specific interfaces */
        int             lifn_count;     /* Result */
};

/*
 * Structure used in SIOCGLIFCONF request.
 * Used to retrieve interface configuration
 * for machine (useful for programs which
 * must know all networks accessible) for a given address family.
 * Using AF_UNSPEC will retrieve all address families.
 */
struct  lifconf {
        sa_family_t     lifc_family;
        int             lifc_flags;     /* request specific interfaces */
        int             lifc_len;       /* size of associated buffer */
        union {
                caddr_t lifcu_buf;
                struct  lifreq *lifcu_req;
        } lifc_lifcu;
#define lifc_buf lifc_lifcu.lifcu_buf   /* buffer address */
#define lifc_req lifc_lifcu.lifcu_req   /* array of structures returned */
};

/* Flags */
#define LIFC_NOXMIT     0x01            /* Include IFF_NOXMIT interfaces */
#define LIFC_EXTERNAL_SOURCE    0x02    /* Exclude the interfaces which can't */
                                        /* be used to communicate outside the */
                                        /* node (exclude interfaces which are */
                                        /* IFF_NOXMIT, IFF_NOLOCAL, */
                                        /* IFF_LOOPBACK, IFF_DEPRECATED, or */
                                        /* not IFF_UP). Has priority over */
                                        /* LIFC_NOXMIT. */

#if defined(_SYSCALL32)

struct  lifconf32 {
        sa_family_t     lifc_family;
        int             lifc_flags;     /* request specific interfaces */
        int32_t lifc_len;               /* size of associated buffer */
        union {
                caddr32_t lifcu_buf;
                caddr32_t lifcu_req;
        } lifc_lifcu;
};

#endif  /* _SYSCALL32 */

/*
 * OBSOLETE: Structure used in SIOCGIFCONF request.
 * Used to retrieve interface configuration
 * for machine (useful for programs which
 * must know all networks accessible).
 */
struct  ifconf {
        int     ifc_len;                /* size of associated buffer */
        union {
                caddr_t ifcu_buf;
                struct  ifreq *ifcu_req;
        } ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
};

#if defined(_SYSCALL32)

struct  ifconf32 {
        int32_t ifc_len;                /* size of associated buffer */
        union {
                caddr32_t ifcu_buf;
                caddr32_t ifcu_req;
        } ifc_ifcu;
};

#endif  /* _SYSCALL32 */

typedef struct if_data {
                                /* generic interface information */
        uchar_t ifi_type;       /* ethernet, tokenring, etc */
        uchar_t ifi_addrlen;    /* media address length */
        uchar_t ifi_hdrlen;     /* media header length */
        uint_t  ifi_mtu;        /* maximum transmission unit */
        uint_t  ifi_metric;     /* routing metric (external only) */
        uint_t  ifi_baudrate;   /* linespeed */
                                /* volatile statistics */
        uint_t  ifi_ipackets;   /* packets received on interface */
        uint_t  ifi_ierrors;    /* input errors on interface */
        uint_t  ifi_opackets;   /* packets sent on interface */
        uint_t  ifi_oerrors;    /* output errors on interface */
        uint_t  ifi_collisions; /* collisions on csma interfaces */
        uint_t  ifi_ibytes;     /* total number of octets received */
        uint_t  ifi_obytes;     /* total number of octets sent */
        uint_t  ifi_imcasts;    /* packets received via multicast */
        uint_t  ifi_omcasts;    /* packets sent via multicast */
        uint_t  ifi_iqdrops;    /* dropped on input, this interface */
        uint_t  ifi_noproto;    /* destined for unsupported protocol */
        struct  timeval ifi_lastchange; /* last updated */
} if_data_t;

/*
 * Message format for use in obtaining information about interfaces
 * from the routing socket
 */
typedef struct if_msghdr {
        ushort_t ifm_msglen;    /* to skip over non-understood messages */
        uchar_t ifm_version;    /* future binary compatibility */
        uchar_t ifm_type;       /* message type */
        int     ifm_addrs;      /* like rtm_addrs */
        int     ifm_flags;      /* value of if_flags */
        ushort_t ifm_index;     /* index for associated ifp */
        struct  if_data ifm_data; /* statistics and other data about if */
} if_msghdr_t;

/*
 * Message format for use in obtaining information about interface addresses
 * from the routing socket
 */
typedef struct ifa_msghdr {
        ushort_t ifam_msglen;   /* to skip over non-understood messages */
        uchar_t ifam_version;   /* future binary compatibility */
        uchar_t ifam_type;      /* message type */
        int     ifam_addrs;     /* like rtm_addrs */
        int     ifam_flags;     /* route flags */
        ushort_t ifam_index;    /* index for associated ifp */
        int     ifam_metric;    /* value of ipif_metric */
} ifa_msghdr_t;

/* currently tunnels only support IPv4 or IPv6 */
enum ifta_proto {
        IFTAP_INVALID,
        IFTAP_IPV4,
        IFTAP_IPV6
};

#define IFTUN_SECINFOLEN 8      /* In units of 32-bit words. */
#define IFTUN_VERSION 1         /* Current version number. */

/*
 * Used by tunneling module to get/set a tunnel parameters using
 * SIOCTUN[SG]PARAM.
 *
 * There is a version number and an array of uint32_t at the end of this
 * ioctl because in a perfect world, the ipsec_req_t would be inside
 * tun_addreq.  Since this file is independent of IP (and IPsec), I have to
 * just leave room there, and have the appropriate handlers deal with the
 * security information.
 *
 * In the future, the sockaddr types and the ta_vers could be used together
 * to determine the nature of the security information that is at the end
 * of this ioctl.
 */
struct iftun_req {
        char            ifta_lifr_name[LIFNAMSIZ]; /* if name */
        struct sockaddr_storage ifta_saddr;     /* source address */
        struct sockaddr_storage ifta_daddr;     /* destination address */
        uint_t          ifta_flags;             /* See below */
        /* IP version information is read only */
        enum ifta_proto ifta_upper;             /* IP version above tunnel */
        enum ifta_proto ifta_lower;             /* IP version below tunnel */
        uint_t          ifta_vers;              /* Version number */
        uint32_t        ifta_secinfo[IFTUN_SECINFOLEN]; /* Security prefs. */
};

/* ifta_flags are set to indicate which members are valid */
#define IFTUN_SRC                       0x01
#define IFTUN_DST                       0x02
#define IFTUN_SECURITY                  0x04    /* Pay attention to secinfo */

/* Interface index identification API definitions */
extern  uint32_t        if_nametoindex(const char *ifname);
extern  char            *if_indextoname(uint32_t ifindex, char *ifname);
extern  struct if_nameindex     *if_nameindex(void);
extern  void            if_freenameindex(struct if_nameindex *ptr);

#define IF_NAMESIZE     LIFNAMSIZ

#ifdef  __cplusplus
}
#endif

#endif  /* _NET_IF_H */
/*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/*        All Rights Reserved   */

/*      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T     */
/*      The copyright notice above does not evidence any        */
/*      actual or intended publication of such source code.     */

/*
 *              PROPRIETARY NOTICE (Combined)
 *
 *  This source code is unpublished proprietary information
 *  constituting, or derived under license from AT&T's Unix(r) System V.
 *  In addition, portions of such source code were derived from Berkeley
 *  4.3 BSD under license from the Regents of the University of
 *  California.
 *
 *
 *
 *              Copyright Notice
 *
 *  Notice of copyright on this source code product does not indicate
 *  publication.
 *
 *      Copyright (c) 1986-1989,1997-2001 by Sun Microsystems, Inc.
 *      All rights reserved.
 *
 *      Copyright (c) 1983-1989 by AT&T.
 *      All rights reserved.
 */

#ifndef _SYS_SOCKETVAR_H
#define _SYS_SOCKETVAR_H

#pragma ident   "@(#)socketvar.h        1.48    01/12/04 SMI"   /* SVr4.0 1.3 */

#include <sys/types.h>
#include <sys/stream.h>
#include <sys/t_lock.h>
#include <sys/cred.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/param.h>

#ifdef  __cplusplus
extern "C" {
#endif



/*
 * Internal representation used for addresses.
 */
struct soaddr {
        struct sockaddr *soa_sa;        /* Actual address */
        t_uscalar_t     soa_len;        /* Length in bytes for kmem_free */
        t_uscalar_t     soa_maxlen;     /* Allocated length */
};
/* Maximum size address for transports that have ADDR_size == 1 */
#define SOA_DEFSIZE     128

/*
 * Internal representation of the address used to represent addresses
 * in the loopback transport for AF_UNIX. While the sockaddr_un is used
 * as the sockfs layer address for AF_UNIX the pathnames contained in
 * these addresses are not unique (due to relative pathnames) thus can not
 * be used in the transport.
 *
 * The transport level address consists of a magic number (used to separate the
 * name space for specific and implicit binds). For a specific bind
 * this is followed by a "vnode *" which ensures that all specific binds
 * have a unique transport level address. For implicit binds the latter
 * part of the address is a byte string (of the same length as a pointer)
 * that is assigned by the loopback transport.
 *
 * The uniqueness assumes that the loopback transport has a separate namespace
 * for sockets in order to avoid name conflicts with e.g. TLI use of the
 * same transport.
 */
struct so_ux_addr {
        void    *soua_vp;       /* vnode pointer or assigned by tl */
        uint_t  soua_magic;     /* See below */
};

#define SOU_MAGIC_EXPLICIT      0x75787670      /* "uxvp" */
#define SOU_MAGIC_IMPLICIT      0x616e6f6e      /* "anon" */

struct sockaddr_ux {
        sa_family_t             sou_family;     /* AF_UNIX */
        struct so_ux_addr       sou_addr;
};

/*
 * The sonode represents a socket. A sonode never exist in the file system
 * name space and can not be opened using open() - only the socket, socketpair
 * and accept calls create sonodes.
 *
 * When an AF_UNIX socket is bound to a pathname the sockfs
 * creates a VSOCK vnode in the underlying file system. However, the vnodeops
 * etc in this VNODE remain those of the underlying file system.
 * Sockfs uses the v_stream pointer in the underlying file system VSOCK node
 * to find the sonode bound to the pathname. The bound pathname vnode
 * is accessed through so_ux_vp.
 *
 * A socket always corresponds to a VCHR stream representing the transport
 * provider (e.g. /dev/tcp). This information is retrieved from the kernel
 * socket configuration table and entered into so_accessvp. sockfs uses
 * this to perform VOP_ACCESS checks before allowing an open of the transport
 * provider.
 *
 * The locking of sockfs uses the so_lock mutex plus the SOLOCKED
 * and SOREADLOCKED flags in so_flag. The mutex protects all the state
 * in the sonode. The SOLOCKED flag is used to single-thread operations from
 * sockfs users to prevent e.g. multiple bind() calls to operate on the
 * same sonode concurrently. The SOREADLOCKED flag is used to ensure that
 * only one thread sleeps in kstrgetmsg for a given sonode. This is needed
 * to ensure atomic operation for things like MSG_WAITALL.
 *
 * Note that so_lock is sometimes held across calls that might go to sleep
 * (kmem_alloc and soallocproto*). This implies that no other lock in
 * the system should be held when calling into sockfs; from the system call
 * side or from strrput. If locks are held while calling into sockfs
 * the system might hang when running low on memory.
 */
struct sonode {
        struct  vnode so_vnode; /* vnode associated with this sonode */
        /*
         * These fields are initialized once.
         */
        dev_t   so_dev;                 /* device the sonode represents */
        struct  vnode *so_accessvp;     /* vnode for the /dev entry */

        /* The locks themselves */
        kmutex_t        so_lock;        /* protects sonode fields */
        kcondvar_t      so_state_cv;    /* synchronize state changes */
        kcondvar_t      so_ack_cv;      /* wait for TPI acks */
        kcondvar_t      so_connind_cv;  /* wait for T_CONN_IND */
        kcondvar_t      so_want_cv;     /* wait due to SOLOCKED */

        /* These fields are protected by so_lock */
        uint_t  so_state;               /* internal state flags SS_*, below */
        uint_t  so_mode;                /* characteristics on socket. SM_* */

        mblk_t  *so_ack_mp;             /* TPI ack received from below */
        mblk_t  *so_conn_ind_head;      /* b_next list of T_CONN_IND */
        mblk_t  *so_conn_ind_tail;
        mblk_t  *so_unbind_mp;          /* Preallocated T_UNBIND_REQ message */

        ushort_t so_flag;               /* flags, see below */
        dev_t   so_fsid;                /* file system identifier */
        time_t  so_atime;               /* time of last access */
        time_t  so_mtime;               /* time of last modification */
        time_t  so_ctime;               /* time of last attributes change */
        int     so_count;               /* count of opened references */

        /* Needed to recreate the same socket for accept */
        short   so_family;
        short   so_type;
        short   so_protocol;
        short   so_version;             /* From so_socket call */
        short   so_pushcnt;             /* Number of modules above "sockmod" */

        /* Options */
        short   so_options;             /* From socket call, see socket.h */
        struct linger   so_linger;      /* SO_LINGER value */
        int     so_sndbuf;              /* SO_SNDBUF value */
        int     so_rcvbuf;              /* SO_RCVBUF value */
#ifdef notyet
        int     so_sndlowat;            /* Not yet implemented */
        int     so_rcvlowat;            /* Not yet implemented */
        int     so_sndtimeo;            /* Not yet implemented */
        int     so_rcvtimeo;            /* Not yet implemented */
#endif /* notyet */
        ushort_t so_error;              /* error affecting connection */
        ushort_t so_delayed_error;      /* From T_uderror_ind */
        int     so_backlog;             /* Listen backlog */

        /*
         * The counts (so_oobcnt and so_oobsigcnt) track the number of
         * urgent indicates that are (logically) queued on the stream head
         * read queue. The urgent data is queued on the stream head
         * as follows.
         *
         * In the normal case the SIGURG is not generated until
         * the T_EXDATA_IND arrives at the stream head. However, transports
         * that have an early indication that urgent data is pending
         * (e.g. TCP receiving a "new" urgent pointer value) can send up
         * an M_PCPROTO/SIGURG message to generate the signal early.
         *
         * The mark is indicated by either:
         *  - a T_EXDATA_IND (with no M_DATA b_cont) with MSGMARK set.
         *    When this message is consumed by sorecvmsg the socket layer
         *    sets SS_RCVATMARK until data has been consumed past the mark.
         *  - a message with MSGMARKNEXT set (indicating that the
         *    first byte of the next message constitutes the mark). When
         *    the last byte of the MSGMARKNEXT message is consumed in
         *    the stream head the stream head sets STRATMARK. This flag
         *    is cleared when at least one byte is read. (Note that
         *    the MSGMARKNEXT messages can be of zero length when there
         *    is no previous data to which the marknext can be attached.)
         *
         * While the T_EXDATA_IND method is the common case which is used
         * with all TPI transports, the MSGMARKNEXT method is needed to
         * indicate the mark when e.g. the TCP urgent byte has not been
         * received yet but the TCP urgent pointer has made TCP generate
         * the M_PCSIG/SIGURG.
         *
         * The signal (the M_PCSIG carrying the SIGURG) and the mark
         * indication can not be delivered as a single message, since
         * the signal should be delivered as high priority and any mark
         * indication must flow with the data. This implies that immediately
         * when the SIGURG has been delivered if the stream head queue is
         * empty it is impossible to determine if this will be the position
         * of the mark. This race condition is resolved by using MSGNOTMARKNEXT
         * messages and the STRNOTATMARK flag in the stream head. The
         * SIOCATMARK code calls the stream head to wait for either a
         * non-empty queue or one of the STR*ATMARK flags being set.
         * This implies that any transport that is sending M_PCSIG(SIGURG)
         * should send the appropriate MSGNOTMARKNEXT message (which can be
         * zero length) after sending an M_PCSIG to prevent SIOCATMARK
         * from sleeping unnecessarily.
         */
        mblk_t  *so_oobmsg;             /* outofline oob data */
        uint_t  so_oobsigcnt;           /* Number of SIGURG generated */
        uint_t  so_oobcnt;              /* Number of T_EXDATA_IND queued */
        pid_t   so_pgrp;                /* pgrp for signals */

        /* From T_info_ack */
        t_uscalar_t     so_tsdu_size;
        t_uscalar_t     so_etsdu_size;
        t_scalar_t      so_addr_size;
        t_uscalar_t     so_opt_size;
        t_uscalar_t     so_tidu_size;
        t_scalar_t      so_serv_type;

        /* From T_capability_ack */
        t_uscalar_t     so_acceptor_id;

        /* Internal provider information */
        struct tpi_provinfo     *so_provinfo;

        /*
         * The local and remote addresses have multiple purposes
         * but one of the key reasons for their existence and careful
         * tracking in sockfs is to support getsockname and getpeername
         * when the transport does not handle the TI_GET*NAME ioctls.
         * When all transports support the new TPI (with T_ADDR_REQ)
         * we can revisit this code.
         * The other usage of so_faddr is to keep the "connected to"
         * address for datagram sockets.
         * Finally, for AF_UNIX both local and remote addresses are used
         * to record the sockaddr_un since we use a separate namespace
         * in the loopback transport.
         */
        struct soaddr so_laddr;         /* Local address */
        struct soaddr so_faddr;         /* Peer address */
#define so_laddr_sa     so_laddr.soa_sa
#define so_faddr_sa     so_faddr.soa_sa
#define so_laddr_len    so_laddr.soa_len
#define so_faddr_len    so_faddr.soa_len
#define so_laddr_maxlen so_laddr.soa_maxlen
#define so_faddr_maxlen so_faddr.soa_maxlen
        mblk_t          *so_eaddr_mp;   /* for so_delayed_error */

        /*
         * For AF_UNIX sockets:
         * so_ux_laddr/faddr records the internal addresses used with the
         * transport.
         * so_ux_vp and v_stream->sd_vnode form the cross-
         * linkage between the underlying fs vnode corresponding to
         * the bound sockaddr_un and the socket node.
         */
        struct so_ux_addr so_ux_laddr;  /* laddr bound with the transport */
        struct so_ux_addr so_ux_faddr;  /* temporary peer address */
        struct vnode    *so_ux_bound_vp; /* bound AF_UNIX file system vnode */
        struct sonode   *so_next;       /* next sonode on socklist      */
        struct sonode   *so_prev;       /* previous sonode on socklist  */
        mblk_t  *so_discon_ind_mp;      /* T_DISCON_IND received from below */
                                        /* put here for delayed processing  */
        void            *so_priv;       /* sonode private data */
};

/* flags */
#define SOMOD           0x0001          /* update socket modification time */
#define SOACC           0x0002          /* update socket access time */

#define SOLOCKED        0x0010          /* use to serialize open/closes */
#define SOREADLOCKED    0x0020          /* serialize kstrgetmsg calls */
#define SOWANT          0x0040          /* some process waiting on lock */
#define SOCLONE         0x0080          /* child of clone driver */
#define SOASYNC_UNBIND  0x0100          /* wait for ACK of async unbind */

/*
 * Socket state bits.
 */
#define SS_ISCONNECTED          0x000001 /* socket connected to a peer */
#define SS_ISCONNECTING         0x000002 /* in process of connecting to peer */
#define SS_ISDISCONNECTING      0x000004 /* in process of disconnecting */
#define SS_CANTSENDMORE         0x000008 /* can't send more data to peer */

#define SS_CANTRCVMORE          0x000010 /* can't receive more data from peer */
#define SS_ISBOUND              0x000020 /* socket is bound */
#define SS_NDELAY               0x000040 /* FNDELAY non-blocking */
#define SS_NONBLOCK             0x000080 /* O_NONBLOCK non-blocking */

#define SS_ASYNC                0x000100 /* async i/o notify */
#define SS_ACCEPTCONN           0x000200 /* listen done */
#define SS_HASCONNIND           0x000400 /* T_CONN_IND for poll */
#define SS_SAVEDEOR             0x000800 /* Saved MSG_EOR receive side state */

#define SS_RCVATMARK            0x001000 /* at mark on input */
#define SS_OOBPEND              0x002000 /* OOB pending or present - poll */
#define SS_HAVEOOBDATA          0x004000 /* OOB data present */
#define SS_HADOOBDATA           0x008000 /* OOB data consumed */

#define SS_FADDR_NOXLATE        0x020000 /* No xlation of faddr for AF_UNIX */

#define SS_RESERVED1            0x040000 /* Reserved for NCAfs */
#define SS_RESERVED2            0x080000 /* Reserved for NCAfs */
#define SS_RESERVED3            0x100000 /* Reserved for NCAfs */
#define SS_RESERVED4            0x200000 /* Reserved for NCAfs */
#define SS_RESERVED5            0x400000 /* Reserved for NCAfs */

/* State bits that can be changed using SO_STATE setsockopt */
#define SS_CANCHANGE            (SS_ASYNC)

/* Set of states when the socket can't be rebound */
#define SS_CANTREBIND   (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING|\
                            SS_CANTSENDMORE|SS_CANTRCVMORE|SS_ACCEPTCONN)

/*
 * Characteristics of sockets. Not changed after the socket is created.
 */
#define SM_PRIV                 0x001   /* privileged for broadcast, raw... */
#define SM_ATOMIC               0x002   /* atomic data transmission */
#define SM_ADDR                 0x004   /* addresses given with messages */
#define SM_CONNREQUIRED         0x008   /* connection required by protocol */

#define SM_FDPASSING            0x010   /* passes file descriptors */
#define SM_EXDATA               0x020   /* Can handle T_EXDATA_REQ */
#define SM_OPTDATA              0x040   /* Can handle T_OPTDATA_REQ */
#define SM_BYTESTREAM           0x080   /* Byte stream - can use M_DATA */

#define SM_ACCEPTOR_ID          0x100   /* so_acceptor_id is valid */

/*
 * Socket versions. Used by the socket library when calling _so_socket().
 */
#define SOV_STREAM      0       /* Not a socket - just a stream */
#define SOV_DEFAULT     1       /* Select based on so_default_version */
#define SOV_SOCKSTREAM  2       /* Socket plus streams operations */
#define SOV_SOCKBSD     3       /* Socket with no streams operations */
#define SOV_XPG4_2      4       /* Xnet socket */

#if defined(_KERNEL) || defined(_KMEMUSER)
/*
 * Used for mapping family/type/protocol to vnode.
 * Defined here so that crash can use it.
 */
struct sockparams {
        int     sp_domain;
        int     sp_type;
        int     sp_protocol;
        char    *sp_devpath;
        int     sp_devpathlen;  /* Is 0 if sp_devpath is a static string */
        vnode_t *sp_vnode;
        struct sockparams *sp_next;
};

extern struct sockparams *sphead;

/*
 * Used to traverse the list of AF_UNIX sockets to construct the kstat
 * for netstat(1m).
 */
struct socklist {
        kmutex_t        sl_lock;
        struct sonode   *sl_list;
};

extern struct socklist socklist;
/*
 * ss_full_waits is the number of times the reader thread
 * waits when the queue is full and ss_empty_waits is the number
 * of times the consumer thread waits when the queue is empty.
 * No locks for these as they are just indicators of whether
 * disk or network or both is slow or fast.
 */
struct sendfile_stats {
        uint32_t ss_file_cached;
        uint32_t ss_file_not_cached;
        uint32_t ss_full_waits;
        uint32_t ss_empty_waits;
};

/*
 * A single sendfile request is represented by snf_req.
 * Request is serviced by reading in data chunks
 * represented by ioblk_ts.
 */
typedef struct ioblk {
        struct ioblk    *ib_next;
        uchar_t         *ib_buf;
        int             ib_size;
        int             ib_retsize;
        uint32_t        ib_refcnt;
        frtn_t          ib_frtn;
} ioblk_t;

typedef struct snf_req {
        struct snf_req  *sr_next;
        ioblk_t         *sr_ib_head;
        ioblk_t         *sr_ib_tail;
        kmutex_t        sr_lock;
        kcondvar_t      sr_cv;
        uint_t          sr_qlen;
        int             sr_hiwat;
        int             sr_lowat;
        int             sr_operation;
        struct vnode    *sr_vp;
        file_t          *sr_fp;
        u_offset_t      sr_file_off;
        u_offset_t      sr_file_size;
#define SR_READ_DONE    0x80000000
        int             sr_read_error;
        int             sr_write_error;
} snf_req_t;

/* A queue of sendfile requests */
struct sendfile_queue {
        snf_req_t       *snfq_req_head;
        snf_req_t       *snfq_req_tail;
        kmutex_t        snfq_lock;
        kcondvar_t      snfq_cv;
        int             snfq_svc_threads;       /* # of service threads */
        int             snfq_idle_cnt;          /* # of idling threads */
        int             snfq_max_threads;
        int             snfq_req_cnt;           /* Number of requests */
};

/*
 * When sendfile uses the filesystem cache, the following
 * structure is used to read the data from the cache.
 * This is similar to ioblk_t.
 */
typedef struct sf_map {
        caddr_t         sfm_base;
        int             sfm_len;
        uint32_t        sfm_refcnt;
        frtn_t          sfm_frtn;
} sf_map_t;

#define READ_OP                 1
#define SNFQ_TIMEOUT            (60 * 5 * hz)   /* 5 minutes */

#endif /* defined(_KERNEL) || defined(_KMEMUSER) */

#ifdef _KERNEL

#define ISALIGNED_cmsghdr(addr) \
                (((uintptr_t)(addr) & (_CMSG_HDR_ALIGNMENT - 1)) == 0)

#define ROUNDUP_cmsglen(len) \
        (((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1))

/*
 * Maximum size of any argument that is copied in (addresses, options,
 * access rights). MUST be at least MAXPATHLEN + 3.
 * BSD and SunOS 4.X limited this to MLEN or MCLBYTES.
 */
#define SO_MAXARGSIZE   8192

/*
 * Convert between vnode and sonode
 */
#define VTOSO(vp)       ((struct sonode *)((vp)->v_data))
#define SOTOV(sp)       (&(sp)->so_vnode)

/*
 * Internal flags for sobind()
 */
#define _SOBIND_REBIND          0x01    /* Bind to existing local address */
#define _SOBIND_UNSPEC          0x02    /* Bind to unspecified address */
#define _SOBIND_LOCK_HELD       0x04    /* so_excl_lock held by caller */
#define _SOBIND_NOXLATE         0x08    /* No addr translation for AF_UNIX */
#define _SOBIND_XPG4_2          0x10    /* xpg4.2 semantics */
#define _SOBIND_SOCKBSD         0x20    /* BSD semantics */
#define _SOBIND_LISTEN          0x40    /* Make into SS_ACCEPTCONN */

/*
 * Internal flags for sounbind()
 */
#define _SOUNBIND_REBIND        0x01    /* Don't clear fields - will rebind */
#define _SOUNBIND_LOCK_HELD     0x02    /* so_excl_lock held by caller */

/*
 * Internal flags for soconnect()
 */
#define _SOCONNECT_NOXLATE      0x01    /* No addr translation for AF_UNIX */
#define _SOCONNECT_DID_BIND     0x02    /* Unbind when connect fails */
#define _SOCONNECT_XPG4_2       0x04    /* xpg4.2 semantics */

/*
 * Internal flags for sodisconnect()
 */
#define _SODISCONNECT_LOCK_HELD 0x01    /* so_excl_lock held by caller */

/*
 * Internal flags for sogetsockopt().
 */
#define _SOGETSOCKOPT_XPG4_2    0x01    /* xpg4.2 semantics */

/*
 * Internal flags for soallocproto*()
 */
#define _ALLOC_NOSLEEP          0       /* Don't sleep for memory */
#define _ALLOC_INTR             1       /* Sleep until interrupt */
#define _ALLOC_SLEEP            2       /* Sleep forever */

/*
 * Internal structure for handling AF_UNIX file descriptor passing
 */
struct fdbuf {
        int             fd_size;        /* In bytes, for kmem_free */
        int             fd_numfd;       /* Number of elements below */
        char            *fd_ebuf;       /* Extra buffer to free  */
        int             fd_ebuflen;
        frtn_t          fd_frtn;
        struct file     *fd_fds[1];     /* One or more */
};
#define FDBUF_HDRSIZE   (sizeof (struct fdbuf) - sizeof (struct file *))

/*
 * Variable that can be patched to set what version of socket socket()
 * will create.
 */
extern int so_default_version;

#ifdef DEBUG
/* Turn on extra testing capabilities */
#define SOCK_TEST
#endif /* DEBUG */

#ifdef DEBUG
char    *pr_state(uint_t, uint_t);
char    *pr_addr(int, struct sockaddr *, t_uscalar_t);
int     so_verify_oobstate(struct sonode *);
#endif /* DEBUG */

/*
 * DEBUG macros
 */
#if defined(DEBUG) && !defined(lint)
#define SOCK_DEBUG

extern int sockdebug;
extern int sockprinterr;

#define eprint(args)    printf args
#define eprintso(so, args) \
{ if (sockprinterr && ((so)->so_options & SO_DEBUG)) printf args; }
#define eprintline(errno)                                       \
{                                                               \
        if (errno != EINTR && (sockprinterr || sockdebug > 0))  \
                printf("socket error %d: line %d file %s\n",    \
                        (errno), __LINE__, __FILE__);           \
}

#define eprintsoline(so, errno)                                 \
{ if (sockprinterr && ((so)->so_options & SO_DEBUG))            \
        printf("socket(%p) error %d: line %d file %s\n",        \
                (so), (errno), __LINE__, __FILE__);             \
}
#define dprint(level, args)     { if (sockdebug > (level)) printf args; }
#define dprintso(so, level, args) \
{ if (sockdebug > (level) && ((so)->so_options & SO_DEBUG)) printf args; }

#else /* define(DEBUG) && !defined(lint) */

#define eprint(args)            {}
#define eprintso(so, args)      {}
#define eprintline(error)       {}
#define eprintsoline(so, errno) {}
#define dprint(level, args)     {}
#define dprintso(so, level, args) {}
#ifdef DEBUG
#undef DEBUG
#endif

#endif /* defined(DEBUG) && !defined(lint) */

extern struct vfsops sock_vfsops;
extern struct kmem_cache *sock_cache;

/*
 * sockfs functions
 */
int             sock_getmsg(vnode_t *, struct strbuf *, struct strbuf *,
                        uchar_t *, int *, int, rval_t *);
int             sock_putmsg(vnode_t *, struct strbuf *, struct strbuf *,
                        uchar_t, int, int);
struct sonode   *socreate(vnode_t *, int, int, int, int, struct sonode *,
                        int *);
int             sock_open(struct vnode **, int, struct cred *);
struct vnodeops *sock_getvnodeops(void);
void            so_sock2stream(struct sonode *);
void            so_stream2sock(struct sonode *);
int             sockinit(struct vfssw *, int);
struct vnode    *makesockvp(struct vnode *, int, int, int);
void            sockfree(struct sonode *);
void            so_update_attrs(struct sonode *, int);
int             soconfig(int, int, int, char *, int);
struct vnode    *solookup(int, int, int, char *, int *);
void            so_lock_single(struct sonode *);
void            so_unlock_single(struct sonode *, int);
int             so_lock_read(struct sonode *, int);
int             so_lock_read_intr(struct sonode *, int);
void            so_unlock_read(struct sonode *);
void            *sogetoff(mblk_t *, t_uscalar_t, t_uscalar_t, uint_t);
void            so_getopt_srcaddr(void *, t_uscalar_t,
                        void **, t_uscalar_t *);
int             so_getopt_unix_close(void *, t_uscalar_t);
int             so_addr_verify(struct sonode *, const struct sockaddr *,
                        socklen_t);
int             so_ux_addr_xlate(struct sonode *, struct sockaddr *,
                        socklen_t, int, void **, socklen_t *);
void            fdbuf_free(struct fdbuf *);
mblk_t          *fdbuf_allocmsg(int, struct fdbuf *);
int             fdbuf_create(void *, int, struct fdbuf **);
void            so_closefds(void *, t_uscalar_t, int, int);
int             so_getfdopt(void *, t_uscalar_t, int, void **, int *);
t_uscalar_t     so_optlen(void *, t_uscalar_t, int);
void            so_cmsg2opt(void *, t_uscalar_t, int, mblk_t *);
t_uscalar_t     so_cmsglen(mblk_t *, void *, t_uscalar_t, int);
int             so_opt2cmsg(mblk_t *, void *, t_uscalar_t, int,
                        void *, t_uscalar_t);
void            soisconnecting(struct sonode *);
void            soisconnected(struct sonode *);
void            soisdisconnected(struct sonode *, int);
void            socantsendmore(struct sonode *);
void            socantrcvmore(struct sonode *);
void            soseterror(struct sonode *, int);
int             sogeterr(struct sonode *, int);
int             sogetrderr(vnode_t *, int, int *);
int             sogetwrerr(vnode_t *, int, int *);
void            so_unix_close(struct sonode *);
mblk_t          *soallocproto(size_t, int);
mblk_t          *soallocproto1(const void *, ssize_t, ssize_t, int);
void            soappendmsg(mblk_t *, const void *, ssize_t);
mblk_t          *soallocproto2(const void *, ssize_t, const void *, ssize_t,
                        ssize_t, int);
mblk_t          *soallocproto3(const void *, ssize_t, const void *, ssize_t,
                        const void *, ssize_t, ssize_t, int);
int             sowaitprim(struct sonode *, t_scalar_t, t_scalar_t,
                        t_uscalar_t, mblk_t **, clock_t);
int             sowaitokack(struct sonode *, t_scalar_t);
int             sowaitack(struct sonode *, mblk_t **, clock_t);
void            soqueueack(struct sonode *, mblk_t *);
int             sowaitconnind(struct sonode *, int, mblk_t **);
void            soqueueconnind(struct sonode *, mblk_t *);
int             soflushconnind(struct sonode *, t_scalar_t);
void            so_drain_discon_ind(struct sonode *);
void            so_flush_discon_ind(struct sonode *);
int             sowaitconnected(struct sonode *, int, int);

int             sosend_dgram(struct sonode *, struct sockaddr *,
                        socklen_t, struct uio *, int);
int             sosend_svc(struct sonode *, struct uio *, t_scalar_t, int, int);
int             so_strinit(struct sonode *, struct sonode *);
int             sobind(struct sonode *, struct sockaddr *,
                        socklen_t, int, int);
int             sounbind(struct sonode *, int);
int             solisten(struct sonode *, int);
int             soaccept(struct sonode *, int, struct sonode **);
int             soconnect(struct sonode *, const struct sockaddr *,
                        socklen_t, int, int);
int             sodisconnect(struct sonode *, t_scalar_t, int);
int             soshutdown(struct sonode *, int);
int             sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *);
int             sosendmsg(struct sonode *, struct nmsghdr *, struct uio *);
int             sogetpeername(struct sonode *);
int             sogetsockname(struct sonode *);
int             sogetsockopt(struct sonode *, int, int,
                        void *, socklen_t *, int);
int             sosetsockopt(struct sonode *, int, int, const void *,
                        t_uscalar_t);
ssize_t         soreadfile(file_t *, uchar_t *, u_offset_t, int *, size_t);

#endif

/*
 * Internal structure for obtaining sonode information from the socklist.
 * These types match those corresponding in the sonode structure.
 * This is not a published interface, and may change at any time.
 */
struct sockinfo {
        uint_t          si_size;                /* real length of this struct */
        short           si_family;
        short           si_type;
        ushort_t        si_flag;
        uint_t          si_state;
        uint_t          si_ux_laddr_sou_magic;
        uint_t          si_ux_faddr_sou_magic;
        t_scalar_t      si_serv_type;
        t_uscalar_t     si_laddr_soa_len;
        t_uscalar_t     si_faddr_soa_len;
        uint16_t        si_laddr_family;
        uint16_t        si_faddr_family;
        char            si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
        char            si_faddr_sun_path[MAXPATHLEN + 1];
};


#ifdef  __cplusplus
}
#endif

#endif  /* _SYS_SOCKETVAR_H */
/*
 * Copyright (c) 1991-1999 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * Udp protocol header.
 * Per RFC 768, September, 1981.
 */

#ifndef _NETINET_UDP_H
#define _NETINET_UDP_H

#pragma ident   "@(#)udp.h      1.6     99/11/04 SMI"
/* udp.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86  */

#ifdef  __cplusplus
extern "C" {
#endif

struct udphdr {
        in_port_t       uh_sport;               /* source port */
        in_port_t       uh_dport;               /* destination port */
        int16_t         uh_ulen;                /* udp length */
        uint16_t        uh_sum;                 /* udp checksum */
};

/* Option definitions. */
#define UDP_ANONPRIVBIND        0x0100          /* for internal use only */
#define UDP_EXCLBIND            0x0101          /* for internal use only */

/*
 * Following option in UDP_ namespace required to be exposed through
 * <xti.h> (It also requires exposing options not implemented). The options
 * with potential for conflicts use #ifndef guards.
 *
 */
#ifndef UDP_CHECKSUM
#define UDP_CHECKSUM    0x0600
#endif

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_UDP_H */
/*
 * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1985, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * Interface address, Internet version.  One of these structures
 * is allocated for each interface with an Internet address.
 * The ifaddr structure contains the protocol-independent part
 * of the structure and is assumed to be first.
 */

#ifndef _NETINET_IN_VAR_H
#define _NETINET_IN_VAR_H

#pragma ident   "@(#)in_var.h   1.3     98/01/06 SMI"
/* in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86       */

#ifdef  __cplusplus
extern "C" {
#endif

struct in_ifaddr {
        struct  ifaddr ia_ifa;          /* protocol-independent info */
#define ia_addr ia_ifa.ifa_addr
#define ia_broadaddr    ia_ifa.ifa_broadaddr
#define ia_dstaddr      ia_ifa.ifa_dstaddr
#define ia_ifp          ia_ifa.ifa_ifp
        ulong_t ia_net;                 /* network number of interface */
        ulong_t ia_netmask;             /* mask of net part */
        ulong_t ia_subnet;              /* subnet number, including net */
        ulong_t ia_subnetmask;          /* mask of net + subnet */
        struct  in_addr ia_netbroadcast; /* broadcast addr for (logical) net */
        int     ia_flags;
        struct  in_ifaddr *ia_next;     /* next in list of internet addresses */
};
/*
 * Given a pointer to an in_ifaddr (ifaddr),
 * return a pointer to the addr as a sockadd_in.
 */
#define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr))
/*
 * ia_flags
 */
#define IFA_ROUTE       0x01            /* routing entry installed */

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_IN_VAR_H */
/*
 * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that this notice is preserved and that due credit is given
 * to the University of California at Berkeley. The name of the University
 * may not be used to endorse or promote products derived from this
 * software without specific prior written permission. This software
 * is provided ``as is'' without express or implied warranty.
 */

#ifndef _NETINET_IF_ETHER_H
#define _NETINET_IF_ETHER_H

#pragma ident   "@(#)if_ether.h 1.10    01/09/13 SMI"
/* if_ether.h 1.28 89/08/04 SMI; from UCB 7.2 12/7/87 */

/*
 * The following include is for compatibility with SunOS 3.x and
 * 4.3bsd.  Newly written programs should include it separately.
 */
#include <net/if_arp.h>

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * Ethernet address - 6 octets
 */
typedef uchar_t ether_addr_t[6];

/*
 * Ethernet address - 6 octets
 */
struct ether_addr {
        uchar_t ether_addr_octet[6];
};

/*
 * Structure of a 10Mb/s Ethernet header.
 */
struct  ether_header {
        struct  ether_addr ether_dhost;
        struct  ether_addr ether_shost;
        ushort_t ether_type;
};

#define ETHERTYPE_PUP           0x0200          /* PUP protocol */
#define ETHERTYPE_IP            0x0800          /* IP protocol */
#define ETHERTYPE_ARP           0x0806          /* Addr. resolution protocol */
#define ETHERTYPE_REVARP        0x8035          /* Reverse ARP */
#define ETHERTYPE_AT            0x809b          /* AppleTalk protocol */
#define ETHERTYPE_AARP          0x80f3          /* AppleTalk ARP */
#define ETHERTYPE_IPV6          0x86dd          /* IPv6 */
#define ETHERTYPE_PPPOED        0x8863          /* PPPoE Discovery Stage */
#define ETHERTYPE_PPPOES        0x8864          /* PPPoE Session Stage */

/*
 * 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_TRAIL         0x1000          /* Trailer packet */
#define ETHERTYPE_NTRAILER      16

#define ETHERMTU        1500
#define ETHERMIN        (60-14)

/*
 * Ethernet Address Resolution Protocol.
 *
 * See RFC 826 for protocol description.  Structure below is adapted
 * to resolving internet addresses.  Field names used correspond to
 * RFC 826.
 */
struct  ether_arp {
        struct  arphdr ea_hdr;          /* fixed-size header */
        ether_addr_t arp_sha;           /* sender hardware address */
        uchar_t arp_spa[4];             /* sender protocol address */
        ether_addr_t arp_tha;           /* target hardware address */
        uchar_t arp_tpa[4];             /* target protocol address */
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op  ea_hdr.ar_op

/*
 *      multicast address structure
 *
 *      Keep a reference count for each multicast address so
 *      addresses loaded into chip are unique.
 */
struct  mcaddr {
        struct  ether_addr      mc_enaddr;      /* multicast address */
        ushort_t mc_count;                      /* reference count */
};
#define MCADDRMAX       64              /* multicast addr table length */
#define MCCOUNTMAX      4096            /* multicast addr max reference count */

/*
 * Structure shared between the ethernet driver modules and
 * the address resolution code.  For example, each ec_softc or il_softc
 * begins with this structure.
 *
 * The structure contains a pointer to an array of multicast addresses.
 * This pointer is NULL until the first successful SIOCADDMULTI ioctl
 * is issued for the interface.
 */
struct  arpcom {
        struct  ifnet ac_if;            /* network-visible interface */
        struct  ether_addr ac_enaddr;   /* ethernet hardware address */
        struct  in_addr ac_ipaddr;      /* copy of ip address- XXX */
        struct  mcaddr *ac_mcaddr;      /* table of multicast addrs */
        ushort_t ac_nmcaddr;            /* count of M/C addrs in use */
        struct  in_addr ac_lastip;      /* cache of last ARP lookup */
        struct  ether_addr ac_lastarp;  /* result of the last ARP */
};

/*
 * Internet to ethernet address resolution table.
 */
struct  arptab {
        struct  in_addr at_iaddr;       /* internet address */
        union {
            struct ether_addr atu_enaddr;       /* ethernet address */
            long   atu_tvsec;                   /* timestamp if incomplete */
        }       at_union;
        uchar_t at_timer;               /* minutes since last reference */
        uchar_t at_flags;               /* flags */
        struct  mbuf *at_hold;          /* last packet until resolved/timeout */
};

#define at_enaddr       at_union.atu_enaddr
#define at_tvsec        at_union.atu_tvsec

/*
 * 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.
 */
#if defined(sparc) || defined(__sparc)
#define ether_cmp(a, b) (((short *)b)[2] != ((short *)a)[2] || \
        ((short *)b)[1] != ((short *)a)[1] || \
        ((short *)b)[0] != ((short *)a)[0])
#else
#define ether_cmp(a, b) (bcmp((caddr_t)a, (caddr_t)b, 6))
#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.
 */
#if defined(sparc) || defined(__sparc)
#define ether_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \
        ((short *)b)[1] = ((short *)a)[1]; ((short *)b)[2] = ((short *)a)[2]; }
#else
#define ether_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 6))
#endif

/*
 * Copy IP 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.
 */
#if defined(sparc) || defined(__sparc)
#define ip_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \
        ((short *)b)[1] = ((short *)a)[1]; }
#else
#define ip_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 4))
#endif

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_IF_ETHER_H */
/*
 * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * Overlay for ip header used by other protocols (tcp, udp).
 */

#ifndef _NETINET_IP_VAR_H
#define _NETINET_IP_VAR_H

#pragma ident   "@(#)ip_var.h   1.5     01/10/03 SMI"
/* ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86      */

#include <sys/isa_defs.h>

#ifdef  __cplusplus
extern "C" {
#endif

struct ipovly {
#ifdef _LP64
        uint32_t        ih_next, ih_prev;
#else
        caddr_t ih_next, ih_prev;       /* for protocol sequence q's */
#endif
        uchar_t ih_x1;                  /* (unused) */
        uchar_t ih_pr;                  /* protocol */
        short   ih_len;                 /* protocol length */
        struct  in_addr ih_src;         /* source internet address */
        struct  in_addr ih_dst;         /* destination internet address */
};

/*
 * Ip reassembly queue structure.  Each fragment
 * being reassembled is attached to one of these structures.
 * They are timed out after ipq_ttl drops to 0, and may also
 * be reclaimed if memory becomes tight.
 */
struct ipq {
        struct  ipq *next, *prev;       /* to other reass headers */
        uchar_t ipq_ttl;                /* time for reass q to live */
        uchar_t ipq_p;                  /* protocol of this fragment */
        ushort_t ipq_id;                /* sequence id for reassembly */
        struct  ipasfrag *ipq_next, *ipq_prev;
                                        /* to ip headers of fragments */
        struct  in_addr ipq_src, ipq_dst;
};

/*
 * Ip header, when holding a fragment.
 *
 * Note: ipf_next must be at same offset as ipq_next above
 */
struct  ipasfrag {
#ifdef _BIT_FIELDS_LTOH
        uchar_t ip_hl:4,
                ip_v:4;
#else
        uchar_t ip_v:4,
                ip_hl:4;
#endif
        uchar_t ipf_mff;                /* copied from (ip_off&IP_MF) */
        short   ip_len;
        ushort_t ip_id;
        short   ip_off;
        uchar_t ip_ttl;
        uchar_t ip_p;
        ushort_t ip_sum;
        struct  ipasfrag *ipf_next;     /* next fragment */
        struct  ipasfrag *ipf_prev;     /* previous fragment */
};

/*
 * Structure stored in mbuf in inpcb.ip_options
 * and passed to ip_output when ip options are in use.
 * The actual length of the options (including ipopt_dst)
 * is in m_len.
 */
#define MAX_IPOPTLEN    40

struct ipoption {
        struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
        char    ipopt_list[MAX_IPOPTLEN];       /* options proper */
};

struct  ipstat {
        long    ips_total;              /* total packets received */
        long    ips_badsum;             /* checksum bad */
        long    ips_tooshort;           /* packet too short */
        long    ips_toosmall;           /* not enough data */
        long    ips_badhlen;            /* ip header length < data size */
        long    ips_badlen;             /* ip length < ip header length */
        long    ips_fragments;          /* fragments received */
        long    ips_fragdropped;        /* frags dropped (dups, out of space) */
        long    ips_fragtimeout;        /* fragments timed out */
        long    ips_forward;            /* packets forwarded */
        long    ips_cantforward;        /* packets rcvd for unreachable dest */
        long    ips_redirectsent;       /* packets forwarded on same net */
};

#ifdef _KERNEL
/* flags passed to ip_output as last parameter */
#define IP_FORWARDING           0x1             /* most of ip header exists */
#define IP_ROUTETOIF            SO_DONTROUTE    /* bypass routing tables */
#define IP_ALLOWBROADCAST       SO_BROADCAST    /* can send broadcast packets */
#endif

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_IP_VAR_H */
/*
 * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * Kernel variables for tcp.
 */

#ifndef _NETINET_TCP_VAR_H
#define _NETINET_TCP_VAR_H

#pragma ident   "@(#)tcp_var.h  1.4     98/01/06 SMI"
/* tcp_var.h 1.11 88/08/19 SMI; from UCB 7.3 6/30/87    */

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * Tcp control block, one per tcp; fields:
 */
struct tcpcb {
        struct  tcpiphdr *seg_next;     /* sequencing queue */
        struct  tcpiphdr *seg_prev;
        short   t_state;                /* state of this connection */
        short   t_timer[TCPT_NTIMERS];  /* tcp timers */
        short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
        short   t_rxtcur;               /* current retransmit value */
        short   t_dupacks;              /* consecutive dup acks recd */
        ushort_t t_maxseg;              /* maximum segment size */
        char    t_force;                /* 1 if forcing out a byte */
        uchar_t t_flags;
#define TF_ACKNOW       0x01            /* ack peer immediately */
#define TF_DELACK       0x02            /* ack, but try to delay it */
#define TF_NODELAY      0x04            /* don't delay packets to coalesce */
#define TF_NOOPT        0x08            /* don't use tcp options */
#define TF_SENTFIN      0x10            /* have sent FIN */
        struct  tcpiphdr *t_template;   /* skeletal packet for transmit */
        struct  inpcb *t_inpcb;         /* back pointer to internet pcb */
/*
 * The following fields are used as in the protocol specification.
 * See RFC783, Dec. 1981, page 21.
 */
/* send sequence variables */
        tcp_seq snd_una;                /* send unacknowledged */
        tcp_seq snd_nxt;                /* send next */
        tcp_seq snd_up;                 /* send urgent pointer */
        tcp_seq snd_wl1;                /* window update seg seq number */
        tcp_seq snd_wl2;                /* window update seg ack number */
        tcp_seq iss;                    /* initial send sequence number */
        ushort_t snd_wnd;               /* send window */
/* receive sequence variables */
        ushort_t rcv_wnd;               /* receive window */
        tcp_seq rcv_nxt;                /* receive next */
        tcp_seq rcv_up;                 /* receive urgent pointer */
        tcp_seq irs;                    /* initial receive sequence number */
/*
 * Additional variables for this implementation.
 */
/* receive variables */
        tcp_seq rcv_adv;                /* advertised window */
/* retransmit variables */
        tcp_seq snd_max;                /* highest sequence number sent */
                                        /* used to recognize retransmits */

/* congestion control (for slow start, source quench, retransmit after loss) */
        ushort_t snd_cwnd;              /* congestion-controlled window */
        ushort_t snd_ssthresh;          /* snd_cwnd size threshhold for */
                                        /* for slow start exponential to */
/*
 * transmit timing stuff.
 * srtt and rttvar are stored as fixed point; for convenience in smoothing,
 * srtt has 3 bits to the right of the binary point, rttvar has 2.
 * "Variance" is actually smoothed difference.
 */
        short   t_idle;                 /* inactivity time */
        short   t_rtt;                  /* round trip time */
        tcp_seq t_rtseq;                /* sequence number being timed */
        short   t_srtt;                 /* smoothed round-trip time */
        short   t_rttvar;               /* variance in round-trip time */
        ushort_t max_rcvd;              /* most peer has sent into window */
        ushort_t max_sndwnd;            /* largest window peer has offered */
/* out-of-band data */
        char    t_oobflags;             /* have some */
        char    t_iobc;                 /* input character */
#define TCPOOB_HAVEDATA 0x01
#define TCPOOB_HADDATA  0x02
};

#define intotcpcb(ip)   ((struct tcpcb *)(ip)->inp_ppcb)
#define sototcpcb(so)   (intotcpcb(sotoinpcb(so)))

/*
 * TCP statistics.
 * Many of these should be kept per connection,
 * but that's inconvenient at the moment.
 */
struct  tcpstat {
        uint_t  tcps_connattempt;       /* connections initiated */
        uint_t  tcps_accepts;           /* connections accepted */
        uint_t  tcps_connects;          /* connections established */
        uint_t  tcps_drops;             /* connections dropped */
        uint_t  tcps_conndrops;         /* embryonic connections dropped */
        uint_t  tcps_closed;            /* conn. closed (includes drops) */
        uint_t  tcps_segstimed;         /* segs where we tried to get rtt */
        uint_t  tcps_rttupdated;        /* times we succeeded */
        uint_t  tcps_delack;            /* delayed acks sent */
        uint_t  tcps_timeoutdrop;       /* conn. dropped in rxmt timeout */
        uint_t  tcps_rexmttimeo;        /* retransmit timeouts */
        uint_t  tcps_persisttimeo;      /* persist timeouts */
        uint_t  tcps_keeptimeo;         /* keepalive timeouts */
        uint_t  tcps_keepprobe;         /* keepalive probes sent */
        uint_t  tcps_keepdrops;         /* connections dropped in keepalive */

        uint_t  tcps_sndtotal;          /* total packets sent */
        uint_t  tcps_sndpack;           /* data packets sent */
        uint_t  tcps_sndbyte;           /* data bytes sent */
        uint_t  tcps_sndrexmitpack;     /* data packets retransmitted */
        uint_t  tcps_sndrexmitbyte;     /* data bytes retransmitted */
        uint_t  tcps_sndacks;           /* ack-only packets sent */
        uint_t  tcps_sndprobe;          /* window probes sent */
        uint_t  tcps_sndurg;            /* packets sent with URG only */
        uint_t  tcps_sndwinup;          /* window update-only packets sent */
        uint_t  tcps_sndctrl;           /* control (SYN|FIN|RST) packets sent */

        uint_t  tcps_rcvtotal;          /* total packets received */
        uint_t  tcps_rcvpack;           /* packets received in sequence */
        uint_t  tcps_rcvbyte;           /* bytes received in sequence */
        uint_t  tcps_rcvbadsum;         /* packets received with ccksum errs */
        uint_t  tcps_rcvbadoff;         /* packets received with bad offset */
        uint_t  tcps_rcvshort;          /* packets received too short */
        uint_t  tcps_rcvduppack;        /* duplicate-only packets received */
        uint_t  tcps_rcvdupbyte;        /* duplicate-only bytes received */
        uint_t  tcps_rcvpartduppack;    /* packets with some duplicate data */
        uint_t  tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
        uint_t  tcps_rcvoopack;         /* out-of-order packets received */
        uint_t  tcps_rcvoobyte;         /* out-of-order bytes received */
        uint_t  tcps_rcvpackafterwin;   /* packets with data after window */
        uint_t  tcps_rcvbyteafterwin;   /* bytes rcvd after window */
        uint_t  tcps_rcvafterclose;     /* packets rcvd after "close" */
        uint_t  tcps_rcvwinprobe;       /* rcvd window probe packets */
        uint_t  tcps_rcvdupack;         /* rcvd duplicate acks */
        uint_t  tcps_rcvacktoomuch;     /* rcvd acks for unsent data */
        uint_t  tcps_rcvackpack;        /* rcvd ack packets */
        uint_t  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
        uint_t  tcps_rcvwinupd;         /* rcvd window update packets */
};

#define TCP_COMPAT_42

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_TCP_VAR_H */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * UDP kernel structures and variables.
 */

#ifndef _NETINET_UDP_VAR_H
#define _NETINET_UDP_VAR_H

#pragma ident   "@(#)udp_var.h  1.2     93/02/04 SMI"
/* udp_var.h 1.8 88/08/19 SMI; from UCB 7.1 6/5/86      */

#ifdef  __cplusplus
extern "C" {
#endif

struct  udpiphdr {
        struct  ipovly ui_i;            /* overlaid ip structure */
        struct  udphdr ui_u;            /* udp header */
};
#define ui_next         ui_i.ih_next
#define ui_prev         ui_i.ih_prev
#define ui_x1           ui_i.ih_x1
#define ui_pr           ui_i.ih_pr
#define ui_len          ui_i.ih_len
#define ui_src          ui_i.ih_src
#define ui_dst          ui_i.ih_dst
#define ui_sport        ui_u.uh_sport
#define ui_dport        ui_u.uh_dport
#define ui_ulen         ui_u.uh_ulen
#define ui_sum          ui_u.uh_sum

struct  udpstat {
        int     udps_hdrops;
        int     udps_badsum;
        int     udps_badlen;
        int     udps_fullsock;
};

#define UDP_TTL         30              /* time to live for UDP packets */

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_UDP_VAR_H */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * Variables related to this implementation
 * of the internet control message protocol.
 */

#ifndef _NETINET_ICMP_VAR_H
#define _NETINET_ICMP_VAR_H

#pragma ident   "@(#)icmp_var.h 1.2     93/02/04 SMI"
/* icmp_var.h 1.10 88/08/19 SMI; from UCB 7.2 1/13/87   */

#ifdef  __cplusplus
extern "C" {
#endif

struct  icmpstat {
/* statistics related to icmp packets generated */
        int     icps_error;             /* # of calls to icmp_error */
        int     icps_oldshort;          /* no error 'cuz old ip too short */
        int     icps_oldicmp;           /* no error 'cuz old was icmp */
        int     icps_outhist[ICMP_MAXTYPE + 1];
/* statistics related to input messages processed */
        int     icps_badcode;           /* icmp_code out of range */
        int     icps_tooshort;          /* packet < ICMP_MINLEN */
        int     icps_checksum;          /* bad checksum */
        int     icps_badlen;            /* calculated bound mismatch */
        int     icps_reflect;           /* number of responses */
        int     icps_inhist[ICMP_MAXTYPE + 1];
};

#ifdef  __cplusplus
}
#endif

#endif  /* _NETINET_ICMP_VAR_H */
/*
 * Copyright (c) 1992-2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */
/*
 * Copyright (c) 1980, 1986, 1993
 *      The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Kernel resident routing tables.
 *
 * The routing tables are initialized when interface addresses
 * are set by making entries for all directly connected interfaces.
 */

#ifndef _NET_ROUTE_H
#define _NET_ROUTE_H

#pragma ident   "@(#)route.h    1.17    00/10/01 SMI"
/* from UCB 8.5 (Berkeley) 2/8/95 */

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * A route consists of a destination address and a reference
 * to a routing entry.  These are often held by protocols
 * in their control blocks, e.g. inpcb.
 */
struct route {
        struct  rtentry *ro_rt;
        struct  sockaddr ro_dst;
};

/*
 * These numbers are used by reliable protocols for determining
 * retransmission behavior and are included in the routing structure.
 *
 * rmx_rtt and rmx_rttvar are stored as microseconds;
 */
typedef struct rt_metrics {
        uint32_t        rmx_locks;      /* Kernel must leave these values */
                                        /* alone */
        uint32_t        rmx_mtu;        /* MTU for this path */
        uint32_t        rmx_hopcount;   /* max hops expected */
        uint32_t        rmx_expire;     /* lifetime for route, e.g. redirect */
        uint32_t        rmx_recvpipe;   /* inbound delay-bandwith product */
        uint32_t        rmx_sendpipe;   /* outbound delay-bandwith product */
        uint32_t        rmx_ssthresh;   /* outbound gateway buffer limit */
        uint32_t        rmx_rtt;        /* estimated round trip time */
        uint32_t        rmx_rttvar;     /* estimated rtt variance */
        uint32_t        rmx_pksent;     /* packets sent using this route */
} rt_metrics_t;

/*
 * OLD rtentry structure not used in the kernel. Instead the kernel
 * uses struct ire defined in <inet/ip.h>.
 *
 * We distinguish between routes to hosts and routes to networks,
 * preferring the former if available.  For each route we infer
 * the interface to use from the gateway address supplied when
 * the route was entered.  Routes that forward packets through
 * gateways are marked so that the output routines know to address the
 * gateway rather than the ultimate destination.
 */
struct rtentry {
        uint_t  rt_hash;                /* to speed lookups */
        struct  sockaddr rt_dst;        /* key */
        struct  sockaddr rt_gateway;    /* value */
        short   rt_flags;               /* up/down?, host/net */
        short   rt_refcnt;              /* # held references */
        uint_t  rt_use;                 /* raw # packets forwarded */

/*
 * The kernel does not use this field, and without it the structure is
 * datamodel independent.
 */
#if !defined(_KERNEL)
        struct  ifnet *rt_ifp;          /* the answer: interface to use */
#endif /* !defined(_KERNEL) */
};

#define RTF_UP          0x1             /* route usable */
#define RTF_GATEWAY     0x2             /* destination is a gateway */
#define RTF_HOST        0x4             /* host entry (net otherwise) */
#define RTF_REJECT      0x8             /* host or net unreachable */
#define RTF_DYNAMIC     0x10            /* created dynamically (by redirect) */
#define RTF_MODIFIED    0x20            /* modified dynamically (by redirect) */
#define RTF_DONE        0x40            /* message confirmed */
#define RTF_MASK        0x80            /* subnet mask present */
#define RTF_CLONING     0x100           /* generate new routes on use */
#define RTF_XRESOLVE    0x200           /* external daemon resolves name */
#define RTF_LLINFO      0x400           /* generated by ARP or ESIS */
#define RTF_STATIC      0x800           /* manually added */
#define RTF_BLACKHOLE   0x1000          /* just discard pkts (during updates) */
#define RTF_PRIVATE     0x2000          /* do not advertise this route */
#define RTF_PROTO2      0x4000          /* protocol specific routing flag */
#define RTF_PROTO1      0x8000          /* protocol specific routing flag */


/*
 * OLD statistics not used by the kernel. The kernel uses <inet/mib2.h>.
 *
 * Routing statistics.
 */
struct  rtstat {
        short   rts_badredirect;        /* bogus redirect calls */
        short   rts_dynamic;            /* routes created by redirects */
        short   rts_newgateway;         /* routes modified by redirects */
        short   rts_unreach;            /* lookups which failed */
        short   rts_wildcard;           /* lookups satisfied by a wildcard */
};

/*
 * Structures for routing messages.
 */
typedef struct rt_msghdr {
        ushort_t rtm_msglen;    /* to skip over non-understood messages */
        uchar_t rtm_version;    /* future binary compatibility */
        uchar_t rtm_type;       /* message type */
        ushort_t rtm_index;     /* index for associated ifp */
        int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
        int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
        pid_t   rtm_pid;        /* identify sender */
        int     rtm_seq;        /* for sender to identify action */
        int     rtm_errno;      /* why failed */
        int     rtm_use;        /* from rtentry */
        uint_t  rtm_inits;      /* which metrics we are initializing */
        struct  rt_metrics rtm_rmx; /* metrics themselves */
} rt_msghdr_t;

#define RTM_VERSION     3       /* Up the ante and ignore older versions */

#define RTM_ADD         0x1     /* Add Route */
#define RTM_DELETE      0x2     /* Delete Route */
#define RTM_CHANGE      0x3     /* Change Metrics or flags */
#define RTM_GET         0x4     /* Report Metrics */
#define RTM_LOSING      0x5     /* Kernel Suspects Partitioning */
#define RTM_REDIRECT    0x6     /* Told to use different route */
#define RTM_MISS        0x7     /* Lookup failed on this address */
#define RTM_LOCK        0x8     /* fix specified metrics */
#define RTM_OLDADD      0x9     /* caused by SIOCADDRT */
#define RTM_OLDDEL      0xa     /* caused by SIOCDELRT */
#define RTM_RESOLVE     0xb     /* req to resolve dst to LL addr */
#define RTM_NEWADDR     0xc     /* address being added to iface */
#define RTM_DELADDR     0xd     /* address being removed from iface */
#define RTM_IFINFO      0xe     /* iface going up/down etc. */

#define RTV_MTU         0x1     /* init or lock _mtu */
#define RTV_HOPCOUNT    0x2     /* init or lock _hopcount */
#define RTV_EXPIRE      0x4     /* init or lock _expire */
#define RTV_RPIPE       0x8     /* init or lock _recvpipe */
#define RTV_SPIPE       0x10    /* init or lock _sendpipe */
#define RTV_SSTHRESH    0x20    /* init or lock _ssthresh */
#define RTV_RTT         0x40    /* init or lock _rtt */
#define RTV_RTTVAR      0x80    /* init or lock _rttvar */

/*
 * Bitmask values for rtm_addr.
 */
#define RTA_DST         0x1     /* destination sockaddr present */
#define RTA_GATEWAY     0x2     /* gateway sockaddr present */
#define RTA_NETMASK     0x4     /* netmask sockaddr present */
#define RTA_GENMASK     0x8     /* cloning mask sockaddr present */
#define RTA_IFP         0x10    /* interface name sockaddr present */
#define RTA_IFA         0x20    /* interface addr sockaddr present */
#define RTA_AUTHOR      0x40    /* sockaddr for author of redirect */
#define RTA_BRD         0x80    /* for NEWADDR, broadcast or p-p dest addr */
#define RTA_SRC         0x100   /* source sockaddr present */
#define RTA_SRCIFP      0x200   /* source interface index sockaddr present */

#define RTA_NUMBITS     10      /* Number of bits used in RTA_* */

#ifdef  __cplusplus
}
#endif

#endif  /* _NET_ROUTE_H */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]