mirror of
https://code.semirocket.science/wrapsix
synced 2024-11-08 15:21:00 +02:00
Simplified assigning of IP addresses
This commit is contained in:
parent
378d3200c2
commit
e722e80149
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* WrapSix
|
||||
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
|
||||
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
|
||||
*
|
||||
* 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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user