- revised packet and socket interface

- tested
This commit is contained in:
Martin Willi
2005-11-07 09:11:58 +00:00
parent e15f7292ec
commit 9317c2a1c6
6 changed files with 94 additions and 39 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ static void test_send_queue_sender(send_queue_test_t * testinfo)
int i;
for (i = 0; i < testinfo->insert_item_count; i++)
{
packet_t *packet = packet_create();
packet_t *packet = packet_create(AF_INET);
testinfo->tester->assert_true(testinfo->tester,(packet != NULL), "create packet call check");
testinfo->tester->assert_true(testinfo->tester,(testinfo->send_queue->add(testinfo->send_queue,packet) == SUCCESS), "add packet call check");
}
+22 -9
View File
@@ -32,20 +32,33 @@
*/
void test_socket(tester_t *tester)
{
socket_t *skt = socket_create();
packet_t *pkt = packet_create();
int packet_count = 5;
int current;
socket_t *skt = socket_create(4500);
packet_t *pkt = packet_create(AF_INET);
char *test_string = "Testing functionality of socket_t";
pkt->data.ptr = test_string;
pkt->data.len = strlen(test_string);
pkt->receiver.addr.sin_family = AF_INET;
pkt->receiver.addr.sin_addr.s_addr = inet_addr("127.0.0.1");
pkt->receiver.addr.sin_port = htons(500);
skt->send(skt, pkt);
/* send to previously bound socket */
pkt->set_destination(pkt, "127.0.0.1", 4500);
/* 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);
skt->receive(skt, &pkt);
tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange");
/* receive packet_count packets */
for (current = 0; current < packet_count; current++)
{
skt->receive(skt, &pkt);
tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange");
pkt->destroy(pkt);
}
}