* Queue processing callout handler. */
| 661 | * Queue processing callout handler. |
| 662 | */ |
| 663 | void |
| 664 | ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2) |
| 665 | { |
| 666 | struct hookinfo *hinfo = NG_HOOK_PRIVATE(hook); |
| 667 | struct mbuf *m; |
| 668 | int error; |
| 669 | |
| 670 | /* Refill tokens for time we have slept. */ |
| 671 | ng_car_refillhook(hinfo); |
| 672 | |
| 673 | /* If we have some tokens */ |
| 674 | while (hinfo->tc >= 0) { |
| 675 | /* Send packet. */ |
| 676 | m = hinfo->q[hinfo->q_first]; |
| 677 | NG_SEND_DATA_ONLY(error, hinfo->dest, m); |
| 678 | if (error != 0) |
| 679 | ++hinfo->stats.errors; |
| 680 | ++hinfo->stats.passed_pkts; |
| 681 | |
| 682 | /* Get next one. */ |
| 683 | hinfo->q_first++; |
| 684 | if (hinfo->q_first >= NG_CAR_QUEUE_SIZE) |
| 685 | hinfo->q_first = 0; |
| 686 | |
| 687 | /* Stop if none left. */ |
| 688 | if (hinfo->q_first == hinfo->q_last) |
| 689 | break; |
| 690 | |
| 691 | /* If we have more packet, try it. */ |
| 692 | m = hinfo->q[hinfo->q_first]; |
| 693 | if (hinfo->conf.opt & NG_CAR_COUNT_PACKETS) { |
| 694 | hinfo->tc -= 128; |
| 695 | } else { |
| 696 | hinfo->tc -= m->m_pkthdr.len; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /* If something left */ |
| 701 | if (hinfo->q_first != hinfo->q_last) |
| 702 | /* Schedule queue processing. */ |
| 703 | ng_car_schedule(hinfo); |
| 704 | } |
| 705 | |
| 706 | /* |
| 707 | * Enqueue packet. |
nothing calls this directly
no test coverage detected