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

📄 allports.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * FILENAME: allports.c
 *
 * Copyright 1998- 2002 By InterNiche Technologies Inc. All rights reserved
 *
 * Routines common to most targets. 
 *
 * MODULE: MISCLIB
 *
 * ROUTINES: netmain_init(), icmp_port_du(), station_state(), 
 * ROUTINES: ftpc_callback(), sysuptime(), packet_check(), mcastlist(), 
 *
 * The functions in this file are generic functions 
 * and hence used for all builds. In addition to the above functions,
 * globals "name" and "prompt" are also initialized in this file.
 *
 * This file was previously .\misclib\cmnport.c
 *
 * PORTABLE: yes
 * They are portable for all targets that InterNiche supports. In future
 * if there is need for any of them  to be made target-specific, then
 * #ifndef wrappers can be provided over here.
 */

#include "ipport.h"

#ifdef DHCP_SERVER
#include "dhcpport.h"
#endif   /* DHCP_SERVER */

#include "libport.h"
#include "q.h"
#include "netbuf.h"
#include "net.h"
#include "ether.h"
#include "arp.h"
#include "ip.h"
#include "icmp.h"
#include "udp.h"

#ifdef INCLUDE_NVPARMS     /* system uses InterNiche NV system */
#include "nvparms.h"
#endif

#ifdef USE_PPP
#include "ppp_port.h"
#endif   /* USE_PPP */

#ifdef USE_MODEM
#include "mdmport.h"
#else
#ifdef USE_PPP
#include "../mppp/mppp.h" /* for pppcfg */
#endif
#endif   /* USE_MODEM */

#ifdef PING_APP
#include "app_ping.h"
#endif

#include "menu.h"
#include "zprint.h"

#ifdef OSPORT_H
#include OSPORT_H
#endif

/* various network entry points */
extern   char* ip_startup(void);
extern   void  inet_timer(void);

#ifdef WEBPORT
extern   int   http_init(void);   /* start up the web server */
extern   void  http_check(void);
#endif

#ifdef TK_STDIN_DEVICE
extern   void  kbdio(void);
#endif

#if defined(TFTP_CLIENT) || defined(TFTP_SERVER)
extern   int   tftp_init(void);
#endif

#ifdef TELNET_SVR
extern   int   tel_init(void);
extern   void  tel_cleanup(void);
extern   void  tel_check(void);
extern   int   prep_telnet(void);
#endif

#ifdef DHCP_CLIENT
extern   void  dhc_setup(void);
#endif

#ifdef DHCP_SERVER
extern   int   dhcp_init(void);
extern   int   prep_dhcpsrv(void);
extern   void  dhcpsrv_cleanup(void);
#endif

#ifdef DNS_CLIENT
#include "dns.h"
#endif

#ifdef TCP_ECHOTEST
extern   int   tcp_echo_init(void);
extern   void  tcp_echo_cleanup(void);
extern   void  tcp_echo_recv(void);
#endif

#ifdef FTP_CLIENT
extern   int   fc_check(void);
extern   void  (*fc_callback)(void *fc,int logstate, int cmdstate);
extern   void  ftpc_callback(void *fc,int logstate, int cmdstate);
extern   int   prep_ftpc(void);
#endif

#ifdef VFS_FILES
extern   int   prep_vfs(void);
#endif

#ifdef INCLUDE_SNMP
extern   int   prep_snmp(void);
#endif

#ifdef SMTP_ALERTS
extern   int   prep_smtp(void);
#endif

#ifdef NATRT
extern   int   prep_natrt(void);
#endif

#ifdef  IP_MULTICAST
/* Add multicast test program call and a dummy definition of mcastlist */
extern   void  u_mctest_init(void);
extern   int   mcastlist(struct in_multi *);
#endif   /* IP_MULTICAST */

#ifdef TESTMENU   /* after menus.h */
extern   struct menu_op testmenu[10];
#endif   /* TESTMENU */

#ifdef DNS_SERVER
extern   int 	 dns_srvr_check(void);
extern 	 int 	 dns_srvr_init(int );
extern   void  dns_srvr_timer(void);
#endif   /* DNS_SERVER */

#ifdef UDPSTEST
extern   int   udp_echo_init(void);
extern   void  udp_echo_cleanup(void);
#endif   /* UDPSTEST */

#ifdef RIP_SUPPORT 
extern   int   rip_init(void);
extern   void  rip_cleanup(void);
extern   int   prep_rip(void);
#endif   /* RIP_SUPPORT */

#if (defined(INCLUDE_SNMPV1) || defined(INCLUDE_SNMPV2C))
extern   int   snmp_init(void);
#endif   /* INCLUDE_SNMPV1 || INCLUDE_SNMPV2C */

#ifdef INCLUDE_SNMPV3
extern   int   v3_init(void);
extern   void  v3_cleanup(void);
#endif   /* INCLUDE_SNMPV3 */

#ifdef RAWIPTEST
extern int raw_test_init(void);
#endif   /* RAWIPTEST */

#ifdef SUPERLOOP
#define task_stats(x)     ;
#else
void task_stats(void * pio);
#endif

#ifdef FULL_ICMP
void icmp_port_du(PACKET p, struct destun * pdp);
#endif

#ifdef FTP_SERVER
extern   int   ftps_init(void);
extern   void  ftps_cleanup(void);
#endif

#if defined(MEMDEV_SIZE) && defined(VFS_FILES)
extern int   init_memdev(void);
#endif

#ifdef USE_AUTOIP
extern   int   Upnp_init(void);
#endif   /* USE_AUTOIP */

