From: sphoorthi Date: Fri, 5 Mar 2021 17:42:11 +0000 (+0530) Subject: lua changes X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F25%2F5725%2F1;p=o-du%2Fl2.git lua changes Change-Id: I26becb64c0a03be6e3fe652370815846357f39fb Signed-off-by: sphoorthi --- diff --git a/src/codec_utils/e2ap.lua b/src/codec_utils/e2ap.lua index 4ce0a583f..439d70660 100644 --- a/src/codec_utils/e2ap.lua +++ b/src/codec_utils/e2ap.lua @@ -1,6 +1,7 @@ ----------------------------------------- +------------------------------------------------------------------------------------- -- script-name: e2ap.lua ----------------------------------------- +-- This script is a plugin to dissect packets that are exchanged over E2AP interface +------------------------------------------------------------------------------------- ---------------------------------------- -- creates a Proto object, but doesn't register it yet @@ -12,7 +13,7 @@ local E2apPduEnum = { [1] = "successfulOutcome", [2] = "unsuccessfulOutcome" } -local ProcedureCodeE2 = { +local E2ProcedureCode = { [1] = "ProcedureCodeE2_id_E2setup", [2] = "ProcedureCodeE2_id_ErrorIndicationE2", [3] = "ProcedureCodeE2_id_Reset", @@ -23,12 +24,12 @@ local ProcedureCodeE2 = { [8] = "ProcedureCodeE2_id_RICsubscription", [9] = "ProcedureCodeE2_id_RICsubscriptionDelete" } -local CriticalityE2 ={ +local E2Criticality ={ [0] = "CriticalityE2_reject", [1] = "CriticalityE2_ignore", [2] = "CriticalityE2_notify" } -local InitiatingMessageE2ValuePrEnum = { +local E2InitiatingMessagePresenceEnum = { [0] = "InitiatingMessageE2__value_PR_NOTHING", [1] = "InitiatingMessageE2__value_PR_RICsubscriptionRequest", [2] = "InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequest", @@ -80,7 +81,7 @@ local E2PotocolIEs = { local RIC_indication = "Ric Indication Message" local Initiating_Message_Type_Value = { - value = "value"--, nil,InitiatingMessageE2ValuePrEnum, 0xFF) + value = "value"--, nil,E2InitiatingMessagePresenceEnum, 0xFF) } local InitiatingMessageE2 = { @@ -92,14 +93,14 @@ local InitiatingMessageE2 = { local InitiatingMessageE2__value_u = { RICsubscriptionRequest = "RIC subscription Request", -RICsubscriptionDeleteRequest = "RIC subscription Delete Request", -RICserviceUpdate = "RIC service Update", -RICcontrolRequest = "RIC control Request", -E2setupRequest = "E2 setup Request", -ResetRequest = "Reset Request", -RICindication = "RIC indication", -RICserviceQuery = "RIC service Query", -ErrorIndicationE2 = "Error Indication E2" +RICsubscriptionDeleteRequest = "RIC subscription Delete Request", +RICserviceUpdate = "RIC service Update", +RICcontrolRequest = "RIC control Request", +E2setupRequest = "E2 setup Request", +ResetRequest = "Reset Request", +RICindication = "RIC indication", +RICserviceQuery = "RIC service Query", +ErrorIndicationE2 = "Error Indication E2" } local successfulOutcomeE2 = { @@ -107,7 +108,7 @@ local successfulOutcomeE2 = { procedureCode = "procedureCode: ", criticality = "criticality: ", valueLen = "Value Length: ", - value = "Value" + value = "value" } local e2SetupResponse = "E2SetupResponse" @@ -132,18 +133,18 @@ function fetch2Bytes(tvbuf, offset) local result = bit.bor(fbyte1, sbyte) return result end -function addE2apInitiatingMessageToTree(tvbuf, tree, offset, endianness) +function addE2apInitiatingMessageToTree(tvbuf, pktinfo, tree, offset, endianness) local info = tvbuf:range(offset, 1) local initiatingMessageE2Tree = tree:add(info, InitiatingMessageE2.Initiating_Message_E2) local procId = tvbuf:range(offset,1):le_uint() - strId = tostring(ProcedureCodeE2[procId]) .. " (" .. tostring(procId) ..")" + strId = tostring(E2ProcedureCode[procId]) .. " (" .. tostring(procId) ..")" tree:add(tvbuf:range(offset,1), InitiatingMessageE2.procedureCode .. strId) offset = offset + 1 local criticalityId = tvbuf:range(offset,1):le_uint() - strId = tostring(CriticalityE2[criticalityId]) .. " (" .. tostring(criticalityId) ..")" + strId = tostring(E2Criticality[criticalityId]) .. " (" .. tostring(criticalityId) ..")" tree:add(tvbuf:range(offset,1), InitiatingMessageE2.criticality .. strId) offset = offset + 1 @@ -155,73 +156,75 @@ end function addGobalRICIdToTree(tvbuf, valueTree, offset, valueLen, endianness) end -function addE2SetupResponseToTree(tvbuf, valueTree, offset, pktlen, endianness) +function addE2SetupResponseToTree(tvbuf, pktinfo, valueTree, offset, pktlen, endianness) + pktinfo.cols.info:set("E2 Setup Response") + local e2SetupResponseTree = valueTree:add(tvbuf:range(offset, pktlen), e2SetupResponse) - local extBit = tvbuf:range(offset,1):le_uint() - if(extBit == 0) then - e2SetupResponseTree:add(tvbuf:range(offset,1), "<" .. extBit .. "... .... Extension Bit: FALSE>") - else - e2SetupResponseTree:add(tvbuf:range(offset,1), "<" .. extBit .. "... .... Extension Bit: TRUE>") - end - offset = offset + 1 +-- local extBit = tvbuf:range(offset,1):le_uint() +-- if(extBit == 0) then +-- e2SetupResponseTree:add(tvbuf:range(offset,1), "<" .. extBit .. "... .... Extension Bit: FALSE>") +-- else +-- e2SetupResponseTree:add(tvbuf:range(offset,1), "<" .. extBit .. "... .... Extension Bit: TRUE>") +-- end + offset = offset + 1 - local seqLen = fetch2Bytes(tvbuf, offset) - e2SetupResponseTree:add(tvbuf:range(offset, 2), "") - local protoIeTree = e2SetupResponseTree:add(tvbuf:range(offset, 2), protocolIE .. seqLen .. " items") - offset = offset + 2 + local seqLen = fetch2Bytes(tvbuf, offset) +-- e2SetupResponseTree:add(tvbuf:range(offset, 2), "") + local protoIeTree = e2SetupResponseTree:add(tvbuf:range(offset, 2), protocolIE .. seqLen .. " items") + offset = offset + 2 - for ie=0, seqLen-1, 1 - do - local protocolIEId = fetch2Bytes(tvbuf, offset) - strId = tostring(E2PotocolIEs[protocolIEId]) - local itemTree = protoIeTree:add(protocolItem .. ie .. ": " .. strId) + for ie=0, seqLen-1, 1 + do + local protocolIEId = fetch2Bytes(tvbuf, offset) + strId = tostring(E2PotocolIEs[protocolIEId]) + local itemTree = protoIeTree:add(protocolItem .. ie .. ": " .. strId) + + strId = strId .. " (" .. tostring(protocolIEId) ..")" + local protocolFieldTree = itemTree:add(tvbuf:range(offset,2), protocolIEField.protocolIEFieldMsg) + protocolFieldTree:add(protocolIEField.id .. strId) + offset = offset + 2 - strId = strId .. " (" .. tostring(protocolIEId) ..")" - local protocolFieldTree = itemTree:add(tvbuf:range(offset,2), protocolIEField.protocolIEFieldMsg) - protocolFieldTree:add(protocolIEField.id .. strId) - offset = offset + 2 - - local criticalityId = tvbuf:range(offset,1):le_uint() - protocolFieldTree:add(tvbuf:range(offset,1), "") - strId = tostring(CriticalityE2[criticalityId]) .. " (" .. tostring(criticalityId) ..")" - protocolFieldTree:add(tvbuf:range(offset,1), protocolIEField.criticality .. strId) - offset = offset + 1 - - local valueLen = tvbuf:range(offset,1):le_uint() - protocolFieldTree:add(tvbuf:range(offset,1), "<" .. protocolIEField.valueLen .. valueLen ..">") - offset = offset + 1 - - local valueTree = protocolFieldTree:add(tvbuf:range(offset, valueLen), protocolIEField.value) - - if(protocolIEId == 4) then - addGobalRICIdToTree(tvbuf, valueTree, offset, valueLen, endianness) - end - end -end - -function addE2apSuccessfulOutcomeToTree(tvbuf, tree, offset, pktlen, endianness) - local successfulOutcomeTree = tree:add(tvbuf:range(offset, (pktlen-offset)), successfulOutcomeE2.successOutcomeMsg) - local procId = tvbuf:range(offset,1):le_uint() - strId = tostring(ProcedureCodeE2[procId]) .. " (" .. tostring(procId) ..")" - successfulOutcomeTree:add(tvbuf:range(offset,1), successfulOutcomeE2.procedureCode .. strId) - offset = offset + 1 - local criticalityId = tvbuf:range(offset,1):le_uint() - successfulOutcomeTree:add(tvbuf:range(offset,1), "") - strId = tostring(CriticalityE2[criticalityId]) .. " (" .. tostring(criticalityId) ..")" - successfulOutcomeTree:add(tvbuf:range(offset,1), successfulOutcomeE2.criticality .. strId) - offset = offset + 1 +-- protocolFieldTree:add(tvbuf:range(offset,1), "") + strId = tostring(E2Criticality[criticalityId]) .. " (" .. tostring(criticalityId) ..")" + protocolFieldTree:add(tvbuf:range(offset,1), protocolIEField.criticality .. strId) + offset = offset + 1 local valueLen = tvbuf:range(offset,1):le_uint() - successfulOutcomeTree:add(tvbuf:range(offset,1), "<" .. successfulOutcomeE2.valueLen .. valueLen ..">") +-- protocolFieldTree:add(tvbuf:range(offset,1), "<" .. protocolIEField.valueLen .. valueLen ..">") offset = offset + 1 - local valueTree = successfulOutcomeTree:add(tvbuf:range(offset, valueLen), successfulOutcomeE2.value) + local valueTree = protocolFieldTree:add(tvbuf:range(offset, valueLen), protocolIEField.value) - if(procId == 1) then - addE2SetupResponseToTree(tvbuf, valueTree, offset, valueLen, endianness) + if(protocolIEId == 4) then + addGobalRICIdToTree(tvbuf, valueTree, offset, valueLen, endianness) end + end +end + +function addE2apSuccessfulOutcomeToTree(tvbuf, pktinfo, tree, offset, pktlen, endianness) + local successfulOutcomeTree = tree:add(tvbuf:range(offset, (pktlen-offset)), successfulOutcomeE2.successOutcomeMsg) + local procId = tvbuf:range(offset,1):le_uint() + strId = tostring(E2ProcedureCode[procId]) .. " (" .. tostring(procId) ..")" + successfulOutcomeTree:add(tvbuf:range(offset,1), successfulOutcomeE2.procedureCode .. strId) + offset = offset + 1 + + local criticalityId = tvbuf:range(offset,1):le_uint() +-- successfulOutcomeTree:add(tvbuf:range(offset,1), "") + strId = tostring(E2Criticality[criticalityId]) .. " (" .. tostring(criticalityId) ..")" + successfulOutcomeTree:add(tvbuf:range(offset,1), successfulOutcomeE2.criticality .. strId) + offset = offset + 1 + + local valueLen = tvbuf:range(offset,1):le_uint() +-- successfulOutcomeTree:add(tvbuf:range(offset,1), "<" .. successfulOutcomeE2.valueLen .. valueLen ..">") + offset = offset + 1 + + local valueTree = successfulOutcomeTree:add(tvbuf:range(offset, valueLen), successfulOutcomeE2.value) + + if(procId == 1) then + addE2SetupResponseToTree(tvbuf, pktinfo, valueTree, offset, valueLen, endianness) + end end ---------------------------------------- -- The following creates the callback function for the dissector. @@ -249,18 +252,18 @@ function E2AP.dissector(tvbuf,pktinfo,root) -- Now let's add our protocol header fields under the protocol tree we just created. local fByte = tvbuf:range(offset,1):le_uint() - local apiId = bit.rshift(fByte, 5) - tree:add(tvbuf:range(offset,1), "") + local apiId = bit.rshift(fByte, 5) +-- tree:add(tvbuf:range(offset,1), "") strId = tostring(E2apPduEnum[apiId]) .. " (" .. tostring(apiId) ..")" - tree:add(tvbuf:range(offset,1), "E2AP-PDU: " .. strId) + local e2apTree = tree:add(tvbuf:range(offset,1), "E2AP-PDU: " .. strId) offset = offset + 1 -- Now let's add our protocol fields under the protocol tree we just created. if (apiId == 0) then - addE2apInitiatingMessageToTree(tvbuf, tree, offset, endianness) + addE2apInitiatingMessageToTree(tvbuf, pktinfo, e2apTree, offset, endianness) end if(apiId == 1) then - addE2apSuccessfulOutcomeToTree(tvbuf, tree, offset, pktlen, endianness) + addE2apSuccessfulOutcomeToTree(tvbuf, pktinfo, e2apTree, offset, pktlen, endianness) end end -- end of dissector funciton