From 519342a06467033929d5ba8b69ee2bcc85a100b7 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Sat, 7 Nov 2020 21:58:21 +0100 Subject: [PATCH] Ticket refs #3707: bbf: XML generator generates two Device.Hosts. --- dmtree/tr181/device.c | 2 +- tools/generate_xml.sh | 28 +++++++++------------------- tools/generate_xml_bbf.sh | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/dmtree/tr181/device.c b/dmtree/tr181/device.c index 58cc6e35..75ac7039 100644 --- a/dmtree/tr181/device.c +++ b/dmtree/tr181/device.c @@ -104,7 +104,7 @@ DMOBJ tDeviceObj[] = { {"Firewall", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL, BBFDM_BOTH}, {"DNS", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH}, {"Users", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tUsersObj, tUsersParams, NULL, BBFDM_BOTH}, -{"IEEE1905", &DMREAD, NULL, NULL, "file:/etc/config/ieee1905,/etc/config/topology;ubus:ieee1905->info,topology->dump", NULL, NULL, NULL, NULL, tIEEE1905Obj , tIEEE1905Params, NULL, BBFDM_BOTH}, +{"IEEE1905", &DMREAD, NULL, NULL, "file:/etc/config/ieee1905,/etc/config/topology;ubus:ieee1905->info,topology->dump", NULL, NULL, NULL, NULL, tIEEE1905Obj, tIEEE1905Params, NULL, BBFDM_BOTH}, {"InterfaceStack", &DMREAD, NULL, NULL, "file:/etc/config/network", browseInterfaceStackInst, NULL, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH}, {"USB", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tUSBObj, tUSBParams, NULL, BBFDM_BOTH}, {"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh", NULL, NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH}, diff --git a/tools/generate_xml.sh b/tools/generate_xml.sh index ebf6e9ed..05d7616e 100755 --- a/tools/generate_xml.sh +++ b/tools/generate_xml.sh @@ -77,11 +77,7 @@ get_param_type(){ } get_leaf_obj_line_number(){ - if [ "$1" != "device.c" ]; then - echo `grep -nE DMOBJ\|DMLEAF $1 | grep -v UPNP |cut -f1 -d: | tr "\n" " "` - else - echo `grep -nE DMOBJ\|DMLEAF $1 |grep "181" |grep -v UPNP | cut -f1 -d: | tr "\n" " "` - fi + echo `grep -nE DMOBJ\|DMLEAF $1 | grep -v UPNP | cut -f1 -d: | tr "\n" " "` } add_item_to_list(){ @@ -143,10 +139,9 @@ gen_dm_tree(){ ######## Create Childs list while IFS=, read -r f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13; do - name=`echo ${f1//{} | sed 's/^"\(.*\)"$/\1/'` - permission=${f2// &} + name=`echo ${f1/CUSTOM_PREFIX/$CUSTOM_PREFIX} | sed 's/{//' | sed 's/"//g'` type=${f3// } - multiinstance=${f6// } + multiinstance=${f5// } if [ "$multiinstance" != "NULL" ]; then instance="true" else @@ -156,22 +151,16 @@ gen_dm_tree(){ name=`set_obj_object_child "$father_name" "$name"` oname=`set_obj_object_line $instance "$name"` echo "$oname," >> $TREE_TXT -# if [ "$instance" == "true" ]; then -# objinst=`set_obj_instance_line $name` -# echo $objinst >> $TREE_TXT -# fi - #tree=`add_item_to_list "$oname" "$tree"` fi if [ "$p_found" == "1" ]; then name=`set_obj_param_child "$father_name" "$name"` otype=`get_param_type $type` pname=`set_obj_param_line "$otype" "$name"` - #tree=`add_item_to_list "$pname" "$tree"` echo $pname >> $TREE_TXT fi if [ -n "$str" ]; then - child_objects=${f10// } - child_parameters=${f11// } + child_objects=${f9// } + child_parameters=${f10// } obj_name=${name} #Add the actual object to the list of objects looking for their children objects ######## if [ "$child_objects" != "NULL" ]; then @@ -184,7 +173,7 @@ gen_dm_tree(){ obj_look_param_child_list=`add_item_to_list "$new_item" "$obj_look_param_child_list"` fi fi - done <<<"`sed -n $line_number',/{0}/p' $file | sed -e '/{0}/d' | sed -e '/^{/!d'`" + done <<<"`sed -n $line_number',/{0}/p' $file | cut -d \" \" -f 1-4,6- | sed '/#ifdef GENERIC_OPENWRT/,/#else/d' | sed -e '/{0}/d' | sed -e '/^{/!d'`" ######### Remove object from list of object looking there childs for obj in $obj_look_obj_child_list; do @@ -322,9 +311,9 @@ OUT_STREAM="tmp.txt" ROOT_FILE="device.c" TREE_TXT=$CURRENT_PATH"/"$OUT_STREAM DM_PATH=${2:-"$(pwd)/../dmtree/"} -PRODUCT_CLASS=${3:-"DG301"} +PRODUCT_CLASS=${3:-"DG400PRIME"} DEVICE_PROTOCOL=${4:-"DEVICE_PROTOCOL_DSLFTR069v1"} -MODEL_NAME=${5:-"DG301-A"} +MODEL_NAME=${5:-"DG400PRIME-A"} SOFTWARE_VERSION=${6:-"1.2.3.4B"} cnt_obj=0 cnt_param=0 @@ -339,6 +328,7 @@ SCRIPTS_PATH_TR157=${DM_PATH}/${DM_TR157} DIR_LIST="$SCRIPTS_PATH_TR181 $SCRIPTS_PATH_TR104 $SCRIPTS_PATH_TR143 $SCRIPTS_PATH_TR157" XML_OUT_STREAM_BBF="iopsys.xml" ROOT_PATH="Device" +CUSTOM_PREFIX="X_IOPSYS_EU_" ############## GEN BBF Data Models TREE ############## echo "Start Generation of BBF Data Models..." diff --git a/tools/generate_xml_bbf.sh b/tools/generate_xml_bbf.sh index ee256e20..95004b4b 100755 --- a/tools/generate_xml_bbf.sh +++ b/tools/generate_xml_bbf.sh @@ -54,18 +54,19 @@ get_param_type(){ echo "int" ;; "DMT_HEXBIN" ) - echo "hexbin" + echo "hexBinary" ;; + "DMT_UNLONG" ) + echo "unsignedLong" + ;; + "DMT_BASE64" ) + echo "base64" + ;; esac - } get_leaf_obj_line_number(){ - if [ "$1" != "device.c" ]; then - echo `grep -nE DMOBJ\|DMLEAF $1 | grep -v UPNP |cut -f1 -d: | tr "\n" " "` - else - echo `grep -nE DMOBJ\|DMLEAF $1 |grep "181" |grep -v UPNP | cut -f1 -d: | tr "\n" " "` - fi + echo `grep -nE DMOBJ\|DMLEAF $1 | grep -v UPNP |cut -f1 -d: | tr "\n" " "` } add_item_to_list(){ @@ -182,7 +183,7 @@ gen_dm_tree(){ name=`echo ${f1//{} | sed 's/^"\(.*\)"$/\1/'` permission=${f2// &} type=${f3// } - browse=${f6// } + browse=${f5// } if [ "$permission" == "DMWRITE" ]; then instance="readWrite" @@ -190,7 +191,6 @@ gen_dm_tree(){ instance="readOnly" fi - if [ "$o_found" == "1" ]; then name=`set_obj_object_child "$father_name" "$name"` oname=`set_obj_object_line $instance "$name"` @@ -213,8 +213,8 @@ gen_dm_tree(){ fi if [ -n "$str" ]; then - child_objects=${f10// } - child_parameters=${f11// } + child_objects=${f9// } + child_parameters=${f10// } obj_name=${name} #Add the actual object to the list of objects looking for their children objects ######## if [ "$child_objects" != "NULL" ]; then @@ -228,7 +228,7 @@ gen_dm_tree(){ fi fi - done <<<"`sed -n $line_number',/{0}/p' $file | sed -e '/{0}/d' | sed -e '/^{/!d'`" + done <<<"`sed -n $line_number',/{0}/p' $file | cut -d \" \" -f 1-4,6- | sed '/#ifdef GENERIC_OPENWRT/,/#else/d' | sed -e '/{0}/d' | sed -e '/^{/!d'`" ######### Remove object from list of object looking there childs for obj in $obj_look_obj_child_list; do