Exemple #1
0
 public Setup(ChabuSetupInfo info, AbortMessage abortMessage, ChabuConnectingValidator connectingValidator)
 {
     this.infoLocal           = info;
     this.infoRemote          = new ChabuSetupInfo();
     this.abortMessage        = abortMessage;
     this.connectingValidator = connectingValidator;
 }
Exemple #2
0
        protected override void processRecvSetup()
        {
            /// when is startupRx set before?
            Utils.ensure(!setup.isRemoteSetupReceived(), ChabuErrorCode.PROTOCOL_SETUP_TWICE, "Recveived SETUP twice");
            //		Utils.ensure( activated, ChabuErrorCode.NOT_ACTIVATED, "While receiving the SETUP block, org.chabu was not activated." );

            string pn = getRecvString(8);
            int    pv = recvBuf.getInt();
            int    rs = recvBuf.getInt();
            int    av = recvBuf.getInt();
            string an = getRecvString(56);

            if (!Constants.PROTOCOL_NAME.equals(pn))
            {
                localAbortMessage.setPending(ChabuErrorCode.SETUP_REMOTE_CHABU_NAME,
                                             string.Format("Chabu protocol name mismatch. Expected {0}, received {1}", Constants.PROTOCOL_NAME, pn));
                return;
            }


            ChabuSetupInfo info = new ChabuSetupInfo(rs, av, an);

            setup.setRemote(info);

            if ((pv >> 16) != (Constants.PROTOCOL_VERSION >> 16))
            {
                localAbortMessage.setPending(ChabuErrorCode.SETUP_REMOTE_CHABU_VERSION, string.Format("Chabu Protocol Version: expt 0x{0:X8} recv 0x{1:X8}",
                                                                                                      Constants.PROTOCOL_VERSION, pv));
                return;
            }

            setup.checkConnectingValidator();
        }
Exemple #3
0
 protected void xmitFillSetupPacket(ChabuSetupInfo setupInfo)
 {
     xmitFillStart(PacketType.SETUP);
     xmitFillAddstring(SETUP_PROTNAME_MAXLENGTH, Constants.PROTOCOL_NAME);
     xmitFillAddInt(Constants.PROTOCOL_VERSION);
     xmitFillAddInt(setupInfo.recvPacketSize);
     xmitFillAddInt(setupInfo.applicationVersion);
     xmitFillAddstring(SETUP_APPNAME_MAXLENGTH, setupInfo.applicationProtocolName);
     xmitFillComplete();
 }
Exemple #4
0
        private static void verifyLocalSetup(ChabuSetupInfo localSetupInfo)
        {
            Utils.ensure(localSetupInfo.recvPacketSize >= Constants.MAX_RECV_LIMIT_LOW, ChabuErrorCode.SETUP_LOCAL_MAXRECVSIZE_TOO_LOW,
                         "maxReceiveSize must be at least 0x100, but is {0}", localSetupInfo.recvPacketSize);

            Utils.ensure(localSetupInfo.recvPacketSize <= Constants.MAX_RECV_LIMIT_HIGH, ChabuErrorCode.SETUP_LOCAL_MAXRECVSIZE_TOO_HIGH,
                         "maxReceiveSize must be max 0x{0:X}, but is {1}", Constants.MAX_RECV_LIMIT_HIGH, localSetupInfo.recvPacketSize);

            Utils.ensure(Utils.isAligned4(localSetupInfo.recvPacketSize), ChabuErrorCode.SETUP_LOCAL_MAXRECVSIZE_NOT_ALIGNED,
                         "maxReceiveSize must 4-byte aligned: {0}", localSetupInfo.recvPacketSize);

            Utils.ensure(localSetupInfo.applicationProtocolName != null, ChabuErrorCode.SETUP_LOCAL_APPLICATIONNAME_NULL,
                         "applicationName must not be null");

            int nameBytes = localSetupInfo.applicationProtocolName.getBytes(StandardCharsets.UTF_8).Length;

            Utils.ensure(nameBytes <= Constants.APV_MAX_LENGTH, ChabuErrorCode.SETUP_LOCAL_APPLICATIONNAME_TOO_LONG,
                         "applicationName must have length at maximum 200 UTF8 bytes, but has {0}", nameBytes);
        }
Exemple #5
0
        public ChabuImpl(ChabuFactory factory, ChabuSetupInfo localSetupInfo, int priorityCount,
                         List <ChabuChannelImpl> channels, Runnable xmitRequestListener, ChabuConnectingValidator connectingValidator)
        {
            this.notifierWhenRecvAndXmitCompletedStartup = new SingleEventNotifierFromTwoSources(eventCompletedStartup);
            this.xmitRequestListener = xmitRequestListener;
            verifyLocalSetup(localSetupInfo);
            xmitAbortMessage   = new AbortMessage(xmitRequestListener);
            this.channels      = channels;
            this.priorityCount = priorityCount;
            this.factory       = factory;

            this.setup = new Setup(localSetupInfo, xmitAbortMessage, connectingValidator);

            this.xmitter = factory.createXmitterStartup(xmitAbortMessage, xmitRequestListener, setup, xmitCompletedStartup);

            this.receiver = factory.createReceiverStartup(xmitAbortMessage, setup, recvCompletedStartup);
            verifyPriorityCount();
            verifyChannels();
        }
Exemple #6
0
 public void setRemote(ChabuSetupInfo info)
 {
     infoRemote = info;
     this.recvSetupCompleted = RecvState.RECVED;
 }