mirror of
https://code.semirocket.science/wrapsix
synced 2024-09-20 07:11:06 +03:00
4bc68edce5
Written new mechanism of wrapper from scratch in C * It listens to all ICMPv6 packets (for now) and translates them to ICMPv4 ones * It can compute the checksum of the packet as well
19 lines
408 B
C
19 lines
408 B
C
#include "wrapper.h"
|
|
#include "translate_ip.h"
|
|
|
|
struct in_addr ipaddr_6to4(struct in6_addr ip6_addr)
|
|
{
|
|
struct ip6addr_ip4part *addr;
|
|
struct in_addr ip4_addr;
|
|
char ip4_str[15];
|
|
|
|
/* "parse" the IPv6 addres */
|
|
addr = (struct ip6addr_ip4part *)(&ip6_addr);
|
|
|
|
/* build IPv4 address */
|
|
sprintf(ip4_str, "%d.%d.%d.%d", addr->a, addr->b, addr->c, addr->d);
|
|
inet_aton(ip4_str, &ip4_addr);
|
|
|
|
return ip4_addr;
|
|
}
|