43#include <sys/kernel.h>
44#include <sys/malloc.h>
47#include <sys/socket.h>
48#include <sys/socketvar.h>
50#include <machine/stdarg.h>
55#include <netnatm/unimsg.h>
56#include <netnatm/msg/unistruct.h>
57#include <netnatm/api/unisap.h>
58#include <netnatm/sig/unidef.h>
61#include <netnatm/api/atmapi.h>
63#include <netnatm/api/ccatm.h>
124 const u_char *start,
const u_char *buf)
150 const u_char *start,
const u_char *buf)
334static const struct cc_funcs cc_funcs = {
351 priv = malloc(
sizeof(*
priv), M_NG_CCATM, M_WAITOK | M_ZERO);
354 priv->data = cc_create(&cc_funcs);
355 if (
priv->data == NULL) {
356 free(
priv, M_NG_CCATM);
376 cc_destroy(
priv->data);
378 free(
priv, M_NG_CCATM);
395 struct uni_addr *addrs;
402 err = cc_get_addrs(
priv->data, portno, &addrs, &ports, &
count);
406 len =
sizeof(*list) +
count *
sizeof(list->
addr[0]);
409 free(addrs, M_NG_CCATM);
410 free(ports, M_NG_CCATM);
416 for (i = 0; i <
count; i++) {
421 free(addrs, M_NG_CCATM);
422 free(ports, M_NG_CCATM);
436 if (
priv->dump == NULL) {
437 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
440 priv->dump_first =
priv->dump_last = m;
443 m = m_getcl(M_NOWAIT, MT_DATA, 0);
445 m_freem(
priv->dump_first);
448 priv->dump_last->m_next = m;
452 strcpy(m->m_data, buf);
453 priv->dump_first->m_pkthdr.len += (m->m_len = strlen(buf));
468 priv->dump_first =
priv->dump_last = NULL;
473 if ((m =
priv->dump_first) != NULL) {
474 priv->dump_first =
priv->dump_last = NULL;
513 error = cc_port_stop(
priv->data, arg->
port);
526 error = cc_port_start(
priv->data, arg->
port);
540 error = cc_port_isrunning(
priv->data, arg->
port,
577 error = cc_port_clear(
priv->data, arg->
port);
590 error = cc_addr_register(
priv->data, arg->
port,
604 error = cc_addr_unregister(
priv->data, arg->
port,
624 error = cc_port_get_param(
priv->data, arg->
port,
625 (
struct atm_port_info *)resp->
data);
627 free(resp, M_NETGRAPH_MSG);
635 struct atm_port_info *arg;
641 arg = (
struct atm_port_info *)msg->
data;
642 error = cc_port_set_param(
priv->data, arg);
655 error = cc_port_getlist(
priv->data, &n, &
ports);
660 n *
sizeof(arg->
ports[0]), M_NOWAIT);
662 free(
ports, M_NG_CCATM);
671 free(
ports, M_NG_CCATM);
679 log_level = cc_get_log(
priv->data);
685 cc_set_log(
priv->data, *(uint32_t *)msg->
data);
692 cc_set_log(
priv->data, log_level);
695 *(uint32_t *)resp->
data = log_level;
705 if (
priv->hook_cnt != 0) {
709 cc_reset(
priv->data);
714 struct atm_exstatus s;
715 struct atm_exstatus_ep *eps;
716 struct atm_exstatus_port *ports;
717 struct atm_exstatus_conn *conns;
718 struct atm_exstatus_party *parties;
725 error = cc_get_extended_status(
priv->data,
726 &s, &eps, &ports, &conns, &parties);
730 offs =
sizeof(s) + s.neps *
sizeof(*eps) +
731 s.nports *
sizeof(*ports) +
732 s.nconns *
sizeof(*conns) +
733 s.nparties *
sizeof(*parties);
741 memcpy(resp->
data, &s,
sizeof(s));
744 memcpy(resp->
data + offs, eps,
745 sizeof(*eps) * s.neps);
746 offs +=
sizeof(*eps) * s.neps;
748 memcpy(resp->
data + offs, ports,
749 sizeof(*ports) * s.nports);
750 offs +=
sizeof(*ports) * s.nports;
752 memcpy(resp->
data + offs, conns,
753 sizeof(*conns) * s.nconns);
754 offs +=
sizeof(*conns) * s.nconns;
756 memcpy(resp->
data + offs, parties,
757 sizeof(*parties) * s.nparties);
758 offs +=
sizeof(*parties) * s.nparties;
760 free(eps, M_NG_CCATM);
761 free(ports, M_NG_CCATM);
762 free(conns, M_NG_CCATM);
763 free(parties, M_NG_CCATM);
797 if (strncmp(
name,
"uni", 3) == 0) {
803 lport = strtoul(
name + 3, &end, 10);
804 if (*end !=
'\0' || lport == 0 || lport > 0xffffffff)
807 hd = malloc(
sizeof(*hd), M_NG_CCATM, M_NOWAIT);
814 port = cc_port_create(
priv->data, hd, (u_int)lport);
816 free(hd, M_NG_CCATM);
830 if (strcmp(
name,
"dump") == 0) {
836 if (strcmp(
name,
"manage") == 0) {
845 hd = malloc(
sizeof(*hd), M_NG_CCATM, M_NOWAIT);
854 free(hd, M_NG_CCATM);
878 if (hook ==
priv->dump) {
883 cc_unmanage(
priv->data);
887 cc_port_destroy(hd->
inst, 0);
889 cc_user_destroy(hd->
inst);
893 free(hd, M_NG_CCATM);
932 if (uni_msg_len(msg) <
sizeof(
op)) {
933 printf(
"%s: packet too short\n", __func__);
938 bcopy(msg->b_rptr, &
op,
sizeof(
op));
939 msg->b_rptr +=
sizeof(
op);
941 err = cc_user_signal(hd->
inst,
op.op, msg);
950pack_buf(
void *h,
size_t hlen,
void *t,
size_t tlen)
952 struct mbuf *m, *m0, *
last;
953 u_char *buf = (u_char *)t;
957 MGETHDR(m0, M_NOWAIT, MT_DATA);
961 KASSERT(hlen <= MHLEN, (
"hlen > MHLEN"));
963 bcopy(h, m0->m_data, hlen);
965 m0->m_pkthdr.len = hlen;
968 while ((n = tlen) != 0) {
970 m = m_getcl(M_NOWAIT, MT_DATA, 0);
974 MGET(m, M_NOWAIT, MT_DATA);
982 bcopy(buf, m->m_data, n);
986 m0->m_pkthdr.len += n;
1001 void *val,
size_t len)
1003 struct cchook *hd = uarg;
1009 m =
pack_buf(&h,
sizeof(h), val, len);
1015 printf(
"%s: error=%d\n", __func__, error);
1023 void *val,
size_t len)
1025 struct cchook *hd = uarg;
1029 struct atm_resp resp;
1033 resp.op.op = ATMOP_RESP;
1034 resp.resp.resp = err;
1035 resp.resp.data =
data;
1036 m =
pack_buf(&resp,
sizeof(resp), val, len);
1042 printf(
"%s: error=%d\n", __func__, error);
1052 struct uni_msg *msg;
1066 if (uni_msg_len(msg) <
sizeof(arg)) {
1067 printf(
"%s: packet too short\n", __func__);
1072 bcopy(msg->b_rptr, &arg,
sizeof(arg));
1073 msg->b_rptr +=
sizeof(arg);
1075 if (arg.
sig == UNIAPI_ERROR) {
1076 if (uni_msg_len(msg) !=
sizeof(
struct uniapi_error)) {
1077 printf(
"%s: bad UNIAPI_ERROR size %zu\n", __func__,
1083 ((
struct uniapi_error *)msg->b_rptr)->reason,
1084 ((
struct uniapi_error *)msg->b_rptr)->state);
1098 struct uni_msg *msg)
1100 struct cchook *hd = uarg;
1115 printf(
"%s: error=%d\n", __func__, error);
1123 struct uni_msg *msg)
1125 struct cchook *hd = uarg;
1141 printf(
"%s: error=%d\n", __func__, error);
#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_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
int ng_rmnode_self(node_p here)
#define NG_SEND_DATA_ONLY(error, hook, m)
#define NG_HOOK_FORCE_QUEUE(hook)
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_HOOK_PRIVATE(hook)
static void ng_ccatm_log(const char *,...)
static const struct ng_parse_fixedarray_info ng_ccatm_esi_type_info
static ng_shutdown_t ng_ccatm_shutdown
static ng_disconnect_t ng_ccatm_disconnect
static struct mbuf * pack_buf(void *h, size_t hlen, void *t, size_t tlen)
static int ng_ccatm_dump(node_p node)
static const struct ng_cmdlist ng_ccatm_cmdlist[]
static ng_rcvdata_t ng_ccatm_rcvmanage
static const struct ng_parse_type ng_ccatm_get_addresses_type
static ng_rcvmsg_t ng_ccatm_rcvmsg
static const struct ng_parse_type ng_ccatm_port_type
static const struct ng_parse_type ng_ccatm_port_array_type
static const struct ng_parse_type ng_ccatm_uni_addr_type
static struct ng_type ng_ccatm_typestruct
static const struct ng_parse_type ng_ccatm_portlist_type
static const struct ng_parse_struct_field ng_ccatm_uni_addr_type_info[]
static void ng_ccatm_send_uni_glob(struct ccport *, void *, u_int, u_int, struct uni_msg *)
static void ng_ccatm_send_user(struct ccuser *, void *, u_int, void *, size_t)
static int send_dump(struct ccdata *data, void *uarg, const char *buf)
static int ng_ccatm_addr_req_array_getlen(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
static const struct ng_parse_type ng_ccatm_atm_port_type
static int ng_ccatm_get_addresses(node_p node, uint32_t portno, struct ng_mesg *msg, struct ng_mesg **resp)
static ng_newhook_t ng_ccatm_newhook
static ng_rcvdata_t ng_ccatm_rcvdata
static const struct ng_parse_type ng_ccatm_addr_array_type
static ng_rcvdata_t ng_ccatm_rcvdump
MODULE_DEPEND(ng_ccatm, ngatmbase, 1, 1, 1)
static const struct ng_parse_struct_field ng_ccatm_get_addresses_type_info[]
static const struct ng_parse_array_info ng_ccatm_addr_req_array_type_info
static const struct ng_parse_struct_field ng_ccatm_atm_port_type_info[]
static int ng_ccatm_port_array_getlen(const struct ng_parse_type *type, const u_char *start, const u_char *buf)
static ng_constructor_t ng_ccatm_constructor
NETGRAPH_INIT(ccatm, &ng_ccatm_typestruct)
static void ng_ccatm_respond_user(struct ccuser *, void *, int, u_int, void *, size_t)
static const struct ng_parse_array_info ng_ccatm_port_array_type_info
static const struct ng_parse_struct_field ng_ccatm_addr_req_type_info[]
static void ng_ccatm_send_uni(struct ccconn *, void *, u_int, u_int, struct uni_msg *)
static const struct ng_parse_fixedarray_info ng_ccatm_addr_array_type_info
static const struct ng_parse_type ng_ccatm_addr_req_type
static const struct ng_parse_struct_field ng_ccatm_portlist_type_info[]
static int ng_ccatm_mod_event(module_t, int, void *)
static const struct ng_parse_type ng_ccatm_addr_req_array_type
MALLOC_DEFINE(M_NG_CCATM, "ng_ccatm", "netgraph uni api node")
static ng_rcvdata_t ng_ccatm_rcvuni
static const struct ng_parse_type ng_ccatm_esi_type
static const struct ng_parse_struct_field ng_ccatm_port_type_info[]
#define NGM_CCATM_ESI_INFO
#define NGM_CCATM_PORT_INFO
@ NGM_CCATM_ADDRESS_REGISTERED
@ NGM_CCATM_ADDRESS_UNREGISTERED
@ NGM_CCATM_SET_PORT_PARAM
@ NGM_CCATM_GET_PORT_PARAM
@ NGM_CCATM_GET_ADDRESSES
#define NG_CCATM_NODE_TYPE
#define NGM_CCATM_ADDR_REQ_ARRAY_INFO
#define NGM_CCATM_UNI_ADDR_INFO
#define NGM_CCATM_GET_ADDRESSES_INFO
#define NGM_CCATM_PORT_ARRAY_INFO
#define NGM_CCATM_PORTLIST_INFO
#define NGM_CCATM_ADDR_REQ_INFO
#define NGM_CCATM_ADDR_ARRAY_INFO
#define NGM_CCATM_ATM_PORT_INFO
#define NG_MKRESPONSE(rsp, msg, len, how)
const struct ng_parse_type ng_parse_fixedarray_type
const struct ng_parse_type ng_parse_array_type
const struct ng_parse_type ng_parse_struct_type
const struct ng_parse_type ng_parse_uint32_type
const struct ng_parse_type ng_parse_hint32_type
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
struct ngm_ccatm_addr_req addr[]