FreeBSD kernel netgraph code
ng_tty.c File Reference
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/ioccom.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/priv.h>
#include <sys/socket.h>
#include <sys/syslog.h>
#include <sys/tty.h>
#include <sys/ttycom.h>
#include <sys/proc.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_tty.h>
Include dependency graph for ng_tty.c:

Go to the source code of this file.

Data Structures

struct  ngt_softc
 

Macros

#define FLG_DEBUG   0x0002
 
#define ERROUT(x)   do { error = (x); goto done; } while (0)
 
#define NGTLOCK(sc)   IF_LOCK(&sc->outq)
 
#define NGTUNLOCK(sc)   IF_UNLOCK(&sc->outq)
 

Typedefs

typedef struct ngt_softcsc_p
 

Functions

 NETGRAPH_INIT (tty, &typestruct)
 
static int ngt_constructor (node_p node)
 
static int ngt_newhook (node_p node, hook_p hook, const char *name)
 
static int ngt_connect (hook_p hook)
 
static int ngt_disconnect (hook_p hook)
 
static int ngt_shutdown (node_p node)
 
static int ngt_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ngt_rcvdata (hook_p hook, item_p item)
 
static size_t ngt_getc_inject (struct tty *tp, void *buf, size_t len)
 
static size_t ngt_getc_poll (struct tty *tp)
 
static size_t ngt_rint_bypass (struct tty *tp, const void *buf, size_t len)
 
static int ngt_rint (struct tty *tp, char c, int flags)
 
static size_t ngt_rint_poll (struct tty *tp)
 

Variables

static ng_constructor_t ngt_constructor
 
static ng_rcvmsg_t ngt_rcvmsg
 
static ng_shutdown_t ngt_shutdown
 
static ng_newhook_t ngt_newhook
 
static ng_connect_t ngt_connect
 
static ng_rcvdata_t ngt_rcvdata
 
static ng_disconnect_t ngt_disconnect
 
static th_getc_inject_t ngt_getc_inject
 
static th_getc_poll_t ngt_getc_poll
 
static th_rint_t ngt_rint
 
static th_rint_bypass_t ngt_rint_bypass
 
static th_rint_poll_t ngt_rint_poll
 
static struct ttyhook ngt_hook
 
static struct ng_type typestruct
 

Macro Definition Documentation

◆ ERROUT

#define ERROUT (   x)    do { error = (x); goto done; } while (0)

Definition at line 110 of file ng_tty.c.

◆ FLG_DEBUG

#define FLG_DEBUG   0x0002

Definition at line 99 of file ng_tty.c.

◆ NGTLOCK

#define NGTLOCK (   sc)    IF_LOCK(&sc->outq)

Definition at line 140 of file ng_tty.c.

◆ NGTUNLOCK

#define NGTUNLOCK (   sc)    IF_UNLOCK(&sc->outq)

Definition at line 141 of file ng_tty.c.

Typedef Documentation

◆ sc_p

typedef struct ngt_softc* sc_p

Definition at line 96 of file ng_tty.c.

Function Documentation

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( tty  ,
typestruct 
)

◆ ngt_connect()

static int ngt_connect ( hook_p  hook)
static

Definition at line 197 of file ng_tty.c.

References NG_HOOK_FORCE_QUEUE.

◆ ngt_constructor()

static int ngt_constructor ( node_p  node)
static

Definition at line 154 of file ng_tty.c.

References ifqmaxlen, NG_NODE_SET_PRIVATE, and ng_async_private::node.

◆ ngt_disconnect()

static int ngt_disconnect ( hook_p  hook)
static

Definition at line 207 of file ng_tty.c.

References NG_HOOK_NODE, NG_NODE_PRIVATE, NGTLOCK, and NGTUNLOCK.

◆ ngt_getc_inject()

static size_t ngt_getc_inject ( struct tty *  tp,
void *  buf,
size_t  len 
)
static

Definition at line 349 of file ng_tty.c.

References length, and min.

◆ ngt_getc_poll()

static size_t ngt_getc_poll ( struct tty *  tp)
static

Definition at line 393 of file ng_tty.c.

◆ ngt_newhook()

static int ngt_newhook ( node_p  node,
hook_p  hook,
const char *  name 
)
static

Definition at line 174 of file ng_tty.c.

References name, NG_NODE_PRIVATE, NG_TTY_HOOK, NGTLOCK, and NGTUNLOCK.

◆ ngt_rcvdata()

static int ngt_rcvdata ( hook_p  hook,
item_p  item 
)
static

Definition at line 311 of file ng_tty.c.

