Beispiel #1
0
        internal ER Accept(tcp_pcb_listen pcb, TcpCep cep, T_IPV4EP p_dstaddr, TMO tmout)
        {
            ER ret;

            m_Pcb    = pcb;
            m_TcpCep = cep;

            tcp.tcp_accept(pcb, Accepting);

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
            {
                return(ER.E_CTX);
            }

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

            if ((m_TskQueue.First == null) && (m_AcceptQueue.First != null))
            {
                m_NewPcb = m_AcceptQueue.First.Value;
                m_AcceptQueue.RemoveFirst();
                p_dstaddr.ipaddr = lwip.lwip_ntohl(m_NewPcb.remote_ip.addr);
                p_dstaddr.portno = lwip.lwip_ntohs(m_NewPcb.remote_port);
            }
            else
            {
                if (task == null)
                {
                    return(ER.E_TMOUT);
                }

                if (tmout == 0)
                {
                    return(ER.E_TMOUT);
                }

                ret = task.Wait(m_TskQueue, TSKWAIT.TTW_ACP, m_RepID, tmout);

                switch (ret)
                {
                case ER.E_OK:
                    if (m_AcceptQueue.First == null)
                    {
                        return(ER.E_RLWAI);
                    }
                    m_NewPcb = m_AcceptQueue.First.Value;
                    m_AcceptQueue.RemoveFirst();
                    p_dstaddr.ipaddr = lwip.lwip_ntohl(m_NewPcb.remote_ip.addr);
                    p_dstaddr.portno = lwip.lwip_ntohs(m_NewPcb.remote_port);
                    break;

                case ER.E_TMOUT:
                    return(ER.E_TMOUT);

                default:
                    return(ER.E_RLWAI);
                }
            }

            return(ER.E_OK);
        }
Beispiel #2
0
        internal memp memp_malloc(memp_t type)
        {
            memp memp;

            switch (type)
            {
#if LWIP_RAW
            case memp_t.MEMP_RAW_PCB:
                memp = new raw_pcb(this);
                break;
#endif
#if LWIP_UDP
            case memp_t.MEMP_UDP_PCB:
                memp = new udp_pcb(this);
                break;
#endif
#if LWIP_TCP
            case memp_t.MEMP_TCP_PCB:
                memp = new tcp_pcb(this);
                break;

            case memp_t.MEMP_TCP_PCB_LISTEN:
                memp = new tcp_pcb_listen(this);
                break;

            case memp_t.MEMP_TCP_SEG:
                memp = new tcp_seg(this);
                break;
#endif
#if IP_REASSEMBLY
            case memp_t.MEMP_REASSDATA:
                memp = new ip_reassdata(this);
                break;

            case memp_t.MEMP_FRAG_PBUF:
                memp = new frag_pbuf(this);
                break;
#endif
#if LWIP_NETCONN
            case memp_t.MEMP_NETBUF:
                memp = new netbuf(this);
                break;

            case memp_t.MEMP_NETCONN:
                memp = new netconn(this);
                break;
#endif
#if false //!NO_SYS
            case memp_t.MEMP_TCPIP_MSG_API:
                memp = new tcpip_msg(this);
                break;

            case memp_t.MEMP_TCPIP_MSG_INPKT:
                memp = new tcpip_msg(this);
                break;
#endif
#if LWIP_ARP && ARP_QUEUEING
            case memp_t.MEMP_ARP_QUEUE:
                memp = new etharp_q_entry(this);
                break;
#endif
#if LWIP_IGMP
            case memp_t.MEMP_IGMP_GROUP:
                memp = new igmp_group(this);
                break;
#endif
#if false //(!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS))
            case memp_t.MEMP_SYS_TIMEOUT:
                memp = new sys_timeo(this);
                break;
#endif
#if LWIP_SNMP
            case memp_t.MEMP_SNMP_ROOTNODE:
                memp = new mib_list_rootnode(this);
                break;

            case memp_t.MEMP_SNMP_NODE:
                memp = new mib_list_node(this);
                break;

            case memp_t.MEMP_SNMP_VARBIND:
                memp = new snmp_varbind(this);
                break;

            case memp_t.MEMP_SNMP_VALUE:
                memp = new snmp_value(this);
                break;
#endif
#if LWIP_DNS && LWIP_SOCKET
            case memp_t.MEMP_NETDB:
                memp = new netdb(this);
                break;
#endif
#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
            case memp_t.MEMP_LOCALHOSTLIST:
                memp = new local_hostlist_entry(this);
                break;
#endif
#if PPP_SUPPORT && PPPOE_SUPPORT
            case memp_t.MEMP_PPPOE_IF:
                memp = new pppoe_softc(this);
                break;
#endif
            default:
                throw new InvalidOperationException();
            }

            memp._type = type;
            memp_heap.AddLast(memp);
            return(memp);
        }
Beispiel #3
0
        public ER Accept(TcpRep tcpRep, T_IPV4EP p_dstaddr, TMO tmout)
        {
            tcp_pcb_listen pcb = m_lwIP.tcp.tcp_listen(m_Pcb);

            return(tcpRep.Accept(pcb, this, p_dstaddr, tmout));
        }