sppptun.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <net/ppp_defs.h>
#include "s_common.h"
#include "sppptun_mod.h"
#include "sppptun_impl.h"
/*
* This is used to tag official Solaris sources. Please do not define
* "INTERNAL_BUILD" when building this software outside of Sun
* Microsystems.
*/
#ifdef INTERNAL_BUILD
/* MODINFO is limited to 32 characters. */
const char sppptun_driver_description[] = "PPP 4.0 tunnel driver v%I%";
const char sppptun_module_description[] = "PPP 4.0 tunnel module v%I%";
#else
const char sppptun_driver_description[] = "ANU PPP tundrv $Revision: $";
const char sppptun_module_description[] = "ANU PPP tunmod $Revision: $";
/* LINTED */
#ifdef DEBUG
" DEBUG"
#endif
"\n";
#endif
/*
* Tunable values; these are similar to the values used in ptms_conf.c.
*/
typedef struct ether_dest_s {
} ether_dest_t;
/* Allows unaligned access. */
static const char *tll_kstats_list[] = { TLL_KSTATS_NAMES };
static const char *tcl_kstats_list[] = { TCL_KSTATS_NAMES };
"device" : "module")
static int sppptun_close(queue_t *);
static int sppptun_ursrv(queue_t *);
static int sppptun_uwsrv(queue_t *);
/*
* This is the hash table of clients. Clients are the programs that
* these; one per tunneled PPP session.
*
* Note: slots are offset from minor node value by 1 because
* vmem_alloc returns 0 for failure.
*
* The tcl_slots array entries are modified only when exclusive on
* both inner and outer perimeters. This ensures that threads on
* shared perimeters always view this as unchanging memory with no
* need to lock around accesses. (Specifically, the tcl_slots array
* is modified by entry to sppptun_open, sppptun_close, and _fini.)
*/
static krwlock_t tcl_rwlock;
/*
* This is the simple list of lower layers. For PPPoE, there is one
* of these per Ethernet interface. Lower layers are established by
* "plumbing" -- using I_PLINK to connect the tunnel multiplexor to
* the physical interface.
*/
static struct qelem tunll_list;
static int tunll_index;
/* Test value; if all zeroes, then address hasn't been set yet. */
static const ether_addr_t zero_mac_addr = { 0, 0, 0, 0, 0, 0 };
#define MIN_SET_FASTPATH_UNITDATAREQ_SIZE \
(sizeof (dl_unitdata_req_t) + 4)
#define TUN_MI_MINPSZ (0)
#define TUN_MI_MAXPSZ (PPP_MAXMTU)
#define TUN_MI_LOWAT (128)
static struct module_info sppptun_modinfo = {
TUN_MI_ID, /* mi_idnum */
PPP_TUN_NAME, /* mi_idname */
TUN_MI_MINPSZ, /* mi_minpsz */
TUN_MI_MAXPSZ, /* mi_maxpsz */
TUN_MI_HIWAT, /* mi_hiwat */
TUN_MI_LOWAT /* mi_lowat */
};
static struct qinit sppptun_urinit = {
(int (*)())sppptun_urput, /* qi_putp */
sppptun_ursrv, /* qi_srvp */
sppptun_open, /* qi_qopen */
sppptun_close, /* qi_qclose */
NULL, /* qi_qadmin */
&sppptun_modinfo, /* qi_minfo */
NULL /* qi_mstat */
};
static struct qinit sppptun_uwinit = {
(int (*)())sppptun_uwput, /* qi_putp */
sppptun_uwsrv, /* qi_srvp */
NULL, /* qi_qopen */
NULL, /* qi_qclose */
NULL, /* qi_qadmin */
&sppptun_modinfo, /* qi_minfo */
NULL /* qi_mstat */
};
static struct qinit sppptun_lrinit = {
(int (*)())sppptun_lrput, /* qi_putp */
NULL, /* qi_srvp */
NULL, /* qi_qopen */
NULL, /* qi_qclose */
NULL, /* qi_qadmin */
&sppptun_modinfo, /* qi_minfo */
NULL /* qi_mstat */
};
static struct qinit sppptun_lwinit = {
(int (*)())sppptun_lwput, /* qi_putp */
NULL, /* qi_srvp */
NULL, /* qi_qopen */
NULL, /* qi_qclose */
NULL, /* qi_qadmin */
&sppptun_modinfo, /* qi_minfo */
NULL /* qi_mstat */
};
/*
* This is referenced in sppptun_mod.c.
*/
struct streamtab sppptun_tab = {
&sppptun_urinit, /* st_rdinit */
&sppptun_uwinit, /* st_wrinit */
&sppptun_lrinit, /* st_muxrinit */
&sppptun_lwinit /* st_muxwrinit */
};
/*
* Nifty packet dumper; copied from pppd AIX 4.1 port. This routine
* dumps the raw received and transmitted data through syslog. This
* allows debug of communications problems without resorting to a line
* analyzer.
*
* The expression "3*BYTES_PER_LINE" used frequently here represents
* the size of each hex value printed -- two hex digits and a space.
*/
#define BYTES_PER_LINE 8
static void
{
/*
* Buffer is big enough for hex digits, two spaces, ASCII output,
* and one NUL byte.
*/
int i, chr;
char *bp;
static const char digits[] = "0123456789abcdef";
i = 0;
/* Add filler spaces between hex output and ASCII */
/* Add NUL byte at end */
/* convert byte to ascii hex */
*bp++ = ' ';
/* Insert ASCII past hex output and filler */
i++;
if (i >= BYTES_PER_LINE) {
buf);
i = 0;
}
}
}
/* fill over unused hex display positions */
*bp++ = ' ';
/* terminate ASCII string at right position */
}
}
/*
* Allocate another slot table twice as large as the original one
* (limited to global maximum). Migrate all tunnels to the new slot
* table and free the original one. Assumes we're exclusive on both
* inner and outer perimeters, and thus there are no other users of
* the tcl_slots array.
*/
static minor_t
tcl_grow(void)
{
void *vaddr; /* vmem_add return value */
/* Allocate new ptms array */
return ((minor_t)0);
/* Increase clone index space */
return ((minor_t)0);
}
/* Migrate tuncl_t entries to a new location */
/* Allocate minor number and return it */
}
/*
* Allocate new minor number and tunnel client entry. Returns the new
* entry or NULL if no memory or maximum number of entries reached.
* Assumes we're exclusive on both inner and outer perimeters, and
* thus there are no other users of the tcl_slots array.
*/
static tuncl_t *
tuncl_alloc(int wantminor)
{
/*
* Always try to allocate new pty when sppptun_cnt minimum
* limit is not achieved. If it is achieved, the maximum is
* determined by either user-specified value (if it is
* non-zero) or our memory estimations - whatever is less.
*/
if (tcl_inuse >= sppptun_cnt) {
/*
* When system achieved required minimum of tunnels,
* check for the denial of service limits.
*
* Get user-imposed maximum, if configured, or
* calculated memory constraint.
*/
/* Do not try to allocate more than allowed */
return (NULL);
}
}
tcl_inuse++;
/*
* Allocate new minor number. If this fails, all slots are
* busy and we need to grow the hash.
*/
if (wantminor <= 0) {
if (dminor == 0) {
/* Grow the cache and retry allocation */
}
} else {
1);
dminor = 0;
}
}
if (dminor == 0) {
/* Not enough memory now */
tcl_inuse--;
return (NULL);
}
/* Not enough memory - this entry can't be used now. */
tcl_inuse--;
} else {
}
return (tcl);
}
/*
* This routine frees an upper level (client) stream by removing it
* from the minor number pool and freeing the state structure storage.
* Assumes we're exclusive on both inner and outer perimeters, and
* thus there are no other concurrent users of the tcl_slots array or
* of any entry in that array.
*/
static void
{
tcl_inuse--;
}
/* Return minor number to the pool of minors */
/* Return tuncl_t to the cache */
}
/*
* Get tuncl_t structure by minor number. Returns NULL when minor is
* out of range. Note that lookup of tcl pointers (and use of those
* pointers) is safe because modification is done only when exclusive
* on both inner and outer perimeters.
*/
static tuncl_t *
{
}
return (tcl);
}
/*
* Set up kstats for upper or lower stream.
*/
static kstat_t *
{
char unitname[KSTAT_STRLEN];
int i;
for (i = 0; i < nstat; i++) {
}
}
return (ksp);
}
/*
* sppptun_open()
*
* MT-Perimeters:
* exclusive inner, exclusive outer.
*
* Description:
* Common open procedure for module and driver.
*/
static int
{
/* Allow a re-open */
return (0);
/* In the off chance that we're on our way out, just return error */
return (EINVAL);
}
char *cp;
/* ordinary users have no need to push this module */
return (EPERM);
/* Insert at end of list */
/*
* Find the name of the driver somewhere beneath us.
* Note that we have no driver under us until after
* qprocson().
*/
qprocson(q);
;
/* Set initial name; user should overwrite. */
else
} else {
} else {
/*
* Support of non-clone open (ie, mknod with
* defined minor number) is supported for
* testing purposes so that 'arbitrary' minor
* numbers can be used.
*/
return (EPERM);
}
}
return (ENOSR);
tcl->tcl_lsessid);
qprocson(q);
}
return (0);
}
/*
* Create an appropriate control message for this client event.
*/
static mblk_t *
{
struct ppptun_control *ptc;
} else {
}
}
return (mp);
}
/*
* Send an appropriate control message up this client session.
*/
static void
{
}
}
}
/*
* If a lower stream is being unplumbed, then the upper streams
* connected to this lower stream must be disconnected. This routine
* accomplishes this by sending M_HANGUP to data streams and M_PROTO
* messages to control streams. This is called by vmem_walk, and
* handles a span of minor node numbers.
*
* No need to update lks_clients here; the lower stream is on its way
* out.
*/
static void
{
}
}
}
minorn++;
}
}
/*
* sppptun_close()
*
* MT-Perimeters:
* exclusive inner, exclusive outer.
*
* Description:
* Common close procedure for module and driver.
*/
static int
sppptun_close(queue_t *q)
{
int err;
void *qptr;
err = 0;
/* q_next is set on modules */
/* unlink any clients using this lower layer. */
/* tell daemon that this has been removed. */
}
break;
}
qprocsoff(q);
} else {
/* devices are end of line; no q_next. */
qprocsoff(q);
}
/*
* If this was a normal session, then tell the daemon.
*/
}
/* Update statistics for references being dropped. */
}
}
}
return (err);
}
/*
* Allocate and initialize a DLPI or TPI template of the specified
* length.
*/
static mblk_t *
{
}
return (mp);
}
#define dlpi_alloc(l, p) pi_alloc((l), (p))
/*
* Prepend some room to an mblk. Try to reuse the existing buffer, if
* at all possible, rather than allocating a new one. (Fast-path
* output should be able to use this.)
*
* (XXX why isn't this a library function ...?)
*/
static mblk_t *
{
if (align == 0)
align = 8;
return (NULL);
}
return (newmp);
}
return (mp);
}
/*
* sppptun_outpkt()
*
* MT-Perimeters:
* shared inner, shared outer (if called from sppptun_uwput),
* exclusive inner, shared outer (if called from sppptun_uwsrv).
*
* Description:
* Called from sppptun_uwput or sppptun_uwsrv when processing a
* M_DATA, M_PROTO, or M_PCPROTO message. For all cases, it tries
* to prepare the data to be sent to the module below this driver
* if there is a lower stream linked underneath. If no lower
* stream exists, then the data will be discarded and an ENXIO
* error returned.
*
* Returns:
* pointer to queue if caller should do putnext, otherwise
* *mpp != NULL if message should be enqueued, otherwise
* *mpp == NULL if message is gone.
*/
static queue_t *
{
int len;
struct ppptun_control *ptc;
return (NULL);
}
if (isdata) {
} else {
/*
* If data are unaligned or otherwise unsuitable, then
* discard.
*/
return (NULL);
}
/* Set stream discriminator value if not yet set. */
if (tcl->tcl_ctlval == 0)
/* If this is a test message, then reply to caller. */
}
return (NULL);
}
/* If this one isn't for us, then discard it */
return (NULL);
}
/* Don't allow empty control packets. */
return (NULL);
}
}
if (isdata) {
} else {
}
return (NULL);
}
/*
* If so, then try to send it down. The lower queue is only
* ever detached while holding an exclusive lock on the whole
* driver, so we can be confident that the lower queue is
* still there.
*/
return (NULL);
}
/*
* Note: DLPI and TPI expect that the first buffer contains
* the control (unitdata-req) header, destination address, and
* nothing else. Any protocol headers must go in the next
* buffer.
*/
if (isdata) {
case PTS_PPPOE:
/* Strip address and control fields if present. */
break;
}
}
/* Broadcasting data is probably not a good idea. */
break;
break;
/* DLPI SAPs are in host byte order! */
/* Make sure the protocol field isn't compressed. */
break;
sizeof (*poep));
if (len > 0)
break;
default:
ASSERT(0);
}
} else {
/*
* Control side encapsulation.
*/
== 0)
case PTS_PPPOE:
/*
* Don't allow a loopback session to establish
* itself. PPPoE is broken; it uses only one
* session ID for both data directions, so the
* loopback data path can simply never work.
*/
break;
break;
/* DLPI SAPs are in host byte order! */
/*
* If destination isn't set yet, then we have to
* allow anything at all. Otherwise, force use
* of configured peer address.
*/
zero_mac_addr, sizeof (zero_mac_addr)) == 0 ||
} else {
}
break;
case PTS_PPTP:
/*
* PPTP's control side is actually done over
* separate TCP connections.
*/
default:
ASSERT(0);
}
}
if (isdata) {
} else {
}
} else {
if (isdata) {
} else {
}
switch (loopup) {
case luNone:
break;
case luCopy:
break;
case luSend:
break;
}
}
return (lowerq);
}
/*
* Enqueue a message to be sent when the lower stream is closed. This
* is done so that we're guaranteed that we always have the necessary
* resources to properly detach ourselves from the system. (If we
* waited until the close was done to allocate these messages, then
* the message allocation could fail, and we'd be unable to properly
* detach.)
*/
static void
{
else {
}
}
/*
* Given the lower stream name, locate the state structure. Note that
* lookup of tcl pointers (and use of those pointers) is safe because
* modification is done only when exclusive on both inner and outer
* perimeters.
*/
static tunll_t *
tll_lookup_on_name(char *dname)
{
return (tll);
return (NULL);
}
/*
* sppptun_inner_ioctl()
*
* MT-Perimeters:
* exclusive inner, shared outer.
*
* Description:
* Called by qwriter from sppptun_ioctl as the result of receiving
* a handled ioctl.
*/
static void
{
int rc = 0;
int len = 0;
int i;
union ppptun_name *ptn;
struct ppptun_info *pti;
struct ppptun_peer *ptp;
struct ppp_stats64 *psp;
}
case PPPIO_DEBUG:
/* Client (device) side only */
break;
}
/* just one type of debug so far */
if (i != PPPDBG_LOG + PPPDBG_AHDLC)
else
break;
case PPPIO_GETSTAT:
break;
case PPPIO_GETSTAT64:
/* Client (device) side only */
break;
}
break;
}
break;
case PPPTUN_SNAME:
/* This is done on the *module* (lower level) side. */
break;
}
break;
}
break;
case PPPTUN_GNAME:
/* This is done on the *module* (lower level) side. */
break;
}
break;
}
break;
case PPPTUN_SINFO:
case PPPTUN_GINFO:
/* Either side */
break;
}
/* Driver (client) side must have name */
"null sinfo name on driver"));
} else
break;
}
break;
}
case PTS_PPPOE: /* DLPI type */
break;
}
break;
}
break;
default:
break;
}
break;
case PPPTUN_GNNAME:
/* This can be done on either side. */
break;
}
} else {
}
break;
case PPPTUN_LCLADDR:
/* This is done on the *module* (lower level) side. */
break;
}
break;
}
len = 0;
break;
case PPPTUN_SPEER:
/* Client (device) side only; before SDATA */
break;
}
break;
}
/* Once set, the style cannot change. */
break;
}
/* User requests registration for tunnel 0 */
break;
}
} else {
/* Normal client connection */
break;
}
if (ptp->ptp_lsessid != 0 &&
break;
}
/*
* If we're reassigning the peer data, then
* the previous assignment must have been for
* a client control connection. Check that.
*/
((tcl->tcl_ltunid != 0 &&
(tcl->tcl_rtunid != 0 &&
(tcl->tcl_rsessid != 0 &&
break;
}
tcl->tcl_rsessid));
}
goto fill_in_peer;
case PPPTUN_GPEER:
/* Client (device) side only */
break;
}
break;
}
0;
break;
case PPPTUN_SDATA:
case PPPTUN_SCTL:
/* Client (device) side only; must do SPEER first */
break;
}
break;
}
break;
}
break;
}
break;
}
/* server daemons cannot use regular data */
break;
}
"control link already set"));
break;
}
}
} else {
"control link already set"));
break;
}
}
break;
case PPPTUN_GDATA:
case PPPTUN_GCTL:
/* Client (device) side only */
break;
}
break;
}
else
else
break;
case PPPTUN_DCTL:
/* Client (device) side daemon mode only */
break;
}
break;
}
break;
default:
/* Caller should already have checked command value */
ASSERT(0);
}
if (rc != 0) {
} else {
if (len > 0)
}
}
/*
* sppptun_ioctl()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Called by sppptun_uwput as the result of receiving a M_IOCTL command.
*/
static void
{
int rc = 0;
int len = 0;
case PPPIO_DEBUG:
case PPPIO_GETSTAT:
case PPPIO_GETSTAT64:
case PPPTUN_SNAME:
case PPPTUN_GNAME:
case PPPTUN_SINFO:
case PPPTUN_GINFO:
case PPPTUN_GNNAME:
case PPPTUN_LCLADDR:
case PPPTUN_SPEER:
case PPPTUN_GPEER:
case PPPTUN_SDATA:
case PPPTUN_GDATA:
case PPPTUN_SCTL:
case PPPTUN_GCTL:
case PPPTUN_DCTL:
return;
case PPPIO_GCLEAN: /* always clean */
break;
case PPPIO_GTYPE: /* we look like an async driver. */
val = PPPTYP_AHDLC;
break;
case PPPIO_CFLAGS: /* never compress headers */
val = 0;
break;
/* quietly ack PPP things we don't need to do. */
case PPPIO_XFCS:
case PPPIO_RFCS:
case PPPIO_XACCM:
case PPPIO_RACCM:
case PPPIO_LASTMOD:
case PPPIO_MUX:
case I_PLINK:
case I_PUNLINK:
case I_LINK:
case I_UNLINK:
break;
default:
/* module side; pass this through. */
return;
}
break;
}
} else {
}
}
if (rc == 0) {
} else {
}
}
/*
* sppptun_inner_mctl()
*
* MT-Perimeters:
* exclusive inner, shared outer.
*
* Description:
* Called by qwriter (via sppptun_uwput) as the result of receiving
* an M_CTL. Called only on the client (driver) side.
*/
static void
{
int msglen;
return;
}
case PPPCTL_UNIT:
if (msglen == 2)
else if (msglen == 8)
break;
}
}
/*
* sppptun_uwput()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Regular output data and controls pass through here.
*/
static void
{
case M_DATA:
case M_PROTO:
case M_PCPROTO:
}
break;
case M_IOCTL:
sppptun_ioctl(q, mp);
break;
case M_CTL:
break;
default:
/*
* If we're the driver, then discard unknown junk.
* Otherwise, if we're the module, then forward along.
*/
else
break;
}
}
/*
* is only one outstanding message. Uses tll_msg_pending to tell when
* it must queue. sppptun_urput calls message_done() when an ACK or a
* NAK is received to process the next queued message.
*/
static void
{
if (tll->tll_msg_pending) {
/* Must queue message. Tail insertion */
return;
}
}
/*
* send down the next queued message (if any).
*/
static void
{
tll->tll_msg_pending = 0;
}
}
/*
* Send down queued "close" messages to lower stream. These were
* enqueued right after the stream was originally allocated, when the
* tll_style was set by PPPTUN_SINFO.
*/
static int
{
else {
}
}
return (0);
}
/*
* sppptun_uwsrv()
*
* MT-Perimeters:
* exclusive inner, shared outer.
*
* Description:
* Upper write-side service procedure. In addition to the usual
* STREAMS queue service handling, this routine also handles the
* driver when a lower stream is being closed. (See the use of
*/
static int
sppptun_uwsrv(queue_t *q)
{
TLLF_CLOSING) {
}
return (0);
}
break;
}
}
return (0);
}
/*
* sppptun_lwput()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Lower write-side put procedure. Nothing should be sending
* packets down this stream.
*/
static void
{
case M_PROTO:
break;
default:
break;
}
}
/*
* sppptun_lrput()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Lower read-side put procedure. Nothing should arrive here.
*/
static void
{
case M_IOCTL:
return;
case M_FLUSH:
}
} else {
}
return;
}
/*
* Try to forward the message to the put procedure for the upper
* control stream for this lower stream. If there are already messages
* queued here, queue this one up to preserve message ordering.
*/
return;
}
} else {
}
}
/*
* MT-Perimeters:
* shared inner, shared outer.
*
* Handle non-data DLPI messages. Used with PPPoE, which runs over
* Ethernet only.
*/
static void
{
int err;
dlp->dl_primitive));
switch (dlp->dl_primitive) {
case DL_UDERROR_IND:
break;
case DL_ERROR_ACK:
"error-ack: unix %d, dlpi %d on primitive %d\n",
case DL_UNBIND_REQ:
break;
case DL_DETACH_REQ:
err));
break;
case DL_PHYS_ADDR_REQ:
break;
case DL_INFO_REQ:
case DL_ATTACH_REQ:
case DL_BIND_REQ:
break;
}
break;
case DL_INFO_ACK:
break;
case DL_BIND_ACK:
break;
case DL_PHYS_ADDR_ACK:
break;
case DL_OK_ACK:
case DL_UNBIND_REQ:
break;
case DL_DETACH_REQ:
break;
case DL_ATTACH_REQ:
break;
}
break;
}
}
/* Search structure used with PPPoE only; see tclvm_pppoe_search(). */
struct poedat {
void *srcaddr;
int isdata;
};
/*
* This function is called by vmem_walk from within sppptun_recv. It
* iterates over a span of allocated minor node numbers to search for
* the appropriate lower stream, session ID, and peer MAC address.
*
* (This is necessary due to a design flaw in the PPPoE protocol
* itself. The protocol assigns session IDs from the server side
* only. Both server and client use the same number. Thus, if there
* are multiple clients on a single host, there can be session ID
* conflicts between servers and there's no way to detangle them
* except by looking at the remote MAC address.)
*
* (This could have been handled by linking together sessions that
* differ only in the remote MAC address. This isn't done because it
* would involve extra per-session storage and it's very unlikely that
* PPPoE would be used this way.)
*/
static void
{
return;
break;
}
minorn++;
}
}
/*
* sppptun_recv()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Receive function called by sppptun_urput, which is called when
* the lower read-side put or service procedure sends a message
* upstream to the a device user (PPP). It attempts to find an
* appropriate queue on the module above us (depending on what the
* associated upper stream for the protocol would be), and if not
* possible, it will find an upper control stream for the protocol.
* Returns a pointer to the upper queue_t, or NULL if the message
* has been discarded.
*
* About demultiplexing:
*
* All four protocols (L2F, PPTP, L2TP, and PPPoE) support a
* locally assigned ID for demultiplexing incoming traffic. For
* L2F, this is called the Client ID, for PPTP the Call ID, for
* L2TP the Session ID, and for PPPoE the SESSION_ID. This is a
* 16 bit number for all four protocols, and is used to directly
* index into a list of upper streams. With the upper stream in
* hand, we verify that this is the right stream and deliver the
* data.
*
* L2TP has a Tunnel ID, which represents a bundle of PPP
* sessions between the peers. Because we always assign unique
* session ID numbers, we merely check that the given ID matches
* the assigned ID for the upper stream.
*
* L2F has a Multiplex ID, which is unique per connection. It
* does not have L2TP's concept of multiple-connections-within-
* a-tunnel. The same checking is done.
*
* PPPoE is a horribly broken protocol. Only one ID is assigned
* per connection. The client must somehow demultiplex based on
* an ID number assigned by the server. It's not necessarily
* unique. The search is done based on {ID,peerEthernet} (using
* tcl_rsessid) for all packet types except PADI and PADS.
*
* Neither PPPoE nor PPTP supports additional ID numbers.
*
* Both L2F and L2TP come in over UDP. They are distinguished by
* looking at the GRE version field -- 001 for L2F and 010 for
* L2TP.
*/
static queue_t *
{
int sessid;
int remlen;
int msglen;
int isdata;
int i;
/*
* First, extract a session ID number. All protocols have
* this.
*/
case PTS_PPPOE:
break;
if (i == POECODE_PADI || i == POECODE_PADR) {
/* These go to the server daemon only. */
} else if (i == POECODE_PADO || i == POECODE_PADS) {
/*
* These go to a client only, and are demuxed
* by the Host-Uniq field (into which we stuff
* our local ID number when generating
*/
i = msglen;
while (i > POET_HDRLEN) {
i = 0;
break;
}
break;
}
if (i >= POET_HDRLEN + 4)
} else {
/*
* Try minor number as session ID first, since
* it's used that way on server side. It's
* not used that way on the client, though, so
* this might not work. If this isn't the
* right one, then try the tll cache. If
* neither is right, then search all open
* clients. Did I mention that the PPPoE
* protocol is badly designed?
*/
/*
* Slow mode. Too bad. If you don't like it,
* you can always choose a better protocol.
*/
}
}
}
break;
}
}
if (isdata) {
} else {
}
}
return (NULL);
}
return (NULL);
}
return (NULL);
}
}
} else {
NULL) {
return (NULL);
}
/* Fix up source address; peer might not be set yet. */
}
}
/*
* sppptun_urput()
*
* MT-Perimeters:
* shared inner, shared outer.
*
* Description:
* Upper read-side put procedure. Messages from the underlying
* lower stream driver arrive here. See sppptun_recv for the
* demultiplexing logic.
*/
static void
{
union DL_primitives *dlprim;
case M_DATA:
/*
* When we're bound over IP, data arrives here. The
* packet starts with the IP header itself.
*/
break;
case M_PROTO:
case M_PCPROTO:
/* Data arrives here for UDP or raw Ethernet, not IP. */
/* PPTP control messages are over TCP only. */
case PTS_PPTP:
default:
ASSERT(0); /* how'd that happen? */
break;
case PTS_PPPOE: /* DLPI message */
switch (dlprim->dl_primitive) {
case DL_UNITDATA_IND:
break;
/* For loopback support. */
case DL_UNITDATA_REQ:
break;
default:
urput_dlpi(q, mp);
break;
}
break;
}
break;
default:
break;
}
}
/*
* sppptun_ursrv()
*
* MT-Perimeters:
* exclusive inner, shared outer.
*
* Description:
* Upper read-side service procedure. This procedure services the
* client streams. We get here because the client (PPP) asserts
* flow control down to us.
*/
static int
sppptun_ursrv(queue_t *q)
{
if (canputnext(q)) {
} else {
break;
}
}
return (0);
}
/*
* Dummy constructor/destructor functions for kmem_cache_create.
* We're just using kmem as an allocator of integers, not real
* storage.
*/
/*ARGSUSED*/
static int
{
return (0);
}
/*ARGSUSED*/
static void
{
}
/*
* Total size occupied by one tunnel client. Each tunnel client
* consumes one pointer for tcl_slots array, one tuncl_t structure and
* two messages preallocated for close.
*/
2 * sizeof (dblk_t))
/*
* Clear all bits of x except the highest bit
*/
/*
* This function initializes some well-known global variables inside
* the module.
*
* Called by sppptun_mod.c:_init() before installing the module.
*/
void
sppptun_init(void)
{
}
/*
* This function allocates the initial internal storage for the
* sppptun driver.
*
* Called by sppptun_mod.c:_init() after installing module.
*/
void
sppptun_tcl_init(void)
{
uint_t i, j;
/* Allocate integer space for minor numbers */
/*
* Calculate available number of tunnels - how many tunnels
* can we allocate in sppptun_pctofmem % of available
* memory. The value is rounded up to the nearest power of 2.
*/
j = truncate(i); /* i with non-high bits stripped */
if (i != j)
j *= 2;
tcl_minormax = j;
}
/*
* This function checks that there are no plumbed streams or other users.
*
* Called by sppptun_mod.c:_fini(). Assumes that we're exclusive on
* both perimeters.
*/
int
sppptun_tcl_fintest(void)
{
"_fini: return busy; plumbed and %d in use\n",
tcl_inuse));
return (EBUSY);
}
return (0);
}
/*
* If no lower streams are plumbed, then this function deallocates all
* internal storage in preparation for unload.
*
* Called by sppptun_mod.c:_fini(). Assumes that we're exclusive on
* both perimeters.
*/
void
sppptun_tcl_fini(void)
{
if (tcl_minor_arena != NULL) {
}
}
}