Lines Matching +full:protocol +full:- +full:node
5 /*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
63 #define CISCO_KEEPALIVE 0x8035 /* Cisco keepalive protocol */
73 uint16_t protocol; member
91 uint16_t af; /* address family, -1 = downstream */
99 node_p node; member
121 static void cisco_keepalive(node_p node, hook_p hook, void *arg1, int arg2);
167 /* Node type */
182 * Node constructor
185 cisco_constructor(node_p node) in cisco_constructor() argument
191 ng_callout_init(&sc->handle); in cisco_constructor()
192 NG_NODE_SET_PRIVATE(node, sc); in cisco_constructor()
193 sc->node = node; in cisco_constructor()
195 /* Initialise the varous protocol hook holders */ in cisco_constructor()
196 sc->downstream.af = 0xffff; in cisco_constructor()
197 sc->inet.af = AF_INET; in cisco_constructor()
198 sc->inet6.af = AF_INET6; in cisco_constructor()
199 sc->atalk.af = AF_APPLETALK; in cisco_constructor()
200 sc->ipx.af = AF_IPX; in cisco_constructor()
208 cisco_newhook(node_p node, hook_p hook, const char *name) in cisco_newhook() argument
210 const sc_p sc = NG_NODE_PRIVATE(node); in cisco_newhook()
213 sc->downstream.hook = hook; in cisco_newhook()
214 NG_HOOK_SET_PRIVATE(hook, &sc->downstream); in cisco_newhook()
217 ng_callout(&sc->handle, node, NULL, (hz * KEEPALIVE_SECS), in cisco_newhook()
220 sc->inet.hook = hook; in cisco_newhook()
221 NG_HOOK_SET_PRIVATE(hook, &sc->inet); in cisco_newhook()
223 sc->inet6.hook = hook; in cisco_newhook()
224 NG_HOOK_SET_PRIVATE(hook, &sc->inet6); in cisco_newhook()
226 sc->atalk.hook = hook; in cisco_newhook()
227 NG_HOOK_SET_PRIVATE(hook, &sc->atalk); in cisco_newhook()
229 sc->ipx.hook = hook; in cisco_newhook()
230 NG_HOOK_SET_PRIVATE(hook, &sc->ipx); in cisco_newhook()
242 cisco_rcvmsg(node_p node, item_p item, hook_p lasthook) in cisco_rcvmsg() argument
245 const sc_p sc = NG_NODE_PRIVATE(node); in cisco_rcvmsg()
250 switch (msg->header.typecookie) { in cisco_rcvmsg()
252 switch (msg->header.cmd) { in cisco_rcvmsg()
263 arg = (char *) resp->data; in cisco_rcvmsg()
267 "unacknowledged keepalives: %d", sc->seqRetries); in cisco_rcvmsg()
268 resp->header.arglen = pos + 1; in cisco_rcvmsg()
277 switch (msg->header.cmd) { in cisco_rcvmsg()
279 if ((msg->header.flags & NGF_RESP) == 0) { in cisco_rcvmsg()
288 ips = (struct in_addr *) resp->data; in cisco_rcvmsg()
289 ips[0] = sc->localip; in cisco_rcvmsg()
290 ips[1] = sc->localmask; in cisco_rcvmsg()
296 struct in_addr *const ips = (struct in_addr *)msg->data; in cisco_rcvmsg()
298 if (msg->header.arglen < 2 * sizeof(*ips)) { in cisco_rcvmsg()
302 sc->localip = ips[0]; in cisco_rcvmsg()
303 sc->localmask = ips[1]; in cisco_rcvmsg()
315 stat = (struct ng_cisco_stats *)resp->data; in cisco_rcvmsg()
316 stat->seqRetries = sc->seqRetries; in cisco_rcvmsg()
317 stat->keepAlivePeriod = KEEPALIVE_SECS; in cisco_rcvmsg()
329 NG_RESPOND_MSG(error, node, item, resp); in cisco_rcvmsg()
350 if (pep->af == 0xffff) in cisco_rcvdata()
353 /* OK so it came from a protocol, heading out. Prepend general data in cisco_rcvdata()
363 h->address = CISCO_UNICAST; in cisco_rcvdata()
364 h->control = 0; in cisco_rcvdata()
366 switch (pep->af) { in cisco_rcvdata()
367 case AF_INET: /* Internet Protocol */ in cisco_rcvdata()
368 h->protocol = htons(ETHERTYPE_IP); in cisco_rcvdata()
371 h->protocol = htons(ETHERTYPE_IPV6); in cisco_rcvdata()
373 case AF_APPLETALK: /* AppleTalk Protocol */ in cisco_rcvdata()
374 h->protocol = htons(ETHERTYPE_AT); in cisco_rcvdata()
376 case AF_IPX: /* Novell IPX Protocol */ in cisco_rcvdata()
377 h->protocol = htons(ETHERTYPE_IPX); in cisco_rcvdata()
385 NG_FWD_NEW_DATA(error, item, sc->downstream.hook, m); in cisco_rcvdata()
394 * Shutdown node
397 cisco_shutdown(node_p node) in cisco_shutdown() argument
399 const sc_p sc = NG_NODE_PRIVATE(node); in cisco_shutdown()
401 NG_NODE_SET_PRIVATE(node, NULL); in cisco_shutdown()
402 NG_NODE_UNREF(sc->node); in cisco_shutdown()
410 * For this type, removal of the last link destroys the node
420 pep->hook = NULL; in cisco_disconnect()
421 if (pep->af == 0xffff) in cisco_disconnect()
423 ng_uncallout(&sc->handle, NG_HOOK_NODE(hook)); in cisco_disconnect()
426 /* If no more hooks, remove the node */ in cisco_disconnect()
449 if (m->m_pkthdr.len < sizeof(*h)) { in cisco_input()
455 if (m->m_len >= sizeof(*h)) /* the common case */ in cisco_input()
464 switch (h->address) { in cisco_input()
470 switch (ntohs(h->protocol)) { in cisco_input()
479 if (m->m_pkthdr.len < sizeof(*p)) { in cisco_input()
485 if (m->m_len >= sizeof(*p)) /* the common case */ in cisco_input()
493 switch (ntohl(p->type)) { in cisco_input()
497 (long)ntohl(p->type)); in cisco_input()
503 sc->remote_seq = ntohl(p->par1); in cisco_input()
504 if (sc->local_seq == ntohl(p->par2)) { in cisco_input()
505 sc->local_seq++; in cisco_input()
506 if (sc->seqRetries > 1) in cisco_input()
508 sc->seqRetries = 0; in cisco_input()
517 if (sc->inet.hook == NULL) in cisco_input()
524 sc->node, msg, sc->inet.hook, 0); in cisco_input()
533 ntohl(sc->localip.s_addr), in cisco_input()
534 ntohl(sc->localmask.s_addr)); in cisco_input()
541 pep = &sc->inet; in cisco_input()
544 pep = &sc->inet6; in cisco_input()
547 pep = &sc->atalk; in cisco_input()
550 pep = &sc->ipx; in cisco_input()
557 if (m->m_pkthdr.len == 0) { in cisco_input()
563 if (pep->hook == NULL) in cisco_input()
565 NG_FWD_NEW_DATA(error, item, pep->hook, m); in cisco_input()
577 cisco_keepalive(node_p node, hook_p hook, void *arg1, int arg2) in cisco_keepalive() argument
581 cisco_send(sc, CISCO_KEEPALIVE_REQ, sc->local_seq, sc->remote_seq); in cisco_keepalive()
582 if (sc->seqRetries++ > 1) in cisco_keepalive()
584 ng_callout(&sc->handle, node, NULL, (hz * KEEPALIVE_SECS), in cisco_keepalive()
608 m->m_pkthdr.len = m->m_len = CISCO_HEADER_LEN + CISCO_PACKET_LEN; in cisco_send()
609 m->m_pkthdr.rcvif = 0; in cisco_send()
612 h->address = CISCO_MULTICAST; in cisco_send()
613 h->control = 0; in cisco_send()
614 h->protocol = htons(CISCO_KEEPALIVE); in cisco_send()
617 ch->type = htonl(type); in cisco_send()
618 ch->par1 = htonl(par1); in cisco_send()
619 ch->par2 = htonl(par2); in cisco_send()
620 ch->rel = -1; in cisco_send()
621 ch->time0 = htons((uint16_t) (t >> 16)); in cisco_send()
622 ch->time1 = htons((uint16_t) t); in cisco_send()
624 NG_SEND_DATA_ONLY(error, sc->downstream.hook, m); in cisco_send()
629 * Send linkstate to upstream node.
637 if (sc->inet.hook == NULL) /* nothing to notify */ in cisco_notify()
642 NG_SEND_MSG_HOOK(dummy_error, sc->node, msg, sc->inet.hook, 0); in cisco_notify()