summaryrefslogtreecommitdiff
path: root/src/uanytun.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-12-28 10:36:20 +0000
committerChristian Pointner <equinox@anytun.org>2008-12-28 10:36:20 +0000
commit65dd1b1e7b663d5b1f18171ff1de0b46a6196d2c (patch)
tree5591bf544a9aa2d84bcf906b57893b8b9c19aabd /src/uanytun.c
parentadded plain packet (diff)
added encrypted packet
some cleanup
Diffstat (limited to 'src/uanytun.c')
-rw-r--r--src/uanytun.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/src/uanytun.c b/src/uanytun.c
index a546287..a80dfe2 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -44,6 +44,7 @@
#include "udp.h"
#include "plain_packet.h"
+#include "encrypted_packet.h"
#include "daemon.h"
#include "sysexec.h"
@@ -94,60 +95,71 @@ int main(int argc, char* argv[])
log_init("uanytun", DAEMON);
signal_init();
- plain_packet_t packet;
- plain_packet_init(&packet);
+ encrypted_packet_t packet;
+ encrypted_packet_init(&packet);
- printf("packet length: %d\n", plain_packet_get_length(&packet));
+ printf("packet length: %d\n", encrypted_packet_get_length(&packet));
printf("packet: \n");
- print_hex_dump(plain_packet_get_packet(&packet), plain_packet_get_length(&packet));
- printf("\npayload type: 0x%04X\n", plain_packet_get_type(&packet));
- printf("payload length: %d\n", plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_packet(&packet), encrypted_packet_get_length(&packet));
+ printf("\nseq nr: 0x%08X\n", encrypted_packet_get_seq_nr(&packet));
+ printf("sender id: 0x%04X\n", encrypted_packet_get_sender_id(&packet));
+ printf("mux: 0x%04X\n", encrypted_packet_get_mux(&packet));
+ printf("payload length: %d\n", encrypted_packet_get_payload_length(&packet));
printf("payload: \n");
- print_hex_dump(plain_packet_get_payload(&packet), plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_payload(&packet), encrypted_packet_get_payload_length(&packet));
printf("\n\n");
- plain_packet_set_payload_length(&packet, 20);
+ encrypted_packet_set_payload_length(&packet, 20);
-
- printf("packet length: %d\n", plain_packet_get_length(&packet));
+ printf("packet length: %d\n", encrypted_packet_get_length(&packet));
printf("packet: \n");
- print_hex_dump(plain_packet_get_packet(&packet), plain_packet_get_length(&packet));
- printf("\npayload type: 0x%04X\n", plain_packet_get_type(&packet));
- printf("payload length: %d\n", plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_packet(&packet), encrypted_packet_get_length(&packet));
+ printf("\nseq nr: 0x%08X\n", encrypted_packet_get_seq_nr(&packet));
+ printf("sender id: 0x%04X\n", encrypted_packet_get_sender_id(&packet));
+ printf("mux: 0x%04X\n", encrypted_packet_get_mux(&packet));
+ printf("payload length: %d\n", encrypted_packet_get_payload_length(&packet));
printf("payload: \n");
- print_hex_dump(plain_packet_get_payload(&packet), plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_payload(&packet), encrypted_packet_get_payload_length(&packet));
printf("\n\n");
+
u_int32_t i;
- for(i=0; i<plain_packet_get_payload_length(&packet); i++)
- plain_packet_get_payload(&packet)[i] = (u_int8_t)i;
- plain_packet_set_type(&packet, PAYLOAD_TYPE_TUN6);
+ for(i=0; i<encrypted_packet_get_payload_length(&packet); i++)
+ encrypted_packet_get_payload(&packet)[i] = (u_int8_t)i;
+ encrypted_packet_set_seq_nr(&packet, 124);
+ encrypted_packet_set_sender_id(&packet, 2);
+ encrypted_packet_set_mux(&packet, 234);
- printf("packet length: %d\n", plain_packet_get_length(&packet));
+ printf("packet length: %d\n", encrypted_packet_get_length(&packet));
printf("packet: \n");
- print_hex_dump(plain_packet_get_packet(&packet), plain_packet_get_length(&packet));
- printf("\npayload type: 0x%04X\n", plain_packet_get_type(&packet));
- printf("payload length: %d\n", plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_packet(&packet), encrypted_packet_get_length(&packet));
+ printf("\nseq nr: 0x%08X\n", encrypted_packet_get_seq_nr(&packet));
+ printf("sender id: 0x%04X\n", encrypted_packet_get_sender_id(&packet));
+ printf("mux: 0x%04X\n", encrypted_packet_get_mux(&packet));
+ printf("payload length: %d\n", encrypted_packet_get_payload_length(&packet));
printf("payload: \n");
- print_hex_dump(plain_packet_get_payload(&packet), plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_payload(&packet), encrypted_packet_get_payload_length(&packet));
printf("\n\n");
- plain_packet_set_payload_length(&packet, 18);
- plain_packet_set_type(&packet, PAYLOAD_TYPE_TAP);
+ encrypted_packet_set_payload_length(&packet, 18);
+ encrypted_packet_set_seq_nr(&packet, 124025310);
+ encrypted_packet_set_sender_id(&packet, 0);
+ encrypted_packet_set_mux(&packet, 23412);
- printf("packet length: %d\n", plain_packet_get_length(&packet));
+ printf("packet length: %d\n", encrypted_packet_get_length(&packet));
printf("packet: \n");
- print_hex_dump(plain_packet_get_packet(&packet), plain_packet_get_length(&packet));
- printf("\npayload type: 0x%04X\n", plain_packet_get_type(&packet));
- printf("payload length: %d\n", plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_packet(&packet), encrypted_packet_get_length(&packet));
+ printf("\nseq nr: 0x%08X\n", encrypted_packet_get_seq_nr(&packet));
+ printf("sender id: 0x%04X\n", encrypted_packet_get_sender_id(&packet));
+ printf("mux: 0x%04X\n", encrypted_packet_get_mux(&packet));
+ printf("payload length: %d\n", encrypted_packet_get_payload_length(&packet));
printf("payload: \n");
- print_hex_dump(plain_packet_get_payload(&packet), plain_packet_get_payload_length(&packet));
+ print_hex_dump(encrypted_packet_get_payload(&packet), encrypted_packet_get_payload_length(&packet));
printf("\n\n");
-
// chrootAndDrop("/var/run/", "nobody");
// daemonize();
// log_printf(INFO, "running in background now");