Пример #1
0
void test_is_enabled()
{
	pfq_t * q = pfq_open(64, 1024, 1024);

	assert(q);
	assert(pfq_is_enabled(q) == 0);
	assert(pfq_enable(q) == 0);
	assert(pfq_is_enabled(q) == 1);
	assert(pfq_disable(q) == 0);
	assert(pfq_is_enabled(q) == 0);

	pfq_close(q);
}
Пример #2
0
int
pfq_set_tx_slots(pfq_t *q, size_t value)
{
	int enabled = pfq_is_enabled(q);
	if (enabled == 1) {
		return Q_ERROR(q, "PFQ: enabled (Tx slots could not be set)");
	}
	if (setsockopt(q->fd, PF_Q, Q_SO_SET_TX_SLOTS, &value, sizeof(value)) == -1) {
		return Q_ERROR(q, "PFQ: set Tx slots error");
	}

	q->tx_slots = value;
	return Q_OK(q);
}
Пример #3
0
int
pfq_set_caplen(pfq_t *q, size_t value)
{
	int enabled = pfq_is_enabled(q);
	if (enabled == 1) {
		return Q_ERROR(q, "PFQ: enabled (caplen could not be set)");
	}

	if (setsockopt(q->fd, PF_Q, Q_SO_SET_RX_CAPLEN, &value, sizeof(value)) == -1) {
		return Q_ERROR(q, "PFQ: set caplen error");
	}

	q->rx_slot_size = ALIGN(sizeof(struct pfq_pkthdr) + value, 8);
	return Q_OK(q);
}