1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-12-26 01:59:53 +03:00

Fix IPv6 Neighbor Discovery for PPP based protocols

This commit is contained in:
sl077 2021-05-09 13:55:31 +02:00
parent e2d61133fe
commit f9a1d72ce7
4 changed files with 26 additions and 18 deletions

View File

@ -1633,7 +1633,7 @@ void HubWatchDogThread(THREAD *t, void *param)
{
buf = BuildICMPv6NeighborSoliciation(&hub->HubIpV6,
&ip6addr,
hub->HubMacAddr, ++hub->HubIP6Id);
hub->HubMacAddr, ++hub->HubIP6Id, false);
if (buf != NULL)
{

View File

@ -2109,13 +2109,12 @@ void IPCIPv6AssociateOnNDTEx(IPC *ipc, IP *ip, UCHAR *mac_address, bool isNeighb
addrType = GetIPAddrType6(ip);
if (addrType != IPV6_ADDR_LOCAL_UNICAST &&
addrType != IPV6_ADDR_GLOBAL_UNICAST)
if (!(addrType & IPV6_ADDR_UNICAST))
{
return;
}
if (addrType == IPV6_ADDR_GLOBAL_UNICAST)
if (addrType & IPV6_ADDR_GLOBAL_UNICAST)
{
if (!IPCIPv6CheckUnicastFromRouterPrefix(ipc, ip, NULL))
{
@ -2617,23 +2616,16 @@ void IPCIPv6SendUnicast(IPC *ipc, void *data, UINT size, IP *next_ip)
// Generate the MAC address from the multicast address
BUF *neighborSolicit;
UCHAR destMacAddress[6];
IPV6_ADDR solicitAddress;
char tmp[MAX_SIZE];
UCHAR *copy;
BLOCK *blk;
Zero(&solicitAddress, sizeof(IPV6_ADDR));
Copy(&solicitAddress.Value[13], &header->DestAddress.Value[13], 3);
solicitAddress.Value[0] = 0xFF;
solicitAddress.Value[1] = 0x02;
solicitAddress.Value[11] = 0x01;
solicitAddress.Value[12] = 0xFF;
neighborSolicit = BuildICMPv6NeighborSoliciation(&header->SrcAddress, &solicitAddress, ipc->MacAddress, 0);
neighborSolicit = BuildICMPv6NeighborSoliciation(&header->SrcAddress, &header->DestAddress, ipc->MacAddress, 0, true);
destMacAddress[0] = 0x33;
destMacAddress[1] = 0x33;
Copy(&destMacAddress[2], &solicitAddress.Value[12], sizeof(UINT));
destMacAddress[2] = 0xFF;
Copy(&destMacAddress[3], &header->DestAddress.Value[13], 3);
IPCIPv6SendWithDestMacAddr(ipc, neighborSolicit->Buf, neighborSolicit->Size, destMacAddress);
FreeBuf(neighborSolicit);

View File

@ -845,7 +845,7 @@ BUF *BuildICMPv6(IPV6_ADDR *src_ip, IPV6_ADDR *dest_ip, UCHAR hop_limit, UCHAR t
}
// Build an ICMPv6 Neighbor Solicitation packet
BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id)
BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id, bool use_multicast)
{
ICMPV6_OPTION_LIST opt;
ICMPV6_OPTION_LINK_LAYER link;
@ -875,8 +875,24 @@ BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCH
WriteBuf(b2, &header, sizeof(header));
WriteBufBuf(b2, b);
ret = BuildICMPv6(src_ip, target_ip, 255,
ICMPV6_TYPE_NEIGHBOR_SOLICIATION, 0, b2->Buf, b2->Size, id);
if (use_multicast)
{
IPV6_ADDR solicitAddress;
Zero(&solicitAddress, sizeof(IPV6_ADDR));
solicitAddress.Value[0] = 0xFF;
solicitAddress.Value[1] = 0x02;
solicitAddress.Value[11] = 0x01;
solicitAddress.Value[12] = 0xFF;
Copy(&solicitAddress.Value[13], &target_ip->Value[13], 3);
ret = BuildICMPv6(src_ip, &solicitAddress, 255,
ICMPV6_TYPE_NEIGHBOR_SOLICIATION, 0, b2->Buf, b2->Size, id);
}
else
{
ret = BuildICMPv6(src_ip, target_ip, 255,
ICMPV6_TYPE_NEIGHBOR_SOLICIATION, 0, b2->Buf, b2->Size, id);
}
FreeBuf(b);
FreeBuf(b2);

View File

@ -792,7 +792,7 @@ BUF *BuildIPv6(IPV6_ADDR *dest_ip, IPV6_ADDR *src_ip, UINT id, UCHAR protocol, U
BUF *BuildIPv6PacketHeader(IPV6_HEADER_PACKET_INFO *info, UINT *bytes_before_payload);
UCHAR IPv6GetNextHeaderFromQueue(QUEUE *q);
void BuildAndAddIPv6PacketOptionHeader(BUF *b, IPV6_OPTION_HEADER *opt, UCHAR next_header, UINT size);
BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id);
BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id, bool use_multicast);
BUF *BuildICMPv6RouterSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id);
BUF *BuildICMPv6(IPV6_ADDR *src_ip, IPV6_ADDR *dest_ip, UCHAR hop_limit, UCHAR type, UCHAR code, void *data, UINT size, UINT id);