⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ethernetstart.c

📁 lwIP-Softools-11Jul2002-alpha
💻 C
字号:
/* * Functions to start the ethernet system. * * (C) 2002 Compendium Technologies, Inc. * (C) 2002 Softools, Inc. * All rights reserved. * * This software is the proprietary information of Compendium Technologies, Inc. * and Softools, Inc. Use is subject to license terms. */#include <Rabbit2000.h>#include <stdlib.h>#include <stdarg.h>#include <rabbitlwip.h>#include "dns.h"#include "RTK8019AS.h"#include "lwip/netif.h"#include "lwip/api_msg.h"extern unsigned char netInited;#define DEBUG/* * Flag helps us avoid stepping on configurations that are already set up */unsigned char _ethInitialized = 0;static void _nearcallethernetTimer(void *arg){#ifdef TIMER_DEBUG    puts("|");#endif    tcp_tmr();    sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler) ethernetTimer, NULL);}/* * Start an ethernet interface, initialize arp and dns. * prerequisite: netRecognize(). */int ethernetStart(NetConnectionConfig *config, ...){    //int retValue;    va_list ap;    char *nameserver;    ipset3();    if (_ethInitialized)        return 0;    // Initialize TCP/UDP/IP system    // Alternative in threaded environment is to call tcpip_init() to do this    if (!netInited)    {       netInit();    }    ip_init();  // From tcpip_thread    udp_init(); // From tcpip_thread    tcp_init(); // From tcpip_thread    arp_init();    // Need to initialize timeouts as well    sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)ethernetTimer, NULL);    // Initialize the packet driver and the TCP/IP stack constructs    // This also zeros out things like the name server list    //netif_add();        //retValue = tcp_init_noexit(); /* Must precede configuration */    //if (retValue)    //    return retValue;    _ethInitialized = 1;    ipres();    if (config == NULL)    {#ifdef DEBUG        printf("doing DHCP init\n");#endif        /* DHCP/BOOTP initialization */        // TODO: DHCP        // if (!dhcp_enable())        // {        //     shutdown();        //     _ethInitialized = 0;        //     return 3;        // }        _ethInitialized = 0;        return 3;    }    else    {        struct netif * interface;#ifdef DEBUG        printf("doing static IP init\n");#endif        /* Static IP initialization */               interface = netif_add(&config->address,                              &config->netmask,                              &configuration.defaultGateway,                              RTK8019AS_if_init,                              ip_input);        netif_set_default(interface);    }    // Swap it once and store so we don't have to do this again.    //interfaceStats[0].swappedIpAddress = intel(my_ip_addr);    // Get the list of DNS servers (if there are any) in the variable length    // argument list.    va_start(ap, config);    nameserver = va_arg(ap, char *);    while(nameserver != NULL)    {        struct ip_addr nsip;#ifdef DEBUG        printf("adding nameserver\n");#endif        if (netStringToIP(nameserver, &nsip))        {            dnsAddServer(&nsip);        }        nameserver = va_arg(ap, char *);    }    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -