Update bbf generator and json files

This commit is contained in:
Amin Ben Ramdhane 2020-09-03 13:31:30 +01:00
parent ef8e6c2000
commit 3a807945f9
9 changed files with 22766 additions and 631 deletions

View file

@ -280,7 +280,7 @@ static int get_rule_order(char *refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
/*#Device.Firewall.Chain.{i}.Rule.{i}.Alias!UCI:dmmap_firewall/rule,@i-1/user_alias*/
/*#Device.Firewall.Chain.{i}.Rule.{i}.Alias!UCI:dmmap_firewall/rule,@i-1/firewall_chain_rule_alias*/
static int get_rule_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section = NULL;
@ -292,7 +292,7 @@ static int get_rule_alias(char *refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
/*#Device.Firewall.Chain.{i}.Rule.{i}.Target!UCI:firewall/rule,@i-1/name*/
/*#Device.Firewall.Chain.{i}.Rule.{i}.Description!UCI:firewall/rule,@i-1/name*/
static int get_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "name", value);

View file

@ -13,7 +13,7 @@
/*************************************************************
* ENTRY METHOD
**************************************************************/
/*#Device.IEEE1905.AL.Interface.{i}.!UBUS:ieee1905/info/None,None/interfaces*/
/*#Device.IEEE1905.AL.Interface.{i}.!UBUS:ieee1905/interfaces//names*/
static int browseIEEE1905ALInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *result = NULL, *interfaces = NULL, *interface_id = NULL;
@ -45,7 +45,7 @@ static int browseIEEE1905ALInterfaceVendorPropertiesInst(struct dmctx *dmctx, DM
}
#endif
/*#Device.IEEE1905.AL.Interface.{i}.Link.{i}.!UBUS:ieee1905.al.Name/link_info/None,None/Links*/
/*#Device.IEEE1905.AL.Interface.{i}.Link.{i}.!UBUS:ieee1905.al.Name/link_info//Links*/
static int browseIEEE1905ALInterfaceLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res = NULL, *link_obj = NULL, *arrobj = NULL;
@ -536,7 +536,7 @@ static int set_IEEE1905ALForwardingTable_SetForwardingEnabled(char *refparam, st
return 0;
}
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRuleNumberOfEntries!UCI:ieee1905/forwarding_rule,None/forwarding_rule_nr*/
/*#Device.IEEE1905.AL.ForwardingTable.ForwardingRuleNumberOfEntries!UCI:ieee1905/forwarding_rule*/
static int get_IEEE1905ALForwardingTable_ForwardingRuleNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
@ -1239,7 +1239,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceLis
}
#endif
/*#Device.IEEE1905.AL.Security.SetupMethod!UCI:ieee1905/security,security/None*/
/*#Device.IEEE1905.AL.Security.SetupMethod!UCI:ieee1905/security,security/method*/
static int get_IEEE1905ALSecurity_SetupMethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("ieee1905", "security", "method", value);

View file

@ -404,6 +404,7 @@ int os_delObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char *inst
/*************************************************************
* GET & SET PARAM
*************************************************************/
/*#Device.QoS.ClassificationNumberOfEntries!UCI:qos/classify/*/
int os_get_QoS_ClassificationNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
@ -423,7 +424,6 @@ int os_get_QoS_MaxClassificationEntries(char *refparam, struct dmctx *ctx, void
return 0;
}
/*#Device.QoS.ClassificationNumberOfEntries!UCI:qos/classify,false/false*/
int os_get_QoS_ClassificationNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
@ -479,7 +479,7 @@ int os_get_QoS_MaxQueueEntries(char *refparam, struct dmctx *ctx, void *data, ch
}
#endif
/*#Device.QoS.QueueNumberOfEntries!UCI:qos/queue,false/false*/
/*#Device.QoS.QueueNumberOfEntries!UCI:qos/queue*/
int os_get_QoS_QueueNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;

View file

@ -1905,7 +1905,7 @@ static int set_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Alias!UCI:dmmap_wireless/wifi-iface,@i-1/accesspointalias*/
/*#Device.WiFi.AccessPoint.{i}.Alias!UCI:dmmap_wireless/wifi-iface,@i-1/ap_alias*/
static int get_access_point_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section = NULL;

View file

