예제 #1
0
void test_join_shared_()
{
	{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED, 	64, 1024, 1024);
	pfq_t * y = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED,   64, 1024, 1024);

	int gid = pfq_group_id(q);

	assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED) >= 0);

	pfq_close(q);
	pfq_close(y);
	}

	{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED, 64, 1024, 1024);
	pfq_t * y = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);

	int gid = pfq_group_id(q);

	assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_PRIVATE) < 0);
	assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED) < 0);
	assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED) < 0);

	pfq_close(q);
	pfq_close(y);
	}
}
예제 #2
0
void test_join_restricted_process()
{
	pfq_t * x = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED, 64, 1024, 1024);
	pfq_t * z = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED, 64, 1024, 1024);

	assert(x);
	assert(z);

	int p = fork();
	if (p == 0) {
		pfq_t * y = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);

		int gid = pfq_group_id(z);
		assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED) == gid);
		assert( pfq_join_group(y, pfq_group_id(x), Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED) == -1);

		pfq_close(y);

		_Exit(1);
	}

	wait(NULL);

	pfq_close(x);
	pfq_close(z);
}
예제 #3
0
void test_join_restricted()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED, 64, 1024, 1024);
        assert(q);

	pfq_t * y = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);

	int gid = pfq_group_id(q);
	assert( pfq_join_group(y, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED) == gid);

	pfq_close(q);
	pfq_close(y);
}
예제 #4
0
void *restricted_thread(void *arg)
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);
        assert(q);

	long int gid = (long int)arg;
	long int ngid = pfq_join_group(q, gid, Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED);

	assert(ngid == gid);

	pfq_close(q);
	return 0;
}
예제 #5
0
void test_join_restricted_thread()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_RESTRICTED, 64, 1024, 1024);
        assert(q);

	pthread_t t;

	long int gid = pfq_group_id(q);

	assert(pthread_create(&t, NULL, restricted_thread, (void *)gid) == 0);

        pthread_join(t, NULL);

	pfq_close(q);
}
예제 #6
0
void test_leave_group()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);
	assert(q);

	int gid = pfq_join_group(q, 22, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED);
	assert(gid == 22);

	assert(pfq_leave_group(q, 22) == 0);
	assert(pfq_group_id(q) == -1);

	unsigned long mask;
	assert(pfq_groups_mask(q, &mask) == 0);
	assert(mask == 0);

	pfq_close(q);
}
예제 #7
0
void test_join_group()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);
	assert(q);

	int gid = pfq_join_group(q, 0, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED);
	assert(gid == 0);

	gid = pfq_join_group(q, Q_ANY_GROUP, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED);
	assert(gid == 1);

	unsigned long mask;
	assert(pfq_groups_mask(q, &mask) == 0);

	assert(mask == 3);
	pfq_close(q);
}
예제 #8
0
void test_join_deferred()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);
        assert(q);

	assert(pfq_join_group(q, 13, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED) == 13);
	assert(pfq_join_group(q, 13, Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED) == 13);

	unsigned long mask;

	assert(pfq_groups_mask(q, &mask) == 0);

	assert(mask != 0);
	assert(mask == (1<<13));

	pfq_close(q);
}
예제 #9
0
void test_my_group_stats_shared()
{
	pfq_t * q = pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_SHARED, 64, 1024, 1024);
        assert(q);

	int gid = pfq_group_id(q);
	assert(gid != -1);

	struct pfq_stats s;
	assert(pfq_get_group_stats(q, gid, &s) == 0);

	assert(s.recv == 0);
	assert(s.lost == 0);
	assert(s.drop == 0);

	pfq_close(q);
}
예제 #10
0
파일: libpfq.c 프로젝트: Mr-Click/PFQ
pfq_t *
pfq_open_nogroup_(size_t caplen, size_t rx_slots, size_t tx_slots)
{
	return pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, caplen, rx_slots, tx_slots);
}
예제 #11
0
파일: libpfq.c 프로젝트: Mr-Click/PFQ
pfq_t *
pfq_open_(size_t caplen, size_t rx_slots, size_t tx_slots)
{
	return pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_PRIVATE, caplen, rx_slots, tx_slots);
}
예제 #12
0
파일: libpfq.c 프로젝트: Mr-Click/PFQ
pfq_t *
pfq_open(size_t length, size_t slots)
{
	return pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_PRIVATE, length, slots, slots);
}
예제 #13
0
파일: libpfq.c 프로젝트: Mr-Click/PFQ
pfq_t *
pfq_open_default()
{
	return pfq_open_group(Q_CLASS_DEFAULT, Q_POLICY_GROUP_UNDEFINED, 64, 1024, 1024);
}