Exemple #1
0
        public ER tcp_cre_cep(ID cepid, ref T_TCP_CCEP pk_ccep, out ID p_cepid)
        {
            ER Result = ER.E_NOEXS;

            p_cepid = ID.NULL;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                Result = g_Kernel.Nucleus.CreateTcpCep(cepid, ref pk_ccep, out p_cepid);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }
Exemple #2
0
        internal ER CreateTcpCep(ID cepid, ref T_TCP_CCEP pk_ccep, out ID p_cepid)
        {
            int i;

            //if (pk_ccep == null)
            //	return ER.E_PAR;

            if (cepid == ID.ID_AUTO) {
                //if (p_cepid == 0)
                //	return ER.E_PAR;

                cepid.Value = 1;

                for (i = 0; ; i++) {
                    if (i >= m_TcpCepTable.Count) {
                        TcpCep tcpCep = new TcpCep(cepid, ref pk_ccep, this, m_lwIP);
                        m_TcpCepTable.Add(tcpCep);
                        break;
                    }

                    if (cepid == m_TcpCepTable[i].CepID) {
                        cepid.Value++;
                    }
                    else {
                        TcpCep tcpCep = new TcpCep(cepid, ref pk_ccep, this, m_lwIP);
                        m_TcpCepTable.Insert(i, tcpCep);
                        break;
                    }
                }
                p_cepid = cepid;
            }
            else {
                ID tmpid;

                p_cepid = ID.NULL;

                for (i = 0; i < m_TcpCepTable.Count; i++) {
                    tmpid = m_TcpCepTable[i].CepID;

                    if (cepid == tmpid) {
                        return ER.E_OBJ;
                    }
                    else if (cepid < tmpid) {
                        break;
                    }
                }
                TcpCep tcpCep = new TcpCep(cepid, ref pk_ccep, this, m_lwIP);
                m_TcpCepTable.Insert(i, tcpCep);
            }

            return ER.E_OK;
        }