@ -45,33 +45,49 @@ def getprotocols( value ):
def check_obj(dmobject):
dmobject = dmobject.replace(".{i}.", ".")
count = dmobject.count('.')
obj = dmobject.split(".")
if dmobject.count('.') == 2:
if count == 2:
cmd = 'awk \'/DMOBJ tRoot_181_Obj/,/^{0}$/\' ../dmtree/tr181/device.c'
res = os.popen(cmd).read()
string = "\n{\"%s\"," % obj[1]
elif "Device.Services." in dmobject and count == 3:
cmd = 'awk \'/DMOBJ tServicesObj/,/^{0}$/\' ../dmtree/tr104/servicesvoiceservice.c'
res = os.popen(cmd).read()
string = "\n{\"%s\"," % obj[2]
elif "Device.Services." in dmobject and count == 4:
cmd = 'awk \'/DMOBJ tServicesVoiceServiceObj/,/^{0}$/\' ../dmtree/tr104/servicesvoiceservice.c'
res = os.popen(cmd).read()
string = "\n{\"%s\"," % obj[3]
elif "Device.Services." in dmobject and count >= 5:
array_name = ""
file = "../dmtree/tr104/servicesvoiceservice%s.c" % obj[3].lower()
if (os.path.isfile(file)):
for i in range(count-2):
array_name += obj[i+1]
cmd = 'awk \'/DMOBJ t%sObj/,/^{0}$/\' %s' % (array_name, file)
res = os.popen(cmd).read()
string = "\n{\"%s\"," % obj[count - 1]
else:
return "No"
else:
array_name = ""
if "Device.IP.Diagnostics." == dmobject:
file = "../dmtree/tr181/ip.c"
elif "Device.IP.Diagnostics." in dmobject:
file = "../dmtree/tr143/diagnostics.c"
elif "Device.Services." in dmobject:
file = "../dmtree/tr104/voice_services.c"
elif "Device.SoftwareModules." in dmobject:
file = "../dmtree/tr157/softwaremodules.c"
elif "Device.BulkData." in dmobject:
file = "../dmtree/tr157/bulkdata.c"
else:
file = "../dmtree/tr181/%s.c" % obj[1].lower()
if(os.path.isfile(file)):
count = dmobject.count('.')
obj1 = dmobject.split(".")
if (os.path.isfile(file)):
for i in range(count-2):
array_name += obj1[i+1]
array_name += obj[i+1]
cmd = 'awk \'/DMOBJ t%sObj/,/^{0}$/\' %s' % (array_name, file)
res = os.popen(cmd).read()
string = "\n{\"%s\"," % obj1[count - 1]
string = "\n{\"%s\"," % obj[count - 1]
else:
return "No"
@ -88,7 +104,7 @@ def check_param(param, res):
return "No"
def check_commands(param):
cmd = 'awk \'/static struct op_cmd operate_helper/,/^};$/\' ../dmoperate.c'
cmd = 'awk \'/static const struct op_cmd operate_helper/,/^};$/\' ../dmoperate.c'
res = os.popen(cmd).read()
param = param.replace(".{i}.", ".*.")
param = param.replace("()", "")
@ -99,18 +115,32 @@ def check_commands(param):
return "No"
def load_param(dmobject):
if dmobject.count('.') == 1:
dmobject = dmobject.replace(".{i}.", ".")
count = dmobject.count('.')
obj = dmobject.split(".")
if count == 1:
cmd = 'awk \'/DMLEAF tRoot_181_Params/,/^{0}$/\' ../dmtree/tr181/device.c'
res = os.popen(cmd).read()
elif "Device.Services." in dmobject and count == 3:
cmd = 'awk \'/DMLEAF tServicesVoiceServiceParams/,/^{0}$/\' ../dmtree/tr104/servicesvoiceservice.c'
res = os.popen(cmd).read()
elif "Device.Services." in dmobject and count >= 4:
array_name = ""
file = "../dmtree/tr104/servicesvoiceservice%s.c" % obj[3].lower()
if (os.path.isfile(file)):
for i in range(count-1):
array_name += obj[i+1]
cmd = 'awk \'/DMLEAF t%sParams/,/^{0}$/\' %s' % (array_name, file)
res = os.popen(cmd).read()
else:
res = ""
else:
array_name = ""
obj = dmobject.split(".")
if "Device.IP.Diagnostics." in dmobject:
file = "../dmtree/tr143/diagnostics.c"
elif "Device.Time." in dmobject:
file = "../dmtree/tr181/times.c"
elif "Device.Services." in dmobject:
file = "../dmtree/tr104/voice_services.c"
elif "Device.SoftwareModules." in dmobject:
file = "../dmtree/tr157/softwaremodules.c"
elif "Device.BulkData." in dmobject:
@ -118,11 +148,8 @@ def load_param(dmobject):
else:
file = "../dmtree/tr181/%s.c" % obj[1].lower()
if(os.path.isfile(file)):
dmobject = dmobject.replace(".{i}.", ".")
count = dmobject.count('.')
obj1 = dmobject.split(".")
for i in range(count-1):
array_name += obj1[i+1]
array_name += obj[i+1]
cmd = 'awk \'/DMLEAF t%sParams/,/^{0}$/\' %s' % (array_name, file)
res = os.popen(cmd).read()
else:

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -216,8 +216,8 @@ listmapping = []
def generatelistfromfile(dmobject):
obj = dmobject.get('name').split(".")
if "tr-104" in sys.argv[1]:
pathfilename = "../dmtree/tr104/voice_services.c"
pathiopsyswrtfilename = "../dmtree/tr104/voice_services-iopsyswrt.c"
pathfilename = "../dmtree/tr104/" + obj[1].lower() + ".c"
pathiopsyswrtfilename = "../dmtree/tr104/" + obj[1].lower() + "-iopsyswrt.c"
elif obj[1] == "SoftwareModules" or obj[1] == "BulkData" :
pathfilename = "../dmtree/tr157/" + obj[1].lower() + ".c"
pathiopsyswrtfilename = "../dmtree/tr157/" + obj[1].lower() + "-iopsyswrt.c"
@ -578,21 +578,17 @@ def printCOMMAND( dmparam, dmobject, bbfdm_type ):
fp.close()
def printusage():
if "tr-181" in sys.argv[1]:
print "Usage: " + sys.argv[0] + " <tr-181 cwmp xml data model> <tr-181 usp xml data model> [Object path]"
print "Examples:"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml tr-181-2-13-0-usp-full.xml Device."
print " ==> Generate the json file of the sub tree Device. in tr181.json"
else:
print "Usage: " + sys.argv[0] + " <xml data model> [Object path]"
print "Examples:"
print " - " + sys.argv[0] + " tr-104-1-1-0-full.xml VoiceService."
print " ==> Generate the json file of the sub tree VoiceService. in tr104.json"
print " - " + sys.argv[0] + " tr-106-1-2-0-full.xml Device."
print " ==> Generate the json file of the sub tree Device. in tr106.json"
print "Usage: " + sys.argv[0] + " <tr-xxx cwmp xml data model> <tr-xxx usp xml data model> [Object path]"
print "Examples:"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml tr-181-2-13-0-usp-full.xml Device."
print " ==> Generate the json file of the sub tree Device. in tr181.json"
print " - " + sys.argv[0] + " tr-104-2-0-2-cwmp-full.xml tr-104-2-0-2-usp-full.xml VoiceService."
print " ==> Generate the json file of the sub tree VoiceService. in tr104.json"
print " - " + sys.argv[0] + " tr-106-1-2-0-full.xml Device."
print " ==> Generate the json file of the sub tree Device. in tr106.json"
print ""
print "Example of xml data model file: https://www.broadband-forum.org/cwmp/tr-181-2-13-0-cwmp-full.xml"
exit(1)
def getobjectpointer( objname ):
obj = None
@ -658,7 +654,7 @@ def chech_obj_with_other_obj(obj, dmobject):
def object_parse_childs(dmobject, level, generatelist, check_obj):
if generatelist == 0 and (dmobject.get('name')).count(".") == 2:
generatelistfromfile(dmobject)
if check_obj == 1 and "tr-181" in sys.argv[1]:
if check_obj == 1 and ("tr-181" in sys.argv[1] or "tr-104" in sys.argv[1]):
obj, exist = check_if_obj_exist_in_other_xml_file(dmobject)
hasobj = objhaschild(dmobject.get('name'), level, check_obj)
@ -752,18 +748,11 @@ def generatejsonfromobj(pobj, pdir):
### main ###
if "tr-181" in sys.argv[1]:
if len(sys.argv) < 4:
printusage()
exit(1)
else:
if len(sys.argv) < 3:
printusage()
exit(1)
if len(sys.argv) < 4:
printusage()
if (sys.argv[1]).lower() == "-h" or (sys.argv[1]).lower() == "--help":
printusage()
exit(1)
is_service_model = 0
model_root_name = "Root"
@ -798,7 +787,7 @@ if dmroot1 == None:
print "Wrong %s XML Data model format!" % sys.argv[1]
exit(1)
if "tr-181" in sys.argv[1]:
if "tr-181" in sys.argv[1] or "tr-104" in sys.argv[1]:
tree2 = xml.parse(sys.argv[2])
xmlroot2 = tree2.getroot()
model2 = xmlroot2
@ -817,6 +806,13 @@ if "tr-181" in sys.argv[1]:
dmroot2 = c
break
#If it is service data model
if dmroot2 == None:
for c in model2:
if c.tag == "object" and c.get("name").count(".") == 2:
dmroot2 = c
break
if dmroot2 == None:
print "Wrong %s XML Data model format!" % sys.argv[2]
exit(1)
@ -830,12 +826,10 @@ elif "tr-106" in sys.argv[1]:
else:
gendir = "source_" + time.strftime("%Y-%m-%d_%H-%M-%S")
if "tr-181" in sys.argv[1]:
Root = sys.argv[3]
objstart = getobjectpointer(Root)
else:
Root = sys.argv[2]
objstart = getobjectpointer(Root)
Root = sys.argv[3]
objstart = getobjectpointer(Root)
if objstart == None:
print "Wrong Object Name! %s" % Root

File diff suppressed because it is too large Load diff