Lines Matching +full:drop +full:- +full:out
5 /*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
29 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
91 uint16_t af; /* address family, -1 = downstream */
97 uint32_t seqRetries; /* how many times we've been here throwing out
191 ng_callout_init(&sc->handle); in cisco_constructor()
193 sc->node = node; 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()
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()
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()
347 goto out; in cisco_rcvdata()
350 if (pep->af == 0xffff) in cisco_rcvdata()
353 /* OK so it came from a protocol, heading out. Prepend general data in cisco_rcvdata()
359 goto out; 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()
368 h->protocol = htons(ETHERTYPE_IP); in cisco_rcvdata()
371 h->protocol = htons(ETHERTYPE_IPV6); in cisco_rcvdata()
374 h->protocol = htons(ETHERTYPE_AT); in cisco_rcvdata()
377 h->protocol = htons(ETHERTYPE_IPX); in cisco_rcvdata()
381 goto out; in cisco_rcvdata()
385 NG_FWD_NEW_DATA(error, item, sc->downstream.hook, m); in cisco_rcvdata()
388 out: in cisco_rcvdata()
402 NG_NODE_UNREF(sc->node); in cisco_shutdown()
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()
449 if (m->m_pkthdr.len < sizeof(*h)) { in cisco_input()
451 goto drop; in cisco_input()
455 if (m->m_len >= sizeof(*h)) /* the common case */ in cisco_input()
464 switch (h->address) { in cisco_input()
466 goto drop; in cisco_input()
470 switch (ntohs(h->protocol)) { in cisco_input()
472 goto drop; in cisco_input()
479 if (m->m_pkthdr.len < sizeof(*p)) { in cisco_input()
481 goto drop; 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()
538 goto drop; 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()
556 /* Drop if payload is empty */ in cisco_input()
557 if (m->m_pkthdr.len == 0) { in cisco_input()
559 goto drop; in cisco_input()
563 if (pep->hook == NULL) in cisco_input()
564 goto drop; in cisco_input()
565 NG_FWD_NEW_DATA(error, item, pep->hook, m); in cisco_input()
568 drop: in cisco_input()
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()
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()