sppp.h revision 002c70ff32f5df6f93c15f88d351ce26443e6ee7
/*
* sppp.h - Solaris STREAMS PPP multiplexing pseudo-driver definitions
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, provided that the above copyright
* notice appears in all copies.
*
* SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
*
* Copyright (c) 1994 The Australian National University.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, provided that the above copyright
* notice appears in all copies. This software is provided without any
* warranty, express or implied. The Australian National University
* makes no representations about the suitability of this software for
* any purpose.
*
* IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
* PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
* This driver is derived from the original SVR4 STREAMS PPP driver
* originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>.
*
* Adi Masputra <adi.masputra@sun.com> rewrote and restructured the code
* for improved performance and scalability.
*
* $Id: sppp.h,v 1.0 2000/05/08 01:10:12 masputra Exp $
*/
#ifndef __SPPP_H
#define __SPPP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <net/ppp_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(ETHERTYPE_IP)
#define ETHERTYPE_IP 0x800
#endif
#if !defined(ETHERTYPE_IPV6)
#define ETHERTYPE_IPV6 0x86dd
#endif
#if !defined(ETHERTYPE_PPP)
#define ETHERTYPE_PPP 0x880b
#endif
#if !defined(ETHERTYPE_ALLSAP)
#define ETHERTYPE_ALLSAP 0
#endif
#if !defined(PPP_ALLSAP)
#define PPP_ALLSAP PPP_ALLSTATIONS
#endif
/*
* DLPI handler (function table item).
*/
struct sppp_dlpi_pinfo_t {
int pi_minlen; /* minimum primitive length */
int (*pi_funcp)(); /* function() to call */
};
#ifndef DL_MAXPRIM
#define DL_MAXPRIM DL_GET_STATISTICS_ACK
#endif
/*
* Per-attachment kstats.
*/
typedef struct sppp_kstats {
/* 64 bit entries */
/*
* Same order as above. Note that for netstat -i to work, there needs
* to be "ipackets", "opackets", "ierrors", and "oerrors" kstat named
* variables.
*/
#define SPPP_KSTATS_NAMES \
"allocbfail", "rbytes", "ierrors", "ierrors_lower", "ioctlsfwd", \
"ioctlsfwdok", "ioctlsfwderr", "ipackets", "ipkts_ctl", \
"ipkts_qdropped", "ipkts_runts", "ipkts_toolong", "lsneedup", \
"lsdown", "mctlsfwd", "mctlsfwderr", "mctlsknown", "mctlsunknown", \
"obytes", "oerrors", "oerrors_lower", "opackets", "opkts_ctl", \
"opkts_qdropped", "opkts_toolong", "opkts_runts"
#define SPPP_KSTATS64_NAMES \
"ipackets64", "opackets64", "rbytes64", "obytes64"
/*
* dl_addr_length needs to be equal to the absolute value of dl_sap_length,
* in order for IP to derive a default setting for IFF_POINTOPOINT flag.
*/
typedef t_uscalar_t spppreqsap_t;
#define SPPP_SAPL sizeof (spppreqsap_t)
#define SPPP_ADDRL SPPP_SAPL
/*
* Per-Stream instance state information.
*
* Each instance is dynamically allocated at open() and free'd at close().
* Each per-Stream instance points to at most one per-attachment structure
* using the sps_ppa field. All instances are threaded together into one
* list of active instances ordered on minor device number, using the
* sps_nextmn field.
*/
typedef struct spppstr {
/*
* Note that EX_st_nextmn field should never be referenced other
* than by the routines manipulating the global upper streams list,
* by first obtaining exclusive access at the outer perimeter.
*/
/*
* These fields are common to all upper streams. If this stream
* is attached to a ppa, then the sps_ppa field will point to the
* ppa structure associated with this particular upper stream.
*/
/*
* sps_nextsib is protected by the ppa's sibling lock (ppa_sib_lock),
* and access made to it should only be done by first ensuring that
* the sps_ppa field is valid, i.e., this stream has been attached.
*/
/*
* These fields are common to all non-control streams, i.e., those
* in which a PPPIO_NEWPPA has not been issued on. Non-control
* streams are valid candidates for network streams, and they can
* only be considered network streams (ones which carry IP packets)
* if they are attached and bound. The only mandatory requirement
* for control stream is that its sps_npmode field should always
* be equal to NPMODE_PASS, as we obviously will never block the
* control stream from sending or receiving packets.
*/
/*
* sps_dlstate is only valid for network streams in which DLPI
* is intended to be used to transfer network-layer data. It is set
* to DL_UNATTACHED for all other streams.
*/
} spppstr_t;
/*
* Values for sps_flags, and their descriptions.
*/
/* 0x00000001 unused */
#define IS_SPS_CONTROL(x) \
((x)->sps_flags & SPS_CONTROL)
#define IS_SPS_FASTPATH(x) \
((x)->sps_flags & SPS_FASTPATH)
#define IS_SPS_PROMISC(x) \
((x)->sps_flags & SPS_PROMISC)
#define IS_SPS_RAWDATA(x) \
((x)->sps_flags & SPS_RAWDATA)
#define IS_SPS_PIOATTACH(x) \
((x)->sps_flags & SPS_PIOATTACH)
#define IS_SPS_KDEBUG(x) \
((x)->sps_flags & SPS_KDEBUG)
#define IS_SPS_CACHED(x) \
((x)->sps_flags & SPS_CACHED)
/*
* Bit format (octal based) string for cmn_err, which represents the flags.
*/
#define SPS_FLAGS_STR \
"\020" \
"\1priv" \
"\2control" \
"\3fastpath" \
"\4promisc" \
"\5rawdata" \
"\6pioattach" \
"\7kdebug" \
"\10cached"
/*
* Per-Attachment instance state information.
*
* Each instance is dynamically allocated on first attach (PPPIO_NEWPPA).
* Allocation of this structure is only done once per control stream. A ppa
* instance may be shared by two or more upper streams, and it is always
* linked to the upper stream marked as the control stream (SPS_CONTROL)
* via the ppa_ctl field. Non-control streams are linked to ppa_streams.
*/
typedef struct sppa {
/*
* Note that EX_st_nextppa field should only be accessed (walked)
* by the ppa manipulation routines, i.e, those which affect
* the global ppa list, e.g: open, close, new_ppa, and XX_attach_upper.
*/
/*
* ppa_sib_lock guards the linkages between all upper streams related
* to this ppa. Walking the sps_nextsib of any upper streams should
* be done by first holding this lock.
*/
/*
* ppa_sta_lock mutex guards the statistic fields of this ppa, since
* this structure is shared by upper streams of the same ppa.
*/
/*
* We keep the following pointers for performance reasons. Instead
* of walking the list of attached upper streams to find the
* destination upper stream everytime we need to send a packet up,
* we keep them here for easy access.
*/
} sppa_t;
/* bit position (in ppa_npflag) for each ppp_protocol that can be blocked */
#define NP_IP 1
#define NP_IPV6 2
/*
* Values for ppa_flags, and their descriptions.
*/
#define IS_PPA_LASTMOD(x) \
((x)->ppa_flags & PPA_LASTMOD)
#define IS_PPA_TIMESTAMP(x) \
((x)->ppa_flags & PPA_TIMESTAMP)
/*
* Bit format (octal based) string for cmn_err, which represents the flags.
*/
#define PPA_FLAGS_STR \
"\020" \
"\1lastmod" \
"\2timestamp"
/*
* General macros.
*/
/*
* Function declarations.
*/
extern int sppp_close(queue_t *);
extern void sppp_dlpi_pinfoinit(void);
extern void sppp_lwsrv(queue_t *);
extern void sppp_uwsrv(queue_t *);
#ifdef __cplusplus
}
#endif
#endif /* __SPPP_H */