00001 /*############################################################################## 00002 00003 nIP - nano IP stack 00004 00005 File : nip_init.c 00006 00007 Description : Initialize NIP Internetstack 00008 00009 Copyright notice: 00010 00011 Copyright (C) 2007 - 00012 Andreas Dittrich, dittrich@informatik.hu-berlin.de 00013 Jon Kowal, kowal@informatik.hu-berlin.de 00014 00015 This program is free software; you can redistribute it and/or 00016 modify it under the terms of the GNU General Public License 00017 as published by the Free Software Foundation; either version 2 00018 of the License, or (at your option) any later version. 00019 00020 This program is distributed in the hope that it will be useful, 00021 but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License 00026 along with this program; if not, write to the Free Software 00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00028 00029 ##############################################################################*/ 00030 00031 #include "nip_init.h" 00032 #include "net/net_if.h" 00033 #include "mem.h" 00034 #include "nip_error.h" 00035 #include "app/mdns.h" 00036 00037 extern nip_net_if_t nip_net_if_list[]; 00038 00039 /// global variable used by nIP functions to post additional error codes. 00040 nip_error_t nip_error; 00041 00042 /** Initialize NIP Internetstack 00043 */ 00044 void nip_init() 00045 { 00046 nip_net_if_id_t net_if_id = 0; 00047 00048 // clear network interfaces 00049 #if (NIP_NET_ENABLE==1) 00050 do 00051 { 00052 nip_net_if_list[ net_if_id ].id = NIP_NET_NO_IF; 00053 00054 /** \todo check if doing interface transmission memory allocation at this 00055 * point makes more sense than doing it whenever the transmission is used. 00056 * PRO: no need to initialize before usage -> saves program memory 00057 * CON: each allocated block eats up sizeof( nip_mem_block_t ) even when 00058 * not in use. 00059 * There should be a Switch to decide which way to go. 00060 */ 00061 00062 } while ( ++net_if_id < NIP_NET_IF_COUNT ); 00063 #endif 00064 00065 #if (NIP_MEM_ENABLE==1) 00066 // initialize dynamic memory 00067 nip_mem_init(); 00068 #endif 00069 00070 #if (NIP_MDNS_ENABLE == 1) 00071 // initialize MDNS buffers 00072 nip_mdns_init(); 00073 #endif 00074 }