39#include <sys/kernel.h>
40#include <sys/malloc.h>
43#include <sys/syslog.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/callout.h>
48#include <machine/stdarg.h>
53#include <netnatm/unimsg.h>
54#include <netnatm/msg/unistruct.h>
56#include <netnatm/saal/sscopdef.h>
57#include <netnatm/saal/sscfudef.h>
59#include <netnatm/sig/uni.h>
60#include <netnatm/sig/unisig.h>
65static MALLOC_DEFINE(M_NG_UNI,
"netgraph_uni_node",
"netgraph uni node");
203static void uni_uni_output(
struct uni *,
void *,
enum uni_sig, u_int32_t,
207static void uni_verbose(
struct uni *,
void *, u_int,
const char *, ...)
209static
void uni_do_status(struct uni *,
void *,
void *, const
char *, ...)
212static const struct uni_funcs uni_funcs = {
228 priv = malloc(
sizeof(*
priv), M_NG_UNI, M_WAITOK | M_ZERO);
230 if ((
priv->
uni = uni_create(node, &uni_funcs)) == NULL) {
231 free(
priv, M_NG_UNI);
248 free(
priv, M_NG_UNI);
266 sbuf_printf(sbuf, fmt, ap);
276 sbuf_new(&sbuf, buf, len, 0);
279 sbuf_printf(&sbuf,
"lower hook: connected to %s:%s\n",
283 sbuf_printf(&sbuf,
"lower hook: <not connected>\n");
286 sbuf_printf(&sbuf,
"upper hook: connected to %s:%s\n",
290 sbuf_printf(&sbuf,
"upper hook: <not connected>\n");
292 sbuf_printf(&sbuf,
"debugging:");
293 for (f = 0; f < UNI_MAXFACILITY; f++)
294 if (uni_get_debug(
priv->
uni, f) != 0)
295 sbuf_printf(&sbuf,
" %s=%u", uni_facname(f),
297 sbuf_printf(&sbuf,
"\n");
303 return (sbuf_len(&sbuf));
348 for (i = 0; i < UNI_MAXFACILITY; i++)
363 for (i = 0; i < UNI_MAXFACILITY; i++)
370 struct uni_config *config;
381 config = (
struct uni_config *)resp->
data;
382 uni_get_config(
priv->
uni, config);
448 *(u_int32_t *)resp->
data =
478 if (strcmp(
name,
"lower") == 0) {
480 }
else if(strcmp(
name,
"upper") == 0) {
500 printf(
"%s: bogus hook %s\n", __func__,
NG_HOOK_NAME(hook));
543 if (uni_msg_len(msg) <
sizeof(arg)) {
544 printf(
"%s: packet too short\n", __func__);
549 bcopy(msg->b_rptr, &arg,
sizeof(arg));
550 msg->b_rptr +=
sizeof(arg);
552 if (arg.
sig >= UNIAPI_MAXSIG) {
553 printf(
"%s: bogus signal\n", __func__);
598 for (pos = 0; pos < uni_msg_len(msg); pos++) {
600 printf(
"%06o ", pos);
603 printf(
" %02x", msg->b_rptr[pos]);
619 printf(
"signal %s SAAL: ", to ?
"to" :
"from");
622#define D(S) case S: printf("%s", #S); break
624 D(SAAL_ESTABLISH_request);
625 D(SAAL_ESTABLISH_indication);
626 D(SAAL_ESTABLISH_confirm);
627 D(SAAL_RELEASE_request);
628 D(SAAL_RELEASE_confirm);
629 D(SAAL_RELEASE_indication);
630 D(SAAL_DATA_request);
631 D(SAAL_DATA_indication);
632 D(SAAL_UDATA_request);
633 D(SAAL_UDATA_indication);
637 printf(
"sig=%d", sig);
break;
640 printf(
" data=%zu\n", uni_msg_len(msg));
641 if (uni_get_debug(
priv->
uni, UNI_FAC_SAAL) > 1)
678 if (uni_msg_len(msg) <
sizeof(arg)) {
680 printf(
"%s: packet too short\n", __func__);
683 bcopy(msg->b_rptr, &arg,
sizeof(arg));
684 msg->b_rptr +=
sizeof(arg);
686 if (arg.
sig > SAAL_UDATA_indication) {
688 printf(
"%s: bogus signal\n", __func__);
692 if (uni_get_debug(
priv->
uni, UNI_FAC_SAAL) > 0)
714 if (uni_get_debug(
priv->
uni, UNI_FAC_SAAL) > 0)
735uni_verbose(
struct uni *uni,
void *varg, u_int fac,
const char *fmt, ...)
739 static char *facnames[] = {
740#define UNI_DEBUG_DEFINE(D) [UNI_FAC_##D] = #D,
742#undef UNI_DEBUG_DEFINE
745 printf(
"%s: ", facnames[fac]);
806 LIST_REMOVE(h, link);
811 LIST_REMOVE(h, link);
812 printf(
"ng_uni: %s in use: %p (%s,%u)\n",
836 LIST_REMOVE(d, link);
844 if ((d = malloc(full, M_UNI, M_NOWAIT | M_ZERO)) == NULL)
873 LIST_REMOVE(d, link);
883 printf(
"ng_uni: %s,%u: %p(%s) was never allocated\n",
886 printf(
"ng_uni: %s,%u: %p(%s) was already destroyed "
#define NG_HOOK_NODE(hook)
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_RESPOND_MSG(error, here, item, resp)
#define NG_NODE_IS_VALID(node)
#define NG_NODE_FORCE_WRITER(node)
#define NG_HOOK_PEER(hook)
#define NG_NODE_UNREF(node)
#define NG_NODE_NAME(node)
int ng_rmnode_self(node_p here)
#define NG_SEND_DATA_ONLY(error, hook, m)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
#define NG_HOOK_NAME(hook)
#define NG_FREE_ITEM(item)
#define NG_HOOK_SET_RCVDATA(hook, val)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_MKRESPONSE(rsp, msg, len, how)
#define NGM_GENERIC_COOKIE
const struct ng_parse_type ng_parse_fixedarray_type
const struct ng_parse_type ng_parse_struct_type
const struct ng_parse_type ng_parse_uint32_type
static struct unimem_debug_list nguni_usedmem[UNIMEM_TYPES]
static struct unimem_debug_list nguni_freemem[UNIMEM_TYPES]
static const struct ng_parse_fixedarray_info ng_uni_debuglevel_type_info
static void uni_uni_output(struct uni *, void *, enum uni_sig, u_int32_t, struct uni_msg *)
static int ng_uni_mod_event(module_t, int, void *)
static const struct ng_parse_type ng_uni_debug_type
static ng_rcvmsg_t ng_uni_rcvmsg
static int text_status(node_p node, struct priv *priv, char *buf, u_int len)
static void uni_fini(void)
static ng_newhook_t ng_uni_newhook
static ng_rcvdata_t ng_uni_rcvlower
static void uni_saal_output(struct uni *, void *, enum saal_sig, struct uni_msg *)
static const struct ng_parse_struct_field ng_uni_set_config_type_info[]
MODULE_DEPEND(ng_uni, ngatmbase, 1, 1, 1)
static const struct ng_cmdlist ng_uni_cmdlist[]
static const struct ng_parse_type ng_uni_debuglevel_type
static void uni_verbose(struct uni *, static void uni_do_status(struct uni void *, u_int, static void uni_do_status(struct uni const char *,...)
static const struct ng_parse_type ng_uni_set_config_type
LIST_HEAD(unimem_debug_list, unimem_debug)
static const char * unimem_names[UNIMEM_TYPES]
void * ng_uni_malloc(enum unimem type, const char *file, u_int lno)
static const struct ng_parse_struct_field ng_uni_config_type_info[]
static const struct ng_parse_struct_field ng_uni_config_mask_type_info[]
static ng_constructor_t ng_uni_constructor
static struct mtx nguni_unilist_mtx
static void dump_saal_signal(node_p node, enum saal_sig sig, struct uni_msg *msg, int to)
static ng_shutdown_t ng_uni_shutdown
NETGRAPH_INIT(uni, &ng_uni_typestruct)
static void uni_do_status(struct uni *uni, void *uarg, void *sbuf, const char *fmt,...)
static const struct ng_parse_type ng_uni_config_mask_type
static void dump_uni_msg(struct uni_msg *msg)
static const struct ng_parse_type ng_uni_config_type
static ng_rcvdata_t ng_uni_rcvupper
static void uni_init(void)
static const struct ng_parse_struct_field ng_uni_debug_type_info[]
static ng_disconnect_t ng_uni_disconnect
static struct ng_type ng_uni_typestruct
void ng_uni_free(enum unimem type, void *ptr, const char *file, u_int lno)
static MALLOC_DEFINE(M_NG_UNI, "netgraph_uni_node", "netgraph uni node")
#define NGM_UNI_CONFIG_INFO
#define NGM_UNI_CONFIG_MASK_INFO
#define NGM_UNI_SET_CONFIG_INFO
#define NGM_UNI_DEBUG_INFO
#define NGM_UNI_DEBUGLEVEL_INFO
size_t unimem_sizes[UNIMEM_TYPES]
int uni_msg_unpack_mbuf(struct mbuf *m, struct uni_msg **pmsg)
struct mbuf * uni_msg_pack_mbuf(struct uni_msg *msg, void *hdr, size_t hdrlen)
void uni_msg_destroy(struct uni_msg *m)
struct ng_mesg::ng_msghdr header
uint32_t level[UNI_MAXFACILITY]
struct ngm_uni_config_mask mask