47#include <sys/kernel.h>
48#include <sys/socket.h>
49#include <sys/malloc.h>
51#include <sys/syslog.h>
55#include <netinet/in.h>
56#include <netinet/if_ether.h>
63#define CISCO_MULTICAST 0x8f
64#define CISCO_UNICAST 0x0f
65#define CISCO_KEEPALIVE 0x8035
66#define CISCO_ADDR_REQ 0
67#define CISCO_ADDR_REPLY 1
68#define CISCO_KEEPALIVE_REQ 2
70#define KEEPALIVE_SECS 10
78#define CISCO_HEADER_LEN sizeof (struct cisco_header)
89#define CISCO_PACKET_LEN (sizeof(struct cisco_packet))
191 sc = malloc(
sizeof(*sc), M_NETGRAPH, M_WAITOK | M_ZERO);
198 sc->downstream.af = 0xffff;
199 sc->inet.af = AF_INET;
200 sc->inet6.af = AF_INET6;
201 sc->atalk.af = AF_APPLETALK;
215 sc->downstream.hook = hook;
222 sc->inet.hook = hook;
225 sc->inet6.hook = hook;
228 sc->atalk.hook = hook;
265 arg = (
char *) resp->
data;
268 pos += sprintf(arg + pos,
269 "unacknowledged keepalives: %d", sc->seqRetries);
285 2 *
sizeof(*ips), M_NOWAIT);
290 ips = (
struct in_addr *) resp->
data;
291 ips[0] = sc->localip;
292 ips[1] = sc->localmask;
298 struct in_addr *
const ips = (
struct in_addr *)msg->
data;
304 sc->localip = ips[0];
305 sc->localmask = ips[1];
352 if (pep->
af == 0xffff)
373 h->
protocol = htons(ETHERTYPE_IPV6);
382 error = EAFNOSUPPORT;
405 free(sc, M_NETGRAPH);
423 if (pep->
af == 0xffff)
451 if (m->m_pkthdr.len <
sizeof(*h)) {
457 if (m->m_len >=
sizeof(*h))
460 m_copydata(m, 0,
sizeof(*h), (caddr_t)&hdrbuf);
463 m_adj(m,
sizeof(*h));
481 if (m->m_pkthdr.len <
sizeof(*p)) {
487 if (m->m_len >=
sizeof(*p))
490 m_copydata(m, 0,
sizeof(*p), (caddr_t)&pktbuf);
495 switch (ntohl(p->
type)) {
498 "cisco: unknown cisco packet type: 0x%lx\n",
499 (
long)ntohl(p->
type));
505 sc->remote_seq = ntohl(p->
par1);
506 if (sc->local_seq == ntohl(p->
par2)) {
508 if (sc->seqRetries > 1)
519 if (sc->inet.hook == NULL)
526 sc->
node, msg, sc->inet.hook, 0);
535 ntohl(sc->localip.s_addr),
536 ntohl(sc->localmask.s_addr));
559 if (m->m_pkthdr.len == 0) {
565 if (pep->
hook == NULL)
581 const sc_p sc = arg1;
584 if (sc->seqRetries++ > 1)
603 getmicrouptime(&time);
605 MGETHDR(m, M_NOWAIT, MT_DATA);
609 t = time.tv_sec * 1000 + time.tv_usec / 1000;
611 m->m_pkthdr.rcvif = 0;
623 ch->
time0 = htons((uint16_t) (t >> 16));
624 ch->
time1 = htons((uint16_t) t);
639 if (sc->inet.hook == NULL)
#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_callout_init(c)
#define NG_FWD_NEW_DATA(error, item, hook, m)
#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)
int ng_uncallout(struct callout *c, node_p node)
#define NG_FREE_ITEM(item)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks, ng_item_fn *fn, void *arg1, int arg2)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_HOOK_PRIVATE(hook)
struct cisco_header __packed
static const struct ng_parse_struct_field ng_cisco_stats_type_fields[]
static void cisco_keepalive(node_p node, hook_p hook, void *arg1, int arg2)
static const struct ng_parse_type ng_cisco_stats_type
static int cisco_input(sc_p sc, item_p item)
static const struct ng_cmdlist ng_cisco_cmdlist[]
#define CISCO_KEEPALIVE_REQ
static ng_shutdown_t cisco_shutdown
static const struct ng_parse_struct_field ng_cisco_ipaddr_type_fields[]
static ng_newhook_t cisco_newhook
static ng_rcvdata_t cisco_rcvdata
static ng_constructor_t cisco_constructor
static struct ng_type typestruct
static int cisco_send(sc_p sc, int type, long par1, long par2)
static ng_disconnect_t cisco_disconnect
NETGRAPH_INIT(cisco, &typestruct)
static const struct ng_parse_type ng_cisco_ipaddr_type
static ng_rcvmsg_t cisco_rcvmsg
static void cisco_notify(sc_p sc, uint32_t cmd)
#define NG_CISCO_HOOK_DOWNSTREAM
#define NG_CISCO_HOOK_DEBUG
#define NG_CISCO_HOOK_INET6
#define NG_CISCO_IPADDR_TYPE_INFO
#define NG_CISCO_HOOK_INET
#define NG_CISCO_HOOK_APPLETALK
#define NG_CISCO_HOOK_IPX
#define NG_CISCO_NODE_TYPE
#define NG_CISCO_STATS_TYPE_INFO
#define NG_MKRESPONSE(rsp, msg, len, how)
#define NGM_GENERIC_COOKIE
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
const struct ng_parse_type ng_parse_struct_type
struct protoent downstream
struct ng_mesg::ng_msghdr header