/* The following global variables are used in most ports. They are used by code
 * covered under a variety of ipport.h feature ifdefs. Experience has show that
 * it's not practical to do a complete ifdef to omit these when they are not
 * in use. It would require a huge multiple OR case, and many preprocessors
 * don't handle ifdef logic that complex.
 */

//char * name = "InterNiche Portable TCP/IP Demo, v1.91\n";
char * prompt = "INET> ";     /* prompt for console */
ip_addr activehost  =  0L;    /* default ping host */
u_long  pingdelay   =  TPS;   /* 1 second between pings modify by zealea*/
int     deflength   =  64;    /* default ping packet length */

#ifdef USE_COMPORT
/* Struct contaning all configuration global params for Comport */
struct ComPortCfg comportcfg;
#endif   /* USE_COMPORT */

/* static net structs, so we can patch in default IP address. */
extern   struct net  netstatic[STATIC_NETS];


/* FUNCTION: netmain_init()
 * 
 * Initialize all the modules that are being compiled in.
 * This function is generic and is required for all builds
 *
 * Tasks do their own initialization. Hence for modules which have
 * their own tasks, we don't do the initialization in netmain_init(). 
 * That is done by putting then under "#ifdef SUPERLOOP"
 * 
 * PARAM1: 
 *
 * RETURNS: 
 */

void 
netmain_init(void)
{
   int   e;
   int   i;
   char *   msg;

  // printf("%s\n", name);
   //printf("Copyright 1996-2002 by InterNiche Technologies. All rights reserved. \n");

#ifndef SUPERLOOP
   /* call this to do pre-task setup including intialization of port_prep */
   
   msg = pre_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef INCLUDE_NVPARMS     /* system uses InterNiche NV system */
   e = get_nv_params();    /* get flash parameters into data structs */
   if (e)
   {
      Printu_Net("fatal error (%d) reading NV parameters.\n", e);
      panic("nv");
   }

   /* set static iface IP info up from stored parameters. These may 
   be overwritten from command line parms or DHCP later. */
   for (i = 0; i < STATIC_NETS; i++)
   {
      netstatic[i].n_ipaddr = inet_nvparms.ifs[i].ipaddr;
      netstatic[i].snmask = inet_nvparms.ifs[i].subnet;
      netstatic[i].n_defgw = inet_nvparms.ifs[i].gateway;
#ifdef IP_MULTICAST_IF
      /* Create a dummy entry for the Ethernet interface mcastlist */
      /* If this entry is set to NULL, multicast is not supported  */
      /* on this interface */
      netstatic[i].n_mcastlist = mcastlist;
#endif   /* IP_MULTICAST */
   }

#ifdef DNS_CLIENT
   /* set DNS client's server list from nvparms information */
   MEMCPY(dns_servers, inet_nvparms.dns_servers, sizeof(dns_servers));

#ifdef DNS_CLIENT_UPDT
   MEMCPY(soa_mname, inet_nvparms.dns_zone_name, sizeof(soa_mname));
#endif   /* DNS_CLIENT_UPDT */

#endif   /* DNS_CLIENT */

#ifdef USE_COMPORT
   comportcfg.comport = comport_nvparms.comport;
   comportcfg.LineProtocol = comport_nvparms.LineProtocol;
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */

#ifndef INCLUDE_NVPARMS
#ifdef USE_COMPORT
   comportcfg.comport = 0x01;
   comportcfg.LineProtocol = PPP;   /* Default to PPP */
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */
   msg = ip_startup();
   if (msg)
   {
      Printu_Net("inet startup error: %s\n", msg);
      panic("IP\0");
   }

#if defined(MEMDEV_SIZE) && defined(VFS_FILES)
   init_memdev(); /* init the mem and null test devices */
#endif

#ifdef IP_MULTICAST
   /* call the IP multicast test program */
   u_mctest_init();
#endif   /* IP_MULTICAST */

   /* clear debugging flags. Port can optionally turn them
    * back on in post_task_setup();
    * NDEBUG = UPCTRACE | IPTRACE | TPTRACE ;  
    */
   NDEBUG = 0;    

   /* print IP address of the first interface - for user's benefit */
   Printu_Net("IP address of %s : %s\n" , ((NET)(netlist.q_head))->name,
      print_ipad(((NET)(netlist.q_head))->n_ipaddr));
 
#ifndef SUPERLOOP
   /* call this per-target routine after basic tasks & net are up */
   msg = post_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef PING_APP
   ping_init();
#endif   /* PING_APP */

#ifdef RAWIPTEST
   raw_test_init();
#endif   /* RAWIPTEST */

#if defined(TFTP_CLIENT) || defined(TFTP_SERVER)
   tftp_init();
#endif   /* TFTP */

#ifdef TESTMENU
   install_menu(testmenu);
#endif   /* TESTMENU */

#ifdef USE_AUTOIP
   Upnp_init();      /* start Auto IP before DHCP client */
#endif   /* USE_AUTOIP */

#ifdef DHCP_CLIENT
   dhc_setup();   /* kick off any DHCP clients */
#endif   /* DHCP_CLIENT */

#ifdef DHCP_SERVER
#ifdef INCLUDE_NVPARMS
   if(dhserve_nvparms.ServeDHCP)
#endif
   {
      e = dhcp_init();
      if(e)
      {
         dprintf("Error %d starting DHCP server.\n",e);
      }
      else
      {
         exit_hook(dhcpsrv_cleanup);
         dprintf("Started DHCP server\n");
      }
   }
#endif /* DHCP_SERVER */

⌨️ 快捷键说明

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