diff --git a/src/sys/net/api/tcpip.c b/src/sys/net/api/tcpip.c index acbb182..189fcb0 100644 --- a/src/sys/net/api/tcpip.c +++ b/src/sys/net/api/tcpip.c @@ -51,22 +51,18 @@ #include "net/tcpip.h" -static void (* tcpip_init_done)(void *arg) = NULL; +static void (*tcpip_init_done)(void *arg) = NULL; static void *tcpip_init_done_arg; static sys_mbox_t mbox; /*-----------------------------------------------------------------------------------*/ -static void -tcpip_tcp_timer(void *arg) -{ +static void tcpip_tcp_timer(void *arg) { tcp_tmr(); - sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); + sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler) tcpip_tcp_timer, NULL); } /*-----------------------------------------------------------------------------------*/ -static void -tcpip_thread(void *arg) -{ +static void tcpip_thread(void *arg) { struct tcpip_msg *msg; kprintf("Started TCP THread"); @@ -75,47 +71,45 @@ tcp_init(); kprintf("Started TCP THread"); - sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); - - if(tcpip_init_done != NULL) { + 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) { /* MAIN Loop */ + while (1) { /* MAIN Loop */ kprintf("mbf1"); - sys_mbox_fetch(mbox, (void *)&msg); + sys_mbox_fetch(mbox, (void *) &msg); kprintf("mbf1"); - switch(msg->type) { - case TCPIP_MSG_API: - //kprintf("tcpip_thread: API message %p\n", msg); - api_msg_input(msg->msg.apimsg); + switch (msg->type) { + case TCPIP_MSG_API: + //kprintf("tcpip_thread: API message %p\n", msg); + api_msg_input(msg->msg.apimsg); break; - case TCPIP_MSG_INPUT: - //kprintf("tcpip_thread: IP packet %p\n", msg); - ip_input(msg->msg.inp.p, msg->msg.inp.netif); + case TCPIP_MSG_INPUT: + //kprintf("tcpip_thread: IP packet %p\n", msg); + ip_input(msg->msg.inp.p, msg->msg.inp.netif); break; - default: + default: break; } memp_freep(MEMP_TCPIP_MSG, msg); } } /*-----------------------------------------------------------------------------------*/ -err_t -tcpip_input(struct pbuf *p, struct netif *inp) -{ +err_t tcpip_input(struct pbuf *p, struct netif *inp) { struct tcpip_msg *msg; - + msg = memp_mallocp(MEMP_TCPIP_MSG); - if(msg == NULL) { + if (msg == NULL) { kprintf("BAD MESSAGE!!!\n"); while (1) - asm("nop"); - pbuf_free(p); - return ERR_MEM; + sched_yeild(); + pbuf_free(p); + return ERR_MEM; } kprintf("GOOD MESSAGE\n"); - + msg->type = TCPIP_MSG_INPUT; msg->msg.inp.p = p; msg->msg.inp.netif = inp; @@ -123,12 +117,10 @@ return ERR_OK; } /*-----------------------------------------------------------------------------------*/ -void -tcpip_apimsg(struct api_msg *apimsg) -{ +void tcpip_apimsg(struct api_msg *apimsg) { struct tcpip_msg *msg; msg = memp_mallocp(MEMP_TCPIP_MSG); - if(msg == NULL) { + if (msg == NULL) { memp_free(MEMP_TCPIP_MSG, apimsg); return; } @@ -137,15 +129,11 @@ sys_mbox_post(mbox, msg); } /*-----------------------------------------------------------------------------------*/ -void -tcpip_init(void (* initfunc)(void *), void *arg) -{ +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); + sys_thread_new((void *) tcpip_thread, NULL); } /*-----------------------------------------------------------------------------------*/ - - diff --git a/src/sys/net/net/init.c b/src/sys/net/net/init.c index ce38631..6a3a545 100644 --- a/src/sys/net/net/init.c +++ b/src/sys/net/net/init.c @@ -2,30 +2,30 @@ Copyright (c) 2004 The UbixOS Project All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: -Redistributions of source code must retain the above copyright notice, this list of -conditions, the following disclaimer and the list of authors. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions, the following -disclaimer and the list of authors in the documentation and/or other materials provided -with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software -without specific prior written permission. + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Id: init.c 54 2016-01-11 01:29:55Z reddawg $ -*****************************************************************************************/ + *****************************************************************************************/ #include #include @@ -45,6 +45,7 @@ #include void netMainThread(); + static void tcpip_init_done(void *arg); int net_init() { @@ -53,38 +54,32 @@ memp_init(); pbuf_init(); - /* - *thread = (void *)execThread((void *)start_routine,0x0,arg); - */ - - sys_thread_new((void *)(netMainThread), 0x0); + sys_thread_new((void *) (netMainThread), 0x0); - return(0x0); - } - + return (0x0); +} void netMainThread() { struct ip_addr ipaddr, netmask, gw; sys_sem_t sem; - + netif_init(); sem = sys_sem_new(0); + tcpip_init(tcpip_init_done, &sem); - kprintf("WAIT: %i]",_current->id); sys_sem_wait(sem); - kprintf("FREE"); sys_sem_free(sem); kprintf("TCP/IP initialized.\n"); - IP4_ADDR(&gw, 10,50,0,1); - IP4_ADDR(&ipaddr, 10,50,6,65); - IP4_ADDR(&netmask, 255,255,0,0); + IP4_ADDR(&gw, 10, 50, 0, 1); + IP4_ADDR(&ipaddr, 10, 50, 6, 65); + IP4_ADDR(&netmask, 255, 255, 0, 0); netif_set_default(netif_add(&ipaddr, &netmask, &gw, ethernetif_init, tcpip_input)); - IP4_ADDR(&gw, 127,0,0,1); - IP4_ADDR(&ipaddr, 127,0,0,1); - IP4_ADDR(&netmask, 255,0,0,0); + IP4_ADDR(&gw, 127, 0, 0, 1); + IP4_ADDR(&ipaddr, 127, 0, 0, 1); + IP4_ADDR(&netmask, 255, 0, 0, 0); netif_add(&ipaddr, &netmask, &gw, loopif_init, tcpip_input); //udpecho_init(); @@ -92,16 +87,13 @@ //bot_init(); irqEnable(0x9); endTask(_current->id); - } - +} static void tcpip_init_done(void *arg) { sys_sem_t *sem = 0x0; sem = arg; - kprintf("SIG"); sys_sem_signal(*sem); - kprintf("NAL"); - } +} /*** END diff --git a/src/sys/net/net/shell.c b/src/sys/net/net/shell.c index 95dd489..d497afc 100644 --- a/src/sys/net/net/shell.c +++ b/src/sys/net/net/shell.c @@ -56,12 +56,12 @@ // UBU static struct netconn *conns[NCONNS]; static void sendstr(const char *str, struct netconn *conn) { - netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY); - } + netconn_write(conn, (void *) str, strlen(str), NETCONN_NOCOPY); +} static void prompt(struct netconn *conn) { sendstr("uBixCube:@sys> ", conn); - } +} static void shell_main(struct netconn *conn) { struct netbuf *buf = 0x0; @@ -72,35 +72,35 @@ while (1) { buf = netconn_recv(conn); if (buf != 0x0) - netbuf_copy(buf,buffer,1024); - len = netbuf_len(buf); - netbuf_delete(buf); - buffer[len-2] = '\0'; - kprintf("Buffer: [%s:%i]\n",buffer,len); - if (!strcmp(buffer,"quit")) { - netconn_close(conn); - break; - } - else if (!strcmp(buffer,"ls")) { - sendstr("no\nfiles\nhere\n", conn); - } - else if (!strcmp(buffer,"uname")) { - sendstr("UbixOS v1.0 reddawg@devel.ubixos.com:/ubix.elf\n",conn); - } - prompt(conn); - } + netbuf_copy(buf, buffer, 1024); + len = netbuf_len(buf); + netbuf_delete(buf); + buffer[len - 2] = '\0'; + kprintf("Buffer: [%s:%i]\n", buffer, len); + if (!strcmp(buffer, "quit")) { + netconn_close(conn); + break; + } + else if (!strcmp(buffer, "ls")) { + sendstr("no\nfiles\nhere\n", conn); + } + else if (!strcmp(buffer, "uname")) { + sendstr("UbixOS v1.0 reddawg@devel.ubixos.com:/ubix.elf\n", conn); + } + prompt(conn); } +} static void shell_thread(void *arg) { struct netconn *conn = 0x0, *newconn = 0x0; - - buffer = (char *)kmalloc(1024); - + + buffer = (char *) kmalloc(1024); + conn = netconn_new(NETCONN_TCP); netconn_bind(conn, NULL, 23); netconn_listen(conn); - while(1) { + while (1) { kprintf("shell1"); newconn = netconn_accept(conn); kprintf("2"); @@ -108,12 +108,12 @@ kprintf("3"); //netconn_delete(newconn); kprintf("4"); - } } +} -void shell_init(void) { +void shell_init(void) { sys_thread_new(shell_thread, NULL); - } +} /*** END diff --git a/src/sys/net/net/sys_arch.c b/src/sys/net/net/sys_arch.c index 1899ee4..4529333 100644 --- a/src/sys/net/net/sys_arch.c +++ b/src/sys/net/net/sys_arch.c @@ -124,7 +124,6 @@ kTask_t *ubthread; }; - static struct timeval starttime; static struct sys_sem *sys_sem_new_(uInt8 count); @@ -138,8 +137,8 @@ pt = ubthread_self(); //kprintf("SL: %i-0x%X]", _current->id, &netThreadSpinlock); spinLock(&netThreadSpinlock); - for(st = threads; st != NULL; st = st->next) { - if(st->ubthread == pt) { + for (st = threads; st != NULL; st = st->next) { + if (st->ubthread == pt) { //kprintf("SUL: %i-0x%X]", _current->id, &netThreadSpinlock); spinUnlock(&netThreadSpinlock); return st; @@ -150,183 +149,178 @@ kprintf("sys: current_thread: could not find current thread!\n"); kprintf("This is due to a race condition in the LinuxThreads\n"); kprintf("ubthreads implementation. Start the program again.\n"); - - kpanic("ABORT"); - return(0x0); - } + kpanic("ABORT"); + return (0x0); +} struct thread_start_param { struct sys_thread *thread; - void (* function)(void *); + void (*function)(void *); void *arg; - }; +}; /* -static void *thread_start(void *arg) { - struct thread_start_param *tp = arg; - tp->thread->ubthread = ubthread_self(); - tp->function(tp->arg); - kfree(tp); - return(NULL); - } -*/ + static void *thread_start(void *arg) { + struct thread_start_param *tp = arg; + tp->thread->ubthread = ubthread_self(); + tp->function(tp->arg); + kfree(tp); + return(NULL); + } + */ -void sys_thread_new(void (* function)(void), void *arg) { +void sys_thread_new(void (*function)(void), void *arg) { struct sys_thread *thread = 0x0; //struct thread_start_param *thread_param; - kprintf("sys_thread: [0x%X]\n",sizeof(struct sys_thread)); + kprintf("sys_thread: [0x%X]\n", sizeof(struct sys_thread)); + thread = kmalloc(sizeof(struct sys_thread)); - memset(thread,0x0,sizeof(struct sys_thread)); - kprintf("THREAD: [0x%X]\n",thread); - //kprintf("SL: %i-0x%X]", _current->id, &netThreadSpinlock); + memset(thread, 0x0, sizeof(struct sys_thread)); + kprintf("THREAD: [0x%X]\n", thread); + + spinLock(&netThreadSpinlock); thread->next = threads; thread->timeouts.next = NULL; thread->ubthread = 0x0; threads = thread; - //kprintf("SUL: %i-0x%X]", _current->id, &netThreadSpinlock); spinUnlock(&netThreadSpinlock); - /* - thread_param = kmalloc(sizeof(struct thread_start_param)); - - thread_param->function = function; - thread_param->arg = arg; - thread_param->thread = thread; - */ + thread_param = kmalloc(sizeof(struct thread_start_param)); + + thread_param->function = function; + thread_param->arg = arg; + thread_param->thread = thread; + */ //execThread((void *)function,0x0,0x0); - - kprintf("thread->ubthread: [0x%X]\n",thread->ubthread); - if(ubthread_create(&thread->ubthread, 0x0,(void *)(function), arg) != 0x0) { + kprintf("thread->ubthread: [0x%X]\n", thread->ubthread); + if (ubthread_create(&thread->ubthread, 0x0, (void *) (function), arg) != 0x0) { kpanic("sys_thread_new: ubthread_create"); - } - kprintf("thread->ubthread: [0x%X]\n",thread->ubthread); - } + kprintf("thread->ubthread: [0x%X]\n", thread->ubthread); + +} struct sys_mbox *sys_mbox_new() { struct sys_mbox *mbox; mbox = kmalloc(sizeof(struct sys_mbox)); - memset(mbox,0x0,sizeof(struct sys_mbox)); + memset(mbox, 0x0, sizeof(struct sys_mbox)); mbox->first = mbox->last = 0; mbox->mail = sys_sem_new_(0); mbox->mutex = sys_sem_new_(1); - - return(mbox); - } + + return (mbox); +} void sys_mbox_free(struct sys_mbox *mbox) { if (mbox != SYS_MBOX_NULL) { sys_sem_wait(mbox->mutex); - sys_sem_free_(mbox->mail); sys_sem_free_(mbox->mutex); mbox->mail = mbox->mutex = NULL; - //kprintf("sys_mbox_free: mbox 0x%lx\n", mbox); kfree(mbox); - } } +} void sys_mbox_post(struct sys_mbox *mbox, void *msg) { uInt8 first; - + sys_sem_wait(mbox->mutex); - + //kprintf("sys_mbox_post: mbox %p msg %p\n", mbox, msg); mbox->msgs[mbox->last] = msg; - if (mbox->last == mbox->first) { + if (mbox->last == mbox->first) first = 1; - } - else { + else first = 0; - } - - mbox->last++; - if(mbox->last == SYS_MBOX_SIZE) { - mbox->last = 0; - } - if(first) { + mbox->last++; + + if (mbox->last == SYS_MBOX_SIZE) + mbox->last = 0; + + + if (first) sys_sem_signal(mbox->mail); - } + sys_sem_signal(mbox->mutex); - } +} uint16_t sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, uint16_t timeout) { uint16_t time = 1; - + /* The mutex lock is quick so we don't bother with the timeout - stuff here. */ -kprintf("sem wait0"); + stuff here. */ + kprintf("sem wait0"); sys_arch_sem_wait(mbox->mutex, 0); -kprintf("sem wait1"); - - while(mbox->first == mbox->last) { -kprintf("sem wait2"); + kprintf("sem wait1"); + + while (mbox->first == mbox->last) { + kprintf("sem wait2"); sys_sem_signal(mbox->mutex); -kprintf("sem wait3"); - + kprintf("sem wait3"); + /* We block while waiting for a mail to arrive in the mailbox. We - must be prepared to timeout. */ - if(timeout != 0) { -kprintf("sem wait4"); + must be prepared to timeout. */ + if (timeout != 0) { + kprintf("sem wait4"); time = sys_arch_sem_wait(mbox->mail, timeout); -kprintf("sem wait5"); - + kprintf("sem wait5"); + /* If time == 0, the sem_wait timed out, and we return 0. */ - if(time == 0) { - return 0; + if (time == 0) { + return 0; } - } else { -kprintf("sem wait6"); - sys_arch_sem_wait(mbox->mail, 0); -kprintf("sem wait7"); } - -kprintf("sem wait8"); + else { + kprintf("sem wait6"); + sys_arch_sem_wait(mbox->mail, 0); + kprintf("sem wait7"); + } + + kprintf("sem wait8"); sys_arch_sem_wait(mbox->mutex, 0); -kprintf("sem wait9"); + kprintf("sem wait9"); } -kprintf("sem wait10"); - - if(msg != NULL) { + kprintf("sem wait10"); + + if (msg != NULL) { //kprintf("sys_mbox_fetch: mbox %p msg %p\n", mbox, *msg); *msg = mbox->msgs[mbox->first]; } - + mbox->first++; - if(mbox->first == SYS_MBOX_SIZE) { + if (mbox->first == SYS_MBOX_SIZE) { mbox->first = 0; - } - - sys_sem_signal(mbox->mutex); - - return(time); } + sys_sem_signal(mbox->mutex); + + return (time); +} + struct sys_sem *sys_sem_new(uInt8 count) { return sys_sem_new_(count); - } +} -static struct sys_sem *sys_sem_new_(uInt8 count) { +static struct sys_sem *sys_sem_new_(uint8_t count) { struct sys_sem *sem; - + sem = kmalloc(sizeof(struct sys_sem)); - memset(sem,0x0,sizeof(struct sys_sem)); + memset(sem, 0x0, sizeof(struct sys_sem)); sem->c = count; - + ubthread_cond_init(&(sem->cond), NULL); ubthread_mutex_init(&(sem->mutex), NULL); - kprintf("C: 0x%X, M: 0x%X, ID: %i]",&(sem->cond),&(sem->mutex),_current->id); - + return sem; - } +} static uint16_t cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, uint16_t timeout) { unsigned int tdiff; @@ -341,52 +335,52 @@ gettimeofday(&rtime1, &tz); sec = rtime1.tv_sec; usec = rtime1.tv_usec; - usec += timeout % 1000 * 1000; - sec += (int)(timeout / 1000) + (int)(usec / 1000000); + usec += timeout % 1000 * 1000; + sec += (int) (timeout / 1000) + (int) (usec / 1000000); usec = usec % 1000000; ts.tv_nsec = usec * 1000; ts.tv_sec = sec; - + retval = ubthread_cond_timedwait(cond, mutex, &ts); if (retval == ETIMEDOUT) { return 0; - } + } else { /* Calculate for how long we waited for the cond. */ gettimeofday(&rtime2, &tz); - tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + - (rtime2.tv_usec - rtime1.tv_usec) / 1000; + tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000; if (tdiff == 0) { - return 1; - } - return tdiff; + return 1; } + return tdiff; } + } else { ubthread_cond_wait(cond, mutex); return 0; - } } +} uint16_t sys_arch_sem_wait(struct sys_sem *sem, uint16_t timeout) { //kprintf("Or Here? %i:%i-0x%X]", _current->id, sem->mutex->pid,&(sem->mutex)); uint16_t time = 1; ubthread_mutex_lock(&(sem->mutex)); - while(sem->c <= 0) { - if(timeout > 0) { + while (sem->c <= 0) { + if (timeout > 0) { time = cond_wait(&(sem->cond), &(sem->mutex), timeout); - if(time == 0) { - ubthread_mutex_unlock(&(sem->mutex)); - return 0; + if (time == 0) { + ubthread_mutex_unlock(&(sem->mutex)); + return 0; } - } else { + } + else { cond_wait(&(sem->cond), &(sem->mutex), 0); } } sem->c--; ubthread_mutex_unlock(&(sem->mutex)); - return(time); - } + return (time); +} void sys_sem_signal(struct sys_sem *sem) { //kprintf("HERE: %i:0x%X", _current->id,&(sem->mutex)); @@ -394,24 +388,24 @@ ubthread_mutex_lock(&(sem->mutex)); sem->c++; - if(sem->c > 1) + if (sem->c > 1) sem->c = 1; ubthread_cond_signal(&(sem->cond)); ubthread_mutex_unlock(&(sem->mutex)); - } +} void sys_sem_free(struct sys_sem *sem) { - if(sem != SYS_SEM_NULL) { + if (sem != SYS_SEM_NULL) { sys_sem_free_(sem); - } } +} static void sys_sem_free_(struct sys_sem *sem) { ubthread_cond_destroy(&(sem->cond)); ubthread_mutex_destroy(&(sem->mutex)); kfree(sem); - } +} unsigned long sys_unix_now() { struct timeval tv; @@ -424,18 +418,18 @@ usec = tv.tv_usec - starttime.tv_usec; msec = sec * 1000 + usec / 1000; return msec; - } +} void sys_init() { struct timezone tz; gettimeofday(&starttime, &tz); - } +} struct sys_timeouts *sys_arch_timeouts(void) { struct sys_thread *thread; thread = current_thread(); - return(&thread->timeouts); - } + return (&thread->timeouts); +} /*** END diff --git a/src/sys/net/net/udpecho.c b/src/sys/net/net/udpecho.c index 285db42..30e9087 100644 --- a/src/sys/net/net/udpecho.c +++ b/src/sys/net/net/udpecho.c @@ -40,22 +40,20 @@ #include "net/sys.h" /*-----------------------------------------------------------------------------------*/ -void -udpecho_thread(void *arg) -{ +void udpecho_thread(void *arg) { static struct netconn *conn; static struct netbuf *buf; static struct ip_addr *addr; static unsigned short port; char buffer[4096]; - + kprintf("1"); conn = netconn_new(NETCONN_UDP); kprintf("2"); netconn_bind(conn, NULL, 7); kprintf("3"); - while(1) { + while (1) { kprintf("a"); buf = netconn_recv(conn); kprintf("b"); @@ -74,8 +72,6 @@ } } /*-----------------------------------------------------------------------------------*/ -void -udpecho_init(void) -{ +void udpecho_init(void) { sys_thread_new(udpecho_thread, NULL); }