Board logo

标题: vxworks 添加默认网关 [打印本页]

作者: samwalton    时间: 2014-3-26 15:08     标题: 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);
}
}




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0