References NG_FREE_ITEM, NG_FREE_M, NG_HOOK_NODE, NG_NODE_PRIVATE, and NGI_GET_M.

◆ ngt_rcvmsg()

◆ ngt_rint()

static int ngt_rint ( struct tty *  tp,
char  c,
int  flags 
)
static

Definition at line 455 of file ng_tty.c.

References flags, FLG_DEBUG, NG_NODE_NAME, NG_SEND_DATA_ONLY, and ng_async_private::node.

◆ ngt_rint_bypass()

static size_t ngt_rint_bypass ( struct tty *  tp,
const void *  buf,
size_t  len 
)
static

Definition at line 407 of file ng_tty.c.

References FLG_DEBUG, length, min, NG_NODE_NAME, NG_SEND_DATA_ONLY, and ng_async_private::node.

◆ ngt_rint_poll()

static size_t ngt_rint_poll ( struct tty *  tp)
static

Definition at line 505 of file ng_tty.c.

◆ ngt_shutdown()

static int ngt_shutdown ( node_p  node)
static

Definition at line 225 of file ng_tty.c.

References NG_NODE_PRIVATE, NG_NODE_UNREF, and ng_async_private::node.

Variable Documentation

◆ ngt_connect

ng_connect_t ngt_connect
static

Definition at line 106 of file ng_tty.c.

◆ ngt_constructor

ng_constructor_t ngt_constructor
static

Definition at line 102 of file ng_tty.c.

◆ ngt_disconnect

ng_disconnect_t ngt_disconnect
static

Definition at line 108 of file ng_tty.c.

◆ ngt_getc_inject

th_getc_inject_t ngt_getc_inject
static

Definition at line 112 of file ng_tty.c.

◆ ngt_getc_poll

th_getc_poll_t ngt_getc_poll
static

Definition at line 113 of file ng_tty.c.

◆ ngt_hook

struct ttyhook ngt_hook
static
Initial value:
= {
.th_getc_inject = ngt_getc_inject,
.th_getc_poll = ngt_getc_poll,
.th_rint = ngt_rint,
.th_rint_bypass = ngt_rint_bypass,
.th_rint_poll = ngt_rint_poll,
}
static th_rint_poll_t ngt_rint_poll
Definition: ng_tty.c:116
static th_getc_inject_t ngt_getc_inject
Definition: ng_tty.c:112
static th_rint_t ngt_rint
Definition: ng_tty.c:114
static th_getc_poll_t ngt_getc_poll
Definition: ng_tty.c:113
static th_rint_bypass_t ngt_rint_bypass
Definition: ng_tty.c:115

Definition at line 118 of file ng_tty.c.

Referenced by ngt_rcvmsg().

◆ ngt_newhook

ng_newhook_t ngt_newhook
static

Definition at line 105 of file ng_tty.c.

◆ ngt_rcvdata

ng_rcvdata_t ngt_rcvdata
static

Definition at line 107 of file ng_tty.c.

◆ ngt_rcvmsg

ng_rcvmsg_t ngt_rcvmsg
static

Definition at line 103 of file ng_tty.c.

◆ ngt_rint

th_rint_t ngt_rint
static

Definition at line 114 of file ng_tty.c.

◆ ngt_rint_bypass

th_rint_bypass_t ngt_rint_bypass
static

Definition at line 115 of file ng_tty.c.

◆ ngt_rint_poll

th_rint_poll_t ngt_rint_poll
static

Definition at line 116 of file ng_tty.c.

◆ ngt_shutdown

ng_shutdown_t ngt_shutdown
static

Definition at line 104 of file ng_tty.c.

◆ typestruct

struct ng_type typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ngt_constructor,
.rcvmsg = ngt_rcvmsg,
.shutdown = ngt_shutdown,
.newhook = ngt_newhook,
.connect = ngt_connect,
.rcvdata = ngt_rcvdata,
.disconnect = ngt_disconnect,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_disconnect_t ngt_disconnect
Definition: ng_tty.c:108
static ng_rcvmsg_t ngt_rcvmsg
Definition: ng_tty.c:103
static ng_connect_t ngt_connect
Definition: ng_tty.c:106
static ng_constructor_t ngt_constructor
Definition: ng_tty.c:102
static ng_newhook_t ngt_newhook
Definition: ng_tty.c:105
static ng_rcvdata_t ngt_rcvdata
Definition: ng_tty.c:107
static ng_shutdown_t ngt_shutdown
Definition: ng_tty.c:104
#define NG_TTY_NODE_TYPE
Definition: ng_tty.h:49

Definition at line 127 of file ng_tty.c.