about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorChoupom <andycootlapin@hotmail.fr>2011-03-17 17:38:30 +0100
committeroy <Tom_Adams@web.de>2011-03-31 22:58:23 +0200
commit979eca0095ecfb40a160636752eaf0e61bdc4ca9 (patch)
tree73d72a71e65487b6e24f45b6947c0e2cfe19f45e /src
parente9ab42795a47dc6fab3112602a85780bcc1aecfb (diff)
downloadzcatch-979eca0095ecfb40a160636752eaf0e61bdc4ca9.tar.gz
zcatch-979eca0095ecfb40a160636752eaf0e61bdc4ca9.zip
refactored packetgen
Diffstat (limited to 'src')
-rw-r--r--src/tools/packetgen.c37
-rw-r--r--src/tools/packetgen.cpp36
2 files changed, 36 insertions, 37 deletions
diff --git a/src/tools/packetgen.c b/src/tools/packetgen.c
deleted file mode 100644
index d8b70dbc..00000000
--- a/src/tools/packetgen.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
-/* If you are missing that file, acquire a complete release at teeworlds.com.                */
-#include <base/system.h>
-
-enum { NUM_SOCKETS = 64 };
-
-int run(NETADDR dest)
-{
-	NETSOCKET sockets[NUM_SOCKETS];
-	int i;
-	
-	for(i = 0; i < NUM_SOCKETS; i++)
-	{
-		NETADDR bindaddr = {NETTYPE_IPV4, {0}, 0};
-	 	sockets[i] = net_udp_create(bindaddr);
-	}
-	
-	while(1)
-	{
-		unsigned char data[1024];
-		int size = 0;
-		int socket_to_use = 0;
-		io_read(io_stdin(), &size, 2);
-		io_read(io_stdin(), &socket_to_use, 1);
-		size %= 256;
-		socket_to_use %= NUM_SOCKETS;
-		io_read(io_stdin(), data, size);
-		net_udp_send(sockets[socket_to_use], &dest, data, size);
-	}
-}
-
-int main(int argc, char **argv)
-{
-	NETADDR dest = {NETTYPE_IPV4, {127,0,0,1},8303};
-	run(dest);
-	return 0;
-}
diff --git a/src/tools/packetgen.cpp b/src/tools/packetgen.cpp
new file mode 100644
index 00000000..7d11ed26
--- /dev/null
+++ b/src/tools/packetgen.cpp
@@ -0,0 +1,36 @@
+/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
+/* If you are missing that file, acquire a complete release at teeworlds.com.                */
+#include <base/system.h>
+
+enum { NUM_SOCKETS = 64 };
+
+int Run(NETADDR Dest)
+{
+	NETSOCKET aSockets[NUM_SOCKETS];
+	
+	for(int i = 0; i < NUM_SOCKETS; i++)
+	{
+		NETADDR BindAddr = {NETTYPE_IPV4, {0}, 0};
+	 	aSockets[i] = net_udp_create(BindAddr);
+	}
+	
+	while(1)
+	{
+		unsigned char aData[1024];
+		int Size = 0;
+		int SocketToUse = 0;
+		io_read(io_stdin(), &Size, 2);
+		io_read(io_stdin(), &SocketToUse, 1);
+		Size %= 256;
+		SocketToUse %= NUM_SOCKETS;
+		io_read(io_stdin(), aData, Size);
+		net_udp_send(aSockets[SocketToUse], &Dest, aData, Size);
+	}
+}
+
+int main(int argc, char **argv)
+{
+	NETADDR Dest = {NETTYPE_IPV4, {127,0,0,1}, 8303};
+	Run(Dest);
+	return 0;
+}