首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

vxworks 添加默认网关

vxworks 添加默认网关

Q: How can I get the default gateway from the bootline to be the default gateway?

A: Thanks to a suggestion by Michael Lawnick I pilfered some code from the bootConfig.c file and threw it into usrAppInit.c. This was to get the gateway from the bootline.... The system now works the way it should from the factory. Here is an excerpt of my code:

#include "VxWorks.h"
#include "bootLib.h"
#include "prjParams.h"

void usrAppInit (void)
{
BOOT_PARAMS params;

#ifdef USER_APPL_INIT
USER_APPL_INIT; /* for backwards compatibility */
#endif
/* add application specific code here */
bootStringToStruct (BOOT_LINE_ADRS, &params);
if ((sysNvRamGet (BOOT_LINE_ADRS, BOOT_LINE_SIZE, 0) == ERROR) ||
(*BOOT_LINE_ADRS == EOS))
{
/* either no non-volatile RAM or empty boot line */
printf("Adding hardwired gateway\n");
routeAdd ("0.0.0.0", "155.34.103.1");
}
else {
printf("Adding gateway %s from bootline\n", params.gad);
routeAdd("0.0.0.0", params.gad);
}
}
返回列表