From e722e80149eaef8bebd9199a2ff91afaff04ecda Mon Sep 17 00:00:00 2001 From: Michal Zima Date: Thu, 14 Feb 2013 14:04:33 +0100 Subject: [PATCH] Simplified assigning of IP addresses --- src/icmp.c | 6 +++--- src/tcp.c | 8 +++----- src/udp.c | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/icmp.c b/src/icmp.c index cbb713f..76b598d 100644 --- a/src/icmp.c +++ b/src/icmp.c @@ -1,6 +1,6 @@ /* * WrapSix - * Copyright (C) 2008-2012 Michal Zima + * Copyright (C) 2008-2013 Michal Zima * * 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 @@ -125,7 +125,7 @@ int icmp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, ip6->next_header = IPPROTO_ICMPV6; ip6->hop_limit = ip4->ttl; ipv4_to_ipv6(&ip4->ip_src, &ip6->ip_src); - memcpy(&ip6->ip_dest, &connection->ipv6, sizeof(struct s_ipv6_addr)); + ip6->ip_dest = connection->ipv6; /* compute ICMP checksum */ icmp->checksum = 0x0; @@ -247,8 +247,8 @@ int icmp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload) ip4->flags_offset = htons(IPV4_FLAG_DONT_FRAGMENT); ip4->ttl = ip6->hop_limit; ip4->proto = IPPROTO_ICMP; + ip4->ip_src = wrapsix_ipv4_addr; ipv6_to_ipv4(&ip6->ip_dest, &ip4->ip_dest); - memcpy(&ip4->ip_src, &wrapsix_ipv4_addr, sizeof(struct s_ipv4_addr)); /* compute ICMP checksum */ icmp->checksum = 0x0; diff --git a/src/tcp.c b/src/tcp.c index a93c8a1..5437474 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -220,8 +220,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload, ip6->flow_label = 0x0; ip6->hop_limit = ip4->ttl; ipv4_to_ipv6(&ip4->ip_src, &ip6->ip_src); - memcpy(&ip6->ip_dest, &connection->ipv6, - sizeof(struct s_ipv6_addr)); + ip6->ip_dest = connection->ipv6; /* set incoming source port */ tcp->port_dest = connection->ipv6_port_src; @@ -367,8 +366,7 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload, ip6->hop_limit = ip4->ttl; ip6->next_header = IPPROTO_FRAGMENT; ipv4_to_ipv6(&ip4->ip_src, &ip6->ip_src); - memcpy(&ip6->ip_dest, &connection->ipv6, - sizeof(struct s_ipv6_addr)); + ip6->ip_dest = connection->ipv6; /* build IPv6 fragment header */ frag->next_header = IPPROTO_TCP; @@ -579,8 +577,8 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload) ip4->flags_offset = htons(IPV4_FLAG_DONT_FRAGMENT); ip4->ttl = ip6->hop_limit; ip4->proto = IPPROTO_TCP; + ip4->ip_src = wrapsix_ipv4_addr; ipv6_to_ipv4(&ip6->ip_dest, &ip4->ip_dest); - memcpy(&ip4->ip_src, &wrapsix_ipv4_addr, sizeof(struct s_ipv4_addr)); /* set outgoing source port */ tcp->port_src = connection->ipv4_port_src; diff --git a/src/udp.c b/src/udp.c index 9d33ca0..6972129 100644 --- a/src/udp.c +++ b/src/udp.c @@ -108,7 +108,7 @@ int udp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload, ip6->next_header = IPPROTO_UDP; ip6->hop_limit = ip4->ttl; ipv4_to_ipv6(&ip4->ip_src, &ip6->ip_src); - memcpy(&ip6->ip_dest, &connection->ipv6, sizeof(struct s_ipv6_addr)); + ip6->ip_dest = connection->ipv6; /* set incoming source port */ udp->port_dest = connection->ipv6_port_src; @@ -210,8 +210,8 @@ int udp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload) ip4->flags_offset = htons(IPV4_FLAG_DONT_FRAGMENT); ip4->ttl = ip6->hop_limit; ip4->proto = IPPROTO_UDP; + ip4->ip_src = wrapsix_ipv4_addr; ipv6_to_ipv4(&ip6->ip_dest, &ip4->ip_dest); - memcpy(&ip4->ip_src, &wrapsix_ipv4_addr, sizeof(struct s_ipv4_addr)); /* set outgoing source port */ udp->port_src = connection->ipv4_port_src;