diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b21754f76b503f09bce85563a467512f5be86ee..ab33f40acb30f1ebfc742c66f98a731854a7b1e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ variables: run_unit_test: stage: unit_test image: iopsys/code-analysis-dev:latest - allow_failure: true + allow_failure: false script: - "./gitlab-ci/install-dependencies.sh" - "./gitlab-ci/setup.sh" @@ -30,7 +30,7 @@ run_unit_test: run_functional_test: stage: functional_test image: iopsys/code-analysis-dev:latest - allow_failure: true + allow_failure: false script: - "./gitlab-ci/install-dependencies.sh" - "./gitlab-ci/setup.sh" @@ -49,7 +49,7 @@ run_functional_test: run_api_test: stage: api_test image: iopsys/code-analysis-dev:latest - allow_failure: true + allow_failure: false script: - "./gitlab-ci/install-dependencies.sh" - "./gitlab-ci/setup.sh" diff --git a/README.md b/README.md index f286b70ff154b30f85d97e0bc06e8ce3561ae83a..333589170198be52e522163eeb728cf0927ee36e 100644 --- a/README.md +++ b/README.md @@ -570,37 +570,60 @@ API to list all operate command objects ````bash root@iopsys:~# ubus call usp list_operate { - "parameters": [ - { - "parameter": "Device.DHCPv4.Client.{i}.Renew()", - "type": "sync" - }, - { - "parameter": "Device.DNS.Diagnostics.NSLookupDiagnostics()", - "type": "async" - }, - { - { - "parameter": "Device.IP.Diagnostics.IPPing()", - "type": "async" - }, - { - "parameter": "Device.IP.Diagnostics.TraceRoute()", - "type": "async" - }, - { - "parameter": "Device.IP.Diagnostics.UDPEchoDiagnostics()", - "type": "async" - }, - { - "parameter": "Device.IP.Interface.{i}.Reset()", - "type": "sync" - }, - { - "parameter": "Device.Reboot()", - "type": "sync" - }, - { + "parameters": [ + { + "parameter": "Device.DHCPv4.Client.{i}.Renew()", + "type": "sync" + }, + { + "parameter": "Device.DNS.Diagnostics.NSLookupDiagnostics()", + "type": "async", + "in": [ + "HostName", + "Interface", + "DNSServer", + "Timeout", + "NumberOfRepetitions" + ], + "out": [ + "Status", + "AnswerType", + "HostNameReturned", + "IPAddresses", + "DNSServerIP", + "ResponseTime" + ] + }, + { + "parameter": "Device.DeviceInfo.FirmwareImage.{i}.Activate()", + "type": "async" + }, + { + "parameter": "Device.IP.Diagnostics.IPPing()", + "type": "async", + "in": [ + "Interface", + "ProtocolVersion", + "Host", + "NumberOfRepetitions", + "Timeout", + "DataBlockSize", + "DSCP" + ], + "out": [ + "Status", + "IPAddressUsed", + "SuccessCount", + "FailureCount", + "AverageResponseTime", + "MinimumResponseTime", + "MaximumResponseTime", + "AverageResponseTimeDetailed", + "MinimumResponseTimeDetailed", + "MaximumResponseTimeDetailed" + ] + }, + { ```` #### Dump schema diff --git a/docs/api/usp.md b/docs/api/usp.md index 7d3ee813833a350599b22637360351af440cae76..9f560748642b206ad9f395a67a440b08fdcaa7a2 100644 --- a/docs/api/usp.md +++ b/docs/api/usp.md @@ -130,7 +130,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp add_object {"path":"Device.DsgM.ztUYhyhhdc.TjT.QVpdEpNoiIL.8.edaaNoS.UM.xdQAENoz.rH.","proto":"cwmp"} +ubus call usp add_object {"path":"Device.oPukAG.mK.xujHy.0.TdY.LoKAFb.sbpgb.tfiQumMYzv.I.WzWXtO.Xs","proto":"usp"} ``` ### JSONRPC Example @@ -144,7 +144,7 @@ ubus call usp add_object {"path":"Device.DsgM.ztUYhyhhdc.TjT.QVpdEpNoiIL.8.edaaN "<SID>", "usp", "add_object", - { "path": "Device.DsgM.ztUYhyhhdc.TjT.QVpdEpNoiIL.8.edaaNoS.UM.xdQAENoz.rH.", "proto": "cwmp" } + { "path": "Device.oPukAG.mK.xujHy.0.TdY.LoKAFb.sbpgb.tfiQumMYzv.I.WzWXtO.Xs", "proto": "usp" } ] } ``` @@ -207,7 +207,7 @@ ubus call usp add_object {"path":"Device.DsgM.ztUYhyhhdc.TjT.QVpdEpNoiIL.8.edaaN ### Output Example ```json -{ "status": false, "instance": 22685966, "fault": 9027 } +{ "status": true, "instance": 63157939, "fault": 9008 } ``` ## del_object @@ -326,7 +326,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp del_object {"path":"Device.QSapjKLxqBa.*uBviMOaLWqv.i.kHWvyVRF.PTEy.AYlIGAtfk.yyQkP.","proto":"both"} +ubus call usp del_object {"path":"Device.8.cx.ea.NnXymncQH.SNt.hEijAmaqk.HjPsE.wRkz.iSnDOHvi.DxMd.","proto":"both"} ``` ### JSONRPC Example @@ -340,7 +340,7 @@ ubus call usp del_object {"path":"Device.QSapjKLxqBa.*uBviMOaLWqv.i.kHWvyVRF.PTE "<SID>", "usp", "del_object", - { "path": "Device.QSapjKLxqBa.*uBviMOaLWqv.i.kHWvyVRF.PTEy.AYlIGAtfk.yyQkP.", "proto": "both" } + { "path": "Device.8.cx.ea.NnXymncQH.SNt.hEijAmaqk.HjPsE.wRkz.iSnDOHvi.DxMd.", "proto": "both" } ] } ``` @@ -389,7 +389,7 @@ ubus call usp del_object {"path":"Device.QSapjKLxqBa.*uBviMOaLWqv.i.kHWvyVRF.PTE ### Output Example ```json -{ "status": true, "fault": 9019 } +{ "status": false, "fault": 9004 } ``` ## dump_schema @@ -520,14 +520,9 @@ All instances must conform to this regular expression (test examples [here](<htt { "parameters": [ { - "parameter": "Device.HGlGamI.Z.nAVvF.aTimYiGlzgS.{i}.CfAjmMiT.lnlc.{i}.hdRGZUs", + "parameter": "Device.gqhI.LUZSe.uxRwqfvMNmN.d.r.qeJnUpDlU.RKibpaNwT.IIEacNUdN.", "writable": "1", - "type": "xsd:dateTime" - }, - { - "parameter": "Device.bOIkZws.UJNHXVogaQq.xdZcAmBuL.J.HvKTOakG.FgDqzqHqUA.asCo.", - "writable": "0", - "type": "xsd:boolean" + "type": "xsd:string" } ] } @@ -649,7 +644,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp get {"path":"Device.NSih.UWOKI.EqcYyM.WztCcfYuS.DawOma.AyMDfqvCebp.ek.Lmyr.fr","proto":"usp"} +ubus call usp get {"path":"Device.h.i.EFqzBiaaf.WNBCnC.CD.AHPKqRvtrKD.MpqF.tP.SoyHuGybvz.hW","proto":"cwmp"} ``` ### JSONRPC Example @@ -663,7 +658,7 @@ ubus call usp get {"path":"Device.NSih.UWOKI.EqcYyM.WztCcfYuS.DawOma.AyMDfqvCebp "<SID>", "usp", "get", - { "path": "Device.NSih.UWOKI.EqcYyM.WztCcfYuS.DawOma.AyMDfqvCebp.ek.Lmyr.fr", "proto": "usp" } + { "path": "Device.h.i.EFqzBiaaf.WNBCnC.CD.AHPKqRvtrKD.MpqF.tP.SoyHuGybvz.hW", "proto": "cwmp" } ] } ``` @@ -834,7 +829,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp getm_attributes {"paths":["Device.AiEpIlr.liuccmnAP.qaaBzSZmy.QWacO.tJnTuBk.TWDMhy.hJCA.wiN","Device.yBiROCwkp.xXSp.RwJyL.QBfrCTg.NcSCtdosN.bGJL.VwbOoIiZt.f.3","Device.gZSjZwDLUVF.2.IWdgAhdYD.wGSQ.upSowlLDquA.HGJEJ.OvxSQIV.tO"],"proto":"both","next-level":true} +ubus call usp getm_attributes {"paths":["Device.JuH.cq.b.NqXoeifZks.bevfK.K.GK.PK.Ai","Device.kdFYRYqCgx.bT.uVfj.ykJH.b.MFfMrRC.kgTFsaxDGP.wIWjWqJh.WsY"],"proto":"cwmp","next-level":false} ``` ### JSONRPC Example @@ -850,12 +845,11 @@ ubus call usp getm_attributes {"paths":["Device.AiEpIlr.liuccmnAP.qaaBzSZmy.QWac "getm_attributes", { "paths": [ - "Device.AiEpIlr.liuccmnAP.qaaBzSZmy.QWacO.tJnTuBk.TWDMhy.hJCA.wiN", - "Device.yBiROCwkp.xXSp.RwJyL.QBfrCTg.NcSCtdosN.bGJL.VwbOoIiZt.f.3", - "Device.gZSjZwDLUVF.2.IWdgAhdYD.wGSQ.upSowlLDquA.HGJEJ.OvxSQIV.tO" + "Device.JuH.cq.b.NqXoeifZks.bevfK.K.GK.PK.Ai", + "Device.kdFYRYqCgx.bT.uVfj.ykJH.b.MFfMrRC.kgTFsaxDGP.wIWjWqJh.WsY" ], - "proto": "both", - "next-level": true + "proto": "cwmp", + "next-level": false } ] } @@ -994,7 +988,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp getm_names {"paths":["Device.Fn.ujXmqwHz.QGMz.JIwtNbKyZ.Y.WPNbIGh.kHuBpsgN.bwFZ.OSdEIE","Device.D.JcvooAldw.nLKzvbncMM.EvpivzoPIa.EtIfbirOZ.0.oldtaNC.LPq","Device.SvW.vBdbYearT.U.JaSpb.ZD.hoQIgPT.mBqk.XS.RUd.IEnTQHnmu.Bt","Device.KhVFWk.ZIHKJzqJIS.R.HHUxAmdj"],"proto":"usp","next-level":true} +ubus call usp getm_names {"paths":["Device.OVBCZYv.JgJjVJ.NKhZAWY.EdpWmD.symj.gxvkE.zhHdtI.fx.lgSoAE","Device.yWYJ.fLaqmgPV.2.AkNuvLgrXr.sV.dFXczMCIlHu.kep.liyKGwvFsco","Device.JyxO.LFPHrOAuW.FmByk.ga.dAATZgRhd.hgiHwtnaece.u.vkG"],"proto":"both","next-level":true} ``` ### JSONRPC Example @@ -1010,12 +1004,11 @@ ubus call usp getm_names {"paths":["Device.Fn.ujXmqwHz.QGMz.JIwtNbKyZ.Y.WPNbIGh. "getm_names", { "paths": [ - "Device.Fn.ujXmqwHz.QGMz.JIwtNbKyZ.Y.WPNbIGh.kHuBpsgN.bwFZ.OSdEIE", - "Device.D.JcvooAldw.nLKzvbncMM.EvpivzoPIa.EtIfbirOZ.0.oldtaNC.LPq", - "Device.SvW.vBdbYearT.U.JaSpb.ZD.hoQIgPT.mBqk.XS.RUd.IEnTQHnmu.Bt", - "Device.KhVFWk.ZIHKJzqJIS.R.HHUxAmdj" + "Device.OVBCZYv.JgJjVJ.NKhZAWY.EdpWmD.symj.gxvkE.zhHdtI.fx.lgSoAE", + "Device.yWYJ.fLaqmgPV.2.AkNuvLgrXr.sV.dFXczMCIlHu.kep.liyKGwvFsco", + "Device.JyxO.LFPHrOAuW.FmByk.ga.dAATZgRhd.hgiHwtnaece.u.vkG" ], - "proto": "usp", + "proto": "both", "next-level": true } ] @@ -1141,7 +1134,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp getm_values {"paths":["Device.CumEGUhww.DOzotuHhwr.B.mx.MXYv.WxcOushDGxt.YypSnSvV.RByvd","Device.yTVC.OscFMpGS.liCYl.XPULRSUAn.nJPFELNZWwd.HblTVFBpo.UhbTk"],"proto":"usp"} +ubus call usp getm_values {"paths":["Device.TGX.G.YDt","Device.VyzTtP"],"proto":"cwmp"} ``` ### JSONRPC Example @@ -1151,18 +1144,7 @@ ubus call usp getm_values {"paths":["Device.CumEGUhww.DOzotuHhwr.B.mx.MXYv.WxcOu "jsonrpc": "2.0", "id": 0, "method": "call", - "params": [ - "<SID>", - "usp", - "getm_values", - { - "paths": [ - "Device.CumEGUhww.DOzotuHhwr.B.mx.MXYv.WxcOushDGxt.YypSnSvV.RByvd", - "Device.yTVC.OscFMpGS.liCYl.XPULRSUAn.nJPFELNZWwd.HblTVFBpo.UhbTk" - ], - "proto": "usp" - } - ] + "params": ["<SID>", "usp", "getm_values", { "paths": ["Device.TGX.G.YDt", "Device.VyzTtP"], "proto": "cwmp" }] } ``` @@ -1313,7 +1295,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp instances {"path":"Device.PjUFBBz.eLYbwfiDII.fZpOLCqyL.qOM.lqLLOdCR.IG.owfMvj.E.qm.","proto":"usp"} +ubus call usp instances {"path":"Device.n","proto":"cwmp"} ``` ### JSONRPC Example @@ -1323,12 +1305,7 @@ ubus call usp instances {"path":"Device.PjUFBBz.eLYbwfiDII.fZpOLCqyL.qOM.lqLLOdC "jsonrpc": "2.0", "id": 0, "method": "call", - "params": [ - "<SID>", - "usp", - "instances", - { "path": "Device.PjUFBBz.eLYbwfiDII.fZpOLCqyL.qOM.lqLLOdCR.IG.owfMvj.E.qm.", "proto": "usp" } - ] + "params": ["<SID>", "usp", "instances", { "path": "Device.n", "proto": "cwmp" }] } ``` @@ -1390,9 +1367,10 @@ Device\.(([a-zA-Z]+\.)*(\d\.)?)*[a-zA-Z]*.\d ```json { "parameters": [ - { "parameter": "Device.fvaOy.u.UqljGFDHhC.g.xUPFbBSm.LGZHWTZEPyi.JmU.MkhSBKG.6.P" }, - { "parameter": "Device.wcACQRfEuUI.hykNcwR.zeQf.FGriFe.elSUte.ImJB.mwDcIBo.8.LpD" }, - { "parameter": "Device.iasqFP.OikUCP.y.xCXkcmC.jU.xS.krTqXR.UPtsk.ewTfl.4.GDylra" } + { "parameter": "Device.xqfWfE.3.DmHfrIybyz.gRZqozTko.cUxmKfvjZ.QJpTQfVC.MXJ.Sjsv" }, + { "parameter": "Device.JhxgoYNPGQu.rErr.laLs.7.vmrtib.9.WAVKz.II.GQGVBDVY.XYH.gF" }, + { "parameter": "Device.sIGkybebP.Hc.I.Lpm.IGvUpOAmO.sSQfiYuk.iyVtqfe.k.zgEmexyD." }, + { "parameter": "Device.rJlCKTm.wnTdWvxV.xnwlvvvO.O.CjZXT.4.uOu.Q.Dpn.JhLfcLn.MwQ" } ] } ``` @@ -1443,10 +1421,38 @@ Array type: `object[]` All items must be of the type: `object` with following properties: -| Property | Type | Required | -| ----------- | ------ | -------- | -| `parameter` | string | Optional | -| `type` | string | Optional | +| Property | Type | Required | +| ----------- | ------ | ------------ | +| `in` | array | Optional | +| `out` | array | Optional | +| `parameter` | string | **Required** | +| `type` | string | **Required** | + +#### in + +`in` + +- is optional +- type: `string[]` + +##### in Type + +Array type: `string[]` + +All items must be of the type: `string` + +#### out + +`out` + +- is optional +- type: `string[]` + +##### out Type + +Array type: `string[]` + +All items must be of the type: `string` #### parameter @@ -1454,7 +1460,7 @@ Datamodel object schema path `parameter` -- is optional +- is **required** - type: reference ##### parameter Type @@ -1487,7 +1493,7 @@ Device.FactoryReset() `type` -- is optional +- is **required** - type: reference ##### type Type @@ -1506,10 +1512,12 @@ All instances must conform to this regular expression (test examples ```json { "parameters": [ - { "parameter": "Device.nBahQKD.stPJDFWz.LFe.DWb.mEeLQwqVQnA.wUmRVOK.kAKKexy.aL.O", "type": "sync" }, - { "parameter": "Device.IMUmevE.FRxsjyvzmsa.VSQ.f.dljQzMR.lX.HfINtXQ.JaKMCPJF.OmP", "type": "sync" }, - { "parameter": "Device.wajwEwPdqWP.jqSUUsIgYfN.ud.ioKMDDlNdm.GeQWeEw.WvtprhdAAj.", "type": "sync" }, - { "parameter": "Device.yVQ.cRHNLWa.sdft.YHPyGjD.bhZGtnf.diVLQZje.sLcwaHjPLE.ZdSS", "type": "sync" } + { + "parameter": "Device.sgaBDwus.tjArIVd.YfNmYprMg.kBtMMZfKI.zoP.QamG.z.MA.{i}.n.", + "type": "async", + "in": ["Duis irure", "cillum Ut nulla", "est culpa sed", "Duis", "magna Duis"], + "out": ["exercitation quis in ut tempor"] + } ] } ``` @@ -1630,7 +1638,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp object_names {"path":"Device.HuUE.ChYKWJu.wUOTFflJJfn.zNQPtPPe.CjdJF.[]IRfr.QoNFdthHec","proto":"usp"} +ubus call usp object_names {"path":"Device.aTbCTOjEZ.MEMtMduhV.hVbOSjzGEV","proto":"both"} ``` ### JSONRPC Example @@ -1640,12 +1648,7 @@ ubus call usp object_names {"path":"Device.HuUE.ChYKWJu.wUOTFflJJfn.zNQPtPPe.Cjd "jsonrpc": "2.0", "id": 0, "method": "call", - "params": [ - "<SID>", - "usp", - "object_names", - { "path": "Device.HuUE.ChYKWJu.wUOTFflJJfn.zNQPtPPe.CjdJF.[]IRfr.QoNFdthHec", "proto": "usp" } - ] + "params": ["<SID>", "usp", "object_names", { "path": "Device.aTbCTOjEZ.MEMtMduhV.hVbOSjzGEV", "proto": "both" }] } ``` @@ -1733,11 +1736,9 @@ Device.WiFi. ```json { "parameters": [ - { "parameter": "Device.dke" }, - { "parameter": "Device.LN.XjbZN.qhOEeLgs.L.2.eMSsFL.H.yIYRdPgEHig.myVHbE.WAsVNOT" }, - { "parameter": "Device.n.9.zjLkb" }, - { "parameter": "Device.KwFINz.tDyP.mOqR.lG.hCrHVNgsaTx.x.HrmFYHQri.axMH.xKzfdDRV" }, - { "parameter": "Device.bTYdEmH.zsdkFzRJ.9.j.CabW.niiUQnq.XzgvXskd.qBFk.GWRuh.EY." } + { "parameter": "Device.qhuCY.lgvsGCobuk.Et.9.jhRbDirVzA.FfmgKXuD.sRTXVYP.QnxJ.cB" }, + { "parameter": "Device.kALlek.DkZwJLCp.kpxDv.PrAxesp.GtuywIxHU.fZIiGByc.hfNf.jEy" }, + { "parameter": "Device.atyLC.mmhVySRq.MDqkIs.el" } ] } ``` @@ -1911,7 +1912,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp operate {"path":"Device.Qk.uVSLam.jh.*MV.ia.hO.uqqPutPLJGK.EvZMZF.ikAzjTRjBo.LPag","action":"CxkekDIiWrP()","proto":"both","input":{}} +ubus call usp operate {"path":"Device.upFMrBYO.KQHCv.0.wLNbkrngZp","action":"yvVWI()","proto":"both","input":{}} ``` ### JSONRPC Example @@ -1925,12 +1926,7 @@ ubus call usp operate {"path":"Device.Qk.uVSLam.jh.*MV.ia.hO.uqqPutPLJGK.EvZMZF. "<SID>", "usp", "operate", - { - "path": "Device.Qk.uVSLam.jh.*MV.ia.hO.uqqPutPLJGK.EvZMZF.ikAzjTRjBo.LPag", - "action": "CxkekDIiWrP()", - "proto": "both", - "input": {} - } + { "path": "Device.upFMrBYO.KQHCv.0.wLNbkrngZp", "action": "yvVWI()", "proto": "both", "input": {} } ] } ``` @@ -2164,7 +2160,7 @@ To set multiple values at once, path should be relative to object elements ### Ubus CLI Example ``` -ubus call usp set {"path":"Device.evgUSLoVDUJ.RcwPl.UtkgybTLhmh.8.jc.etSMVerJkjq.drJhKXhEuK","value":"g","proto":"usp","values":{}} +ubus call usp set {"path":"Device.Zei.RXbdZV.B.VeWpshhl.ZguWyauH.JBL.[O&3]ugHLxwx.ZG.tZpT.d","value":"eiInrou","proto":"both","values":{}} ``` ### JSONRPC Example @@ -2179,9 +2175,9 @@ ubus call usp set {"path":"Device.evgUSLoVDUJ.RcwPl.UtkgybTLhmh.8.jc.etSMVerJkjq "usp", "set", { - "path": "Device.evgUSLoVDUJ.RcwPl.UtkgybTLhmh.8.jc.etSMVerJkjq.drJhKXhEuK", - "value": "g", - "proto": "usp", + "path": "Device.Zei.RXbdZV.B.VeWpshhl.ZguWyauH.JBL.[O&3]ugHLxwx.ZG.tZpT.d", + "value": "eiInrou", + "proto": "both", "values": {} } ] @@ -2299,10 +2295,10 @@ Device.WiFi. ```json { "parameters": [ - { "path": "Device.eYBoKFBl.oFeXCjIzaFw.Cpg.VpzWTP.ahTtT.9.SPLrq.ZbZvJtbHxR.", "status": true, "fault": 9005 }, - { "path": "Device.rjRKoodjsX.YyJ.xTXAakxU.gpWoocoATIe.usabcg.jidupL", "status": true, "fault": 9032 }, - { "path": "Device.ReoQHekkN.ZPzghZGpc.MAVwCMWNr.cY.BGKPbxIV.FMnmLUT.eqjYSEL", "status": false, "fault": 9015 }, - { "path": "Device.GbNCngTQu.xLioi.MeqQs.hTEBCktw.7.YCjiLvpa.2.plSqp.GJKt.WH", "status": true, "fault": 9005 } + { "path": "Device.A.bHbxr.QiNVvxJrF.UpuABcLH.baPPI.vMdFgmv.jTegiK.kCTb.bQoY", "status": true, "fault": 9018 }, + { "path": "Device.NlNboVxF.HTKTrbIdDTa.UJbEakIkurh.GQTkSXAkMZa.qCHmFpI.bVQn", "status": true, "fault": 9030 }, + { "path": "Device.FSPlvuonvq.KuHsv.X.6.zLhUzInG.dIMiW.voGmgGmgVI.pYiJspEI.C", "status": false, "fault": 9025 }, + { "path": "Device.6.KWeLlmj", "status": true, "fault": 9027 } ] } ``` @@ -2465,7 +2461,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp setm_attributes {"paths":[{"path":"Device.hoTPjeT.Ok.eOnK.CpFNboDaYpl.g.bVVOxrE.nZNomIUNs.4.gzwYHz.","notify-type":"6","notify":"0"},{"path":"Device.pl.sERCIzBPHm.IdIMawM.","notify-type":"6","notify":"1"},{"path":"Device.Ghso.aNPam.VTEJlH.dXOANMlTqIz.LBKnuYWBaT.Lwn.HTveOGaFKGq.","notify-type":"6","notify":"0"},{"path":"Device.mx.ujMHxQr.lAGUYUhg.aMRXsAzRGL.xU.XBJcR.mRq.4.a.YKXqPMD.C","notify-type":"6","notify":"0"},{"path":"Device.ZQsXR.eISncCCb.mB.BOOGMifU.IJCb.GEQFxoFpq.oqKad.N.yXjWGC.","notify-type":"0","notify":"1"}],"proto":"usp"} +ubus call usp setm_attributes {"paths":[{"path":"Device.fgmT.vGPKc.ehbgSxI.RVMLISbARvi.bhl.elF.CNip.eev.lnMzoLIp.","notify-type":"5","notify":"1"},{"path":"Device.BFNBuiE.tvEyLwMnQ.MHZfJSLb.Mjutri.aufifgfzq.0.rYQFk.C.loa","notify-type":"3","notify":"0"}],"proto":"cwmp"} ``` ### JSONRPC Example @@ -2482,28 +2478,17 @@ ubus call usp setm_attributes {"paths":[{"path":"Device.hoTPjeT.Ok.eOnK.CpFNboDa { "paths": [ { - "path": "Device.hoTPjeT.Ok.eOnK.CpFNboDaYpl.g.bVVOxrE.nZNomIUNs.4.gzwYHz.", - "notify-type": "6", - "notify": "0" - }, - { "path": "Device.pl.sERCIzBPHm.IdIMawM.", "notify-type": "6", "notify": "1" }, - { - "path": "Device.Ghso.aNPam.VTEJlH.dXOANMlTqIz.LBKnuYWBaT.Lwn.HTveOGaFKGq.", - "notify-type": "6", - "notify": "0" + "path": "Device.fgmT.vGPKc.ehbgSxI.RVMLISbARvi.bhl.elF.CNip.eev.lnMzoLIp.", + "notify-type": "5", + "notify": "1" }, { - "path": "Device.mx.ujMHxQr.lAGUYUhg.aMRXsAzRGL.xU.XBJcR.mRq.4.a.YKXqPMD.C", - "notify-type": "6", + "path": "Device.BFNBuiE.tvEyLwMnQ.MHZfJSLb.Mjutri.aufifgfzq.0.rYQFk.C.loa", + "notify-type": "3", "notify": "0" - }, - { - "path": "Device.ZQsXR.eISncCCb.mB.BOOGMifU.IJCb.GEQFxoFpq.oqKad.N.yXjWGC.", - "notify-type": "0", - "notify": "1" } ], - "proto": "usp" + "proto": "cwmp" } ] } @@ -2593,8 +2578,8 @@ Device.WiFi. ```json { "parameters": [ - { "path": "Device.LFZQURxG" }, - { "path": "Device.QRemVQxXht.EXQfVOqqiqG.bKkKa.ggngBgUV.mtvtvFljU.UUMfBpthR" } + { "path": "Device.MCPrG.diHnoyMcPn.c.SDULZye.TIOzwaVNElZ.fLhS.HLdPtI.GOuOxg" }, + { "path": "Device.HZWXfhMsO.VFRHzePh.jvEUfh.qrAhVVNff.DyjEp.Ap.BaD.4.SWTW" } ] } ``` diff --git a/docs/api/usp.raw.md b/docs/api/usp.raw.md index fa2609e208bc731ce02d85ecc88d9bccd9f063fa..9045034fd304a698c52bb582a738c56936bc9615 100644 --- a/docs/api/usp.raw.md +++ b/docs/api/usp.raw.md @@ -131,7 +131,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw add_object {"path":"Device.oCXif.ep.KKMmNUYdKON.KQD.fGzw.dMrOjI.Mzce.FRKb.JIaisF.WgX","proto":"usp"} +ubus call usp.raw add_object {"path":"Device.IFp.xCudF.xhXMPLfBq.9.kNfQOXSLIDr.TKMoDekznf.c.feTIZuyAl.","proto":"both"} ``` ### JSONRPC Example @@ -145,7 +145,7 @@ ubus call usp.raw add_object {"path":"Device.oCXif.ep.KKMmNUYdKON.KQD.fGzw.dMrOj "<SID>", "usp.raw", "add_object", - { "path": "Device.oCXif.ep.KKMmNUYdKON.KQD.fGzw.dMrOjI.Mzce.FRKb.JIaisF.WgX", "proto": "usp" } + { "path": "Device.IFp.xCudF.xhXMPLfBq.9.kNfQOXSLIDr.TKMoDekznf.c.feTIZuyAl.", "proto": "both" } ] } ``` @@ -208,7 +208,7 @@ ubus call usp.raw add_object {"path":"Device.oCXif.ep.KKMmNUYdKON.KQD.fGzw.dMrOj ### Output Example ```json -{ "status": false, "instance": 64849768, "fault": 8185 } +{ "status": false, "instance": 641154, "fault": 7641 } ``` ## del_object @@ -327,7 +327,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw del_object {"path":"Device.p.MADSlZyfNP.zND.yddMqWCvdqS.KRUDjgbQXT.kTU.CCsluZqBLdF.o","proto":"cwmp"} +ubus call usp.raw del_object {"path":"Device.MNHcbK.wNnVCIhIS.nwj.PSIDND.Rj.ES.Uc.zekyf.xfvfcNYcYYx.Ev","proto":"usp"} ``` ### JSONRPC Example @@ -341,7 +341,7 @@ ubus call usp.raw del_object {"path":"Device.p.MADSlZyfNP.zND.yddMqWCvdqS.KRUDjg "<SID>", "usp.raw", "del_object", - { "path": "Device.p.MADSlZyfNP.zND.yddMqWCvdqS.KRUDjgbQXT.kTU.CCsluZqBLdF.o", "proto": "cwmp" } + { "path": "Device.MNHcbK.wNnVCIhIS.nwj.PSIDND.Rj.ES.Uc.zekyf.xfvfcNYcYYx.Ev", "proto": "usp" } ] } ``` @@ -390,7 +390,7 @@ ubus call usp.raw del_object {"path":"Device.p.MADSlZyfNP.zND.yddMqWCvdqS.KRUDjg ### Output Example ```json -{ "status": false, "fault": 7374 } +{ "status": true, "fault": 7752 } ``` ## dump_schema @@ -520,26 +520,20 @@ All instances must conform to this regular expression (test examples [here](<htt ```json { "parameters": [ - { "parameter": "Device.kkGtpzq", "writable": "1", "type": "xsd:dateTime" }, { - "parameter": "Device.l.eencF.r.pTLOxxFWk.iVEpILL.XKnIp.ZDWSPAKR.Izvj.gQawp.ETL", - "writable": "1", - "type": "xsd:string" - }, - { - "parameter": "Device.ifwG.lemoGoTdxU.bgBC.LjQ.bhQPMyaDd.jVxfOeIFtra.DFKujllg.j", - "writable": "1", - "type": "xsd:string" + "parameter": "Device.AXf.Vie.DyAT.Ctao.yMDOBHWVyb.IR.dRkoc.OdN.i.AMWLxbjdSQ.X.", + "writable": "0", + "type": "xsd:unsignedLong" }, { - "parameter": "Device.Ix.LpbvAKwg.WQbPdxbJGRV.XokL.FujHHIXC.i.PBGPHnHInJB.RgKBj", + "parameter": "Device.bSuaisGY.PZWNThw.iKgi.nGsHB.mfVlMFmCK.DD.PnGbdso.QwuCSKCE", "writable": "0", - "type": "xsd:unsignedLong" + "type": "xsd:unsignedInt" }, { - "parameter": "Device.ieztRklueM.NvmUt.{i}.phjBs.rhioikGB.{i}.JGzPgMaVbL.rdbREI", + "parameter": "Device.clIpJ.lbRVFYnEWm.Xx.ZskGRSZbOZ.sqrCGnv.FYLjuQJjP.diAIj.vB", "writable": "0", - "type": "xsd:long" + "type": "xsd:string" } ] } @@ -661,7 +655,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw get {"path":"Device.PMcczcQ.lwgBoKtYme.euHbqTcgTI","proto":"both"} +ubus call usp.raw get {"path":"Device.VgpyBJaVYmU.JZZCB.mSsqbWsNTX.OMneW.CFZeyXmGE.AikN.q.cHUDp","proto":"usp"} ``` ### JSONRPC Example @@ -671,7 +665,12 @@ ubus call usp.raw get {"path":"Device.PMcczcQ.lwgBoKtYme.euHbqTcgTI","proto":"bo "jsonrpc": "2.0", "id": 0, "method": "call", - "params": ["<SID>", "usp.raw", "get", { "path": "Device.PMcczcQ.lwgBoKtYme.euHbqTcgTI", "proto": "both" }] + "params": [ + "<SID>", + "usp.raw", + "get", + { "path": "Device.VgpyBJaVYmU.JZZCB.mSsqbWsNTX.OMneW.CFZeyXmGE.AikN.q.cHUDp", "proto": "usp" } + ] } ``` @@ -791,13 +790,24 @@ xsd:(string|unsignedInt|int|unsignedLong|long|boolean|dateTime|hexBinary) { "parameters": [ { - "parameter": "Device.UsTcD.rFzY.GltRzUluH.DDWSZwhXyO.TlUv.cbemZ.fWyfbu.VygZDiU", - "value": "enim consectetur nostrud", - "type": "xsd:string" + "parameter": "Device.qCqliKO.eyjiWpou.ibMHowe.2.C.yPCKqgqceCw.NMzaMNvAgc", + "value": "dolore enim Excepteur nulla occaecat", + "type": "xsd:unsignedLong" + }, + { "parameter": "Device.ugnTjsaVqwW.gDadVR", "value": "voluptate ea dolor Excepteur", "type": "xsd:hexBinary" }, + { + "parameter": "Device.JgVimYwdT.xWcobmWHXxj.da.oKioOUZzAd.IF.mOWGV.rWXELTB.QfRy", + "value": "velit", + "type": "xsd:int" + }, + { + "parameter": "Device.fmvL.IOWmRNn.pCb.zjnnFrCDDEx.BXrGz.7.hKcOyVdM", + "value": "veniam elit aliqua", + "type": "xsd:int" }, { - "parameter": "Device.HBw.eWBp.TLZ.VqON.RGqFhUIfGYZ.MThBwelsaZk.xCDUyhHbfa.SepZ", - "value": "do mollit ad", + "parameter": "Device.B.OEOuHvL.erxTiCEIvfs.kWmOBOcg.CoDYtb.Wj.3.L.HqYGlBkJ.MoC", + "value": "elit nulla", "type": "xsd:hexBinary" } ] @@ -904,7 +914,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw getm_attributes {"paths":["Device.HXA.FZb.UIV.IWIi.aLSNcwWX.cfhoKgZ.L.fIElTU.zhaEfv.b.XmZUK","Device.grGwkUW","Device.UH.H.8.M.PPRoPxuKfN.RSltK.BqcaPmib.Y.lTgm.hwRLVoLw.OfeOzB","Device.wdSb","Device.ULTie.y.uSelPgluZf.CxuWTxzK.3.Nmv.KlGkIfQpzgw.DXKTFLvco.x"],"proto":"cwmp","next-level":false} +ubus call usp.raw getm_attributes {"paths":["Device.hnBteeyDl.b.NpUFPSsAMO.iQWlIbav.DzBgLJLGHaN.ZNnLgRE.whgeo","Device.Y.UUIJA.nX.dEvAjast.JGrSoqpyeUm.KJtSYMbLGp.hCPvq.aUQ.cXmF"],"proto":"cwmp","next-level":true} ``` ### JSONRPC Example @@ -920,14 +930,11 @@ ubus call usp.raw getm_attributes {"paths":["Device.HXA.FZb.UIV.IWIi.aLSNcwWX.cf "getm_attributes", { "paths": [ - "Device.HXA.FZb.UIV.IWIi.aLSNcwWX.cfhoKgZ.L.fIElTU.zhaEfv.b.XmZUK", - "Device.grGwkUW", - "Device.UH.H.8.M.PPRoPxuKfN.RSltK.BqcaPmib.Y.lTgm.hwRLVoLw.OfeOzB", - "Device.wdSb", - "Device.ULTie.y.uSelPgluZf.CxuWTxzK.3.Nmv.KlGkIfQpzgw.DXKTFLvco.x" + "Device.hnBteeyDl.b.NpUFPSsAMO.iQWlIbav.DzBgLJLGHaN.ZNnLgRE.whgeo", + "Device.Y.UUIJA.nX.dEvAjast.JGrSoqpyeUm.KJtSYMbLGp.hCPvq.aUQ.cXmF" ], "proto": "cwmp", - "next-level": false + "next-level": true } ] } @@ -1055,9 +1062,21 @@ All instances must conform to this regular expression (test examples [here](<htt { "parameters": [ { - "parameter": "Device.tyrcZuvR.CWGSAEDaSL.J.PzxNIrJ.Z.qPk.dfZTcLjAJeU.RchwgcYOp", + "parameter": "Device.wWfAhktRgE.f.VnaRspjpFO.ScOEvSjjuF.DLvJyNCxhG.LgEuh.voUfP", "value": "0", - "type": "xsd:hexBinary" + "type": "xsd:int" + }, + { + "parameter": "Device.mfxHRJ.MhMhehG.WWMji.cxO.szLOzvs.qDbfpsR.f.EcV.qjZJ.DjKYG", + "value": "0", + "type": "xsd:int" + }, + { "parameter": "Device.PIIYTaVst", "value": "0", "type": "xsd:unsignedInt" }, + { "parameter": "Device.zql.ainJ.7.IlfHQYN", "value": "0", "type": "xsd:hexBinary" }, + { + "parameter": "Device.tHhNFIKp.EIsdwCn.kmOJJdf.k.rft.NSNfUVmPk.tDldA.AVKoL.pMmh", + "value": "0", + "type": "xsd:string" } ] } @@ -1165,7 +1184,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw getm_names {"paths":["Device.jxVLecrEb.gmhrerLA.cFvUfFYlWqu.sKsP.C.jkPW.8.OlxuKwQcsVo."],"proto":"both","next-level":false} +ubus call usp.raw getm_names {"paths":["Device.pDTXuNwobx.dEzHu.ou.AUSJBIqRRK.gkVoqv.TcadHAc.nOzmeCxXEp.","Device.Qbbk.R","Device.vXCHIsOf.dhhtLyyq.NKgzazgv.AEY.bKIolb.yiLlzinRA.puguyEEo."],"proto":"cwmp","next-level":true} ``` ### JSONRPC Example @@ -1180,9 +1199,13 @@ ubus call usp.raw getm_names {"paths":["Device.jxVLecrEb.gmhrerLA.cFvUfFYlWqu.sK "usp.raw", "getm_names", { - "paths": ["Device.jxVLecrEb.gmhrerLA.cFvUfFYlWqu.sKsP.C.jkPW.8.OlxuKwQcsVo."], - "proto": "both", - "next-level": false + "paths": [ + "Device.pDTXuNwobx.dEzHu.ou.AUSJBIqRRK.gkVoqv.TcadHAc.nOzmeCxXEp.", + "Device.Qbbk.R", + "Device.vXCHIsOf.dhhtLyyq.NKgzazgv.AEY.bKIolb.yiLlzinRA.puguyEEo." + ], + "proto": "cwmp", + "next-level": true } ] } @@ -1309,27 +1332,7 @@ All instances must conform to this regular expression (test examples [here](<htt ```json { "parameters": [ - { "parameter": "Device.oYVB", "value": "0", "type": "xsd:int" }, - { - "parameter": "Device.QetpVFQtP.dysKpdK.ppUA.MhoTuYLwJBZ.dnHhTUQxQS.ceRKliPtddn", - "value": "1", - "type": "xsd:boolean" - }, - { - "parameter": "Device.wgluUPROnu.RmzJk.riXfmGJ.ZwQhxZmJFkc.MwbWgixuyO.dwbckrsXC", - "value": "0", - "type": "xsd:unsignedInt" - }, - { - "parameter": "Device.yGCxILdXqS.Y.kARHO.bPmmntGHFT.als.OXWrtp.soo.S.zwBT.IhzOn", - "value": "0", - "type": "xsd:long" - }, - { - "parameter": "Device.f.WlczxJrwaqK.jJVI.XRCK.aecQNMfADz.PuOVe.S.nyFIPSA.IPqBtP", - "value": "1", - "type": "xsd:hexBinary" - } + { "parameter": "Device.niVsZHuR.gkYBhyjCKC.irovKXRzgx.8.rVzdJU", "value": "0", "type": "xsd:dateTime" } ] } ``` @@ -1422,7 +1425,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw getm_values {"paths":["Device.rc.aV.brHw.zdgIQdj.ZWx.jYmK.vVp.7.lFjdnnhmYPi.SbIua.bJpiX","Device.dakwhLxeR.LrLrdGf.pVXPsbddt.HhOHdbWh.zNR.0.A.LPjSWARil.aG","Device.rqK.I.Rq.jgIOKFJzg.8.HAqb.gwapNMkrS.he.wSlmzEFdFx.ahmX.Zp"],"proto":"cwmp"} +ubus call usp.raw getm_values {"paths":["Device.OUWKvZfSsmj.ZAjZaGF.HUBd.nzRYnrkfKtB.W.TGXtqcWA.1.l.qnDvy","Device.CbqXuTQXsL.eoITagtkph.FzoZXR.UVWKcE.tcPwm.jSNcAGB.nSkYCsX","Device.fVqn.iJPwSYgz.ginu.kdzUuNdw.e.qNcfp.UBp.Xbr.s.3.QNKaheLyW"],"proto":"both"} ``` ### JSONRPC Example @@ -1438,11 +1441,11 @@ ubus call usp.raw getm_values {"paths":["Device.rc.aV.brHw.zdgIQdj.ZWx.jYmK.vVp. "getm_values", { "paths": [ - "Device.rc.aV.brHw.zdgIQdj.ZWx.jYmK.vVp.7.lFjdnnhmYPi.SbIua.bJpiX", - "Device.dakwhLxeR.LrLrdGf.pVXPsbddt.HhOHdbWh.zNR.0.A.LPjSWARil.aG", - "Device.rqK.I.Rq.jgIOKFJzg.8.HAqb.gwapNMkrS.he.wSlmzEFdFx.ahmX.Zp" + "Device.OUWKvZfSsmj.ZAjZaGF.HUBd.nzRYnrkfKtB.W.TGXtqcWA.1.l.qnDvy", + "Device.CbqXuTQXsL.eoITagtkph.FzoZXR.UVWKcE.tcPwm.jSNcAGB.nSkYCsX", + "Device.fVqn.iJPwSYgz.ginu.kdzUuNdw.e.qNcfp.UBp.Xbr.s.3.QNKaheLyW" ], - "proto": "cwmp" + "proto": "both" } ] } @@ -1563,12 +1566,10 @@ xsd:(string|unsignedInt|int|unsignedLong|long|boolean|dateTime|hexBinary) ```json { "parameters": [ - { "parameter": "Device.vegW", "value": "nulla eiusmod", "type": "xsd:dateTime" }, - { "parameter": "Device.DTqdJ", "value": "eu lab", "type": "xsd:string" }, { - "parameter": "Device.QxNcH.ayzZoMELatJ.LqWx.VO.LQu.4.QNVjESWcOw.GQwQhPGCYa.k.X", - "value": "do aliquip", - "type": "xsd:dateTime" + "parameter": "Device.UaOlTKVmn.C.Yud.yTFxMqEk.Wd.QqSHJ.Iv.lnA.3.nyNK.7.YQnZCIY", + "value": "occaecat et", + "type": "xsd:int" } ] } @@ -1690,7 +1691,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw instances {"path":"Device.*nEsGiYmXY.BRXDOCJvwk.IvQyy.OWSBZ.FiQ.[J]fOobmqbHFB.wYtvt","proto":"both"} +ubus call usp.raw instances {"path":"Device.2.1.Pmievqz","proto":"usp"} ``` ### JSONRPC Example @@ -1700,12 +1701,7 @@ ubus call usp.raw instances {"path":"Device.*nEsGiYmXY.BRXDOCJvwk.IvQyy.OWSBZ.Fi "jsonrpc": "2.0", "id": 0, "method": "call", - "params": [ - "<SID>", - "usp.raw", - "instances", - { "path": "Device.*nEsGiYmXY.BRXDOCJvwk.IvQyy.OWSBZ.FiQ.[J]fOobmqbHFB.wYtvt", "proto": "both" } - ] + "params": ["<SID>", "usp.raw", "instances", { "path": "Device.2.1.Pmievqz", "proto": "usp" }] } ``` @@ -1767,9 +1763,9 @@ Device\.(([a-zA-Z]+\.)*(\d\.)?)*[a-zA-Z]*.\d ```json { "parameters": [ - { "parameter": "Device.l.e.quaXiduDnq.4.owYxRBABIA.CiUJeJUXdvE.GWThAF.TmHtp.vAHt" }, - { "parameter": "Device.pZQRdx.qZ.aRQQiOsaTi.nPMYLsf.IAiwnvgMWF.M.yyYjVPPdf.dscrY" }, - { "parameter": "Device.kTqkkp.yUewOU.z.FeIW.DJ.hGTaOoOXbS.Mb.JQm.kNfqv.sz.UlHEiU" } + { "parameter": "Device.ziD.YIPGqAi.VMmdb.iPkVTtZBD.Y.Qma.d.MK.kZCzkvL.GOZThKedx." }, + { "parameter": "Device.qlyLZRgb.uFnh.TZ.7.jhv.FL.GWp.ffTSUHAQPff.NTQuIEDrl.gDZ.h" }, + { "parameter": "Device.UWMePzgwwk.wgJI.PuyjR.PIvCNBtgF.PxFSCPSGmz.TY.7.FEmmNlTaJ" } ] } ``` @@ -1820,10 +1816,38 @@ Array type: `object[]` All items must be of the type: `object` with following properties: -| Property | Type | Required | -| ----------- | ------ | -------- | -| `parameter` | string | Optional | -| `type` | string | Optional | +| Property | Type | Required | +| ----------- | ------ | ------------ | +| `in` | array | Optional | +| `out` | array | Optional | +| `parameter` | string | **Required** | +| `type` | string | **Required** | + +#### in + +`in` + +- is optional +- type: `string[]` + +##### in Type + +Array type: `string[]` + +All items must be of the type: `string` + +#### out + +`out` + +- is optional +- type: `string[]` + +##### out Type + +Array type: `string[]` + +All items must be of the type: `string` #### parameter @@ -1831,7 +1855,7 @@ Datamodel object schema path `parameter` -- is optional +- is **required** - type: reference ##### parameter Type @@ -1864,7 +1888,7 @@ Device.FactoryReset() `type` -- is optional +- is **required** - type: reference ##### type Type @@ -1883,8 +1907,30 @@ All instances must conform to this regular expression (test examples ```json { "parameters": [ - { "parameter": "Device.TCXsOgjA.T.zfPSnnGL.DfPukR.UqGS.{i}.kYYvuw.fQPvRkMK.oNNNq", "type": "sync" }, - { "parameter": "Device.UMQ()", "type": "sync" } + { + "parameter": "Device.svvS.Xc.AUWMqyJ.ByoZFyL.hOCLJK.oecGdX.Vht.{i}.fXwLshUSRKj", + "type": "async", + "in": ["velit est dolor", "aliquip officia et", "do occaecat consequat Duis laborum", "labore"], + "out": ["nisi ea exercitation", "culpa est cupidatat"] + }, + { + "parameter": "Device.CElbWVr.MM.NVAEOU.T.IUXQ.wkNHyQVndqh.rGOmlUKE.WBPo.aCAKwA", + "type": "async", + "in": ["officia", "ipsum esse ea", "ullamco"], + "out": ["in in proident Excepteur", "Lorem", "dolor "] + }, + { + "parameter": "Device.TtT.lHSjmtpT.{i}.cijsbZ()", + "type": "sync", + "in": ["reprehenderit sint"], + "out": ["elit aute proide", "enim adipisicing proident officia ut", "adipisicing q", "in", "dolore magna"] + }, + { + "parameter": "Device.U.MWpaonhrg.sGMrL.daRkXUB.v.Yn.YQ.PxQHm.{i}.J.nzFaDAt.s.r", + "type": "sync", + "in": ["qui", "culpa de", "velit pariatur nostrud consectetur", "anim cupidatat occaecat elit ex"], + "out": ["labore occaecat tempor", "ex in elit sunt culpa", "esse"] + } ] } ``` @@ -2005,7 +2051,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw object_names {"path":"Device.kDASYpIS.R.MsI.O.EwIsePP.fWtMob.vEhwIQUkvhX.APJhUGqavZ.Il","proto":"cwmp"} +ubus call usp.raw object_names {"path":"Device.wBfj.PHSPDYAPj.jLLVXHFmad.zTj.sYjjyfcl.RpWmsNPY.gbxVelmtC","proto":"both"} ``` ### JSONRPC Example @@ -2019,7 +2065,7 @@ ubus call usp.raw object_names {"path":"Device.kDASYpIS.R.MsI.O.EwIsePP.fWtMob.v "<SID>", "usp.raw", "object_names", - { "path": "Device.kDASYpIS.R.MsI.O.EwIsePP.fWtMob.vEhwIQUkvhX.APJhUGqavZ.Il", "proto": "cwmp" } + { "path": "Device.wBfj.PHSPDYAPj.jLLVXHFmad.zTj.sYjjyfcl.RpWmsNPY.gbxVelmtC", "proto": "both" } ] } ``` @@ -2106,14 +2152,7 @@ Device.WiFi. ### Output Example ```json -{ - "parameters": [ - { "parameter": "Device.tgSCbJaaC.KZfOAcoj.TAdQvN.d.n.VvCLJFdkP.EQzeG.OUOgGj.LOle" }, - { "parameter": "Device.QD.DTQbqZZ.jBVmZqkX.JvAUcdufZ.DHBMTNAbZFt.O.X" }, - { "parameter": "Device.vkxqBPzob.aYxM.hPucFVl.Ewz.G.VAM.iS.m.kT.4.FlKEoWgHRy.JMJ" }, - { "parameter": "Device.ThXSNqtbjV.KNPBO.dukKWFvue.yq.IOh.WprYZpQX.pcSY.AjJy.GFKr" } - ] -} +{ "parameters": [{ "parameter": "Device.ZyV.iyFNP.qzR.sPaeRysI.5.vHiIrtjaA.ZNDKSS.ldFXSOG.SotdlFa" }] } ``` ## operate @@ -2285,7 +2324,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw operate {"path":"Device.piVrA.ymNPgCkUcA","action":"HHmEBL()","proto":"usp","input":{}} +ubus call usp.raw operate {"path":"Device.UqNsqVsb.MkndiMxPeVu.BnQtVgqHI.[Jc7]mTaonhZ.hiFwTLIOxT.Yn","action":"aCMs()","proto":"usp","input":{}} ``` ### JSONRPC Example @@ -2299,7 +2338,12 @@ ubus call usp.raw operate {"path":"Device.piVrA.ymNPgCkUcA","action":"HHmEBL()", "<SID>", "usp.raw", "operate", - { "path": "Device.piVrA.ymNPgCkUcA", "action": "HHmEBL()", "proto": "usp", "input": {} } + { + "path": "Device.UqNsqVsb.MkndiMxPeVu.BnQtVgqHI.[Jc7]mTaonhZ.hiFwTLIOxT.Yn", + "action": "aCMs()", + "proto": "usp", + "input": {} + } ] } ``` @@ -2533,7 +2577,7 @@ To set multiple values at once, path should be relative to object elements ### Ubus CLI Example ``` -ubus call usp.raw set {"path":"Device.l.N.zVmSjiAjeC.GDk.zApfZKYtxp.jzb.TI.nlCSzJ.CtQh.ro.tlset","value":"dbR","proto":"cwmp","values":{}} +ubus call usp.raw set {"path":"Device.DeKDocuKdtR.OYgCJ.oRBNmY.UsfQCkm.ncCcUVIIVs.Q.cAXMuvKvbyf","value":"hiEYQ","proto":"cwmp","values":{}} ``` ### JSONRPC Example @@ -2548,8 +2592,8 @@ ubus call usp.raw set {"path":"Device.l.N.zVmSjiAjeC.GDk.zApfZKYtxp.jzb.TI.nlCSz "usp.raw", "set", { - "path": "Device.l.N.zVmSjiAjeC.GDk.zApfZKYtxp.jzb.TI.nlCSzJ.CtQh.ro.tlset", - "value": "dbR", + "path": "Device.DeKDocuKdtR.OYgCJ.oRBNmY.UsfQCkm.ncCcUVIIVs.Q.cAXMuvKvbyf", + "value": "hiEYQ", "proto": "cwmp", "values": {} } @@ -2668,8 +2712,10 @@ Device.WiFi. ```json { "parameters": [ - { "path": "Device.DvSoRhyqtXs.pZslyOa.XjkAHF.hFapQCb.NLUYVaasn.iC.bkSPIsacq", "status": true, "fault": 7325 }, - { "path": "Device.NcbtYeXNY.Vfdor.scWXvNmpDwk.EVfKiyVJ.8.amoSNsFLhW.YagDt.C", "status": false, "fault": 8355 } + { "path": "Device.QbxnRcz.OYAi.EIV.tH.fmhDOlAaQ.ojMFsODNG.4.vSDI.w.Nte.GXPs", "status": false, "fault": 8660 }, + { "path": "Device.lZxTsEhM", "status": true, "fault": 8797 }, + { "path": "Device.TWzGOadWUFI.p.0.e.AEKgZY.mJ.mCk.ArQQV.kM.h.symUBEvd.jem.Q", "status": false, "fault": 8640 }, + { "path": "Device.xVZZ.SGE.KVvfLfg.EBYAmFsjdMz.4.MU.IMItPIUrD.ZZcxD.uGbjydP", "status": false, "fault": 7819 } ] } ``` @@ -2832,7 +2878,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw setm_attributes {"paths":[{"path":"Device.fDLQH.6.nJtEEW.gjUrq.OPsfKXZPXX.NCcxksCGN.oAuAHfhhBve.sCD","notify-type":"0","notify":"0"},{"path":"Device.5.OIx.cnY.eS.cqFVLpzx.EkesWXgeE.eS.rccuuayv.c.jMHvkSE.D.e","notify-type":"1","notify":"0"},{"path":"Device.DeBpB.ItKxfIopnUV.MoT.ZPJ.gqUUtI.wyApGGU.jmwGaY.ToyqHygxX","notify-type":"0","notify":"0"}],"proto":"both"} +ubus call usp.raw setm_attributes {"paths":[{"path":"Device.jX.AJmZO.r.HAfIBE.ajM.XvapHyAJwE.CckrIdy.MQvzhAaPQdr.Hxlp","notify-type":"1","notify":"1"}],"proto":"cwmp"} ``` ### JSONRPC Example @@ -2849,22 +2895,12 @@ ubus call usp.raw setm_attributes {"paths":[{"path":"Device.fDLQH.6.nJtEEW.gjUrq { "paths": [ { - "path": "Device.fDLQH.6.nJtEEW.gjUrq.OPsfKXZPXX.NCcxksCGN.oAuAHfhhBve.sCD", - "notify-type": "0", - "notify": "0" - }, - { - "path": "Device.5.OIx.cnY.eS.cqFVLpzx.EkesWXgeE.eS.rccuuayv.c.jMHvkSE.D.e", + "path": "Device.jX.AJmZO.r.HAfIBE.ajM.XvapHyAJwE.CckrIdy.MQvzhAaPQdr.Hxlp", "notify-type": "1", - "notify": "0" - }, - { - "path": "Device.DeBpB.ItKxfIopnUV.MoT.ZPJ.gqUUtI.wyApGGU.jmwGaY.ToyqHygxX", - "notify-type": "0", - "notify": "0" + "notify": "1" } ], - "proto": "both" + "proto": "cwmp" } ] } @@ -2954,11 +2990,9 @@ Device.WiFi. ```json { "parameters": [ - { "path": "Device.Rbfqc.OyKuhubBl.TwVAIFgJfBW.Bflm.pJedSvphte.YqJAT.TMqVzsu" }, - { "path": "Device." }, - { "path": "Device.WFdrhmmLg.ypMVG.SIEgqH.KgJYmlbJ.ZTYtZ.yPlK.6.ojuNMAMxjq.K" }, - { "path": "Device.UDXJthKlacd.EGecr.Pnbuvy.JJ.SmEA.9.bVXODLKq.Ik.AePbvNoQo." }, - { "path": "Device.s.JgDV.QgZCp.IJPlFmXSOa.FENAjg.IqHklGTaSc.KQsoNZdX.B.EfZE" } + { "path": "Device.vEbUJ.EAd.jGSA.ye.xnudaNUV.vuRgSdsDb.zvPMfGO.3.4.YhdZbbID" }, + { "path": "Device.4.xwN.sD" }, + { "path": "Device.LCHdxFo.M.RfSLLFUosKY.NR.HaKsfXxz.PF.mNhmMiqyEjr.TJJpGQyk" } ] } ``` @@ -3079,7 +3113,7 @@ All instances must conform to this regular expression (test examples ### Ubus CLI Example ``` -ubus call usp.raw validate {"path":"Device.*WaEwqWqh.R.jsnzQWOCc.CcoPaq.uMUY.DlrOBm.ddON.j.P.YqyZMgG","proto":"both"} +ubus call usp.raw validate {"path":"Device.Zj","proto":"both"} ``` ### JSONRPC Example @@ -3089,12 +3123,7 @@ ubus call usp.raw validate {"path":"Device.*WaEwqWqh.R.jsnzQWOCc.CcoPaq.uMUY.Dlr "jsonrpc": "2.0", "id": 0, "method": "call", - "params": [ - "<SID>", - "usp.raw", - "validate", - { "path": "Device.*WaEwqWqh.R.jsnzQWOCc.CcoPaq.uMUY.DlrOBm.ddON.j.P.YqyZMgG", "proto": "both" } - ] + "params": ["<SID>", "usp.raw", "validate", { "path": "Device.Zj", "proto": "both" }] } ``` @@ -3195,5 +3224,5 @@ Device.WiFi. ### Output Example ```json -{ "parameters": [{ "parameter": "Device.Pk", "fault": 7767 }, { "parameter": "Device.TWW", "fault": 8455 }] } +{ "parameters": [{ "parameter": "Device.", "fault": 7521 }] } ``` diff --git a/gitlab-ci/functional-test.sh b/gitlab-ci/functional-test.sh index 1d43dc4ef355f8d89f3636f506d71cf209d3d0ed..28e8bb776862fddf6cd7143bc3d733eb07dc5fe6 100755 --- a/gitlab-ci/functional-test.sh +++ b/gitlab-ci/functional-test.sh @@ -5,6 +5,10 @@ pwd make clean make func-test -C ./ +if [ "$?" -ne 0 ]; then + echo "Compilation failed" + exit 1 +fi supervisorctl status all supervisorctl update @@ -17,16 +21,14 @@ supervisorctl status all ubus-api-validator -d ./test/funl/json/ > ./funl-result.log ret=$? -output=`ubus call usp.raw get '{"path":"Device.USB.USBHosts.Host.[Enable==0].Device."}' | grep "DeviceNumberOfEntries"` -echo "=====================================================================" -echo "Validating Bug 3272 :: $output" -if [ -z "$output" ]; then - echo "Bug Validation 3272 Pass" -else - echo "Bug Validation 3272 Fail" - ret=1 -fi -echo "=====================================================================" +echo "## Running python based verification of functionalities ##" +for test in `ls -1 ./test/python/*.py` +do + $test + if [ "$?" -ne 0 ]; then + ret=$(( $ret + 1 )) + fi +done supervisorctl stop all supervisorctl status @@ -41,7 +43,7 @@ date +%s > timestamp.log echo "Checking memory leaks..." grep -q "Leak_DefinitelyLost" memory-report.xml if [ "$?" -eq 0 ]; then - ret=2 + ret=$(( $ret + 1 )) fi echo "Validating CPU/MEM usage during functional testing" diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh index 3742d0e0a4c81805268f6946cb6a30f259b2890c..5af400118194804b065675d696618d306edc4494 100755 --- a/gitlab-ci/install-dependencies.sh +++ b/gitlab-ci/install-dependencies.sh @@ -19,15 +19,19 @@ cd /opt/dev rm -rf bbf exec_cmd git clone -b devel https://dev.iopsys.eu/iopsys/bbf.git cd /opt/dev/bbf -#exec_cmd git checkout a9dff9e62134c3b758afc243eee1da5ed8a0a439 +if [ -n "${UPSTREAM_BBF_SHA}" ]; then + exec_cmd git checkout ${UPSTREAM_BBF_SHA} +fi + +echo "Compiling bbf" exec_cmd autoreconf -i exec_cmd ./configure --enable-tr181 --enable-tr104 --enable-tr143 --enable-tr157 CPPFLAGS=-DCUSTOM_PREFIX=\\\"X_IOPSYS_EU_\\\" exec_cmd make -cp bin/.libs/libbbfdm.so* /usr/lib/ -cp bin/.libs/libbbf_api.so* /usr/lib/ -mkdir /usr/include/libbbfdm -mkdir /usr/include/libbbf_api +cp -f bin/.libs/libbbfdm.so* /usr/lib/ +cp -f bin/.libs/libbbf_api.so* /usr/lib/ +mkdir -p /usr/include/libbbfdm +mkdir -p /usr/include/libbbf_api cp *.h /usr/include/libbbfdm/ cp dmtree/tr181/*.h /usr/include/libbbfdm/ cp dmtree/tr157/*.h /usr/include/libbbfdm/ @@ -36,4 +40,9 @@ ldconfig # configure libbbf mkdir -p /etc/bbfdm/ +mkdir -p /etc/bbfdm/json +cp config/dmmap /etc/bbfdm/ +mkdir -p /usr/share/bbfdm +cp scripts/functions /usr/share/bbfdm +mkdir -p /usr/lib/bbfdm diff --git a/schemas/ubus/usp.json b/schemas/ubus/usp.json index ccb7ec51b738c56cd3cc0e3d63513c0b06835044..38b4e8810b1f4434ca1d2618d57424702cf35f37 100644 --- a/schemas/ubus/usp.json +++ b/schemas/ubus/usp.json @@ -140,12 +140,28 @@ "type": "array", "items": { "type": "object", + "required": [ + "parameter", + "type" + ], "properties": { "parameter": { "$ref": "#/definitions/operate_path_t" }, "type": { "$ref": "#/definitions/operate_type_t" + }, + "in": { + "type": "array", + "items": { + "type": "string" + } + }, + "out": { + "type": "array", + "items": { + "type": "string" + } } } } diff --git a/schemas/ubus/usp.raw.json b/schemas/ubus/usp.raw.json index 5ae39141db227597f97e50bcc25ba4a5b0b5cbb8..8699be6219203288c21552d6676116f365f630bf 100644 --- a/schemas/ubus/usp.raw.json +++ b/schemas/ubus/usp.raw.json @@ -140,12 +140,28 @@ "type": "array", "items": { "type": "object", + "required": [ + "parameter", + "type" + ], "properties": { "parameter": { "$ref": "#/definitions/operate_path_t" }, "type": { "$ref": "#/definitions/operate_type_t" + }, + "in": { + "type": "array", + "items": { + "type": "string" + } + }, + "out": { + "type": "array", + "items": { + "type": "string" + } } } } diff --git a/src/add_delete.c b/src/add_delete.c index 79c7ab6d94c18b903139cbf73bb8b7e43f2ebb2b..72b7489f037b7fe65c7a5d6ce344a47165ff7aa4 100644 --- a/src/add_delete.c +++ b/src/add_delete.c @@ -42,27 +42,29 @@ void create_add_del_response(struct blob_buf *bb, char *path, const char *pkey, LIST_HEAD(resolved_paths); - get_resolved_paths(&bbf_ctx, path, &resolved_paths); - - array = blobmsg_open_array(bb, "parameters"); - if (is_str_eq(method, "add_object")) { - list_for_each_entry(p, &resolved_paths, list) { - table = blobmsg_open_table(bb, NULL); - fault |= usp_add_object(&bbf_ctx, bb, p->path, pkey); - blobmsg_close_table(bb, table); - } - } else if (is_str_eq(method, "del_object")) { - list_for_each_entry(p, &resolved_paths, list) { - table = blobmsg_open_table(bb, NULL); - fault |= usp_del_object(&bbf_ctx, bb, p->path, pkey); - blobmsg_close_table(bb, table); - } + fault = get_resolved_paths(&bbf_ctx, path, &resolved_paths); + if (fault) { + fill_err_code(bb, fault); } else { - ERR("method(%s) not defined", method); + array = blobmsg_open_array(bb, "parameters"); + if (is_str_eq(method, "add_object")) { + list_for_each_entry(p, &resolved_paths, list) { + table = blobmsg_open_table(bb, NULL); + fault |= usp_add_object(&bbf_ctx, bb, p->path, pkey); + blobmsg_close_table(bb, table); + } + } else if (is_str_eq(method, "del_object")) { + list_for_each_entry(p, &resolved_paths, list) { + table = blobmsg_open_table(bb, NULL); + fault |= usp_del_object(&bbf_ctx, bb, p->path, pkey); + blobmsg_close_table(bb, table); + } + } else { + ERR("method(%s) not defined", method); + } + blobmsg_close_array(bb, array); } - blobmsg_close_array(bb, array); - bbf_cleanup(&bbf_ctx); if (fault == 0) { diff --git a/src/common.h b/src/common.h index 4ec5c5ab890c45f077363aaa0c474a87a12bccea..c6ae6c5e48141b880367a8b55ce3b30db27cd5f5 100644 --- a/src/common.h +++ b/src/common.h @@ -72,7 +72,6 @@ void print_info(const char *format, ...); void print_debug(const char *format, ...); bool get_boolean_string(char *value); -int get_dm_type(char *dm_str); #define DEBUG(fmt, args...) \ print_debug("[%s:%d]"fmt, __func__, __LINE__, ##args) @@ -86,6 +85,4 @@ int get_dm_type(char *dm_str); #define WARNING(fmt, args...) \ print_warning("[%s:%d] " fmt, __func__, __LINE__, ##args) -#define __unused __attribute__((unused)) - #endif /* COMMON_H */ diff --git a/src/get_helper.c b/src/get_helper.c index 1952e8ace8913fb77eb8ef9ec8c208647b52d7b0..b4644593dae1eb417e707fca8f28bf5e313d845e 100644 --- a/src/get_helper.c +++ b/src/get_helper.c @@ -42,17 +42,6 @@ static const char * const operations[] = { [OPER_GREATER_THAN] = ">" }; -const char *DMT_TYPE[] = { -[DMT_STRING] = "xsd:string", -[DMT_UNINT] = "xsd:unsignedInt", -[DMT_INT] = "xsd:int", -[DMT_UNLONG] = "xsd:unsignedLong", -[DMT_LONG] = "xsd:long", -[DMT_BOOL] = "xsd:boolean", -[DMT_TIME] = "xsd:dateTime", -[DMT_HEXBIN] = "xsd:hexBinary", -}; - // Common utilities // blobmsg result in segfault when null values added void bb_add_string(struct blob_buf *bb, const char *name, const char *value) @@ -63,33 +52,6 @@ void bb_add_string(struct blob_buf *bb, const char *name, const char *value) blobmsg_add_string(bb, name, ""); } -int get_dm_type(char *dm_str) -{ - if (dm_str == NULL) - return DMT_STRING; - - if (strcmp(dm_str, DMT_TYPE[DMT_STRING]) == 0) - return DMT_STRING; - else if (strcmp(dm_str, DMT_TYPE[DMT_UNINT]) == 0) - return DMT_UNINT; - else if (strcmp(dm_str, DMT_TYPE[DMT_INT]) == 0) - return DMT_INT; - else if (strcmp(dm_str, DMT_TYPE[DMT_UNLONG]) == 0) - return DMT_UNLONG; - else if (strcmp(dm_str, DMT_TYPE[DMT_LONG]) == 0) - return DMT_LONG; - else if (strcmp(dm_str, DMT_TYPE[DMT_BOOL]) == 0) - return DMT_BOOL; - else if (strcmp(dm_str, DMT_TYPE[DMT_TIME]) == 0) - return DMT_TIME; - else if (strcmp(dm_str, DMT_TYPE[DMT_HEXBIN]) == 0) - return DMT_HEXBIN; - else - return DMT_STRING; - - return DMT_STRING; -} - void bbf_init(struct dmctx *dm_ctx, char *path) { unsigned int amd = AMD_5, instance = INSTANCE_MODE_NUMBER; @@ -1368,6 +1330,9 @@ static int usp_dm_set_notif(char *path, int proto, char *arg1, char *arg2) } } + if (fault == USP_ERR_OK) + fault = dm_entry_apply(&dm_ctx, CMD_SET_NOTIFICATION, NULL, NULL); + bbf_cleanup(&dm_ctx); return fault; diff --git a/src/operate.c b/src/operate.c index 141ac22c7fe76c2f4549b021682aadf4faa31ff1..b917dd61519704f8ad338b4ee80ed74bec6875bb 100644 --- a/src/operate.c +++ b/src/operate.c @@ -56,8 +56,11 @@ void list_operate_schema(struct blob_buf *bb) { struct dm_parameter *n; char tmp[MAX_DM_PATH] = {'\0'}; - void *array, *table; + void *array, *table, *array_arg; struct dmctx bbf_ctx; + operation_args *args; + size_t i; + const char **ap; memset(&bbf_ctx, 0, sizeof(struct dmctx)); @@ -69,12 +72,36 @@ void list_operate_schema(struct blob_buf *bb) array = blobmsg_open_array(bb, "parameters"); list_for_each_entry(n, &bbf_ctx.list_parameter, list) { get_operate_schema_path(n->name, tmp); - DEBUG("Operate node|%s|, schema|%s| type(%s)", - n->name, tmp, n->type); table = blobmsg_open_table(bb, NULL); blobmsg_add_string(bb, "parameter", tmp); blobmsg_add_string(bb, "type", n->type); + + DEBUG("Operate node|%s|, schema|%s| type(%s)", + n->name, tmp, n->type); + + // filling in and out parameter + if (n->data) { + args = (operation_args *) n->data; + + ap = args->in; + if (ap) { + array_arg = blobmsg_open_array(bb, "in"); + for (i = 0; ap[i] != NULL; i++) + blobmsg_add_string(bb, NULL, ap[i]); + + blobmsg_close_array(bb, array_arg); + } + + ap = args->out; + if (ap) { + array_arg = blobmsg_open_array(bb, "out"); + for (i = 0; ap[i] != NULL; i++) + blobmsg_add_string(bb, NULL, ap[i]); + + blobmsg_close_array(bb, array_arg); + } + } blobmsg_close_table(bb, table); } @@ -89,6 +116,7 @@ void usp_operate_cmd(usp_data_t *data) void *array, *table; char path[MAX_DM_PATH]; struct dmctx bbf_ctx; + int fault; memset(&bbf_ctx, 0, sizeof(struct dmctx)); @@ -100,20 +128,22 @@ void usp_operate_cmd(usp_data_t *data) memset(&bb, 0, sizeof(struct blob_buf)); blob_buf_init(&bb, 0); - get_resolved_paths(&bbf_ctx, data->qpath, &resolved_paths); - - array = blobmsg_open_array(&bb, "Results"); - list_for_each_entry(rv, &resolved_paths, list) { - strcpy(path, rv->path); - strcat(path, data->op_action); - - table = blobmsg_open_table(&bb, NULL); - blobmsg_add_string(&bb, "path", path); - usp_dm_operate(&bb, path, data->op_input, data->is_raw); - blobmsg_close_table(&bb, table); + fault = get_resolved_paths(&bbf_ctx, data->qpath, &resolved_paths); + if (fault) { + fill_err_code(&bb, fault); + } else { + array = blobmsg_open_array(&bb, "Results"); + list_for_each_entry(rv, &resolved_paths, list) { + strcpy(path, rv->path); + strcat(path, data->op_action); + + table = blobmsg_open_table(&bb, NULL); + blobmsg_add_string(&bb, "path", path); + usp_dm_operate(&bb, path, data->op_input, data->is_raw); + blobmsg_close_table(&bb, table); + } + blobmsg_close_array(&bb, array); } - blobmsg_close_array(&bb, array); - ubus_send_reply(data->ctx, data->req, bb.head); // free blob_buf_free(&bb); diff --git a/src/pretty_print.c b/src/pretty_print.c index c95a96f7324f55d6967b229f0c05bf8276b58962..934b1c4a33b6a3f8b0060fab5abfc98aaeb332e6 100644 --- a/src/pretty_print.c +++ b/src/pretty_print.c @@ -24,6 +24,7 @@ #include "get_helper.h" #include "pretty_print.h" #include <libbbf_api/dmbbf.h> +#include <libbbfdm/dmbbfcommon.h> // private function and structures diff --git a/src/set.c b/src/set.c index 41c9b4cbd73583e81309379a08ae8b561d5c2d3a..e4c464d5d3d7655adb309b83d78a5123de69e0d1 100644 --- a/src/set.c +++ b/src/set.c @@ -41,6 +41,7 @@ void usp_set_value(usp_data_t *data) struct pathNode *rv; struct pvNode *pv; struct dmctx bbf_ctx; + int fault = USP_ERR_OK; memset(&bbf_ctx, 0, sizeof(struct dmctx)); @@ -58,18 +59,20 @@ void usp_set_value(usp_data_t *data) memset(&bb, 0, sizeof(struct blob_buf)); blob_buf_init(&bb, 0); - get_resolved_paths(&bbf_ctx, qpath, &resolved_paths); - - array = blobmsg_open_array(&bb, "parameters"); - list_for_each_entry(rv, &resolved_paths, list) { - list_for_each_entry(pv, val_pv_list, list) { - snprintf(temp, MAX_DM_PATH, "%s%s", rv->path, pv->param); - INFO("## set (%s)::(%s)::(%s) ##", temp, pv->val, key); - usp_dm_set(&bbf_ctx, &bb, temp, pv->val, key); + fault = get_resolved_paths(&bbf_ctx, qpath, &resolved_paths); + if (fault) { + fill_err_code(&bb, fault); + } else { + array = blobmsg_open_array(&bb, "parameters"); + list_for_each_entry(rv, &resolved_paths, list) { + list_for_each_entry(pv, val_pv_list, list) { + snprintf(temp, MAX_DM_PATH, "%s%s", rv->path, pv->param); + INFO("## set (%s)::(%s)::(%s) ##", temp, pv->val, key); + usp_dm_set(&bbf_ctx, &bb, temp, pv->val, key); + } } + blobmsg_close_array(&bb, array); } - blobmsg_close_array(&bb, array); - ubus_send_reply(ctx, req, bb.head); // free diff --git a/src/usp.c b/src/usp.c index 891c89003cf28531d06f006a45c9124d80ebba83..1669120dadb6f8844763b266413b2b21f90685d4 100644 --- a/src/usp.c +++ b/src/usp.c @@ -337,7 +337,7 @@ int get_safe(struct ubus_context *ctx, int usp_get_attributes(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, - __unused const char *method, + __attribute__((unused)) const char *method, struct blob_attr *msg) { return get_safe(ctx, obj, req, msg, CMD_GET_NOTIFICATION); @@ -346,7 +346,7 @@ int usp_get_attributes(struct ubus_context *ctx, int usp_get_safe_values(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, - __unused const char *method, + __attribute__((unused)) const char *method, struct blob_attr *msg) { return get_safe(ctx, obj, req, msg, CMD_GET_VALUE); @@ -355,16 +355,16 @@ int usp_get_safe_values(struct ubus_context *ctx, int usp_get_safe_names(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, - __unused const char *method, + __attribute__((unused)) const char *method, struct blob_attr *msg) { return get_safe(ctx, obj, req, msg, CMD_GET_NAME); } int usp_set_safe_attributes(struct ubus_context *ctx, - __unused struct ubus_object *obj, + __attribute__((unused)) struct ubus_object *obj, struct ubus_request_data *req, - __unused const char *method, + __attribute__((unused)) const char *method, struct blob_attr *msg) { struct blob_buf bb = {}; @@ -428,10 +428,9 @@ int usp_add_del_handler(struct ubus_context *ctx, struct ubus_object *obj, char path[PATH_MAX]; const char *pkey = NULL; struct blob_buf bb = {}; - size_t path_len; char *blob_msg = NULL; int proto; - + size_t path_len; if (blobmsg_parse(dm_add_policy, __DM_ADD_MAX, tb, blob_data(msg), blob_len(msg))) { ERR("Failed to parse blob"); @@ -460,8 +459,18 @@ int usp_add_del_handler(struct ubus_context *ctx, struct ubus_object *obj, INFO("ubus method|%s|, name|%s|, path(%s)", method, obj->name, path); if (!path_present_in_schema(path)) { + memset(&bb, 0, sizeof(struct blob_buf)); + blob_buf_init(&bb, 0); + ERR("Invalid path |%s|", path); - return UBUS_STATUS_INVALID_ARGUMENT; + if (proto == BBFDM_CWMP) + fill_err_code(&bb, FAULT_9005); + else + fill_err_code(&bb, USP_ERR_INVALID_PATH); + + ubus_send_reply(ctx, req, bb.head); + blob_buf_free(&bb); + return 0; } if (tb[DM_ADD_PARAMETER_KEY]) @@ -479,7 +488,7 @@ int usp_add_del_handler(struct ubus_context *ctx, struct ubus_object *obj, } int usp_get_handler(struct ubus_context *ctx, struct ubus_object *obj, - struct ubus_request_data *req, const char *method __unused, + struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg) { struct blob_attr *tb[__DM_GET_MAX]; @@ -507,7 +516,7 @@ int usp_get_handler(struct ubus_context *ctx, struct ubus_object *obj, // In case of granular objects, Concatenate relative path to ubus object if (strncmp(obj->name, USPEXT, strlen(USPEXT)) == 0) { snprintf(path, PATH_MAX, "%s%s", obj->name + USP_EXT_LEN, - (char *)blobmsg_data(tb[DM_ADD_PATH])); + (char *)blobmsg_data(tb[DM_GET_PATH])); } else { strncpyt(path, blobmsg_data(tb[DM_GET_PATH]), sizeof(path)); } @@ -518,7 +527,11 @@ int usp_get_handler(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(&bb, 0); ERR("Invalid path |%s|", path); - fill_err_code(&bb, USP_ERR_INVALID_PATH); + if (get_bbf_proto_type(tb[DM_GET_PROTO]) == BBFDM_CWMP) + fill_err_code(&bb, FAULT_9005); + else + fill_err_code(&bb, USP_ERR_INVALID_PATH); + ubus_send_reply(ctx, req, bb.head); blob_buf_free(&bb); return 0; @@ -583,7 +596,7 @@ int usp_set(struct ubus_context *ctx, struct ubus_object *obj, // In case of granular objects, Concatenate relative path to ubus object if (strncmp(obj->name, USPEXT, strlen(USPEXT)) == 0) { snprintf(path, PATH_MAX, "%s%s", obj->name + USP_EXT_LEN, - (char *)blobmsg_data(tb[DM_ADD_PATH])); + (char *)blobmsg_data(tb[DM_SET_PATH])); } else { blob_msg = blobmsg_data(tb[DM_SET_PATH]); strncpyt(path, blob_msg, sizeof(path)); @@ -624,7 +637,10 @@ int usp_set(struct ubus_context *ctx, struct ubus_object *obj, if (fault) { ERR("Fault in set path |%s|", path); - fill_err_code(&bb, fault); + if (get_bbf_proto_type(tb[DM_SET_PROTO]) == BBFDM_CWMP) + fill_err_code(&bb, FAULT_9005); + else + fill_err_code(&bb, fault); ubus_send_reply(ctx, req, bb.head); blob_buf_free(&bb); free_pv_list(&pv_list); @@ -638,7 +654,7 @@ int usp_set(struct ubus_context *ctx, struct ubus_object *obj, data.qpath = path; data.pv_list = &pv_list; data.set_key = key; - data.proto = get_bbf_proto_type(tb[DM_GET_PROTO]); + data.proto = get_bbf_proto_type(tb[DM_SET_PROTO]); usp_set_value(&data); @@ -688,7 +704,7 @@ int usp_operate(struct ubus_context *ctx, struct ubus_object *obj __attribute__( strncpyt(cmd, blob_msg, sizeof(cmd)); INFO("ubus method|%s|, name|%s|, path(%s)", method, obj->name, path); - if (get_bbf_proto_type(tb[DM_GET_PROTO]) == BBFDM_CWMP) { + if (get_bbf_proto_type(tb[DM_OPERATE_PROTO]) == BBFDM_CWMP) { ERR("Operate commands not available for CWMP proto"); return UBUS_STATUS_UNKNOWN_ERROR; } @@ -699,7 +715,7 @@ int usp_operate(struct ubus_context *ctx, struct ubus_object *obj __attribute__( data.req = req; data.qpath = path; data.op_action = cmd; - data.proto = get_bbf_proto_type(tb[DM_GET_PROTO]); + data.proto = get_bbf_proto_type(tb[DM_OPERATE_PROTO]); data.is_raw = is_str_eq(obj->name, USPRAW); if (tb[DM_OPERATE_INPUT]) @@ -715,7 +731,7 @@ int usp_operate(struct ubus_context *ctx, struct ubus_object *obj __attribute__( int usp_list_schema(struct ubus_context *actx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, - struct blob_attr *msg __attribute__ ((unused))) + struct blob_attr *msg __attribute__((unused))) { struct blob_buf bb; void *array, *table; @@ -749,7 +765,7 @@ int usp_list_schema(struct ubus_context *actx, struct ubus_object *obj, int usp_list_operate(struct ubus_context *actx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, - struct blob_attr *msg __unused) + struct blob_attr *msg __attribute__((unused))) { struct blob_buf bb; diff --git a/test/cmocka/unit_test_uspd.c b/test/cmocka/unit_test_uspd.c index 928f398c78bd6e094ca415d288a6b53603087fe4..2032999d919590d44b87b87ca9c21007ac10e32e 100644 --- a/test/cmocka/unit_test_uspd.c +++ b/test/cmocka/unit_test_uspd.c @@ -675,7 +675,7 @@ static void test_api_usp_del_Device_Users_User(void **state) struct json_object *jobj, *tmp, *array_obj, *array_index_obj; struct ubus_request_data *req = ctx->req; - blobmsg_add_string(bb, "path", "Device.Users.User.[Username==\"user2\"]"); + blobmsg_add_string(bb, "path", "Device.Users.User.[Username==\"user2\"]."); blobmsg_add_string(bb, "proto", GET_PROTO); usp_add_del_handler(NULL, obj, req, "del_object", bb->head); @@ -713,7 +713,6 @@ static void test_api_usp_instances_Device_Users_User(void **state) jobj = json_object_from_file("/tmp/test.log"); assert_non_null(jobj); - printf("json(%s)\n", json_object_to_json_string(jobj)); array_obj = json_object_object_get(jobj, "parameters"); array_index_obj = json_object_array_get_idx(array_obj, 0); @@ -742,7 +741,6 @@ static void test_api_usp_instances_Device(void **state) jobj = json_object_from_file("/tmp/test.log"); assert_non_null(jobj); - printf("json(%s)\n", json_object_to_json_string(jobj)); array_obj = json_object_object_get(jobj, "parameters"); array_index_obj = json_object_array_get_idx(array_obj, 0); @@ -752,7 +750,7 @@ static void test_api_usp_instances_Device(void **state) return; } -static void test_api_usp_raw_set_safe_Device_Users_User(void **state) +static void test_api_usp_raw_set_safe_Device_wifi_alias(void **state) { int i = 0; struct test_ctx *ctx = (struct test_ctx *) *state; @@ -765,7 +763,7 @@ static void test_api_usp_raw_set_safe_Device_Users_User(void **state) paths = blobmsg_open_array(bb, "paths"); table = blobmsg_open_table(bb, NULL); blobmsg_add_string(bb, "path", "Device.WiFi.SSID.1.Alias"); - blobmsg_add_string(bb, "notify-type", "0"); + blobmsg_add_string(bb, "notify-type", "1"); blobmsg_add_string(bb, "notify", "1"); blobmsg_close_table(bb, table); blobmsg_close_array(bb, paths); @@ -803,7 +801,7 @@ static void test_api_usp_set_safe_Device_DeviceInfo_SerialNumber(void **state) paths = blobmsg_open_array(bb, "paths"); table = blobmsg_open_table(bb, NULL); blobmsg_add_string(bb, "path", "Device.DeviceInfo.SerialNumber"); - blobmsg_add_string(bb, "notify-type", "0"); + blobmsg_add_string(bb, "notify-type", "1"); blobmsg_add_string(bb, "notify", "1"); blobmsg_close_table(bb, table); blobmsg_close_array(bb, paths); @@ -1186,7 +1184,7 @@ int main(void) cmocka_unit_test_setup(test_api_usp_raw_resolve_Device_Users_User, setup), cmocka_unit_test_setup(test_api_usp_raw_add_object_Device_Users_User, setup), cmocka_unit_test_setup(test_api_usp_raw_set_Device_Users_User, setup), - cmocka_unit_test_setup(test_api_usp_raw_set_safe_Device_Users_User, setup), + cmocka_unit_test_setup(test_api_usp_raw_set_safe_Device_wifi_alias, setup), cmocka_unit_test_setup(test_api_usp_raw_del_Device_Users_User, setup), cmocka_unit_test_setup(test_api_usp_raw_operate_reset, setup), cmocka_unit_test_setup(test_api_usp_raw_object_name_Device_Users_User, setup), diff --git a/test/files/etc/config/cwmp b/test/files/etc/config/cwmp new file mode 100644 index 0000000000000000000000000000000000000000..567717d596c15b55aa3d4b9f4337950055ff3799 --- /dev/null +++ b/test/files/etc/config/cwmp @@ -0,0 +1,47 @@ +config acs 'acs' + option url '' + option userid '' #$OUI-$SER + option passwd 'iopsys' + option periodic_inform_enable 'true' + option periodic_inform_interval '1800' + option periodic_inform_time '0' + option ParameterKey '' + option dhcp_discovery 'enable' + # compression possible configs: GZIP, Deflate, Disabled + option compression 'Disabled' + # possible configs interval :[1:65535] + option retry_min_wait_interval '5' + # possible configs interval :[1000:65535] + option retry_interval_multiplier '2000' + option https_ssl_capath '' + option ipv6_enable '0' + +config cpe 'cpe' + option interface 'eth0.1' + option default_wan_interface 'wan' + option log_to_console 'disable' + option log_to_file 'enable' + # log_severity: INFO (Default) + # log_severity possible configs: EMERG, ALERT, CRITIC ,ERROR, WARNING, NOTICE, INFO, DEBUG + option log_severity 'INFO' + option log_file_name '/var/log/icwmpd.log' + option log_max_size '102400' + option userid '' #$OUI-$SER + option passwd 'iopsys' + option port '7547' + option ubus_socket '/var/run/ubus.sock' + option provisioning_code '' + option amd_version '5' + # compression possible configs: InstanceNumber, InstanceAlias + option instance_mode 'InstanceNumber' + option session_timeout '60' + option notification '1' + option datamodel 'tr181' + option exec_download '0' + option periodic_notify_enable '1' + option periodic_notify_interval '10' + +config lwn 'lwn' + option enable '1' + option hostname '' + option port '0' diff --git a/test/files/etc/config/uspd b/test/files/etc/config/uspd index 0cab0f63eb9ddbb554da4537f3436d5bc91333fd..86a3c9df97ea7f7421bab3ef6c4fcfecac702b9b 100644 --- a/test/files/etc/config/uspd +++ b/test/files/etc/config/uspd @@ -1,3 +1,3 @@ config uspd 'usp' option granularitylevel '0' - option loglevel '3' + option loglevel '1' diff --git a/test/python/validate_3272.py b/test/python/validate_3272.py new file mode 100755 index 0000000000000000000000000000000000000000..a126f69c2dca7ce0edd7a192fa5b4e9e6525beec --- /dev/null +++ b/test/python/validate_3272.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +import subprocess +import json + +TEST_NAME = "BUG_3272" + +def usp_get(path, proto = ""): + path_arg = "{\"path\":\"" + path + "\",\"proto\":\"" + proto + "\"}" + cmd = ['ubus', 'call', 'usp.raw', 'get', path_arg] + + out = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + + stdout,stderr = out.communicate() + return stdout + +# check fault code of invalid path +output = json.loads(usp_get("Device.USB.USBHosts.Host.[Enable==0].Device.")) + +for param in enumerate(output["parameters"]): + assert param[1]["parameter"].endswith("DeviceNumberOfEntries") == False, "FAIL" + TEST_NAME + +print("PASS: " + TEST_NAME) diff --git a/test/python/validate_fault_code.py b/test/python/validate_fault_code.py new file mode 100755 index 0000000000000000000000000000000000000000..cb3a6cc77b7a4cd731fae5bf08ea1280fb4102d7 --- /dev/null +++ b/test/python/validate_fault_code.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import subprocess +import json + +TEST_NAME = "Invalid path fault test" + +def usp_get(path, proto = ""): + path_arg = "{\"path\":\"" + path + "\",\"proto\":\"" + proto + "\"}" + cmd = ['ubus', 'call', 'usp.raw', 'get', path_arg] + + out = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + + stdout,stderr = out.communicate() + return stdout + +# check fault code of invalid path +output = json.loads(usp_get("Device")) +assert output["fault"] == 7026, "FAIL: " + TEST_NAME + +output = json.loads(usp_get("Device", "usp")) +assert output["fault"] == 7026, "FAIL: " + TEST_NAME + +# for cmwp proto fault should be 9005 +output = json.loads(usp_get("Device", "cwmp")) +assert output["fault"] == 9005, "FAIL: " + TEST_NAME + +print("PASS: " + TEST_NAME) diff --git a/test/python/validate_serial.py b/test/python/validate_serial.py new file mode 100755 index 0000000000000000000000000000000000000000..403024931251284c00589f2bcd4a560018f7b666 --- /dev/null +++ b/test/python/validate_serial.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +import subprocess +import json + +out = subprocess.Popen(['ubus', 'call', 'usp.raw', 'get', '{"path":"Device.DeviceInfo.SerialNumber"}'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + +stdout,stderr = out.communicate() + +jout = json.loads(stdout) + +assert jout["parameters"][0]["value"] == "000000001", "FAIL: serial number mismatch" + +print("PASS: serial number validation") diff --git a/test/python/validate_setm_notification.py b/test/python/validate_setm_notification.py new file mode 100755 index 0000000000000000000000000000000000000000..756d700718a7213055446b6b0c79b32f3d541562 --- /dev/null +++ b/test/python/validate_setm_notification.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +import subprocess +import json + +TEST_NAME = "Notification set/get test" +#ubus call usp.raw setm_attributes '{"paths":[{"path":"Device.Users.User.1.Enable","notify-type":"1","notify":"1"}]}' +#ubus call usp.raw getm_attributes '{"paths":["Device.Users.User.1.Enable"]}' + +def usp_get_attrib(path): + path_arg = "{\"paths\":[\"" + path + "\"]}" + cmd = ['ubus', 'call', 'usp.raw', 'getm_attributes', path_arg] + + out = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + + stdout,stderr = out.communicate() + return stdout + +def usp_set_attrib(path, notify_type, notify): + path_arg = "{\"paths\":[{\"path\":\"" + path + "\",\"notify-type\":\"" + notify_type + "\", \"notify\":\"" + notify + "\"}]}" + cmd = ['ubus', 'call', 'usp.raw', 'setm_attributes', path_arg] + + out = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + + stdout,stderr = out.communicate() + return stdout + +# get the attribute first +output = json.loads(usp_get_attrib("Device.Users.User.1.Enable")) +assert output["parameters"][0]["value"] == "0", "FAIL: other than default value" + TEST_NAME + +# set the attribute +output = json.loads(usp_set_attrib("Device.Users.User.1.Enable", "1", "1")) +assert output["parameters"][0]["path"] == "Device.Users.User.1.Enable", "FAIL: " + TEST_NAME + +# get the attribute and validate +output = json.loads(usp_get_attrib("Device.Users.User.1.Enable")) +assert output["parameters"][0]["value"] == "1", "FAIL: set attribute does not have effect" + TEST_NAME + +# change it back +output = json.loads(usp_set_attrib("Device.Users.User.1.Enable", "0", "1")) +assert output["parameters"][0]["path"] == "Device.Users.User.1.Enable", "FAIL: " + TEST_NAME + +# get the attribute and validate +output = json.loads(usp_get_attrib("Device.Users.User.1.Enable")) +assert output["parameters"][0]["value"] == "0", "FAIL: reset attribute does not have effect" + TEST_NAME + +print("PASS: " + TEST_NAME)