Receive data on hook. */
| 584 | |
| 585 | /* Receive data on hook. */ |
| 586 | static int |
| 587 | ng_netflow_rcvdata (hook_p hook, item_p item) |
| 588 | { |
| 589 | const node_p node = NG_HOOK_NODE(hook); |
| 590 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 591 | const iface_p iface = NG_HOOK_PRIVATE(hook); |
| 592 | hook_p out; |
| 593 | struct mbuf *m = NULL, *m_old = NULL; |
| 594 | struct ip *ip = NULL; |
| 595 | struct ip6_hdr *ip6 = NULL; |
| 596 | struct m_tag *mtag; |
| 597 | int pullup_len = 0, off; |
| 598 | uint8_t acct = 0, bypass = 0, flags = 0, upper_proto = 0; |
| 599 | int error = 0, l3_off = 0; |
| 600 | unsigned int src_if_index; |
| 601 | caddr_t upper_ptr = NULL; |
| 602 | fib_export_p fe; |
| 603 | uint32_t fib; |
| 604 | |
| 605 | if ((hook == priv->export) || (hook == priv->export9)) { |
| 606 | /* |
| 607 | * Data arrived on export hook. |
| 608 | * This must not happen. |
| 609 | */ |
| 610 | log(LOG_ERR, "ng_netflow: incoming data on export hook!\n"); |
| 611 | ERROUT(EINVAL); |
| 612 | } |
| 613 | |
| 614 | if (hook == iface->hook) { |
| 615 | if ((iface->info.conf & NG_NETFLOW_CONF_INGRESS) == 0) |
| 616 | bypass = 1; |
| 617 | out = iface->out; |
| 618 | } else if (hook == iface->out) { |
| 619 | if ((iface->info.conf & NG_NETFLOW_CONF_EGRESS) == 0) |
| 620 | bypass = 1; |
| 621 | out = iface->hook; |
| 622 | } else |
| 623 | ERROUT(EINVAL); |
| 624 | |
| 625 | if ((!bypass) && (iface->info.conf & |
| 626 | (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE))) { |
| 627 | mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW, |
| 628 | MTAG_NETFLOW_CALLED, NULL); |
| 629 | while (mtag != NULL) { |
| 630 | if ((iface->info.conf & NG_NETFLOW_CONF_ONCE) || |
| 631 | ((ng_ID_t *)(mtag + 1))[0] == NG_NODE_ID(node)) { |
| 632 | bypass = 1; |
| 633 | break; |
| 634 | } |
| 635 | mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW, |
| 636 | MTAG_NETFLOW_CALLED, mtag); |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | if (bypass) { |
| 641 | if (out == NULL) |
| 642 | ERROUT(ENOTCONN); |
| 643 |
nothing calls this directly
no test coverage detected