Ejemplo n.º 1
0
        private void SendRouteError(Message.RouteError re)
        {
            Frame frame = Frame.GetFrame(_macHeader + Message.RouteError.cLength + _macTailer);
            if (frame == null)
                return;
            frame.ReserveHeader(_macHeader);
            if (re.WriteToFrame(frame))
            {
                UInt16 nextHop;
                if (_routingTable.GetRoute(re.TargetAddr, out nextHop))
                {
                    MacDataRequest(nextHop, ref frame);
                }
            }

            Frame.Release(ref frame);
        }
Ejemplo n.º 2
0
        private void SendRoutingMessage(Message.RoutingMessage rm)
        {
            Frame frame = Frame.GetFrame(_macHeader + Message.RoutingMessage.cLength + _macTailer);
            if (frame == null)
                return;
            frame.ReserveHeader(_macHeader);
            if (!rm.WriteToFrame(frame))
            {
                Frame.Release(ref frame);
                return;
            }

            bool ok;
            UInt16 nextHop;
            if (rm.IsRequest)
            {
                ok = true;
                nextHop = cBroadcastShortAddr;
            }
            else
            {
                ok = _routingTable.GetRoute(rm.TargetAddr, out nextHop);
            }

            if (ok)
            {
                Trace.Print("Sending " + rm.ToString());
                MacDataRequest(nextHop, ref frame);
            }

            Frame.Release(ref frame);
        }