Whistle's Netgraph link-layer (sometimes more) networking infrastructure.
Been in production for 3 years now. Gives Instant Frame relay to if_sr and if_ar drivers, and PPPOE support soon. See: ftp://ftp.whistle.com/pub/archie/netgraph/index.html for on-line manual pages. Reviewed by: Doug Rabson (dfr@freebsd.org) Obtained from: Whistle CVS tree
This commit is contained in:
parent
67494b1a71
commit
4cf49a4355
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52419
@ -29,6 +29,8 @@
|
||||
..
|
||||
netatm
|
||||
..
|
||||
netgraph
|
||||
..
|
||||
netinet
|
||||
..
|
||||
netipx
|
||||
|
@ -41,8 +41,8 @@ SFILES= soundcard.h
|
||||
LFILES= aio.h errno.h fcntl.h inttypes.h linker_set.h poll.h syslog.h \
|
||||
termios.h ucontext.h
|
||||
|
||||
LDIRS= cam msdosfs net netatalk netatm netinet netipx netkey netncp netns \
|
||||
nfs nwfs pccard posix4 sys vm
|
||||
LDIRS= cam msdosfs net netatalk netatm netgraph netinet netipx netkey \
|
||||
netncp netns nfs nwfs pccard posix4 sys vm
|
||||
|
||||
LNOHEADERDIRS= isofs ufs
|
||||
LSUBDIRS= isofs/cd9660 ufs/ffs ufs/mfs ufs/ufs cam/scsi
|
||||
|
@ -22,8 +22,8 @@ SUBDIR= ${_csu} libcom_err ${_libm} libmd ${_libcrypt} \
|
||||
${_compat} libalias libatm libbind libc ${_libc_r} libcalendar libcam \
|
||||
libcompat libdevstat libdisk libedit libfetch libform \
|
||||
libftpio libgnumalloc ${_libio} libipx libkvm libmenu ${_libncp} \
|
||||
libopie libpam libpanel libpcap libresolv librpcsvc libss libstand \
|
||||
${_libtelnet} libutil ${_libvgl} libwrap libxpg4 liby libz
|
||||
libnetgraph libopie libpam libpanel libpcap libresolv librpcsvc libss \
|
||||
libstand ${_libtelnet} libutil ${_libvgl} libwrap libxpg4 liby libz
|
||||
|
||||
.if exists(${.CURDIR}/csu/${MACHINE_ARCH}-${OBJFORMAT})
|
||||
_csu=csu/${MACHINE_ARCH}-${OBJFORMAT}
|
||||
|
19
lib/libnetgraph/Makefile
Normal file
19
lib/libnetgraph/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.4 1999/01/17 03:41:02 julian Exp $
|
||||
|
||||
LIB= netgraph
|
||||
MAN3= netgraph.3
|
||||
|
||||
SHLIB_MAJOR= 1
|
||||
#SHLIB_MINOR= 1
|
||||
|
||||
SRCS= sock.c msg.c debug.c
|
||||
|
||||
CFLAGS+= -g -Wall -O2 -Werror
|
||||
CFLAGS+= -I/usr/src.freefall/sys
|
||||
|
||||
beforeinstall:
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/netgraph.h \
|
||||
${DESTDIR}/usr/include
|
||||
|
||||
.include <bsd.lib.mk>
|
404
lib/libnetgraph/debug.c
Normal file
404
lib/libnetgraph/debug.c
Normal file
@ -0,0 +1,404 @@
|
||||
|
||||
/*
|
||||
* debug.c
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: debug.c,v 1.24 1999/01/24 01:15:33 archie Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/ng_socket.h>
|
||||
|
||||
#include "netgraph.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include <netgraph/ng_socket.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/ng_iface.h>
|
||||
#include <netgraph/ng_rfc1490.h>
|
||||
#include <netgraph/ng_cisco.h>
|
||||
#include <netgraph/ng_async.h>
|
||||
#include <netgraph/ng_ppp.h>
|
||||
#include <netgraph/ng_frame_relay.h>
|
||||
#include <netgraph/ng_lmi.h>
|
||||
#include <netgraph/ng_tty.h>
|
||||
#include <netgraph/ng_tty.h>
|
||||
|
||||
/* Global debug level */
|
||||
int _gNgDebugLevel = 0;
|
||||
|
||||
/* Debug printing functions */
|
||||
void (*_NgLog) (const char *fmt,...) = warn;
|
||||
void (*_NgLogx) (const char *fmt,...) = warnx;
|
||||
|
||||
/* Internal functions */
|
||||
static const char *NgCookie(int cookie);
|
||||
static const char *NgCmd(int cookie, int cmd);
|
||||
static void NgArgs(int cookie, int cmd, int resp, void *args, int arglen);
|
||||
|
||||
/*
|
||||
* Set debug level, ie, verbosity, if "level" is non-negative.
|
||||
* Returns old debug level.
|
||||
*/
|
||||
int
|
||||
NgSetDebug(int level)
|
||||
{
|
||||
int old = _gNgDebugLevel;
|
||||
|
||||
if (level < 0)
|
||||
level = old;
|
||||
_gNgDebugLevel = level;
|
||||
return (old);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set debug logging functions.
|
||||
*/
|
||||
void
|
||||
NgSetErrLog(void (*log) (const char *fmt,...),
|
||||
void (*logx) (const char *fmt,...))
|
||||
{
|
||||
_NgLog = log;
|
||||
_NgLogx = logx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a netgraph sockaddr
|
||||
*/
|
||||
void
|
||||
_NgDebugSockaddr(struct sockaddr_ng *sg)
|
||||
{
|
||||
NGLOGX("SOCKADDR: { fam=%d len=%d addr=\"%s\" }",
|
||||
sg->sg_family, sg->sg_len, sg->sg_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a negraph message
|
||||
*/
|
||||
void
|
||||
_NgDebugMsg(struct ng_mesg * msg)
|
||||
{
|
||||
NGLOGX("NG_MESG :");
|
||||
NGLOGX(" vers %d", msg->header.version);
|
||||
NGLOGX(" arglen %d", msg->header.arglen);
|
||||
NGLOGX(" flags %ld", msg->header.flags);
|
||||
NGLOGX(" token %lu", (u_long) msg->header.token);
|
||||
NGLOGX(" cookie %s", NgCookie(msg->header.typecookie));
|
||||
NGLOGX(" cmd %s", NgCmd(msg->header.typecookie, msg->header.cmd));
|
||||
NgArgs(msg->header.typecookie, msg->header.cmd,
|
||||
(msg->header.flags & NGF_RESP), msg->data, msg->header.arglen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of the node type corresponding to the cookie
|
||||
*/
|
||||
static const char *
|
||||
NgCookie(int cookie)
|
||||
{
|
||||
static char buf[20];
|
||||
|
||||
switch (cookie) {
|
||||
case NGM_GENERIC_COOKIE:
|
||||
return "generic";
|
||||
case NGM_TTY_COOKIE:
|
||||
return "tty";
|
||||
case NGM_ASYNC_COOKIE:
|
||||
return "async";
|
||||
case NGM_IFACE_COOKIE:
|
||||
return "iface";
|
||||
case NGM_FRAMERELAY_COOKIE:
|
||||
return "frame_relay";
|
||||
case NGM_LMI_COOKIE:
|
||||
return "lmi";
|
||||
case NGM_CISCO_COOKIE:
|
||||
return "cisco";
|
||||
case NGM_PPP_COOKIE:
|
||||
return "ppp";
|
||||
case NGM_RFC1490_NODE_COOKIE:
|
||||
return "rfc1490";
|
||||
case NGM_SOCKET_COOKIE:
|
||||
return "socket";
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "?? (%d)", cookie);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the name of the command
|
||||
*/
|
||||
static const char *
|
||||
NgCmd(int cookie, int cmd)
|
||||
{
|
||||
static char buf[20];
|
||||
|
||||
switch (cookie) {
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_SHUTDOWN:
|
||||
return "shutdown";
|
||||
case NGM_MKPEER:
|
||||
return "mkpeer";
|
||||
case NGM_CONNECT:
|
||||
return "connect";
|
||||
case NGM_NAME:
|
||||
return "name";
|
||||
case NGM_RMHOOK:
|
||||
return "rmhook";
|
||||
case NGM_NODEINFO:
|
||||
return "nodeinfo";
|
||||
case NGM_LISTHOOKS:
|
||||
return "listhooks";
|
||||
case NGM_LISTNAMES:
|
||||
return "listnames";
|
||||
case NGM_LISTNODES:
|
||||
return "listnodes";
|
||||
case NGM_TEXT_STATUS:
|
||||
return "text_status";
|
||||
}
|
||||
break;
|
||||
case NGM_TTY_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_TTY_GET_HOTCHAR:
|
||||
return "getHotChar";
|
||||
case NGM_TTY_SET_HOTCHAR:
|
||||
return "setHotChar";
|
||||
}
|
||||
break;
|
||||
case NGM_ASYNC_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_ASYNC_CMD_GET_STATS:
|
||||
return "getStats";
|
||||
case NGM_ASYNC_CMD_CLR_STATS:
|
||||
return "setStats";
|
||||
case NGM_ASYNC_CMD_SET_CONFIG:
|
||||
return "setConfig";
|
||||
case NGM_ASYNC_CMD_GET_CONFIG:
|
||||
return "getConfig";
|
||||
}
|
||||
break;
|
||||
case NGM_IFACE_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_IFACE_GET_IFNAME:
|
||||
return "getIfName";
|
||||
case NGM_IFACE_GET_IFADDRS:
|
||||
return "getIfAddrs";
|
||||
}
|
||||
break;
|
||||
case NGM_LMI_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_LMI_GET_STATUS:
|
||||
return "get-status";
|
||||
}
|
||||
break;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "?? (%d)", cmd);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode message arguments
|
||||
*/
|
||||
static void
|
||||
NgArgs(int cookie, int cmd, int resp, void *args, int arglen)
|
||||
{
|
||||
|
||||
switch (cookie) {
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_SHUTDOWN:
|
||||
return;
|
||||
case NGM_MKPEER:
|
||||
{
|
||||
struct ngm_mkpeer *const mkp = (struct ngm_mkpeer *) args;
|
||||
|
||||
if (resp)
|
||||
return;
|
||||
NGLOGX(" type \"%s\"", mkp->type);
|
||||
NGLOGX(" ourhook \"%s\"", mkp->ourhook);
|
||||
NGLOGX(" peerhook \"%s\"", mkp->peerhook);
|
||||
return;
|
||||
}
|
||||
case NGM_CONNECT:
|
||||
{
|
||||
struct ngm_connect *const ngc = (struct ngm_connect *) args;
|
||||
|
||||
if (resp)
|
||||
return;
|
||||
NGLOGX(" path \"%s\"", ngc->path);
|
||||
NGLOGX(" ourhook \"%s\"", ngc->ourhook);
|
||||
NGLOGX(" peerhook \"%s\"", ngc->peerhook);
|
||||
return;
|
||||
}
|
||||
case NGM_NAME:
|
||||
{
|
||||
struct ngm_name *const ngn = (struct ngm_name *) args;
|
||||
|
||||
if (resp)
|
||||
return;
|
||||
NGLOGX(" name \"%s\"", ngn->name);
|
||||
return;
|
||||
}
|
||||
case NGM_RMHOOK:
|
||||
{
|
||||
struct ngm_rmhook *const ngr = (struct ngm_rmhook *) args;
|
||||
|
||||
if (resp)
|
||||
return;
|
||||
NGLOGX(" hook \"%s\"", ngr->ourhook);
|
||||
return;
|
||||
}
|
||||
case NGM_NODEINFO:
|
||||
return;
|
||||
case NGM_LISTHOOKS:
|
||||
return;
|
||||
case NGM_LISTNAMES:
|
||||
case NGM_LISTNODES:
|
||||
return;
|
||||
case NGM_TEXT_STATUS:
|
||||
if (!resp)
|
||||
return;
|
||||
NGLOGX(" status \"%s\"", (char *) args);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGM_TTY_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_TTY_GET_HOTCHAR:
|
||||
if (!resp)
|
||||
return;
|
||||
NGLOGX(" char 0x%02x", *((int *) args));
|
||||
return;
|
||||
case NGM_TTY_SET_HOTCHAR:
|
||||
NGLOGX(" char 0x%02x", *((int *) args));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGM_ASYNC_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_ASYNC_CMD_GET_STATS:
|
||||
{
|
||||
struct ng_async_stat *const as = (struct ng_async_stat *) args;
|
||||
|
||||
if (!resp)
|
||||
return;
|
||||
NGLOGX(" syncOctets = %lu", as->syncOctets);
|
||||
NGLOGX(" syncFrames = %lu", as->syncFrames);
|
||||
NGLOGX(" syncOverflows = %lu", as->syncOverflows);
|
||||
NGLOGX(" asyncOctets = %lu", as->asyncOctets);
|
||||
NGLOGX(" asyncFrames = %lu", as->asyncFrames);
|
||||
NGLOGX(" asyncRunts = %lu", as->asyncRunts);
|
||||
NGLOGX(" asyncOverflows = %lu", as->asyncOverflows);
|
||||
NGLOGX(" asyncBadCheckSums = %lu", as->asyncBadCheckSums);
|
||||
return;
|
||||
}
|
||||
case NGM_ASYNC_CMD_GET_CONFIG:
|
||||
case NGM_ASYNC_CMD_SET_CONFIG:
|
||||
{
|
||||
struct ng_async_cfg *const ac = (struct ng_async_cfg *) args;
|
||||
|
||||
if (!resp ^ (cmd != NGM_ASYNC_CMD_GET_CONFIG))
|
||||
return;
|
||||
NGLOGX(" enabled %s", ac->enabled ? "YES" : "NO");
|
||||
NGLOGX(" acfcomp %s", ac->acfcomp ? "YES" : "NO");
|
||||
NGLOGX(" Async MRU %u", ac->amru);
|
||||
NGLOGX(" Sync MRU %u", ac->smru);
|
||||
NGLOGX(" ACCM 0x%08x", ac->accm);
|
||||
return;
|
||||
}
|
||||
case NGM_ASYNC_CMD_CLR_STATS:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case NGM_IFACE_COOKIE:
|
||||
switch (cmd) {
|
||||
case NGM_IFACE_GET_IFNAME:
|
||||
return;
|
||||
case NGM_IFACE_GET_IFADDRS:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
_NgDebugBytes(args, arglen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump bytes in hex
|
||||
*/
|
||||
void
|
||||
_NgDebugBytes(const u_char * ptr, int len)
|
||||
{
|
||||
char buf[100];
|
||||
int k, count;
|
||||
|
||||
#define BYPERLINE 16
|
||||
|
||||
for (count = 0; count < len; ptr += BYPERLINE, count += BYPERLINE) {
|
||||
|
||||
/* Do hex */
|
||||
snprintf(buf, sizeof(buf), "%04x: ", count);
|
||||
for (k = 0; k < BYPERLINE; k++, count++)
|
||||
if (count < len)
|
||||
snprintf(buf + strlen(buf),
|
||||
sizeof(buf) - strlen(buf), "%02x ", ptr[k]);
|
||||
else
|
||||
snprintf(buf + strlen(buf),
|
||||
sizeof(buf) - strlen(buf), " ");
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " ");
|
||||
count -= BYPERLINE;
|
||||
|
||||
/* Do ASCII */
|
||||
for (k = 0; k < BYPERLINE; k++, count++)
|
||||
if (count < len)
|
||||
snprintf(buf + strlen(buf),
|
||||
sizeof(buf) - strlen(buf),
|
||||
"%c", isprint(ptr[k]) ? ptr[k] : '.');
|
||||
else
|
||||
snprintf(buf + strlen(buf),
|
||||
sizeof(buf) - strlen(buf), " ");
|
||||
count -= BYPERLINE;
|
||||
|
||||
/* Print it */
|
||||
NGLOGX("%s", buf);
|
||||
}
|
||||
}
|
||||
|
67
lib/libnetgraph/internal.h
Normal file
67
lib/libnetgraph/internal.h
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
/*
|
||||
* internal.h
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: internal.h,v 1.5 1999/01/20 00:57:22 archie Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
|
||||
extern int _gNgDebugLevel;
|
||||
|
||||
extern void (*_NgLog)(const char *fmt, ...);
|
||||
extern void (*_NgLogx)(const char *fmt, ...);
|
||||
|
||||
#define NGLOG (*_NgLog)
|
||||
#define NGLOGX (*_NgLogx)
|
||||
|
||||
extern void _NgDebugSockaddr(struct sockaddr_ng *sg);
|
||||
extern void _NgDebugMsg(struct ng_mesg *msg);
|
||||
extern void _NgDebugBytes(const u_char *ptr, int size);
|
||||
|
206
lib/libnetgraph/msg.c
Normal file
206
lib/libnetgraph/msg.c
Normal file
@ -0,0 +1,206 @@
|
||||
|
||||
/*
|
||||
* msg.c
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: msg.c,v 1.9 1999/01/20 00:57:23 archie Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/ng_socket.h>
|
||||
|
||||
#include "netgraph.h"
|
||||
#include "internal.h"
|
||||
|
||||
/* Next message token value */
|
||||
static int gMsgId;
|
||||
|
||||
/* For delivering both messages and replies */
|
||||
static int NgDeliverMsg(int cs, const char *path,
|
||||
const struct ng_mesg *hdr, const void *args, size_t arglen);
|
||||
|
||||
/*
|
||||
* Send a message to a node using control socket node "cs".
|
||||
* Returns -1 if error and sets errno appropriately.
|
||||
* If successful, returns the message ID (token) used.
|
||||
*/
|
||||
int
|
||||
NgSendMsg(int cs, const char *path,
|
||||
int cookie, int cmd, const void *args, size_t arglen)
|
||||
{
|
||||
struct ng_mesg msg;
|
||||
|
||||
/* Prepare message header */
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.header.version = NG_VERSION;
|
||||
msg.header.typecookie = cookie;
|
||||
msg.header.token = ++gMsgId;
|
||||
msg.header.flags = NGF_ORIG;
|
||||
msg.header.cmd = cmd;
|
||||
snprintf(msg.header.cmdstr, NG_CMDSTRLEN + 1, "cmd%d", cmd);
|
||||
|
||||
/* Deliver message */
|
||||
if (NgDeliverMsg(cs, path, &msg, args, arglen) < 0)
|
||||
return (-1);
|
||||
return(gMsgId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a message that is a reply to a previously received message.
|
||||
* Returns -1 and sets errno on error, otherwise returns zero.
|
||||
*/
|
||||
int
|
||||
NgSendReplyMsg(int cs, const char *path,
|
||||
const struct ng_mesg *msg, const void *args, size_t arglen)
|
||||
{
|
||||
struct ng_mesg rep;
|
||||
|
||||
/* Prepare message header */
|
||||
rep = *msg;
|
||||
rep.header.flags = NGF_RESP;
|
||||
|
||||
/* Deliver message */
|
||||
return (NgDeliverMsg(cs, path, &rep, args, arglen));
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a message to a node using control socket node "cs".
|
||||
* Returns -1 if error and sets errno appropriately, otherwise zero.
|
||||
*/
|
||||
static int
|
||||
NgDeliverMsg(int cs, const char *path,
|
||||
const struct ng_mesg *hdr, const void *args, size_t arglen)
|
||||
{
|
||||
u_char sgbuf[NG_PATHLEN + 3];
|
||||
struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
|
||||
u_char *buf = NULL;
|
||||
struct ng_mesg *msg;
|
||||
int errnosv = 0;
|
||||
int rtn = 0;
|
||||
|
||||
/* Sanity check */
|
||||
if (args == NULL)
|
||||
arglen = 0;
|
||||
|
||||
/* Get buffer */
|
||||
if ((buf = malloc(sizeof(*msg) + arglen)) == NULL) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("malloc");
|
||||
rtn = -1;
|
||||
goto done;
|
||||
}
|
||||
msg = (struct ng_mesg *) buf;
|
||||
|
||||
/* Finalize message */
|
||||
*msg = *hdr;
|
||||
msg->header.arglen = arglen;
|
||||
memcpy(msg->data, args, arglen);
|
||||
|
||||
/* Prepare socket address */
|
||||
sg->sg_family = AF_NETGRAPH;
|
||||
snprintf(sg->sg_data, NG_PATHLEN + 1, "%s", path);
|
||||
sg->sg_len = strlen(sg->sg_data) + 3;
|
||||
|
||||
/* Debugging */
|
||||
if (_gNgDebugLevel >= 2) {
|
||||
NGLOGX("SENDING %s:",
|
||||
(msg->header.flags & NGF_RESP) ? "RESPONSE" : "MESSAGE");
|
||||
_NgDebugSockaddr(sg);
|
||||
_NgDebugMsg(msg);
|
||||
}
|
||||
|
||||
/* Send it */
|
||||
if (sendto(cs, msg, sizeof(*msg) + arglen,
|
||||
0, (struct sockaddr *) sg, sg->sg_len) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("sendto(%s)", sg->sg_data);
|
||||
rtn = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
/* Done */
|
||||
free(buf); /* OK if buf is NULL */
|
||||
errno = errnosv;
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive a control message.
|
||||
*
|
||||
* On error, this returns -1 and sets errno.
|
||||
* Otherwise, it returns the length of the received reply.
|
||||
*/
|
||||
int
|
||||
NgRecvMsg(int cs, struct ng_mesg *rep, size_t replen, char *path)
|
||||
{
|
||||
u_char sgbuf[NG_PATHLEN + sizeof(struct sockaddr_ng)];
|
||||
struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
|
||||
int len, sglen = sizeof(sgbuf);
|
||||
int errnosv;
|
||||
|
||||
/* Read reply */
|
||||
len = recvfrom(cs, rep, replen, 0, (struct sockaddr *) sg, &sglen);
|
||||
if (len < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("recvfrom");
|
||||
goto errout;
|
||||
}
|
||||
if (path != NULL)
|
||||
snprintf(path, NG_PATHLEN + 1, "%s", sg->sg_data);
|
||||
|
||||
/* Debugging */
|
||||
if (_gNgDebugLevel >= 2) {
|
||||
NGLOGX("RECEIVED %s:",
|
||||
(rep->header.flags & NGF_RESP) ? "RESPONSE" : "MESSAGE");
|
||||
_NgDebugSockaddr(sg);
|
||||
_NgDebugMsg(rep);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return (len);
|
||||
|
||||
errout:
|
||||
errno = errnosv;
|
||||
return (-1);
|
||||
}
|
||||
|
211
lib/libnetgraph/netgraph.3
Normal file
211
lib/libnetgraph/netgraph.3
Normal file
@ -0,0 +1,211 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: netgraph.3,v 1.7 1999/01/25 07:14:06 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NETGRAPH 3
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm NgMkSockNode ,
|
||||
.Nm NgNameNode ,
|
||||
.Nm NgSendMsg ,
|
||||
.Nm NgRecvMsg ,
|
||||
.Nm NgSendData ,
|
||||
.Nm NgRecvData ,
|
||||
.Nm NgSetDebug ,
|
||||
.Nm NgSetErrLog
|
||||
.Nd Netgraph user library
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph.h>
|
||||
.Ft int
|
||||
.Fn NgMkSockNode "const char *name" "int *csp" "int *dsp"
|
||||
.Ft int
|
||||
.Fn NgNameNode "int cs" "const char *path" "const char *fmt" "..."
|
||||
.Ft int
|
||||
.Fn NgSendMsg "int cs" "const char *path" "int cookie" "int cmd" "const void *arg" "size_t arglen"
|
||||
.Ft int
|
||||
.Fn NgSendMsgReply "int cs" "const char *path" "struct ng_mesg *msg" "const void *arg" "size_t arglen"
|
||||
.Ft int
|
||||
.Fn NgRecvMsg "int cs" "struct ng_mesg *rep" "size_t replen" "char *path"
|
||||
.Ft int
|
||||
.Fn NgSendData "int ds" "const char *hook" "const u_char *buf" "size_t len"
|
||||
.Ft int
|
||||
.Fn NgRecvData "int ds" "u_char *buf" "size_t len" "char *hook"
|
||||
.Ft int
|
||||
.Fn NgSetDebug "int level"
|
||||
.Ft void
|
||||
.Fn NgSetErrLog "void (*log)(const char *fmt, ...)" "void (*logx)(const char *fmt, ...)"
|
||||
.Sh DESCRIPTION
|
||||
These functions facilitate user-mode program participation in the kernel
|
||||
.Xr netgraph 4
|
||||
graph-based networking system, by utilizing the netgraph
|
||||
.Em socket
|
||||
node type (see
|
||||
.Xr ng_socket 8 ")."
|
||||
.Pp
|
||||
.Fn NgMkSockNode
|
||||
should be called first, to create a new
|
||||
.Em socket
|
||||
type netgraph node with associated control and data sockets. If
|
||||
.Fa name
|
||||
is non-NULL, the node will have that global name assigned to it.
|
||||
.Fa "*csp"
|
||||
and
|
||||
.Fa "*dsp"
|
||||
will be set to the newly opened control and data sockets
|
||||
associated with the node; either
|
||||
.Fa "csp"
|
||||
or
|
||||
.Fa "dsp"
|
||||
may be NULL if only one socket is desired.
|
||||
.Pp
|
||||
.Fn NgNameNode
|
||||
assigns a global name to the node addressed by
|
||||
.Fa path .
|
||||
.Pp
|
||||
.Fn NgSendMsg
|
||||
sends a control message from the socket node associated with control socket
|
||||
.Fa cs
|
||||
to the node addressed by
|
||||
.Fa path .
|
||||
The
|
||||
.Fa cookie
|
||||
indicates how to interpret
|
||||
.Fa cmd ,
|
||||
which indicates a specific command.
|
||||
Extra argument data (if any) is specified by
|
||||
.Fa arg
|
||||
and
|
||||
.Fa arglen .
|
||||
The
|
||||
.Fa cookie ,
|
||||
.Fa cmd ,
|
||||
and argument data are defined by the header file corresponding
|
||||
to the type of the node being addressed.
|
||||
.Pp
|
||||
Use
|
||||
.Fn NgSendMsgReply
|
||||
to send reply to a previously received control message.
|
||||
The original message header should be pointed to by
|
||||
.Fa msg .
|
||||
.Pp
|
||||
.Fn NgRecvMsg
|
||||
reads the next control message received by the node associated with
|
||||
control socket
|
||||
.Fa cs .
|
||||
The message and any extra argument data must fit in
|
||||
.Fa replen
|
||||
bytes.
|
||||
If
|
||||
.Fa "path"
|
||||
is non-NULL, it must point to a buffer of at least
|
||||
.Dv "NG_PATHLEN + 1"
|
||||
bytes, which will be filled in (and NUL terminated) with the path to
|
||||
the node from which the message was received.
|
||||
.Pp
|
||||
.Fn NgSendData
|
||||
writes a data packet out on the specified hook of the node corresponding
|
||||
to data socket
|
||||
.Fa ds .
|
||||
The node must already be connected to some other node via that hook.
|
||||
.Pp
|
||||
.Fn NgRecvData
|
||||
reads the next data packet (of up to
|
||||
.Fa len
|
||||
bytes) received by the node corresponding to data socket
|
||||
.Fa ds
|
||||
and stores it in
|
||||
.Fa buf ,
|
||||
which must be large enough to hold the entire packet. If
|
||||
.Fa "hook"
|
||||
is non-NULL, it must point to a buffer of at least
|
||||
.Dv "NG_HOOKLEN + 1"
|
||||
bytes, which will be filled in (and NUL terminated) with the name of
|
||||
the hook on which the data was received.
|
||||
.Pp
|
||||
.Fn NgSetDebug
|
||||
and
|
||||
.Fn NgSetErrLog
|
||||
are used for debugging.
|
||||
.Fn NgSetDebug
|
||||
sets the debug level (if non-negative), and returns the old setting.
|
||||
Higher debug levels result in more verbosity. The default is zero.
|
||||
All debug and error messages are logged via the functions
|
||||
specified in the most recent call to
|
||||
.Fn NgSetErrLog .
|
||||
The default logging functions are
|
||||
.Xr vwarn 3
|
||||
and
|
||||
.Xr vwarnx 3 .
|
||||
.Pp
|
||||
Note that
|
||||
.Xr select 2
|
||||
can be used on the data and the control sockets to detect the presence of
|
||||
incoming data and control messages, respectively.
|
||||
Data and control packets are always written and read atomically, i.e.,
|
||||
in one whole piece.
|
||||
.Pp
|
||||
User mode programs must be linked with the
|
||||
.Dv -lnetgraph
|
||||
flag to link in this library.
|
||||
.Sh INITIALIZATION
|
||||
Netgraph is not part of the standard FreeBSD kernel. To enable it,
|
||||
either your kernel must be compiled with ``options NETGRAPH''
|
||||
in the kernel configuration file, or else the
|
||||
.Xr netgraph 4
|
||||
and
|
||||
.Xr ng_socket 8
|
||||
KLD modules must have been loaded via
|
||||
.Xr kldload 8 .
|
||||
.Sh DIAGNOSTICS
|
||||
All functions except
|
||||
.Fn NgSetDebug
|
||||
and
|
||||
.Fn NgSetErrLog
|
||||
return -1 if there was an error and set errno accordingly.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr socket 2 ,
|
||||
.Xr select 2 ,
|
||||
.Xr warnx 3 ,
|
||||
.Xr ng_socket 8 .
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Em netgraph
|
||||
system was designed and first implemented at Whistle Communications, Inc.
|
||||
in a version FreeBSD 2.2 customized for the Whistle InterJet.
|
||||
.Sh AUTHOR
|
||||
.An Archie Cobbs <archie@whistle.com>
|
64
lib/libnetgraph/netgraph.h
Normal file
64
lib/libnetgraph/netgraph.h
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
/*
|
||||
* netgraph.h
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: netgraph.h,v 1.7 1999/01/20 00:57:23 archie Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETGRAPH_H_
|
||||
#define _NETGRAPH_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int NgMkSockNode(const char *, int *, int *);
|
||||
int NgNameNode(int, const char *, const char *, ...);
|
||||
int NgSendMsg(int, const char *, int, int, const void *, size_t);
|
||||
int NgSendReplyMsg(int, const char *,
|
||||
const struct ng_mesg *, const void *, size_t);
|
||||
int NgRecvMsg(int, struct ng_mesg *, size_t, char *);
|
||||
int NgSendData(int, const char *, const u_char *, size_t);
|
||||
int NgRecvData(int, u_char *, size_t, char *);
|
||||
int NgSetDebug(int);
|
||||
void NgSetErrLog(void (*)(const char *fmt, ...),
|
||||
void (*)(const char *fmt, ...));
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
264
lib/libnetgraph/sock.c
Normal file
264
lib/libnetgraph/sock.c
Normal file
@ -0,0 +1,264 @@
|
||||
|
||||
/*
|
||||
* sock.c
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: sock.c,v 1.12 1999/01/20 00:57:23 archie Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/ng_socket.h>
|
||||
|
||||
#include "netgraph.h"
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* Create a socket type node and give it the supplied name.
|
||||
* Return data and control sockets corresponding to the node.
|
||||
* Returns -1 if error and sets errno.
|
||||
*/
|
||||
int
|
||||
NgMkSockNode(const char *name, int *csp, int *dsp)
|
||||
{
|
||||
char namebuf[NG_NODELEN + 1];
|
||||
int cs = -1; /* control socket */
|
||||
int ds = -1; /* data socket */
|
||||
int errnosv;
|
||||
|
||||
/* Empty name means no name */
|
||||
if (name && *name == 0)
|
||||
name = NULL;
|
||||
|
||||
/* Create control socket; this also creates the netgraph node */
|
||||
if ((cs = socket(AF_NETGRAPH, SOCK_DGRAM, NG_CONTROL)) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("socket");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Assign the node the desired name, if any */
|
||||
if (name != NULL) {
|
||||
u_char sbuf[NG_NODELEN + 3];
|
||||
struct sockaddr_ng *const sg = (struct sockaddr_ng *) sbuf;
|
||||
|
||||
/* Assign name */
|
||||
snprintf(sg->sg_data, NG_NODELEN + 1, "%s", name);
|
||||
sg->sg_family = AF_NETGRAPH;
|
||||
sg->sg_len = strlen(sg->sg_data) + 3;
|
||||
if (bind(cs, (struct sockaddr *) sg, sg->sg_len) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("bind(%s)", sg->sg_data);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Save node name */
|
||||
snprintf(namebuf, sizeof(namebuf), "%s", name);
|
||||
} else if (dsp != NULL) {
|
||||
u_char rbuf[sizeof(struct ng_mesg) + sizeof(struct nodeinfo)];
|
||||
struct ng_mesg *const resp = (struct ng_mesg *) rbuf;
|
||||
struct nodeinfo *const ni = (struct nodeinfo *) resp->data;
|
||||
|
||||
/* Find out the node ID */
|
||||
if (NgSendMsg(cs, ".", NGM_GENERIC_COOKIE,
|
||||
NGM_NODEINFO, NULL, 0) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("send nodeinfo");
|
||||
goto errout;
|
||||
}
|
||||
if (NgRecvMsg(cs, resp, sizeof(rbuf), NULL) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("recv nodeinfo");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Save node "name" */
|
||||
snprintf(namebuf, sizeof(namebuf), "[%lx]", (u_long) ni->id);
|
||||
}
|
||||
|
||||
/* Create data socket if desired */
|
||||
if (dsp != NULL) {
|
||||
u_char sbuf[NG_NODELEN + 4];
|
||||
struct sockaddr_ng *const sg = (struct sockaddr_ng *) sbuf;
|
||||
|
||||
/* Create data socket, initially just "floating" */
|
||||
if ((ds = socket(AF_NETGRAPH, SOCK_DGRAM, NG_DATA)) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("socket");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Associate the data socket with the node */
|
||||
snprintf(sg->sg_data, NG_NODELEN + 2, "%s:", namebuf);
|
||||
sg->sg_family = AF_NETGRAPH;
|
||||
sg->sg_len = strlen(sg->sg_data) + 3;
|
||||
if (connect(ds, (struct sockaddr *) sg, sg->sg_len) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("connect(%s)", sg->sg_data);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the socket(s) */
|
||||
if (csp)
|
||||
*csp = cs;
|
||||
else
|
||||
close(cs);
|
||||
if (dsp)
|
||||
*dsp = ds;
|
||||
return (0);
|
||||
|
||||
errout:
|
||||
/* Failed */
|
||||
if (cs >= 0)
|
||||
close(cs);
|
||||
if (ds >= 0)
|
||||
close(ds);
|
||||
errno = errnosv;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Assign a globally unique name to a node
|
||||
* Returns -1 if error and sets errno.
|
||||
*/
|
||||
int
|
||||
NgNameNode(int cs, const char *path, const char *fmt, ...)
|
||||
{
|
||||
struct ngm_name ngn;
|
||||
va_list args;
|
||||
|
||||
/* Build message arg */
|
||||
va_start(args, fmt);
|
||||
vsnprintf(ngn.name, sizeof(ngn.name), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* Send message */
|
||||
if (NgSendMsg(cs, path,
|
||||
NGM_GENERIC_COOKIE, NGM_NAME, &ngn, sizeof(ngn)) < 0) {
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOGX("%s: failed", __FUNCTION__);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a packet from a data socket
|
||||
* Returns -1 if error and sets errno.
|
||||
*/
|
||||
int
|
||||
NgRecvData(int ds, u_char * buf, size_t len, char *hook)
|
||||
{
|
||||
u_char frombuf[NG_HOOKLEN + sizeof(struct sockaddr_ng)];
|
||||
struct sockaddr_ng *const from = (struct sockaddr_ng *) frombuf;
|
||||
int fromlen = sizeof(frombuf);
|
||||
int rtn, errnosv;
|
||||
|
||||
/* Read packet */
|
||||
rtn = recvfrom(ds, buf, len, 0, (struct sockaddr *) from, &fromlen);
|
||||
if (rtn < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("recvfrom");
|
||||
errno = errnosv;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Copy hook name */
|
||||
if (hook != NULL)
|
||||
snprintf(hook, NG_HOOKLEN + 1, "%s", from->sg_data);
|
||||
|
||||
/* Debugging */
|
||||
if (_gNgDebugLevel >= 2) {
|
||||
NGLOGX("READ %s from hook \"%s\" (%d bytes)",
|
||||
rtn ? "PACKET" : "EOF", from->sg_data, rtn);
|
||||
if (_gNgDebugLevel >= 3)
|
||||
_NgDebugBytes(buf, rtn);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a packet to a data socket. The packet will be sent
|
||||
* out the corresponding node on the specified hook.
|
||||
* Returns -1 if error and sets errno.
|
||||
*/
|
||||
int
|
||||
NgSendData(int ds, const char *hook, const u_char * buf, size_t len)
|
||||
{
|
||||
u_char sgbuf[NG_HOOKLEN + sizeof(struct sockaddr_ng)];
|
||||
struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
|
||||
int errnosv;
|
||||
|
||||
/* Set up destination hook */
|
||||
sg->sg_family = AF_NETGRAPH;
|
||||
snprintf(sg->sg_data, NG_HOOKLEN + 1, "%s", hook);
|
||||
sg->sg_len = strlen(sg->sg_data) + 3;
|
||||
|
||||
/* Debugging */
|
||||
if (_gNgDebugLevel >= 2) {
|
||||
NGLOGX("WRITE PACKET to hook \"%s\" (%d bytes)", hook, len);
|
||||
_NgDebugSockaddr(sg);
|
||||
if (_gNgDebugLevel >= 3)
|
||||
_NgDebugBytes(buf, len);
|
||||
}
|
||||
|
||||
/* Send packet */
|
||||
if (sendto(ds, buf, len, 0, (struct sockaddr *) sg, sg->sg_len) < 0) {
|
||||
errnosv = errno;
|
||||
if (_gNgDebugLevel >= 1)
|
||||
NGLOG("sendto(%s)", sg->sg_data);
|
||||
errno = errnosv;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
}
|
||||
|
876
share/man/man4/netgraph.4
Normal file
876
share/man/man4/netgraph.4
Normal file
@ -0,0 +1,876 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Authors: Julian Elischer <julian@whistle.com>
|
||||
.\" Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NETGRAPH 4
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm netgraph
|
||||
.Nd graph based kernel networking subsystem
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
system provides a uniform and modular system for the implementation
|
||||
of kernel objects which perform various networking functions. The objects,
|
||||
known as
|
||||
.Em nodes ,
|
||||
can be arranged into arbitrarily complicated graphs. Nodes have
|
||||
.Em hooks
|
||||
which are used to connect two nodes together, forming the edges in the graph.
|
||||
Nodes communicate along the edges to process data, implement protocols, etc.
|
||||
.Pp
|
||||
The aim of
|
||||
.Nm
|
||||
is to supplement rather than replace the existing kernel networking
|
||||
infrastructure. It provides:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
A flexible way of combining protocol and link level drivers
|
||||
.It
|
||||
A modular way to implement new protocols
|
||||
.It
|
||||
A common framework for kernel entities to inter-communicate
|
||||
.It
|
||||
A reasonably fast, kernel-based implementation
|
||||
.El
|
||||
.Sh Nodes and Types
|
||||
The most fundamental concept in
|
||||
.Nm
|
||||
is that of a
|
||||
.Em node .
|
||||
All nodes implement a number of predefined methods which allow them
|
||||
to interact with other nodes in a well defined manner.
|
||||
.Pp
|
||||
Each node has a
|
||||
.Em type ,
|
||||
which is a static property of the node determined at node creation time.
|
||||
A node's type is described by a unique ASCII type name.
|
||||
The type implies what the node does and how it may be connected
|
||||
to other nodes.
|
||||
.Pp
|
||||
In object-oriented language, types are classes and nodes are instances
|
||||
of their respective class. All node types are subclasses of the generic node
|
||||
type, and hence inherit certain common functionality and capabilities
|
||||
(e.g., the ability to have an ASCII name).
|
||||
.Pp
|
||||
Nodes may be assigned a globally unique ASCII name which can be
|
||||
used to refer to the node.
|
||||
The name must not contain the characters ``.'' or ``:'' and is limited to
|
||||
.Dv "NG_NODELEN + 1"
|
||||
characters (including NUL byte).
|
||||
.Pp
|
||||
Each node instance has a unique
|
||||
.Em ID number
|
||||
which is expressed as a 32-bit hex value. This value may be used to
|
||||
refer to a node when there is no ASCII name assigned to it.
|
||||
.Sh Hooks
|
||||
Nodes are connected to other nodes by connecting a pair of
|
||||
.Em hooks ,
|
||||
one from each node. Data flows bidirectionally between nodes along
|
||||
connected pairs of hooks. A node may have as many hooks as it
|
||||
needs, and may assign whatever meaning it wants to a hook.
|
||||
.Pp
|
||||
Hooks have these properties:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
A hook has an ASCII name which is unique among all hooks
|
||||
on that node (other hooks on other nodes may have the same name).
|
||||
The name must not contain a ``.'' or a ``:'' and is
|
||||
limited to
|
||||
.Dv "NG_HOOKLEN + 1"
|
||||
characters (including NUL byte).
|
||||
.It
|
||||
A hook is always connected to another hook. That is, hooks are
|
||||
created at the time they are connected, and breaking an edge by
|
||||
removing either hook destroys both hooks.
|
||||
.El
|
||||
.Pp
|
||||
A node may decide to assign special meaning to some hooks.
|
||||
For example, connecting to the hook named ``debug'' might trigger
|
||||
the node to start sending debugging information to that hook.
|
||||
.Sh Data Flow
|
||||
Two types of information flow between nodes: data messages and
|
||||
control messages. Data messages are passed in mbuf chains along the edges
|
||||
in the graph, one edge at a time. The first mbuf in a chain must have the
|
||||
.Dv M_PKTHDR
|
||||
flag set. Each node decides how to handle data coming in on its hooks.
|
||||
.Pp
|
||||
Control messages are type-specific structures sent from one node directly
|
||||
to an arbitrary other node. There are two ways to address such a message. If
|
||||
there is a sequence of edges connecting the two nodes, the message
|
||||
may be ``source routed'' by specifying the corresponding sequence
|
||||
of hooks as the destination address for the message (relative
|
||||
addressing). Otherwise, the recipient node global ASCII name
|
||||
(or equivalent ID based name) is used as the destination address
|
||||
for the message (absolute addressing). The two types of addressing
|
||||
may be combined, by specifying an absolute start node and a sequence
|
||||
of hooks.
|
||||
.Pp
|
||||
Messages often represent commands that are followed by a reply message
|
||||
in the reverse direction. To facilitate this, the recipient of a
|
||||
control message is supplied with a ``return address'' that is suitable
|
||||
for addressing a reply.
|
||||
.Pp
|
||||
Each control message contains a 32 bit value called a
|
||||
.Em typecookie
|
||||
indicating the type of the message, i.e., how to interpret it.
|
||||
Typically each type defines a unique typecookie for the messages
|
||||
that it understands. However, a node may choose to recognize and
|
||||
implement more than one type of message.
|
||||
.Sh Netgraph is Functional
|
||||
In order to minimize latency, most
|
||||
.Nm netgraph
|
||||
operations are functional.
|
||||
That is, data and control messages are delivered by making function
|
||||
calls rather than by using queues and mailboxes. For example, if node
|
||||
A wishes to send a data mbuf to neighboring node B, it calls the
|
||||
generic
|
||||
.Nm
|
||||
data delivery function. This function in turn locates
|
||||
node B and calls B's ``receive data'' method. While this mode of operation
|
||||
results in good performance, it has a few implications for node
|
||||
developers:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
Whenever a node delivers a data or control message, the node
|
||||
may need to allow for the possibility of receiving a returning message
|
||||
before the original delivery function call returns.
|
||||
.It
|
||||
Netgraph nodes and support routines generally run at
|
||||
.Dv "splnet()" .
|
||||
However, some nodes may want to send data and control messages
|
||||
from a different priority level. Netgraph supplies queueing routines which
|
||||
utilize the NETISR system to move message delivery to
|
||||
.Dv "splnet()" .
|
||||
Note that messages are always received at
|
||||
.Dv "splnet()" .
|
||||
.It
|
||||
It's possible for an infinite loop to occur if the graph contains cycles.
|
||||
.El
|
||||
.Pp
|
||||
So far, these issues have not proven problematical in practice.
|
||||
.Sh Interaction With Other Parts of the Kernel
|
||||
A node may have a hidden interaction with other components of the
|
||||
kernel outside of the
|
||||
.Nm
|
||||
subsystem, such as device hardware,
|
||||
kernel protocol stacks, etc. In fact, one of the benefits of
|
||||
.Nm
|
||||
is the ability to join disparate kernel networking entities together in a
|
||||
consistent communication framework.
|
||||
.Pp
|
||||
An example is the node type
|
||||
.Em socket
|
||||
which is both a netgraph node and a
|
||||
.Xr socket 2
|
||||
BSD socket in the protocol family
|
||||
.Dv PF_NETGRAPH .
|
||||
Socket nodes allow user processes to participate in
|
||||
.Nm netgraph .
|
||||
Other nodes communicate with socket nodes using the usual methods, and the
|
||||
node hides the fact that it is also passing information to and from a
|
||||
cooperating user process.
|
||||
.Pp
|
||||
Another example is a device driver that presents
|
||||
a node interface to the hardware.
|
||||
.Sh Node Methods
|
||||
Nodes are notified of the following actions via function calls
|
||||
to the following node methods (all at
|
||||
.Dv "splnet()" )
|
||||
and may accept or reject that action (by returning the appropriate
|
||||
error code):
|
||||
.Bl -tag -width xxx
|
||||
.It Creation of a new node
|
||||
The constructor for the type is called. If creation of a new node is
|
||||
allowed, the constructor must call the generic node creation
|
||||
function (in object-oriented terms, the superclass constructor)
|
||||
and then allocate any special resources it needs. For nodes that
|
||||
correspond to hardware, this is typically done during the device
|
||||
attach routine. Often a global ASCII name corresponding to the
|
||||
device name is assigned here as well.
|
||||
.It Creation of a new hook
|
||||
The hook is created and tentatively
|
||||
linked to the node, and the node is told about the name that will be
|
||||
used to describe this hook. The node sets up any special data structures
|
||||
it needs, or may reject the connection, based on the name of the hook.
|
||||
.It Successful connection of two hooks
|
||||
After both ends have accepted their
|
||||
hooks, and the links have been made, the nodes get a chance to
|
||||
find out who their peer is across the link and can then decide to reject
|
||||
the connection. Tear-down is automatic.
|
||||
.It Destruction of a hook
|
||||
The node is notified of a broken connection. The node may consider some hooks
|
||||
to be critical to operation and others to be expendable: the disconnection
|
||||
of one hook may be an acceptable event while for another it
|
||||
may effect a total shutdown for the node.
|
||||
.It Shutdown of a node
|
||||
This method allows a node to clean up
|
||||
and to ensure that any actions that need to be performed
|
||||
at this time are taken. The method must call the generic (i.e., superclass)
|
||||
node destructor to get rid of the generic components of the node.
|
||||
Some nodes (usually associated with a piece of hardware) may be
|
||||
.Em persistent
|
||||
in that a shutdown breaks all edges and resets the node,
|
||||
but doesn't remove it, in which case the generic destructor is not called.
|
||||
.El
|
||||
.Sh Sending and Receiving Data
|
||||
Three other methods are also supported by all nodes:
|
||||
.Bl -tag -width xxx
|
||||
.It Receive data message
|
||||
An mbuf chain is passed to the node.
|
||||
The node is notified on which hook the data arrived,
|
||||
and can use this information in its processing decision.
|
||||
The node must must always
|
||||
.Dv m_freem()
|
||||
the mbuf chain on completion or error, or pass it on to another node
|
||||
(or kernel module) which will then be responsible for freeing it.
|
||||
.Pp
|
||||
In addition to the mbuf chain itself there is also a pointer to a
|
||||
structure describing meta-data about the message
|
||||
(e.g. priority information). This pointer may be
|
||||
.Dv NULL
|
||||
if there is no additional information. The format for this information is
|
||||
described in
|
||||
.Dv netgraph.h .
|
||||
The memory for meta-data must allocated via
|
||||
.Dv malloc()
|
||||
with type
|
||||
.Dv M_NETGRAPH .
|
||||
As with the data itself, it is the receiver's responsibility to
|
||||
.Dv free()
|
||||
the meta-data. If the mbuf chain is freed the meta-data must
|
||||
be freed at the same time. If the meta-data is freed but the
|
||||
real data on is passed on, then a
|
||||
.Dv NULL
|
||||
pointer must be substituted.
|
||||
.Pp
|
||||
The receiving node may decide to defer the data by queueing it in the
|
||||
.Nm
|
||||
NETISR system (see below).
|
||||
.Pp
|
||||
The structure and use of meta-data is still experimental, but is presently used in
|
||||
frame-relay to indicate that management packets should be queued for transmission
|
||||
at a higher priority than data packets. This is required for
|
||||
conformance with Frame Relay standards.
|
||||
.Pp
|
||||
.It Receive queued data message
|
||||
Usually this will be the same function as
|
||||
.Em Receive data message.
|
||||
This is the entry point called when a data message is being handed to
|
||||
the node after having been queued in the NETISR system.
|
||||
This allows a node to decide in the
|
||||
.Em Receive data message
|
||||
method that a message should be defered and queued,
|
||||
and be sure that when it is processed from the queue,
|
||||
it will not be queued again.
|
||||
.It Receive control message
|
||||
This method is called when a control message is addressed to the node.
|
||||
A return address is always supplied, giving the address of the node
|
||||
that originated the message so a reply message can be sent anytime later.
|
||||
.Pp
|
||||
It is possible for a synchronous reply to be made, and in fact this
|
||||
is more common in practice.
|
||||
This is done by setting a pointer (supplied as an extra function parameter)
|
||||
to point to the reply.
|
||||
Then when the control message delivery function returns,
|
||||
the caller can check if this pointer has been made non-NULL,
|
||||
and if so then it points to the reply message allocated via
|
||||
.Dv malloc()
|
||||
and containing the synchronous response. In both directions,
|
||||
(request and response) it is up to the
|
||||
receiver of that message to
|
||||
.Dv free()
|
||||
the control message buffer. All control messages and replies are
|
||||
allocated with
|
||||
.Dv malloc()
|
||||
type
|
||||
.Dv M_NETGRAPH .
|
||||
.El
|
||||
.Pp
|
||||
Much use has been made of reference counts, so that nodes being
|
||||
free'd of all references are automatically freed, and this behaviour
|
||||
has been tested and debugged to present a consistent and trustworthy
|
||||
framework for the ``type module'' writer to use.
|
||||
.Sh Addressing
|
||||
The
|
||||
.Nm
|
||||
framework provides an unambiguous and simple to use method of specifically
|
||||
addressing any single node in the graph. The naming of a node is
|
||||
independent of its type, in that another node, or external component
|
||||
need not know anything about the node's type in order to address it so as
|
||||
to send it a generic message type. Node and hook names should be
|
||||
chosen so as to make addresses meaningful.
|
||||
.Pp
|
||||
Addresses are either absolute or relative. An absolute address begins
|
||||
with a node name, (or ID), followed by a colon, followed by a sequence of hook
|
||||
names separated by periods. This addresses the node reached by starting
|
||||
at the named node and following the specified sequence of hooks.
|
||||
A relative address includes only the sequence of hook names, implicitly
|
||||
starting hook traversal at the local node.
|
||||
.Pp
|
||||
There are a couple of special possibilities for the node name.
|
||||
The name ``.'' (refered to as ``.:'') always refers to the local node.
|
||||
Also, nodes that have no global name may be addressed by their ID numbers,
|
||||
by enclosing the hex representation of the ID number within square brackets.
|
||||
Here are some examples of valid netgraph addresses:
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
.:
|
||||
foo:
|
||||
.:hook1
|
||||
foo:hook1.hook2
|
||||
[f057cd80]:hook1
|
||||
.Ed
|
||||
.Pp
|
||||
Consider the following set of nodes might be created for a site with
|
||||
a single physical frame relay line having two active logical DLCI channels,
|
||||
with RFC-1490 frames on DLCI 16 and PPP frames over DLCI 20:
|
||||
.Pp
|
||||
.Bd -literal
|
||||
[type SYNC ] [type FRAME] [type RFC1490]
|
||||
[ "Frame1" ](uplink)<-->(data)[<un-named>](dlci16)<-->(mux)[<un-named> ]
|
||||
[ A ] [ B ](dlci20)<---+ [ C ]
|
||||
|
|
||||
| [ type PPP ]
|
||||
+>(mux)[<un-named>]
|
||||
[ D ]
|
||||
.Ed
|
||||
.Pp
|
||||
One could always send a control message to node C from anywhere
|
||||
by using the name
|
||||
.Em "Frame1:uplink.dlci16" .
|
||||
Similarly,
|
||||
.Em "Frame1:uplink.dlci20"
|
||||
could reliably be used to reach node D, and node A could refer
|
||||
to node B as
|
||||
.Em ".:uplink" ,
|
||||
or simply
|
||||
.Em "uplink" .
|
||||
Conversely, B can refer to A as
|
||||
.Em "data" .
|
||||
The address
|
||||
.Em "mux.data"
|
||||
could be used by both nodes C and D to address a message to node A.
|
||||
.Pp
|
||||
Note that this is only for
|
||||
.Em control messages .
|
||||
Data messages are routed one hop at a time, by specifying the departing
|
||||
hook, with each node making the next routing decision. So when B
|
||||
receives a frame on hook
|
||||
.Em data
|
||||
it decodes the frame relay header to determine the DLCI,
|
||||
and then forwards the unwrapped frame to either C or D.
|
||||
.Pp
|
||||
A similar graph might be used to represent multi-link PPP running
|
||||
over an ISDN line:
|
||||
.Pp
|
||||
.Bd -literal
|
||||
[ type BRI ](B1)<--->(link1)[ type MPP ]
|
||||
[ "ISDN1" ](B2)<--->(link2)[ (no name) ]
|
||||
[ ](D) <-+
|
||||
|
|
||||
+----------------+
|
||||
|
|
||||
+->(switch)[ type Q.921 ](term1)<---->(datalink)[ type Q.931 ]
|
||||
[ (no name) ] [ (no name) ]
|
||||
.Ed
|
||||
.Sh Netgraph Structures
|
||||
Interesting members of the node and hook structures are shown below:
|
||||
.Bd -literal
|
||||
struct ng_node {
|
||||
char *name; /* Optional globally unique name */
|
||||
void *private; /* Node implementation private info */
|
||||
struct ng_type *type; /* The type of this node */
|
||||
int refs; /* Number of references to this struct */
|
||||
int numhooks; /* Number of connected hooks */
|
||||
hook_p hooks; /* Linked list of (connected) hooks */
|
||||
};
|
||||
typedef struct ng_node *node_p;
|
||||
|
||||
struct ng_hook {
|
||||
char *name; /* This node's name for this hook */
|
||||
void *private; /* Node implementation private info */
|
||||
int refs; /* Number of references to this struct */
|
||||
struct ng_node *node; /* The node this hook is attached to */
|
||||
struct ng_hook *peer; /* The other hook in this connected pair */
|
||||
struct ng_hook *next; /* Next in list of hooks for this node */
|
||||
};
|
||||
typedef struct ng_hook *hook_p;
|
||||
.Ed
|
||||
.Pp
|
||||
The maintenance of the name pointers, reference counts, and linked list
|
||||
of hooks for each node is handled automatically by the
|
||||
.Nm
|
||||
subsystem.
|
||||
Typically a node's private info contains a back-pointer to the node or hook
|
||||
structure, which counts as a new reference that must be registered by
|
||||
incrementing
|
||||
.Dv "node->refs" .
|
||||
.Pp
|
||||
From a hook you can obtain the corresponding node, and from
|
||||
a node the list of all active hooks.
|
||||
.Pp
|
||||
Node types are described by this structure:
|
||||
.Bd -literal
|
||||
struct ng_type {
|
||||
u_int32_t version; /* Must equal NG_VERSION */
|
||||
const char *name; /* Unique type name */
|
||||
|
||||
/* Module event handler */
|
||||
modeventhand_t mod_event; /* Handle load/unload (optional) */
|
||||
|
||||
/* Constructor */
|
||||
int (*constructor)(node_p *node); /* Create a new node */
|
||||
|
||||
/** Methods using the node **/
|
||||
int (*rcvmsg)(node_p node, /* Receive control message */
|
||||
struct ng_mesg *msg, /* The message */
|
||||
const char *retaddr, /* Return address */
|
||||
struct ng_mesg **resp); /* Synchronous response */
|
||||
int (*shutdown)(node_p node); /* Shutdown this node */
|
||||
int (*newhook)(node_p node, /* create a new hook */
|
||||
hook_p hook, /* Pre-allocated struct */
|
||||
const char *name); /* Name for new hook */
|
||||
|
||||
/** Methods using the hook **/
|
||||
int (*connect)(hook_p hook); /* Confirm new hook attachment */
|
||||
int (*rcvdata)(hook_p hook, /* Receive data on a hook */
|
||||
struct mbuf *m, /* The data in an mbuf */
|
||||
meta_p meta); /* Meta-data, if any */
|
||||
int (*disconnect)(hook_p hook); /* Notify disconnection of hook */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
Control messages have the following structure:
|
||||
.Bd -literal
|
||||
#define NG_CMDSTRLEN 15 /* Max command string (16 with null) */
|
||||
|
||||
struct ng_mesg {
|
||||
struct ng_msghdr {
|
||||
u_char version; /* Must equal NG_VERSION */
|
||||
u_char spare; /* Pad to 2 bytes */
|
||||
u_short arglen; /* Length of cmd/resp data */
|
||||
u_long flags; /* Message status flags */
|
||||
u_long token; /* Reply should have the same token */
|
||||
u_long typecookie; /* Node type understanding this message */
|
||||
u_long cmd; /* Command identifier */
|
||||
u_char cmdstr[NG_CMDSTRLEN+1]; /* Cmd string (for debug) */
|
||||
} header;
|
||||
char data[0]; /* Start of cmd/resp data */
|
||||
};
|
||||
|
||||
#define NG_VERSION 1 /* Netgraph version */
|
||||
#define NGF_ORIG 0x0000 /* Command */
|
||||
#define NGF_RESP 0x0001 /* Response */
|
||||
.Ed
|
||||
.Pp
|
||||
Control messages have the fixed header shown above, followed by a
|
||||
variable length data section which depends on the type cookie
|
||||
and the command. Each field is explained below:
|
||||
.Bl -tag -width xxx
|
||||
.It Dv version
|
||||
Indicates the version of netgraph itself. The current version is
|
||||
.Dv NG_VERSION .
|
||||
.It Dv arglen
|
||||
This is the length of any extra arguments, which begin at
|
||||
.Dv data .
|
||||
.It Dv flags
|
||||
Indicates whether this is a command or a response control message.
|
||||
.It Dv token
|
||||
The
|
||||
.Dv token
|
||||
is a means by which a sender can match a reply message to the
|
||||
corresponding command message; the reply always has the same token.
|
||||
.Pp
|
||||
.It Dv typecookie
|
||||
The corresponding node type's unique 32-bit value.
|
||||
If a node doesn't recognize the type cookie it must reject the message
|
||||
by returning
|
||||
.Er EINVAL .
|
||||
.Pp
|
||||
Each type should have an include file that defines the commands,
|
||||
argument format, and cookie for its own messages.
|
||||
The typecookie
|
||||
insures that the same header file was included by both sender and
|
||||
receiver; when an incompatible change in the header file is made,
|
||||
the typecookie
|
||||
.Em must
|
||||
be changed.
|
||||
The de facto method for generating unique type cookies is to take the
|
||||
seconds from the epoch at the time the header file is written
|
||||
(i.e., the output of
|
||||
.Dv "date -u +'%s'" ")."
|
||||
.Pp
|
||||
There is a predefined typecookie
|
||||
.Dv NGM_GENERIC_COOKIE
|
||||
for the ``generic'' node type, and
|
||||
a corresponding set of generic messages which all nodes understand.
|
||||
The handling of these messages is automatic.
|
||||
.It Dv command
|
||||
The identifier for the message command. This is type specific,
|
||||
and is defined in the same header file as the typecookie.
|
||||
.It Dv cmdstr
|
||||
Room for a short human readable version of ``command'' (for debugging
|
||||
purposes only).
|
||||
.El
|
||||
.Pp
|
||||
Some modules may choose to implement messages from more than one
|
||||
of the header files and thus recognize more than one type cookie.
|
||||
.Sh Generic Control Messages
|
||||
There are a number of standard predefined messages that will work
|
||||
for any node, as they are supported directly by the framework itself.
|
||||
These are defined in
|
||||
.Dv ng_message.h
|
||||
along with the basic layout of messages and other similar information.
|
||||
.Bl -tag -width xxx
|
||||
.It Dv NGM_CONNECT
|
||||
Connect to another node, using the supplied hook names on either end.
|
||||
.It Dv NGM_MKPEER
|
||||
Construct a node of the given type and then connect to it using the
|
||||
supplied hook names.
|
||||
.It Dv NGM_SHUTDOWN
|
||||
The target node should disconnect from all its neighbours and shut down.
|
||||
Persistent nodes such as those representing physical hardware
|
||||
might not dissappear from the node namespace, but only reset themselves.
|
||||
The node must disconnect all of its hooks.
|
||||
This may result in neighbors shutting themselves down, and possibly a
|
||||
cascading shutdown of the entire connected graph.
|
||||
.It Dv NGM_NAME
|
||||
Assign a name to a node. Nodes can exist without having a name, and this
|
||||
is the default for nodes created using the
|
||||
.Dv NGM_MKPEER
|
||||
method. Such nodes can only be addressed relatively or by their ID number.
|
||||
.It Dv NGM_RMHOOK
|
||||
Ask the node to break a hook connection to one of its neighbours.
|
||||
Both nodes will have their ``disconnect'' method invoked.
|
||||
Either node may elect to totally shut down as a result.
|
||||
.It Dv NGM_NODEINFO
|
||||
Asks the target node to describe itself. The four returned fields
|
||||
are the node name (if named), the node type, the node ID and the
|
||||
number of hooks attached. The ID is an internal number unique to that node.
|
||||
.It Dv NGM_LISTHOOKS
|
||||
This returns the information given by
|
||||
.Dv NGM_NODEINFO ,
|
||||
but in addition
|
||||
includes an array of fields describing each link, and the desription for
|
||||
the node at the far end of that link.
|
||||
.It Dv NGM_LISTNAMES
|
||||
This returns an array of node descriptions (as for
|
||||
.Dv NGM_NODEINFO ")"
|
||||
where each entry of the array describes a named node.
|
||||
All named nodes will be described.
|
||||
.It Dv NGM_LISTNODES
|
||||
This is the same as
|
||||
.Dv NGM_LISTNAMES
|
||||
except that all nodes are listed regardless of whether they have a name or not.
|
||||
.It Dv NGM_LISTTYPES
|
||||
This returns a list of all currently installed netgraph types.
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
The node may return a text formatted status message.
|
||||
The status information is determined entirely by the node type.
|
||||
It is the only "generic" message
|
||||
that requires any support within the node itself and as such the node may
|
||||
elect to not support this message. The text response must be less than
|
||||
.Dv NG_TEXTRESPONSE
|
||||
bytes in length (presently 1024). This can be used to return general
|
||||
status information in human readable form.
|
||||
.El
|
||||
.Sh Metadata
|
||||
Data moving through the
|
||||
.Nm
|
||||
system can be accompanied by meta-data that describes some
|
||||
aspect of that data. The form of the meta-data is a fixed header,
|
||||
which contains enough information for most uses, and can optionally
|
||||
be suplemented by trailing
|
||||
.Em option
|
||||
structures, which contain a
|
||||
.Em cookie
|
||||
(see the section on control messages), an identifier, a length and optional
|
||||
data. If a node does not recognize the cookie associated with an option,
|
||||
it should ignore that option.
|
||||
.Pp
|
||||
Meta data might include such things as priority, discard eligibility,
|
||||
or special processing requirements. It might also mark a packet for
|
||||
debug status, etc. The use of meta-data is still experimental.
|
||||
.Sh INITIALIZATION
|
||||
The base
|
||||
.Nm
|
||||
code may either be statically compiled
|
||||
into the kernel or else loaded dynamically as a KLD via
|
||||
.Xr kldload 8 .
|
||||
In the former case, include
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
options NETGRAPH
|
||||
|
||||
.Ed
|
||||
in your kernel configuration file. You may also include selected
|
||||
node types in the kernel compilation, for example:
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
options NETGRAPH
|
||||
options NETGRAPH_SOCKET
|
||||
options NETGRAPH_ECHO
|
||||
|
||||
.Ed
|
||||
.Pp
|
||||
Once the
|
||||
.Nm
|
||||
subsystem is loaded, individual node types may be loaded at any time
|
||||
as KLD modules via
|
||||
.Xr kldload 8 .
|
||||
Moreover,
|
||||
.Nm
|
||||
knows how to automatically do this; when a request to create a new
|
||||
node of unknown type
|
||||
.Em type
|
||||
is made,
|
||||
.Nm
|
||||
will attempt to load the KLD module
|
||||
.Dv ng_type.ko .
|
||||
.Pp
|
||||
Types can also be installed at boot time, as certain device drivers
|
||||
may want to export each instance of the device as a netgraph node.
|
||||
.Pp
|
||||
In general, new types can be installed at any time from within the
|
||||
kernel by calling
|
||||
.Dv ng_newtype() ,
|
||||
supplying a pointer to the type's
|
||||
.Dv struct ng_type
|
||||
structure.
|
||||
.Pp
|
||||
The
|
||||
.Dv "NETGRAPH_INIT()"
|
||||
macro automates this process by using a linker set.
|
||||
.Sh EXISTING NODE TYPES
|
||||
Several node types currently exist. Each is fully documented
|
||||
in its own man page:
|
||||
.Bl -tag -width xxx
|
||||
.It SOCKET
|
||||
The socket type implements two new sockets in the new protocol domain
|
||||
.Dv PF_NETGRAPH .
|
||||
The new sockets protocols are
|
||||
.Dv NG_DATA
|
||||
and
|
||||
.Dv NG_CONTROL ,
|
||||
both of type
|
||||
.Dv SOCK_DGRAM .
|
||||
Typically one of each is associated with a socket node.
|
||||
When both sockets have closed, the node will shut down. The
|
||||
.Dv NG_DATA
|
||||
socket is used for sending and receiving data, while the
|
||||
.Dv NG_CONTROL
|
||||
socket is used for sending and receiving control messages.
|
||||
Data and control messages are passed using the
|
||||
.Xr sendto 2
|
||||
and
|
||||
.Xr recvfrom 2
|
||||
calls, using a
|
||||
.Dv struct sockaddr_ng
|
||||
socket address.
|
||||
.Pp
|
||||
.It HOLE
|
||||
Responds only to generic messages and is a ``black hole'' for data,
|
||||
Useful for testing. Always accepts new hooks.
|
||||
.Pp
|
||||
.It ECHO
|
||||
Responds only to generic messages and always echoes data back through the
|
||||
hook from which it arrived. Returns any non generic messages as their
|
||||
own response. Useful for testing. Always accepts new hooks.
|
||||
.Pp
|
||||
.It TEE
|
||||
This node is useful for ``snooping.'' It has 4 hooks:
|
||||
.Dv left ,
|
||||
.Dv right ,
|
||||
.Dv left2right ,
|
||||
and
|
||||
.Dv right2left .
|
||||
Data entering from the right is passed to the left and duplicated on
|
||||
.Dv right2left,
|
||||
and data entering from the left is passed to the right and
|
||||
duplicated on
|
||||
.Dv left2right .
|
||||
Data entering from
|
||||
.Dv left2right
|
||||
is sent to the right and data from
|
||||
.Dv right2left
|
||||
to left.
|
||||
.Pp
|
||||
.It RFC1490 MUX
|
||||
Encapsulates/de-encapsulates frames encoded according to RFC 1490.
|
||||
Has a hook for the encapsulated packets (``downstream'') and one hook
|
||||
for each protocol (i.e., IP, PPP, etc.).
|
||||
.Pp
|
||||
.It FRAME RELAY MUX
|
||||
Encapsulates/de-encapsulates Frame Relay frames.
|
||||
Has a hook for the encapsulated packets (``downstream'') and one hook
|
||||
for each DLCI.
|
||||
.Pp
|
||||
.It FRAME RELAY LMI
|
||||
Automatically handles frame relay
|
||||
``LMI'' (link management interface) operations and packets.
|
||||
Automatically probes and detects whch of several LMI standards
|
||||
is in use at the exchange.
|
||||
.Pp
|
||||
.It TTY
|
||||
This node is also a line discipline. It simply converts between mbuf
|
||||
frames and sequential serial data, allowing a tty to appear as a netgraph
|
||||
node. It has a programmable ``hotkey'' character.
|
||||
.Pp
|
||||
.It ASYNC
|
||||
This node encapsulates and de-encapsulates asynchronous frames
|
||||
according to RFC 1662. This is used in conjunction with the TTY node
|
||||
type for supporting PPP links over asynchronous serial lines.
|
||||
.Pp
|
||||
.It INTERFACE
|
||||
This node is also a system networking interface. It has hooks representing
|
||||
each protocol family (IP, AppleTalk, IPX, etc.) and appears in the output of
|
||||
.Xr ifconfig 8 .
|
||||
The interfaces are named
|
||||
.Em ng0 ,
|
||||
.Em ng1 ,
|
||||
etc.
|
||||
.El
|
||||
.Sh NOTES
|
||||
Whether a named node exists can be checked by trying to send a control mesage
|
||||
to it (e.g.,
|
||||
.Dv NGM_NODEINFO
|
||||
).
|
||||
If it does not exist,
|
||||
.Er ENOENT
|
||||
will be returned.
|
||||
.Pp
|
||||
All data messages are mbuf chains with the M_PKTHDR flag set.
|
||||
.Pp
|
||||
Nodes are responsible for freeing what they allocate.
|
||||
There are three exceptions:
|
||||
.Bl -tag -width xxxx
|
||||
.It 1
|
||||
Mbufs sent across a data link are never to be freed by the sender.
|
||||
.It 2
|
||||
Any meta-data information travelling with the data has the same restriction.
|
||||
It might be freed by any node the data passes through, and a
|
||||
.Dv NULL
|
||||
passed onwards, but the caller will never free it.
|
||||
Two macros
|
||||
.Dv "NG_FREE_META(meta)"
|
||||
and
|
||||
.Dv "NG_FREE_DATA(m, meta)"
|
||||
should be used if possible to free data and meta data (see
|
||||
.Dv netgraph.h ")."
|
||||
.It 3
|
||||
Messages sent using
|
||||
.Dv ng_send_message()
|
||||
are freed by the callee. As in the case above, the addresses
|
||||
associated with the message are freed by whatever allocated them so the
|
||||
recipient should copy them if it wants to keep that information.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width xxxxx -compact
|
||||
.It Pa /sys/netgraph/netgraph.h
|
||||
Definitions for use soley within the kernel by
|
||||
.Nm
|
||||
nodes.
|
||||
.It Pa /sys/netgraph/ng_message.h
|
||||
Definitions needed by any file that needs to deal with
|
||||
.Nm
|
||||
messages.
|
||||
.It Pa /sys/netgraph/ng_socket.h
|
||||
Definitions needed to use
|
||||
.Nm
|
||||
socket type nodes.
|
||||
.It Pa /sys/netgraph/ng_{type}.h
|
||||
Definitions needed to use
|
||||
.Nm
|
||||
{type}
|
||||
nodes, including the type cookie definition.
|
||||
.It Pa /modules/netgraph.ko
|
||||
Netgraph subsystem loadable KLD module.
|
||||
.It Pa /modules/ng_{type}.ko
|
||||
Loadable KLD module for node type {type}.
|
||||
.El
|
||||
.Sh USER MODE SUPPORT
|
||||
There is a library for supporting user-mode programs that wish
|
||||
to interact with the netgraph system. See
|
||||
.Xr netgraph 3
|
||||
for details.
|
||||
.Pp
|
||||
Two user-mode support programs,
|
||||
.Xr ngctl 8
|
||||
and
|
||||
.Xr nghook 8 ,
|
||||
are available to assist manual configuration and debugging.
|
||||
.Pp
|
||||
There are a few useful techniques for debugging new node types.
|
||||
First, implementing new node types in user-mode first
|
||||
makes debugging easier.
|
||||
The
|
||||
.Em tee
|
||||
node type is also useful for debugging, especially in conjunction with
|
||||
.Xr ngctl 8
|
||||
and
|
||||
.Xr nghook 8 .
|
||||
.Sh SEE ALSO
|
||||
.Xr socket 2 ,
|
||||
.Xr netgraph 3 ,
|
||||
.Xr ngctl 8 ,
|
||||
.Xr nghook 8 ,
|
||||
.Xr ng_async 8 .
|
||||
.Xr ng_cisco 8 .
|
||||
.Xr ng_echo 8 .
|
||||
.Xr ng_frame_relay 8 .
|
||||
.Xr ng_hole 8 .
|
||||
.Xr ng_iface 8 .
|
||||
.Xr ng_lmi 8 .
|
||||
.Xr ng_rfc1490 8 .
|
||||
.Xr ng_socket 8 .
|
||||
.Xr ng_tee 8 .
|
||||
.Xr ng_tty 8 .
|
||||
.Xr ng_UI 8 .
|
||||
.Xr ng_{type} 8 .
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
system was designed and first implemented at Whistle Communications, Inc.
|
||||
in a version FreeBSD 2.2 customized for the Whistle InterJet.
|
||||
.Sh AUTHORS
|
||||
Julian Elischer <julian@whistle.com>, with contributions by
|
||||
Archie Cobbs <archie@whistle.com>.
|
86
share/man/man4/ng_UI.4
Normal file
86
share/man/man4/ng_UI.4
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_UI.8,v 1.4 1999/01/25 02:37:56 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_UI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_UI
|
||||
.Nd UI netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_UI.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm UI
|
||||
node type has two hooks,
|
||||
.Dv upstream
|
||||
and
|
||||
.Dv downstream .
|
||||
Packets received on
|
||||
.Dv downstream
|
||||
must have 0x03 (indicating unnumbered information) as their first byte;
|
||||
if not the packet is dropped. This byte is then stripped and the
|
||||
remainder of the packet sent out on
|
||||
.Dv upstream .
|
||||
.Pp
|
||||
Conversely, packets received on
|
||||
.Dv upstream
|
||||
will have a 0x03 byte prepended to them before being forwarded out on the
|
||||
.Dv downstream
|
||||
hook.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
Downstream connection. Packets on this side of the node have a 0x03 as
|
||||
their first byte.
|
||||
.It Dv upstream
|
||||
Upstream connection. Packets on this side of the node have the
|
||||
initial 0x03 byte stripped off.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when both hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elischer <julian@whistle.com>
|
160
share/man/man4/ng_async.4
Normal file
160
share/man/man4/ng_async.4
Normal file
@ -0,0 +1,160 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_async.8,v 1.6 1999/01/25 23:46:25 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ASYNC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_async
|
||||
.Nd asynchronous framing netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_async.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm async
|
||||
node type performs conversion between synchronous frames and
|
||||
asynchronous frames, as defined for the PPP protocol in RFC 1662.
|
||||
Asynchronous framing uses flag bytes and octet-stuffing
|
||||
to simulate a frame oriented connection over an octet-oriented
|
||||
asynchronous line.
|
||||
.Pp
|
||||
The node trasmits and receives asynchronous data on the
|
||||
.Dv async
|
||||
hook. Incoming data mbuf boundaries are ignored, while
|
||||
outgoing data is sent as a complete frame at a time.
|
||||
.Pp
|
||||
There are two synchronous hooks,
|
||||
.Dv sync
|
||||
and
|
||||
.Dv sync2 .
|
||||
For both hooks, received packets are encoded as asynchronous frames
|
||||
and sent out on
|
||||
.Dv async .
|
||||
Hook
|
||||
.Dv sync2
|
||||
differs from
|
||||
.Dv sync
|
||||
only in that any configured address and control field compression
|
||||
and/or control character escaping is disabled when the frame is encoded.
|
||||
This is useful for transmitting PPP LCP packets, which are always sent
|
||||
this way.
|
||||
.Pp
|
||||
This node supports ``flag sharing'' for packets transmitted on
|
||||
.Dv async .
|
||||
This is an optimization where the trailing flag byte
|
||||
of one frame is shared with the opening flag byte of the next.
|
||||
Flag sharing between frames is disabled after one second of transmit
|
||||
idle time.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv async
|
||||
Asynchronous connection.
|
||||
Typically this hook would be connected to a
|
||||
.Xr ng_tty 8
|
||||
node, which handles transmission of serial data over a tty device.
|
||||
.It Dv sync
|
||||
Synchronous connection. This hook sends and receives synchronous frames.
|
||||
For PPP, these frames contain no address, control, or checksum fields;
|
||||
each frame begins with the PPP protocol number. Typically this hook would
|
||||
be connected to the
|
||||
.Dv downstream
|
||||
hook of a
|
||||
.Xr ng_ppp 8
|
||||
type node.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_ASYNC_CMD_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_async_stat"
|
||||
containing node statistics for packet, octet, and error counts.
|
||||
.It Dv NGM_ASYNC_CMD_CLR_STATS
|
||||
Clears the node statistics.
|
||||
.It Dv NGM_ASYNC_CMD_SET_CONFIG
|
||||
Sets the node configuration, which is described by a
|
||||
.Dv "struct ng_async_cfg" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_async_cfg {
|
||||
u_char enabled; /* Turn encoding on/off */
|
||||
u_char acfcomp; /* Address/control field comp. */
|
||||
u_int16_t amru; /* Max receive async frame len */
|
||||
u_int16_t smru; /* Max receive sync frame len */
|
||||
u_int32_t accm; /* ACCM encoding */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dv enabled
|
||||
field enables or disables all encoding/decoding functions (default disabled).
|
||||
When disabled, the node operates in simple ``pass through'' mode. Setting
|
||||
.Dv acfcomp
|
||||
enables address and control field compression on transmission (for packets
|
||||
received on the
|
||||
.Dv sync
|
||||
hook only; default off).
|
||||
.Dv amru
|
||||
and
|
||||
.Dv smru
|
||||
are the asynchronous and synchronous MRU (maximum receive unit) values,
|
||||
respectively. These both default to 1600; note that the async MRU
|
||||
applies to the incoming frame length after asynchronous decoding.
|
||||
Finally,
|
||||
.Dv accm
|
||||
is the asynchronous character control map, which controls the escaping
|
||||
of characters 0x00 thorough 0x1f (default 0xffffffff).
|
||||
.It Dv NGM_ASYNC_CMD_GET_CONFIG
|
||||
This command returns the current configuration structure.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_tty 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in HDLC-link Framing"
|
||||
.%O RFC 1662
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
159
share/man/man4/ng_cisco.4
Normal file
159
share/man/man4/ng_cisco.4
Normal file
@ -0,0 +1,159 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_cisco.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_CISCO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_cisco
|
||||
.Nd Cisco HDLC protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_cisco.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm cisco
|
||||
node type performs encapsulation and de-encapsulation of packets
|
||||
using the Cisco HDLC protocol. This is a fairly simple
|
||||
protocol for the transmission of packets across
|
||||
high speed synchronous lines. Each packet is prepended with
|
||||
an Ethertype, indicating the protocol. There is also a
|
||||
``keep alive'' and an ``inquire'' capability.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should connect to the synchronous line. On the other side
|
||||
of the node are the
|
||||
.Dv inet ,
|
||||
.Dv atalk ,
|
||||
and
|
||||
.Dv ipx
|
||||
hooks, which transmit and receive raw IP, AppleTalk, and IPX packets,
|
||||
respectively. Typically these hooks would connect to the corresponding
|
||||
hooks on an
|
||||
.Xr ng_iface 8
|
||||
type node.
|
||||
.Sh IP Configuration
|
||||
In order to function properly for IP traffic, the node must be informed
|
||||
of the local IP address and netmask setting. This is because the protocol
|
||||
includes an ``inquire'' packet which we must be prepared to answer.
|
||||
There are two ways to acomplish this, manually and automatically.
|
||||
.Pp
|
||||
Whenever such an inquire packet is received, the node sends a
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
control message to the peer node connected to the
|
||||
.Dv inet
|
||||
hook (if any).
|
||||
If the peer responds, then that response is used. This is the automatic method.
|
||||
.Pp
|
||||
If the peer does not respond, the node falls back on its cached value
|
||||
for the IP address and netmask. This cached value can be set at any time
|
||||
with a
|
||||
.Dv NGM_CISCO_SET_IPADDR
|
||||
message, and this is the manual method.
|
||||
.Pp
|
||||
If the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node, as is usually the case, then configuration is automatic as the
|
||||
.Xr ng_iface 8
|
||||
understands the
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazio
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv inet
|
||||
IP hook.
|
||||
.It Dv atalk
|
||||
AppleTalk hook.
|
||||
.It Dv ipx
|
||||
IPX hook
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_CISCO_SET_IPADDR
|
||||
This command takes an array of two
|
||||
.Dv "struct in_addr"
|
||||
arguments. The first is the IP address of the corresponding interface
|
||||
and the second is the netmask.
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This command returns the IP configuration in the same format used by
|
||||
.Dv NGM_CISCO_SET_IPADDR .
|
||||
This command is also
|
||||
.Em sent
|
||||
by this node type to the
|
||||
.Dv inet
|
||||
peer whenever an IP address inquiry packet is received.
|
||||
.It Dv NGM_CISCO_GET_STATUS
|
||||
Returns a
|
||||
.Dv "struct ngciscostat" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ngciscostat {
|
||||
u_int32_t seq_retries; /* # unack'd retries */
|
||||
u_int32_t keepalive_period; /* in seconds */
|
||||
};
|
||||
.Ed
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of the functionality has been implemented. For example,
|
||||
the node does not support querying the remote end for its IP address
|
||||
and netmask.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A D. Perkins
|
||||
.%T "Requirements for an Internet Standard Point-to-Point Protocol"
|
||||
.%O RFC 1547
|
||||
.Re
|
||||
.Sh LEGAL
|
||||
Cisco is a trademark of Cisco Systems, Inc.
|
||||
.Sh AUTHORS
|
||||
Julian Elisher <julian@whistle.com>,
|
||||
Archie Cobbs <archie@whistle.com>
|
67
share/man/man4/ng_echo.4
Normal file
67
share/man/man4/ng_echo.4
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_echo.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ECHO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_echo
|
||||
.Nd netgraph echo node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_echo.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm echo
|
||||
node type reflects all data and control messages back to the sender.
|
||||
This node type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Echo
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Any other control messages are reflected back to the sender.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_hole 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
93
share/man/man4/ng_frame_relay.4
Normal file
93
share/man/man4/ng_frame_relay.4
Normal file
@ -0,0 +1,93 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_frame_relay.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_FRAME_RELAY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_frame_relay
|
||||
.Nd Frame relay netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_frame_relay.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type performs encapsulation, de-encapsulation, and multiplexing
|
||||
of packets using the frame relay protocol. It supports up to 1024 DLCI's.
|
||||
The LMI protocol is handled by a separate node type (see
|
||||
.Xr ng_lmi 8 ).
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should be connected to the synchronous line, i.e., the switch.
|
||||
Then hooks
|
||||
.Dv dlci0 ,
|
||||
.Dv dlci1 ,
|
||||
through
|
||||
.Dv dlci1023
|
||||
are available to connect to each of the DLCI channels.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv dlciX
|
||||
Here X is a decimal number from 0 to 1023. This hook corresponds
|
||||
to the DLCI X frame relay virtual channel.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Technically, frames on DLCI X should not be transmitted to the switch
|
||||
until the LMI protocol entity on both ends has configured DLCI X as active.
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type ignores this restriction, and will always pass data received
|
||||
on a DLCI hook to
|
||||
.Dv downstream .
|
||||
Instead, it should query the LMI node first.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_lmi 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
67
share/man/man4/ng_hole.4
Normal file
67
share/man/man4/ng_hole.4
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_hole.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_HOLE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_hole
|
||||
.Nd netgraph discard node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_hole.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm hole
|
||||
node type silently discards all data and control messages it receives.
|
||||
This type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Hole
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Other control messages are silently discarded.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_echo 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
126
share/man/man4/ng_iface.4
Normal file
126
share/man/man4/ng_iface.4
Normal file
@ -0,0 +1,126 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_iface.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_IFACE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_iface
|
||||
.Nd interface netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_iface.h>
|
||||
.Sh DESCRIPTION
|
||||
An
|
||||
.Nm iface
|
||||
node is both a netgraph node and a system networking interface. When an
|
||||
.Nm iface
|
||||
node is created, a new point-to-point interface appears which is accessible via
|
||||
.Xr ifconfig 8 .
|
||||
The new interfaces are named
|
||||
.Dv ng0 ,
|
||||
.Dv ng1 ,
|
||||
etc. The node is assigned the same name as its interface, unless the name
|
||||
already exists, in which case the node remains unnamed.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes have a single hook corresponding to each supported protocol.
|
||||
Packets transmitted via the interface flow out the corresponding
|
||||
protocol-specific hook.
|
||||
Similarly, packets received on a hook appear on the interface as
|
||||
packets received in the corresponding protocol.
|
||||
.Pp
|
||||
The currently supported protocols are IP, IPX, AppleTalk, and NS.
|
||||
In the KLD module, only support for IP is compiled in by default.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes support the Berkeley Packet Filter (BPF).
|
||||
In the KLD module, this support is disabled by default.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv inet
|
||||
Transmission and reception of IP packets.
|
||||
.It Dv ipx
|
||||
Transmission and reception of IPX packets.
|
||||
.It Dv atalk
|
||||
Transmission and reception of AppleTalk packets.
|
||||
.It Dv ns
|
||||
Transmission and reception of NS packets.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_IFACE_GET_IFNAME
|
||||
Returns the name of the interface corresponding to this node in a
|
||||
.Dv "struct ng_iface_ifname" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_iface_ifname {
|
||||
char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1];
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_IFACE_GET_IFADDRS
|
||||
Returns the list of addresses associated with this interface.
|
||||
The list is returned in the same format as the
|
||||
.Dv SIOCGIFCONF
|
||||
ioctl().
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This message is defined by the
|
||||
.Xr ng_cisco 8
|
||||
node type; see
|
||||
.Xr ng_cisco 8
|
||||
for a description.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
Because it is currenly not possible to remove a system networking
|
||||
interface in FreeBSD,
|
||||
.Nm iface
|
||||
nodes are
|
||||
.Em persistent.
|
||||
That is, once created they are never destroyed.
|
||||
The receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message disconnects all hooks but does not remove the node.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr bpf 4 ,
|
||||
.Xr ng_cisco 8 ,
|
||||
.Xr ng_rfc1490 8 ,
|
||||
.Xr ngctl 8 ,
|
||||
.Xr ifconfig 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
130
share/man/man4/ng_lmi.4
Normal file
130
share/man/man4/ng_lmi.4
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
164
share/man/man4/ng_ppp.4
Normal file
164
share/man/man4/ng_ppp.4
Normal file
@ -0,0 +1,164 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_ppp.8,v 1.3 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_PPP 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_ppp
|
||||
.Nd PPP protocol multiplexor negraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_ppp.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm ppp
|
||||
node type performs multiplexing for the PPP protocol. On the
|
||||
.Dv downstream
|
||||
hook it transmits and receives full PPP frames, which include the
|
||||
protocol field, but no address, control or checksum fields.
|
||||
On outgoing frames, when protocol compression has been enabled and
|
||||
the protocol number is suitable for compression, the protocol field will
|
||||
be compressed (i.e., sent as one byte instead of two).
|
||||
Either compressed or uncompressed protocol fields are accepted
|
||||
on incoming frames.
|
||||
.Pp
|
||||
For each 16-bit PPP procotol number there is a corresponding ``upstream'' hook.
|
||||
Packets on these hooks contain no PPP protocol header.
|
||||
The node simply multiplexes between the
|
||||
.Dv downstream
|
||||
hook and all of the upstream hooks by adding or subtracting the
|
||||
PPP protocol field, depending on the direction of flow.
|
||||
.Pp
|
||||
When a frame is received on
|
||||
.Dv downstream ,
|
||||
if the corresponding protocol hook is
|
||||
not connected, the packet is forwarded to a special upstream hook called
|
||||
.Dv bypass .
|
||||
This hook is a catch-all for any incoming frames not destined
|
||||
for another already connected hook. Packets sent out on the
|
||||
.Dv bypass
|
||||
hook always have the PPP protcol header prepended as the first
|
||||
two bytes (even if the
|
||||
original incoming frame was protocol compressed to one byte).
|
||||
.Pp
|
||||
Any frames received on the
|
||||
.Dv bypass
|
||||
hook are forwarded to
|
||||
.Dv downstream
|
||||
without modification.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv downstream
|
||||
Connection to the PPP link layer.
|
||||
.It Dv bypass
|
||||
Frames that do not correspond to a connected protocol hook;
|
||||
the PPP protocol header is included.
|
||||
.It Dv 0xNNNN
|
||||
Conection to the PPP protocol with 16-bit hex value
|
||||
.Dv NNNN .
|
||||
No PPP protocol header is included.
|
||||
.El
|
||||
.Pp
|
||||
For convenience, the
|
||||
.Nm
|
||||
node type defines several hook name aliases for common PPP protocols:
|
||||
.Pp
|
||||
.Bl -tag -width abcdefgh -compact -offset 4n
|
||||
.It Dv lcp
|
||||
LCP protocol data (0xc021)
|
||||
.It Dv ipcp
|
||||
IPCP protocol data (0x8021)
|
||||
.It Dv atcp
|
||||
ATCP protocol data (0x8029)
|
||||
.It Dv ccp
|
||||
CCP protocol data (0x80fd)
|
||||
.It Dv ecp
|
||||
ECP protocol data (0x8053)
|
||||
.It Dv ip
|
||||
IP protocol data (0x0021)
|
||||
.It Dv vjcomp
|
||||
Van Jacobsen compressed TCP data (0x002d)
|
||||
.It Dv vjuncomp
|
||||
Van Jacobsen uncompressed TCP data (0x002f)
|
||||
.It Dv mp
|
||||
Multi-link protocol data (0x003d)
|
||||
.It Dv compd
|
||||
Compressed protocol data (0x00fd)
|
||||
.It Dv cryptd
|
||||
Encrypted protocol data (0x0053)
|
||||
.It Dv pap
|
||||
PAP authentication protocol data (0xc023)
|
||||
.It Dv chap
|
||||
CHAP authentication protocol data (0xc223)
|
||||
.It Dv lqr
|
||||
LQR protocol data (0xc025)
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_PPP_SET_PROTOCOMP
|
||||
This command takes a single integer as argument and enables or disables
|
||||
protocol field compression as the value is zero or non-zero.
|
||||
Note that only protocols with high order byte equal to
|
||||
.Dv 0x00
|
||||
are compressible.
|
||||
.It Dv NGM_PPP_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_ppp_stat"
|
||||
containing various node statistics.
|
||||
.It Dv NGM_PPP_CLR_STATS
|
||||
Clears the node statistics. Statistics are also cleared whenever the
|
||||
.Dv downstream
|
||||
hook is reconnected.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ng_vjc 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "The Point-to-Point Protocol (PPP)"
|
||||
.%O RFC 1661
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
130
share/man/man4/ng_pppoe.4
Normal file
130
share/man/man4/ng_pppoe.4
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
109
share/man/man4/ng_rfc1490.4
Normal file
109
share/man/man4/ng_rfc1490.4
Normal file
@ -0,0 +1,109 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_rfc1490.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_RFC1490 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_rfc1490
|
||||
.Nd RFC 1490 netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_rfc1490.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm rfc1490
|
||||
node type performs protocol encapsulation, de-encapsulation, and
|
||||
multiplexing according to RFC 1490 (which has since been updated by RFC 2427).
|
||||
This particular type of encapsulation is often used on top of frame relay
|
||||
DLCI channels.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook is used to transmit and receive encapsulated frames. On the other
|
||||
side of the node, the
|
||||
.Dv inet
|
||||
and
|
||||
.Dv ppp
|
||||
hooks are used to transmit and receive raw IP frames and PPP frames,
|
||||
respectively. PPP frames are transmitted and received according to
|
||||
RFC 1973; in particular, frames appearing on the
|
||||
.Dv ppp
|
||||
hook begin with the PPP protocol number.
|
||||
.Pp
|
||||
Typically the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazum
|
||||
.It Dv downstream
|
||||
Connects to the RFC 1490 peer entity.
|
||||
.It Dv inet
|
||||
Transmits and receives raw IP frames.
|
||||
.It Dv ppp
|
||||
Transmits and receives PPP frames.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type only supports the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of RFC 1490 is implemented.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A C. Brown, A. Malis
|
||||
.%T "Multiprotocol Interconnect over Frame Relay"
|
||||
.%O RFC 2427
|
||||
.Re
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in Frame Relay"
|
||||
.%O RFC 1973
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
127
share/man/man4/ng_socket.4
Normal file
127
share/man/man4/ng_socket.4
Normal file
@ -0,0 +1,127 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_SOCKET 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_socket
|
||||
.Nd netgraph socket node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_socket.h>
|
||||
.Sh DESCRIPTION
|
||||
A
|
||||
.Nm socket
|
||||
node is both a BSD socket and a netgraph node. The
|
||||
.Nm socket
|
||||
node type allows user-mode processes to participate in the kernel
|
||||
.Xr netgraph 4
|
||||
networking subsystem using the BSD socket interface.
|
||||
.Pp
|
||||
A new
|
||||
.Nm socket
|
||||
node is created by creating a new socket of type
|
||||
.Dv NG_CONTROL
|
||||
in the protocol family
|
||||
.Dv PF_NETGRAPH ,
|
||||
using the
|
||||
.Xr socket 2
|
||||
system call.
|
||||
Any control messages received by the node are received using
|
||||
.Xr recvfrom 2 ;
|
||||
the socket address argument is a
|
||||
.Dv "struct sockaddr_ng"
|
||||
containing the sender's netgraph address. Conversely, control messages
|
||||
can be sent to any node by calling
|
||||
.Xr sendto 2 ,
|
||||
supplying the recipient's address in a
|
||||
.Dv "struct sockaddr_ng" .
|
||||
The
|
||||
.Xr bind 2
|
||||
system call may be used to assign a global netgraph name to the node.
|
||||
.Pp
|
||||
To transmit and receive netgraph data packets, a
|
||||
.Dv NG_DATA
|
||||
socket must also be created using
|
||||
.Xr socket 2
|
||||
and associated with a
|
||||
.Nm socket
|
||||
node.
|
||||
.Dv NG_DATA sockets do not automatically
|
||||
have nodes associated with them; they are bound to a specific node via the
|
||||
.Xr connect 2
|
||||
system call. The address argument is the netgraph address of the
|
||||
.Nm socket
|
||||
node already created. Once a data socket is associated with a node,
|
||||
any data packets received by the node are read using
|
||||
.Xr recvfrom 2
|
||||
and any packets to be sent out from the node are written using
|
||||
.Xr sendto 2 .
|
||||
In the case of data sockets, the
|
||||
.Dv "struct sockaddr_ng"
|
||||
contains the name of the
|
||||
.Em hook
|
||||
on which the data was received or should be sent.
|
||||
.Pp
|
||||
There is a user library that simplifies using netgraph sockets; see
|
||||
.Xr netgraph 3 .
|
||||
.Sh HOOKS
|
||||
This node type supports hooks with arbitrary names (as long as
|
||||
they are unique) and always accepts hook connection requests.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node type shuts down and disappears when both the associated
|
||||
.Dv NG_CONTROL
|
||||
and
|
||||
.Dv NG_DATA
|
||||
sockets have been closed, or a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is received. In the latter case, attempts to write
|
||||
to the still-open sockets will return
|
||||
.Er ENOTCONN .
|
||||
.Sh BUGS
|
||||
It is not possible to reject the connection of a hook, though any
|
||||
data received on that hook can certainly be ignored.
|
||||
.Sh SEE ALSO
|
||||
.Xr socket 2 ,
|
||||
.Xr netgraph 3 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
110
share/man/man4/ng_tee.4
Normal file
110
share/man/man4/ng_tee.4
Normal file
@ -0,0 +1,110 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tee.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TEE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tee
|
||||
.Nd netgraph ``tee'' node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_tee.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tee
|
||||
node type has a purpose similar to the
|
||||
.Xr tee 1
|
||||
command.
|
||||
.Nm Tee
|
||||
nodes are useful for debugging or ``snooping'' on a connection
|
||||
between two netgraph nodes.
|
||||
.Nm Tee
|
||||
nodes have four hooks,
|
||||
.Dv right ,
|
||||
.Dv left ,
|
||||
.Dv right2left ,
|
||||
and
|
||||
.Dv left2right .
|
||||
All data received on
|
||||
.Dv right
|
||||
is sent unmodified to
|
||||
.Em both
|
||||
hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right2left .
|
||||
Similarly, all data received on
|
||||
.Dv left
|
||||
is sent unmodified to both
|
||||
.Dv right
|
||||
and
|
||||
.Dv left2right .
|
||||
.Pp
|
||||
Packets may also be received on
|
||||
.Dv right2left
|
||||
and
|
||||
.Dv left2right ;
|
||||
if so, they are forwarded unchanged out hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right ,
|
||||
respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbarfoo
|
||||
.It Dv right
|
||||
The connection to the node on the right.
|
||||
.It Dv left
|
||||
The connection to the node on the left.
|
||||
.It Dv right2left
|
||||
Tap for right to left traffic.
|
||||
.It Dv left2right
|
||||
Tap for left to right traffic.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr tee 1 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
141
share/man/man4/ng_tty.4
Normal file
141
share/man/man4/ng_tty.4
Normal file
@ -0,0 +1,141 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TTY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tty
|
||||
.Nd netgraph node type that is also a line discipline
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_tty.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tty
|
||||
node type is both a netgraph node type and a line discipline.
|
||||
A new node is created when the corresponding line discipline is
|
||||
registered on a tty device (see
|
||||
.Xr tty 4 ")."
|
||||
.Pp
|
||||
The node has a single hook called
|
||||
.Dv hook .
|
||||
Incoming bytes received on the tty device are sent out on this hook,
|
||||
and frames received on
|
||||
.Dv hook
|
||||
are transmitted out on the tty device.
|
||||
No modification to the data is performed in either direction.
|
||||
While the line discipline is installed on a tty, the normal
|
||||
read and write operations are unavailable, returning
|
||||
.Er EIO .
|
||||
.Pp
|
||||
The node supports an optional ``hot character.'' If set to non-zero, incoming
|
||||
data from the tty device is queued until this character is seen.
|
||||
This avoids sending lots of mbufs containing a small number of bytes,
|
||||
but introduces potentially infinite latency.
|
||||
The default hot character is 0x7e, consistent with
|
||||
.Dv hook
|
||||
being connected to a
|
||||
.Xr ng_async 8
|
||||
type node. The hot character has no effect on the transmission of data.
|
||||
.Pp
|
||||
The node will attempt to give itself the same netgraph name as the name
|
||||
of the tty device.
|
||||
In any case, information about the node is available via the netgraph
|
||||
.Xr ioctl 2
|
||||
command
|
||||
.Dv NGIOCGINFO .
|
||||
This command returns a
|
||||
.Dv "struct nodeinfo"
|
||||
similar to the
|
||||
.Dv NGM_NODEINFO
|
||||
netgraph control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv hook
|
||||
.Xr tty 4
|
||||
serial data contained in
|
||||
.Dv mbuf
|
||||
structures, with arbitrary inter-frame boundaries.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_TTY_SET_HOTCHAR
|
||||
This command takes an integer argument and sets the hot character
|
||||
from the lower 8 bits. A hot character of zero disables queueing,
|
||||
so that all received data is forwarded immediately.
|
||||
.It Dv NGM_TTY_GET_HOTCHAR
|
||||
Returns an integer containing the current hot character in the lower
|
||||
eight bits.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down when the corresponding device is closed
|
||||
(or the line discipline is uninstalled on the device).
|
||||
The
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is not valid, and always returns the error
|
||||
.Er EOPNOTSUPP .
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm tty
|
||||
type registers its line discipline when the type is installed,
|
||||
where it is dynamically assigned an integer index.
|
||||
Unfortunately, there's no way to know what this integer is
|
||||
except by reading the output of
|
||||
.Xr dmesg 8 .
|
||||
The fix for this is to have line disciplines identified by
|
||||
unique ASCII strings instead of fixed integer constants,
|
||||
or else to assign one of those constants to
|
||||
.Nm ng_tty .
|
||||
.Pp
|
||||
The serial driver code also has a notion of a ``hot character.''
|
||||
Unfortunately, this value is statically defined in terms of the
|
||||
line discipline and cannot be changed.
|
||||
Therefore, if a hot character other than 0x7e (the default) is set for the
|
||||
.Nm tty
|
||||
node, the node has no way to convey this information to the
|
||||
serial driver, and sub-optimal performance may result.
|
||||
.Sh SEE ALSO
|
||||
.Xr ioctl 2 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
188
share/man/man4/ng_vjc.4
Normal file
188
share/man/man4/ng_vjc.4
Normal file
@ -0,0 +1,188 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_vjc.8,v 1.4 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_VJC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_vjc
|
||||
.Nd Van Jacobsen compression netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <net/slcompress.h>
|
||||
.Fd #include <netgraph/ng_vjc.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm vjc
|
||||
node type performs Van Jacobsen compresion, which is used
|
||||
over PPP, SLIP, and other point-to-point IP connections to
|
||||
compress TCP packet headers. The
|
||||
.Dv ip
|
||||
hook represents the uncompressed side of the node, while the
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes represent the compressed side of the node. Packets received on the
|
||||
.Dv ip
|
||||
will be compressed or passed through as appropriate. Packets received
|
||||
on the other three hooks will be uncompressed as appropriate.
|
||||
.Pp
|
||||
Van Jacobsen compression only applies to TCP packets.
|
||||
Only ``normal'' (i.e., common case) TCP packets are actually compressed.
|
||||
These are output on the
|
||||
.Dv vjcomp
|
||||
hook. Other TCP packets are run through the state machine but not
|
||||
compressed; these appear on the
|
||||
.Dv vjuncomp
|
||||
hook.
|
||||
Other non-TCP IP packets are forwarded unchanged to
|
||||
.Dv vjip .
|
||||
.Pp
|
||||
When connecting to a
|
||||
.Xr ng_ppp 8
|
||||
node, the
|
||||
.Dv vjuncomp ,
|
||||
.Dv vjcomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes should be connected to the
|
||||
.Xr ng_ppp 8
|
||||
node's
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv ip
|
||||
nodes, respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv ip
|
||||
Upstream (uncompressed) IP packets.
|
||||
.It Dv vjcomp
|
||||
Downstream compressed TCP packets.
|
||||
.It Dv vjuncomp
|
||||
Downstream uncompressed TCP packets.
|
||||
.It Dv vjip
|
||||
Downstream uncompressed IP packets.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_VJC_CONFIG
|
||||
This command resets the compression state and configures it according
|
||||
to the supplied
|
||||
.Dv "struct ngm_vjc_config"
|
||||
argument. This structure contains the following fields:
|
||||
.Bd -literal -offset 4n
|
||||
struct ngm_vjc_config {
|
||||
u_char enabled; /* Enable compression/decompression */
|
||||
u_char numChannels; /* Number of outgoing channels */
|
||||
u_char compressCID; /* OK to compress outgoing CID's */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
When
|
||||
.Dv enabled
|
||||
is set to zero, the node operates in ``pass through'' mode, only
|
||||
accepting packets on the
|
||||
.Dv ip
|
||||
and
|
||||
.Dv vjip
|
||||
hooks.
|
||||
.Dv numChannels
|
||||
should be set to the number of compression channels, and is a value
|
||||
between 3 and 16, inclusive.
|
||||
.Pp
|
||||
The
|
||||
.Dv compressCID
|
||||
field indicates whether it is OK to compress the CID field for
|
||||
outgoing compressed TCP packets. This value should be zero unless
|
||||
either (a) it not possible for an incoming frame to be lost, or
|
||||
(b) lost frames can be reliably detected and a
|
||||
.Dv NGM_VJC_RECV_ERROR
|
||||
mesages is immediately sent whenever this occurs.
|
||||
.It Dv NGM_VJC_GET_STATE
|
||||
This command returns the node's current state described by the
|
||||
.Dv "struct slcompress"
|
||||
structure, which is defined in
|
||||
.Dv "net/slcompress.h" .
|
||||
.It Dv NGM_VJC_CLR_STATS
|
||||
Clears the node statistics counters. Statistics are also cleared whenever the
|
||||
.Dv enabled
|
||||
field is changed from zero to one by a
|
||||
.Dv NGM_VJC_CONFIG
|
||||
control message.
|
||||
.It Dv NGM_VJC_RECV_ERROR
|
||||
When the
|
||||
.Dv compressCID
|
||||
is set to one, this message must be sent to the node immediately
|
||||
after detecting that a recieved frame has been lost, due to a bad
|
||||
checksum or for any other reason. Failing to do this can result
|
||||
in corrupted TCP stream data.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
This node type requires that the file
|
||||
.Dv "net/slcompress.c"
|
||||
was compiled into the kernel. Currently the only way to insure this
|
||||
is to include the
|
||||
.Dv slip ,
|
||||
.Dv ppp ,
|
||||
or
|
||||
.Dv i4bipr
|
||||
pseudo-devices in your kernel compilation. In the future there should
|
||||
be a kernel option that causes inclusion of this file without requiring
|
||||
one of these drivers.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A V. Jacobsen
|
||||
.%T "Compressing TCP/IP Headers"
|
||||
.%O RFC 1144
|
||||
.Re
|
||||
.Rs
|
||||
.%A G. McGregor
|
||||
.%T "The PPP Internet Control Protocol (IPCP)"
|
||||
.%O RFC 1332
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
@ -48,6 +48,7 @@ LIBMP?= ${DESTDIR}${LIBDIR}/libmp.a
|
||||
LIBMYTINFO?= ${DESTDIR}${LIBDIR}/libmytinfo.a
|
||||
LIBNCP?= ${DESTDIR}${LIBDIR}/libncp.a
|
||||
LIBNCURSES?= ${DESTDIR}${LIBDIR}/libncurses.a
|
||||
LIBNETGRAPH?= ${DESTDIR}${LIBDIR}/libnetgraph.a
|
||||
LIBOBJC?= ${DESTDIR}${LIBDIR}/libobjc.a
|
||||
LIBOPIE?= ${DESTDIR}${LIBDIR}/libopie.a
|
||||
|
||||
|
@ -387,6 +387,24 @@ options NETATALK #Appletalk communications protocols
|
||||
#options EON #ISO CLNP over IP
|
||||
#options NSIP #XNS over IP
|
||||
|
||||
# netgraph(4). Enable the base netgraph code with the NETGRAPH option.
|
||||
# Individual node types can be enabled with the corresponding option
|
||||
# listed below; however, this is not strictly necessary as netgraph
|
||||
# will automatically load the corresponding KLD module if the node type
|
||||
# is not already compiled into the kernel.
|
||||
options NETGRAPH #netgraph(4) system
|
||||
options NETGRAPH_ASYNC
|
||||
options NETGRAPH_CISCO
|
||||
options NETGRAPH_ECHO
|
||||
options NETGRAPH_FRAME_RELAY
|
||||
options NETGRAPH_HOLE
|
||||
options NETGRAPH_IFACE
|
||||
options NETGRAPH_LMI
|
||||
options NETGRAPH_RFC1490
|
||||
options NETGRAPH_TEE
|
||||
options NETGRAPH_TTY
|
||||
options NETGRAPH_UI
|
||||
|
||||
#
|
||||
# Network interfaces:
|
||||
# The `loop' pseudo-device is MANDATORY when networking is enabled.
|
||||
|
@ -563,6 +563,19 @@ netatm/uni/unisig_sigmgr_state.c optional atm_uni atm_core
|
||||
netatm/uni/unisig_subr.c optional atm_uni atm_core
|
||||
netatm/uni/unisig_util.c optional atm_uni atm_core
|
||||
netatm/uni/unisig_vc_state.c optional atm_uni atm_core
|
||||
netgraph/ng_base.c optional netgraph
|
||||
netgraph/ng_async.c optional netgraph_async
|
||||
netgraph/ng_cisco.c optional netgraph_cisco
|
||||
netgraph/ng_echo.c optional netgraph_echo
|
||||
netgraph/ng_frame_relay.c optional netgraph_frame_relay
|
||||
netgraph/ng_hole.c optional netgraph_hole
|
||||
netgraph/ng_iface.c optional netgraph_iface
|
||||
netgraph/ng_lmi.c optional netgraph_lmi
|
||||
netgraph/ng_rfc1490.c optional netgraph_rfc1490
|
||||
netgraph/ng_socket.c optional netgraph_socket
|
||||
netgraph/ng_tee.c optional netgraph_tee
|
||||
netgraph/ng_tty.c optional netgraph_tty
|
||||
netgraph/ng_UI.c optional netgraph_UI
|
||||
netinet/if_atm.c optional atm
|
||||
netinet/if_ether.c optional ether
|
||||
netinet/igmp.c optional inet
|
||||
|
@ -237,6 +237,24 @@ TCPDEBUG
|
||||
TCP_DROP_SYNFIN opt_tcp_input.h
|
||||
TCP_RESTRICT_RST opt_tcp_input.h
|
||||
|
||||
# Netgraph(4). Use option NETGRAPH to enable the base netgraph code.
|
||||
# Each netgraph node type can be either be compiled into the kernel
|
||||
# or loaded dynamically. To get the former, include the corresponding
|
||||
# option below.
|
||||
NETGRAPH
|
||||
NETGRAPH_ASYNC opt_netgraph.h
|
||||
NETGRAPH_CISCO opt_netgraph.h
|
||||
NETGRAPH_ECHO opt_netgraph.h
|
||||
NETGRAPH_FRAME_RELAY opt_netgraph.h
|
||||
NETGRAPH_HOLE opt_netgraph.h
|
||||
NETGRAPH_IFACE opt_netgraph.h
|
||||
NETGRAPH_LMI opt_netgraph.h
|
||||
NETGRAPH_RFC1490 opt_netgraph.h
|
||||
NETGRAPH_SOCKET opt_netgraph.h
|
||||
NETGRAPH_TEE opt_netgraph.h
|
||||
NETGRAPH_TTY opt_netgraph.h
|
||||
NETGRAPH_UI opt_netgraph.h
|
||||
|
||||
# ATM (HARP version)
|
||||
ATM_CORE opt_atm.h
|
||||
ATM_IP opt_atm.h
|
||||
|
@ -45,6 +45,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opt_netgraph.h"
|
||||
#include "ar.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -55,9 +56,16 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#ifdef NETGRAPH
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <i386/isa/if_ar.h>
|
||||
#else /* NETGRAPH */
|
||||
#include <net/if_sppp.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/md_var.h>
|
||||
@ -66,10 +74,12 @@
|
||||
#include <i386/isa/ic/hd64570.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
|
||||
#ifndef NETGRAPH
|
||||
#include "sppp.h"
|
||||
#if NSPPP <= 0
|
||||
#error device 'ar' require sppp.
|
||||
#endif
|
||||
#endif /* NSPPP <= 0 */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#ifdef TRACE
|
||||
#define TRC(x) x
|
||||
@ -118,7 +128,9 @@ static int next_ar_unit = 0;
|
||||
static struct ar_hardc ar_hardc[NAR];
|
||||
|
||||
struct ar_softc {
|
||||
#ifndef NETGRAPH
|
||||
struct sppp ifsppp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit; /* With regards to all ar devices */
|
||||
int subunit; /* With regards to this card */
|
||||
struct ar_hardc *hc;
|
||||
@ -146,8 +158,38 @@ struct ar_softc {
|
||||
int scano;
|
||||
int scachan;
|
||||
sca_regs *sca;
|
||||
#ifdef NETGRAPH
|
||||
int running; /* something is attached so we are running */
|
||||
int dcd; /* do we have dcd? */
|
||||
/* ---netgraph bits --- */
|
||||
char nodename[NG_NODELEN + 1]; /* store our node name */
|
||||
int datahooks; /* number of data hooks attached */
|
||||
node_p node; /* netgraph node */
|
||||
hook_p hook; /* data hook */
|
||||
hook_p debug_hook;
|
||||
struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
|
||||
struct ifqueue xmitq; /* transmit queue */
|
||||
int flags; /* state */
|
||||
#define SCF_RUNNING 0x01 /* board is active */
|
||||
#define SCF_OACTIVE 0x02 /* output is active */
|
||||
int out_dog; /* watchdog cycles output count-down */
|
||||
struct callout_handle handle; /* timeout(9) handle */
|
||||
u_long inbytes, outbytes; /* stats */
|
||||
u_long lastinbytes, lastoutbytes; /* a second ago */
|
||||
u_long inrate, outrate; /* highest rate seen */
|
||||
u_long inlast; /* last input N secs ago */
|
||||
u_long out_deficit; /* output since last input */
|
||||
u_long oerrors, ierrors[6];
|
||||
u_long opackets, ipackets;
|
||||
#endif /* NETGRAPH */
|
||||
};
|
||||
|
||||
#ifdef NETGRAPH
|
||||
#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
|
||||
#define QUITE_A_WHILE 300 /* 5 MINUTES */
|
||||
#define LOTS_OF_PACKETS 100
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
static int arprobe(struct isa_device *id);
|
||||
static int arattach_isa(struct isa_device *id);
|
||||
|
||||
@ -184,9 +226,14 @@ void arintr_hc(struct ar_hardc *hc);
|
||||
static ointhand2_t arintr;
|
||||
static int arattach(struct ar_hardc *hc);
|
||||
static void ar_xmit(struct ar_softc *sc);
|
||||
#ifndef NETGRAPH
|
||||
static void arstart(struct ifnet *ifp);
|
||||
static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
|
||||
static void arwatchdog(struct ifnet *ifp);
|
||||
#else /* NETGRAPH */
|
||||
static void arstart(struct ar_softc *sc);
|
||||
static void arwatchdog(struct ar_softc *sc);
|
||||
#endif /* NETGRAPH */
|
||||
static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
|
||||
static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
|
||||
static void ar_eat_packet(struct ar_softc *sc, int single);
|
||||
@ -204,6 +251,37 @@ static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
|
||||
#ifdef NETGRAPH
|
||||
static void ngar_watchdog_frame(void * arg);
|
||||
static void ngar_init(void* ignored);
|
||||
static int ngar_constructor(node_p *nodep);
|
||||
static int ngar_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
static int ngar_rmnode(node_p node);
|
||||
static int ngar_newhook(node_p node, hook_p hook, const char *name);
|
||||
/*static hook_p ngar_findhook(node_p node, char *name);*/
|
||||
static int ngar_connect(hook_p hook); /* already PARTLY linked */
|
||||
static int ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int ngar_disconnect(hook_p hook); /* notify on disconnect */
|
||||
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_AR_NODE_TYPE,
|
||||
NULL,
|
||||
ngar_constructor,
|
||||
ngar_rcvmsg,
|
||||
ngar_rmnode,
|
||||
ngar_newhook,
|
||||
NULL,
|
||||
ngar_connect,
|
||||
ngar_rcvdata,
|
||||
ngar_rcvdata,
|
||||
ngar_disconnect
|
||||
};
|
||||
|
||||
static int ngar_done_init = 0;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Register the Adapter.
|
||||
* Probe to see if it is there.
|
||||
@ -348,7 +426,9 @@ static int
|
||||
arattach(struct ar_hardc *hc)
|
||||
{
|
||||
struct ar_softc *sc;
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit;
|
||||
char *iface;
|
||||
|
||||
@ -380,6 +460,7 @@ arattach(struct ar_hardc *hc)
|
||||
ar_init_tx_dmac(sc);
|
||||
ar_init_msci(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
|
||||
ifp->if_softc = sc;
|
||||
@ -412,6 +493,25 @@ arattach(struct ar_hardc *hc)
|
||||
if_attach(ifp);
|
||||
|
||||
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
|
||||
#else /* NETGRAPH */
|
||||
/*
|
||||
* we have found a node, make sure our 'type' is availabe.
|
||||
*/
|
||||
if (ngar_done_init == 0) ngar_init(NULL);
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
sc->node->private = sc;
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_rmnode(sc->node);
|
||||
ng_unref(sc->node);
|
||||
return (0);
|
||||
}
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
@ -511,10 +611,14 @@ arintr_hc(struct ar_hardc *hc)
|
||||
static void
|
||||
ar_xmit(struct ar_softc *sc)
|
||||
{
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
dmac_channel *dmac;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
#endif /* NETGRAPH */
|
||||
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
@ -530,7 +634,11 @@ ar_xmit(struct ar_softc *sc)
|
||||
if(sc->txb_next_tx == AR_TX_BLOCKS)
|
||||
sc->txb_next_tx = 0;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_timer = 2; /* Value in seconds. */
|
||||
#else /* NETGRAPH */
|
||||
sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
|
||||
#endif /* NETGRAPH */
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
}
|
||||
@ -549,30 +657,51 @@ ar_xmit(struct ar_softc *sc)
|
||||
* that clears that should ensure that the transmitter and its DMA is
|
||||
* in a "good" idle state.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
static void
|
||||
arstart(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
static void
|
||||
arstart(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
int i, len, tlen;
|
||||
struct mbuf *mtx;
|
||||
u_char *txdata;
|
||||
sca_descriptor *txdesc;
|
||||
struct buf_block *blkp;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
top_arstart:
|
||||
|
||||
/*
|
||||
* See if we have space for more packets.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
if(sc->txb_inuse == AR_TX_BLOCKS) {
|
||||
ifp->if_flags |= IFF_OACTIVE;
|
||||
ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
|
||||
#else /* NETGRAPH */
|
||||
/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
|
||||
#endif /* NETGRAPH */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
return;
|
||||
|
||||
@ -618,10 +747,16 @@ arstart(struct ifnet *ifp)
|
||||
txdata += AR_BUF_SIZ;
|
||||
i++;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(ifp->if_bpf)
|
||||
bpf_mtap(ifp, mtx);
|
||||
m_freem(mtx);
|
||||
++sc->ifsppp.pp_if.if_opackets;
|
||||
#else /* NETGRAPH */
|
||||
m_freem(mtx);
|
||||
sc->outbytes += len;
|
||||
++sc->opackets;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Check if we have space for another mbuf.
|
||||
@ -631,7 +766,14 @@ arstart(struct ifnet *ifp)
|
||||
if((i + 3) >= blkp->txmax)
|
||||
break;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
break;
|
||||
}
|
||||
@ -670,6 +812,7 @@ arstart(struct ifnet *ifp)
|
||||
goto top_arstart;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
static int
|
||||
arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
@ -711,18 +854,26 @@ arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* This is to catch lost tx interrupts.
|
||||
*/
|
||||
static void
|
||||
#ifndef NETGRAPH
|
||||
arwatchdog(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
arwatchdog(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
msci_channel *msci = &sc->sca->msci[sc->scachan];
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -730,7 +881,7 @@ arwatchdog(struct ifnet *ifp)
|
||||
/* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
|
||||
printf("ar%d: transmit failed, "
|
||||
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
|
||||
ifp->if_unit,
|
||||
sc->unit,
|
||||
msci->st0,
|
||||
msci->st1,
|
||||
msci->st3,
|
||||
@ -743,12 +894,20 @@ arwatchdog(struct ifnet *ifp)
|
||||
}
|
||||
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX ifp->if_flags &= ~IFF_OACTIVE; */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
arstart(ifp);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -803,6 +962,11 @@ ar_up(struct ar_softc *sc)
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
sc->running = 1;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -814,6 +978,10 @@ ar_down(struct ar_softc *sc)
|
||||
sca = sc->sca;
|
||||
msci = &sca->msci[sc->scachan];
|
||||
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
/*
|
||||
* Disable transmitter and receiver.
|
||||
* Lower DTR and RTS.
|
||||
@ -958,9 +1126,12 @@ arc_init(struct ar_hardc *hc)
|
||||
u_int descneeded;
|
||||
u_char isr, mar;
|
||||
|
||||
sc = hc->sc = malloc(hc->numports * sizeof(struct ar_softc),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
MALLOC(sc, struct ar_softc *,
|
||||
hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, hc->numports * sizeof(struct ar_softc));
|
||||
hc->sc = sc;
|
||||
|
||||
hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
|
||||
AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
|
||||
@ -1088,7 +1259,6 @@ arc_init(struct ar_hardc *hc)
|
||||
|
||||
if(hc->bustype == AR_BUS_PCI)
|
||||
hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1105,7 +1275,6 @@ ar_init_sca(struct ar_hardc *hc, int scano)
|
||||
sca_regs *sca;
|
||||
|
||||
sca = hc->sca[scano];
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
|
||||
@ -1562,7 +1731,13 @@ ar_get_packets(struct ar_softc *sc)
|
||||
ar_eat_packet(sc, 1);
|
||||
continue;
|
||||
}
|
||||
#ifndef NETGRAPH
|
||||
m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
|
||||
#else /* NETGRAPH */
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
sc->inbytes += len;
|
||||
sc->inlast = 0;
|
||||
#endif /* NETGRAPH */
|
||||
m->m_pkthdr.len = m->m_len = len;
|
||||
if(len > MHLEN) {
|
||||
MCLGET(m, M_DONTWAIT);
|
||||
@ -1573,10 +1748,15 @@ ar_get_packets(struct ar_softc *sc)
|
||||
}
|
||||
}
|
||||
ar_copy_rxbuf(m, sc, len);
|
||||
#ifndef NETGRAPH
|
||||
if(sc->ifsppp.pp_if.if_bpf)
|
||||
bpf_mtap(&sc->ifsppp.pp_if, m);
|
||||
sppp_input(&sc->ifsppp.pp_if, m);
|
||||
sc->ifsppp.pp_if.if_ipackets++;
|
||||
#else /* NETGRAPH */
|
||||
ng_queue_data(sc->hook, m, NULL);
|
||||
sc->ipackets++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Update the eda to the previous descriptor.
|
||||
@ -1609,7 +1789,11 @@ ar_get_packets(struct ar_softc *sc)
|
||||
|
||||
ar_eat_packet(sc, 1);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[0]++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -1678,8 +1862,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: TX DMA Counter overflow, "
|
||||
"txpacket no %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets);
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets);
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1688,11 +1877,19 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"txpacket no %lu, dsr %02x, "
|
||||
"cda %04x, eda %04x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets,
|
||||
#endif /* NETGRAPH */
|
||||
dsr,
|
||||
dmac->cda,
|
||||
dmac->eda);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* End of Transfer */
|
||||
@ -1706,8 +1903,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* there is data to transmit.
|
||||
*/
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
|
||||
sc->ifsppp.pp_if.if_timer = 0;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
|
||||
sc->out_dog = 0; /* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
@ -1735,7 +1937,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
|
||||
ar_get_packets(sc);
|
||||
TRC(
|
||||
#ifndef NETGRAPH
|
||||
if(tt == sc->ifsppp.pp_if.if_ipackets) {
|
||||
#else /* NETGRAPH */
|
||||
if(tt == sc->ipackets) {
|
||||
#endif /* NETGRAPH */
|
||||
sca_descriptor *rxdesc;
|
||||
int i;
|
||||
|
||||
@ -1779,8 +1985,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: RX DMA Counter overflow, "
|
||||
"rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[1]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1791,7 +2002,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"rxpkts %lu, rxind %d, "
|
||||
"cda %x, eda %x, dsr %x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets,
|
||||
#endif /* NETGRAPH */
|
||||
sc->rxhind,
|
||||
dmac->cda,
|
||||
dmac->eda,
|
||||
@ -1801,7 +2016,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* Then get the system running again.
|
||||
*/
|
||||
ar_eat_packet(sc, 0);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[2]++;
|
||||
#endif /* NETGRAPH */
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
|
||||
@ -1829,8 +2048,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
*/
|
||||
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[3]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
}
|
||||
|
||||
@ -1846,7 +2070,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
for(mch = 0; mch < NCHAN; mch++) {
|
||||
if(dotxstart & 0x0C) {
|
||||
sc = &hc->sc[mch + (NCHAN * scano)];
|
||||
#ifndef NETGRAPH
|
||||
arstart(&sc->ifsppp.pp_if);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
dotxstart >>= 4;
|
||||
}
|
||||
@ -1864,7 +2092,299 @@ ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
|
||||
printf("arc%d: ARINTR: TIMER\n", hc->cunit);
|
||||
}
|
||||
|
||||
|
||||
#ifdef NETGRAPH
|
||||
/*****************************************
|
||||
* Device timeout/watchdog routine.
|
||||
* called once per second.
|
||||
* checks to see that if activity was expected, that it hapenned.
|
||||
* At present we only look to see if expected output was completed.
|
||||
*/
|
||||
static void
|
||||
ngar_watchdog_frame(void * arg)
|
||||
{
|
||||
struct ar_softc * sc = arg;
|
||||
int s;
|
||||
int speed;
|
||||
|
||||
if(sc->running == 0)
|
||||
return; /* if we are not running let timeouts die */
|
||||
/*
|
||||
* calculate the apparent throughputs
|
||||
* XXX a real hack
|
||||
*/
|
||||
s = splimp();
|
||||
speed = sc->inbytes - sc->lastinbytes;
|
||||
sc->lastinbytes = sc->inbytes;
|
||||
if ( sc->inrate < speed )
|
||||
sc->inrate = speed;
|
||||
speed = sc->outbytes - sc->lastoutbytes;
|
||||
sc->lastoutbytes = sc->outbytes;
|
||||
if ( sc->outrate < speed )
|
||||
sc->outrate = speed;
|
||||
sc->inlast++;
|
||||
splx(s);
|
||||
|
||||
if ((sc->inlast > QUITE_A_WHILE)
|
||||
&& (sc->out_deficit > LOTS_OF_PACKETS)) {
|
||||
log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
splx(s);
|
||||
} else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
|
||||
if (sc->out_dog == 0) {
|
||||
log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
|
||||
sc->unit);
|
||||
arwatchdog(sc);
|
||||
#if 0
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
splx(s);
|
||||
#endif
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
} else {
|
||||
sc->out_dog--;
|
||||
}
|
||||
}
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* This section contains the methods for the Netgraph interface
|
||||
***********************************************************************/
|
||||
/*
|
||||
* It is not possible or allowable to create a node of this type.
|
||||
* If the hardware exists, it will already have created it.
|
||||
*/
|
||||
static int
|
||||
ngar_constructor(node_p *nodep)
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* give our ok for a hook to be added...
|
||||
* If we are not running this should kick the device into life.
|
||||
* We allow hooks called "control" and dlci[1-1023]
|
||||
* The hook's private info points to our stash of info about that
|
||||
* channel.
|
||||
*/
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for raw mode hook.
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* incoming messages.
|
||||
* Just respond to the generic TEXT_STATUS message
|
||||
*/
|
||||
static int
|
||||
ngar_rcvmsg(node_p node,
|
||||
struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
|
||||
{
|
||||
struct ar_softc * sc;
|
||||
int error = 0;
|
||||
|
||||
sc = node->private;
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
break;
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch(msg->header.cmd) {
|
||||
case NGM_TEXT_STATUS: {
|
||||
char *arg;
|
||||
int pos = 0;
|
||||
int resplen = sizeof(struct ng_mesg) + 512;
|
||||
MALLOC(*resp, struct ng_mesg *, resplen,
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (*resp == NULL) {
|
||||
error = ENOMEM;
|
||||
break;
|
||||
}
|
||||
bzero(*resp, resplen);
|
||||
arg = (*resp)->data;
|
||||
|
||||
/*
|
||||
* Put in the throughput information.
|
||||
*/
|
||||
pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
|
||||
"highest rate seen: %ld B/S in, %ld B/S out\n",
|
||||
sc->inbytes, sc->outbytes,
|
||||
sc->inrate, sc->outrate);
|
||||
pos += sprintf(arg + pos,
|
||||
"%ld output errors\n",
|
||||
sc->oerrors);
|
||||
pos += sprintf(arg + pos,
|
||||
"ierrors = %ld, %ld, %ld, %ld\n",
|
||||
sc->ierrors[0],
|
||||
sc->ierrors[1],
|
||||
sc->ierrors[2],
|
||||
sc->ierrors[3]);
|
||||
|
||||
(*resp)->header.version = NG_VERSION;
|
||||
(*resp)->header.arglen = strlen(arg) + 1;
|
||||
(*resp)->header.token = msg->header.token;
|
||||
(*resp)->header.typecookie = NG_AR_COOKIE;
|
||||
(*resp)->header.cmd = msg->header.cmd;
|
||||
strncpy((*resp)->header.cmdstr, "status",
|
||||
NG_CMDSTRLEN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
free(msg, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* get data from another node and transmit it to the correct channel
|
||||
*/
|
||||
static int
|
||||
ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ifqueue *xmitq_p;
|
||||
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now queue the data for when it can be sent
|
||||
*/
|
||||
if (meta && meta->priority > 0) {
|
||||
xmitq_p = (&sc->xmitq_hipri);
|
||||
} else {
|
||||
xmitq_p = (&sc->xmitq);
|
||||
}
|
||||
s = splimp();
|
||||
if (IF_QFULL(xmitq_p)) {
|
||||
IF_DROP(xmitq_p);
|
||||
splx(s);
|
||||
error = ENOBUFS;
|
||||
goto bad;
|
||||
}
|
||||
IF_ENQUEUE(xmitq_p, m);
|
||||
splx(s);
|
||||
arstart(sc);
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
/*
|
||||
* It was an error case.
|
||||
* check if we need to free the mbuf, and then return the error
|
||||
*/
|
||||
NG_FREE_DATA(m, meta);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* do local shutdown processing..
|
||||
* this node will refuse to go away, unless the hardware says to..
|
||||
* don't unref the node, or remove our name. just clear our links up.
|
||||
*/
|
||||
static int
|
||||
ngar_rmnode(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
ar_down(sc);
|
||||
ng_cutlinks(node);
|
||||
node->flags &= ~NG_INVALID; /* bounce back to life */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* already linked */
|
||||
static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* notify on hook disconnection (destruction)
|
||||
*
|
||||
* Invalidate the private data associated with this dlci.
|
||||
* For this type, removal of the last link resets tries to destroy the node.
|
||||
* As the device still exists, the shutdown method will not actually
|
||||
* destroy the node, but reset the device and leave it 'fresh' :)
|
||||
*
|
||||
* The node removal code will remove all references except that owned by the
|
||||
* driver.
|
||||
*/
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
ar_down(sc);
|
||||
splx(s);
|
||||
} else {
|
||||
sc->debug_hook = NULL;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* called during bootup
|
||||
* or LKM loading to put this type into the list of known modules
|
||||
*/
|
||||
static void
|
||||
ngar_init(void *ignored)
|
||||
{
|
||||
if (ng_newtype(&typestruct))
|
||||
printf("ngar install failed\n");
|
||||
ngar_done_init = 1;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
********************************* END ************************************
|
||||
*/
|
||||
|
||||
|
23
sys/dev/ar/if_ar.h
Normal file
23
sys/dev/ar/if_ar.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* if_ar.h
|
||||
*
|
||||
* Copyright (C) 1997-1999 Whistle Communications Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _I386_ISA_IF_AR_H_
|
||||
#define _I386_ISA_IF_AR_H_
|
||||
|
||||
/* Node type name and type cookie */
|
||||
#define NG_AR_NODE_TYPE "sync_ar"
|
||||
#define NG_AR_COOKIE 860552149
|
||||
|
||||
/* Netgraph hooks */
|
||||
#define NG_AR_HOOK_DEBUG "debug"
|
||||
#define NG_AR_HOOK_CONTROL "control"
|
||||
#define NG_AR_HOOK_RAW "rawdata"
|
||||
|
||||
#endif /* _I386_ISA_IF_AR_H_ */
|
||||
|
@ -45,6 +45,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opt_netgraph.h"
|
||||
#include "ar.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -55,9 +56,16 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#ifdef NETGRAPH
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <i386/isa/if_ar.h>
|
||||
#else /* NETGRAPH */
|
||||
#include <net/if_sppp.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/md_var.h>
|
||||
@ -66,10 +74,12 @@
|
||||
#include <i386/isa/ic/hd64570.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
|
||||
#ifndef NETGRAPH
|
||||
#include "sppp.h"
|
||||
#if NSPPP <= 0
|
||||
#error device 'ar' require sppp.
|
||||
#endif
|
||||
#endif /* NSPPP <= 0 */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#ifdef TRACE
|
||||
#define TRC(x) x
|
||||
@ -118,7 +128,9 @@ static int next_ar_unit = 0;
|
||||
static struct ar_hardc ar_hardc[NAR];
|
||||
|
||||
struct ar_softc {
|
||||
#ifndef NETGRAPH
|
||||
struct sppp ifsppp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit; /* With regards to all ar devices */
|
||||
int subunit; /* With regards to this card */
|
||||
struct ar_hardc *hc;
|
||||
@ -146,8 +158,38 @@ struct ar_softc {
|
||||
int scano;
|
||||
int scachan;
|
||||
sca_regs *sca;
|
||||
#ifdef NETGRAPH
|
||||
int running; /* something is attached so we are running */
|
||||
int dcd; /* do we have dcd? */
|
||||
/* ---netgraph bits --- */
|
||||
char nodename[NG_NODELEN + 1]; /* store our node name */
|
||||
int datahooks; /* number of data hooks attached */
|
||||
node_p node; /* netgraph node */
|
||||
hook_p hook; /* data hook */
|
||||
hook_p debug_hook;
|
||||
struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
|
||||
struct ifqueue xmitq; /* transmit queue */
|
||||
int flags; /* state */
|
||||
#define SCF_RUNNING 0x01 /* board is active */
|
||||
#define SCF_OACTIVE 0x02 /* output is active */
|
||||
int out_dog; /* watchdog cycles output count-down */
|
||||
struct callout_handle handle; /* timeout(9) handle */
|
||||
u_long inbytes, outbytes; /* stats */
|
||||
u_long lastinbytes, lastoutbytes; /* a second ago */
|
||||
u_long inrate, outrate; /* highest rate seen */
|
||||
u_long inlast; /* last input N secs ago */
|
||||
u_long out_deficit; /* output since last input */
|
||||
u_long oerrors, ierrors[6];
|
||||
u_long opackets, ipackets;
|
||||
#endif /* NETGRAPH */
|
||||
};
|
||||
|
||||
#ifdef NETGRAPH
|
||||
#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
|
||||
#define QUITE_A_WHILE 300 /* 5 MINUTES */
|
||||
#define LOTS_OF_PACKETS 100
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
static int arprobe(struct isa_device *id);
|
||||
static int arattach_isa(struct isa_device *id);
|
||||
|
||||
@ -184,9 +226,14 @@ void arintr_hc(struct ar_hardc *hc);
|
||||
static ointhand2_t arintr;
|
||||
static int arattach(struct ar_hardc *hc);
|
||||
static void ar_xmit(struct ar_softc *sc);
|
||||
#ifndef NETGRAPH
|
||||
static void arstart(struct ifnet *ifp);
|
||||
static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
|
||||
static void arwatchdog(struct ifnet *ifp);
|
||||
#else /* NETGRAPH */
|
||||
static void arstart(struct ar_softc *sc);
|
||||
static void arwatchdog(struct ar_softc *sc);
|
||||
#endif /* NETGRAPH */
|
||||
static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
|
||||
static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
|
||||
static void ar_eat_packet(struct ar_softc *sc, int single);
|
||||
@ -204,6 +251,37 @@ static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
|
||||
#ifdef NETGRAPH
|
||||
static void ngar_watchdog_frame(void * arg);
|
||||
static void ngar_init(void* ignored);
|
||||
static int ngar_constructor(node_p *nodep);
|
||||
static int ngar_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
static int ngar_rmnode(node_p node);
|
||||
static int ngar_newhook(node_p node, hook_p hook, const char *name);
|
||||
/*static hook_p ngar_findhook(node_p node, char *name);*/
|
||||
static int ngar_connect(hook_p hook); /* already PARTLY linked */
|
||||
static int ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int ngar_disconnect(hook_p hook); /* notify on disconnect */
|
||||
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_AR_NODE_TYPE,
|
||||
NULL,
|
||||
ngar_constructor,
|
||||
ngar_rcvmsg,
|
||||
ngar_rmnode,
|
||||
ngar_newhook,
|
||||
NULL,
|
||||
ngar_connect,
|
||||
ngar_rcvdata,
|
||||
ngar_rcvdata,
|
||||
ngar_disconnect
|
||||
};
|
||||
|
||||
static int ngar_done_init = 0;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Register the Adapter.
|
||||
* Probe to see if it is there.
|
||||
@ -348,7 +426,9 @@ static int
|
||||
arattach(struct ar_hardc *hc)
|
||||
{
|
||||
struct ar_softc *sc;
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit;
|
||||
char *iface;
|
||||
|
||||
@ -380,6 +460,7 @@ arattach(struct ar_hardc *hc)
|
||||
ar_init_tx_dmac(sc);
|
||||
ar_init_msci(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
|
||||
ifp->if_softc = sc;
|
||||
@ -412,6 +493,25 @@ arattach(struct ar_hardc *hc)
|
||||
if_attach(ifp);
|
||||
|
||||
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
|
||||
#else /* NETGRAPH */
|
||||
/*
|
||||
* we have found a node, make sure our 'type' is availabe.
|
||||
*/
|
||||
if (ngar_done_init == 0) ngar_init(NULL);
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
sc->node->private = sc;
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_rmnode(sc->node);
|
||||
ng_unref(sc->node);
|
||||
return (0);
|
||||
}
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
@ -511,10 +611,14 @@ arintr_hc(struct ar_hardc *hc)
|
||||
static void
|
||||
ar_xmit(struct ar_softc *sc)
|
||||
{
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
dmac_channel *dmac;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
#endif /* NETGRAPH */
|
||||
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
@ -530,7 +634,11 @@ ar_xmit(struct ar_softc *sc)
|
||||
if(sc->txb_next_tx == AR_TX_BLOCKS)
|
||||
sc->txb_next_tx = 0;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_timer = 2; /* Value in seconds. */
|
||||
#else /* NETGRAPH */
|
||||
sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
|
||||
#endif /* NETGRAPH */
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
}
|
||||
@ -549,30 +657,51 @@ ar_xmit(struct ar_softc *sc)
|
||||
* that clears that should ensure that the transmitter and its DMA is
|
||||
* in a "good" idle state.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
static void
|
||||
arstart(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
static void
|
||||
arstart(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
int i, len, tlen;
|
||||
struct mbuf *mtx;
|
||||
u_char *txdata;
|
||||
sca_descriptor *txdesc;
|
||||
struct buf_block *blkp;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
top_arstart:
|
||||
|
||||
/*
|
||||
* See if we have space for more packets.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
if(sc->txb_inuse == AR_TX_BLOCKS) {
|
||||
ifp->if_flags |= IFF_OACTIVE;
|
||||
ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
|
||||
#else /* NETGRAPH */
|
||||
/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
|
||||
#endif /* NETGRAPH */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
return;
|
||||
|
||||
@ -618,10 +747,16 @@ arstart(struct ifnet *ifp)
|
||||
txdata += AR_BUF_SIZ;
|
||||
i++;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(ifp->if_bpf)
|
||||
bpf_mtap(ifp, mtx);
|
||||
m_freem(mtx);
|
||||
++sc->ifsppp.pp_if.if_opackets;
|
||||
#else /* NETGRAPH */
|
||||
m_freem(mtx);
|
||||
sc->outbytes += len;
|
||||
++sc->opackets;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Check if we have space for another mbuf.
|
||||
@ -631,7 +766,14 @@ arstart(struct ifnet *ifp)
|
||||
if((i + 3) >= blkp->txmax)
|
||||
break;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
break;
|
||||
}
|
||||
@ -670,6 +812,7 @@ arstart(struct ifnet *ifp)
|
||||
goto top_arstart;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
static int
|
||||
arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
@ -711,18 +854,26 @@ arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* This is to catch lost tx interrupts.
|
||||
*/
|
||||
static void
|
||||
#ifndef NETGRAPH
|
||||
arwatchdog(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
arwatchdog(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
msci_channel *msci = &sc->sca->msci[sc->scachan];
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -730,7 +881,7 @@ arwatchdog(struct ifnet *ifp)
|
||||
/* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
|
||||
printf("ar%d: transmit failed, "
|
||||
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
|
||||
ifp->if_unit,
|
||||
sc->unit,
|
||||
msci->st0,
|
||||
msci->st1,
|
||||
msci->st3,
|
||||
@ -743,12 +894,20 @@ arwatchdog(struct ifnet *ifp)
|
||||
}
|
||||
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX ifp->if_flags &= ~IFF_OACTIVE; */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
arstart(ifp);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -803,6 +962,11 @@ ar_up(struct ar_softc *sc)
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
sc->running = 1;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -814,6 +978,10 @@ ar_down(struct ar_softc *sc)
|
||||
sca = sc->sca;
|
||||
msci = &sca->msci[sc->scachan];
|
||||
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
/*
|
||||
* Disable transmitter and receiver.
|
||||
* Lower DTR and RTS.
|
||||
@ -958,9 +1126,12 @@ arc_init(struct ar_hardc *hc)
|
||||
u_int descneeded;
|
||||
u_char isr, mar;
|
||||
|
||||
sc = hc->sc = malloc(hc->numports * sizeof(struct ar_softc),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
MALLOC(sc, struct ar_softc *,
|
||||
hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, hc->numports * sizeof(struct ar_softc));
|
||||
hc->sc = sc;
|
||||
|
||||
hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
|
||||
AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
|
||||
@ -1088,7 +1259,6 @@ arc_init(struct ar_hardc *hc)
|
||||
|
||||
if(hc->bustype == AR_BUS_PCI)
|
||||
hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1105,7 +1275,6 @@ ar_init_sca(struct ar_hardc *hc, int scano)
|
||||
sca_regs *sca;
|
||||
|
||||
sca = hc->sca[scano];
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
|
||||
@ -1562,7 +1731,13 @@ ar_get_packets(struct ar_softc *sc)
|
||||
ar_eat_packet(sc, 1);
|
||||
continue;
|
||||
}
|
||||
#ifndef NETGRAPH
|
||||
m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
|
||||
#else /* NETGRAPH */
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
sc->inbytes += len;
|
||||
sc->inlast = 0;
|
||||
#endif /* NETGRAPH */
|
||||
m->m_pkthdr.len = m->m_len = len;
|
||||
if(len > MHLEN) {
|
||||
MCLGET(m, M_DONTWAIT);
|
||||
@ -1573,10 +1748,15 @@ ar_get_packets(struct ar_softc *sc)
|
||||
}
|
||||
}
|
||||
ar_copy_rxbuf(m, sc, len);
|
||||
#ifndef NETGRAPH
|
||||
if(sc->ifsppp.pp_if.if_bpf)
|
||||
bpf_mtap(&sc->ifsppp.pp_if, m);
|
||||
sppp_input(&sc->ifsppp.pp_if, m);
|
||||
sc->ifsppp.pp_if.if_ipackets++;
|
||||
#else /* NETGRAPH */
|
||||
ng_queue_data(sc->hook, m, NULL);
|
||||
sc->ipackets++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Update the eda to the previous descriptor.
|
||||
@ -1609,7 +1789,11 @@ ar_get_packets(struct ar_softc *sc)
|
||||
|
||||
ar_eat_packet(sc, 1);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[0]++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -1678,8 +1862,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: TX DMA Counter overflow, "
|
||||
"txpacket no %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets);
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets);
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1688,11 +1877,19 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"txpacket no %lu, dsr %02x, "
|
||||
"cda %04x, eda %04x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets,
|
||||
#endif /* NETGRAPH */
|
||||
dsr,
|
||||
dmac->cda,
|
||||
dmac->eda);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* End of Transfer */
|
||||
@ -1706,8 +1903,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* there is data to transmit.
|
||||
*/
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
|
||||
sc->ifsppp.pp_if.if_timer = 0;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
|
||||
sc->out_dog = 0; /* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
@ -1735,7 +1937,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
|
||||
ar_get_packets(sc);
|
||||
TRC(
|
||||
#ifndef NETGRAPH
|
||||
if(tt == sc->ifsppp.pp_if.if_ipackets) {
|
||||
#else /* NETGRAPH */
|
||||
if(tt == sc->ipackets) {
|
||||
#endif /* NETGRAPH */
|
||||
sca_descriptor *rxdesc;
|
||||
int i;
|
||||
|
||||
@ -1779,8 +1985,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: RX DMA Counter overflow, "
|
||||
"rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[1]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1791,7 +2002,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"rxpkts %lu, rxind %d, "
|
||||
"cda %x, eda %x, dsr %x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets,
|
||||
#endif /* NETGRAPH */
|
||||
sc->rxhind,
|
||||
dmac->cda,
|
||||
dmac->eda,
|
||||
@ -1801,7 +2016,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* Then get the system running again.
|
||||
*/
|
||||
ar_eat_packet(sc, 0);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[2]++;
|
||||
#endif /* NETGRAPH */
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
|
||||
@ -1829,8 +2048,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
*/
|
||||
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[3]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
}
|
||||
|
||||
@ -1846,7 +2070,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
for(mch = 0; mch < NCHAN; mch++) {
|
||||
if(dotxstart & 0x0C) {
|
||||
sc = &hc->sc[mch + (NCHAN * scano)];
|
||||
#ifndef NETGRAPH
|
||||
arstart(&sc->ifsppp.pp_if);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
dotxstart >>= 4;
|
||||
}
|
||||
@ -1864,7 +2092,299 @@ ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
|
||||
printf("arc%d: ARINTR: TIMER\n", hc->cunit);
|
||||
}
|
||||
|
||||
|
||||
#ifdef NETGRAPH
|
||||
/*****************************************
|
||||
* Device timeout/watchdog routine.
|
||||
* called once per second.
|
||||
* checks to see that if activity was expected, that it hapenned.
|
||||
* At present we only look to see if expected output was completed.
|
||||
*/
|
||||
static void
|
||||
ngar_watchdog_frame(void * arg)
|
||||
{
|
||||
struct ar_softc * sc = arg;
|
||||
int s;
|
||||
int speed;
|
||||
|
||||
if(sc->running == 0)
|
||||
return; /* if we are not running let timeouts die */
|
||||
/*
|
||||
* calculate the apparent throughputs
|
||||
* XXX a real hack
|
||||
*/
|
||||
s = splimp();
|
||||
speed = sc->inbytes - sc->lastinbytes;
|
||||
sc->lastinbytes = sc->inbytes;
|
||||
if ( sc->inrate < speed )
|
||||
sc->inrate = speed;
|
||||
speed = sc->outbytes - sc->lastoutbytes;
|
||||
sc->lastoutbytes = sc->outbytes;
|
||||
if ( sc->outrate < speed )
|
||||
sc->outrate = speed;
|
||||
sc->inlast++;
|
||||
splx(s);
|
||||
|
||||
if ((sc->inlast > QUITE_A_WHILE)
|
||||
&& (sc->out_deficit > LOTS_OF_PACKETS)) {
|
||||
log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
splx(s);
|
||||
} else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
|
||||
if (sc->out_dog == 0) {
|
||||
log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
|
||||
sc->unit);
|
||||
arwatchdog(sc);
|
||||
#if 0
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
splx(s);
|
||||
#endif
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
} else {
|
||||
sc->out_dog--;
|
||||
}
|
||||
}
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* This section contains the methods for the Netgraph interface
|
||||
***********************************************************************/
|
||||
/*
|
||||
* It is not possible or allowable to create a node of this type.
|
||||
* If the hardware exists, it will already have created it.
|
||||
*/
|
||||
static int
|
||||
ngar_constructor(node_p *nodep)
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* give our ok for a hook to be added...
|
||||
* If we are not running this should kick the device into life.
|
||||
* We allow hooks called "control" and dlci[1-1023]
|
||||
* The hook's private info points to our stash of info about that
|
||||
* channel.
|
||||
*/
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for raw mode hook.
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* incoming messages.
|
||||
* Just respond to the generic TEXT_STATUS message
|
||||
*/
|
||||
static int
|
||||
ngar_rcvmsg(node_p node,
|
||||
struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
|
||||
{
|
||||
struct ar_softc * sc;
|
||||
int error = 0;
|
||||
|
||||
sc = node->private;
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
break;
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch(msg->header.cmd) {
|
||||
case NGM_TEXT_STATUS: {
|
||||
char *arg;
|
||||
int pos = 0;
|
||||
int resplen = sizeof(struct ng_mesg) + 512;
|
||||
MALLOC(*resp, struct ng_mesg *, resplen,
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (*resp == NULL) {
|
||||
error = ENOMEM;
|
||||
break;
|
||||
}
|
||||
bzero(*resp, resplen);
|
||||
arg = (*resp)->data;
|
||||
|
||||
/*
|
||||
* Put in the throughput information.
|
||||
*/
|
||||
pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
|
||||
"highest rate seen: %ld B/S in, %ld B/S out\n",
|
||||
sc->inbytes, sc->outbytes,
|
||||
sc->inrate, sc->outrate);
|
||||
pos += sprintf(arg + pos,
|
||||
"%ld output errors\n",
|
||||
sc->oerrors);
|
||||
pos += sprintf(arg + pos,
|
||||
"ierrors = %ld, %ld, %ld, %ld\n",
|
||||
sc->ierrors[0],
|
||||
sc->ierrors[1],
|
||||
sc->ierrors[2],
|
||||
sc->ierrors[3]);
|
||||
|
||||
(*resp)->header.version = NG_VERSION;
|
||||
(*resp)->header.arglen = strlen(arg) + 1;
|
||||
(*resp)->header.token = msg->header.token;
|
||||
(*resp)->header.typecookie = NG_AR_COOKIE;
|
||||
(*resp)->header.cmd = msg->header.cmd;
|
||||
strncpy((*resp)->header.cmdstr, "status",
|
||||
NG_CMDSTRLEN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
free(msg, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* get data from another node and transmit it to the correct channel
|
||||
*/
|
||||
static int
|
||||
ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ifqueue *xmitq_p;
|
||||
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now queue the data for when it can be sent
|
||||
*/
|
||||
if (meta && meta->priority > 0) {
|
||||
xmitq_p = (&sc->xmitq_hipri);
|
||||
} else {
|
||||
xmitq_p = (&sc->xmitq);
|
||||
}
|
||||
s = splimp();
|
||||
if (IF_QFULL(xmitq_p)) {
|
||||
IF_DROP(xmitq_p);
|
||||
splx(s);
|
||||
error = ENOBUFS;
|
||||
goto bad;
|
||||
}
|
||||
IF_ENQUEUE(xmitq_p, m);
|
||||
splx(s);
|
||||
arstart(sc);
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
/*
|
||||
* It was an error case.
|
||||
* check if we need to free the mbuf, and then return the error
|
||||
*/
|
||||
NG_FREE_DATA(m, meta);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* do local shutdown processing..
|
||||
* this node will refuse to go away, unless the hardware says to..
|
||||
* don't unref the node, or remove our name. just clear our links up.
|
||||
*/
|
||||
static int
|
||||
ngar_rmnode(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
ar_down(sc);
|
||||
ng_cutlinks(node);
|
||||
node->flags &= ~NG_INVALID; /* bounce back to life */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* already linked */
|
||||
static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* notify on hook disconnection (destruction)
|
||||
*
|
||||
* Invalidate the private data associated with this dlci.
|
||||
* For this type, removal of the last link resets tries to destroy the node.
|
||||
* As the device still exists, the shutdown method will not actually
|
||||
* destroy the node, but reset the device and leave it 'fresh' :)
|
||||
*
|
||||
* The node removal code will remove all references except that owned by the
|
||||
* driver.
|
||||
*/
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
ar_down(sc);
|
||||
splx(s);
|
||||
} else {
|
||||
sc->debug_hook = NULL;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* called during bootup
|
||||
* or LKM loading to put this type into the list of known modules
|
||||
*/
|
||||
static void
|
||||
ngar_init(void *ignored)
|
||||
{
|
||||
if (ng_newtype(&typestruct))
|
||||
printf("ngar install failed\n");
|
||||
ngar_done_init = 1;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
********************************* END ************************************
|
||||
*/
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
23
sys/dev/sr/if_sr.h
Normal file
23
sys/dev/sr/if_sr.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* if_sr.h
|
||||
*
|
||||
* Copyright (C) 1997-1999 Whistle Communications Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _I386_ISA_IF_SR_H_
|
||||
#define _I386_ISA_IF_SR_H_
|
||||
|
||||
/* Node type name and type cookie */
|
||||
#define NG_SR_NODE_TYPE "sync_sr"
|
||||
#define NG_SR_COOKIE 860552148
|
||||
|
||||
/* Netgraph hooks */
|
||||
#define NG_SR_HOOK_DEBUG "debug"
|
||||
#define NG_SR_HOOK_CONTROL "control"
|
||||
#define NG_SR_HOOK_RAW "rawdata"
|
||||
|
||||
#endif /* _I386_ISA_IF_SR_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -387,6 +387,24 @@ options NETATALK #Appletalk communications protocols
|
||||
#options EON #ISO CLNP over IP
|
||||
#options NSIP #XNS over IP
|
||||
|
||||
# netgraph(4). Enable the base netgraph code with the NETGRAPH option.
|
||||
# Individual node types can be enabled with the corresponding option
|
||||
# listed below; however, this is not strictly necessary as netgraph
|
||||
# will automatically load the corresponding KLD module if the node type
|
||||
# is not already compiled into the kernel.
|
||||
options NETGRAPH #netgraph(4) system
|
||||
options NETGRAPH_ASYNC
|
||||
options NETGRAPH_CISCO
|
||||
options NETGRAPH_ECHO
|
||||
options NETGRAPH_FRAME_RELAY
|
||||
options NETGRAPH_HOLE
|
||||
options NETGRAPH_IFACE
|
||||
options NETGRAPH_LMI
|
||||
options NETGRAPH_RFC1490
|
||||
options NETGRAPH_TEE
|
||||
options NETGRAPH_TTY
|
||||
options NETGRAPH_UI
|
||||
|
||||
#
|
||||
# Network interfaces:
|
||||
# The `loop' pseudo-device is MANDATORY when networking is enabled.
|
||||
|
@ -387,6 +387,24 @@ options NETATALK #Appletalk communications protocols
|
||||
#options EON #ISO CLNP over IP
|
||||
#options NSIP #XNS over IP
|
||||
|
||||
# netgraph(4). Enable the base netgraph code with the NETGRAPH option.
|
||||
# Individual node types can be enabled with the corresponding option
|
||||
# listed below; however, this is not strictly necessary as netgraph
|
||||
# will automatically load the corresponding KLD module if the node type
|
||||
# is not already compiled into the kernel.
|
||||
options NETGRAPH #netgraph(4) system
|
||||
options NETGRAPH_ASYNC
|
||||
options NETGRAPH_CISCO
|
||||
options NETGRAPH_ECHO
|
||||
options NETGRAPH_FRAME_RELAY
|
||||
options NETGRAPH_HOLE
|
||||
options NETGRAPH_IFACE
|
||||
options NETGRAPH_LMI
|
||||
options NETGRAPH_RFC1490
|
||||
options NETGRAPH_TEE
|
||||
options NETGRAPH_TTY
|
||||
options NETGRAPH_UI
|
||||
|
||||
#
|
||||
# Network interfaces:
|
||||
# The `loop' pseudo-device is MANDATORY when networking is enabled.
|
||||
|
@ -45,6 +45,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opt_netgraph.h"
|
||||
#include "ar.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -55,9 +56,16 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#ifdef NETGRAPH
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <i386/isa/if_ar.h>
|
||||
#else /* NETGRAPH */
|
||||
#include <net/if_sppp.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/md_var.h>
|
||||
@ -66,10 +74,12 @@
|
||||
#include <i386/isa/ic/hd64570.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
|
||||
#ifndef NETGRAPH
|
||||
#include "sppp.h"
|
||||
#if NSPPP <= 0
|
||||
#error device 'ar' require sppp.
|
||||
#endif
|
||||
#endif /* NSPPP <= 0 */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#ifdef TRACE
|
||||
#define TRC(x) x
|
||||
@ -118,7 +128,9 @@ static int next_ar_unit = 0;
|
||||
static struct ar_hardc ar_hardc[NAR];
|
||||
|
||||
struct ar_softc {
|
||||
#ifndef NETGRAPH
|
||||
struct sppp ifsppp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit; /* With regards to all ar devices */
|
||||
int subunit; /* With regards to this card */
|
||||
struct ar_hardc *hc;
|
||||
@ -146,8 +158,38 @@ struct ar_softc {
|
||||
int scano;
|
||||
int scachan;
|
||||
sca_regs *sca;
|
||||
#ifdef NETGRAPH
|
||||
int running; /* something is attached so we are running */
|
||||
int dcd; /* do we have dcd? */
|
||||
/* ---netgraph bits --- */
|
||||
char nodename[NG_NODELEN + 1]; /* store our node name */
|
||||
int datahooks; /* number of data hooks attached */
|
||||
node_p node; /* netgraph node */
|
||||
hook_p hook; /* data hook */
|
||||
hook_p debug_hook;
|
||||
struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
|
||||
struct ifqueue xmitq; /* transmit queue */
|
||||
int flags; /* state */
|
||||
#define SCF_RUNNING 0x01 /* board is active */
|
||||
#define SCF_OACTIVE 0x02 /* output is active */
|
||||
int out_dog; /* watchdog cycles output count-down */
|
||||
struct callout_handle handle; /* timeout(9) handle */
|
||||
u_long inbytes, outbytes; /* stats */
|
||||
u_long lastinbytes, lastoutbytes; /* a second ago */
|
||||
u_long inrate, outrate; /* highest rate seen */
|
||||
u_long inlast; /* last input N secs ago */
|
||||
u_long out_deficit; /* output since last input */
|
||||
u_long oerrors, ierrors[6];
|
||||
u_long opackets, ipackets;
|
||||
#endif /* NETGRAPH */
|
||||
};
|
||||
|
||||
#ifdef NETGRAPH
|
||||
#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
|
||||
#define QUITE_A_WHILE 300 /* 5 MINUTES */
|
||||
#define LOTS_OF_PACKETS 100
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
static int arprobe(struct isa_device *id);
|
||||
static int arattach_isa(struct isa_device *id);
|
||||
|
||||
@ -184,9 +226,14 @@ void arintr_hc(struct ar_hardc *hc);
|
||||
static ointhand2_t arintr;
|
||||
static int arattach(struct ar_hardc *hc);
|
||||
static void ar_xmit(struct ar_softc *sc);
|
||||
#ifndef NETGRAPH
|
||||
static void arstart(struct ifnet *ifp);
|
||||
static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
|
||||
static void arwatchdog(struct ifnet *ifp);
|
||||
#else /* NETGRAPH */
|
||||
static void arstart(struct ar_softc *sc);
|
||||
static void arwatchdog(struct ar_softc *sc);
|
||||
#endif /* NETGRAPH */
|
||||
static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
|
||||
static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
|
||||
static void ar_eat_packet(struct ar_softc *sc, int single);
|
||||
@ -204,6 +251,37 @@ static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
|
||||
|
||||
#ifdef NETGRAPH
|
||||
static void ngar_watchdog_frame(void * arg);
|
||||
static void ngar_init(void* ignored);
|
||||
static int ngar_constructor(node_p *nodep);
|
||||
static int ngar_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
static int ngar_rmnode(node_p node);
|
||||
static int ngar_newhook(node_p node, hook_p hook, const char *name);
|
||||
/*static hook_p ngar_findhook(node_p node, char *name);*/
|
||||
static int ngar_connect(hook_p hook); /* already PARTLY linked */
|
||||
static int ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int ngar_disconnect(hook_p hook); /* notify on disconnect */
|
||||
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_AR_NODE_TYPE,
|
||||
NULL,
|
||||
ngar_constructor,
|
||||
ngar_rcvmsg,
|
||||
ngar_rmnode,
|
||||
ngar_newhook,
|
||||
NULL,
|
||||
ngar_connect,
|
||||
ngar_rcvdata,
|
||||
ngar_rcvdata,
|
||||
ngar_disconnect
|
||||
};
|
||||
|
||||
static int ngar_done_init = 0;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Register the Adapter.
|
||||
* Probe to see if it is there.
|
||||
@ -348,7 +426,9 @@ static int
|
||||
arattach(struct ar_hardc *hc)
|
||||
{
|
||||
struct ar_softc *sc;
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
int unit;
|
||||
char *iface;
|
||||
|
||||
@ -380,6 +460,7 @@ arattach(struct ar_hardc *hc)
|
||||
ar_init_tx_dmac(sc);
|
||||
ar_init_msci(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
|
||||
ifp->if_softc = sc;
|
||||
@ -412,6 +493,25 @@ arattach(struct ar_hardc *hc)
|
||||
if_attach(ifp);
|
||||
|
||||
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
|
||||
#else /* NETGRAPH */
|
||||
/*
|
||||
* we have found a node, make sure our 'type' is availabe.
|
||||
*/
|
||||
if (ngar_done_init == 0) ngar_init(NULL);
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
sc->node->private = sc;
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_rmnode(sc->node);
|
||||
ng_unref(sc->node);
|
||||
return (0);
|
||||
}
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
@ -511,10 +611,14 @@ arintr_hc(struct ar_hardc *hc)
|
||||
static void
|
||||
ar_xmit(struct ar_softc *sc)
|
||||
{
|
||||
#ifndef NETGRAPH
|
||||
struct ifnet *ifp;
|
||||
#endif /* NETGRAPH */
|
||||
dmac_channel *dmac;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp = &sc->ifsppp.pp_if;
|
||||
#endif /* NETGRAPH */
|
||||
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
@ -530,7 +634,11 @@ ar_xmit(struct ar_softc *sc)
|
||||
if(sc->txb_next_tx == AR_TX_BLOCKS)
|
||||
sc->txb_next_tx = 0;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_timer = 2; /* Value in seconds. */
|
||||
#else /* NETGRAPH */
|
||||
sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
|
||||
#endif /* NETGRAPH */
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
}
|
||||
@ -549,30 +657,51 @@ ar_xmit(struct ar_softc *sc)
|
||||
* that clears that should ensure that the transmitter and its DMA is
|
||||
* in a "good" idle state.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
static void
|
||||
arstart(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
static void
|
||||
arstart(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
int i, len, tlen;
|
||||
struct mbuf *mtx;
|
||||
u_char *txdata;
|
||||
sca_descriptor *txdesc;
|
||||
struct buf_block *blkp;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
top_arstart:
|
||||
|
||||
/*
|
||||
* See if we have space for more packets.
|
||||
*/
|
||||
#ifndef NETGRAPH
|
||||
if(sc->txb_inuse == AR_TX_BLOCKS) {
|
||||
ifp->if_flags |= IFF_OACTIVE;
|
||||
ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
|
||||
#else /* NETGRAPH */
|
||||
/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
|
||||
#endif /* NETGRAPH */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
return;
|
||||
|
||||
@ -618,10 +747,16 @@ arstart(struct ifnet *ifp)
|
||||
txdata += AR_BUF_SIZ;
|
||||
i++;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(ifp->if_bpf)
|
||||
bpf_mtap(ifp, mtx);
|
||||
m_freem(mtx);
|
||||
++sc->ifsppp.pp_if.if_opackets;
|
||||
#else /* NETGRAPH */
|
||||
m_freem(mtx);
|
||||
sc->outbytes += len;
|
||||
++sc->opackets;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Check if we have space for another mbuf.
|
||||
@ -631,7 +766,14 @@ arstart(struct ifnet *ifp)
|
||||
if((i + 3) >= blkp->txmax)
|
||||
break;
|
||||
|
||||
#ifndef NETGRAPH
|
||||
mtx = sppp_dequeue(ifp);
|
||||
#else /* NETGRAPH */
|
||||
IF_DEQUEUE(&sc->xmitq_hipri, mtx);
|
||||
if (mtx == NULL) {
|
||||
IF_DEQUEUE(&sc->xmitq, mtx);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
if(!mtx)
|
||||
break;
|
||||
}
|
||||
@ -670,6 +812,7 @@ arstart(struct ifnet *ifp)
|
||||
goto top_arstart;
|
||||
}
|
||||
|
||||
#ifndef NETGRAPH
|
||||
static int
|
||||
arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
{
|
||||
@ -711,18 +854,26 @@ arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* This is to catch lost tx interrupts.
|
||||
*/
|
||||
static void
|
||||
#ifndef NETGRAPH
|
||||
arwatchdog(struct ifnet *ifp)
|
||||
{
|
||||
struct ar_softc *sc = ifp->if_softc;
|
||||
#else /* NETGRAPH */
|
||||
arwatchdog(struct ar_softc *sc)
|
||||
{
|
||||
#endif /* NETGRAPH */
|
||||
msci_channel *msci = &sc->sca->msci[sc->scachan];
|
||||
|
||||
#ifndef NETGRAPH
|
||||
if(!(ifp->if_flags & IFF_RUNNING))
|
||||
return;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -730,7 +881,7 @@ arwatchdog(struct ifnet *ifp)
|
||||
/* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
|
||||
printf("ar%d: transmit failed, "
|
||||
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
|
||||
ifp->if_unit,
|
||||
sc->unit,
|
||||
msci->st0,
|
||||
msci->st1,
|
||||
msci->st3,
|
||||
@ -743,12 +894,20 @@ arwatchdog(struct ifnet *ifp)
|
||||
}
|
||||
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX ifp->if_flags &= ~IFF_OACTIVE; */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
arstart(ifp);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -803,6 +962,11 @@ ar_up(struct ar_softc *sc)
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_OFF(sc->hc->iobase);
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
sc->running = 1;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -814,6 +978,10 @@ ar_down(struct ar_softc *sc)
|
||||
sca = sc->sca;
|
||||
msci = &sca->msci[sc->scachan];
|
||||
|
||||
#ifdef NETGRAPH
|
||||
untimeout(ngar_watchdog_frame, sc, sc->handle);
|
||||
sc->running = 0;
|
||||
#endif /* NETGRAPH */
|
||||
/*
|
||||
* Disable transmitter and receiver.
|
||||
* Lower DTR and RTS.
|
||||
@ -958,9 +1126,12 @@ arc_init(struct ar_hardc *hc)
|
||||
u_int descneeded;
|
||||
u_char isr, mar;
|
||||
|
||||
sc = hc->sc = malloc(hc->numports * sizeof(struct ar_softc),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
MALLOC(sc, struct ar_softc *,
|
||||
hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, hc->numports * sizeof(struct ar_softc));
|
||||
hc->sc = sc;
|
||||
|
||||
hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
|
||||
AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
|
||||
@ -1088,7 +1259,6 @@ arc_init(struct ar_hardc *hc)
|
||||
|
||||
if(hc->bustype == AR_BUS_PCI)
|
||||
hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1105,7 +1275,6 @@ ar_init_sca(struct ar_hardc *hc, int scano)
|
||||
sca_regs *sca;
|
||||
|
||||
sca = hc->sca[scano];
|
||||
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
|
||||
@ -1562,7 +1731,13 @@ ar_get_packets(struct ar_softc *sc)
|
||||
ar_eat_packet(sc, 1);
|
||||
continue;
|
||||
}
|
||||
#ifndef NETGRAPH
|
||||
m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
|
||||
#else /* NETGRAPH */
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
sc->inbytes += len;
|
||||
sc->inlast = 0;
|
||||
#endif /* NETGRAPH */
|
||||
m->m_pkthdr.len = m->m_len = len;
|
||||
if(len > MHLEN) {
|
||||
MCLGET(m, M_DONTWAIT);
|
||||
@ -1573,10 +1748,15 @@ ar_get_packets(struct ar_softc *sc)
|
||||
}
|
||||
}
|
||||
ar_copy_rxbuf(m, sc, len);
|
||||
#ifndef NETGRAPH
|
||||
if(sc->ifsppp.pp_if.if_bpf)
|
||||
bpf_mtap(&sc->ifsppp.pp_if, m);
|
||||
sppp_input(&sc->ifsppp.pp_if, m);
|
||||
sc->ifsppp.pp_if.if_ipackets++;
|
||||
#else /* NETGRAPH */
|
||||
ng_queue_data(sc->hook, m, NULL);
|
||||
sc->ipackets++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Update the eda to the previous descriptor.
|
||||
@ -1609,7 +1789,11 @@ ar_get_packets(struct ar_softc *sc)
|
||||
|
||||
ar_eat_packet(sc, 1);
|
||||
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[0]++;
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(sc->hc->iobase, sc->scano);
|
||||
@ -1678,8 +1862,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: TX DMA Counter overflow, "
|
||||
"txpacket no %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets);
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets);
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1688,11 +1877,19 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"txpacket no %lu, dsr %02x, "
|
||||
"cda %04x, eda %04x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_opackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->opackets,
|
||||
#endif /* NETGRAPH */
|
||||
dsr,
|
||||
dmac->cda,
|
||||
dmac->eda);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_oerrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->oerrors++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* End of Transfer */
|
||||
@ -1706,8 +1903,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* there is data to transmit.
|
||||
*/
|
||||
sc->xmit_busy = 0;
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
|
||||
sc->ifsppp.pp_if.if_timer = 0;
|
||||
#else /* NETGRAPH */
|
||||
/* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
|
||||
sc->out_dog = 0; /* XXX */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
if(sc->txb_inuse && --sc->txb_inuse)
|
||||
ar_xmit(sc);
|
||||
@ -1735,7 +1937,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
|
||||
ar_get_packets(sc);
|
||||
TRC(
|
||||
#ifndef NETGRAPH
|
||||
if(tt == sc->ifsppp.pp_if.if_ipackets) {
|
||||
#else /* NETGRAPH */
|
||||
if(tt == sc->ipackets) {
|
||||
#endif /* NETGRAPH */
|
||||
sca_descriptor *rxdesc;
|
||||
int i;
|
||||
|
||||
@ -1779,8 +1985,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
printf("ar%d: RX DMA Counter overflow, "
|
||||
"rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[1]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
|
||||
/* Buffer overflow */
|
||||
@ -1791,7 +2002,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
"rxpkts %lu, rxind %d, "
|
||||
"cda %x, eda %x, dsr %x.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets,
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets,
|
||||
#endif /* NETGRAPH */
|
||||
sc->rxhind,
|
||||
dmac->cda,
|
||||
dmac->eda,
|
||||
@ -1801,7 +2016,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
* Then get the system running again.
|
||||
*/
|
||||
ar_eat_packet(sc, 0);
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ierrors[2]++;
|
||||
#endif /* NETGRAPH */
|
||||
if(hc->bustype == AR_BUS_ISA)
|
||||
ARC_SET_SCA(hc->iobase, scano);
|
||||
sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
|
||||
@ -1829,8 +2048,13 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
*/
|
||||
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
|
||||
sc->unit,
|
||||
#ifndef NETGRAPH
|
||||
sc->ifsppp.pp_if.if_ipackets);
|
||||
sc->ifsppp.pp_if.if_ierrors++;
|
||||
#else /* NETGRAPH */
|
||||
sc->ipackets);
|
||||
sc->ierrors[3]++;
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
}
|
||||
|
||||
@ -1846,7 +2070,11 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
|
||||
for(mch = 0; mch < NCHAN; mch++) {
|
||||
if(dotxstart & 0x0C) {
|
||||
sc = &hc->sc[mch + (NCHAN * scano)];
|
||||
#ifndef NETGRAPH
|
||||
arstart(&sc->ifsppp.pp_if);
|
||||
#else /* NETGRAPH */
|
||||
arstart(sc);
|
||||
#endif /* NETGRAPH */
|
||||
}
|
||||
dotxstart >>= 4;
|
||||
}
|
||||
@ -1864,7 +2092,299 @@ ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
|
||||
printf("arc%d: ARINTR: TIMER\n", hc->cunit);
|
||||
}
|
||||
|
||||
|
||||
#ifdef NETGRAPH
|
||||
/*****************************************
|
||||
* Device timeout/watchdog routine.
|
||||
* called once per second.
|
||||
* checks to see that if activity was expected, that it hapenned.
|
||||
* At present we only look to see if expected output was completed.
|
||||
*/
|
||||
static void
|
||||
ngar_watchdog_frame(void * arg)
|
||||
{
|
||||
struct ar_softc * sc = arg;
|
||||
int s;
|
||||
int speed;
|
||||
|
||||
if(sc->running == 0)
|
||||
return; /* if we are not running let timeouts die */
|
||||
/*
|
||||
* calculate the apparent throughputs
|
||||
* XXX a real hack
|
||||
*/
|
||||
s = splimp();
|
||||
speed = sc->inbytes - sc->lastinbytes;
|
||||
sc->lastinbytes = sc->inbytes;
|
||||
if ( sc->inrate < speed )
|
||||
sc->inrate = speed;
|
||||
speed = sc->outbytes - sc->lastoutbytes;
|
||||
sc->lastoutbytes = sc->outbytes;
|
||||
if ( sc->outrate < speed )
|
||||
sc->outrate = speed;
|
||||
sc->inlast++;
|
||||
splx(s);
|
||||
|
||||
if ((sc->inlast > QUITE_A_WHILE)
|
||||
&& (sc->out_deficit > LOTS_OF_PACKETS)) {
|
||||
log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
splx(s);
|
||||
} else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
|
||||
if (sc->out_dog == 0) {
|
||||
log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
|
||||
sc->unit);
|
||||
arwatchdog(sc);
|
||||
#if 0
|
||||
s = splimp();
|
||||
ar_down(sc);
|
||||
ar_up(sc);
|
||||
splx(s);
|
||||
#endif
|
||||
sc->inlast = sc->out_deficit = 0;
|
||||
} else {
|
||||
sc->out_dog--;
|
||||
}
|
||||
}
|
||||
sc->handle = timeout(ngar_watchdog_frame, sc, hz);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* This section contains the methods for the Netgraph interface
|
||||
***********************************************************************/
|
||||
/*
|
||||
* It is not possible or allowable to create a node of this type.
|
||||
* If the hardware exists, it will already have created it.
|
||||
*/
|
||||
static int
|
||||
ngar_constructor(node_p *nodep)
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* give our ok for a hook to be added...
|
||||
* If we are not running this should kick the device into life.
|
||||
* We allow hooks called "control" and dlci[1-1023]
|
||||
* The hook's private info points to our stash of info about that
|
||||
* channel.
|
||||
*/
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for raw mode hook.
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* incoming messages.
|
||||
* Just respond to the generic TEXT_STATUS message
|
||||
*/
|
||||
static int
|
||||
ngar_rcvmsg(node_p node,
|
||||
struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
|
||||
{
|
||||
struct ar_softc * sc;
|
||||
int error = 0;
|
||||
|
||||
sc = node->private;
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
break;
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch(msg->header.cmd) {
|
||||
case NGM_TEXT_STATUS: {
|
||||
char *arg;
|
||||
int pos = 0;
|
||||
int resplen = sizeof(struct ng_mesg) + 512;
|
||||
MALLOC(*resp, struct ng_mesg *, resplen,
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (*resp == NULL) {
|
||||
error = ENOMEM;
|
||||
break;
|
||||
}
|
||||
bzero(*resp, resplen);
|
||||
arg = (*resp)->data;
|
||||
|
||||
/*
|
||||
* Put in the throughput information.
|
||||
*/
|
||||
pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
|
||||
"highest rate seen: %ld B/S in, %ld B/S out\n",
|
||||
sc->inbytes, sc->outbytes,
|
||||
sc->inrate, sc->outrate);
|
||||
pos += sprintf(arg + pos,
|
||||
"%ld output errors\n",
|
||||
sc->oerrors);
|
||||
pos += sprintf(arg + pos,
|
||||
"ierrors = %ld, %ld, %ld, %ld\n",
|
||||
sc->ierrors[0],
|
||||
sc->ierrors[1],
|
||||
sc->ierrors[2],
|
||||
sc->ierrors[3]);
|
||||
|
||||
(*resp)->header.version = NG_VERSION;
|
||||
(*resp)->header.arglen = strlen(arg) + 1;
|
||||
(*resp)->header.token = msg->header.token;
|
||||
(*resp)->header.typecookie = NG_AR_COOKIE;
|
||||
(*resp)->header.cmd = msg->header.cmd;
|
||||
strncpy((*resp)->header.cmdstr, "status",
|
||||
NG_CMDSTRLEN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
free(msg, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* get data from another node and transmit it to the correct channel
|
||||
*/
|
||||
static int
|
||||
ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ifqueue *xmitq_p;
|
||||
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now queue the data for when it can be sent
|
||||
*/
|
||||
if (meta && meta->priority > 0) {
|
||||
xmitq_p = (&sc->xmitq_hipri);
|
||||
} else {
|
||||
xmitq_p = (&sc->xmitq);
|
||||
}
|
||||
s = splimp();
|
||||
if (IF_QFULL(xmitq_p)) {
|
||||
IF_DROP(xmitq_p);
|
||||
splx(s);
|
||||
error = ENOBUFS;
|
||||
goto bad;
|
||||
}
|
||||
IF_ENQUEUE(xmitq_p, m);
|
||||
splx(s);
|
||||
arstart(sc);
|
||||
return (0);
|
||||
|
||||
bad:
|
||||
/*
|
||||
* It was an error case.
|
||||
* check if we need to free the mbuf, and then return the error
|
||||
*/
|
||||
NG_FREE_DATA(m, meta);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* do local shutdown processing..
|
||||
* this node will refuse to go away, unless the hardware says to..
|
||||
* don't unref the node, or remove our name. just clear our links up.
|
||||
*/
|
||||
static int
|
||||
ngar_rmnode(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
|
||||
ar_down(sc);
|
||||
ng_cutlinks(node);
|
||||
node->flags &= ~NG_INVALID; /* bounce back to life */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* already linked */
|
||||
static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* notify on hook disconnection (destruction)
|
||||
*
|
||||
* Invalidate the private data associated with this dlci.
|
||||
* For this type, removal of the last link resets tries to destroy the node.
|
||||
* As the device still exists, the shutdown method will not actually
|
||||
* destroy the node, but reset the device and leave it 'fresh' :)
|
||||
*
|
||||
* The node removal code will remove all references except that owned by the
|
||||
* driver.
|
||||
*/
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
ar_down(sc);
|
||||
splx(s);
|
||||
} else {
|
||||
sc->debug_hook = NULL;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* called during bootup
|
||||
* or LKM loading to put this type into the list of known modules
|
||||
*/
|
||||
static void
|
||||
ngar_init(void *ignored)
|
||||
{
|
||||
if (ng_newtype(&typestruct))
|
||||
printf("ngar install failed\n");
|
||||
ngar_done_init = 1;
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
********************************* END ************************************
|
||||
*/
|
||||
|
||||
|
23
sys/i386/isa/if_ar.h
Normal file
23
sys/i386/isa/if_ar.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* if_ar.h
|
||||
*
|
||||
* Copyright (C) 1997-1999 Whistle Communications Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _I386_ISA_IF_AR_H_
|
||||
#define _I386_ISA_IF_AR_H_
|
||||
|
||||
/* Node type name and type cookie */
|
||||
#define NG_AR_NODE_TYPE "sync_ar"
|
||||
#define NG_AR_COOKIE 860552149
|
||||
|
||||
/* Netgraph hooks */
|
||||
#define NG_AR_HOOK_DEBUG "debug"
|
||||
#define NG_AR_HOOK_CONTROL "control"
|
||||
#define NG_AR_HOOK_RAW "rawdata"
|
||||
|
||||
#endif /* _I386_ISA_IF_AR_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
23
sys/i386/isa/if_sr.h
Normal file
23
sys/i386/isa/if_sr.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* if_sr.h
|
||||
*
|
||||
* Copyright (C) 1997-1999 Whistle Communications Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _I386_ISA_IF_SR_H_
|
||||
#define _I386_ISA_IF_SR_H_
|
||||
|
||||
/* Node type name and type cookie */
|
||||
#define NG_SR_NODE_TYPE "sync_sr"
|
||||
#define NG_SR_COOKIE 860552148
|
||||
|
||||
/* Netgraph hooks */
|
||||
#define NG_SR_HOOK_DEBUG "debug"
|
||||
#define NG_SR_HOOK_CONTROL "control"
|
||||
#define NG_SR_HOOK_RAW "rawdata"
|
||||
|
||||
#endif /* _I386_ISA_IF_SR_H_ */
|
||||
|
@ -3,8 +3,8 @@
|
||||
# XXX present but broken: atapi ip_mroute_mod joy pcic
|
||||
|
||||
SUBDIR= aha al ax ccd cd9660 coda dm fdesc fxp if_disc if_ppp if_sl if_tun \
|
||||
ipfw kernfs md mfs mii msdos mx nfs ntfs nullfs pn portal procfs rl \
|
||||
sf sis sk ste ti tl umapfs union vn vr wb xl
|
||||
ipfw kernfs md mfs mii msdos mx netgraph nfs ntfs nullfs pn portal \
|
||||
procfs rl sf sis sk ste ti tl umapfs union vn vr wb xl
|
||||
|
||||
# XXX some of these can move to the general case when de-i386'ed
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.5 1999/01/24 06:48:37 archie Exp $
|
||||
# $Whistle: Makefile,v 1.5 1999/01/24 06:48:37 archie Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SUBDIR= async cisco echo frame_relay hole iface lmi netgraph ppp rfc1490 \
|
||||
|
7
sys/modules/netgraph/Makefile.inc
Normal file
7
sys/modules/netgraph/Makefile.inc
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile.inc,v 1.4 1999/01/19 23:46:16 archie Exp $
|
||||
|
||||
.PATH: ${.CURDIR}/../../../netgraph
|
||||
CFLAGS+= -Wall
|
||||
|
||||
.include "../Makefile.inc"
|
9
sys/modules/netgraph/UI/Makefile
Normal file
9
sys/modules/netgraph/UI/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:20 archie Exp $
|
||||
|
||||
KMOD= ng_UI
|
||||
SRCS= ng_UI.c
|
||||
MAN8= ng_UI.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
86
sys/modules/netgraph/UI/ng_UI.4
Normal file
86
sys/modules/netgraph/UI/ng_UI.4
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_UI.8,v 1.4 1999/01/25 02:37:56 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_UI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_UI
|
||||
.Nd UI netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_UI.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm UI
|
||||
node type has two hooks,
|
||||
.Dv upstream
|
||||
and
|
||||
.Dv downstream .
|
||||
Packets received on
|
||||
.Dv downstream
|
||||
must have 0x03 (indicating unnumbered information) as their first byte;
|
||||
if not the packet is dropped. This byte is then stripped and the
|
||||
remainder of the packet sent out on
|
||||
.Dv upstream .
|
||||
.Pp
|
||||
Conversely, packets received on
|
||||
.Dv upstream
|
||||
will have a 0x03 byte prepended to them before being forwarded out on the
|
||||
.Dv downstream
|
||||
hook.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
Downstream connection. Packets on this side of the node have a 0x03 as
|
||||
their first byte.
|
||||
.It Dv upstream
|
||||
Upstream connection. Packets on this side of the node have the
|
||||
initial 0x03 byte stripped off.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when both hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elischer <julian@whistle.com>
|
86
sys/modules/netgraph/UI/ng_UI.8
Normal file
86
sys/modules/netgraph/UI/ng_UI.8
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_UI.8,v 1.4 1999/01/25 02:37:56 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_UI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_UI
|
||||
.Nd UI netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_UI.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm UI
|
||||
node type has two hooks,
|
||||
.Dv upstream
|
||||
and
|
||||
.Dv downstream .
|
||||
Packets received on
|
||||
.Dv downstream
|
||||
must have 0x03 (indicating unnumbered information) as their first byte;
|
||||
if not the packet is dropped. This byte is then stripped and the
|
||||
remainder of the packet sent out on
|
||||
.Dv upstream .
|
||||
.Pp
|
||||
Conversely, packets received on
|
||||
.Dv upstream
|
||||
will have a 0x03 byte prepended to them before being forwarded out on the
|
||||
.Dv downstream
|
||||
hook.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
Downstream connection. Packets on this side of the node have a 0x03 as
|
||||
their first byte.
|
||||
.It Dv upstream
|
||||
Upstream connection. Packets on this side of the node have the
|
||||
initial 0x03 byte stripped off.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when both hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elischer <julian@whistle.com>
|
9
sys/modules/netgraph/async/Makefile
Normal file
9
sys/modules/netgraph/async/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:20 archie Exp $
|
||||
|
||||
KMOD= ng_async
|
||||
SRCS= ng_async.c
|
||||
MAN8= ng_async.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
160
sys/modules/netgraph/async/ng_async.4
Normal file
160
sys/modules/netgraph/async/ng_async.4
Normal file
@ -0,0 +1,160 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_async.8,v 1.6 1999/01/25 23:46:25 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ASYNC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_async
|
||||
.Nd asynchronous framing netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_async.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm async
|
||||
node type performs conversion between synchronous frames and
|
||||
asynchronous frames, as defined for the PPP protocol in RFC 1662.
|
||||
Asynchronous framing uses flag bytes and octet-stuffing
|
||||
to simulate a frame oriented connection over an octet-oriented
|
||||
asynchronous line.
|
||||
.Pp
|
||||
The node trasmits and receives asynchronous data on the
|
||||
.Dv async
|
||||
hook. Incoming data mbuf boundaries are ignored, while
|
||||
outgoing data is sent as a complete frame at a time.
|
||||
.Pp
|
||||
There are two synchronous hooks,
|
||||
.Dv sync
|
||||
and
|
||||
.Dv sync2 .
|
||||
For both hooks, received packets are encoded as asynchronous frames
|
||||
and sent out on
|
||||
.Dv async .
|
||||
Hook
|
||||
.Dv sync2
|
||||
differs from
|
||||
.Dv sync
|
||||
only in that any configured address and control field compression
|
||||
and/or control character escaping is disabled when the frame is encoded.
|
||||
This is useful for transmitting PPP LCP packets, which are always sent
|
||||
this way.
|
||||
.Pp
|
||||
This node supports ``flag sharing'' for packets transmitted on
|
||||
.Dv async .
|
||||
This is an optimization where the trailing flag byte
|
||||
of one frame is shared with the opening flag byte of the next.
|
||||
Flag sharing between frames is disabled after one second of transmit
|
||||
idle time.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv async
|
||||
Asynchronous connection.
|
||||
Typically this hook would be connected to a
|
||||
.Xr ng_tty 8
|
||||
node, which handles transmission of serial data over a tty device.
|
||||
.It Dv sync
|
||||
Synchronous connection. This hook sends and receives synchronous frames.
|
||||
For PPP, these frames contain no address, control, or checksum fields;
|
||||
each frame begins with the PPP protocol number. Typically this hook would
|
||||
be connected to the
|
||||
.Dv downstream
|
||||
hook of a
|
||||
.Xr ng_ppp 8
|
||||
type node.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_ASYNC_CMD_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_async_stat"
|
||||
containing node statistics for packet, octet, and error counts.
|
||||
.It Dv NGM_ASYNC_CMD_CLR_STATS
|
||||
Clears the node statistics.
|
||||
.It Dv NGM_ASYNC_CMD_SET_CONFIG
|
||||
Sets the node configuration, which is described by a
|
||||
.Dv "struct ng_async_cfg" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_async_cfg {
|
||||
u_char enabled; /* Turn encoding on/off */
|
||||
u_char acfcomp; /* Address/control field comp. */
|
||||
u_int16_t amru; /* Max receive async frame len */
|
||||
u_int16_t smru; /* Max receive sync frame len */
|
||||
u_int32_t accm; /* ACCM encoding */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dv enabled
|
||||
field enables or disables all encoding/decoding functions (default disabled).
|
||||
When disabled, the node operates in simple ``pass through'' mode. Setting
|
||||
.Dv acfcomp
|
||||
enables address and control field compression on transmission (for packets
|
||||
received on the
|
||||
.Dv sync
|
||||
hook only; default off).
|
||||
.Dv amru
|
||||
and
|
||||
.Dv smru
|
||||
are the asynchronous and synchronous MRU (maximum receive unit) values,
|
||||
respectively. These both default to 1600; note that the async MRU
|
||||
applies to the incoming frame length after asynchronous decoding.
|
||||
Finally,
|
||||
.Dv accm
|
||||
is the asynchronous character control map, which controls the escaping
|
||||
of characters 0x00 thorough 0x1f (default 0xffffffff).
|
||||
.It Dv NGM_ASYNC_CMD_GET_CONFIG
|
||||
This command returns the current configuration structure.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_tty 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in HDLC-link Framing"
|
||||
.%O RFC 1662
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
160
sys/modules/netgraph/async/ng_async.8
Normal file
160
sys/modules/netgraph/async/ng_async.8
Normal file
@ -0,0 +1,160 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_async.8,v 1.6 1999/01/25 23:46:25 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ASYNC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_async
|
||||
.Nd asynchronous framing netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_async.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm async
|
||||
node type performs conversion between synchronous frames and
|
||||
asynchronous frames, as defined for the PPP protocol in RFC 1662.
|
||||
Asynchronous framing uses flag bytes and octet-stuffing
|
||||
to simulate a frame oriented connection over an octet-oriented
|
||||
asynchronous line.
|
||||
.Pp
|
||||
The node trasmits and receives asynchronous data on the
|
||||
.Dv async
|
||||
hook. Incoming data mbuf boundaries are ignored, while
|
||||
outgoing data is sent as a complete frame at a time.
|
||||
.Pp
|
||||
There are two synchronous hooks,
|
||||
.Dv sync
|
||||
and
|
||||
.Dv sync2 .
|
||||
For both hooks, received packets are encoded as asynchronous frames
|
||||
and sent out on
|
||||
.Dv async .
|
||||
Hook
|
||||
.Dv sync2
|
||||
differs from
|
||||
.Dv sync
|
||||
only in that any configured address and control field compression
|
||||
and/or control character escaping is disabled when the frame is encoded.
|
||||
This is useful for transmitting PPP LCP packets, which are always sent
|
||||
this way.
|
||||
.Pp
|
||||
This node supports ``flag sharing'' for packets transmitted on
|
||||
.Dv async .
|
||||
This is an optimization where the trailing flag byte
|
||||
of one frame is shared with the opening flag byte of the next.
|
||||
Flag sharing between frames is disabled after one second of transmit
|
||||
idle time.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv async
|
||||
Asynchronous connection.
|
||||
Typically this hook would be connected to a
|
||||
.Xr ng_tty 8
|
||||
node, which handles transmission of serial data over a tty device.
|
||||
.It Dv sync
|
||||
Synchronous connection. This hook sends and receives synchronous frames.
|
||||
For PPP, these frames contain no address, control, or checksum fields;
|
||||
each frame begins with the PPP protocol number. Typically this hook would
|
||||
be connected to the
|
||||
.Dv downstream
|
||||
hook of a
|
||||
.Xr ng_ppp 8
|
||||
type node.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_ASYNC_CMD_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_async_stat"
|
||||
containing node statistics for packet, octet, and error counts.
|
||||
.It Dv NGM_ASYNC_CMD_CLR_STATS
|
||||
Clears the node statistics.
|
||||
.It Dv NGM_ASYNC_CMD_SET_CONFIG
|
||||
Sets the node configuration, which is described by a
|
||||
.Dv "struct ng_async_cfg" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_async_cfg {
|
||||
u_char enabled; /* Turn encoding on/off */
|
||||
u_char acfcomp; /* Address/control field comp. */
|
||||
u_int16_t amru; /* Max receive async frame len */
|
||||
u_int16_t smru; /* Max receive sync frame len */
|
||||
u_int32_t accm; /* ACCM encoding */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dv enabled
|
||||
field enables or disables all encoding/decoding functions (default disabled).
|
||||
When disabled, the node operates in simple ``pass through'' mode. Setting
|
||||
.Dv acfcomp
|
||||
enables address and control field compression on transmission (for packets
|
||||
received on the
|
||||
.Dv sync
|
||||
hook only; default off).
|
||||
.Dv amru
|
||||
and
|
||||
.Dv smru
|
||||
are the asynchronous and synchronous MRU (maximum receive unit) values,
|
||||
respectively. These both default to 1600; note that the async MRU
|
||||
applies to the incoming frame length after asynchronous decoding.
|
||||
Finally,
|
||||
.Dv accm
|
||||
is the asynchronous character control map, which controls the escaping
|
||||
of characters 0x00 thorough 0x1f (default 0xffffffff).
|
||||
.It Dv NGM_ASYNC_CMD_GET_CONFIG
|
||||
This command returns the current configuration structure.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_tty 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in HDLC-link Framing"
|
||||
.%O RFC 1662
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
35
sys/modules/netgraph/cisco/Makefile
Normal file
35
sys/modules/netgraph/cisco/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:20 archie Exp $
|
||||
|
||||
KMOD= ng_cisco
|
||||
SRCS= ng_cisco.c opt_inet.h opt_atalk.h opt_ipx.h
|
||||
MAN8= ng_cisco.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
IFACE_INET?= 1 # 0/1 - requires INET configured in kernel
|
||||
IFACE_NETATALK?= 0 # 0/1 - requires NETATALK configured in kernel
|
||||
IFACE_IPX?= 0 # 0/1 - requires IPX configured in kernel
|
||||
|
||||
CFLAGS+= ${PROTOS}
|
||||
|
||||
CLEANFILES+= opt_inet.h opt_atalk.h opt_ipx.h
|
||||
|
||||
opt_inet.h:
|
||||
touch opt_inet.h
|
||||
.if ${IFACE_INET} > 0
|
||||
echo "#define INET 1" > opt_inet.h
|
||||
.endif
|
||||
|
||||
opt_atalk.h:
|
||||
touch opt_atalk.h
|
||||
.if ${IFACE_NETATALK} > 0
|
||||
echo "#define NETATALK ${IFACE_NETATALK}" > opt_atalk.h
|
||||
.endif
|
||||
|
||||
opt_ipx.h:
|
||||
touch opt_ipx.h
|
||||
.if ${IFACE_IPX} > 0
|
||||
echo "#define IPX ${IFACE_IPX}" > opt_ipx.h
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
159
sys/modules/netgraph/cisco/ng_cisco.4
Normal file
159
sys/modules/netgraph/cisco/ng_cisco.4
Normal file
@ -0,0 +1,159 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_cisco.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_CISCO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_cisco
|
||||
.Nd Cisco HDLC protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_cisco.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm cisco
|
||||
node type performs encapsulation and de-encapsulation of packets
|
||||
using the Cisco HDLC protocol. This is a fairly simple
|
||||
protocol for the transmission of packets across
|
||||
high speed synchronous lines. Each packet is prepended with
|
||||
an Ethertype, indicating the protocol. There is also a
|
||||
``keep alive'' and an ``inquire'' capability.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should connect to the synchronous line. On the other side
|
||||
of the node are the
|
||||
.Dv inet ,
|
||||
.Dv atalk ,
|
||||
and
|
||||
.Dv ipx
|
||||
hooks, which transmit and receive raw IP, AppleTalk, and IPX packets,
|
||||
respectively. Typically these hooks would connect to the corresponding
|
||||
hooks on an
|
||||
.Xr ng_iface 8
|
||||
type node.
|
||||
.Sh IP Configuration
|
||||
In order to function properly for IP traffic, the node must be informed
|
||||
of the local IP address and netmask setting. This is because the protocol
|
||||
includes an ``inquire'' packet which we must be prepared to answer.
|
||||
There are two ways to acomplish this, manually and automatically.
|
||||
.Pp
|
||||
Whenever such an inquire packet is received, the node sends a
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
control message to the peer node connected to the
|
||||
.Dv inet
|
||||
hook (if any).
|
||||
If the peer responds, then that response is used. This is the automatic method.
|
||||
.Pp
|
||||
If the peer does not respond, the node falls back on its cached value
|
||||
for the IP address and netmask. This cached value can be set at any time
|
||||
with a
|
||||
.Dv NGM_CISCO_SET_IPADDR
|
||||
message, and this is the manual method.
|
||||
.Pp
|
||||
If the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node, as is usually the case, then configuration is automatic as the
|
||||
.Xr ng_iface 8
|
||||
understands the
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazio
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv inet
|
||||
IP hook.
|
||||
.It Dv atalk
|
||||
AppleTalk hook.
|
||||
.It Dv ipx
|
||||
IPX hook
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_CISCO_SET_IPADDR
|
||||
This command takes an array of two
|
||||
.Dv "struct in_addr"
|
||||
arguments. The first is the IP address of the corresponding interface
|
||||
and the second is the netmask.
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This command returns the IP configuration in the same format used by
|
||||
.Dv NGM_CISCO_SET_IPADDR .
|
||||
This command is also
|
||||
.Em sent
|
||||
by this node type to the
|
||||
.Dv inet
|
||||
peer whenever an IP address inquiry packet is received.
|
||||
.It Dv NGM_CISCO_GET_STATUS
|
||||
Returns a
|
||||
.Dv "struct ngciscostat" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ngciscostat {
|
||||
u_int32_t seq_retries; /* # unack'd retries */
|
||||
u_int32_t keepalive_period; /* in seconds */
|
||||
};
|
||||
.Ed
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of the functionality has been implemented. For example,
|
||||
the node does not support querying the remote end for its IP address
|
||||
and netmask.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A D. Perkins
|
||||
.%T "Requirements for an Internet Standard Point-to-Point Protocol"
|
||||
.%O RFC 1547
|
||||
.Re
|
||||
.Sh LEGAL
|
||||
Cisco is a trademark of Cisco Systems, Inc.
|
||||
.Sh AUTHORS
|
||||
Julian Elisher <julian@whistle.com>,
|
||||
Archie Cobbs <archie@whistle.com>
|
159
sys/modules/netgraph/cisco/ng_cisco.8
Normal file
159
sys/modules/netgraph/cisco/ng_cisco.8
Normal file
@ -0,0 +1,159 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_cisco.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_CISCO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_cisco
|
||||
.Nd Cisco HDLC protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_cisco.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm cisco
|
||||
node type performs encapsulation and de-encapsulation of packets
|
||||
using the Cisco HDLC protocol. This is a fairly simple
|
||||
protocol for the transmission of packets across
|
||||
high speed synchronous lines. Each packet is prepended with
|
||||
an Ethertype, indicating the protocol. There is also a
|
||||
``keep alive'' and an ``inquire'' capability.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should connect to the synchronous line. On the other side
|
||||
of the node are the
|
||||
.Dv inet ,
|
||||
.Dv atalk ,
|
||||
and
|
||||
.Dv ipx
|
||||
hooks, which transmit and receive raw IP, AppleTalk, and IPX packets,
|
||||
respectively. Typically these hooks would connect to the corresponding
|
||||
hooks on an
|
||||
.Xr ng_iface 8
|
||||
type node.
|
||||
.Sh IP Configuration
|
||||
In order to function properly for IP traffic, the node must be informed
|
||||
of the local IP address and netmask setting. This is because the protocol
|
||||
includes an ``inquire'' packet which we must be prepared to answer.
|
||||
There are two ways to acomplish this, manually and automatically.
|
||||
.Pp
|
||||
Whenever such an inquire packet is received, the node sends a
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
control message to the peer node connected to the
|
||||
.Dv inet
|
||||
hook (if any).
|
||||
If the peer responds, then that response is used. This is the automatic method.
|
||||
.Pp
|
||||
If the peer does not respond, the node falls back on its cached value
|
||||
for the IP address and netmask. This cached value can be set at any time
|
||||
with a
|
||||
.Dv NGM_CISCO_SET_IPADDR
|
||||
message, and this is the manual method.
|
||||
.Pp
|
||||
If the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node, as is usually the case, then configuration is automatic as the
|
||||
.Xr ng_iface 8
|
||||
understands the
|
||||
.Dv NGM_CISCO_GET_IPADDR
|
||||
message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazio
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv inet
|
||||
IP hook.
|
||||
.It Dv atalk
|
||||
AppleTalk hook.
|
||||
.It Dv ipx
|
||||
IPX hook
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_CISCO_SET_IPADDR
|
||||
This command takes an array of two
|
||||
.Dv "struct in_addr"
|
||||
arguments. The first is the IP address of the corresponding interface
|
||||
and the second is the netmask.
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This command returns the IP configuration in the same format used by
|
||||
.Dv NGM_CISCO_SET_IPADDR .
|
||||
This command is also
|
||||
.Em sent
|
||||
by this node type to the
|
||||
.Dv inet
|
||||
peer whenever an IP address inquiry packet is received.
|
||||
.It Dv NGM_CISCO_GET_STATUS
|
||||
Returns a
|
||||
.Dv "struct ngciscostat" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ngciscostat {
|
||||
u_int32_t seq_retries; /* # unack'd retries */
|
||||
u_int32_t keepalive_period; /* in seconds */
|
||||
};
|
||||
.Ed
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of the functionality has been implemented. For example,
|
||||
the node does not support querying the remote end for its IP address
|
||||
and netmask.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A D. Perkins
|
||||
.%T "Requirements for an Internet Standard Point-to-Point Protocol"
|
||||
.%O RFC 1547
|
||||
.Re
|
||||
.Sh LEGAL
|
||||
Cisco is a trademark of Cisco Systems, Inc.
|
||||
.Sh AUTHORS
|
||||
Julian Elisher <julian@whistle.com>,
|
||||
Archie Cobbs <archie@whistle.com>
|
9
sys/modules/netgraph/echo/Makefile
Normal file
9
sys/modules/netgraph/echo/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:20 archie Exp $
|
||||
|
||||
KMOD= ng_echo
|
||||
SRCS= ng_echo.c
|
||||
MAN8= ng_echo.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
67
sys/modules/netgraph/echo/ng_echo.4
Normal file
67
sys/modules/netgraph/echo/ng_echo.4
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_echo.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ECHO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_echo
|
||||
.Nd netgraph echo node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_echo.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm echo
|
||||
node type reflects all data and control messages back to the sender.
|
||||
This node type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Echo
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Any other control messages are reflected back to the sender.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_hole 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
67
sys/modules/netgraph/echo/ng_echo.8
Normal file
67
sys/modules/netgraph/echo/ng_echo.8
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_echo.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_ECHO 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_echo
|
||||
.Nd netgraph echo node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_echo.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm echo
|
||||
node type reflects all data and control messages back to the sender.
|
||||
This node type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Echo
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Any other control messages are reflected back to the sender.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_hole 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/frame_relay/Makefile
Normal file
9
sys/modules/netgraph/frame_relay/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.1 1999/01/19 19:39:21 archie Exp $
|
||||
|
||||
KMOD= ng_frame_relay
|
||||
SRCS= ng_frame_relay.c
|
||||
MAN8= ng_frame_relay.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
93
sys/modules/netgraph/frame_relay/ng_frame_relay.4
Normal file
93
sys/modules/netgraph/frame_relay/ng_frame_relay.4
Normal file
@ -0,0 +1,93 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_frame_relay.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_FRAME_RELAY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_frame_relay
|
||||
.Nd Frame relay netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_frame_relay.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type performs encapsulation, de-encapsulation, and multiplexing
|
||||
of packets using the frame relay protocol. It supports up to 1024 DLCI's.
|
||||
The LMI protocol is handled by a separate node type (see
|
||||
.Xr ng_lmi 8 ).
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should be connected to the synchronous line, i.e., the switch.
|
||||
Then hooks
|
||||
.Dv dlci0 ,
|
||||
.Dv dlci1 ,
|
||||
through
|
||||
.Dv dlci1023
|
||||
are available to connect to each of the DLCI channels.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv dlciX
|
||||
Here X is a decimal number from 0 to 1023. This hook corresponds
|
||||
to the DLCI X frame relay virtual channel.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Technically, frames on DLCI X should not be transmitted to the switch
|
||||
until the LMI protocol entity on both ends has configured DLCI X as active.
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type ignores this restriction, and will always pass data received
|
||||
on a DLCI hook to
|
||||
.Dv downstream .
|
||||
Instead, it should query the LMI node first.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_lmi 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
93
sys/modules/netgraph/frame_relay/ng_frame_relay.8
Normal file
93
sys/modules/netgraph/frame_relay/ng_frame_relay.8
Normal file
@ -0,0 +1,93 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_frame_relay.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_FRAME_RELAY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_frame_relay
|
||||
.Nd Frame relay netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_frame_relay.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type performs encapsulation, de-encapsulation, and multiplexing
|
||||
of packets using the frame relay protocol. It supports up to 1024 DLCI's.
|
||||
The LMI protocol is handled by a separate node type (see
|
||||
.Xr ng_lmi 8 ).
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook should be connected to the synchronous line, i.e., the switch.
|
||||
Then hooks
|
||||
.Dv dlci0 ,
|
||||
.Dv dlci1 ,
|
||||
through
|
||||
.Dv dlci1023
|
||||
are available to connect to each of the DLCI channels.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv downstream
|
||||
The connection to the synchronous line.
|
||||
.It Dv dlciX
|
||||
Here X is a decimal number from 0 to 1023. This hook corresponds
|
||||
to the DLCI X frame relay virtual channel.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Technically, frames on DLCI X should not be transmitted to the switch
|
||||
until the LMI protocol entity on both ends has configured DLCI X as active.
|
||||
The
|
||||
.Nm frame_relay
|
||||
node type ignores this restriction, and will always pass data received
|
||||
on a DLCI hook to
|
||||
.Dv downstream .
|
||||
Instead, it should query the LMI node first.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_lmi 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/hole/Makefile
Normal file
9
sys/modules/netgraph/hole/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:21 archie Exp $
|
||||
|
||||
KMOD= ng_hole
|
||||
SRCS= ng_hole.c
|
||||
MAN8= ng_hole.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
67
sys/modules/netgraph/hole/ng_hole.4
Normal file
67
sys/modules/netgraph/hole/ng_hole.4
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_hole.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_HOLE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_hole
|
||||
.Nd netgraph discard node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_hole.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm hole
|
||||
node type silently discards all data and control messages it receives.
|
||||
This type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Hole
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Other control messages are silently discarded.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_echo 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
67
sys/modules/netgraph/hole/ng_hole.8
Normal file
67
sys/modules/netgraph/hole/ng_hole.8
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_hole.8,v 1.4 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_HOLE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_hole
|
||||
.Nd netgraph discard node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_hole.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm hole
|
||||
node type silently discards all data and control messages it receives.
|
||||
This type is used for testing and debugging.
|
||||
.Sh HOOKS
|
||||
.Nm Hole
|
||||
nodes accept any request to connect, regardless of the hook name,
|
||||
as long as the name is unique.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
Other control messages are silently discarded.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_echo 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
39
sys/modules/netgraph/iface/Makefile
Normal file
39
sys/modules/netgraph/iface/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:21 archie Exp $
|
||||
|
||||
KMOD= ng_iface
|
||||
SRCS= ng_iface.c bpfilter.h opt_inet.h opt_atalk.h opt_ipx.h
|
||||
MAN8= ng_iface.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
IFACE_FILTER?= 0 # 0/1 - requires bpf configured in kernel
|
||||
IFACE_INET?= 1 # 0/1 - requires INET configured in kernel
|
||||
IFACE_NETATALK?= 0 # 0/1 - requires NETATALK configured in kernel
|
||||
IFACE_IPX?= 0 # 0/1 - requires IPX configured in kernel
|
||||
|
||||
CFLAGS+= ${PROTOS}
|
||||
|
||||
CLEANFILES+= bpfilter.h opt_inet.h opt_atalk.h opt_ipx.h
|
||||
|
||||
bpfilter.h:
|
||||
echo "#define NBPFILTER ${IFACE_FILTER}" > bpfilter.h
|
||||
|
||||
opt_inet.h:
|
||||
touch opt_inet.h
|
||||
.if ${IFACE_INET} > 0
|
||||
echo "#define INET 1" > opt_inet.h
|
||||
.endif
|
||||
|
||||
opt_atalk.h:
|
||||
touch opt_atalk.h
|
||||
.if ${IFACE_NETATALK} > 0
|
||||
echo "#define NETATALK ${IFACE_NETATALK}" > opt_atalk.h
|
||||
.endif
|
||||
|
||||
opt_ipx.h:
|
||||
touch opt_ipx.h
|
||||
.if ${IFACE_IPX} > 0
|
||||
echo "#define IPX ${IFACE_IPX}" > opt_ipx.h
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
126
sys/modules/netgraph/iface/ng_iface.4
Normal file
126
sys/modules/netgraph/iface/ng_iface.4
Normal file
@ -0,0 +1,126 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_iface.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_IFACE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_iface
|
||||
.Nd interface netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_iface.h>
|
||||
.Sh DESCRIPTION
|
||||
An
|
||||
.Nm iface
|
||||
node is both a netgraph node and a system networking interface. When an
|
||||
.Nm iface
|
||||
node is created, a new point-to-point interface appears which is accessible via
|
||||
.Xr ifconfig 8 .
|
||||
The new interfaces are named
|
||||
.Dv ng0 ,
|
||||
.Dv ng1 ,
|
||||
etc. The node is assigned the same name as its interface, unless the name
|
||||
already exists, in which case the node remains unnamed.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes have a single hook corresponding to each supported protocol.
|
||||
Packets transmitted via the interface flow out the corresponding
|
||||
protocol-specific hook.
|
||||
Similarly, packets received on a hook appear on the interface as
|
||||
packets received in the corresponding protocol.
|
||||
.Pp
|
||||
The currently supported protocols are IP, IPX, AppleTalk, and NS.
|
||||
In the KLD module, only support for IP is compiled in by default.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes support the Berkeley Packet Filter (BPF).
|
||||
In the KLD module, this support is disabled by default.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv inet
|
||||
Transmission and reception of IP packets.
|
||||
.It Dv ipx
|
||||
Transmission and reception of IPX packets.
|
||||
.It Dv atalk
|
||||
Transmission and reception of AppleTalk packets.
|
||||
.It Dv ns
|
||||
Transmission and reception of NS packets.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_IFACE_GET_IFNAME
|
||||
Returns the name of the interface corresponding to this node in a
|
||||
.Dv "struct ng_iface_ifname" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_iface_ifname {
|
||||
char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1];
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_IFACE_GET_IFADDRS
|
||||
Returns the list of addresses associated with this interface.
|
||||
The list is returned in the same format as the
|
||||
.Dv SIOCGIFCONF
|
||||
ioctl().
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This message is defined by the
|
||||
.Xr ng_cisco 8
|
||||
node type; see
|
||||
.Xr ng_cisco 8
|
||||
for a description.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
Because it is currenly not possible to remove a system networking
|
||||
interface in FreeBSD,
|
||||
.Nm iface
|
||||
nodes are
|
||||
.Em persistent.
|
||||
That is, once created they are never destroyed.
|
||||
The receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message disconnects all hooks but does not remove the node.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr bpf 4 ,
|
||||
.Xr ng_cisco 8 ,
|
||||
.Xr ng_rfc1490 8 ,
|
||||
.Xr ngctl 8 ,
|
||||
.Xr ifconfig 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
126
sys/modules/netgraph/iface/ng_iface.8
Normal file
126
sys/modules/netgraph/iface/ng_iface.8
Normal file
@ -0,0 +1,126 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_iface.8,v 1.5 1999/01/25 23:46:26 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_IFACE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_iface
|
||||
.Nd interface netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_iface.h>
|
||||
.Sh DESCRIPTION
|
||||
An
|
||||
.Nm iface
|
||||
node is both a netgraph node and a system networking interface. When an
|
||||
.Nm iface
|
||||
node is created, a new point-to-point interface appears which is accessible via
|
||||
.Xr ifconfig 8 .
|
||||
The new interfaces are named
|
||||
.Dv ng0 ,
|
||||
.Dv ng1 ,
|
||||
etc. The node is assigned the same name as its interface, unless the name
|
||||
already exists, in which case the node remains unnamed.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes have a single hook corresponding to each supported protocol.
|
||||
Packets transmitted via the interface flow out the corresponding
|
||||
protocol-specific hook.
|
||||
Similarly, packets received on a hook appear on the interface as
|
||||
packets received in the corresponding protocol.
|
||||
.Pp
|
||||
The currently supported protocols are IP, IPX, AppleTalk, and NS.
|
||||
In the KLD module, only support for IP is compiled in by default.
|
||||
.Pp
|
||||
.Nm Iface
|
||||
nodes support the Berkeley Packet Filter (BPF).
|
||||
In the KLD module, this support is disabled by default.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv inet
|
||||
Transmission and reception of IP packets.
|
||||
.It Dv ipx
|
||||
Transmission and reception of IPX packets.
|
||||
.It Dv atalk
|
||||
Transmission and reception of AppleTalk packets.
|
||||
.It Dv ns
|
||||
Transmission and reception of NS packets.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_IFACE_GET_IFNAME
|
||||
Returns the name of the interface corresponding to this node in a
|
||||
.Dv "struct ng_iface_ifname" :
|
||||
.Bd -literal -offset 4n
|
||||
struct ng_iface_ifname {
|
||||
char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1];
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_IFACE_GET_IFADDRS
|
||||
Returns the list of addresses associated with this interface.
|
||||
The list is returned in the same format as the
|
||||
.Dv SIOCGIFCONF
|
||||
ioctl().
|
||||
.It Dv NGM_CISCO_GET_IPADDR
|
||||
This message is defined by the
|
||||
.Xr ng_cisco 8
|
||||
node type; see
|
||||
.Xr ng_cisco 8
|
||||
for a description.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
Because it is currenly not possible to remove a system networking
|
||||
interface in FreeBSD,
|
||||
.Nm iface
|
||||
nodes are
|
||||
.Em persistent.
|
||||
That is, once created they are never destroyed.
|
||||
The receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message disconnects all hooks but does not remove the node.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr bpf 4 ,
|
||||
.Xr ng_cisco 8 ,
|
||||
.Xr ng_rfc1490 8 ,
|
||||
.Xr ngctl 8 ,
|
||||
.Xr ifconfig 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
9
sys/modules/netgraph/lmi/Makefile
Normal file
9
sys/modules/netgraph/lmi/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.1 1999/01/19 19:39:21 archie Exp $
|
||||
|
||||
KMOD= ng_lmi
|
||||
SRCS= ng_lmi.c
|
||||
MAN8= ng_lmi.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
130
sys/modules/netgraph/lmi/ng_lmi.4
Normal file
130
sys/modules/netgraph/lmi/ng_lmi.4
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
130
sys/modules/netgraph/lmi/ng_lmi.8
Normal file
130
sys/modules/netgraph/lmi/ng_lmi.8
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
8
sys/modules/netgraph/netgraph/Makefile
Normal file
8
sys/modules/netgraph/netgraph/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:22 archie Exp $
|
||||
|
||||
KMOD= netgraph
|
||||
SRCS= ng_base.c
|
||||
MAN4= netgraph.4
|
||||
|
||||
.include <bsd.kmod.mk>
|
876
sys/modules/netgraph/netgraph/netgraph.4
Normal file
876
sys/modules/netgraph/netgraph/netgraph.4
Normal file
@ -0,0 +1,876 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Authors: Julian Elischer <julian@whistle.com>
|
||||
.\" Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NETGRAPH 4
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm netgraph
|
||||
.Nd graph based kernel networking subsystem
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
system provides a uniform and modular system for the implementation
|
||||
of kernel objects which perform various networking functions. The objects,
|
||||
known as
|
||||
.Em nodes ,
|
||||
can be arranged into arbitrarily complicated graphs. Nodes have
|
||||
.Em hooks
|
||||
which are used to connect two nodes together, forming the edges in the graph.
|
||||
Nodes communicate along the edges to process data, implement protocols, etc.
|
||||
.Pp
|
||||
The aim of
|
||||
.Nm
|
||||
is to supplement rather than replace the existing kernel networking
|
||||
infrastructure. It provides:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
A flexible way of combining protocol and link level drivers
|
||||
.It
|
||||
A modular way to implement new protocols
|
||||
.It
|
||||
A common framework for kernel entities to inter-communicate
|
||||
.It
|
||||
A reasonably fast, kernel-based implementation
|
||||
.El
|
||||
.Sh Nodes and Types
|
||||
The most fundamental concept in
|
||||
.Nm
|
||||
is that of a
|
||||
.Em node .
|
||||
All nodes implement a number of predefined methods which allow them
|
||||
to interact with other nodes in a well defined manner.
|
||||
.Pp
|
||||
Each node has a
|
||||
.Em type ,
|
||||
which is a static property of the node determined at node creation time.
|
||||
A node's type is described by a unique ASCII type name.
|
||||
The type implies what the node does and how it may be connected
|
||||
to other nodes.
|
||||
.Pp
|
||||
In object-oriented language, types are classes and nodes are instances
|
||||
of their respective class. All node types are subclasses of the generic node
|
||||
type, and hence inherit certain common functionality and capabilities
|
||||
(e.g., the ability to have an ASCII name).
|
||||
.Pp
|
||||
Nodes may be assigned a globally unique ASCII name which can be
|
||||
used to refer to the node.
|
||||
The name must not contain the characters ``.'' or ``:'' and is limited to
|
||||
.Dv "NG_NODELEN + 1"
|
||||
characters (including NUL byte).
|
||||
.Pp
|
||||
Each node instance has a unique
|
||||
.Em ID number
|
||||
which is expressed as a 32-bit hex value. This value may be used to
|
||||
refer to a node when there is no ASCII name assigned to it.
|
||||
.Sh Hooks
|
||||
Nodes are connected to other nodes by connecting a pair of
|
||||
.Em hooks ,
|
||||
one from each node. Data flows bidirectionally between nodes along
|
||||
connected pairs of hooks. A node may have as many hooks as it
|
||||
needs, and may assign whatever meaning it wants to a hook.
|
||||
.Pp
|
||||
Hooks have these properties:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
A hook has an ASCII name which is unique among all hooks
|
||||
on that node (other hooks on other nodes may have the same name).
|
||||
The name must not contain a ``.'' or a ``:'' and is
|
||||
limited to
|
||||
.Dv "NG_HOOKLEN + 1"
|
||||
characters (including NUL byte).
|
||||
.It
|
||||
A hook is always connected to another hook. That is, hooks are
|
||||
created at the time they are connected, and breaking an edge by
|
||||
removing either hook destroys both hooks.
|
||||
.El
|
||||
.Pp
|
||||
A node may decide to assign special meaning to some hooks.
|
||||
For example, connecting to the hook named ``debug'' might trigger
|
||||
the node to start sending debugging information to that hook.
|
||||
.Sh Data Flow
|
||||
Two types of information flow between nodes: data messages and
|
||||
control messages. Data messages are passed in mbuf chains along the edges
|
||||
in the graph, one edge at a time. The first mbuf in a chain must have the
|
||||
.Dv M_PKTHDR
|
||||
flag set. Each node decides how to handle data coming in on its hooks.
|
||||
.Pp
|
||||
Control messages are type-specific structures sent from one node directly
|
||||
to an arbitrary other node. There are two ways to address such a message. If
|
||||
there is a sequence of edges connecting the two nodes, the message
|
||||
may be ``source routed'' by specifying the corresponding sequence
|
||||
of hooks as the destination address for the message (relative
|
||||
addressing). Otherwise, the recipient node global ASCII name
|
||||
(or equivalent ID based name) is used as the destination address
|
||||
for the message (absolute addressing). The two types of addressing
|
||||
may be combined, by specifying an absolute start node and a sequence
|
||||
of hooks.
|
||||
.Pp
|
||||
Messages often represent commands that are followed by a reply message
|
||||
in the reverse direction. To facilitate this, the recipient of a
|
||||
control message is supplied with a ``return address'' that is suitable
|
||||
for addressing a reply.
|
||||
.Pp
|
||||
Each control message contains a 32 bit value called a
|
||||
.Em typecookie
|
||||
indicating the type of the message, i.e., how to interpret it.
|
||||
Typically each type defines a unique typecookie for the messages
|
||||
that it understands. However, a node may choose to recognize and
|
||||
implement more than one type of message.
|
||||
.Sh Netgraph is Functional
|
||||
In order to minimize latency, most
|
||||
.Nm netgraph
|
||||
operations are functional.
|
||||
That is, data and control messages are delivered by making function
|
||||
calls rather than by using queues and mailboxes. For example, if node
|
||||
A wishes to send a data mbuf to neighboring node B, it calls the
|
||||
generic
|
||||
.Nm
|
||||
data delivery function. This function in turn locates
|
||||
node B and calls B's ``receive data'' method. While this mode of operation
|
||||
results in good performance, it has a few implications for node
|
||||
developers:
|
||||
.Pp
|
||||
.Bl -bullet -compact -offset 2n
|
||||
.It
|
||||
Whenever a node delivers a data or control message, the node
|
||||
may need to allow for the possibility of receiving a returning message
|
||||
before the original delivery function call returns.
|
||||
.It
|
||||
Netgraph nodes and support routines generally run at
|
||||
.Dv "splnet()" .
|
||||
However, some nodes may want to send data and control messages
|
||||
from a different priority level. Netgraph supplies queueing routines which
|
||||
utilize the NETISR system to move message delivery to
|
||||
.Dv "splnet()" .
|
||||
Note that messages are always received at
|
||||
.Dv "splnet()" .
|
||||
.It
|
||||
It's possible for an infinite loop to occur if the graph contains cycles.
|
||||
.El
|
||||
.Pp
|
||||
So far, these issues have not proven problematical in practice.
|
||||
.Sh Interaction With Other Parts of the Kernel
|
||||
A node may have a hidden interaction with other components of the
|
||||
kernel outside of the
|
||||
.Nm
|
||||
subsystem, such as device hardware,
|
||||
kernel protocol stacks, etc. In fact, one of the benefits of
|
||||
.Nm
|
||||
is the ability to join disparate kernel networking entities together in a
|
||||
consistent communication framework.
|
||||
.Pp
|
||||
An example is the node type
|
||||
.Em socket
|
||||
which is both a netgraph node and a
|
||||
.Xr socket 2
|
||||
BSD socket in the protocol family
|
||||
.Dv PF_NETGRAPH .
|
||||
Socket nodes allow user processes to participate in
|
||||
.Nm netgraph .
|
||||
Other nodes communicate with socket nodes using the usual methods, and the
|
||||
node hides the fact that it is also passing information to and from a
|
||||
cooperating user process.
|
||||
.Pp
|
||||
Another example is a device driver that presents
|
||||
a node interface to the hardware.
|
||||
.Sh Node Methods
|
||||
Nodes are notified of the following actions via function calls
|
||||
to the following node methods (all at
|
||||
.Dv "splnet()" )
|
||||
and may accept or reject that action (by returning the appropriate
|
||||
error code):
|
||||
.Bl -tag -width xxx
|
||||
.It Creation of a new node
|
||||
The constructor for the type is called. If creation of a new node is
|
||||
allowed, the constructor must call the generic node creation
|
||||
function (in object-oriented terms, the superclass constructor)
|
||||
and then allocate any special resources it needs. For nodes that
|
||||
correspond to hardware, this is typically done during the device
|
||||
attach routine. Often a global ASCII name corresponding to the
|
||||
device name is assigned here as well.
|
||||
.It Creation of a new hook
|
||||
The hook is created and tentatively
|
||||
linked to the node, and the node is told about the name that will be
|
||||
used to describe this hook. The node sets up any special data structures
|
||||
it needs, or may reject the connection, based on the name of the hook.
|
||||
.It Successful connection of two hooks
|
||||
After both ends have accepted their
|
||||
hooks, and the links have been made, the nodes get a chance to
|
||||
find out who their peer is across the link and can then decide to reject
|
||||
the connection. Tear-down is automatic.
|
||||
.It Destruction of a hook
|
||||
The node is notified of a broken connection. The node may consider some hooks
|
||||
to be critical to operation and others to be expendable: the disconnection
|
||||
of one hook may be an acceptable event while for another it
|
||||
may effect a total shutdown for the node.
|
||||
.It Shutdown of a node
|
||||
This method allows a node to clean up
|
||||
and to ensure that any actions that need to be performed
|
||||
at this time are taken. The method must call the generic (i.e., superclass)
|
||||
node destructor to get rid of the generic components of the node.
|
||||
Some nodes (usually associated with a piece of hardware) may be
|
||||
.Em persistent
|
||||
in that a shutdown breaks all edges and resets the node,
|
||||
but doesn't remove it, in which case the generic destructor is not called.
|
||||
.El
|
||||
.Sh Sending and Receiving Data
|
||||
Three other methods are also supported by all nodes:
|
||||
.Bl -tag -width xxx
|
||||
.It Receive data message
|
||||
An mbuf chain is passed to the node.
|
||||
The node is notified on which hook the data arrived,
|
||||
and can use this information in its processing decision.
|
||||
The node must must always
|
||||
.Dv m_freem()
|
||||
the mbuf chain on completion or error, or pass it on to another node
|
||||
(or kernel module) which will then be responsible for freeing it.
|
||||
.Pp
|
||||
In addition to the mbuf chain itself there is also a pointer to a
|
||||
structure describing meta-data about the message
|
||||
(e.g. priority information). This pointer may be
|
||||
.Dv NULL
|
||||
if there is no additional information. The format for this information is
|
||||
described in
|
||||
.Dv netgraph.h .
|
||||
The memory for meta-data must allocated via
|
||||
.Dv malloc()
|
||||
with type
|
||||
.Dv M_NETGRAPH .
|
||||
As with the data itself, it is the receiver's responsibility to
|
||||
.Dv free()
|
||||
the meta-data. If the mbuf chain is freed the meta-data must
|
||||
be freed at the same time. If the meta-data is freed but the
|
||||
real data on is passed on, then a
|
||||
.Dv NULL
|
||||
pointer must be substituted.
|
||||
.Pp
|
||||
The receiving node may decide to defer the data by queueing it in the
|
||||
.Nm
|
||||
NETISR system (see below).
|
||||
.Pp
|
||||
The structure and use of meta-data is still experimental, but is presently used in
|
||||
frame-relay to indicate that management packets should be queued for transmission
|
||||
at a higher priority than data packets. This is required for
|
||||
conformance with Frame Relay standards.
|
||||
.Pp
|
||||
.It Receive queued data message
|
||||
Usually this will be the same function as
|
||||
.Em Receive data message.
|
||||
This is the entry point called when a data message is being handed to
|
||||
the node after having been queued in the NETISR system.
|
||||
This allows a node to decide in the
|
||||
.Em Receive data message
|
||||
method that a message should be defered and queued,
|
||||
and be sure that when it is processed from the queue,
|
||||
it will not be queued again.
|
||||
.It Receive control message
|
||||
This method is called when a control message is addressed to the node.
|
||||
A return address is always supplied, giving the address of the node
|
||||
that originated the message so a reply message can be sent anytime later.
|
||||
.Pp
|
||||
It is possible for a synchronous reply to be made, and in fact this
|
||||
is more common in practice.
|
||||
This is done by setting a pointer (supplied as an extra function parameter)
|
||||
to point to the reply.
|
||||
Then when the control message delivery function returns,
|
||||
the caller can check if this pointer has been made non-NULL,
|
||||
and if so then it points to the reply message allocated via
|
||||
.Dv malloc()
|
||||
and containing the synchronous response. In both directions,
|
||||
(request and response) it is up to the
|
||||
receiver of that message to
|
||||
.Dv free()
|
||||
the control message buffer. All control messages and replies are
|
||||
allocated with
|
||||
.Dv malloc()
|
||||
type
|
||||
.Dv M_NETGRAPH .
|
||||
.El
|
||||
.Pp
|
||||
Much use has been made of reference counts, so that nodes being
|
||||
free'd of all references are automatically freed, and this behaviour
|
||||
has been tested and debugged to present a consistent and trustworthy
|
||||
framework for the ``type module'' writer to use.
|
||||
.Sh Addressing
|
||||
The
|
||||
.Nm
|
||||
framework provides an unambiguous and simple to use method of specifically
|
||||
addressing any single node in the graph. The naming of a node is
|
||||
independent of its type, in that another node, or external component
|
||||
need not know anything about the node's type in order to address it so as
|
||||
to send it a generic message type. Node and hook names should be
|
||||
chosen so as to make addresses meaningful.
|
||||
.Pp
|
||||
Addresses are either absolute or relative. An absolute address begins
|
||||
with a node name, (or ID), followed by a colon, followed by a sequence of hook
|
||||
names separated by periods. This addresses the node reached by starting
|
||||
at the named node and following the specified sequence of hooks.
|
||||
A relative address includes only the sequence of hook names, implicitly
|
||||
starting hook traversal at the local node.
|
||||
.Pp
|
||||
There are a couple of special possibilities for the node name.
|
||||
The name ``.'' (refered to as ``.:'') always refers to the local node.
|
||||
Also, nodes that have no global name may be addressed by their ID numbers,
|
||||
by enclosing the hex representation of the ID number within square brackets.
|
||||
Here are some examples of valid netgraph addresses:
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
.:
|
||||
foo:
|
||||
.:hook1
|
||||
foo:hook1.hook2
|
||||
[f057cd80]:hook1
|
||||
.Ed
|
||||
.Pp
|
||||
Consider the following set of nodes might be created for a site with
|
||||
a single physical frame relay line having two active logical DLCI channels,
|
||||
with RFC-1490 frames on DLCI 16 and PPP frames over DLCI 20:
|
||||
.Pp
|
||||
.Bd -literal
|
||||
[type SYNC ] [type FRAME] [type RFC1490]
|
||||
[ "Frame1" ](uplink)<-->(data)[<un-named>](dlci16)<-->(mux)[<un-named> ]
|
||||
[ A ] [ B ](dlci20)<---+ [ C ]
|
||||
|
|
||||
| [ type PPP ]
|
||||
+>(mux)[<un-named>]
|
||||
[ D ]
|
||||
.Ed
|
||||
.Pp
|
||||
One could always send a control message to node C from anywhere
|
||||
by using the name
|
||||
.Em "Frame1:uplink.dlci16" .
|
||||
Similarly,
|
||||
.Em "Frame1:uplink.dlci20"
|
||||
could reliably be used to reach node D, and node A could refer
|
||||
to node B as
|
||||
.Em ".:uplink" ,
|
||||
or simply
|
||||
.Em "uplink" .
|
||||
Conversely, B can refer to A as
|
||||
.Em "data" .
|
||||
The address
|
||||
.Em "mux.data"
|
||||
could be used by both nodes C and D to address a message to node A.
|
||||
.Pp
|
||||
Note that this is only for
|
||||
.Em control messages .
|
||||
Data messages are routed one hop at a time, by specifying the departing
|
||||
hook, with each node making the next routing decision. So when B
|
||||
receives a frame on hook
|
||||
.Em data
|
||||
it decodes the frame relay header to determine the DLCI,
|
||||
and then forwards the unwrapped frame to either C or D.
|
||||
.Pp
|
||||
A similar graph might be used to represent multi-link PPP running
|
||||
over an ISDN line:
|
||||
.Pp
|
||||
.Bd -literal
|
||||
[ type BRI ](B1)<--->(link1)[ type MPP ]
|
||||
[ "ISDN1" ](B2)<--->(link2)[ (no name) ]
|
||||
[ ](D) <-+
|
||||
|
|
||||
+----------------+
|
||||
|
|
||||
+->(switch)[ type Q.921 ](term1)<---->(datalink)[ type Q.931 ]
|
||||
[ (no name) ] [ (no name) ]
|
||||
.Ed
|
||||
.Sh Netgraph Structures
|
||||
Interesting members of the node and hook structures are shown below:
|
||||
.Bd -literal
|
||||
struct ng_node {
|
||||
char *name; /* Optional globally unique name */
|
||||
void *private; /* Node implementation private info */
|
||||
struct ng_type *type; /* The type of this node */
|
||||
int refs; /* Number of references to this struct */
|
||||
int numhooks; /* Number of connected hooks */
|
||||
hook_p hooks; /* Linked list of (connected) hooks */
|
||||
};
|
||||
typedef struct ng_node *node_p;
|
||||
|
||||
struct ng_hook {
|
||||
char *name; /* This node's name for this hook */
|
||||
void *private; /* Node implementation private info */
|
||||
int refs; /* Number of references to this struct */
|
||||
struct ng_node *node; /* The node this hook is attached to */
|
||||
struct ng_hook *peer; /* The other hook in this connected pair */
|
||||
struct ng_hook *next; /* Next in list of hooks for this node */
|
||||
};
|
||||
typedef struct ng_hook *hook_p;
|
||||
.Ed
|
||||
.Pp
|
||||
The maintenance of the name pointers, reference counts, and linked list
|
||||
of hooks for each node is handled automatically by the
|
||||
.Nm
|
||||
subsystem.
|
||||
Typically a node's private info contains a back-pointer to the node or hook
|
||||
structure, which counts as a new reference that must be registered by
|
||||
incrementing
|
||||
.Dv "node->refs" .
|
||||
.Pp
|
||||
From a hook you can obtain the corresponding node, and from
|
||||
a node the list of all active hooks.
|
||||
.Pp
|
||||
Node types are described by this structure:
|
||||
.Bd -literal
|
||||
struct ng_type {
|
||||
u_int32_t version; /* Must equal NG_VERSION */
|
||||
const char *name; /* Unique type name */
|
||||
|
||||
/* Module event handler */
|
||||
modeventhand_t mod_event; /* Handle load/unload (optional) */
|
||||
|
||||
/* Constructor */
|
||||
int (*constructor)(node_p *node); /* Create a new node */
|
||||
|
||||
/** Methods using the node **/
|
||||
int (*rcvmsg)(node_p node, /* Receive control message */
|
||||
struct ng_mesg *msg, /* The message */
|
||||
const char *retaddr, /* Return address */
|
||||
struct ng_mesg **resp); /* Synchronous response */
|
||||
int (*shutdown)(node_p node); /* Shutdown this node */
|
||||
int (*newhook)(node_p node, /* create a new hook */
|
||||
hook_p hook, /* Pre-allocated struct */
|
||||
const char *name); /* Name for new hook */
|
||||
|
||||
/** Methods using the hook **/
|
||||
int (*connect)(hook_p hook); /* Confirm new hook attachment */
|
||||
int (*rcvdata)(hook_p hook, /* Receive data on a hook */
|
||||
struct mbuf *m, /* The data in an mbuf */
|
||||
meta_p meta); /* Meta-data, if any */
|
||||
int (*disconnect)(hook_p hook); /* Notify disconnection of hook */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
Control messages have the following structure:
|
||||
.Bd -literal
|
||||
#define NG_CMDSTRLEN 15 /* Max command string (16 with null) */
|
||||
|
||||
struct ng_mesg {
|
||||
struct ng_msghdr {
|
||||
u_char version; /* Must equal NG_VERSION */
|
||||
u_char spare; /* Pad to 2 bytes */
|
||||
u_short arglen; /* Length of cmd/resp data */
|
||||
u_long flags; /* Message status flags */
|
||||
u_long token; /* Reply should have the same token */
|
||||
u_long typecookie; /* Node type understanding this message */
|
||||
u_long cmd; /* Command identifier */
|
||||
u_char cmdstr[NG_CMDSTRLEN+1]; /* Cmd string (for debug) */
|
||||
} header;
|
||||
char data[0]; /* Start of cmd/resp data */
|
||||
};
|
||||
|
||||
#define NG_VERSION 1 /* Netgraph version */
|
||||
#define NGF_ORIG 0x0000 /* Command */
|
||||
#define NGF_RESP 0x0001 /* Response */
|
||||
.Ed
|
||||
.Pp
|
||||
Control messages have the fixed header shown above, followed by a
|
||||
variable length data section which depends on the type cookie
|
||||
and the command. Each field is explained below:
|
||||
.Bl -tag -width xxx
|
||||
.It Dv version
|
||||
Indicates the version of netgraph itself. The current version is
|
||||
.Dv NG_VERSION .
|
||||
.It Dv arglen
|
||||
This is the length of any extra arguments, which begin at
|
||||
.Dv data .
|
||||
.It Dv flags
|
||||
Indicates whether this is a command or a response control message.
|
||||
.It Dv token
|
||||
The
|
||||
.Dv token
|
||||
is a means by which a sender can match a reply message to the
|
||||
corresponding command message; the reply always has the same token.
|
||||
.Pp
|
||||
.It Dv typecookie
|
||||
The corresponding node type's unique 32-bit value.
|
||||
If a node doesn't recognize the type cookie it must reject the message
|
||||
by returning
|
||||
.Er EINVAL .
|
||||
.Pp
|
||||
Each type should have an include file that defines the commands,
|
||||
argument format, and cookie for its own messages.
|
||||
The typecookie
|
||||
insures that the same header file was included by both sender and
|
||||
receiver; when an incompatible change in the header file is made,
|
||||
the typecookie
|
||||
.Em must
|
||||
be changed.
|
||||
The de facto method for generating unique type cookies is to take the
|
||||
seconds from the epoch at the time the header file is written
|
||||
(i.e., the output of
|
||||
.Dv "date -u +'%s'" ")."
|
||||
.Pp
|
||||
There is a predefined typecookie
|
||||
.Dv NGM_GENERIC_COOKIE
|
||||
for the ``generic'' node type, and
|
||||
a corresponding set of generic messages which all nodes understand.
|
||||
The handling of these messages is automatic.
|
||||
.It Dv command
|
||||
The identifier for the message command. This is type specific,
|
||||
and is defined in the same header file as the typecookie.
|
||||
.It Dv cmdstr
|
||||
Room for a short human readable version of ``command'' (for debugging
|
||||
purposes only).
|
||||
.El
|
||||
.Pp
|
||||
Some modules may choose to implement messages from more than one
|
||||
of the header files and thus recognize more than one type cookie.
|
||||
.Sh Generic Control Messages
|
||||
There are a number of standard predefined messages that will work
|
||||
for any node, as they are supported directly by the framework itself.
|
||||
These are defined in
|
||||
.Dv ng_message.h
|
||||
along with the basic layout of messages and other similar information.
|
||||
.Bl -tag -width xxx
|
||||
.It Dv NGM_CONNECT
|
||||
Connect to another node, using the supplied hook names on either end.
|
||||
.It Dv NGM_MKPEER
|
||||
Construct a node of the given type and then connect to it using the
|
||||
supplied hook names.
|
||||
.It Dv NGM_SHUTDOWN
|
||||
The target node should disconnect from all its neighbours and shut down.
|
||||
Persistent nodes such as those representing physical hardware
|
||||
might not dissappear from the node namespace, but only reset themselves.
|
||||
The node must disconnect all of its hooks.
|
||||
This may result in neighbors shutting themselves down, and possibly a
|
||||
cascading shutdown of the entire connected graph.
|
||||
.It Dv NGM_NAME
|
||||
Assign a name to a node. Nodes can exist without having a name, and this
|
||||
is the default for nodes created using the
|
||||
.Dv NGM_MKPEER
|
||||
method. Such nodes can only be addressed relatively or by their ID number.
|
||||
.It Dv NGM_RMHOOK
|
||||
Ask the node to break a hook connection to one of its neighbours.
|
||||
Both nodes will have their ``disconnect'' method invoked.
|
||||
Either node may elect to totally shut down as a result.
|
||||
.It Dv NGM_NODEINFO
|
||||
Asks the target node to describe itself. The four returned fields
|
||||
are the node name (if named), the node type, the node ID and the
|
||||
number of hooks attached. The ID is an internal number unique to that node.
|
||||
.It Dv NGM_LISTHOOKS
|
||||
This returns the information given by
|
||||
.Dv NGM_NODEINFO ,
|
||||
but in addition
|
||||
includes an array of fields describing each link, and the desription for
|
||||
the node at the far end of that link.
|
||||
.It Dv NGM_LISTNAMES
|
||||
This returns an array of node descriptions (as for
|
||||
.Dv NGM_NODEINFO ")"
|
||||
where each entry of the array describes a named node.
|
||||
All named nodes will be described.
|
||||
.It Dv NGM_LISTNODES
|
||||
This is the same as
|
||||
.Dv NGM_LISTNAMES
|
||||
except that all nodes are listed regardless of whether they have a name or not.
|
||||
.It Dv NGM_LISTTYPES
|
||||
This returns a list of all currently installed netgraph types.
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
The node may return a text formatted status message.
|
||||
The status information is determined entirely by the node type.
|
||||
It is the only "generic" message
|
||||
that requires any support within the node itself and as such the node may
|
||||
elect to not support this message. The text response must be less than
|
||||
.Dv NG_TEXTRESPONSE
|
||||
bytes in length (presently 1024). This can be used to return general
|
||||
status information in human readable form.
|
||||
.El
|
||||
.Sh Metadata
|
||||
Data moving through the
|
||||
.Nm
|
||||
system can be accompanied by meta-data that describes some
|
||||
aspect of that data. The form of the meta-data is a fixed header,
|
||||
which contains enough information for most uses, and can optionally
|
||||
be suplemented by trailing
|
||||
.Em option
|
||||
structures, which contain a
|
||||
.Em cookie
|
||||
(see the section on control messages), an identifier, a length and optional
|
||||
data. If a node does not recognize the cookie associated with an option,
|
||||
it should ignore that option.
|
||||
.Pp
|
||||
Meta data might include such things as priority, discard eligibility,
|
||||
or special processing requirements. It might also mark a packet for
|
||||
debug status, etc. The use of meta-data is still experimental.
|
||||
.Sh INITIALIZATION
|
||||
The base
|
||||
.Nm
|
||||
code may either be statically compiled
|
||||
into the kernel or else loaded dynamically as a KLD via
|
||||
.Xr kldload 8 .
|
||||
In the former case, include
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
options NETGRAPH
|
||||
|
||||
.Ed
|
||||
in your kernel configuration file. You may also include selected
|
||||
node types in the kernel compilation, for example:
|
||||
.Bd -literal -offset 4n -compact
|
||||
|
||||
options NETGRAPH
|
||||
options NETGRAPH_SOCKET
|
||||
options NETGRAPH_ECHO
|
||||
|
||||
.Ed
|
||||
.Pp
|
||||
Once the
|
||||
.Nm
|
||||
subsystem is loaded, individual node types may be loaded at any time
|
||||
as KLD modules via
|
||||
.Xr kldload 8 .
|
||||
Moreover,
|
||||
.Nm
|
||||
knows how to automatically do this; when a request to create a new
|
||||
node of unknown type
|
||||
.Em type
|
||||
is made,
|
||||
.Nm
|
||||
will attempt to load the KLD module
|
||||
.Dv ng_type.ko .
|
||||
.Pp
|
||||
Types can also be installed at boot time, as certain device drivers
|
||||
may want to export each instance of the device as a netgraph node.
|
||||
.Pp
|
||||
In general, new types can be installed at any time from within the
|
||||
kernel by calling
|
||||
.Dv ng_newtype() ,
|
||||
supplying a pointer to the type's
|
||||
.Dv struct ng_type
|
||||
structure.
|
||||
.Pp
|
||||
The
|
||||
.Dv "NETGRAPH_INIT()"
|
||||
macro automates this process by using a linker set.
|
||||
.Sh EXISTING NODE TYPES
|
||||
Several node types currently exist. Each is fully documented
|
||||
in its own man page:
|
||||
.Bl -tag -width xxx
|
||||
.It SOCKET
|
||||
The socket type implements two new sockets in the new protocol domain
|
||||
.Dv PF_NETGRAPH .
|
||||
The new sockets protocols are
|
||||
.Dv NG_DATA
|
||||
and
|
||||
.Dv NG_CONTROL ,
|
||||
both of type
|
||||
.Dv SOCK_DGRAM .
|
||||
Typically one of each is associated with a socket node.
|
||||
When both sockets have closed, the node will shut down. The
|
||||
.Dv NG_DATA
|
||||
socket is used for sending and receiving data, while the
|
||||
.Dv NG_CONTROL
|
||||
socket is used for sending and receiving control messages.
|
||||
Data and control messages are passed using the
|
||||
.Xr sendto 2
|
||||
and
|
||||
.Xr recvfrom 2
|
||||
calls, using a
|
||||
.Dv struct sockaddr_ng
|
||||
socket address.
|
||||
.Pp
|
||||
.It HOLE
|
||||
Responds only to generic messages and is a ``black hole'' for data,
|
||||
Useful for testing. Always accepts new hooks.
|
||||
.Pp
|
||||
.It ECHO
|
||||
Responds only to generic messages and always echoes data back through the
|
||||
hook from which it arrived. Returns any non generic messages as their
|
||||
own response. Useful for testing. Always accepts new hooks.
|
||||
.Pp
|
||||
.It TEE
|
||||
This node is useful for ``snooping.'' It has 4 hooks:
|
||||
.Dv left ,
|
||||
.Dv right ,
|
||||
.Dv left2right ,
|
||||
and
|
||||
.Dv right2left .
|
||||
Data entering from the right is passed to the left and duplicated on
|
||||
.Dv right2left,
|
||||
and data entering from the left is passed to the right and
|
||||
duplicated on
|
||||
.Dv left2right .
|
||||
Data entering from
|
||||
.Dv left2right
|
||||
is sent to the right and data from
|
||||
.Dv right2left
|
||||
to left.
|
||||
.Pp
|
||||
.It RFC1490 MUX
|
||||
Encapsulates/de-encapsulates frames encoded according to RFC 1490.
|
||||
Has a hook for the encapsulated packets (``downstream'') and one hook
|
||||
for each protocol (i.e., IP, PPP, etc.).
|
||||
.Pp
|
||||
.It FRAME RELAY MUX
|
||||
Encapsulates/de-encapsulates Frame Relay frames.
|
||||
Has a hook for the encapsulated packets (``downstream'') and one hook
|
||||
for each DLCI.
|
||||
.Pp
|
||||
.It FRAME RELAY LMI
|
||||
Automatically handles frame relay
|
||||
``LMI'' (link management interface) operations and packets.
|
||||
Automatically probes and detects whch of several LMI standards
|
||||
is in use at the exchange.
|
||||
.Pp
|
||||
.It TTY
|
||||
This node is also a line discipline. It simply converts between mbuf
|
||||
frames and sequential serial data, allowing a tty to appear as a netgraph
|
||||
node. It has a programmable ``hotkey'' character.
|
||||
.Pp
|
||||
.It ASYNC
|
||||
This node encapsulates and de-encapsulates asynchronous frames
|
||||
according to RFC 1662. This is used in conjunction with the TTY node
|
||||
type for supporting PPP links over asynchronous serial lines.
|
||||
.Pp
|
||||
.It INTERFACE
|
||||
This node is also a system networking interface. It has hooks representing
|
||||
each protocol family (IP, AppleTalk, IPX, etc.) and appears in the output of
|
||||
.Xr ifconfig 8 .
|
||||
The interfaces are named
|
||||
.Em ng0 ,
|
||||
.Em ng1 ,
|
||||
etc.
|
||||
.El
|
||||
.Sh NOTES
|
||||
Whether a named node exists can be checked by trying to send a control mesage
|
||||
to it (e.g.,
|
||||
.Dv NGM_NODEINFO
|
||||
).
|
||||
If it does not exist,
|
||||
.Er ENOENT
|
||||
will be returned.
|
||||
.Pp
|
||||
All data messages are mbuf chains with the M_PKTHDR flag set.
|
||||
.Pp
|
||||
Nodes are responsible for freeing what they allocate.
|
||||
There are three exceptions:
|
||||
.Bl -tag -width xxxx
|
||||
.It 1
|
||||
Mbufs sent across a data link are never to be freed by the sender.
|
||||
.It 2
|
||||
Any meta-data information travelling with the data has the same restriction.
|
||||
It might be freed by any node the data passes through, and a
|
||||
.Dv NULL
|
||||
passed onwards, but the caller will never free it.
|
||||
Two macros
|
||||
.Dv "NG_FREE_META(meta)"
|
||||
and
|
||||
.Dv "NG_FREE_DATA(m, meta)"
|
||||
should be used if possible to free data and meta data (see
|
||||
.Dv netgraph.h ")."
|
||||
.It 3
|
||||
Messages sent using
|
||||
.Dv ng_send_message()
|
||||
are freed by the callee. As in the case above, the addresses
|
||||
associated with the message are freed by whatever allocated them so the
|
||||
recipient should copy them if it wants to keep that information.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width xxxxx -compact
|
||||
.It Pa /sys/netgraph/netgraph.h
|
||||
Definitions for use soley within the kernel by
|
||||
.Nm
|
||||
nodes.
|
||||
.It Pa /sys/netgraph/ng_message.h
|
||||
Definitions needed by any file that needs to deal with
|
||||
.Nm
|
||||
messages.
|
||||
.It Pa /sys/netgraph/ng_socket.h
|
||||
Definitions needed to use
|
||||
.Nm
|
||||
socket type nodes.
|
||||
.It Pa /sys/netgraph/ng_{type}.h
|
||||
Definitions needed to use
|
||||
.Nm
|
||||
{type}
|
||||
nodes, including the type cookie definition.
|
||||
.It Pa /modules/netgraph.ko
|
||||
Netgraph subsystem loadable KLD module.
|
||||
.It Pa /modules/ng_{type}.ko
|
||||
Loadable KLD module for node type {type}.
|
||||
.El
|
||||
.Sh USER MODE SUPPORT
|
||||
There is a library for supporting user-mode programs that wish
|
||||
to interact with the netgraph system. See
|
||||
.Xr netgraph 3
|
||||
for details.
|
||||
.Pp
|
||||
Two user-mode support programs,
|
||||
.Xr ngctl 8
|
||||
and
|
||||
.Xr nghook 8 ,
|
||||
are available to assist manual configuration and debugging.
|
||||
.Pp
|
||||
There are a few useful techniques for debugging new node types.
|
||||
First, implementing new node types in user-mode first
|
||||
makes debugging easier.
|
||||
The
|
||||
.Em tee
|
||||
node type is also useful for debugging, especially in conjunction with
|
||||
.Xr ngctl 8
|
||||
and
|
||||
.Xr nghook 8 .
|
||||
.Sh SEE ALSO
|
||||
.Xr socket 2 ,
|
||||
.Xr netgraph 3 ,
|
||||
.Xr ngctl 8 ,
|
||||
.Xr nghook 8 ,
|
||||
.Xr ng_async 8 .
|
||||
.Xr ng_cisco 8 .
|
||||
.Xr ng_echo 8 .
|
||||
.Xr ng_frame_relay 8 .
|
||||
.Xr ng_hole 8 .
|
||||
.Xr ng_iface 8 .
|
||||
.Xr ng_lmi 8 .
|
||||
.Xr ng_rfc1490 8 .
|
||||
.Xr ng_socket 8 .
|
||||
.Xr ng_tee 8 .
|
||||
.Xr ng_tty 8 .
|
||||
.Xr ng_UI 8 .
|
||||
.Xr ng_{type} 8 .
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
system was designed and first implemented at Whistle Communications, Inc.
|
||||
in a version FreeBSD 2.2 customized for the Whistle InterJet.
|
||||
.Sh AUTHORS
|
||||
Julian Elischer <julian@whistle.com>, with contributions by
|
||||
Archie Cobbs <archie@whistle.com>.
|
9
sys/modules/netgraph/ppp/Makefile
Normal file
9
sys/modules/netgraph/ppp/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.1 1999/01/24 02:52:12 archie Exp $
|
||||
|
||||
KMOD= ng_ppp
|
||||
SRCS= ng_ppp.c
|
||||
MAN8= ng_ppp.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
164
sys/modules/netgraph/ppp/ng_ppp.4
Normal file
164
sys/modules/netgraph/ppp/ng_ppp.4
Normal file
@ -0,0 +1,164 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_ppp.8,v 1.3 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_PPP 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_ppp
|
||||
.Nd PPP protocol multiplexor negraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_ppp.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm ppp
|
||||
node type performs multiplexing for the PPP protocol. On the
|
||||
.Dv downstream
|
||||
hook it transmits and receives full PPP frames, which include the
|
||||
protocol field, but no address, control or checksum fields.
|
||||
On outgoing frames, when protocol compression has been enabled and
|
||||
the protocol number is suitable for compression, the protocol field will
|
||||
be compressed (i.e., sent as one byte instead of two).
|
||||
Either compressed or uncompressed protocol fields are accepted
|
||||
on incoming frames.
|
||||
.Pp
|
||||
For each 16-bit PPP procotol number there is a corresponding ``upstream'' hook.
|
||||
Packets on these hooks contain no PPP protocol header.
|
||||
The node simply multiplexes between the
|
||||
.Dv downstream
|
||||
hook and all of the upstream hooks by adding or subtracting the
|
||||
PPP protocol field, depending on the direction of flow.
|
||||
.Pp
|
||||
When a frame is received on
|
||||
.Dv downstream ,
|
||||
if the corresponding protocol hook is
|
||||
not connected, the packet is forwarded to a special upstream hook called
|
||||
.Dv bypass .
|
||||
This hook is a catch-all for any incoming frames not destined
|
||||
for another already connected hook. Packets sent out on the
|
||||
.Dv bypass
|
||||
hook always have the PPP protcol header prepended as the first
|
||||
two bytes (even if the
|
||||
original incoming frame was protocol compressed to one byte).
|
||||
.Pp
|
||||
Any frames received on the
|
||||
.Dv bypass
|
||||
hook are forwarded to
|
||||
.Dv downstream
|
||||
without modification.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv downstream
|
||||
Connection to the PPP link layer.
|
||||
.It Dv bypass
|
||||
Frames that do not correspond to a connected protocol hook;
|
||||
the PPP protocol header is included.
|
||||
.It Dv 0xNNNN
|
||||
Conection to the PPP protocol with 16-bit hex value
|
||||
.Dv NNNN .
|
||||
No PPP protocol header is included.
|
||||
.El
|
||||
.Pp
|
||||
For convenience, the
|
||||
.Nm
|
||||
node type defines several hook name aliases for common PPP protocols:
|
||||
.Pp
|
||||
.Bl -tag -width abcdefgh -compact -offset 4n
|
||||
.It Dv lcp
|
||||
LCP protocol data (0xc021)
|
||||
.It Dv ipcp
|
||||
IPCP protocol data (0x8021)
|
||||
.It Dv atcp
|
||||
ATCP protocol data (0x8029)
|
||||
.It Dv ccp
|
||||
CCP protocol data (0x80fd)
|
||||
.It Dv ecp
|
||||
ECP protocol data (0x8053)
|
||||
.It Dv ip
|
||||
IP protocol data (0x0021)
|
||||
.It Dv vjcomp
|
||||
Van Jacobsen compressed TCP data (0x002d)
|
||||
.It Dv vjuncomp
|
||||
Van Jacobsen uncompressed TCP data (0x002f)
|
||||
.It Dv mp
|
||||
Multi-link protocol data (0x003d)
|
||||
.It Dv compd
|
||||
Compressed protocol data (0x00fd)
|
||||
.It Dv cryptd
|
||||
Encrypted protocol data (0x0053)
|
||||
.It Dv pap
|
||||
PAP authentication protocol data (0xc023)
|
||||
.It Dv chap
|
||||
CHAP authentication protocol data (0xc223)
|
||||
.It Dv lqr
|
||||
LQR protocol data (0xc025)
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_PPP_SET_PROTOCOMP
|
||||
This command takes a single integer as argument and enables or disables
|
||||
protocol field compression as the value is zero or non-zero.
|
||||
Note that only protocols with high order byte equal to
|
||||
.Dv 0x00
|
||||
are compressible.
|
||||
.It Dv NGM_PPP_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_ppp_stat"
|
||||
containing various node statistics.
|
||||
.It Dv NGM_PPP_CLR_STATS
|
||||
Clears the node statistics. Statistics are also cleared whenever the
|
||||
.Dv downstream
|
||||
hook is reconnected.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ng_vjc 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "The Point-to-Point Protocol (PPP)"
|
||||
.%O RFC 1661
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
164
sys/modules/netgraph/ppp/ng_ppp.8
Normal file
164
sys/modules/netgraph/ppp/ng_ppp.8
Normal file
@ -0,0 +1,164 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_ppp.8,v 1.3 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_PPP 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_ppp
|
||||
.Nd PPP protocol multiplexor negraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_ppp.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm ppp
|
||||
node type performs multiplexing for the PPP protocol. On the
|
||||
.Dv downstream
|
||||
hook it transmits and receives full PPP frames, which include the
|
||||
protocol field, but no address, control or checksum fields.
|
||||
On outgoing frames, when protocol compression has been enabled and
|
||||
the protocol number is suitable for compression, the protocol field will
|
||||
be compressed (i.e., sent as one byte instead of two).
|
||||
Either compressed or uncompressed protocol fields are accepted
|
||||
on incoming frames.
|
||||
.Pp
|
||||
For each 16-bit PPP procotol number there is a corresponding ``upstream'' hook.
|
||||
Packets on these hooks contain no PPP protocol header.
|
||||
The node simply multiplexes between the
|
||||
.Dv downstream
|
||||
hook and all of the upstream hooks by adding or subtracting the
|
||||
PPP protocol field, depending on the direction of flow.
|
||||
.Pp
|
||||
When a frame is received on
|
||||
.Dv downstream ,
|
||||
if the corresponding protocol hook is
|
||||
not connected, the packet is forwarded to a special upstream hook called
|
||||
.Dv bypass .
|
||||
This hook is a catch-all for any incoming frames not destined
|
||||
for another already connected hook. Packets sent out on the
|
||||
.Dv bypass
|
||||
hook always have the PPP protcol header prepended as the first
|
||||
two bytes (even if the
|
||||
original incoming frame was protocol compressed to one byte).
|
||||
.Pp
|
||||
Any frames received on the
|
||||
.Dv bypass
|
||||
hook are forwarded to
|
||||
.Dv downstream
|
||||
without modification.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv downstream
|
||||
Connection to the PPP link layer.
|
||||
.It Dv bypass
|
||||
Frames that do not correspond to a connected protocol hook;
|
||||
the PPP protocol header is included.
|
||||
.It Dv 0xNNNN
|
||||
Conection to the PPP protocol with 16-bit hex value
|
||||
.Dv NNNN .
|
||||
No PPP protocol header is included.
|
||||
.El
|
||||
.Pp
|
||||
For convenience, the
|
||||
.Nm
|
||||
node type defines several hook name aliases for common PPP protocols:
|
||||
.Pp
|
||||
.Bl -tag -width abcdefgh -compact -offset 4n
|
||||
.It Dv lcp
|
||||
LCP protocol data (0xc021)
|
||||
.It Dv ipcp
|
||||
IPCP protocol data (0x8021)
|
||||
.It Dv atcp
|
||||
ATCP protocol data (0x8029)
|
||||
.It Dv ccp
|
||||
CCP protocol data (0x80fd)
|
||||
.It Dv ecp
|
||||
ECP protocol data (0x8053)
|
||||
.It Dv ip
|
||||
IP protocol data (0x0021)
|
||||
.It Dv vjcomp
|
||||
Van Jacobsen compressed TCP data (0x002d)
|
||||
.It Dv vjuncomp
|
||||
Van Jacobsen uncompressed TCP data (0x002f)
|
||||
.It Dv mp
|
||||
Multi-link protocol data (0x003d)
|
||||
.It Dv compd
|
||||
Compressed protocol data (0x00fd)
|
||||
.It Dv cryptd
|
||||
Encrypted protocol data (0x0053)
|
||||
.It Dv pap
|
||||
PAP authentication protocol data (0xc023)
|
||||
.It Dv chap
|
||||
CHAP authentication protocol data (0xc223)
|
||||
.It Dv lqr
|
||||
LQR protocol data (0xc025)
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_PPP_SET_PROTOCOMP
|
||||
This command takes a single integer as argument and enables or disables
|
||||
protocol field compression as the value is zero or non-zero.
|
||||
Note that only protocols with high order byte equal to
|
||||
.Dv 0x00
|
||||
are compressible.
|
||||
.It Dv NGM_PPP_GET_STATS
|
||||
This command returns a
|
||||
.Dv "struct ng_ppp_stat"
|
||||
containing various node statistics.
|
||||
.It Dv NGM_PPP_CLR_STATS
|
||||
Clears the node statistics. Statistics are also cleared whenever the
|
||||
.Dv downstream
|
||||
hook is reconnected.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ng_vjc 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "The Point-to-Point Protocol (PPP)"
|
||||
.%O RFC 1661
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
9
sys/modules/netgraph/pppoe/Makefile
Normal file
9
sys/modules/netgraph/pppoe/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.1 1999/01/19 19:39:21 archie Exp $
|
||||
|
||||
KMOD= ng_pppoe
|
||||
SRCS= ng_pppoe.c
|
||||
MAN8= ng_pppoe.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
130
sys/modules/netgraph/pppoe/ng_pppoe.4
Normal file
130
sys/modules/netgraph/pppoe/ng_pppoe.4
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
130
sys/modules/netgraph/pppoe/ng_pppoe.8
Normal file
130
sys/modules/netgraph/pppoe/ng_pppoe.8
Normal file
@ -0,0 +1,130 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_LMI 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_lmi
|
||||
.Nd Frame relay LMI protocol netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_lmi.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm lmi
|
||||
node type performs the frame relay LMI protocol. It supports
|
||||
the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
|
||||
It also supports auto-detection of the LMI type.
|
||||
.Pp
|
||||
To enable a specific LMI type, connect the corresponding hook (
|
||||
.Dv annexA ,
|
||||
.Dv annexD ,
|
||||
or
|
||||
.Dv group4 ")"
|
||||
to DLCI 0 or 1023 of a
|
||||
.Xr ng_frame_relay 8
|
||||
node.
|
||||
Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
|
||||
lives on DLCI 1023.
|
||||
.Pp
|
||||
To enable LMI type auto-detection, connect the
|
||||
.Dv auto0
|
||||
hook to DLCI 0 and the
|
||||
.Dv auto1023
|
||||
hook to DLCI 1023. The node will attempt to automatically determine
|
||||
which LMI type is running at the switch, and go into that mode.
|
||||
.Pp
|
||||
Only one fixed LMI type, or auto-detection, can be active at any given time.
|
||||
.Pp
|
||||
The
|
||||
.Dv NGM_LMI_GET_STATUS
|
||||
control message can be used at any time to query the current status
|
||||
of the LMI protocol and each DLCI channel. This node also supports the
|
||||
.Dv NGM_TEXT_STATUS
|
||||
control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbaz
|
||||
.It Dv annexA
|
||||
ITU Annex A LMI hook.
|
||||
.It Dv annexD
|
||||
ANSI Annex D LMI hook.
|
||||
.It Dv group4
|
||||
Group-of-four LMI hook.
|
||||
.It Dv auto0
|
||||
Auto-detection hook for DLCI 0.
|
||||
.It Dv auto1023
|
||||
Auto-detection hook for DLCI 1023.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_LMI_GET_STATUS
|
||||
This command returns status information in a
|
||||
.Dv "struct nglmistat" :
|
||||
.Bd -literal -offset 4n
|
||||
#define NGM_LMI_STAT_ARYSIZE (1024/8)
|
||||
|
||||
struct nglmistat {
|
||||
u_char proto[12]; /* Active proto (same as hook name) */
|
||||
u_char hook[12]; /* Active hook */
|
||||
u_char fixed; /* If set to fixed LMI mode */
|
||||
u_char autod; /* If currently auto-detecting */
|
||||
u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
|
||||
u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
|
||||
};
|
||||
.Ed
|
||||
.It Dv NGM_TEXT_STATUS
|
||||
This generic message returns is a human-readable version of the node status.
|
||||
.El
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%T "ANSI T1.617-1991 Annex D"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "ITU-T Q.933 Digital Subscriber Signalling System No. 1 - Signalling Specification for Frame Mode Basic Call Control, Annex A"
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/rfc1490/Makefile
Normal file
9
sys/modules/netgraph/rfc1490/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:22 archie Exp $
|
||||
|
||||
KMOD= ng_rfc1490
|
||||
SRCS= ng_rfc1490.c
|
||||
MAN8= ng_rfc1490.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
109
sys/modules/netgraph/rfc1490/ng_rfc1490.4
Normal file
109
sys/modules/netgraph/rfc1490/ng_rfc1490.4
Normal file
@ -0,0 +1,109 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_rfc1490.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_RFC1490 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_rfc1490
|
||||
.Nd RFC 1490 netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_rfc1490.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm rfc1490
|
||||
node type performs protocol encapsulation, de-encapsulation, and
|
||||
multiplexing according to RFC 1490 (which has since been updated by RFC 2427).
|
||||
This particular type of encapsulation is often used on top of frame relay
|
||||
DLCI channels.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook is used to transmit and receive encapsulated frames. On the other
|
||||
side of the node, the
|
||||
.Dv inet
|
||||
and
|
||||
.Dv ppp
|
||||
hooks are used to transmit and receive raw IP frames and PPP frames,
|
||||
respectively. PPP frames are transmitted and received according to
|
||||
RFC 1973; in particular, frames appearing on the
|
||||
.Dv ppp
|
||||
hook begin with the PPP protocol number.
|
||||
.Pp
|
||||
Typically the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazum
|
||||
.It Dv downstream
|
||||
Connects to the RFC 1490 peer entity.
|
||||
.It Dv inet
|
||||
Transmits and receives raw IP frames.
|
||||
.It Dv ppp
|
||||
Transmits and receives PPP frames.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type only supports the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of RFC 1490 is implemented.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A C. Brown, A. Malis
|
||||
.%T "Multiprotocol Interconnect over Frame Relay"
|
||||
.%O RFC 2427
|
||||
.Re
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in Frame Relay"
|
||||
.%O RFC 1973
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
109
sys/modules/netgraph/rfc1490/ng_rfc1490.8
Normal file
109
sys/modules/netgraph/rfc1490/ng_rfc1490.8
Normal file
@ -0,0 +1,109 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_rfc1490.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_RFC1490 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_rfc1490
|
||||
.Nd RFC 1490 netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_rfc1490.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm rfc1490
|
||||
node type performs protocol encapsulation, de-encapsulation, and
|
||||
multiplexing according to RFC 1490 (which has since been updated by RFC 2427).
|
||||
This particular type of encapsulation is often used on top of frame relay
|
||||
DLCI channels.
|
||||
.Pp
|
||||
The
|
||||
.Dv downstream
|
||||
hook is used to transmit and receive encapsulated frames. On the other
|
||||
side of the node, the
|
||||
.Dv inet
|
||||
and
|
||||
.Dv ppp
|
||||
hooks are used to transmit and receive raw IP frames and PPP frames,
|
||||
respectively. PPP frames are transmitted and received according to
|
||||
RFC 1973; in particular, frames appearing on the
|
||||
.Dv ppp
|
||||
hook begin with the PPP protocol number.
|
||||
.Pp
|
||||
Typically the
|
||||
.Dv inet
|
||||
hook is connected to the
|
||||
.Dv inet
|
||||
hook of an
|
||||
.Xr ng_iface 8
|
||||
node.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazum
|
||||
.It Dv downstream
|
||||
Connects to the RFC 1490 peer entity.
|
||||
.It Dv inet
|
||||
Transmits and receives raw IP frames.
|
||||
.It Dv ppp
|
||||
Transmits and receives PPP frames.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type only supports the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
Not all of RFC 1490 is implemented.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_frame_relay 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A C. Brown, A. Malis
|
||||
.%T "Multiprotocol Interconnect over Frame Relay"
|
||||
.%O RFC 2427
|
||||
.Re
|
||||
.Rs
|
||||
.%A W. Simpson
|
||||
.%T "PPP in Frame Relay"
|
||||
.%O RFC 1973
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/socket/Makefile
Normal file
9
sys/modules/netgraph/socket/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:22 archie Exp $
|
||||
|
||||
KMOD= ng_socket
|
||||
SRCS= ng_socket.c
|
||||
MAN8= ng_socket.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
127
sys/modules/netgraph/socket/ng_socket.4
Normal file
127
sys/modules/netgraph/socket/ng_socket.4
Normal file
@ -0,0 +1,127 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_SOCKET 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_socket
|
||||
.Nd netgraph socket node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_socket.h>
|
||||
.Sh DESCRIPTION
|
||||
A
|
||||
.Nm socket
|
||||
node is both a BSD socket and a netgraph node. The
|
||||
.Nm socket
|
||||
node type allows user-mode processes to participate in the kernel
|
||||
.Xr netgraph 4
|
||||
networking subsystem using the BSD socket interface.
|
||||
.Pp
|
||||
A new
|
||||
.Nm socket
|
||||
node is created by creating a new socket of type
|
||||
.Dv NG_CONTROL
|
||||
in the protocol family
|
||||
.Dv PF_NETGRAPH ,
|
||||
using the
|
||||
.Xr socket 2
|
||||
system call.
|
||||
Any control messages received by the node are received using
|
||||
.Xr recvfrom 2 ;
|
||||
the socket address argument is a
|
||||
.Dv "struct sockaddr_ng"
|
||||
containing the sender's netgraph address. Conversely, control messages
|
||||
can be sent to any node by calling
|
||||
.Xr sendto 2 ,
|
||||
supplying the recipient's address in a
|
||||
.Dv "struct sockaddr_ng" .
|
||||
The
|
||||
.Xr bind 2
|
||||
system call may be used to assign a global netgraph name to the node.
|
||||
.Pp
|
||||
To transmit and receive netgraph data packets, a
|
||||
.Dv NG_DATA
|
||||
socket must also be created using
|
||||
.Xr socket 2
|
||||
and associated with a
|
||||
.Nm socket
|
||||
node.
|
||||
.Dv NG_DATA sockets do not automatically
|
||||
have nodes associated with them; they are bound to a specific node via the
|
||||
.Xr connect 2
|
||||
system call. The address argument is the netgraph address of the
|
||||
.Nm socket
|
||||
node already created. Once a data socket is associated with a node,
|
||||
any data packets received by the node are read using
|
||||
.Xr recvfrom 2
|
||||
and any packets to be sent out from the node are written using
|
||||
.Xr sendto 2 .
|
||||
In the case of data sockets, the
|
||||
.Dv "struct sockaddr_ng"
|
||||
contains the name of the
|
||||
.Em hook
|
||||
on which the data was received or should be sent.
|
||||
.Pp
|
||||
There is a user library that simplifies using netgraph sockets; see
|
||||
.Xr netgraph 3 .
|
||||
.Sh HOOKS
|
||||
This node type supports hooks with arbitrary names (as long as
|
||||
they are unique) and always accepts hook connection requests.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node type shuts down and disappears when both the associated
|
||||
.Dv NG_CONTROL
|
||||
and
|
||||
.Dv NG_DATA
|
||||
sockets have been closed, or a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is received. In the latter case, attempts to write
|
||||
to the still-open sockets will return
|
||||
.Er ENOTCONN .
|
||||
.Sh BUGS
|
||||
It is not possible to reject the connection of a hook, though any
|
||||
data received on that hook can certainly be ignored.
|
||||
.Sh SEE ALSO
|
||||
.Xr socket 2 ,
|
||||
.Xr netgraph 3 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
127
sys/modules/netgraph/socket/ng_socket.8
Normal file
127
sys/modules/netgraph/socket/ng_socket.8
Normal file
@ -0,0 +1,127 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_SOCKET 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_socket
|
||||
.Nd netgraph socket node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_socket.h>
|
||||
.Sh DESCRIPTION
|
||||
A
|
||||
.Nm socket
|
||||
node is both a BSD socket and a netgraph node. The
|
||||
.Nm socket
|
||||
node type allows user-mode processes to participate in the kernel
|
||||
.Xr netgraph 4
|
||||
networking subsystem using the BSD socket interface.
|
||||
.Pp
|
||||
A new
|
||||
.Nm socket
|
||||
node is created by creating a new socket of type
|
||||
.Dv NG_CONTROL
|
||||
in the protocol family
|
||||
.Dv PF_NETGRAPH ,
|
||||
using the
|
||||
.Xr socket 2
|
||||
system call.
|
||||
Any control messages received by the node are received using
|
||||
.Xr recvfrom 2 ;
|
||||
the socket address argument is a
|
||||
.Dv "struct sockaddr_ng"
|
||||
containing the sender's netgraph address. Conversely, control messages
|
||||
can be sent to any node by calling
|
||||
.Xr sendto 2 ,
|
||||
supplying the recipient's address in a
|
||||
.Dv "struct sockaddr_ng" .
|
||||
The
|
||||
.Xr bind 2
|
||||
system call may be used to assign a global netgraph name to the node.
|
||||
.Pp
|
||||
To transmit and receive netgraph data packets, a
|
||||
.Dv NG_DATA
|
||||
socket must also be created using
|
||||
.Xr socket 2
|
||||
and associated with a
|
||||
.Nm socket
|
||||
node.
|
||||
.Dv NG_DATA sockets do not automatically
|
||||
have nodes associated with them; they are bound to a specific node via the
|
||||
.Xr connect 2
|
||||
system call. The address argument is the netgraph address of the
|
||||
.Nm socket
|
||||
node already created. Once a data socket is associated with a node,
|
||||
any data packets received by the node are read using
|
||||
.Xr recvfrom 2
|
||||
and any packets to be sent out from the node are written using
|
||||
.Xr sendto 2 .
|
||||
In the case of data sockets, the
|
||||
.Dv "struct sockaddr_ng"
|
||||
contains the name of the
|
||||
.Em hook
|
||||
on which the data was received or should be sent.
|
||||
.Pp
|
||||
There is a user library that simplifies using netgraph sockets; see
|
||||
.Xr netgraph 3 .
|
||||
.Sh HOOKS
|
||||
This node type supports hooks with arbitrary names (as long as
|
||||
they are unique) and always accepts hook connection requests.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node type shuts down and disappears when both the associated
|
||||
.Dv NG_CONTROL
|
||||
and
|
||||
.Dv NG_DATA
|
||||
sockets have been closed, or a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is received. In the latter case, attempts to write
|
||||
to the still-open sockets will return
|
||||
.Er ENOTCONN .
|
||||
.Sh BUGS
|
||||
It is not possible to reject the connection of a hook, though any
|
||||
data received on that hook can certainly be ignored.
|
||||
.Sh SEE ALSO
|
||||
.Xr socket 2 ,
|
||||
.Xr netgraph 3 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/tee/Makefile
Normal file
9
sys/modules/netgraph/tee/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:22 archie Exp $
|
||||
|
||||
KMOD= ng_tee
|
||||
SRCS= ng_tee.c
|
||||
MAN8= ng_tee.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
110
sys/modules/netgraph/tee/ng_tee.4
Normal file
110
sys/modules/netgraph/tee/ng_tee.4
Normal file
@ -0,0 +1,110 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tee.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TEE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tee
|
||||
.Nd netgraph ``tee'' node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_tee.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tee
|
||||
node type has a purpose similar to the
|
||||
.Xr tee 1
|
||||
command.
|
||||
.Nm Tee
|
||||
nodes are useful for debugging or ``snooping'' on a connection
|
||||
between two netgraph nodes.
|
||||
.Nm Tee
|
||||
nodes have four hooks,
|
||||
.Dv right ,
|
||||
.Dv left ,
|
||||
.Dv right2left ,
|
||||
and
|
||||
.Dv left2right .
|
||||
All data received on
|
||||
.Dv right
|
||||
is sent unmodified to
|
||||
.Em both
|
||||
hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right2left .
|
||||
Similarly, all data received on
|
||||
.Dv left
|
||||
is sent unmodified to both
|
||||
.Dv right
|
||||
and
|
||||
.Dv left2right .
|
||||
.Pp
|
||||
Packets may also be received on
|
||||
.Dv right2left
|
||||
and
|
||||
.Dv left2right ;
|
||||
if so, they are forwarded unchanged out hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right ,
|
||||
respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbarfoo
|
||||
.It Dv right
|
||||
The connection to the node on the right.
|
||||
.It Dv left
|
||||
The connection to the node on the left.
|
||||
.It Dv right2left
|
||||
Tap for right to left traffic.
|
||||
.It Dv left2right
|
||||
Tap for left to right traffic.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr tee 1 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
110
sys/modules/netgraph/tee/ng_tee.8
Normal file
110
sys/modules/netgraph/tee/ng_tee.8
Normal file
@ -0,0 +1,110 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tee.8,v 1.4 1999/01/25 23:46:27 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TEE 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tee
|
||||
.Nd netgraph ``tee'' node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_tee.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tee
|
||||
node type has a purpose similar to the
|
||||
.Xr tee 1
|
||||
command.
|
||||
.Nm Tee
|
||||
nodes are useful for debugging or ``snooping'' on a connection
|
||||
between two netgraph nodes.
|
||||
.Nm Tee
|
||||
nodes have four hooks,
|
||||
.Dv right ,
|
||||
.Dv left ,
|
||||
.Dv right2left ,
|
||||
and
|
||||
.Dv left2right .
|
||||
All data received on
|
||||
.Dv right
|
||||
is sent unmodified to
|
||||
.Em both
|
||||
hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right2left .
|
||||
Similarly, all data received on
|
||||
.Dv left
|
||||
is sent unmodified to both
|
||||
.Dv right
|
||||
and
|
||||
.Dv left2right .
|
||||
.Pp
|
||||
Packets may also be received on
|
||||
.Dv right2left
|
||||
and
|
||||
.Dv left2right ;
|
||||
if so, they are forwarded unchanged out hooks
|
||||
.Dv left
|
||||
and
|
||||
.Dv right ,
|
||||
respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbarfoo
|
||||
.It Dv right
|
||||
The connection to the node on the right.
|
||||
.It Dv left
|
||||
The connection to the node on the left.
|
||||
.It Dv right2left
|
||||
Tap for right to left traffic.
|
||||
.It Dv left2right
|
||||
Tap for left to right traffic.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports only the generic control messages.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh SEE ALSO
|
||||
.Xr tee 1 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Julian Elisher <julian@whistle.com>
|
9
sys/modules/netgraph/tty/Makefile
Normal file
9
sys/modules/netgraph/tty/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.2 1999/01/19 19:39:22 archie Exp $
|
||||
|
||||
KMOD= ng_tty
|
||||
SRCS= ng_tty.c
|
||||
MAN8= ng_tty.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
141
sys/modules/netgraph/tty/ng_tty.4
Normal file
141
sys/modules/netgraph/tty/ng_tty.4
Normal file
@ -0,0 +1,141 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TTY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tty
|
||||
.Nd netgraph node type that is also a line discipline
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_tty.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tty
|
||||
node type is both a netgraph node type and a line discipline.
|
||||
A new node is created when the corresponding line discipline is
|
||||
registered on a tty device (see
|
||||
.Xr tty 4 ")."
|
||||
.Pp
|
||||
The node has a single hook called
|
||||
.Dv hook .
|
||||
Incoming bytes received on the tty device are sent out on this hook,
|
||||
and frames received on
|
||||
.Dv hook
|
||||
are transmitted out on the tty device.
|
||||
No modification to the data is performed in either direction.
|
||||
While the line discipline is installed on a tty, the normal
|
||||
read and write operations are unavailable, returning
|
||||
.Er EIO .
|
||||
.Pp
|
||||
The node supports an optional ``hot character.'' If set to non-zero, incoming
|
||||
data from the tty device is queued until this character is seen.
|
||||
This avoids sending lots of mbufs containing a small number of bytes,
|
||||
but introduces potentially infinite latency.
|
||||
The default hot character is 0x7e, consistent with
|
||||
.Dv hook
|
||||
being connected to a
|
||||
.Xr ng_async 8
|
||||
type node. The hot character has no effect on the transmission of data.
|
||||
.Pp
|
||||
The node will attempt to give itself the same netgraph name as the name
|
||||
of the tty device.
|
||||
In any case, information about the node is available via the netgraph
|
||||
.Xr ioctl 2
|
||||
command
|
||||
.Dv NGIOCGINFO .
|
||||
This command returns a
|
||||
.Dv "struct nodeinfo"
|
||||
similar to the
|
||||
.Dv NGM_NODEINFO
|
||||
netgraph control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv hook
|
||||
.Xr tty 4
|
||||
serial data contained in
|
||||
.Dv mbuf
|
||||
structures, with arbitrary inter-frame boundaries.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_TTY_SET_HOTCHAR
|
||||
This command takes an integer argument and sets the hot character
|
||||
from the lower 8 bits. A hot character of zero disables queueing,
|
||||
so that all received data is forwarded immediately.
|
||||
.It Dv NGM_TTY_GET_HOTCHAR
|
||||
Returns an integer containing the current hot character in the lower
|
||||
eight bits.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down when the corresponding device is closed
|
||||
(or the line discipline is uninstalled on the device).
|
||||
The
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is not valid, and always returns the error
|
||||
.Er EOPNOTSUPP .
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm tty
|
||||
type registers its line discipline when the type is installed,
|
||||
where it is dynamically assigned an integer index.
|
||||
Unfortunately, there's no way to know what this integer is
|
||||
except by reading the output of
|
||||
.Xr dmesg 8 .
|
||||
The fix for this is to have line disciplines identified by
|
||||
unique ASCII strings instead of fixed integer constants,
|
||||
or else to assign one of those constants to
|
||||
.Nm ng_tty .
|
||||
.Pp
|
||||
The serial driver code also has a notion of a ``hot character.''
|
||||
Unfortunately, this value is statically defined in terms of the
|
||||
line discipline and cannot be changed.
|
||||
Therefore, if a hot character other than 0x7e (the default) is set for the
|
||||
.Nm tty
|
||||
node, the node has no way to convey this information to the
|
||||
serial driver, and sub-optimal performance may result.
|
||||
.Sh SEE ALSO
|
||||
.Xr ioctl 2 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
141
sys/modules/netgraph/tty/ng_tty.8
Normal file
141
sys/modules/netgraph/tty/ng_tty.8
Normal file
@ -0,0 +1,141 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_TTY 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_tty
|
||||
.Nd netgraph node type that is also a line discipline
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netgraph/ng_message.h>
|
||||
.Fd #include <netgraph/ng_tty.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tty
|
||||
node type is both a netgraph node type and a line discipline.
|
||||
A new node is created when the corresponding line discipline is
|
||||
registered on a tty device (see
|
||||
.Xr tty 4 ")."
|
||||
.Pp
|
||||
The node has a single hook called
|
||||
.Dv hook .
|
||||
Incoming bytes received on the tty device are sent out on this hook,
|
||||
and frames received on
|
||||
.Dv hook
|
||||
are transmitted out on the tty device.
|
||||
No modification to the data is performed in either direction.
|
||||
While the line discipline is installed on a tty, the normal
|
||||
read and write operations are unavailable, returning
|
||||
.Er EIO .
|
||||
.Pp
|
||||
The node supports an optional ``hot character.'' If set to non-zero, incoming
|
||||
data from the tty device is queued until this character is seen.
|
||||
This avoids sending lots of mbufs containing a small number of bytes,
|
||||
but introduces potentially infinite latency.
|
||||
The default hot character is 0x7e, consistent with
|
||||
.Dv hook
|
||||
being connected to a
|
||||
.Xr ng_async 8
|
||||
type node. The hot character has no effect on the transmission of data.
|
||||
.Pp
|
||||
The node will attempt to give itself the same netgraph name as the name
|
||||
of the tty device.
|
||||
In any case, information about the node is available via the netgraph
|
||||
.Xr ioctl 2
|
||||
command
|
||||
.Dv NGIOCGINFO .
|
||||
This command returns a
|
||||
.Dv "struct nodeinfo"
|
||||
similar to the
|
||||
.Dv NGM_NODEINFO
|
||||
netgraph control message.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobar
|
||||
.It Dv hook
|
||||
.Xr tty 4
|
||||
serial data contained in
|
||||
.Dv mbuf
|
||||
structures, with arbitrary inter-frame boundaries.
|
||||
.El
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_TTY_SET_HOTCHAR
|
||||
This command takes an integer argument and sets the hot character
|
||||
from the lower 8 bits. A hot character of zero disables queueing,
|
||||
so that all received data is forwarded immediately.
|
||||
.It Dv NGM_TTY_GET_HOTCHAR
|
||||
Returns an integer containing the current hot character in the lower
|
||||
eight bits.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down when the corresponding device is closed
|
||||
(or the line discipline is uninstalled on the device).
|
||||
The
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message is not valid, and always returns the error
|
||||
.Er EOPNOTSUPP .
|
||||
.Sh BUGS
|
||||
The
|
||||
.Nm tty
|
||||
type registers its line discipline when the type is installed,
|
||||
where it is dynamically assigned an integer index.
|
||||
Unfortunately, there's no way to know what this integer is
|
||||
except by reading the output of
|
||||
.Xr dmesg 8 .
|
||||
The fix for this is to have line disciplines identified by
|
||||
unique ASCII strings instead of fixed integer constants,
|
||||
or else to assign one of those constants to
|
||||
.Nm ng_tty .
|
||||
.Pp
|
||||
The serial driver code also has a notion of a ``hot character.''
|
||||
Unfortunately, this value is statically defined in terms of the
|
||||
line discipline and cannot be changed.
|
||||
Therefore, if a hot character other than 0x7e (the default) is set for the
|
||||
.Nm tty
|
||||
node, the node has no way to convey this information to the
|
||||
serial driver, and sub-optimal performance may result.
|
||||
.Sh SEE ALSO
|
||||
.Xr ioctl 2 ,
|
||||
.Xr netgraph 4 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr ng_async 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
9
sys/modules/netgraph/vjc/Makefile
Normal file
9
sys/modules/netgraph/vjc/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
# $Whistle: Makefile,v 1.1 1999/01/24 06:48:07 archie Exp $
|
||||
|
||||
KMOD= ng_vjc
|
||||
SRCS= ng_vjc.c
|
||||
MAN8= ng_vjc.8
|
||||
KMODDEPS= netgraph
|
||||
|
||||
.include <bsd.kmod.mk>
|
188
sys/modules/netgraph/vjc/ng_vjc.4
Normal file
188
sys/modules/netgraph/vjc/ng_vjc.4
Normal file
@ -0,0 +1,188 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_vjc.8,v 1.4 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_VJC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_vjc
|
||||
.Nd Van Jacobsen compression netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <net/slcompress.h>
|
||||
.Fd #include <netgraph/ng_vjc.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm vjc
|
||||
node type performs Van Jacobsen compresion, which is used
|
||||
over PPP, SLIP, and other point-to-point IP connections to
|
||||
compress TCP packet headers. The
|
||||
.Dv ip
|
||||
hook represents the uncompressed side of the node, while the
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes represent the compressed side of the node. Packets received on the
|
||||
.Dv ip
|
||||
will be compressed or passed through as appropriate. Packets received
|
||||
on the other three hooks will be uncompressed as appropriate.
|
||||
.Pp
|
||||
Van Jacobsen compression only applies to TCP packets.
|
||||
Only ``normal'' (i.e., common case) TCP packets are actually compressed.
|
||||
These are output on the
|
||||
.Dv vjcomp
|
||||
hook. Other TCP packets are run through the state machine but not
|
||||
compressed; these appear on the
|
||||
.Dv vjuncomp
|
||||
hook.
|
||||
Other non-TCP IP packets are forwarded unchanged to
|
||||
.Dv vjip .
|
||||
.Pp
|
||||
When connecting to a
|
||||
.Xr ng_ppp 8
|
||||
node, the
|
||||
.Dv vjuncomp ,
|
||||
.Dv vjcomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes should be connected to the
|
||||
.Xr ng_ppp 8
|
||||
node's
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv ip
|
||||
nodes, respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv ip
|
||||
Upstream (uncompressed) IP packets.
|
||||
.It Dv vjcomp
|
||||
Downstream compressed TCP packets.
|
||||
.It Dv vjuncomp
|
||||
Downstream uncompressed TCP packets.
|
||||
.It Dv vjip
|
||||
Downstream uncompressed IP packets.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_VJC_CONFIG
|
||||
This command resets the compression state and configures it according
|
||||
to the supplied
|
||||
.Dv "struct ngm_vjc_config"
|
||||
argument. This structure contains the following fields:
|
||||
.Bd -literal -offset 4n
|
||||
struct ngm_vjc_config {
|
||||
u_char enabled; /* Enable compression/decompression */
|
||||
u_char numChannels; /* Number of outgoing channels */
|
||||
u_char compressCID; /* OK to compress outgoing CID's */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
When
|
||||
.Dv enabled
|
||||
is set to zero, the node operates in ``pass through'' mode, only
|
||||
accepting packets on the
|
||||
.Dv ip
|
||||
and
|
||||
.Dv vjip
|
||||
hooks.
|
||||
.Dv numChannels
|
||||
should be set to the number of compression channels, and is a value
|
||||
between 3 and 16, inclusive.
|
||||
.Pp
|
||||
The
|
||||
.Dv compressCID
|
||||
field indicates whether it is OK to compress the CID field for
|
||||
outgoing compressed TCP packets. This value should be zero unless
|
||||
either (a) it not possible for an incoming frame to be lost, or
|
||||
(b) lost frames can be reliably detected and a
|
||||
.Dv NGM_VJC_RECV_ERROR
|
||||
mesages is immediately sent whenever this occurs.
|
||||
.It Dv NGM_VJC_GET_STATE
|
||||
This command returns the node's current state described by the
|
||||
.Dv "struct slcompress"
|
||||
structure, which is defined in
|
||||
.Dv "net/slcompress.h" .
|
||||
.It Dv NGM_VJC_CLR_STATS
|
||||
Clears the node statistics counters. Statistics are also cleared whenever the
|
||||
.Dv enabled
|
||||
field is changed from zero to one by a
|
||||
.Dv NGM_VJC_CONFIG
|
||||
control message.
|
||||
.It Dv NGM_VJC_RECV_ERROR
|
||||
When the
|
||||
.Dv compressCID
|
||||
is set to one, this message must be sent to the node immediately
|
||||
after detecting that a recieved frame has been lost, due to a bad
|
||||
checksum or for any other reason. Failing to do this can result
|
||||
in corrupted TCP stream data.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
This node type requires that the file
|
||||
.Dv "net/slcompress.c"
|
||||
was compiled into the kernel. Currently the only way to insure this
|
||||
is to include the
|
||||
.Dv slip ,
|
||||
.Dv ppp ,
|
||||
or
|
||||
.Dv i4bipr
|
||||
pseudo-devices in your kernel compilation. In the future there should
|
||||
be a kernel option that causes inclusion of this file without requiring
|
||||
one of these drivers.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A V. Jacobsen
|
||||
.%T "Compressing TCP/IP Headers"
|
||||
.%O RFC 1144
|
||||
.Re
|
||||
.Rs
|
||||
.%A G. McGregor
|
||||
.%T "The PPP Internet Control Protocol (IPCP)"
|
||||
.%O RFC 1332
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
188
sys/modules/netgraph/vjc/ng_vjc.8
Normal file
188
sys/modules/netgraph/vjc/ng_vjc.8
Normal file
@ -0,0 +1,188 @@
|
||||
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Subject to the following obligations and disclaimer of warranty, use and
|
||||
.\" redistribution of this software, in source or object code forms, with or
|
||||
.\" without modifications are expressly permitted by Whistle Communications;
|
||||
.\" provided, however, that:
|
||||
.\" 1. Any and all reproductions of the source or object code must include the
|
||||
.\" copyright notice above and the following disclaimer of warranties; and
|
||||
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
||||
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
.\" such appears in the above copyright notice or in the software.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
.\" OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" Author: Archie Cobbs <archie@whistle.com>
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" $Whistle: ng_vjc.8,v 1.4 1999/01/25 23:46:28 archie Exp $
|
||||
.\"
|
||||
.Dd January 19, 1999
|
||||
.Dt NG_VJC 8
|
||||
.Os FreeBSD 3
|
||||
.Sh NAME
|
||||
.Nm ng_vjc
|
||||
.Nd Van Jacobsen compression netgraph node type
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <net/slcompress.h>
|
||||
.Fd #include <netgraph/ng_vjc.h>
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm vjc
|
||||
node type performs Van Jacobsen compresion, which is used
|
||||
over PPP, SLIP, and other point-to-point IP connections to
|
||||
compress TCP packet headers. The
|
||||
.Dv ip
|
||||
hook represents the uncompressed side of the node, while the
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes represent the compressed side of the node. Packets received on the
|
||||
.Dv ip
|
||||
will be compressed or passed through as appropriate. Packets received
|
||||
on the other three hooks will be uncompressed as appropriate.
|
||||
.Pp
|
||||
Van Jacobsen compression only applies to TCP packets.
|
||||
Only ``normal'' (i.e., common case) TCP packets are actually compressed.
|
||||
These are output on the
|
||||
.Dv vjcomp
|
||||
hook. Other TCP packets are run through the state machine but not
|
||||
compressed; these appear on the
|
||||
.Dv vjuncomp
|
||||
hook.
|
||||
Other non-TCP IP packets are forwarded unchanged to
|
||||
.Dv vjip .
|
||||
.Pp
|
||||
When connecting to a
|
||||
.Xr ng_ppp 8
|
||||
node, the
|
||||
.Dv vjuncomp ,
|
||||
.Dv vjcomp ,
|
||||
and
|
||||
.Dv vjip
|
||||
nodes should be connected to the
|
||||
.Xr ng_ppp 8
|
||||
node's
|
||||
.Dv vjcomp ,
|
||||
.Dv vjuncomp ,
|
||||
and
|
||||
.Dv ip
|
||||
nodes, respectively.
|
||||
.Sh HOOKS
|
||||
This node type supports the following hooks:
|
||||
.Pp
|
||||
.Bl -tag -width foobarbazi
|
||||
.It Dv ip
|
||||
Upstream (uncompressed) IP packets.
|
||||
.It Dv vjcomp
|
||||
Downstream compressed TCP packets.
|
||||
.It Dv vjuncomp
|
||||
Downstream uncompressed TCP packets.
|
||||
.It Dv vjip
|
||||
Downstream uncompressed IP packets.
|
||||
.Sh CONTROL MESSAGES
|
||||
This node type supports the generic control messages, plus the following:
|
||||
.Bl -tag -width foo
|
||||
.It Dv NGM_VJC_CONFIG
|
||||
This command resets the compression state and configures it according
|
||||
to the supplied
|
||||
.Dv "struct ngm_vjc_config"
|
||||
argument. This structure contains the following fields:
|
||||
.Bd -literal -offset 4n
|
||||
struct ngm_vjc_config {
|
||||
u_char enabled; /* Enable compression/decompression */
|
||||
u_char numChannels; /* Number of outgoing channels */
|
||||
u_char compressCID; /* OK to compress outgoing CID's */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
When
|
||||
.Dv enabled
|
||||
is set to zero, the node operates in ``pass through'' mode, only
|
||||
accepting packets on the
|
||||
.Dv ip
|
||||
and
|
||||
.Dv vjip
|
||||
hooks.
|
||||
.Dv numChannels
|
||||
should be set to the number of compression channels, and is a value
|
||||
between 3 and 16, inclusive.
|
||||
.Pp
|
||||
The
|
||||
.Dv compressCID
|
||||
field indicates whether it is OK to compress the CID field for
|
||||
outgoing compressed TCP packets. This value should be zero unless
|
||||
either (a) it not possible for an incoming frame to be lost, or
|
||||
(b) lost frames can be reliably detected and a
|
||||
.Dv NGM_VJC_RECV_ERROR
|
||||
mesages is immediately sent whenever this occurs.
|
||||
.It Dv NGM_VJC_GET_STATE
|
||||
This command returns the node's current state described by the
|
||||
.Dv "struct slcompress"
|
||||
structure, which is defined in
|
||||
.Dv "net/slcompress.h" .
|
||||
.It Dv NGM_VJC_CLR_STATS
|
||||
Clears the node statistics counters. Statistics are also cleared whenever the
|
||||
.Dv enabled
|
||||
field is changed from zero to one by a
|
||||
.Dv NGM_VJC_CONFIG
|
||||
control message.
|
||||
.It Dv NGM_VJC_RECV_ERROR
|
||||
When the
|
||||
.Dv compressCID
|
||||
is set to one, this message must be sent to the node immediately
|
||||
after detecting that a recieved frame has been lost, due to a bad
|
||||
checksum or for any other reason. Failing to do this can result
|
||||
in corrupted TCP stream data.
|
||||
.Sh SHUTDOWN
|
||||
This node shuts down upon receipt of a
|
||||
.Dv NGM_SHUTDOWN
|
||||
control message, or when all hooks have been disconnected.
|
||||
.Sh BUGS
|
||||
This node type requires that the file
|
||||
.Dv "net/slcompress.c"
|
||||
was compiled into the kernel. Currently the only way to insure this
|
||||
is to include the
|
||||
.Dv slip ,
|
||||
.Dv ppp ,
|
||||
or
|
||||
.Dv i4bipr
|
||||
pseudo-devices in your kernel compilation. In the future there should
|
||||
be a kernel option that causes inclusion of this file without requiring
|
||||
one of these drivers.
|
||||
.Sh SEE ALSO
|
||||
.Xr netgraph 4 ,
|
||||
.Xr ng_ppp 8 ,
|
||||
.Xr ng_iface 8 ,
|
||||
.Xr ngctl 8 .
|
||||
.Rs
|
||||
.%A V. Jacobsen
|
||||
.%T "Compressing TCP/IP Headers"
|
||||
.%O RFC 1144
|
||||
.Re
|
||||
.Rs
|
||||
.%A G. McGregor
|
||||
.%T "The PPP Internet Control Protocol (IPCP)"
|
||||
.%O RFC 1332
|
||||
.Re
|
||||
.Sh AUTHOR
|
||||
Archie Cobbs <archie@whistle.com>
|
@ -102,6 +102,9 @@ struct arpcom {
|
||||
struct ifnet ac_if; /* network-visible interface */
|
||||
u_char ac_enaddr[6]; /* ethernet hardware address */
|
||||
int ac_multicnt; /* length of ac_multiaddrs list */
|
||||
/* #ifdef NETGRAPH */
|
||||
void *ac_ng; /* hook to hang netgraph stuff off */
|
||||
/* #endif */
|
||||
};
|
||||
|
||||
extern u_char etherbroadcastaddr[6];
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipx.h"
|
||||
#include "opt_bdg.h"
|
||||
#include "opt_netgraph.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -117,6 +118,43 @@ u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
#define senderr(e) do { error = (e); goto bad;} while (0)
|
||||
#define IFP2AC(IFP) ((struct arpcom *)IFP)
|
||||
|
||||
#ifdef NETGRAPH
|
||||
#include <netgraph/ng_ether.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
|
||||
static void ngether_init(void* ignored);
|
||||
static void ngether_send(struct arpcom *ac,
|
||||
struct ether_header *eh, struct mbuf *m);
|
||||
static int ngether_constructor(node_p *nodep);
|
||||
static int ngether_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
static int ngether_rmnode(node_p node);
|
||||
static int ngether_newhook(node_p node, hook_p hook, const char *name);
|
||||
/*static hook_p ngether_findhook(node_p node, char *name);*/
|
||||
static int ngether_connect(hook_p hook); /* already PARTLY linked */
|
||||
static int ngether_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int ngether_disconnect(hook_p hook); /* notify on disconnect */
|
||||
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_ETHER_NODE_TYPE,
|
||||
NULL,
|
||||
ngether_constructor,
|
||||
ngether_rcvmsg,
|
||||
ngether_rmnode,
|
||||
ngether_newhook,
|
||||
NULL,
|
||||
ngether_connect,
|
||||
ngether_rcvdata,
|
||||
ngether_rcvdata,
|
||||
ngether_disconnect
|
||||
};
|
||||
|
||||
#define AC2NG(AC) ((node_p)((AC)->ac_ng))
|
||||
#define NGEF_DIVERT NGF_TYPE1 /* all packets sent to netgraph */
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/*
|
||||
* Ethernet output routine.
|
||||
* Encapsulate a packet of type family for the local net.
|
||||
@ -456,6 +494,16 @@ ether_input(ifp, eh, m)
|
||||
|
||||
ether_type = ntohs(eh->ether_type);
|
||||
|
||||
#ifdef NETGRAPH
|
||||
{
|
||||
struct arpcom *ac = IFP2AC(ifp);
|
||||
if (AC2NG(ac) && (AC2NG(ac)->flags & NGEF_DIVERT)) {
|
||||
ngether_send(ac, eh, m);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
#if NVLAN > 0
|
||||
if (ether_type == vlan_proto) {
|
||||
if (vlan_input(eh, m) < 0)
|
||||
@ -640,11 +688,19 @@ ether_input(ifp, eh, m)
|
||||
#endif /* LLC */
|
||||
dropanyway:
|
||||
default:
|
||||
#ifdef NETGRAPH
|
||||
ngether_send(IFP2AC(ifp), eh, m);
|
||||
#else /* NETGRAPH */
|
||||
m_freem(m);
|
||||
#endif /* NETGRAPH */
|
||||
return;
|
||||
}
|
||||
#else /* ISO || LLC || NETATALK */
|
||||
#ifdef NETGRAPH
|
||||
ngether_send(IFP2AC(ifp), eh, m);
|
||||
#else /* NETGRAPH */
|
||||
m_freem(m);
|
||||
#endif /* NETGRAPH */
|
||||
return;
|
||||
#endif /* ISO || LLC || NETATALK */
|
||||
}
|
||||
@ -844,3 +900,296 @@ ether_resolvemulti(ifp, llsa, sa)
|
||||
return EAFNOSUPPORT;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NETGRAPH
|
||||
|
||||
/***********************************************************************
|
||||
* This section contains the methods for the Netgraph interface
|
||||
***********************************************************************/
|
||||
/* It's Ascii-art time!
|
||||
* The ifnet is the first part of the arpcom which must be
|
||||
* the first part of the device's softc.. yuk.
|
||||
*
|
||||
* +--------------------------+-----+---------+
|
||||
* | struct ifnet (*ifp) | | |
|
||||
* | | | |
|
||||
* +--------------------------+ | |
|
||||
* +--|[ac_ng] struct arpcom (*ac) | |
|
||||
* | +--------------------------------+ |
|
||||
* | | struct softc (*ifp->if_softc) (device) |
|
||||
* | +------------------------------------------+
|
||||
* | ^
|
||||
* AC2NG() |
|
||||
* | v
|
||||
* | +----------------------+
|
||||
* | | [private] [flags] |
|
||||
* +------>| struct ng_node |
|
||||
* | [hooks] | ** we only allow one hook
|
||||
* +----------------------+
|
||||
* ^
|
||||
* |
|
||||
* v
|
||||
* +-------------+
|
||||
* | [node] |
|
||||
* | hook |
|
||||
* | [private]|-- *unused*
|
||||
* +-------------+
|
||||
*/
|
||||
|
||||
/*
|
||||
* called during interface attaching
|
||||
*/
|
||||
static void
|
||||
ngether_init(void *ifpvoid)
|
||||
{
|
||||
struct ifnet *ifp = ifpvoid;
|
||||
struct arpcom *ac = IFP2AC(ifp);
|
||||
static int ngether_done_init;
|
||||
char namebuf[32];
|
||||
node_p node;
|
||||
|
||||
/*
|
||||
* we have found a node, make sure our 'type' is availabe.
|
||||
*/
|
||||
if (ngether_done_init == 0) {
|
||||
if (ng_newtype(&typestruct)) {
|
||||
printf("ngether install failed\n");
|
||||
return;
|
||||
}
|
||||
ngether_done_init = 1;
|
||||
}
|
||||
if (ng_make_node_common(&typestruct, &node) != 0)
|
||||
return;
|
||||
ac->ac_ng = node;
|
||||
node->private = ifp;
|
||||
sprintf(namebuf, "%s%d", ifp->if_name, ifp->if_unit);
|
||||
ng_name_node(AC2NG(ac), namebuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* It is not possible or allowable to create a node of this type.
|
||||
* If the hardware exists, it will already have created it.
|
||||
*/
|
||||
static int
|
||||
ngether_constructor(node_p *nodep)
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give our ok for a hook to be added...
|
||||
*
|
||||
* Allow one hook at a time (rawdata).
|
||||
* It can eiteh rdivert everything or only unclaimed packets.
|
||||
*/
|
||||
static int
|
||||
ngether_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
|
||||
/* check if there is already a hook */
|
||||
if (LIST_FIRST(&(node->hooks)))
|
||||
return(EISCONN);
|
||||
/*
|
||||
* Check for which mode hook we want.
|
||||
*/
|
||||
if (strcmp(name, NG_ETHER_HOOK_ORPHAN) != 0) {
|
||||
if (strcmp(name, NG_ETHER_HOOK_DIVERT) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
node->flags |= NGEF_DIVERT;
|
||||
} else {
|
||||
node->flags &= ~NGEF_DIVERT;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* incoming messages.
|
||||
* Just respond to the generic TEXT_STATUS message
|
||||
*/
|
||||
static int
|
||||
ngether_rcvmsg(node_p node,
|
||||
struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
int error = 0;
|
||||
|
||||
ifp = node->private;
|
||||
switch (msg->header.typecookie) {
|
||||
case NGM_ETHER_COOKIE:
|
||||
error = EINVAL;
|
||||
break;
|
||||
case NGM_GENERIC_COOKIE:
|
||||
switch(msg->header.cmd) {
|
||||
case NGM_TEXT_STATUS: {
|
||||
char *arg;
|
||||
int pos = 0;
|
||||
int resplen = sizeof(struct ng_mesg) + 512;
|
||||
MALLOC(*resp, struct ng_mesg *, resplen,
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (*resp == NULL) {
|
||||
error = ENOMEM;
|
||||
break;
|
||||
}
|
||||
bzero(*resp, resplen);
|
||||
arg = (*resp)->data;
|
||||
|
||||
/*
|
||||
* Put in the throughput information.
|
||||
*/
|
||||
pos = sprintf(arg, "%ld bytes in, %ld bytes out\n",
|
||||
ifp->if_ibytes, ifp->if_obytes);
|
||||
pos += sprintf(arg + pos,
|
||||
"%ld output errors\n",
|
||||
ifp->if_oerrors);
|
||||
pos += sprintf(arg + pos,
|
||||
"ierrors = %ld\n",
|
||||
ifp->if_ierrors);
|
||||
|
||||
(*resp)->header.version = NG_VERSION;
|
||||
(*resp)->header.arglen = strlen(arg) + 1;
|
||||
(*resp)->header.token = msg->header.token;
|
||||
(*resp)->header.typecookie = NGM_ETHER_COOKIE;
|
||||
(*resp)->header.cmd = msg->header.cmd;
|
||||
strncpy((*resp)->header.cmdstr, "status",
|
||||
NG_CMDSTRLEN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
free(msg, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive a completed ethernet packet.
|
||||
* Queue it for output.
|
||||
*/
|
||||
static int
|
||||
ngether_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
int error = 0;
|
||||
int s;
|
||||
struct ether_header *eh;
|
||||
|
||||
ifp = hook->node->private;
|
||||
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
|
||||
senderr(ENETDOWN);
|
||||
/*
|
||||
* If a simplex interface, and the packet is being sent to our
|
||||
* Ethernet address or a broadcast address, loopback a copy.
|
||||
* XXX To make a simplex device behave exactly like a duplex
|
||||
* device, we should copy in the case of sending to our own
|
||||
* ethernet address (thus letting the original actually appear
|
||||
* on the wire). However, we don't do that here for security
|
||||
* reasons and compatibility with the original behavior.
|
||||
*/
|
||||
if (ifp->if_flags & IFF_SIMPLEX) {
|
||||
eh = mtod(m, struct ether_header *);
|
||||
if (m->m_flags & M_BCAST) {
|
||||
struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
|
||||
|
||||
ng_queue_data(hook, n, meta);
|
||||
} else if (bcmp(eh->ether_dhost,
|
||||
eh->ether_shost, ETHER_ADDR_LEN) == 0) {
|
||||
ng_queue_data(hook, m, meta);
|
||||
return (0); /* XXX */
|
||||
}
|
||||
}
|
||||
s = splimp();
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
* XXX if we lookead at the priority in the meta data we could
|
||||
* queue high priority items at the head.
|
||||
*/
|
||||
if (IF_QFULL(&ifp->if_snd)) {
|
||||
IF_DROP(&ifp->if_snd);
|
||||
splx(s);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
||||
(*ifp->if_start)(ifp);
|
||||
splx(s);
|
||||
ifp->if_obytes += m->m_pkthdr.len;
|
||||
if (m->m_flags & M_MCAST)
|
||||
ifp->if_omcasts++;
|
||||
return (error);
|
||||
|
||||
bad:
|
||||
NG_FREE_DATA(m, meta);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* pass an mbuf out to the connected hook
|
||||
*/
|
||||
static void
|
||||
ngether_send(struct arpcom *ac, struct ether_header *eh, struct mbuf *m)
|
||||
{
|
||||
node_p node = AC2NG(ac);
|
||||
struct ether_header *eh2;
|
||||
|
||||
if (node && LIST_FIRST(&(node->hooks))) {
|
||||
M_PREPEND(m, sizeof(*eh), M_DONTWAIT);
|
||||
if (m == 0)
|
||||
return;
|
||||
eh2 = mtod(m, struct ether_header *);
|
||||
/*
|
||||
* Possibly 'eh' already points
|
||||
* to the right place.
|
||||
*/
|
||||
if (eh2 != eh)
|
||||
bcopy(eh, eh2, sizeof(*eh));
|
||||
ng_queue_data(LIST_FIRST(&(node->hooks)), m, NULL);
|
||||
} else {
|
||||
m_freem(m);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* do local shutdown processing..
|
||||
* This node will refuse to go away, unless the hardware says to..
|
||||
* don't unref the node, or remove our name. just clear our links up.
|
||||
*/
|
||||
static int
|
||||
ngether_rmnode(node_p node)
|
||||
{
|
||||
ng_cutlinks(node);
|
||||
node->flags &= ~NG_INVALID; /* bounce back to life */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* already linked */
|
||||
static int
|
||||
ngether_connect(hook_p hook)
|
||||
{
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* notify on hook disconnection (destruction)
|
||||
*
|
||||
* For this type, removal of the last lins no effect. The interface can run
|
||||
* independently.
|
||||
* Since we have no per-hook information, this is rather simple.
|
||||
*/
|
||||
static int
|
||||
ngether_disconnect(hook_p hook)
|
||||
{
|
||||
hook->node->flags &= ~NGEF_DIVERT;
|
||||
return (0);
|
||||
}
|
||||
#endif /* NETGRAPH */
|
||||
|
||||
/********************************** END *************************************/
|
||||
|
@ -67,6 +67,7 @@
|
||||
#define NETISR_ISDN 26 /* same as AF_E164 */
|
||||
#define NETISR_PPP 27 /* PPP soft interrupt */
|
||||
#define NETISR_NATM 29 /* same as AF_NATM */
|
||||
#define NETISR_NETGRAPH 31 /* same as AF_NETGRAPH */
|
||||
|
||||
#define schednetisr(anisr) { netisr |= 1<<(anisr); setsoftnet(); }
|
||||
|
||||
|
81
sys/netgraph/NOTES
Normal file
81
sys/netgraph/NOTES
Normal file
@ -0,0 +1,81 @@
|
||||
$FreeBSD$
|
||||
Development ideas..
|
||||
|
||||
Archie's suggestions... :-)
|
||||
|
||||
- There should be a new malloc type: M_NETGRAPH
|
||||
[DONE]
|
||||
- all mallocs/frees now changed to use this.. JRE
|
||||
- might further split them out some time.
|
||||
|
||||
- Use MALLOC and FREE macros instead of direct function calls
|
||||
[DONE]
|
||||
- They allow conditional compilation which keeps
|
||||
statistics & counters on various memory allocation
|
||||
(or so it seems)
|
||||
|
||||
- In struct ng_mesg: at least make "header" into "hdr", if not
|
||||
getting rid of it altogether. It doesn't seem necessary and
|
||||
makes all my C code lines too long.
|
||||
|
||||
- I understand.. one thought however.. consider..
|
||||
if char data[0] were not legal, so that data[1] needed to be
|
||||
used instead, then the only way to get the size of the header
|
||||
would be sizeof(msg.header) as sizeof(msg) would include the dummy
|
||||
following bytes. this is a portability issue and I hope
|
||||
it will be ported eventually :)
|
||||
|
||||
- Baloney! you can use sizeof(msg) - 1 then.. or just
|
||||
make it a macro, then its always portable:
|
||||
|
||||
#ifdef __GNU_C__
|
||||
#define NG_MSG_HDR_SIZE (sizeof(struct ng_message))
|
||||
#else
|
||||
#define NG_MSG_HDR_SIZE (sizeof(struct ng_message) - 1)
|
||||
#endif
|
||||
|
||||
- Have a user level program to print out and manipulate nodes, etc.
|
||||
- [DONE]
|
||||
see ngctl
|
||||
|
||||
- "Netgraph global" flags to turn on tracing, etc.
|
||||
|
||||
- ngctl needs to be rewritten using libnetgraph. Also it needs a
|
||||
command to list all existing nodes (in case you don't know the
|
||||
name of what you're looking for).
|
||||
[DONE]
|
||||
|
||||
- Need a way to get a list of ALL nodes.
|
||||
[DONE]
|
||||
- see NGM_LISTNODES
|
||||
|
||||
- Enhance "netstat" to display all netgraph nodes -- or at least
|
||||
all netgraph socket nodes.
|
||||
[DONE]
|
||||
|
||||
- BUG FIX: bind() on a socket should neither require nor allow a
|
||||
colon character at the end of the name. Note ngctl allows you
|
||||
to do it either way!
|
||||
[DONE] (I think)
|
||||
|
||||
- Need to implement passing meta information through socket nodes
|
||||
using sendmsg() and recvmsg().
|
||||
|
||||
- Stuff needing to be added to manual:
|
||||
|
||||
- Awareness of SPL level, use ng_queue*() functions when necessary.
|
||||
- Malloc all memory with type M_NETGRAPH.
|
||||
- Write code so it can be an LKM or built into the kernel.. this means
|
||||
be careful with things like #ifdef INET.
|
||||
- All nodes assume that all data mbufs have the M_PKTHDR flag set!
|
||||
The ng_send_data() and related functions should have an
|
||||
#ifdef DIAGNOSTICS check to check this assumption for every mbuf.
|
||||
- More generally, netgraph code should make liberal use of the
|
||||
#ifdef DIAGNOSTICS definition.
|
||||
- Since data and messages are sent functionally, programmers need
|
||||
to watch out for infinite feedback loops. Should ng_base.c detect
|
||||
this automatically?
|
||||
- I've been thinking about this. each node could have a 'colour'
|
||||
which is set to the colour of the packet as you pass through.
|
||||
hitting a node already of your colour would abort. Each packet
|
||||
has another (incremented) colour.
|
255
sys/netgraph/netgraph.h
Normal file
255
sys/netgraph/netgraph.h
Normal file
@ -0,0 +1,255 @@
|
||||
|
||||
/*
|
||||
* netgraph.h
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Julian Elischer <julian@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: netgraph.h,v 1.24 1999/01/28 23:54:52 julian Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETGRAPH_NETGRAPH_H_
|
||||
#define _NETGRAPH_NETGRAPH_H_ 1
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#ifndef KERNEL
|
||||
#error "This file should not be included in user level programs"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure of a hook
|
||||
*/
|
||||
struct ng_hook {
|
||||
char *name; /* what this node knows this link as */
|
||||
void *private; /* node dependant ID for this hook */
|
||||
int flags; /* info about this hook/link */
|
||||
int refs; /* dont actually free this till 0 */
|
||||
struct ng_hook *peer; /* the other end of this link */
|
||||
struct ng_node *node; /* The node this hook is attached to */
|
||||
LIST_ENTRY(ng_hook) hooks; /* linked list of all hooks on node */
|
||||
};
|
||||
typedef struct ng_hook *hook_p;
|
||||
|
||||
/* Flags for a hook */
|
||||
#define HK_INVALID 0x0001 /* don't trust it! */
|
||||
|
||||
/*
|
||||
* Structure of a node
|
||||
*/
|
||||
struct ng_node {
|
||||
char *name; /* optional globally unique name */
|
||||
struct ng_type *type; /* the installed 'type' */
|
||||
int flags; /* see below for bit definitions */
|
||||
int sleepers; /* #procs sleeping on this node */
|
||||
int refs; /* number of references to this node */
|
||||
int numhooks; /* number of hooks */
|
||||
int colour; /* for graph colouring algorithms */
|
||||
void *private; /* node type dependant node ID */
|
||||
LIST_HEAD(hooks, ng_hook) hooks; /* linked list of node hooks */
|
||||
LIST_ENTRY(ng_node) nodes; /* linked list of all nodes */
|
||||
};
|
||||
typedef struct ng_node *node_p;
|
||||
|
||||
/* Flags for a node */
|
||||
#define NG_INVALID 0x001 /* free when all sleepers and refs go to 0 */
|
||||
#define NG_BUSY 0x002 /* callers should sleep or wait */
|
||||
#define NG_TOUCHED 0x004 /* to avoid cycles when 'flooding' */
|
||||
#define NGF_TYPE1 0x10000000 /* reserved for type specific storage */
|
||||
#define NGF_TYPE2 0x20000000 /* reserved for type specific storage */
|
||||
#define NGF_TYPE3 0x40000000 /* reserved for type specific storage */
|
||||
#define NGF_TYPE4 0x80000000 /* reserved for type specific storage */
|
||||
|
||||
/*
|
||||
* The structure that holds meta_data about a data packet (e.g. priority)
|
||||
* Nodes might add or subtract options as needed if there is room.
|
||||
* They might reallocate the struct to make more room if they need to.
|
||||
* Meta-data is still experimental.
|
||||
*/
|
||||
struct meta_field_header {
|
||||
u_long cookie; /* cookie for the field. Skip fields you don't
|
||||
* know about (same cookie as in messgaes) */
|
||||
u_short type; /* field ID */
|
||||
u_short len; /* total len of this field including extra
|
||||
* data */
|
||||
char data[0]; /* data starts here */
|
||||
};
|
||||
|
||||
/* To zero out an option 'in place' set it's cookie to this */
|
||||
#define INVALID_COOKIE 865455152
|
||||
|
||||
/* This part of the metadata is always present if the pointer is non NULL */
|
||||
struct ng_meta {
|
||||
char priority; /* -ve is less priority, 0 is default */
|
||||
char discardability; /* higher is less valuable.. discard first */
|
||||
u_short allocated_len; /* amount malloc'd */
|
||||
u_short used_len; /* sum of all fields, options etc. */
|
||||
u_short flags; /* see below.. generic flags */
|
||||
struct meta_field_header options[0]; /* add as (if) needed */
|
||||
};
|
||||
typedef struct ng_meta *meta_p;
|
||||
|
||||
/* Flags for meta-data */
|
||||
#define NGMF_TEST 0x01 /* discard at the last moment before sending */
|
||||
#define NGMF_TRACE 0x02 /* trace when handing this data to a node */
|
||||
|
||||
/*
|
||||
* Structure of a node type
|
||||
*/
|
||||
struct ng_type {
|
||||
|
||||
/* Netgraph version number (must equal NG_VERSION) */
|
||||
u_int32_t version;
|
||||
|
||||
/* Unique type name */
|
||||
const char *name;
|
||||
|
||||
/* Module event handler (optional) */
|
||||
modeventhand_t mod_event;
|
||||
|
||||
/* Node constructor */
|
||||
int (*constructor)(node_p *node);
|
||||
|
||||
/* Calls using the node */
|
||||
int (*rcvmsg)(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
int (*shutdown)(node_p node);
|
||||
int (*newhook)(node_p node, hook_p hook, const char *name);
|
||||
hook_p (*findhook)(node_p node, const char *name);
|
||||
|
||||
/* Calls using the hook */
|
||||
int (*connect)(hook_p hook); /* already linked in */
|
||||
int (*rcvdata)(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
int (*rcvdataq)(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
int (*disconnect)(hook_p hook); /* notify on disconnect */
|
||||
|
||||
/* These are private to the base netgraph code */
|
||||
LIST_ENTRY(ng_type) types; /* linked list of all types */
|
||||
int refs; /* number of instances */
|
||||
};
|
||||
|
||||
/* Send data packet with meta-data */
|
||||
#define NG_SEND_DATA(error, hook, m, a) \
|
||||
do { \
|
||||
(error) = ng_send_data((hook), (m), (a)); \
|
||||
(m) = NULL; \
|
||||
(a) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/* Send queued data packet with meta-data */
|
||||
#define NG_SEND_DATAQ(error, hook, m, a) \
|
||||
do { \
|
||||
(error) = ng_send_dataq((hook), (m), (a)); \
|
||||
(m) = NULL; \
|
||||
(a) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/* Free metadata */
|
||||
#define NG_FREE_META(a) \
|
||||
do { \
|
||||
if ((a)) { \
|
||||
FREE((a), M_NETGRAPH); \
|
||||
a = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Free any data packet and/or meta-data */
|
||||
#define NG_FREE_DATA(m, a) \
|
||||
do { \
|
||||
if ((m)) { \
|
||||
m_freem((m)); \
|
||||
m = NULL; \
|
||||
} \
|
||||
NG_FREE_META((a)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Use the NETGRAPH_INIT() macro to link a node type into the
|
||||
* netgraph system. This works for types compiled into the kernel
|
||||
* as well as KLD modules. The first argument should be the type
|
||||
* name (eg, echo) and the second a pointer to the type struct.
|
||||
*
|
||||
* If a different link time is desired, e.g., a device driver that
|
||||
* needs to install its netgraph type before probing, use the
|
||||
* NETGRAPH_INIT_ORDERED() macro instead. Deivce drivers probably
|
||||
* want to use SI_SUB_DRIVERS instead of SI_SUB_PSEUDO.
|
||||
*/
|
||||
|
||||
#define NETGRAPH_INIT_ORDERED(typename, typestructp, sub, order) \
|
||||
static moduledata_t ng_##typename##_mod = { \
|
||||
"ng_" #typename, \
|
||||
ng_mod_event, \
|
||||
(typestructp) \
|
||||
}; \
|
||||
DECLARE_MODULE(ng_##typename, ng_##typename##_mod, sub, order)
|
||||
|
||||
#define NETGRAPH_INIT(tn, tp) \
|
||||
NETGRAPH_INIT_ORDERED(tn, tp, SI_SUB_PSEUDO, SI_ORDER_ANY)
|
||||
|
||||
/* Special malloc() type for netgraph structs and ctrl messages */
|
||||
MALLOC_DECLARE(M_NETGRAPH);
|
||||
|
||||
void ng_cutlinks(node_p node);
|
||||
int ng_con_nodes(node_p node,
|
||||
const char *name, node_p node2, const char *name2);
|
||||
void ng_destroy_hook(hook_p hook);
|
||||
node_p ng_findname(node_p node, const char *name);
|
||||
struct ng_type *ng_findtype(const char *type);
|
||||
int ng_make_node(const char *type, node_p *nodepp);
|
||||
int ng_make_node_common(struct ng_type *typep, node_p *nodep);
|
||||
int ng_mkpeer(node_p node, const char *name, const char *name2, char *type);
|
||||
int ng_mod_event(module_t mod, int what, void *arg);
|
||||
int ng_name_node(node_p node, const char *name);
|
||||
int ng_newtype(struct ng_type *tp);
|
||||
int ng_path2node(node_p here, const char *path, node_p *dest, char **rtnp);
|
||||
int ng_path_parse(char *addr, char **node, char **path, char **hook);
|
||||
int ng_queue_data(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
int ng_queue_msg(node_p here, struct ng_mesg *msg, int len,
|
||||
const char *address);
|
||||
void ng_release_node(node_p node);
|
||||
void ng_rmnode(node_p node);
|
||||
int ng_send_data(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
int ng_send_dataq(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
int ng_send_msg(node_p here, struct ng_mesg *msg,
|
||||
const char *address, struct ng_mesg **resp);
|
||||
void ng_unname(node_p node);
|
||||
void ng_unref(node_p node);
|
||||
int ng_bypass(hook_p hook1, hook_p hook2);
|
||||
int ng_wait_node(node_p node, char *msg);
|
||||
|
||||
#endif /* _NETGRAPH_NETGRAPH_H_ */
|
||||
|
242
sys/netgraph/ng_UI.c
Normal file
242
sys/netgraph/ng_UI.c
Normal file
@ -0,0 +1,242 @@
|
||||
|
||||
/*
|
||||
* ng_UI.c
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Julian Elischer <julian@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: ng_UI.c,v 1.11 1999/01/28 23:54:52 julian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <netgraph/ng_UI.h>
|
||||
|
||||
/*
|
||||
* DEFINITIONS
|
||||
*/
|
||||
|
||||
/* Everything, starting with sdlc on has defined UI as 0x03 */
|
||||
#define HDLC_UI 0x03
|
||||
|
||||
/* Node private data */
|
||||
struct private {
|
||||
hook_p downlink;
|
||||
hook_p uplink;
|
||||
};
|
||||
typedef struct private *priv_p;
|
||||
|
||||
/* Netgraph node methods */
|
||||
static int ng_UI_constructor(node_p *nodep);
|
||||
static int ng_UI_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *retaddr, struct ng_mesg **resp);
|
||||
static int ng_UI_rmnode(node_p node);
|
||||
static int ng_UI_newhook(node_p node, hook_p hook, const char *name);
|
||||
static int ng_UI_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int ng_UI_disconnect(hook_p hook);
|
||||
|
||||
/* Node type descriptor */
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_UI_NODE_TYPE,
|
||||
NULL,
|
||||
ng_UI_constructor,
|
||||
ng_UI_rcvmsg,
|
||||
ng_UI_rmnode,
|
||||
ng_UI_newhook,
|
||||
NULL,
|
||||
NULL,
|
||||
ng_UI_rcvdata,
|
||||
ng_UI_rcvdata,
|
||||
ng_UI_disconnect
|
||||
};
|
||||
NETGRAPH_INIT(UI, &typestruct);
|
||||
|
||||
/************************************************************************
|
||||
NETGRAPH NODE STUFF
|
||||
************************************************************************/
|
||||
|
||||
/*
|
||||
* Create a newborn node. We start with an implicit reference.
|
||||
*/
|
||||
|
||||
static int
|
||||
ng_UI_constructor(node_p *nodep)
|
||||
{
|
||||
priv_p priv;
|
||||
int error;
|
||||
|
||||
/* Allocate private structure */
|
||||
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK);
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(priv, sizeof(*priv));
|
||||
|
||||
/* Call generic node constructor */
|
||||
if ((error = ng_make_node_common(&typestruct, nodep))) {
|
||||
FREE(priv, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
(*nodep)->private = priv;
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give our ok for a hook to be added
|
||||
*/
|
||||
static int
|
||||
ng_UI_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
|
||||
if (!strcmp(name, NG_UI_HOOK_DOWNSTREAM)) {
|
||||
if (priv->downlink)
|
||||
return (EISCONN);
|
||||
priv->downlink = hook;
|
||||
} else if (!strcmp(name, NG_UI_HOOK_UPSTREAM)) {
|
||||
if (priv->uplink)
|
||||
return (EISCONN);
|
||||
priv->uplink = hook;
|
||||
} else
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive a control message
|
||||
*/
|
||||
static int
|
||||
ng_UI_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *raddr, struct ng_mesg **rp)
|
||||
{
|
||||
FREE(msg, M_NETGRAPH);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
#define MAX_ENCAPS_HDR 1
|
||||
#define ERROUT(x) do { error = (x); goto done; } while (0)
|
||||
|
||||
/*
|
||||
* Receive a data frame
|
||||
*/
|
||||
static int
|
||||
ng_UI_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
int error = 0;
|
||||
|
||||
if (hook == priv->downlink) {
|
||||
u_char *start, *ptr;
|
||||
|
||||
if (!m || !(m = m_pullup(m, MAX_ENCAPS_HDR)))
|
||||
ERROUT(ENOBUFS);
|
||||
ptr = start = mtod(m, u_char *);
|
||||
|
||||
/* Must be UI frame */
|
||||
if (*ptr++ != HDLC_UI)
|
||||
ERROUT(0);
|
||||
|
||||
m_adj(m, ptr - start);
|
||||
NG_SEND_DATA(error, priv->uplink, m, meta); /* m -> NULL */
|
||||
} else if (hook == priv->uplink) {
|
||||
M_PREPEND(m, 1, M_DONTWAIT); /* Prepend IP NLPID */
|
||||
if (!m)
|
||||
ERROUT(ENOBUFS);
|
||||
mtod(m, u_char *)[0] = HDLC_UI;
|
||||
NG_SEND_DATA(error, priv->downlink, m, meta); /* m -> NULL */
|
||||
} else
|
||||
panic(__FUNCTION__);
|
||||
|
||||
done:
|
||||
NG_FREE_DATA(m, meta); /* does nothing if m == NULL */
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown node
|
||||
*/
|
||||
static int
|
||||
ng_UI_rmnode(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
ng_cutlinks(node);
|
||||
ng_unname(node);
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook disconnection
|
||||
*/
|
||||
static int
|
||||
ng_UI_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
|
||||
if (hook->node->numhooks == 0)
|
||||
ng_rmnode(hook->node);
|
||||
else if (hook == priv->downlink)
|
||||
priv->downlink = NULL;
|
||||
else if (hook == priv->uplink)
|
||||
priv->uplink = NULL;
|
||||
else
|
||||
panic(__FUNCTION__);
|
||||
return (0);
|
||||
}
|
||||
|
55
sys/netgraph/ng_UI.h
Normal file
55
sys/netgraph/ng_UI.h
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
/*
|
||||
* ng_UI.h
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Julian Elischer <julian@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: ng_UI.h,v 1.6 1999/01/20 00:54:15 archie Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETGRAPH_UI_H_
|
||||
#define _NETGRAPH_UI_H_
|
||||
|
||||
/* Node type name and cookie */
|
||||
#define NG_UI_NODE_TYPE "UI"
|
||||
#define NGM_UI_NODE_COOKIE 884639499
|
||||
|
||||
/* Hook names */
|
||||
#define NG_UI_HOOK_DOWNSTREAM "downstream"
|
||||
#define NG_UI_HOOK_UPSTREAM "upstream"
|
||||
|
||||
#endif /* _NETGRAPH_UI_H_ */
|
||||
|
586
sys/netgraph/ng_async.c
Normal file
586
sys/netgraph/ng_async.c
Normal file
@ -0,0 +1,586 @@
|
||||
|
||||
/*
|
||||
* ng_async.c
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
* provided, however, that:
|
||||
* 1. Any and all reproductions of the source or object code must include the
|
||||
* copyright notice above and the following disclaimer of warranties; and
|
||||
* 2. No rights are granted, in any manner or form, to use Whistle
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
||||
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
||||
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
||||
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
||||
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
||||
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Archie Cobbs <archie@whistle.com>
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $Whistle: ng_async.c,v 1.15 1999/01/28 23:54:52 julian Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* This node type implements a PPP style sync <-> async converter.
|
||||
* See RFC 1661 for details of how asynchronous encoding works.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <netgraph/ng_async.h>
|
||||
|
||||
#include <net/ppp_defs.h>
|
||||
|
||||
/* Optimize opening and closing flags into one? Set to max # seconds delay */
|
||||
#define SYNC_OPT_TIME 1 /* one second maximum */
|
||||
|
||||
/* Async decode state */
|
||||
#define MODE_HUNT 0
|
||||
#define MODE_NORMAL 1
|
||||
#define MODE_ESC 2
|
||||
|
||||
/* Private data structure */
|
||||
struct private {
|
||||
node_p node; /* Our node */
|
||||
hook_p async; /* Asynchronous side */
|
||||
hook_p sync; /* Synchronous side */
|
||||
hook_p sync2; /* Synchronous side, full escapes */
|
||||
u_char amode; /* Async hunt/esape mode */
|
||||
u_int16_t fcs; /* Decoded async FCS (so far) */
|
||||
u_char *abuf; /* Buffer to encode sync into */
|
||||
u_char *sbuf; /* Buffer to decode async into */
|
||||
u_int slen; /* Length of data in sbuf */
|
||||
#if SYNC_OPT_TIME
|
||||
long lasttime; /* Time of last async packet sent */
|
||||
#endif
|
||||
struct ng_async_cfg cfg; /* Configuration */
|
||||
struct ng_async_stat stats; /* Statistics */
|
||||
};
|
||||
typedef struct private *sc_p;
|
||||
|
||||
/* Useful macros */
|
||||
#define ASYNC_BUF_SIZE(smru) (2 * (smru) + 10)
|
||||
#define SYNC_BUF_SIZE(amru) ((amru) + 10)
|
||||
#define ERROUT(x) do { error = (x); goto done; } while (0)
|
||||
|
||||
/* Netgraph methods */
|
||||
static int nga_constructor(node_p *node);
|
||||
static int nga_rcvdata(hook_p hook, struct mbuf *m, meta_p meta);
|
||||
static int nga_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *rtn, struct ng_mesg **resp);
|
||||
static int nga_shutdown(node_p node);
|
||||
static int nga_newhook(node_p node, hook_p hook, const char *name);
|
||||
static int nga_disconnect(hook_p hook);
|
||||
|
||||
/* Helper stuff */
|
||||
static int nga_rcv_sync(const sc_p sc, struct mbuf *m, meta_p meta);
|
||||
static int nga_rcv_async(const sc_p sc, struct mbuf *m, meta_p meta);
|
||||
|
||||
/* Define the netgraph node type */
|
||||
static struct ng_type typestruct = {
|
||||
NG_VERSION,
|
||||
NG_ASYNC_NODE_TYPE,
|
||||
NULL,
|
||||
nga_constructor,
|
||||
nga_rcvmsg,
|
||||
nga_shutdown,
|
||||
nga_newhook,
|
||||
NULL,
|
||||
NULL,
|
||||
nga_rcvdata,
|
||||
nga_rcvdata,
|
||||
nga_disconnect
|
||||
};
|
||||
NETGRAPH_INIT(async, &typestruct);
|
||||
|
||||
/* CRC table */
|
||||
static const u_int16_t fcstab[];
|
||||
|
||||
/******************************************************************
|
||||
NETGRAPH NODE METHODS
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
* Initialize a new node
|
||||
*/
|
||||
static int
|
||||
nga_constructor(node_p *nodep)
|
||||
{
|
||||
sc_p sc;
|
||||
int error;
|
||||
|
||||
if ((error = ng_make_node_common(&typestruct, nodep)))
|
||||
return (error);
|
||||
MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_WAITOK);
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
bzero(sc, sizeof(*sc));
|
||||
sc->amode = MODE_HUNT;
|
||||
sc->cfg.accm = ~0;
|
||||
sc->cfg.amru = NG_ASYNC_DEFAULT_MRU;
|
||||
sc->cfg.smru = NG_ASYNC_DEFAULT_MRU;
|
||||
MALLOC(sc->abuf, u_char *,
|
||||
ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH, M_WAITOK);
|
||||
if (sc->abuf == NULL)
|
||||
goto fail;
|
||||
MALLOC(sc->sbuf, u_char *,
|
||||
SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH, M_WAITOK);
|
||||
if (sc->sbuf == NULL) {
|
||||
FREE(sc->abuf, M_NETGRAPH);
|
||||
fail:
|
||||
FREE(sc, M_NETGRAPH);
|
||||
return (ENOMEM);
|
||||
}
|
||||
(*nodep)->private = sc;
|
||||
sc->node = *nodep;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reserve a hook for a pending connection
|
||||
*/
|
||||
static int
|
||||
nga_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
hook_p *hookp;
|
||||
|
||||
if (!strcmp(name, NG_ASYNC_HOOK_ASYNC))
|
||||
hookp = &sc->async;
|
||||
else if (!strcmp(name, NG_ASYNC_HOOK_SYNC))
|
||||
hookp = &sc->sync;
|
||||
else if (!strcmp(name, NG_ASYNC_HOOK_SYNC2))
|
||||
hookp = &sc->sync2;
|
||||
else
|
||||
return (EINVAL);
|
||||
if (*hookp)
|
||||
return (EISCONN);
|
||||
*hookp = hook;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive incoming data
|
||||
*/
|
||||
static int
|
||||
nga_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
|
||||
if (hook == sc->sync)
|
||||
return (nga_rcv_sync(sc, m, meta));
|
||||
else if (hook == sc->sync2) {
|
||||
const u_char acfcompSave = sc->cfg.acfcomp;
|
||||
const u_int32_t accmSave = sc->cfg.accm;
|
||||
int rtn;
|
||||
|
||||
sc->cfg.acfcomp = 0;
|
||||
sc->cfg.accm = ~0;
|
||||
rtn = nga_rcv_sync(sc, m, meta);
|
||||
sc->cfg.acfcomp = acfcompSave;
|
||||
sc->cfg.accm = accmSave;
|
||||
return (rtn);
|
||||
} else if (hook == sc->async)
|
||||
return (nga_rcv_async(sc, m, meta));
|
||||
panic(__FUNCTION__);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive incoming control message
|
||||
*/
|
||||
static int
|
||||
nga_rcvmsg(node_p node, struct ng_mesg *msg,
|
||||
const char *rtn, struct ng_mesg **rptr)
|
||||
{
|
||||
const sc_p sc = (sc_p) node->private;
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
|
||||
switch (msg->header.typecookie) {
|
||||
case NGM_ASYNC_COOKIE:
|
||||
switch (msg->header.cmd) {
|
||||
case NGM_ASYNC_CMD_GET_STATS:
|
||||
NG_MKRESPONSE(resp, msg, sizeof(sc->stats), M_NOWAIT);
|
||||
if (resp == NULL)
|
||||
ERROUT(ENOMEM);
|
||||
*((struct ng_async_stat *) resp->data) = sc->stats;
|
||||
break;
|
||||
case NGM_ASYNC_CMD_CLR_STATS:
|
||||
bzero(&sc->stats, sizeof(sc->stats));
|
||||
break;
|
||||
case NGM_ASYNC_CMD_SET_CONFIG:
|
||||
{
|
||||
struct ng_async_cfg *const cfg =
|
||||
(struct ng_async_cfg *) msg->data;
|
||||
u_char *buf;
|
||||
|
||||
if (msg->header.arglen != sizeof(*cfg))
|
||||
ERROUT(EINVAL);
|
||||
if (cfg->amru < NG_ASYNC_MIN_MRU
|
||||
|| cfg->amru > NG_ASYNC_MAX_MRU
|
||||
|| cfg->smru < NG_ASYNC_MIN_MRU
|
||||
|| cfg->smru > NG_ASYNC_MAX_MRU)
|
||||
ERROUT(EINVAL);
|
||||
cfg->enabled = !!cfg->enabled; /* normalize */
|
||||
cfg->acfcomp = !!cfg->acfcomp; /* normalize */
|
||||
if (cfg->smru > sc->cfg.smru) { /* reallocate buffer */
|
||||
MALLOC(buf, u_char *, ASYNC_BUF_SIZE(cfg->smru),
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (!buf)
|
||||
ERROUT(ENOMEM);
|
||||
FREE(sc->abuf, M_NETGRAPH);
|
||||
sc->abuf = buf;
|
||||
}
|
||||
if (cfg->amru > sc->cfg.amru) { /* reallocate buffer */
|
||||
MALLOC(buf, u_char *, SYNC_BUF_SIZE(cfg->amru),
|
||||
M_NETGRAPH, M_NOWAIT);
|
||||
if (!buf)
|
||||
ERROUT(ENOMEM);
|
||||
FREE(sc->sbuf, M_NETGRAPH);
|
||||
sc->sbuf = buf;
|
||||
sc->amode = MODE_HUNT;
|
||||
sc->slen = 0;
|
||||
}
|
||||
if (!cfg->enabled) {
|
||||
sc->amode = MODE_HUNT;
|
||||
sc->slen = 0;
|
||||
}
|
||||
sc->cfg = *cfg;
|
||||
break;
|
||||
}
|
||||
case NGM_ASYNC_CMD_GET_CONFIG:
|
||||
NG_MKRESPONSE(resp, msg, sizeof(sc->cfg), M_NOWAIT);
|
||||
if (!resp)
|
||||
ERROUT(ENOMEM);
|
||||
*((struct ng_async_cfg *) resp->data) = sc->cfg;
|
||||
break;
|
||||
default:
|
||||
ERROUT(EINVAL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ERROUT(EINVAL);
|
||||
}
|
||||
if (rptr)
|
||||
*rptr = resp;
|
||||
else if (resp)
|
||||
FREE(resp, M_NETGRAPH);
|
||||
|
||||
done:
|
||||
FREE(msg, M_NETGRAPH);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown this node
|
||||
*/
|
||||
static int
|
||||
nga_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
|
||||
ng_cutlinks(node);
|
||||
ng_unname(node);
|
||||
FREE(sc->abuf, M_NETGRAPH);
|
||||
FREE(sc->sbuf, M_NETGRAPH);
|
||||
bzero(sc, sizeof(*sc));
|
||||
FREE(sc, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lose a hook. When both hooks go away, we disappear.
|
||||
*/
|
||||
static int
|
||||
nga_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
hook_p *hookp;
|
||||
|
||||
if (hook == sc->async)
|
||||
hookp = &sc->async;
|
||||
else if (hook == sc->sync)
|
||||
hookp = &sc->sync;
|
||||
else if (hook == sc->sync2)
|
||||
hookp = &sc->sync2;
|
||||
else
|
||||
panic(__FUNCTION__);
|
||||
if (!*hookp)
|
||||
panic(__FUNCTION__ "2");
|
||||
*hookp = NULL;
|
||||
bzero(&sc->stats, sizeof(sc->stats));
|
||||
#if SYNC_OPT_TIME
|
||||
sc->lasttime = 0;
|
||||
#endif
|
||||
if (hook->node->numhooks == 0)
|
||||
ng_rmnode(hook->node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
INTERNAL HELPER STUFF
|
||||
******************************************************************/
|
||||
|
||||
/*
|
||||
* Encode a byte into the async buffer
|
||||
*/
|
||||
static __inline__ void
|
||||
nga_async_add(const sc_p sc, u_int16_t *fcs, u_int32_t accm, int *len, u_char x)
|
||||
{
|
||||
*fcs = PPP_FCS(*fcs, x);
|
||||
if ((x < 32 && ((1 << x) & accm))
|
||||
|| (x == PPP_ESCAPE)
|
||||
|| (x == PPP_FLAG)) {
|
||||
sc->abuf[(*len)++] = PPP_ESCAPE;
|
||||
x ^= PPP_TRANS;
|
||||
}
|
||||
sc->abuf[(*len)++] = x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive incoming synchronous data. Any "meta" information means
|
||||
* for us to apply full ACCM to this frame.
|
||||
*/
|
||||
static int
|
||||
nga_rcv_sync(const sc_p sc, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
struct ifnet *const rcvif = m->m_pkthdr.rcvif;
|
||||
u_int16_t fcs, fcs0;
|
||||
int alen, error = 0;
|
||||
|
||||
#define ADD_BYTE(x) \
|
||||
nga_async_add(sc, &fcs, meta ? ~0 : sc->cfg.accm, &alen, (x))
|
||||
|
||||
if (!sc->cfg.enabled) {
|
||||
NG_SEND_DATA(error, sc->async, m, meta);
|
||||
return (error);
|
||||
}
|
||||
if (m->m_pkthdr.len > sc->cfg.smru) {
|
||||
sc->stats.syncOverflows++;
|
||||
NG_FREE_DATA(m, meta);
|
||||
return (EMSGSIZE);
|
||||
}
|
||||
sc->stats.syncFrames++;
|
||||
sc->stats.syncOctets += m->m_pkthdr.len;
|
||||
|
||||
/* Initialize async encoded version of input mbuf */
|
||||
alen = 0;
|
||||
fcs = PPP_INITFCS;
|
||||
|
||||
/* Add beginning sync flag if it's been long enough to need one */
|
||||
#if SYNC_OPT_TIME
|
||||
{
|
||||
struct timeval time;
|
||||
|
||||
getmicrotime(&time);
|
||||
if (time.tv_sec >= sc->lasttime + SYNC_OPT_TIME) {
|
||||
sc->abuf[alen++] = PPP_FLAG;
|
||||
sc->lasttime = time.tv_sec;
|
||||
}
|
||||
}
|
||||
#else
|
||||
sc->abuf[alen++] = PPP_FLAG;
|
||||
#endif
|
||||
|
||||
/* Add option address and control fields, then packet payload */
|
||||
if (!sc->cfg.acfcomp || meta) {
|
||||
ADD_BYTE(PPP_ALLSTATIONS);
|
||||
ADD_BYTE(PPP_UI);
|
||||
}
|
||||
while (m) {
|
||||
struct mbuf *n;
|
||||
|
||||
while (m->m_len > 0) {
|
||||
u_char const ch = *mtod(m, u_char *);
|
||||
|
||||
ADD_BYTE(ch);
|
||||
m->m_data++;
|
||||
m->m_len--;
|
||||
}
|
||||
MFREE(m, n);
|
||||
m = n;
|
||||
}
|
||||
|
||||
/* Add checksum and final sync flag */
|
||||
fcs0 = fcs;
|
||||
ADD_BYTE(~fcs0 & 0xff);
|
||||
ADD_BYTE(~fcs0 >> 8);
|
||||
sc->abuf[alen++] = PPP_FLAG;
|
||||
|
||||
/* Put frame in an mbuf and ship it off */
|
||||
NG_FREE_META(meta);
|
||||
if (!(m = m_devget(sc->abuf, alen, 0, rcvif, NULL)))
|
||||
error = ENOBUFS;
|
||||
else
|
||||
NG_SEND_DATA(error, sc->async, m, meta);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive incoming asynchronous data
|
||||
* XXX technically, we should strip out supposedly escaped characters
|
||||
*/
|
||||
static int
|
||||
nga_rcv_async(const sc_p sc, struct mbuf * m, meta_p meta)
|
||||
{
|
||||
struct ifnet *const rcvif = m->m_pkthdr.rcvif;
|
||||
int error;
|
||||
|
||||
if (!sc->cfg.enabled) {
|
||||
NG_SEND_DATA(error, sc->sync, m, meta);
|
||||
return (error);
|
||||
}
|
||||
NG_FREE_META(meta);
|
||||
while (m) {
|
||||
struct mbuf *n;
|
||||
|
||||
for (; m->m_len > 0; m->m_data++, m->m_len--) {
|
||||
u_char ch = *mtod(m, u_char *);
|
||||
|
||||
sc->stats.asyncOctets++;
|
||||
if (ch == PPP_FLAG) { /* Flag overrides everything */
|
||||
int skip = 0;
|
||||
|
||||
/* Check for runts */
|
||||
if (sc->slen < 2) {
|
||||
if (sc->slen > 0)
|
||||
sc->stats.asyncRunts++;
|
||||
goto reset;
|
||||
}
|
||||
|
||||
/* Verify CRC */
|
||||
if (sc->fcs != PPP_GOODFCS) {
|
||||
sc->stats.asyncBadCheckSums++;
|
||||
goto reset;
|
||||
}
|
||||
sc->slen -= 2;
|
||||
|
||||
/* Strip address and control fields */
|
||||
if (sc->slen >= 2
|
||||
&& sc->sbuf[0] == PPP_ALLSTATIONS
|
||||
&& sc->sbuf[1] == PPP_UI)
|
||||
skip = 2;
|
||||
|
||||
/* Check for frame too big */
|
||||
if (sc->slen - skip > sc->cfg.amru) {
|
||||
sc->stats.asyncOverflows++;
|
||||
goto reset;
|
||||
}
|
||||
|
||||
/* OK, ship it out */
|
||||
if ((n = m_devget(sc->sbuf + skip,
|
||||
sc->slen - skip, 0, rcvif, NULL)))
|
||||
NG_SEND_DATA(error, sc->sync, n, meta);
|
||||
sc->stats.asyncFrames++;
|
||||
reset:
|
||||
sc->amode = MODE_NORMAL;
|
||||
sc->fcs = PPP_INITFCS;
|
||||
sc->slen = 0;
|
||||
continue;
|
||||
}
|
||||
switch (sc->amode) {
|
||||
case MODE_NORMAL:
|
||||
if (ch == PPP_ESCAPE) {
|
||||
sc->amode = MODE_ESC;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case MODE_ESC:
|
||||
ch ^= PPP_TRANS;
|
||||
sc->amode = MODE_NORMAL;
|
||||
break;
|
||||
case MODE_HUNT:
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add byte to frame */
|
||||
if (sc->slen >= SYNC_BUF_SIZE(sc->cfg.amru)) {
|
||||
sc->stats.asyncOverflows++;
|
||||
sc->amode = MODE_HUNT;
|
||||
sc->slen = 0;
|
||||
} else {
|
||||
sc->sbuf[sc->slen++] = ch;
|
||||
sc->fcs = PPP_FCS(sc->fcs, ch);
|
||||
}
|
||||
}
|
||||
MFREE(m, n);
|
||||
m = n;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* CRC table
|
||||
*
|
||||
* Taken from RFC 1171 Appendix B
|
||||
*/
|
||||
static const u_int16_t fcstab[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user