/// <summary> /// Handles RIPv1 updates /// </summary> /// <param name="udpFrame"></param> /// <param name="ipFrame"></param> /// <returns>Bool indicating if something changed</returns> private bool HandleRIPV1(UDP.UDPFrame udpFrame, IP.IPFrame ipFrame) { RIPFrame fRIPFrame; bool bChanged = false; if (ipFrame.SourceAddress.Equals(IPAddress.Broadcast)) // Check Addr { if (udpFrame.DestinationPort == iRIPPort) // Check Port { fRIPFrame = new RIPFrame(udpFrame.EncapsulatedFrame.FrameBytes); if (fRIPFrame.Version == 1) { foreach (RIPUpdate ru in fRIPFrame.GetUpdates()) { if (ru.AddressFamilyIdentifier == RIPEntryAddressFamily.IPv4) { bChanged |= UpdateEntry(ipFrame.SourceAddress, ru.Address, IPAddressAnalysis.GetClassfullSubnetMask(ru.Address), (int)ru.Metric); } } } } } return(bChanged); }
/// <summary> /// Handles RIPv2 Frames /// </summary> /// <param name="udpFrame"></param> /// <param name="ipFrame"></param> /// <returns>Bool indicating if something changed</returns> private bool HandleRIPV2(UDP.UDPFrame udpFrame, IP.IPFrame ipFrame) { RIPFrame fRIPFrame; bool bChanged = false; if (ipFrame.SourceAddress.Equals(IPAddress.Broadcast)) { HandleRIPV1(udpFrame, ipFrame); // RIPv1? Fallback! } else if (ipFrame.DestinationAddress.Equals(ipaRIPv2Address)) // Check Addr { if (udpFrame.DestinationPort == iRIPPort) //Check Port { fRIPFrame = new RIPFrame(udpFrame.EncapsulatedFrame.FrameBytes); if (fRIPFrame.Version == 2) { foreach (RIPUpdate ru in fRIPFrame.GetUpdates()) { if (ru.AddressFamilyIdentifier == RIPEntryAddressFamily.IPv4) { if (!IsHoldDown(ru.Address)) { bChanged |= UpdateEntry(ipFrame.SourceAddress, ru.Address, ru.Ripv2SubnetMask, (int)ru.Metric); } } } } else { bChanged |= HandleRIPV1(udpFrame, ipFrame); } } } return(bChanged); }