/*
    Copyright 2000 (c) by David Schweikert,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public 
    Licence. A full copy of the GNU GPL is provided in the file COPYING 
    found in the development root of Topsy.
*/
/*
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Net/old/NetInit.c,v $
    Author(s):             
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Creation Date:         
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $      by: $Author: baderma $
 
 
    $Log: NetInit.c,v $
    Revision 1.4  2001/01/23 09:45:52  cjeker
    moved to Net/old
 
    Revision 1.3  2001/01/10 11:34:18  blutz
    getting the network stack to work and adapting stuff to new IO structure
 
    Revision 1.2  2000/11/15 10:12:14  ruf
    Repository Reorganisation
 
    Revision 1.1  2000/03/31 17:50:34  gfa
    Merged with /Net from several term projects
 
*/
#include <Messages.h>
#include <Syscall.h>
#include <Net.h>
#include <NetDebug.h>
#include <NetIface.h>
#include <Ethernet/NetEthernet.h>
#include <ARP/NetARP.h>
#include <IP/NetIP.h>
#include <ICMP/NetICMP.h>
#include <UDP/NetUDP.h>
//-BL #include <TCP/nettcpMain.h>

void netMain(ThreadArg arg);

void netInit()
{
  /* Init debug facility */
  netdbgInit();
  netdbgDisplay(NETDEBUG_GENERIC, "Network started.\n");

  /* Start netMain */
  if(tmStart(&netMainId, netMain, NULL, "net")!=TM_STARTOK)
  {
    netdbgDisplay(NETDEBUG_GENERIC, "*** ERROR: Can't start networking.\n");
    return;
  }

  /* Init netbufs */
  netbufInit();

  /* Init inter-module communication */
  netmodInit();

  /* Init interfaces */
  netifInit();

  /* Init modules */
  netethInit();
  netarpInit();
  netipInit();
  neticmpInit();
  netudpInit();
  //-BL nettcpInit();

  /* Configure the network */

  /* Address: 192.168.2.2 */
  netifSetAttr(0, NETATTR_IP_FROM_0, 192);
  netifSetAttr(0, NETATTR_IP_FROM_1, 168);
  netifSetAttr(0, NETATTR_IP_FROM_2, 2);
  netifSetAttr(0, NETATTR_IP_FROM_3, 2);
}
