use |-operator to calc solicited-node address (draft)

geändert:       lib/libtins
	geändert:       src/ArpToNdpPacketHandler.cpp
	geändert:       src/Main.cpp
This commit is contained in:
stubbfel
2016-12-15 01:01:07 +01:00
parent 7a781d6d46
commit 7e7e66f0b7
3 changed files with 100 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
#include "ArpToNdpPacketHandler.h"
#include <regex>
#include <tins/ethernetII.h>
#include <tins/arp.h>
#include <tins/icmpv6.h>
@@ -34,17 +35,13 @@ bool ArpToNdpPacketHandler::handle(IN const Tins::PDU & pdu, IN IPacketHandler *
}
// convert ipv4 addresses to ipv6 addresses
uint32_t ndpMaskField = *ndpMask;
uint32_t targetMaskield = arpPdu->target_ip_addr();
uint32_t foo = ndpMaskField | targetMaskield;
UPtrIPv6Address srcIp6Address = std::make_unique<Tins::IPv6Address>(*prefix);
UPtrIPv6Address dstIp6Address = std::make_unique<Tins::IPv6Address>(*ndpPrefix);
UPtrIPv6Address targetIp6Address = std::make_unique<Tins::IPv6Address>(*prefix);
IpAddressTranslator::toIpv6Address(arpPdu->sender_ip_addr(), *srcIp6Address);
IpAddressTranslator::toIpv6Address(Tins::IPv4Address(foo), *dstIp6Address);
IpAddressTranslator::toIpv6Address(arpPdu->target_ip_addr(), *targetIp6Address);
// create ip4 pdu
std::unique_ptr<const Tins::IPv6> ipv6Pdu = std::make_unique<const Tins::IPv6>(*dstIp6Address,*srcIp6Address);
std::unique_ptr<const Tins::IPv6> ipv6Pdu = std::make_unique<const Tins::IPv6>((*targetIp6Address)|(*ndpPrefix),*srcIp6Address);
std::unique_ptr<Tins::ICMPv6> ndpPdu;
switch (arpPdu->opcode())
@@ -70,13 +67,16 @@ bool ArpToNdpPacketHandler::handle(IN const Tins::PDU & pdu, IN IPacketHandler *
{
// @todo to set multicast
forwardEthPdu.src_addr(ethPdu->src_addr());
forwardEthPdu.dst_addr(ethPdu->dst_addr());
Tins::IPv4Address foo =arpPdu->target_ip_addr();
std::string string("hello $name");
Tins::EthernetII::address_type ethernatMask = std::regex_replace("00:00:" + foo.to_string(), std::regex("."), ":");
Tins::EthernetII::address_type ethernatMask2 = "33:33:FF:00:00:00";
forwardEthPdu.dst_addr(ethernatMask | ethernatMask2);
}
forwardEthPdu /= *ipv6Pdu;
forwardEthPdu /= *ndpPdu;
// forward frame
return callBackHandler->handle(forwardEthPdu, this);
}