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

📄 ospf_system.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 3 页
字号:
/* ospf_system.c - OSPF system *//* Copyright 2000-2003 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02m,13jun03,agi  SPR#88974, fixed static configuration02l,09jun03,agi  SPR#88958, eliminated race condition - task state should                 be set to created before the task is spawned02k,10jun03,kkz  SPR#88929, moved creation of semaphores to ospfInitialize() 02j,02jun03,ram  Moved OSPF memory partition creation to ospfInitialize02i,29may03,agi  Moved configuration_data definition out of __OSFP_FTP__ preproc02h,12may03,asr	 Changes to make OSPF virtual stack compatible02g,27may03,agi  Removed the SPF task, added code inspection changes02f,26may03,agi  Modified RWOS_MAXIMUM_FILE_SIZE to OSPF_MAXIMUM_FILE_SIZE                 added taskDelay() call for the SPF  task02e,26may03,agi  Added __OSPF_MIB__ conditional compile directive around                  ospf_management_init() to prevent link errors02d,23may03,agi  Added return value checks, updated function headers02c,09may03,agi  Modified OSPF task startup from using RWOS dispatcher to using                  vxWorks taskSpawn()02b,22apr03,ram	 SPR#76812 Modifications for OSPF performance enhancements02a,17feb02,ram	 SPR#81808 Added OSPF memory partition support01p,19nov02,mwv  Merge TMS code SPR 8428401o,29may02,jkw  Change rwos_task_main to rw_task_main for fixes to synchronize                 child and parent task as well as add task options.01n,16apr02,jkw  Remove task_options variable unused.01m,25mar02,kc   Added task_options argument to rwos_task_main() call.01l,24mar02,kc   Modified ospf_startup() to return status code.01k,22feb02,kc   Fixed callout to OSPF MIB API as a result of functions name changes.01j,13feb02,kc   Renamed task name from "OSPF" to "tOspfTimer".01i,11feb02,kc   Added __ENVOY_SNMP_API to init envoy snmp api for ospf mib                 and wrn-ospf enterprise mib.01h,08nov01,kc   Removed MIB API initialization from ospf_init() and added                 "spf_management_init().01g,21oct01,kc   Added ospf_startup() routine for dynamic reconfiguration.01f,13oct01,kc   Dynamic configuration changes.01e,17sep01,kc   Moved raw socket init to ospf_initialize_protocol(). Added ospf_cfg().01d,23aug01,jkw  Fixed compiler warnings.01c,13aug01,aos  Modified OSPF task initialization to save the task ID01b,13aug01,kc   Fixed compiler warnings - added <sockLib.h> include.01a,26jun01,jkw  Moved global variables to ospf_globals.h for cleanup*//*DESCRIPTIONospf_system.c is used for starting OSPF.  This file will call the appropriate functions tointialize the configuration and start the OSPF process.This file is used whenever starting up OSPF.*/#include <vxWorks.h>#if defined (__OSPF_FTP__)/* Added change as per TMS PR # 1555 */#include <taskLib.h>#include <ftpLib.h>#include <ramDrv.h>#include <dosFsLib.h>#endif /*__OSPF_FTP__*/#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ */#include <sockLib.h>#if !defined(__OSPF_VIRTUAL_STACK__)extern void ospf_cfg (void);#endif /* __OSPF_VIRTUAL_STACK__ *//* externs */#if !defined (VIRTUAL_STACK)    IMPORT int	_protoSwIndex;    IMPORT struct protosw 	inetsw [IP_PROTO_NUM_MAX];    IMPORT u_char ip_protox[IPPROTO_MAX];#endif#if defined(VIRTUAL_STACK)    IMPORT int myStackNum;#endif#if defined (__OSPF_FTP__)#if defined (__FILE_SYSTEM__)    static bool initialize_file_system (void);    static BLK_DEV *pBlkDev;    static DOS_VOL_DESC *pVolDesc;#endif /* __FILE_SYSTEM__ */        static bool download_configuration_file (const char* p_configuration_file, const char* p_ftp_server_address, const char* p_directory, const char* p_user, const char* p_password);    static char configuration_data[OSPF_MAXIMUM_FILE_SIZE];#endif /*__OSPF_FTP__*/#if defined(__OSPF_MIB__)IMPORT STATUS ospfMapiInit( NVRAM_SAVE_FUNCPTR nvramSaveRtn,                            NVRAM_DELETE_FUNCPTR nvramDelRtn,                            NVRAM_RETRIEVE_FUNCPTR nvramRetrieveRtn                          );#if defined(__ENVOY_SNMP_API__)IMPORT STATUS ospfEnvoyInit( void );IMPORT STATUS ospfEnvoyWrnInit( void );#endif /* __ENVOY_SNMP_API__ */#endif /* __OSPF_MIB__ *//* globals */static SEM_ID  ospf_startup_sem_id; /* OSPF startup semaphore.  Used to synchronize                               * OSPF task startup                               */#if defined (__OSPF_FTP__)/******************************************************************************** open_configuration_file - open configuration file**/static bool open_configuration_file     (    const char* p_configuration_file,     const char* p_ftp_server_address,     const char* p_directory, const char* p_user,     const char* p_password    )    {#if defined (__FILE_SYSTEM__)    if (initialize_file_system ( ) == false)        {        TRACE (("Failed to initalize file system. \r\n"));        return (false);        }#endif    if (download_configuration_file (p_configuration_file, p_ftp_server_address, p_directory, p_user, p_password) == false)        {        TRACE (("Failed to download file. \r\n"));        return (false);        }        return (true);    }/******************************************************************************** close_configuration_file - close configuration file**/static void close_configuration_file ()    {#if defined (__FILE_SYSTEM__)        /*....*/#endif        return;    }/****************************************************************************/#if defined (__FILE_SYSTEM__)static bool initialize_file_system (void){    pBlkDev = ramDevCreate (        OSPF_RAMDRIVE_ADDRESS,          OSPF_RAMDRIVE_BYTES_PER_BLOCK,        OSPF_RAMDRIVE_BLOCK_PER_TRACK,        OSPF_RAMDRIVE_NUMBER_OF_BLOCKS,        OSPF_RAMDRIVE_BLOCK_OFFSET);        if (pBlkDev == NULL)                {                return (false);                }    pVolDesc = dosFsMkfs (OSPF_RAMDRIVE_VOLUME_NAME,pBlkDev);        if (pVolDesc == NULL)                {                return (false);                }        return (true);}#endif /* __FILE_SYSTEM__ *//******************************************************************************** download_configuration_file - download configuration file**/static bool download_configuration_file     (    const char* p_configuration_file,     const char* p_ftp_server_address,     const char* p_directory, const char* p_user,     const char* p_password    )    {    char relative_file_path[512];    char buf [512];    int ctrlSock;    int dataSock;    int nBytes;    int configuration_file;    STATUS status;    UINT offset;    configuration_file = 0;    nBytes = 0;    ctrlSock = 0;    dataSock = 0;    relative_file_path[0] = '\0';    offset = 0;    if ((p_configuration_file == NULL) || (p_ftp_server_address == NULL) )            {            return (false);            }    if (p_user == NULL)            {            p_user = "anonymous";            }    sprintf (relative_file_path, "%s/%s",        OSPF_RAMDRIVE_VOLUME_NAME, OSPF_CONFIGURATION_FILE_NAME);#if defined (__FILE_SYSTEM__)    configuration_file = creat (relative_file_path, 2);    if (configuration_file == ERROR)            {            return (false);            }#endif    if (ftpXfer ((char *)p_ftp_server_address, (char *)p_user, (char *)p_password,                 "", "RETR %s",(char *)p_directory,(char *)p_configuration_file,  &ctrlSock, &dataSock) == ERROR)        {        close (configuration_file);        return (false);        }    while ((nBytes = read (dataSock, buf, sizeof (buf))) > 0)        {#if defined (__FILE_SYSTEM__)        write (configuration_file, buf, sizeof (buf) );#else        memcpy (&configuration_data[offset], buf, nBytes);        offset += nBytes;#endif        }#if !defined (__FILE_SYSTEM__)        configuration_data[offset] = '\0';#endif    close (dataSock);    if (nBytes < 0)             /* read error? */        {        status = ERROR;        }    if (ftpReplyGet (ctrlSock, TRUE) != FTP_COMPLETE)        {        status = ERROR;        }    if (ftpCommand (ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE)        {        status = ERROR;        }    close (ctrlSock);#if defined (__FILE_SYSTEM__)    close (configuration_file);#endif    return (true);    }#endif /*__OSPF_FTP__*/  /****************************************************************************** ospf_init_stub - OSPF init stub routine** This routine is used by the OSPF .cdf file to pull ospf_systems into the load.** RETURNS: N/A*/void ospf_init_stub()    {    return;    }/******************************************************************************* ospf_1sec_timer_isr - watchdog timer ISR*   * This is a watchdog timer ISR. It gives the semaphore on which <tOspfTimer>* task is pended and restarts the watchdog.  This ISR runs every second. */  void ospf_1sec_timer_isr ()    {    /* restart the watchdog */    wdStart (        ospf.watchdog,         (sysClkRateGet ()),         (FUNCPTR) ospf_1sec_timer_isr,         0);    

⌨️ 快捷键说明

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