Exemple #1
0
        public UdpCep(ID udpid, ref T_UDP_CCEP pk_cudp, Nucleus pNucleus, lwip lwip)
        {
            m_CepID   = udpid;
            m_cudp    = pk_cudp;
            m_Nucleus = pNucleus;
            m_lwIP    = lwip;

            ip_addr addr = new ip_addr(pk_cudp.myaddr.ipaddr);

            m_Pcb = m_lwIP.udp.udp_new();
            m_lwIP.udp.udp_bind(m_Pcb, addr, pk_cudp.myaddr.portno);
            udp.udp_recv(m_Pcb, recv, this);
        }
Exemple #2
0
        internal ER CreateUdpCep(ID cepid, ref T_UDP_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_UdpCepTable.Count)
                    {
                        UdpCep udpCep = new UdpCep(cepid, ref pk_ccep, this, m_lwIP);
                        m_UdpCepTable.Add(udpCep);
                        break;
                    }

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

                p_cepid = ID.NULL;

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

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

            return(ER.E_OK);
        }