13 Star 126 Fork 41

Neo-T / Open-NPStack

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
onps_entry.c 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Copyright 2022-2024 The Onps Project Author All Rights Reserved.
*
* Author:Neo-T
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* http://www.onps.org.cn/apache2.0.txt
*
*/
#define SYMBOL_GLOBALS
#include "onps.h"
#undef SYMBOL_GLOBALS
HMUTEX o_hMtxPrintf = INVALID_HMUTEX;
BOOL open_npstack_load(EN_ONPSERR *penErr)
{
//* lcp魔术字生成及tcp/udp端口号动态分配都需要随机数生成函数,所以协议栈启动时先设置个种子,确保栈每次启动时生成不同的随机数
srand(os_get_system_msecs());
do {
if (!buddy_init(penErr))
break;
if (!buf_list_init(penErr))
break;
#if SUPPORT_PRINTF && PRINTF_THREAD_MUTEX
o_hMtxPrintf = os_thread_mutex_init();
if (INVALID_HMUTEX == o_hMtxPrintf)
{
*penErr = ERRMUTEXINITFAILED;
break;
}
#endif
if (!one_shot_timer_init(penErr))
break;
if (!onps_input_init(penErr))
break;
if (!netif_init(penErr))
break;
if (!route_table_init(penErr))
break;
#if SUPPORT_PPP
if (!ppp_init(penErr))
break;
#endif
#if SUPPORT_ETHERNET
ethernet_init();
#endif
//* 启动协议栈
os_thread_onpstack_start(NULL);
return TRUE;
} while (FALSE);
netif_uninit();
onps_input_uninit();
if (INVALID_HMUTEX != o_hMtxPrintf)
os_thread_mutex_uninit(o_hMtxPrintf);
buf_list_uninit();
buddy_uninit();
one_shot_timer_uninit();
return FALSE;
}
void open_npstack_unload(void)
{
#if SUPPORT_PPP
ppp_uninit();
#endif
route_table_uninit();
netif_uninit();
one_shot_timer_uninit();
onps_input_uninit();
if (INVALID_HMUTEX != o_hMtxPrintf)
os_thread_mutex_uninit(o_hMtxPrintf);
buf_list_uninit();
buddy_uninit();
}
C/C++
1
https://gitee.com/Neo-T/open-npstack.git
git@gitee.com:Neo-T/open-npstack.git
Neo-T
open-npstack
Open-NPStack
master

搜索帮助