00001 /***************************************************************************************** 00002 Copyright (c) 2004 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions, the following disclaimer and the list of authors. Redistributions in binary 00010 form must reproduce the above copyright notice, this list of conditions, the following 00011 disclaimer and the list of authors in the documentation and/or other materials provided 00012 with the distribution. Neither the name of the UbixOS Project nor the names of its 00013 contributors may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00022 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 $Id: init_8c-source.html 88 2016-01-12 00:11:29Z reddawg $ 00027 00028 *****************************************************************************************/ 00029 00030 #include <ubixos/types.h> 00031 #include <ubixos/sched.h> 00032 #include <ubixos/endtask.h> 00033 00034 #include <net/sys.h> 00035 #include <net/mem.h> 00036 #include <net/memp.h> 00037 #include <net/tcpip.h> 00038 00039 #include <netif/loopif.h> 00040 #include <netif/tcpdump.h> 00041 #include <netif/ethernetif.h> 00042 00043 #include <ubixos/exec.h> 00044 #include <lib/kmalloc.h> 00045 #include <lib/kprintf.h> 00046 00047 void netMainThread(); 00048 static void tcpip_init_done(void *arg); 00049 00050 int net_init() { 00051 sys_init(); 00052 mem_init(); 00053 memp_init(); 00054 pbuf_init(); 00055 00056 /* 00057 *thread = (void *)execThread((void *)start_routine,0x0,arg); 00058 */ 00059 00060 sys_thread_new((void *)(netMainThread), 0x0); 00061 00062 return(0x0); 00063 } 00064 00065 00066 void netMainThread() { 00067 struct ip_addr ipaddr, netmask, gw; 00068 sys_sem_t sem; 00069 00070 netif_init(); 00071 sem = sys_sem_new(0); 00072 tcpip_init(tcpip_init_done, &sem); 00073 sys_sem_wait(sem); 00074 sys_sem_free(sem); 00075 00076 kprintf("TCP/IP initialized.\n"); 00077 00078 IP4_ADDR(&gw, 10,4,0,1); 00079 IP4_ADDR(&ipaddr, 10,4,0,69); 00080 IP4_ADDR(&netmask, 255,255,255,0); 00081 netif_set_default(netif_add(&ipaddr, &netmask, &gw, ethernetif_init, tcpip_input)); 00082 00083 IP4_ADDR(&gw, 127,0,0,1); 00084 IP4_ADDR(&ipaddr, 127,0,0,1); 00085 IP4_ADDR(&netmask, 255,0,0,0); 00086 netif_add(&ipaddr, &netmask, &gw, loopif_init, tcpip_input); 00087 00088 //udpecho_init(); 00089 shell_init(); 00090 //bot_init(); 00091 endTask(_current->id); 00092 } 00093 00094 00095 static void tcpip_init_done(void *arg) { 00096 sys_sem_t *sem = 0x0; 00097 sem = arg; 00098 sys_sem_signal(*sem); 00099 } 00100 00101 /*** 00102 END 00103 ***/ 00104