Deleted Added
full compact
ng_source.c (137138) ng_source.c (138268)
1/*
2 * ng_source.c
3 *
4 * Copyright 2002 Sandvine Inc.
5 * All rights reserved.
6 *
7 * Subject to the following obligations and disclaimer of warranty, use and
8 * redistribution of this software, in source or object code forms, with or

--- 22 unchanged lines hidden (view full) ---

31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
33 * DAMAGE.
34 *
35 * Author: Dave Chapeskie <dchapeskie@sandvine.com>
36 */
37
38#include <sys/cdefs.h>
1/*
2 * ng_source.c
3 *
4 * Copyright 2002 Sandvine Inc.
5 * All rights reserved.
6 *
7 * Subject to the following obligations and disclaimer of warranty, use and
8 * redistribution of this software, in source or object code forms, with or

--- 22 unchanged lines hidden (view full) ---

31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
33 * DAMAGE.
34 *
35 * Author: Dave Chapeskie <dchapeskie@sandvine.com>
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/netgraph/ng_source.c 137138 2004-11-02 21:24:30Z glebius $");
39__FBSDID("$FreeBSD: head/sys/netgraph/ng_source.c 138268 2004-12-01 11:56:32Z glebius $");
40
41/*
42 * This node is used for high speed packet geneneration. It queues
43 * all data recieved on it's 'input' hook and when told to start via
44 * a control message it sends the packets out it's 'output' hook. In
45 * this way this node can be preloaded with a packet stream which is
46 * continuously sent.
47 *

--- 278 unchanged lines hidden (view full) ---

326 /* TODO validation of packets */
327 sc->packets = packets;
328 sc->output_ifp = NULL;
329
330 sc->node->nd_flags |= NG_SOURCE_ACTIVE;
331 timevalclear(&sc->stats.elapsedTime);
332 timevalclear(&sc->stats.endTime);
333 getmicrotime(&sc->stats.startTime);
40
41/*
42 * This node is used for high speed packet geneneration. It queues
43 * all data recieved on it's 'input' hook and when told to start via
44 * a control message it sends the packets out it's 'output' hook. In
45 * this way this node can be preloaded with a packet stream which is
46 * continuously sent.
47 *

--- 278 unchanged lines hidden (view full) ---

326 /* TODO validation of packets */
327 sc->packets = packets;
328 sc->output_ifp = NULL;
329
330 sc->node->nd_flags |= NG_SOURCE_ACTIVE;
331 timevalclear(&sc->stats.elapsedTime);
332 timevalclear(&sc->stats.endTime);
333 getmicrotime(&sc->stats.startTime);
334 ng_timeout(&sc->intr_ch, node, NULL, 0,
334 ng_callout(&sc->intr_ch, node, NULL, 0,
335 ng_source_intr, sc, 0);
336 }
337 break;
338 case NGM_SOURCE_STOP:
339 ng_source_stop(sc);
340 break;
341 case NGM_SOURCE_CLR_DATA:
342 ng_source_clr_data(sc);

--- 11 unchanged lines hidden (view full) ---

354 switch (msg->header.cmd) {
355 case NGM_ETHER_GET_IFINDEX:
356 if (ng_source_store_output_ifp(sc, msg) == 0) {
357 ng_source_set_autosrc(sc, 0);
358 sc->node->nd_flags |= NG_SOURCE_ACTIVE;
359 timevalclear(&sc->stats.elapsedTime);
360 timevalclear(&sc->stats.endTime);
361 getmicrotime(&sc->stats.startTime);
335 ng_source_intr, sc, 0);
336 }
337 break;
338 case NGM_SOURCE_STOP:
339 ng_source_stop(sc);
340 break;
341 case NGM_SOURCE_CLR_DATA:
342 ng_source_clr_data(sc);

--- 11 unchanged lines hidden (view full) ---

354 switch (msg->header.cmd) {
355 case NGM_ETHER_GET_IFINDEX:
356 if (ng_source_store_output_ifp(sc, msg) == 0) {
357 ng_source_set_autosrc(sc, 0);
358 sc->node->nd_flags |= NG_SOURCE_ACTIVE;
359 timevalclear(&sc->stats.elapsedTime);
360 timevalclear(&sc->stats.endTime);
361 getmicrotime(&sc->stats.startTime);
362 ng_timeout(&sc->intr_ch, node, NULL, 0,
362 ng_callout(&sc->intr_ch, node, NULL, 0,
363 ng_source_intr, sc, 0);
364 }
365 break;
366 default:
367 error = EINVAL;
368 }
369 break;
370 default:

--- 210 unchanged lines hidden (view full) ---

581
582/*
583 * Stop sending queued data out the output hook
584 */
585static void
586ng_source_stop (sc_p sc)
587{
588 if (sc->node->nd_flags & NG_SOURCE_ACTIVE) {
363 ng_source_intr, sc, 0);
364 }
365 break;
366 default:
367 error = EINVAL;
368 }
369 break;
370 default:

--- 210 unchanged lines hidden (view full) ---

581
582/*
583 * Stop sending queued data out the output hook
584 */
585static void
586ng_source_stop (sc_p sc)
587{
588 if (sc->node->nd_flags & NG_SOURCE_ACTIVE) {
589 ng_untimeout(&sc->intr_ch, sc->node);
589 ng_uncallout(&sc->intr_ch, sc->node);
590 sc->node->nd_flags &= ~NG_SOURCE_ACTIVE;
591 getmicrotime(&sc->stats.endTime);
592 sc->stats.elapsedTime = sc->stats.endTime;
593 timevalsub(&sc->stats.elapsedTime, &sc->stats.startTime);
594 /* XXX should set this to the initial value instead */
595 ng_source_set_autosrc(sc, 1);
596 }
597}

--- 23 unchanged lines hidden (view full) ---

621 packets = ifq->ifq_maxlen - ifq->ifq_len;
622 } else
623 packets = sc->snd_queue.ifq_len;
624
625 ng_source_send(sc, packets, NULL);
626 if (sc->packets == 0)
627 ng_source_stop(sc);
628 else
590 sc->node->nd_flags &= ~NG_SOURCE_ACTIVE;
591 getmicrotime(&sc->stats.endTime);
592 sc->stats.elapsedTime = sc->stats.endTime;
593 timevalsub(&sc->stats.elapsedTime, &sc->stats.startTime);
594 /* XXX should set this to the initial value instead */
595 ng_source_set_autosrc(sc, 1);
596 }
597}

--- 23 unchanged lines hidden (view full) ---

621 packets = ifq->ifq_maxlen - ifq->ifq_len;
622 } else
623 packets = sc->snd_queue.ifq_len;
624
625 ng_source_send(sc, packets, NULL);
626 if (sc->packets == 0)
627 ng_source_stop(sc);
628 else
629 ng_timeout(&sc->intr_ch, node, NULL, NG_SOURCE_INTR_TICKS,
629 ng_callout(&sc->intr_ch, node, NULL, NG_SOURCE_INTR_TICKS,
630 ng_source_intr, sc, 0);
631}
632
633/*
634 * Send packets out our output hook
635 */
636static int
637ng_source_send (sc_p sc, int tosend, int *sent_p)

--- 58 unchanged lines hidden ---
630 ng_source_intr, sc, 0);
631}
632
633/*
634 * Send packets out our output hook
635 */
636static int
637ng_source_send (sc_p sc, int tosend, int *sent_p)

--- 58 unchanged lines hidden ---