一、背景描述

     某系列产品中,不同产品、国家和地区支持不同的配置项(但差异不大)。各配置项均由其BranchLeaf结点值(BLV)唯一标识。

     作为ONU通用配置媒介之一,某模块对各配置项创建合法性校验函数IsBranchLeafValid(…),其中包含的结点列表表示产品缺省支持的所有配置项,类似“白名单”;此外根据各国家地区的要求创建屏蔽函数IsBranchLeafScreened (…),其中包含的结点列表表示该国家/地区不予支持的配置项,类似“黑名单”。其中,“黑名单”列表为“白名单”列表的子集。两个名单结合起来对接收到的OLT配置帧进行校验,从而表现出不同的支持能力。

     因此,对于M个产品,N个国家地区,在物理上将需要M+N个黑白名单。具体实现上,黑白名单函数内充斥着大量if...else与switch...case结构:

 1 /* 每个产品对应一个Product_Adapter.c文件,内含IsBranchLeafValid实现 */
 2 BOOL IsBranchLeafValid(OAM_BRANCH_LEAF eBranchLeaf)
 3 {
 4     BOOLEAN retcode = 1;
 5     switch(eBranchLeaf)
 6     {
 7         case OnuSn:
 8         case FirmwareVer:
 9         case ChipsetID:
10         case EthDSRateLimit:
11         case QosConfig:
12         case FastLeaveState:
13         case FastLeaveCtrl:
14         case FaxModemConf:
15         case SIPDigitMap:
16         //Dozens of eBranchLeaf... ...
17         {
18             retcode = 1;
19         }
20             break;
21 
22         default:
23         {
24             retcode = 0;
25         }
26             break;
27     }
28 
29     return retcode;
30 }
31 
32 
33 BOOL IsBranchLeafScreened(INT32U dwdwdwRegionVer, OAM_BRANCH_LEAF eBranchLeaf)
34 {
35     if(dwdwRegionVer == DEFAULT_XINJIANG_CFG)
36     {
37         switch(eBranchLeaf)
38         {
39             case VlanConfig:
40                 
41             case FaxModemConf:
42             case SIPDigitMap:
43             //Dozens of eBranchLeaf... ...
44                 return 1;
45             default:
46                 return 0;
47         }
48     }
49     else if(dwdwRegionVer == DEFAULT_JIANGSU_CFG)
50     {
51        switch(eBranchLeaf)
52        {
53             case VlanConfig:
54               return 1;
55            default:
56               return 0;
57        }           
58     }
59     else
60     {
61         return 0;
62     }
63 }
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2021-07-13
  • 2021-11-05
猜你喜欢
  • 2021-05-05
  • 2022-01-04
  • 2021-06-05
  • 2021-04-15
  • 2021-04-26
  • 2021-09-21
相关资源
相似解决方案