public static byte[] GetBytes(RipPreambleHeader ripPreambleHeader) { var list = new List<byte>(); list.Add(ripPreambleHeader.command); list.Add(ripPreambleHeader.Version); list.AddRange(ByteReader.GetBytes(ripPreambleHeader.Domain)); return list.ToArray(); }
private void HandleRequest(string deviceID, RipPreambleHeader ripPreambleHeader, RipDataHeader[] ripDataHeaderArray) { //TODO: does rip flood to all interfaces upon requst from one?? SendFlood(deviceID); }
private void HandleResponse(string deviceID, RipPreambleHeader ripPreambleHeader, RipDataHeader[] ripDataHeaderArray, IPHeader ipHeader) { foreach (RipDataHeader ripDataHeader in ripDataHeaderArray) { if (RipDatabase.ContainsKey(ripDataHeader.Network)) { RipRoute route = RipDatabase[ripDataHeader.Network]; if (ripDataHeader.Metric < route.Metric) { RipDatabase[ripDataHeader.Network].UpdateRipHeaderData(ipHeader.SourceAddress, ripDataHeader); } else if (ripDataHeader.Metric > route.Metric && ripDataHeader.NextHop == ipHeader.SourceAddress) { if (route.AcceptPotentialNewMetricOnNextSighting && route.PotentialNewMetric == ripDataHeader.Metric) { route.AcceptPotentialNewMetric(); } else { route.BeginHoldDownTime(ripDataHeader); } } route.TimeUpdated = DateTime.Now; route.RaiseEvent(RipEvent.Sighted); } else { RipRoute route = RipRoute.Create(ipHeader.SourceAddress, ripDataHeader, deviceID); route.GCCollect += (s, e) => { RipDatabase.Remove((s as RipRoute).Network); Controller.RemoveRoute(this, route); }; Log.Write("RIP", "RipDatabaseAdd", ripDataHeader.Network.StandardFormat); RipDatabase.Add(ripDataHeader.Network, route); Controller.RegisterRoute(this, route); } } }