现在我修改了一个CLI指令,其主要分两步,先输入ip dhcp server pool XXX进入视图(这是与原本一致的),然后输入address XXX hardware-address XXX hardware-type ethernet on/off(必选) bind on/of note XXX,其中bind和note是可选的
这是我的CLI指令函数
STATUS cli_dhcpServerManualBindSetCpn(IN cli_env *pCliEnv, IN char *poolName,
IN char *ip, IN char *clientId, IN char *mac, IN int type, IN char *enable, IN char *bind, IN char *note)
{
DBG_ALZ("+++++++++++ENTER cli_dhcpServerManualBindSetCpn++++++++++");
int ret=0;
// MANUAL_BINDING manualBind = {};
OPTION optionList[DHCP_RESERV_OPT_NUM] = {0};
int optNum = 0;
int enableFlag = 0;
CFG_IMB_INST inst = {0};
mac = mac ? mac : "";
clientId = clientId ? clientId : "";
if(!ip||!poolName)
{
ret=ERR_BAD_PARAM;
goto done;
}
if(type==0)
{
type=ETHERNET_BIND;
}
else if(type==1)
{
type=IEEE802_BIND;
}
if (NULL != enable && 0 == strcmp(enable, "on"))
{
enableFlag = 1;
} else {
enableFlag = 0;
}
if (NULL != bind && 0 == strcmp(bind, "on")) {
safeStrncpy(inst.ipaddr, ip, sizeof(inst.ipaddr));
safeStrncpy(inst.enable, "on", sizeof(inst.enable));
safeStrncpy(inst.mac, mac, sizeof(inst.mac));
safeStrncpy(inst.zone, poolName, sizeof(inst.zone));
safeStrncpy(inst.bind, "0", sizeof(inst.bind));
APPL_IF_ERR_DONE(ret, dmCfgIMBInstAddSet(&inst, NULL));
}
ret= uiDhcpServerManualBindSetWithOption(poolName, ip, clientId, mac, type, optionList, optNum, note, enableFlag);
done:
if(ret!=ERR_NO_ERROR)
{
cliPrintErrStr(pCliEnv,ret);
}
return ret;
}
现在我需要对他做配置收集,这是原本CLI指令的配置收集
int uiDhcpServerCollectCb(TPCONFIG_COLLECTFUN_INPUT_T *pInput)
{
DEBUG_DHCPS("region[%d]\r\n", pInput->regionId);
// 此为GLOBAL的配置收集回调函数,此处pInput->regionId 为 COLLECT_REGION_ID_E里的GLOBAL
char *pStr = NULL;
char ipStr[IP_ADDRESS_LENGTH] = {0};
char maskStr[IP_ADDRESS_LENGTH] = {0};
char parseKey[DHCP_SERVER_CONFIGDB_KEY_LEN_MAX] = {0};
DHCP_SERVER_POOL poolParam = {};
char outBuf[DHCPS_MAX_CLI_STR_LEN] = {0}; // 后面的outBuf是否会将已经赋值给Sds的历史值给覆盖掉?????
UINT32 defPingPktNum = 0;
UINT32 defPingTimeout = 0;
UINT32 defLease = 0;
APPL_IF_ERR_RET(uilibDhcpServerDefPingPacketNumGet(&defPingPktNum));
APPL_IF_ERR_RET(uilibDhcpServerDefPingTimeoutGet(&defPingTimeout));
APPL_IF_ERR_RET(uilibDhcpServerDefLeaseGet(&defLease));
// pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]:pool
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL])
{
DEBUG_DHCPS("collect DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL");
DHCPS_GLOBAL_CONFIG conf = {};
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL]);
TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL])
{
if (PFM_ERR_C_OK == tpConfig_IterGetNumU8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL], &conf.dhcpsEnable, pKey, UC_DS_ENABLE))
{
memset(outBuf, 0, sizeof(outBuf));
if (conf.dhcpsEnable)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "service dhcp server");
}
else if (pInput->uShowAllCliMode)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "no service dhcp server");
}
DEBUG_DHCPS("collect [%s]\r\n", outBuf);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL], &conf.extOption.acAddr.s_addr, pKey, UC_DS_CAP_WAP_IP))
{
DEBUG_DHCPS("get_obj acAddr[%s]\r\n", inet_htoa(conf.extOption.acAddr));
memset(outBuf, 0, sizeof(outBuf));
if (conf.extOption.acAddr.s_addr != 0 && OK == Ipv4Int2Str(conf.extOption.acAddr.s_addr, ipStr))
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server extend-option capwap-ac-ip %s", ipStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
else if (conf.extOption.acAddr.s_addr == 0 && pInput->uShowAllCliMode)
{
// DEBUG_DHCPS("get_obj acAddr[%s]\r\n", inet_htoa(conf.extOption.acAddr));
memset(outBuf, 0, sizeof(outBuf));
if (conf.extOption.acAddr.s_addr != 0 && OK == Ipv4Int2Str(conf.extOption.acAddr.s_addr, ipStr))
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server extend-option capwap-ac-ip %s", ipStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
}
// snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "network %s ", ipStr);
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL], &pStr, pKey, UC_DS_VENDER_CLASEE))
{
DEBUG_DHCPS("get_obj vendor class[%s]\r\n", pStr);
memset(outBuf, 0, sizeof(outBuf));
if (pStr && strlen(pStr) > 0)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server extend-option vendor-class-id \"%s\"", pStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
else if (pInput->uShowAllCliMode)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server extend-option vendor-class-id \"\"");
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL], &conf.pingConfig.pingPktNum, pKey, UC_DS_PING_PACKET_NUM))
{
DEBUG_DHCPS("get_obj ping pkt num[%d]\r\n", conf.pingConfig.pingPktNum);
memset(outBuf, 0, sizeof(outBuf));
if (conf.pingConfig.pingPktNum != defPingPktNum)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server ping packets %d", conf.pingConfig.pingPktNum);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
else if (pInput->uShowAllCliMode)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server ping packets %d", conf.pingConfig.pingPktNum);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_GLOBAL], &conf.pingConfig.pingTimeout, pKey, UC_DS_PING_PACKET_TIMEOUT))
{
DEBUG_DHCPS("get_obj ping pkt timeout[%d]\r\n", conf.pingConfig.pingTimeout);
memset(outBuf, 0, sizeof(outBuf));
if (conf.pingConfig.pingTimeout != defPingTimeout)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server ping timeout %d", conf.pingConfig.pingTimeout);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
else if (pInput->uShowAllCliMode)
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server ping timeout %d", conf.pingConfig.pingTimeout);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
}
}
}
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_EXIP])
{
DEBUG_DHCPS("collect DHCP_SERVER_GLOBAL_AREA_TBL_EXIP");
char endIpStr[IP_ADDRESS_LENGTH] = {};
char startIpStr[IP_ADDRESS_LENGTH] = {};
DHCPS_EXCLUDE_IP exIp = {};
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_EXIP])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_EXIP]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
if (3 == sscanf(pKey, UC_DS_EXIP_TBL_FMT, &exIp.exStartIp.s_addr, &exIp.exEndIp.s_addr, exIp.vrfName))
{
Ipv4Int2Str(exIp.exStartIp.s_addr, startIpStr);
Ipv4Int2Str(exIp.exEndIp.s_addr, endIpStr);
if (!VRF_IS_DEFAULT(exIp.vrfName))
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server excluded-address %s %s %s", startIpStr, endIpStr, exIp.vrfName);
}
else
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server excluded-address %s %s", startIpStr, endIpStr);
}
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
}
}
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
/* 此处pIter[0]对应的是tpConfig_colletFunReg注册时,ADD KEY的表顺序,如果只有1个表为0,如果有多个,需要模块自己维护顺序
迭代器取数据是不可逆的,循环一次后,再次使用迭代器进行循环就会失败,所以可以一次把数据全部取出,然后再进行字段的判断,如果想
重新初始化迭代器,请使用Rewind初始化后,可以再次从迭代器头开始循环 */
DEBUG_DHCPS("collect DHCP_SERVER_GLOBAL_AREA_TBL_POOL");
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]) // 如果模块在这个区域只有一个表,不用使用TPCONFIG_ITER_KEY
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
DEBUG_DHCPS("pKey %s", pKey);
sscanf(pKey, UC_DS_POOL_TBL_FMT, poolParam.name);
memset(outBuf, 0, sizeof(outBuf));
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "ip dhcp server pool \"%s\"", poolParam.name);
DEBUG_DHCPS("collect [%s]\r\n", outBuf);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL])
{
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &pStr, pKey, UC_DS_POOL_TBL_name))
{
strncpy(poolParam.name, pStr, DHCPS_POOLNAME_LEN);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &poolParam.ip.s_addr, pKey, UC_DS_POOL_TBL_ip))
{
DEBUG_DHCPS("get_obj ip[%s]\r\n", inet_htoa(poolParam.ip));
// snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "network %s ", ipStr);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &poolParam.mask.s_addr, pKey, UC_DS_POOL_TBL_mask))
{
DEBUG_DHCPS("get_obj mask[%s]\r\n", inet_htoa(poolParam.mask));
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &pStr, pKey, UC_DS_POOL_TBL_vrfName))
{
strncpy(poolParam.vrfName, pStr, sizeof(poolParam.vrfName));
DEBUG_DHCPS("get_obj vrfName[%s]\r\n", poolParam.vrfName);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], (UINT32 *)&poolParam.lease, pKey, UC_DS_POOL_TBL_lease))
{
DEBUG_DHCPS("get_obj lease[%d]\r\n", poolParam.lease);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], (UINT32 *)&poolParam.nextServer.s_addr, pKey, UC_DS_POOL_TBL_nextserver))
{
DEBUG_DHCPS("get_obj nextServer[%s]\r\n", inet_htoa(poolParam.nextServer));
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], (UINT32 *)&poolParam.controllerIp.s_addr, pKey, UC_DS_POOL_TBL_ctrlip))
{
DEBUG_DHCPS("get_obj controllerIp[%s]\r\n", inet_htoa(poolParam.controllerIp));
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &pStr, pKey, UC_DS_POOL_TBL_dname))
{
strncpy(poolParam.domainName, pStr, sizeof(poolParam.domainName));
DEBUG_DHCPS("get_obj domainName[%s]\r\n", poolParam.domainName);
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], &pStr, pKey, UC_DS_POOL_TBL_bfile))
{
strncpy(poolParam.bootFileName, pStr, sizeof(poolParam.bootFileName));
DEBUG_DHCPS("get_obj bootFileName[%s]\r\n", poolParam.bootFileName);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_POOL], (UINT8 *)&poolParam.netBiosNodeType, pKey, UC_DS_POOL_TBL_nbtype))
{
DEBUG_DHCPS("get_obj netBiosNodeType[%d]\r\n", poolParam.netBiosNodeType);
}
}
// 网段地址
if (poolParam.ip.s_addr != 0 && poolParam.mask.s_addr != 0)
{
if (OK != Ipv4Int2Str(poolParam.ip.s_addr, ipStr))
{
return ERROR;
}
if (OK != Ipv4Int2Str(poolParam.mask.s_addr, maskStr))
{
return ERROR;
}
memset(outBuf, 0, sizeof(outBuf));
if (DHCP_SERVER_VRF_IS_DEFUALT(poolParam.vrfName))
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "network %s %s", ipStr, maskStr);
}
else
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "network %s %s %s", ipStr, maskStr, poolParam.vrfName);
}
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (poolParam.lease != defLease || pInput->uShowAllCliMode)
{
memset(outBuf, 0, sizeof(outBuf));
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "lease %ld", poolParam.lease);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (poolParam.nextServer.s_addr != 0 || pInput->uShowAllCliMode)
{
memset(outBuf, 0, sizeof(outBuf));
memset(ipStr, 0, sizeof(ipStr));
Ipv4Int2Str(poolParam.nextServer.s_addr, ipStr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "next-server %s ", ipStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (poolParam.controllerIp.s_addr != 0 || pInput->uShowAllCliMode)
{
memset(outBuf, 0, sizeof(outBuf));
memset(ipStr, 0, sizeof(ipStr));
Ipv4Int2Str(poolParam.controllerIp.s_addr, ipStr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "controller-ip %s ", ipStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (strlen(poolParam.domainName) != 0 || pInput->uShowAllCliMode)
{
memset(outBuf, 0, sizeof(outBuf));
DEBUG_DHCPS("get_obj domainName[%s]\r\n", poolParam.domainName);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "domain-name \"%s\" ", poolParam.domainName);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (strlen(poolParam.bootFileName) != 0 || pInput->uShowAllCliMode)
{
memset(outBuf, 0, sizeof(outBuf));
DEBUG_DHCPS("get_obj bootFileName[%s]\r\n", poolParam.bootFileName);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "bootfile \"%s\" ", poolParam.bootFileName);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (poolParam.netBiosNodeType != 0)
{
memset(outBuf, 0, sizeof(outBuf));
DEBUG_DHCPS("get_obj netBiosNodeType[%d]\r\n", poolParam.netBiosNodeType);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "netbios-node-type ");
if (NBN_SERVER_NODE_TYPE_B == poolParam.netBiosNodeType)
{
strcat(outBuf, "b-node");
}
else if (NBN_SERVER_NODE_TYPE_P == poolParam.netBiosNodeType)
{
strcat(outBuf, "p-node");
}
else if (NBN_SERVER_NODE_TYPE_M == poolParam.netBiosNodeType)
{
strcat(outBuf, "m-node");
}
else if (NBN_SERVER_NODE_TYPE_H == poolParam.netBiosNodeType)
{
strcat(outBuf, "h-node");
}
outBuf[strlen(outBuf)] = '\0';
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (!DHCP_SERVER_VRF_IS_DEFUALT(poolParam.vrfName))
{
memset(outBuf, 0, sizeof(outBuf));
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "vrf %s ", poolParam.vrfName);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
int section = 0;
UINT32 startIp = 0;;
UINT32 endIp = 0;
char poolName[DHCPS_POOLNAME_LEN + 1] = {0};
char startIpStr[IP_ADDRESS_LENGTH] = {0};
char endIpStr[IP_ADDRESS_LENGTH] = {0};
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DHCPS_ADDRESS_RANGE_TBL_FMT, poolName, §ion));
if (strncmp(poolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's range.");
continue;
}
TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE])
{
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE], &startIp, pKey, UC_DHCPS_ADDRESS_RANGE_STARTIP))
{
DEBUG_DHCPS("get_startIp[%d]", startIp);
continue;
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE], &endIp, pKey, UC_DHCPS_ADDRESS_RANGE_ENDIP))
{
DEBUG_DHCPS("get endIp[%d]", endIp);
continue;
}
}
memset(outBuf, 0, sizeof(outBuf));
memset(startIpStr, 0, sizeof(startIpStr));
memset(endIpStr, 0, sizeof(endIpStr));
Ipv4Int2Str(startIp, startIpStr);
Ipv4Int2Str(endIp, endIpStr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "range %d %s %s", section, startIpStr, endIpStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_RANGE]);
}
// 静态绑定
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
UINT32 bindIp = 0;
MANUAL_BINDING bind = {};
char bindPoolName[DHCPS_POOLNAME_LEN] = {};
char ipStr[IP_ADDRESS_LENGTH] = {'\0'};
// char macAddr[MAC_ADDRESS_LENGTH + 6] = {'\0'};
char address[] = COLLECT_STR_MANUAL_ADDRESS;
char hardwareAddress[] = COLLECT_STR_MANUAL_HARDWARE_ADDRESS;
char typeEthernet[] = COLLECT_STR_MANUAL_TYPEETHERNET;
char typeIeee802[] = COLLECT_STR_MANUAL_TYPEIEEE;
char clientIdentifier[] = COLLECT_STR_MANUAL_CLIENT;
char ascii[] = COLLECT_STR_MANUAL_ASCII;
char tailstr[MAXOPT * 2 + 128 + 1] = {'\0'};
char tmpstr[MAXOPT * 2 + 128 + 1] = {'\0'};
INT8 num = 0;
// int subindex = 0;
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
// sscanf(pKey,UC_DS_MANUAL_BIND_ENTRY_FMT,bindPoolName,&bindIp);
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DS_MANUAL_BIND_ENTRY_FMT, bindPoolName, &bindIp));
if (strncmp(bindPoolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's manual bind.");
continue;
}
TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND])
{
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &pStr, pKey, UC_DS_MANUAL_BIND_POOL))
{
strncpy(bind.poolName, pStr, DHCPS_POOLNAME_LEN);
DEBUG_DHCPS("get_obj poolname[%s]\r\n", pStr);
}
if (PFM_ERR_C_OK == tpConfig_IterGetNumU32(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &bind.ip.s_addr, pKey, UC_DS_MANUAL_BIND_IP))
{
DEBUG_DHCPS("get_obj ip[%s]\r\n", inet_htoa(bind.ip));
}
// if (PFM_ERR_C_OK == tpConfig_IterGetNumI8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], (INT8*)&bind.bindType, pKey, UC_DS_MANUAL_BIND_BINDTYPE))
if (PFM_ERR_C_OK == tpConfig_IterGetNumI8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], (INT8 *)&num, pKey, UC_DS_MANUAL_BIND_BINDTYPE))
{
bind.bindType = num;
DEBUG_DHCPS("get_obj bindType[%d]\r\n", bind.bindType);
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &pStr, pKey, UC_DS_MANUAL_BIND_CLIENT_ID_STR))
{
strncpy(bind.cidStr, pStr, DHCPS_CID_STR_LEN_MAX);
DEBUG_DHCPS("get_obj cidStr[%s]\r\n", pStr);
}
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND], &pStr, pKey, UC_DS_MANUAL_BIND_MAC))
{
strncpy(bind.macStr, pStr, MAC_ADDRESS_LENGTH);
DEBUG_DHCPS("get_obj macStr[%s]\r\n", pStr);
}
}
if (ETHERNET_BIND == bind.bindType || IEEE802_BIND == bind.bindType)
{
memset(ipStr, 0, sizeof(ipStr));
memset(outBuf, 0, sizeof(outBuf));
Ipv4Int2Str(bind.ip.s_addr, ipStr);
DEBUG_DHCPS("mac address:%s.", bind.macStr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "%s %s %s %s %s", address, ipStr, hardwareAddress, bind.macStr,
(ETHERNET_BIND == bind.bindType) ? typeEthernet : typeIeee802);
}
else if (CLIENT_ID_ASCII == bind.bindType)
{
memset(ipStr, 0, sizeof(ipStr));
memset(outBuf, 0, sizeof(outBuf));
Ipv4Int2Str(bind.ip.s_addr, ipStr);
dhcpClientIdStrGetCLI(bind.cidStr, tmpstr, tailstr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "%s %s %s \"%s", address, ipStr, clientIdentifier, tmpstr);
if (0 != strlen(tailstr))
{
DEBUG_DHCPS("client id to be continued...");
strcat(outBuf, tailstr);
}
strcat(outBuf, "\"");
strcat(outBuf, " ");
strcat(outBuf, ascii);
}
else if (CLIENT_ID_HEX == bind.bindType)
{
memset(ipStr, 0, sizeof(ipStr));
memset(outBuf, 0, sizeof(outBuf));
Ipv4Int2Str(bind.ip.s_addr, ipStr);
dhcpClientIdStrGetCLI(bind.cidStr, tmpstr, tailstr);
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "%s %s %s \"%s", address, ipStr, clientIdentifier, tmpstr);
if (0 != strlen(tailstr))
{
DEBUG_DHCPS("client id to be continued...");
strcat(outBuf, tailstr);
}
strcat(outBuf, "\"");
strcat(outBuf, " ");
}
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_MANUALBIND]);
}
// nbs
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_NBS]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
int first = 1;
char nbsPoolName[DHCPS_POOLNAME_LEN + 1] = {};
UINT32 nbs = 0;
char ipStr[IP_ADDRESS_LENGTH] = {};
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_NBS])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_NBS]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
// sscanf(pKey,UC_DHCPS_DNS_TBL_FMT,nbsPoolName,&nbs);
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DHCPS_DNS_TBL_FMT, nbsPoolName, &nbs));
if (strncmp(nbsPoolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's nbs.");
continue;
}
if (nbs != 0)
{
if (first == 0)
{
strcat(outBuf, ",");
}
else
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "netbios-name-server ");
first = 0;
}
memset(ipStr, 0, sizeof(ipStr));
if (OK != Ipv4Int2Str(nbs, ipStr))
{
return ERROR;
}
strcat(outBuf, ipStr);
}
}
/* 遍历完全部条目一次打印 */
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_NBS]);
}
// dns
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DNS]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
int first = 1;
char dnsPoolName[DHCPS_POOLNAME_LEN + 1] = {};
UINT32 dns = 0;
char ipStr[IP_ADDRESS_LENGTH] = {};
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DNS])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DNS]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DHCPS_DNS_TBL_FMT, dnsPoolName, &dns));
if (strncmp(dnsPoolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's dns.");
continue;
}
if (dns != 0)
{
if (first == 0)
{
strcat(outBuf, ",");
}
else
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "dns-server ");
first = 0;
}
memset(ipStr, 0, sizeof(ipStr));
if (OK != Ipv4Int2Str(dns, ipStr))
{
return ERROR;
}
strcat(outBuf, ipStr);
}
}
/* 遍历完全部的条目一次打印 */
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DNS]);
}
// default gateway
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DFTGATEWAY]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
int first = 1;
char gatewayPoolName[DHCPS_POOLNAME_LEN + 1] = {};
UINT32 dftGateway = 0;
char ipStr[IP_ADDRESS_LENGTH] = {};
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DFTGATEWAY])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DFTGATEWAY]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
// sscanf(pKey,UC_DHCPS_DNS_TBL_FMT,gatewayPoolName,&dftGateway);
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DHCPS_DNS_TBL_FMT, gatewayPoolName, &dftGateway));
if (strncmp(gatewayPoolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's default-gateway.");
continue;
}
if (dftGateway != 0)
{
if (first == 0)
{
strcat(outBuf, ",");
}
else
{
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "default-gateway ");
first = 0;
}
memset(ipStr, 0, sizeof(ipStr));
if (OK != Ipv4Int2Str(dftGateway, ipStr))
{
return ERROR;
}
strcat(outBuf, ipStr);
}
}
/* 遍历完全部的gateway后一次打印全部gateway */
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_DFTGATEWAY]);
}
// option的收集
if (NULL != pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION]) // 如果KEY在DB里是没有数据的,此处迭代器会为NULL,需要判断一下
{
const char *optionTypeStr[3] = {"HEX", "STRING", "IP"}; // 根据枚举类型的顺序
// char opValStr[DHCPS_MAX_OPTION_ASCII_LEN * 2 + 1] = {0};
char optionPoolName[DHCPS_POOLNAME_LEN] = {};
OPTION option = {};
memset(outBuf, 0, sizeof(outBuf));
TPCONFIG_ITER_KEY(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION])
{
char *pKey = NULL;
pKey = tpConfig_getKeyName(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION]);
if (!pKey)
{
DEBUG_DHCPS("!pKey");
continue;
}
strncpy(parseKey, pKey, sizeof(parseKey) - 1);
// sscanf(pKey,UC_DS_POOL_OPTION_TBL_FMT,optionPoolName,&option.code);
APPL_IF_ERR_RET(dhcpPoolAboutKeyNameParse(parseKey, UC_DS_POOL_OPTION_TBL_FMT, optionPoolName, &option.code));
if (strncmp(optionPoolName, poolParam.name, DHCPS_POOLNAME_LEN) != 0)
{
DEBUG_DHCPS("not this pool 's option.");
continue;
}
TPCONFIG_ITER_FV(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION])
{
if (PFM_ERR_C_OK == tpConfig_IterGetStrPtr(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION], &pStr, pKey, UC_DS_POOL_OPTION_VAL))
{
DEBUG_DHCPS("get_obj option-val[%s]", pStr);
strncpy(option.valStr, pStr, DHCP_OPTION_STR_MAX_LEN);
}
else if (PFM_ERR_C_OK == tpConfig_IterGetNumU8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION], (UINT8 *)&option.code, pKey, UC_DS_POOL_OPTION_CODE))
{
DEBUG_DHCPS("get_obj code[%d]", option.code);
}
else if (PFM_ERR_C_OK == tpConfig_IterGetNumU8(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION], (UINT8 *)&option.type, pKey, UC_DS_POOL_OPTION_TYPE))
{
DEBUG_DHCPS("get_obj type[%d]", option.type);
}
}
if (option.code == 0 || option.code == 138)
{
// 遵从老代码的处理,?
continue;
}
// 开始组装命令
memset(outBuf, 0, sizeof(outBuf));
snprintf(outBuf, DHCPS_MAX_CLI_STR_LEN, "option %d %s \"%s\" ", option.code, optionTypeStr[option.type - 1], option.valStr);
tpConfig_outputToSdsForCli(GLOBAL, 0, outBuf, TPCONFIG_HEADSPACE_YES); /* 如果区域内部没有区分区域的,直接使用0 */
}
tpConfig_objIterRewind(pInput->pIter[DHCP_SERVER_GLOBAL_AREA_TBL_OPTION]);
}
tpConfig_outputToSdsForCli(GLOBAL, 0, "#", TPCONFIG_HEADSPACE_YES);
DEBUG_DHCPS("########");
}
}
return ERR_NO_ERROR;
}
/* 配置收集各个key的注册;该函数在platform阶段注册 */
int cli_dhcp_server_collect_reg()
{
int ret = 0;
/* 配置收集注册,每个key都需要注册 */
// ret=uiDhcpServerCollectReg();
return ret;
}
#endif
这是现在可参考的配置收集函数,我需要完成一个这样的配置收集函数
static int lanInterfaceBridgeCfgCollect(TPSTATE_NETIF_ST* netIfEntry, void* param)
{
int ret = ERR_NO_ERROR;
int subIfIndex = 0;
GATEWAY_IF_TYPE subIfType;
char cliCmd[TPCONFIGCPN_CLI_CMD_LEN + 1] = {0};
CFG_ZONE_INST **zoneCfg = NULL;
char vlanStr[VLAN_MAX_LENGTH] = {};
IF_ADDR allIp[NETIF_MAX_IPV4_ADDR_NUM] = {};
int ipCount = 0;
char maskStr[IP_ADDRESS_MAX_LENGTH] = {"unassigned"};
char ipStr[IP_ADDRESS_MAX_LENGTH] = {};
int ifIndex = 0;
IGMP_INTF_CONFIG_T igmpIntfCfg = {0};
APPL_ENSURE_RET_VAL(netIfEntry, ERR_BAD_PARAM);
APPL_ENSURE_RET_VAL(param, ERR_BAD_PARAM);
APPL_ENSURE_RET_VAL((netIfEntry->netIfId.ifType == NETIF_TYPE_GWVIRT), ERR_NO_ERROR);
if (netIfEntry->netIfId.ifType == NETIF_TYPE_GWVIRT) {
netIfGwVirtDataParse(netIfEntry->netIfId.ifData.data, &subIfIndex, &subIfType);
if (GATEWAY_TYPE_BRIDGE != subIfType) {
return ERR_NO_ERROR;
}
}
TPCONFIG_COLLECTFUN_INPUT_T *pInput = (TPCONFIG_COLLECTFUN_INPUT_T *)param;
char isolation[10];
char allowinternet[10];
if (((netIfEntry->isolation >> 0) & 0x3) == 2) {
strcpy(isolation, "on");
} else {
strcpy(isolation, "off");
}
if (((netIfEntry->isolation >> 2) & 0x3) == 1){
strcpy(allowinternet, "on");
} else {
strcpy(allowinternet, "off");
}
tpConfig_outputToSdsForCli(pInput->regionId, 0, "#", TPCONFIG_HEADSPACE_NO);
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "interface bridge %d", subIfIndex);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_NO));
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "description %s", netIfEntry->description);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
APPL_IF_ERR_DONE(ret, dmCfgZoneInstGetLstByField(CFG_ZONE_INST_F_IFNAME, netIfEntry->kernelName, &zoneCfg));
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "zonename %s", zoneCfg[0]->zoneName);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
uilibNetIfVlanBitmapToString(netIfEntry->vlanListBitMap, vlanStr, NULL);
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "vlans %s", vlanStr);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
libNetIfIndexGet(netIfEntry->netIfId, &ifIndex);
ret = libNetIfIpv4AllIpGet(LIB_NETIF_GETMODE_TPSTATE, ifIndex, allIp, &ipCount);
if (ERR_NO_ERROR != ret)
{
goto done;
}
else
{
inet_ntop(AF_INET, &(V4_ADDR(allIp[0])), ipStr, IP_ADDRESS_MAX_LENGTH);
ret = libNetIfMaskLenToStr(V4_SUBNET(allIp[0]), IP_ADDRESS_MAX_LENGTH, maskStr);
}
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "ip address %s %s", ipStr, maskStr);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
ret = uiIgmpIntfCfgGet(netIfEntry->netIfId, &igmpIntfCfg);
if (ret == ERR_NO_ERROR) {
if(IGMP_NOT_CONFIGURED != igmpIntfCfg.adminMode)
{
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, sizeof(cliCmd), "ip igmp");
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
}
}
if(IGMP_NOT_CONFIGURED != igmpIntfCfg.MrouteProxyType)
{
char proxyIntfType[GL_BUFLEN_64] = {};
char proxyIntfName[GL_BUFLEN_64] = {};
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
uiMrouteGetIntfNameSplit(igmpIntfCfg.MrouteProxyType, igmpIntfCfg.MrouteProxyData,
proxyIntfType, proxyIntfName, GL_BUFLEN_64);
snprintf(cliCmd, sizeof(cliCmd), "ip igmp mroute-proxy %s %s", proxyIntfType, proxyIntfName);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
}
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "isolation %s", isolation);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "allowinternet %s", allowinternet);
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_YES));
memset(cliCmd, 0, TPCONFIGCPN_CLI_CMD_LEN);
snprintf(cliCmd, TPCONFIGCPN_CLI_CMD_LEN, "#");
PFM_IF_FAIL_DONE(ret, tpConfig_outputToSdsForCli(pInput->regionId, 0, cliCmd, TPCONFIG_HEADSPACE_NO));
done:
dmCfgZoneInstListFree(zoneCfg);
return ERR_NO_ERROR;
}
最新发布