Ejemplo n.º 1
0
        public static BabelMessage CreateHandshakeMessage(MessageExchange exchange,
                                                          Router.RouterAction dispatch, byte postNetIfIndex, byte pid, byte arg)
        {
            BabelMessage m = new BabelMessage(exchange);

            m.IsHandshake        = true;
            m.IsGeneral          = false;
            m.Pid                = pid;
            m.Arg                = arg;
            m.PostNetIfIndex     = postNetIfIndex;
            m.Dispatch           = dispatch;
            m.IncomingNetIfIndex = ProtocolConstants.NETIF_UNSET;
            m.OutgoingNetIfIndex = ProtocolConstants.NETIF_UNSET;
            return(m);
        }
Ejemplo n.º 2
0
        public static BabelMessage CreateCommandMessage(MessageExchange exchange, bool verified,
                                                        Router.RouterAction dispatch, byte postNetIfIndex, byte cmd, ushort receiver,
                                                        ushort sender, byte flagsRS, byte ident, byte dataLen, byte dataOffset, byte[] dataAry)
        {
            BabelMessage m;

            if (dataLen >= ProtocolConstants.GENERAL_TAIL_SIZE)
            {
                return(null); // Longer messages not implemented yet.
            }
            m                    = new BabelMessage(exchange);
            m.IsHandshake        = false;
            m.IsGeneral          = true;
            m.Verified           = verified;
            m.PostNetIfIndex     = postNetIfIndex;
            m.Dispatch           = dispatch;
            m.IncomingNetIfIndex = ProtocolConstants.NETIF_UNSET;
            m.OutgoingNetIfIndex = ProtocolConstants.NETIF_UNSET;
            m.Cmd                = cmd;
            m.Receiver           = receiver;
            m.Sender             = sender;
            m.FlagsRS            = flagsRS;
            m.SenderId           = ident;
            m.DataLen            = dataLen;
            if (dataOffset <= 0)
            {
                m.DataAry = dataAry;
            }
            else
            {
                byte[] ary = new byte[dataAry.Length + dataOffset];
                Array.Copy(dataAry, 0, ary, dataOffset, dataAry.Length);
                m.DataAry = ary;
            }
            return(m);
        }
Ejemplo n.º 3
0
        // Helper routine for accessing messages.
        // ioIndex must point to a valid message, i.e. meta is set.
        // Returns 0 on success.
        // Returns error code on parse failure.
        public byte StartMessageTransaction(int ioIndex)
        {
            MsgBuffer   = Manager.IoBuffers[ioIndex];
            IoIndex     = ioIndex;
            ChangeDir   = false;
            Finish      = FinishAction.Free; // Free messages by default: prevents unhandled recursions.
            Dispatch    = Router.RouterAction.PostToNetIf;
            TaskCmd     = 0;
            ReturnCmd   = 0;
            ONetIfIndex = MsgBuffer.iNetIf;
            switch (MsgBuffer.flagsPid & ProtocolConstants.META_FLAGS_PID)
            {
            case ProtocolConstants.PID_GENERAL_V:
                MsgBuffer.flagsPid &= ProtocolConstants.META_FLAGS_PID;    // Clear out any resend value.
                break;

            case ProtocolConstants.PID_GENERAL:
                break;

            default:
                return(100);
            }
            return(0);
        }