init.c

Go to the documentation of this file.
00001 
00002 #include "globals.h"
00003 #include "init.h"
00004 #include "time.h"
00005 #include "nip_init.h"
00006 #include NIP_ARCH_FILE(rtl8019.h)
00007 #include "app/dhcp.h"
00008 
00009 
00010 /** Initialize Networking
00011  *
00012  * @return
00013  *    - \ref SUCCESS if initialization was successfull
00014  *    - \ref ERROR if initialization failed
00015  **/
00016 success_t init_networking()
00017 {
00018         nip_net_if_t    *net_if;
00019 
00020         // initialize network stack
00021         nip_init();
00022 
00023         // configure network interface
00024 
00025         #if (NIP_RTL_ENABLE==1 && NIP_NET_ENABLE ==1)
00026         rtl_net_if_id = nip_net_if_create( NIP_PHY_IF_ETH );
00027 
00028         if ( rtl_net_if_id == NIP_NET_NO_IF )
00029         {
00030                 // network setup failed.
00031                 return ERROR;
00032         }
00033 
00034         // configure network driver interface
00035         ///@todo make driver init function (e.g. rtl_init_if) from the following code
00036         net_if = nip_net_if_ptr( rtl_net_if_id );
00037         net_if->phy_conf.open  = &nip_rtl_open;
00038         net_if->phy_conf.close = &nip_rtl_close;
00039         net_if->phy_conf.hard_send_init = &nip_rtl_send_init;
00040         net_if->phy_conf.hard_send      = &nip_rtl_send;
00041         net_if->phy_conf.hard_read_init = &nip_rtl_read_init;
00042         net_if->phy_conf.hard_read      = &nip_rtl_read;
00043         nip_set_if_flags( rtl_net_if_id, net_if->phy_conf.flags | NIP_PHY_IFF_BROADCAST | NIP_PHY_IFF_MULTICAST );
00044 
00045         // configure network interface (ip address)
00046 //      net_if->ip_conf.addr[0] = 10;
00047 //      net_if->ip_conf.addr[1] = 67;
00048 //      net_if->ip_conf.addr[2] = 74;
00049 //      net_if->ip_conf.addr[3] = 23;
00050 //
00051 //      net_if->ip_conf.subnet_mask[0] = 255;
00052 //      net_if->ip_conf.subnet_mask[1] = 255;
00053 //      net_if->ip_conf.subnet_mask[2] = 0;
00054 //      net_if->ip_conf.subnet_mask[3] = 0;
00055 //
00056 //      net_if->ip_conf.std_gateway[0] = 10;
00057 //      net_if->ip_conf.std_gateway[1] = 67;
00058 //      net_if->ip_conf.std_gateway[2] = 74;
00059 //      net_if->ip_conf.std_gateway[3] = 254;
00060 
00061 //      net_if->ip_conf.addr[0] = 192;
00062 //      net_if->ip_conf.addr[1] = 168;
00063 //      net_if->ip_conf.addr[2] = 2;
00064 //      net_if->ip_conf.addr[3] = 1;
00065 //
00066 //      net_if->ip_conf.subnet_mask[0] = 255;
00067 //      net_if->ip_conf.subnet_mask[1] = 255;
00068 //      net_if->ip_conf.subnet_mask[2] = 255;
00069 //      net_if->ip_conf.subnet_mask[3] = 0;
00070 //
00071 //      net_if->ip_conf.std_gateway[0] = 192;
00072 //      net_if->ip_conf.std_gateway[1] = 168;
00073 //      net_if->ip_conf.std_gateway[2] = 2;
00074 //      net_if->ip_conf.std_gateway[3] = 11;
00075 
00076         // start networking
00077         if ( nip_net_if_up( rtl_net_if_id ) == NIP_SUCCESS )
00078         {
00079                 return SUCCESS;
00080         }
00081         else
00082         {
00083                 return ERROR;
00084         }
00085 
00086         #else /* NIP_NET_ENABLE != 1 || NIP_RTL_ENABLE!=1*/
00087                 return ERROR;
00088         #endif /* NIP_NET_ENABLE == 1 && NIP_RTL_ENABLE==1*/
00089 
00090 }

Generated on Thu Jul 10 01:09:29 2008 for NIP by  doxygen 1.5.5