internal static IpV4Address CalculateDestination(IpV4Address currentDestination, IpV4Options options) { if (options == null) { return(currentDestination); } IpV4OptionRoute ipV4OptionRoute = (IpV4OptionRoute)Enumerable.FirstOrDefault <IpV4Option>((IEnumerable <IpV4Option>)options.OptionsCollection, (Func <IpV4Option, bool>)(option => { if (option.OptionType != IpV4OptionType.LooseSourceRouting) { return(option.OptionType == IpV4OptionType.StrictSourceRouting); } return(true); })); if (ipV4OptionRoute != null) { ReadOnlyCollection <IpV4Address> route = ipV4OptionRoute.Route; if ((int)ipV4OptionRoute.PointedAddressIndex < route.Count) { return(route[route.Count - 1]); } } return(currentDestination); }
Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength) { IpV4Address[] addresses; byte pointedAddressIndex; if (!IpV4OptionRoute.TryRead(out addresses, out pointedAddressIndex, buffer, ref offset, valueLength)) { return((Option)null); } return((Option) new IpV4OptionLooseSourceRouting((IList <IpV4Address>)addresses, pointedAddressIndex)); }
Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength) { IpV4Address[] addresses; byte pointedAddressIndex; if (!IpV4OptionRoute.TryRead(out addresses, out pointedAddressIndex, buffer, ref offset, valueLength)) { return((Option)null); } return((Option) new IpV4OptionRecordRoute(pointedAddressIndex, addresses)); }
internal static IpV4Address CalculateDestination(IpV4Address currentDestination, IpV4Options options) { if (options == null) { return(currentDestination); } IpV4OptionRoute destinationControllerRouteOption = (IpV4OptionRoute)options.OptionsCollection.FirstOrDefault(option => option.OptionType == IpV4OptionType.LooseSourceRouting || option.OptionType == IpV4OptionType.StrictSourceRouting); if (destinationControllerRouteOption != null) { ReadOnlyCollection <IpV4Address> route = destinationControllerRouteOption.Route; if (destinationControllerRouteOption.PointedAddressIndex < route.Count) { return(route[route.Count - 1]); } } return(currentDestination); }