Exemple #1
0
void test_bind_tx()
{
        pfq_t * q = pfq_open(64, 1024, 1024);

        assert(pfq_bind_tx(q, "lo", Q_ANY_QUEUE, Q_NO_KTHREAD) == 0);
        assert(pfq_bind_tx(q, "unknown", Q_ANY_QUEUE, Q_NO_KTHREAD) == -1);

        pfq_close(q);
}
Exemple #2
0
void test_tx_thread()
{
        pfq_t * q = pfq_open(64, 1024, 1024);

        assert(pfq_bind_tx(q, "lo", Q_ANY_QUEUE, 0) == 0);
        assert(pfq_enable(q) == 0);

        pfq_close(q);
}
Exemple #3
0
void test_tx_queue()
{
        pfq_t * q = pfq_open(64, 1024, 1024);
        assert(pfq_tx_queue(q, 1) == -1);

        assert(pfq_bind_tx(q, "lo", Q_ANY_QUEUE, Q_NO_KTHREAD) == 0);
        assert(pfq_enable(q) == 0);

        assert(pfq_tx_queue(q, 0) == 0);

        pfq_close(q);
}
Exemple #4
0
int
main(int argc, char *argv[])
{
        if (argc < 5)
        {
                fprintf(stderr, "usage: %s dev queue kthread num\n", argv[0]);
                return -1;
        }

        const char *dev = argv[1];
        int queue  = atoi(argv[2]);
        int kthread = atoi(argv[3]);
        unsigned long long num = atoll(argv[4]);

        pfq_t * q= pfq_open(64, 1024, 1024);

        if (pfq_bind_tx(q, dev, queue, kthread) < 0) {
		fprintf(stderr, "%s\n", pfq_error(q));
		return -1;
	}

        pfq_enable(q);

	if (kthread == -1) {
		send_packets(q, num);
	}
	else  {
		send_packets_async(q, num);
	}

        sleep(2);

        struct pfq_stats stat;
        pfq_get_stats(q, &stat);

        fprintf(stdout, "sent: %lu - disc: %lu\n", stat.sent, stat.disc);

        pfq_close(q);

        return 0;
}