tcpip.c
ubixos/exec.h
lib/kmalloc.h
net/debug.h
net/opt.h
net/sys.h
net/memp.h
net/pbuf.h
net/ipv4/ip.h
net/udp.h
net/tcp.h
net/tcpip.h
sys/thread.h
net/ipv4/ip.h
arch/lib.h
ubixos/sched.h
net/netif.h
net/udp.h
arch/cpu.h
arch/sys_arch.h
net/tcp.h
ubixos/types.h
sys/_types.h
net/arch.h
net/ipv4/icmp.h
vfs/file.h
sys/tss.h
lib/kmalloc.h
src/sys/net/api/tcpip.c
net/lwipopts.h
net/tcpip.h
net/api_msg.h
net/def.h
net/mem.h
net/memp.h
vfs/vfs.h
vfs/mount.h
net/ipv4/ip_addr.h
net/err.h
net/api.h
ubixfs/dirCache.h
ubixos/exec.h
net/opt.h
sys/sysproto.h
ubixos/elf.h
sys/signal.h
net/sys.h
ubixos/tty.h
net/pbuf.h
net/debug.h
net/ipv4/inet.h
arch/cc.h
void void tcpip_apimsg (struct api_msg *apimsg) tcpip_apimsg struct api_msg * apimsg tcpip_msg::apimsg mbox memp_free memp_mallocp MEMP_TCPIP_MSG tcpip_msg::msg NULL sys_mbox_post TCPIP_MSG_API api_msg_post
void void tcpip_init (void(*initfunc)(void *), void *arg) tcpip_init void(*)(void *) initfunc void * arg mbox NULL sys_mbox_new sys_thread_new tcpip_init_done tcpip_init_done_arg tcpip_thread netMainThread
err_t err_t tcpip_input (struct pbuf *p, struct netif *inp) tcpip_input struct pbuf * p struct netif * inp ERR_MEM ERR_OK tcpip_msg::inp mbox memp_mallocp MEMP_TCPIP_MSG tcpip_msg::msg NULL tcpip_msg::p pbuf_free sys_mbox_post TCPIP_MSG_INPUT netMainThread
void static void tcpip_tcp_timer (void *arg) tcpip_tcp_timer void * arg NULL sys_timeout tcp_tmr TCP_TMR_INTERVAL tcpip_thread
void static void tcpip_thread (void *arg) tcpip_thread void * arg api_msg_input ip_init ip_input mbox memp_freep MEMP_TCPIP_MSG tcpip_msg::msg NULL sys_mbox_fetch sys_timeout tcp_init TCP_TMR_INTERVAL tcpip_init_done tcpip_init_done_arg TCPIP_MSG_API TCPIP_MSG_INPUT tcpip_tcp_timer udp_init tcpip_init
sys_mbox_t sys_mbox_t mbox mbox accept_function mpi_createMbox mpi_destroyMbox mpi_fetchMessage mpi_findMbox mpi_postMessage mpi_spam sys_arch_mbox_fetch sys_mbox_free sys_mbox_new sys_mbox_post tcpip_apimsg tcpip_init tcpip_input tcpip_thread
void(*) void(* ) tcpip_init_done(void *arg) (void *arg) tcpip_init_done NULL netMainThread tcpip_init tcpip_thread
void * void* tcpip_init_done_arg tcpip_init_done_arg tcpip_init tcpip_thread

    /*
    *Copyright(c)2001,SwedishInstituteofComputerScience.
    *Allrightsreserved.
    *
    *Redistributionanduseinsourceandbinaryforms,withorwithout
    *modification,arepermittedprovidedthatthefollowingconditions
    *aremet:
    *1.Redistributionsofsourcecodemustretaintheabovecopyright
    *notice,thislistofconditionsandthefollowingdisclaimer.
    *2.Redistributionsinbinaryformmustreproducetheabovecopyright
    *notice,thislistofconditionsandthefollowingdisclaimerinthe
    *documentationand/orothermaterialsprovidedwiththedistribution.
    *3.NeitherthenameoftheInstitutenorthenamesofitscontributors
    *maybeusedtoendorseorpromoteproductsderivedfromthissoftware
    *withoutspecificpriorwrittenpermission.
    *
    *THISSOFTWAREISPROVIDEDBYTHEINSTITUTEANDCONTRIBUTORS``ASIS''AND
    *ANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THE
    *IMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE
    *AREDISCLAIMED.INNOEVENTSHALLTHEINSTITUTEORCONTRIBUTORSBELIABLE
    *FORANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIAL
    *DAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODS
    *ORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    *HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICT
    *LIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAY
    *OUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOF
    *SUCHDAMAGE.
    *
    *ThisfileispartofthelwIPTCP/IPstack.
    *
    *Author:AdamDunkels<adam@sics.se>
    *
    *$Id: tcpip_8c.xml 88 2016-01-12 00:11:29Z reddawg $
    */

    #include<ubixos/exec.h>
    #include<lib/kmalloc.h>

    #include"net/debug.h"

    #include"net/opt.h"

    #include"net/sys.h"

    #include"net/memp.h"
    #include"net/pbuf.h"

    #include"net/ipv4/ip.h"
    #include"net/udp.h"
    #include"net/tcp.h"

    #include"net/tcpip.h"

    staticvoid(*tcpip_init_done)(void*arg)=NULL;
    staticvoid*tcpip_init_done_arg;
    staticsys_mbox_tmbox;

    /*-----------------------------------------------------------------------------------*/
    staticvoid
    tcpip_tcp_timer(void*arg)
    {
    tcp_tmr();
    sys_timeout(TCP_TMR_INTERVAL,(sys_timeout_handler)tcpip_tcp_timer,NULL);
    }
    /*-----------------------------------------------------------------------------------*/

    staticvoid
    tcpip_thread(void*arg)
    {
    structtcpip_msg*msg;

    ip_init();
    udp_init();
    tcp_init();

    sys_timeout(TCP_TMR_INTERVAL,(sys_timeout_handler)tcpip_tcp_timer,NULL);

    if(tcpip_init_done!=NULL){
    tcpip_init_done(tcpip_init_done_arg);
    }

    while(1){/*MAINLoop*/
    sys_mbox_fetch(mbox,(void*)&msg);
    switch(msg->type){
    caseTCPIP_MSG_API:
    //kprintf("tcpip_thread:APImessage%p\n",msg);
    api_msg_input(msg->msg.apimsg);
    break;
    caseTCPIP_MSG_INPUT:
    //kprintf("tcpip_thread:IPpacket%p\n",msg);
    ip_input(msg->msg.inp.p,msg->msg.inp.netif);
    break;
    default:
    break;
    }
    memp_freep(MEMP_TCPIP_MSG,msg);
    }
    }
    /*-----------------------------------------------------------------------------------*/
    err_t
    tcpip_input(structpbuf*p,structnetif*inp)
    {
    structtcpip_msg*msg;

    msg=memp_mallocp(MEMP_TCPIP_MSG);
    if(msg==NULL){
    //kprintf("BADMESSAGE!!!\n");
    pbuf_free(p);
    returnERR_MEM;
    }
    //kprintf("GOODMESSAGE\n");

    msg->type=TCPIP_MSG_INPUT;
    msg->msg.inp.p=p;
    msg->msg.inp.netif=inp;
    sys_mbox_post(mbox,msg);
    returnERR_OK;
    }
    /*-----------------------------------------------------------------------------------*/
    void
    tcpip_apimsg(structapi_msg*apimsg)
    {
    structtcpip_msg*msg;
    msg=memp_mallocp(MEMP_TCPIP_MSG);
    if(msg==NULL){
    memp_free(MEMP_TCPIP_MSG,apimsg);
    return;
    }
    msg->type=TCPIP_MSG_API;
    msg->msg.apimsg=apimsg;
    sys_mbox_post(mbox,msg);
    }
    /*-----------------------------------------------------------------------------------*/
    void
    tcpip_init(void(*initfunc)(void*),void*arg)
    {
    tcpip_init_done=initfunc;
    tcpip_init_done_arg=arg;
    mbox=sys_mbox_new();
    sys_thread_new((void*)tcpip_thread,NULL);
    }
    /*-----------------------------------------------------------------------------------*/