about summary refs log tree commit diff
path: root/src/tools/crapnet.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-07-06 11:21:21 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-07-06 11:21:21 +0000
commit9d632dd826c8a312095de0f56df66b2580d336cb (patch)
tree3fdde543c94323d6c698d278a58bf18e3c385776 /src/tools/crapnet.cpp
parent3705064b109580103a3d13f44693503da9927281 (diff)
downloadzcatch-9d632dd826c8a312095de0f56df66b2580d336cb.tar.gz
zcatch-9d632dd826c8a312095de0f56df66b2580d336cb.zip
major update. server clean up and much added documentation
Diffstat (limited to 'src/tools/crapnet.cpp')
-rw-r--r--src/tools/crapnet.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp
index ba8a30d8..f807bb61 100644
--- a/src/tools/crapnet.cpp
+++ b/src/tools/crapnet.cpp
@@ -8,7 +8,7 @@ struct packet
 	packet *prev;
 	packet *next;
 	
-	NETADDR4 send_to;
+	NETADDR send_to;
 	int64 timestamp;
 	int id;
 	int data_size;
@@ -20,10 +20,10 @@ static packet *last = (packet *)0;
 static int current_latency = 0;
 static int debug = 0;
 
-int run(int port, NETADDR4 dest)
+int run(int port, NETADDR dest)
 {
-	NETADDR4 src = {{0,0,0,0},port};
-	NETSOCKET socket = net_udp4_create(src);
+	NETADDR src = {NETTYPE_IPV4, {0,0,0,0},port};
+	NETSOCKET socket = net_udp_create(src);
 	
 	char buffer[1024*2];
 	int id = 0;
@@ -35,8 +35,8 @@ int run(int port, NETADDR4 dest)
 		{
 			// fetch data
 			int data_trash = 0;
-			NETADDR4 from;
-			int bytes = net_udp4_recv(socket, &from, buffer, 1024*2);
+			NETADDR from;
+			int bytes = net_udp_recv(socket, &from, buffer, 1024*2);
 			if(bytes <= 0)
 				break;
 				
@@ -46,7 +46,7 @@ int run(int port, NETADDR4 dest)
 			// create new packet				
 			packet *p = (packet *)mem_alloc(sizeof(packet)+bytes, 1);
 
-			if(net_addr4_cmp(&from, &dest) == 0)
+			if(net_addr_comp(&from, &dest) == 0)
 			{
 				p->send_to = src; // from the server
 			}
@@ -112,7 +112,7 @@ int run(int port, NETADDR4 dest)
 				
 				// send and remove packet
 				//if((rand()%20) != 0) // heavy packetloss
-				net_udp4_send(socket, &p->send_to, p->data, p->data_size);
+				net_udp_send(socket, &p->send_to, p->data, p->data_size);
 				
 				// update lag
 				double flux = rand()/(double)RAND_MAX;
@@ -136,7 +136,7 @@ int run(int port, NETADDR4 dest)
 
 int main(int argc, char **argv)
 {
-	NETADDR4 a = {{127,0,0,1},8303};
+	NETADDR a = {NETTYPE_IPV4, {127,0,0,1},8303};
 	run(8302, a);
 	return 0;
 }