- add connection names to connections
- stroke status / ipsec status shows them - added statusall for stroke - added status by connection name - some tests repaired, more to come
This commit is contained in:
@@ -86,10 +86,6 @@ TEST_OBJS+= $(BUILD_DIR)packet_test.o
|
||||
$(BUILD_DIR)packet_test.o : $(TESTCASES_DIR)packet_test.c $(TESTCASES_DIR)packet_test.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
TEST_OBJS+= $(BUILD_DIR)receiver_test.o
|
||||
$(BUILD_DIR)receiver_test.o : $(TESTCASES_DIR)receiver_test.c $(TESTCASES_DIR)receiver_test.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
TEST_OBJS+= $(BUILD_DIR)ike_sa_test.o
|
||||
$(BUILD_DIR)ike_sa_test.o : $(TESTCASES_DIR)ike_sa_test.c $(TESTCASES_DIR)ike_sa_test.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @file receiver_test.c
|
||||
*
|
||||
* @brief Tests for the receiver_t class.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "receiver_test.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <threads/receiver.h>
|
||||
#include <network/packet.h>
|
||||
#include <network/socket.h>
|
||||
#include <queues/send_queue.h>
|
||||
#include <queues/job_queue.h>
|
||||
#include <queues/jobs/incoming_packet_job.h>
|
||||
#include <encoding/payloads/encodings.h>
|
||||
|
||||
/**
|
||||
* Number of packets to send by sender-thread
|
||||
*/
|
||||
#define NUMBER_OF_PACKETS_TO_SEND 100
|
||||
|
||||
/**
|
||||
* Port to send the packets to
|
||||
*/
|
||||
#define PORT_TO_SEND 4600
|
||||
|
||||
/**
|
||||
* Destination IP Address
|
||||
*/
|
||||
#define DESTINATION_IP "127.0.0.1"
|
||||
|
||||
void test_receiver(protected_tester_t *tester)
|
||||
{
|
||||
int i;
|
||||
receiver_t *receiver;
|
||||
packet_t *packet;
|
||||
job_t *job;
|
||||
packet_t *received_packet;
|
||||
receiver = receiver_create();
|
||||
chunk_t test_data;
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
packet = packet_create();
|
||||
packet->set_destination(packet, host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND));
|
||||
test_data.len = (sizeof(int));
|
||||
test_data.ptr = malloc(test_data.len);
|
||||
*((int *) (test_data.ptr)) = i;
|
||||
packet->set_data(packet, test_data);
|
||||
charon->socket->send(charon->socket, packet);
|
||||
packet->destroy(packet);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
job = charon->job_queue->get(charon->job_queue);
|
||||
tester->assert_true(tester, (job->get_type(job) == INCOMING_PACKET), "job type check");
|
||||
|
||||
received_packet = ((incoming_packet_job_t *)(job))->get_packet((incoming_packet_job_t *)(job));
|
||||
test_data = received_packet->get_data(received_packet);
|
||||
tester->assert_true(tester, (test_data.len == (sizeof(int))), "received data length check");
|
||||
tester->assert_true(tester, (i == *((int *)(test_data.ptr))), "received data value check");
|
||||
received_packet->destroy(received_packet);
|
||||
|
||||
job->destroy(job);
|
||||
}
|
||||
|
||||
receiver->destroy(receiver);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* @file receiver_test.h
|
||||
*
|
||||
* @brief Tests for the receiver_t class.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef RECEIVER_TEST_H_
|
||||
#define RECEIVER_TEST_H_
|
||||
|
||||
#include <utils/tester.h>
|
||||
|
||||
/**
|
||||
* @brief Test function for the type receiver_t.
|
||||
*
|
||||
* @param tester tester object
|
||||
*
|
||||
* @ingroup testcases
|
||||
*/
|
||||
void test_receiver(protected_tester_t *tester);
|
||||
|
||||
#endif /*RECEIVER_TEST_H_*/
|
||||
@@ -30,50 +30,59 @@
|
||||
#include <network/socket.h>
|
||||
#include <queues/send_queue.h>
|
||||
#include <queues/job_queue.h>
|
||||
#include <queues/jobs/incoming_packet_job.h>
|
||||
|
||||
/**
|
||||
* Number of packets to send by sender-thread
|
||||
*/
|
||||
#define NUMBER_OF_PACKETS_TO_SEND 50
|
||||
|
||||
/**
|
||||
* Port to send the packets to
|
||||
*/
|
||||
#define PORT_TO_SEND 4600
|
||||
|
||||
/**
|
||||
* Destination IP Address
|
||||
*/
|
||||
#define DESTINATION_IP "127.0.0.1"
|
||||
#define NUMBER_OF_PACKETS_TO_SEND 5
|
||||
|
||||
void test_sender(protected_tester_t *tester)
|
||||
{
|
||||
int i;
|
||||
sender_t *sender;
|
||||
receiver_t *receiver;
|
||||
job_t *job;
|
||||
packet_t *packet;
|
||||
packet_t *received_packet;
|
||||
chunk_t packet_data;
|
||||
packet_t *received_packet;
|
||||
char test_data[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, /* spi */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, /* spi */
|
||||
0x05, /* next payload */
|
||||
0x20, /* IKE version */
|
||||
0x00, /* exchange type */
|
||||
0x00, /* flags */
|
||||
0x00,0x00,0x00,0x01, /* message id */
|
||||
0x00,0x00,0x00,0x24, /* length */
|
||||
0x12,0x34,0x56,0x67, /* some data */
|
||||
0x12,0x34,0x56,0x67,
|
||||
};
|
||||
chunk_t data = chunk_from_buf(test_data);
|
||||
chunk_t received;
|
||||
sender = sender_create();
|
||||
receiver = receiver_create();
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
packet = packet_create(AF_INET);
|
||||
packet->set_destination(packet, host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND));
|
||||
packet_data.len = ( sizeof(int));
|
||||
packet_data.ptr = malloc(packet_data.len);
|
||||
*((int *) (packet_data.ptr)) = i;
|
||||
packet->set_data(packet, packet_data);
|
||||
packet->set_destination(packet, host_create(AF_INET, "127.0.0.1", 500));
|
||||
packet->set_source(packet, host_create(AF_INET, "127.0.0.1", 500));
|
||||
packet->set_data(packet, chunk_clone(data));
|
||||
charon->send_queue->add(charon->send_queue,packet);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
charon->socket->receive(charon->socket,&received_packet);
|
||||
packet_data = received_packet->get_data(received_packet);
|
||||
tester->assert_true(tester, (packet_data.len == (sizeof(int))), "received data length check");
|
||||
tester->assert_true(tester, (i == *((int *)(packet_data.ptr))), "received data value check");
|
||||
job = charon->job_queue->get(charon->job_queue);
|
||||
tester->assert_true(tester, (job->get_type(job) == INCOMING_PACKET), "job type check");
|
||||
received_packet = ((incoming_packet_job_t *)(job))->get_packet((incoming_packet_job_t *)(job));
|
||||
received = received_packet->get_data(received_packet);
|
||||
tester->assert_true(tester, received.len == data.len, "received data length check");
|
||||
tester->assert_true(tester, memcmp(received.ptr, data.ptr, data.len) == 0, "received data value check");
|
||||
received_packet->destroy(received_packet);
|
||||
job->destroy(job);
|
||||
}
|
||||
|
||||
sender->destroy(sender);
|
||||
receiver->destroy(receiver);
|
||||
}
|
||||
|
||||
@@ -26,44 +26,54 @@
|
||||
#include "socket_test.h"
|
||||
|
||||
#include <network/socket.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
/*
|
||||
* Description in header file
|
||||
*/
|
||||
void test_socket(protected_tester_t *tester)
|
||||
{
|
||||
int packet_count = 5;
|
||||
int packet_count = 10;
|
||||
int current;
|
||||
socket_t *skt = socket_create(4500);
|
||||
socket_t *skt = socket_create(500);
|
||||
packet_t *pkt = packet_create(AF_INET);
|
||||
char *test_string = "Testing functionality of socket_t";
|
||||
chunk_t data;
|
||||
|
||||
|
||||
data.ptr = malloc(strlen(test_string) + 1);
|
||||
memcpy(data.ptr,test_string,strlen(test_string) + 1);
|
||||
data.len = strlen(test_string) + 1;
|
||||
char test_data[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, /* spi */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, /* spi */
|
||||
0x05, /* next payload */
|
||||
0x20, /* IKE version */
|
||||
0x00, /* exchange type */
|
||||
0x00, /* flags */
|
||||
0x00,0x00,0x00,0x01, /* message id */
|
||||
0x00,0x00,0x00,0x24, /* length */
|
||||
0x12,0x34,0x56,0x67, /* some data */
|
||||
0x12,0x34,0x56,0x67,
|
||||
};
|
||||
chunk_t data = chunk_from_buf(test_data);
|
||||
chunk_t received;
|
||||
|
||||
/* send to previously bound socket */
|
||||
pkt->set_destination(pkt, host_create(AF_INET, "127.0.0.1", 4500));
|
||||
pkt->set_data(pkt, data);
|
||||
pkt->set_destination(pkt, host_create(AF_INET, "127.0.0.1", 500));
|
||||
pkt->set_source(pkt, host_create(AF_INET, "127.0.0.1", 500));
|
||||
pkt->set_data(pkt, chunk_clone(data));
|
||||
|
||||
/* send packet_count packets */
|
||||
for (current = 0; current < packet_count; current++)
|
||||
{
|
||||
{
|
||||
if (skt->send(skt, pkt) == FAILED)
|
||||
{
|
||||
tester->assert_true(tester, 0, "packet send");
|
||||
}
|
||||
}
|
||||
pkt->destroy(pkt);
|
||||
|
||||
|
||||
/* receive packet_count packets */
|
||||
for (current = 0; current < packet_count; current++)
|
||||
{
|
||||
skt->receive(skt, &pkt);
|
||||
data = pkt->get_data(pkt);
|
||||
tester->assert_false(tester, strcmp(test_string, data.ptr), "packet exchange");
|
||||
received = pkt->get_data(pkt);
|
||||
tester->assert_false(tester, memcmp(received.ptr, data.ptr, max(received.len, data.len)), "packet exchange");
|
||||
pkt->destroy(pkt);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "socket_test.h"
|
||||
#include "sender_test.h"
|
||||
#include "scheduler_test.h"
|
||||
#include "receiver_test.h"
|
||||
#include "ike_sa_id_test.h"
|
||||
#include "ike_sa_test.h"
|
||||
#include "ike_sa_manager_test.h"
|
||||
@@ -78,7 +77,6 @@ test_t socket_test = {test_socket,"Socket"};
|
||||
test_t thread_pool_test = {test_thread_pool,"Thread Pool"};
|
||||
test_t sender_test = {test_sender,"Sender"};
|
||||
test_t scheduler_test = {test_scheduler,"Scheduler"};
|
||||
test_t receiver_test = {test_receiver,"Receiver"};
|
||||
test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"};
|
||||
test_t ike_sa_test = {test_ike_sa,"IKE_SA"};
|
||||
test_t ike_sa_manager_test = {test_ike_sa_manager, "IKE_SA-Manager"};
|
||||
@@ -161,7 +159,7 @@ daemon_t *daemon_create()
|
||||
/* assign methods */
|
||||
charon->kill = daemon_kill;
|
||||
|
||||
//charon->socket = socket_create(4510);
|
||||
charon->socket = socket_create(500);
|
||||
charon->ike_sa_manager = ike_sa_manager_create();
|
||||
charon->job_queue = job_queue_create();
|
||||
charon->event_queue = event_queue_create();
|
||||
@@ -192,7 +190,6 @@ int main()
|
||||
&scheduler_test,
|
||||
&socket_test,
|
||||
&sender_test,
|
||||
&receiver_test,
|
||||
&ike_sa_id_test,
|
||||
&ike_sa_test,
|
||||
&generator_test1,
|
||||
@@ -254,8 +251,8 @@ int main()
|
||||
|
||||
tester_t *tester = tester_create(test_output, FALSE);
|
||||
|
||||
//tester->perform_tests(tester,all_tests);
|
||||
tester->perform_test(tester,&certificate_test);
|
||||
tester->perform_tests(tester,all_tests);
|
||||
//tester->perform_test(tester,&sender_test);
|
||||
|
||||
|
||||
tester->destroy(tester);
|
||||
|
||||
Reference in New Issue
Block a user