RICAPP-222 :- ASN decoders for kpm ran function description and asn encoders for... 38/12138/1
authorsandeepindia <kumar.sandeep3@hcl.com>
Wed, 29 Nov 2023 17:28:18 +0000 (17:28 +0000)
committersandeepindia <kumar.sandeep3@hcl.com>
Wed, 29 Nov 2023 17:28:18 +0000 (17:28 +0000)
Change-Id: Ic0e288d699ac1b88739ef21a194cd39a3b66d36b
Signed-off-by: sandeepindia <kumar.sandeep3@hcl.com>
Dockerfile
control/control.go
e2sm/wrapper.c
e2sm/wrapper.h

index 09ea30a..9a533c2 100644 (file)
@@ -2,6 +2,9 @@
 FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 as build-kpimon
 WORKDIR /opt
 # Install RMR client
+#COPY bin/rmr* ./
+#RUN dpkg -i rmr_4.8.0_amd64.deb; dpkg -i rmr-dev_4.8.0_amd64.deb; rm rmr*
+# Install RMR client
 ARG RMRVERSION=4.9.0
 RUN wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr_${RMRVERSION}_amd64.deb
 RUN wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb
index acb8d59..3a17cd9 100644 (file)
@@ -1,5 +1,4 @@
 package control\r
-\r
 /*\r
 #include <e2sm/wrapper.h>\r
 #cgo LDFLAGS: -le2smwrapper -lm\r
@@ -7,26 +6,26 @@ package control
 */\r
 import "C"\r
 \r
+import (\r
+       "unsafe"\r
+)\r
+\r
 import (\r
        "context"\r
-       "encoding/base64"\r
        "encoding/json"\r
-       "errors"\r
-       "fmt"\r
        "log"\r
        "net/http"\r
-       "reflect"\r
+       "time"\r
+//     "bytes"\r
+//     "encoding/binary"\r
        "strconv"\r
+       "encoding/base64"\r
        "strings"\r
-       "time"\r
-       "unsafe"\r
-\r
+       "fmt"\r
+       "reflect"\r
+       "errors"\r
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"\r
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"\r
-\r
-       //      "bytes"\r
-       //      "encoding/binary"\r
-\r
        influxdb2 "github.com/influxdata/influxdb-client-go"\r
 )\r
 \r
@@ -41,13 +40,12 @@ var (
        actionType           = "report"\r
        actionId             = int64(1)\r
        seqId                = int64(1)\r
-       funcId               = int64(0)\r
+       funcId               = int64(2)\r
        hPort                = int64(8080)\r
        rPort                = int64(4560)\r
        clientEndpoint       = clientmodel.SubscriptionParamsClientEndpoint{Host: "service-ricxapp-kpimon-go-http.ricxapp", HTTPPort: &hPort, RMRPort: &rPort}\r
 )\r
 var Glob_cell = make(map[string]bool)\r
-\r
 func (c Control) Consume(msg *xapp.RMRParams) error {\r
        id := xapp.Rmr.GetRicMessageName(msg.Mtype)\r
        xapp.Logger.Info(\r
@@ -88,9 +86,9 @@ func (c Control) getEnbList() ([]*xapp.RNIBNbIdentity, error) {
                return nil, err\r
        }\r
 \r
-       xapp.Logger.Info("There are %d connected eNBs", len(enbs))\r
+       xapp.Logger.Info("List for connected eNBs :")\r
        for index, enb := range enbs {\r
-               xapp.Logger.Debug("%d. enbid: %s", index+1, enb.InventoryName)\r
+               xapp.Logger.Info("%d. enbid: %s", index+1, enb.InventoryName)\r
        }\r
        return enbs, nil\r
 }\r
@@ -102,9 +100,9 @@ func (c *Control) getGnbList() ([]*xapp.RNIBNbIdentity, error) {
                xapp.Logger.Error("err: %s", err)\r
                return nil, err\r
        }\r
-       xapp.Logger.Info("There are %d connected gNBs", len(gnbs))\r
+       xapp.Logger.Info("List of connected gNBs :")\r
        for index, gnb := range gnbs {\r
-               xapp.Logger.Debug("%d. gnbid : %s", index+1, gnb.InventoryName)\r
+               xapp.Logger.Info("%d. gnbid : %s", index+1, gnb.InventoryName)\r
        }\r
        return gnbs, nil\r
 }\r
@@ -149,26 +147,55 @@ func plmnid_to_list_of_int(str string) []int64 {
        }\r
        return ans\r
 }\r
-func encode_action_format1(plmn string, cellid string) clientmodel.ActionDefinition {\r
+func encode_action_format1(plmn string, cellid string, meid string) clientmodel.ActionDefinition {\r
        lol1 := plmnid_to_list_of_int(plmn)\r
        lol2 := cellid_to_list_of_int(cellid)\r
        var format1 []int64\r
        //format1=[]int64{0,1,1,8,0,19,32,0,3,1,32,0,0,32,0,4,1,32,0,0,32,0,78,1,32,0,0,32,0,79,1,32,0,0,32,0,8,1,32,0,0,32,0,7,1,32,0,0,32,0,11,1,32,0,0,32,0,12,1,32,0,0,32,0,80,1,32,0,0,32,0,81,1,32,0,0,32,0,13,1,32,0,0,32,0,14,1,32,0,0,32,0,40,1,32,0,0,32,0,41,1,32,0,0,32,0,42,1,32,0,0,32,0,82,1,32,0,0,32,0,83,1,32,0,0,32,0,84,1,32,0,0,32,0,85,1,32,0,0,32,0,86,1,32,0,0,64,39,15,0,0,31,1,18,52,92,0,16}\r
        //0(nr) 1(eutra)  0,31,1(plmn)18,52,92,0,16(cellid)\r
+       link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"\r
+       \r
+       link=link+meid\r
+       tmpr,err := http.Get(link)\r
+       if err != nil {\r
+               log.Fatalln(err)\r
+               l:=[]int64{0}\r
+               return l\r
+       }\r
+       defer tmpr.Body.Close()\r
+       var resp E2mgrResponse\r
 \r
-       //for simulation-by measID (not supported in viavi 1.4)\r
-       //format1=[]int64{0,1,1,8,0,22,32,0,3,1,32,0,0,32,0,4,1,32,0,0,32,0,78,1,32,0,0,32,0,79,1,32,0,0,32,0,80,1,32,0,0,32,0,81,1,32,0,0,32,0,8,1,32,0,0,32,0,7,1,32,0,0,32,0,11,1,32,0,0,32,0,12,1,32,0,0,32,0,82,1,32,0,0,32,0,83,1,32,0,0,32,0,13,1,32,0,0,32,0,14,1,32,0,0,32,0,40,1,32,0,0,32,0,41,1,32,0,0,32,0,42,1,32,0,0,32,0,84,1,32,0,0,32,0,85,1,32,0,0,32,0,86,1,32,0,0,32,0,87,1,32,0,0,32,0,88,1,32,0,0,32,0,89,1,32,0,0,64,39,15,0}//assuming nr cells\r
-\r
-       //for simulation-by measName(supported in Viavi 1.4)\r
-       format1 = []int64{0, 1, 1, 8, 0, 22, 0, 160, 68, 82, 66, 46, 85, 69, 84, 104, 112, 68, 108, 1, 32, 0, 0, 0, 160, 68, 82, 66, 46, 85, 69, 84, 104, 112, 85, 108, 1, 32, 0, 0, 0, 176, 80, 69, 69, 46, 65, 118, 103, 80, 111, 119, 101, 114, 1, 32, 0, 0, 0, 144, 80, 69, 69, 46, 69, 110, 101, 114, 103, 121, 1, 32, 0, 0, 1, 144, 81, 111, 115, 70, 108, 111, 119, 46, 84, 111, 116, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 68, 108, 1, 32, 0, 0, 1, 144, 81, 111, 115, 70, 108, 111, 119, 46, 84, 111, 116, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 85, 108, 1, 32, 0, 0, 0, 160, 82, 82, 67, 46, 67, 111, 110, 110, 77, 97, 120, 1, 32, 0, 0, 0, 176, 82, 82, 67, 46, 67, 111, 110, 110, 77, 101, 97, 110, 1, 32, 0, 0, 0, 208, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 68, 108, 1, 32, 0, 0, 0, 208, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 85, 108, 1, 32, 0, 0, 0, 176, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 68, 108, 1, 32, 0, 0, 0, 176, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 85, 108, 1, 32, 0, 0, 0, 192, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 68, 108, 1, 32, 0, 0, 0, 192, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 85, 108, 1, 32, 0, 0, 0, 160, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 120, 1, 32, 0, 0, 0, 160, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 121, 1, 32, 0, 0, 0, 160, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 122, 1, 32, 0, 0, 0, 192, 86, 105, 97, 118, 105, 46, 71, 110, 98, 68, 117, 73, 100, 1, 32, 0, 0, 0, 160, 86, 105, 97, 118, 105, 46, 78, 114, 67, 103, 105, 1, 32, 0, 0, 0, 160, 86, 105, 97, 118, 105, 46, 78, 114, 80, 99, 105, 1, 32, 0, 0, 1, 96, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 97, 110, 116, 101, 110, 110, 97, 84, 121, 112, 101, 1, 32, 0, 0, 1, 32, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 97, 122, 105, 109, 117, 116, 104, 1, 32, 0, 0, 1, 0, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 112, 111, 119, 101, 114, 1, 32, 0, 0, 64, 39, 15, 0} //assuming nr cells\r
-       //for e2test\r
-       // format1=[]int64{0,1,1,8,0,42,32,0,0,1,32,0,0,32,0,1,1,32,0,0,32,0,2,1,32,0,0,32,0,3,1,32,0,0,32,0,4,1,32,0,0,32,0,5,1,32,0,0,32,0,6,1,32,0,0,32,0,7,1,32,0,0,32,0,8,1,32,0,0,32,0,9,1,32,0,0,32,0,10,1,32,0,0,32,0,11,1,32,0,0,32,0,12,1,32,0,0,32,0,13,1,32,0,0,32,0,14,1,32,0,0,32,0,15,1,32,0,0,32,0,16,1,32,0,0,32,0,17,1,32,0,0,32,0,18,1,32,0,0,32,0,19,1,32,0,0,32,0,20,1,32,0,0,32,0,21,1,32,0,0,32,0,22,1,32,0,0,32,0,23,1,32,0,0,32,0,24,1,32,0,0,32,0,25,1,32,0,0,32,0,26,1,32,0,0,32,0,27,1,32,0,0,32,0,28,1,32,0,0,32,0,29,1,32,0,0,32,0,30,1,32,0,0,32,0,31,1,32,0,0,32,0,32,1,32,0,0,32,0,33,1,32,0,0,32,0,34,1,32,0,0,32,0,35,1,32,0,0,32,0,36,1,32,0,0,32,0,37,1,32,0,0,32,0,38,1,32,0,0,32,0,39,1,32,0,0,32,0,40,1,32,0,0,32,0,41,1,32,0,0,32,0,42,1,32,0,0,64,39,15,0}\r
+       err=json.NewDecoder(tmpr.Body).Decode(&resp)\r
+       if err != nil {\r
+                log.Fatalln(err)\r
+                l:=[]int64{0}\r
+                return l\r
+\r
+        }\r
+       counter:=0\r
+       //RanFunctionId=2 for kpm in viavi\r
+       for i := 0; i < len(resp.Gnb.RanFunctions); i++ {\r
+               if resp.Gnb.RanFunctions[i].RanFunctionId  == 2 {\r
+                       counter = i\r
+                       break\r
+               }\r
+       }\r
+       cString := C.CString(resp.Gnb.RanFunctions[counter].RanFunctionDefinition)\r
+       defer C.free(unsafe.Pointer(cString)) // Free the allocated C string when done\r
+       // Call the C function\r
+       determine := 2 //2 for format1 by name\r
+       result:=C.encode_action_Definition(cString, C.int(determine))\r
+       \r
+       for i := 0; i < int(result.length); i++ {\r
+               value := int64(*(*int64)(unsafe.Pointer(uintptr(unsafe.Pointer(result.array)) + uintptr(i*8))))\r
+               format1 = append(format1, value)\r
+       }\r
        format1 = append(format1, lol1...) //appending plmn\r
-       format1 = append(format1, lol2...) //appending cellid\r
+        format1 = append(format1, lol2...) //appending cellid\r
        return format1\r
 }\r
 \r
-func encode_action_format2() clientmodel.ActionDefinition {\r
+func encode_action_format2() clientmodel.ActionDefinition{\r
        var format2 []int64\r
        format2 = []int64{0, 1, 0, 0, 0, 20, 0, 160, 68, 82, 66, 46, 85, 69, 84, 104, 112, 68, 108, 1, 0, 0, 0, 1, 64, 68, 82, 66, 46, 85, 69, 84, 104, 112, 85, 108, 1, 0, 0, 0, 1, 0, 71, 78, 66, 45, 68, 85, 45, 73, 68, 1, 0, 0, 0, 0, 160, 78, 82, 45, 67, 71, 73, 1, 0, 0, 0, 0, 160, 78, 82, 45, 80, 67, 73, 1, 0, 0, 0, 2, 192, 81, 111, 115, 70, 108, 111, 119, 46, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 68, 108, 1, 0, 0, 0, 2, 192, 81, 111, 115, 70, 108, 111, 119, 46, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 85, 108, 1, 0, 0, 0, 1, 64, 82, 82, 67, 46, 67, 111, 110, 110, 77, 97, 120, 1, 0, 0, 0, 1, 96, 82, 82, 67, 46, 67, 111, 110, 110, 77, 101, 97, 110, 1, 0, 0, 0, 1, 160, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 68, 108, 1, 0, 0, 0, 1, 160, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 85, 108, 1, 0, 0, 0, 1, 32, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 1, 0, 0, 0, 1, 96, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 68, 108, 1, 0, 0, 0, 1, 96, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 85, 108, 1, 0, 0, 0, 1, 128, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 68, 108, 1, 0, 0, 0, 1, 128, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 85, 108, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 120, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 121, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 122, 1, 0, 0, 0, 2, 0, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 112, 111, 119, 101, 114, 1, 0, 0, 0, 2, 64, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 115, 101, 99, 116, 111, 114, 115, 1, 0, 0, 0, 0, 0}\r
        //encode the variable part and append it to our array.\r
@@ -176,41 +203,75 @@ func encode_action_format2() clientmodel.ActionDefinition {
        return format2\r
 }\r
 \r
-func encode_action_format3() clientmodel.ActionDefinition {\r
+func encode_action_format3(meid string) clientmodel.ActionDefinition {\r
        var format3 []int64\r
 \r
        //for simulation-by measId(not supported in Viavi 1.4)\r
        //format3=[]int64{0,1,3,64,0,29,32,0,90,0,0,16,0,0,16,0,91,0,0,16,0,0,16,0,3,0,0,16,0,0,16,0,4,0,0,16,0,0,16,0,80,0,0,16,0,0,16,0,13,0,0,16,0,0,16,0,14,0,0,16,0,0,16,0,92,0,0,16,0,0,16,0,93,0,0,16,0,0,16,0,44,0,0,16,0,0,16,0,40,0,0,16,0,0,16,0,41,0,0,16,0,0,16,0,42,0,0,16,0,0,16,0,94,0,0,16,0,0,16,0,95,0,0,16,0,0,16,0,96,0,0,16,0,0,16,0,97,0,0,16,0,0,16,0,45,0,0,16,0,0,16,0,98,0,0,16,0,0,16,0,99,0,0,16,0,0,16,0,100,0,0,16,0,0,16,0,101,0,0,16,0,0,16,0,102,0,0,16,0,0,16,0,103,0,0,16,0,0,16,0,104,0,0,16,0,0,16,0,43,0,0,16,0,0,16,0,105,0,0,16,0,0,16,0,106,0,0,16,0,0,16,0,107,0,0,16,0,0,16,0,108,0,0,16,0,0,32,39,15}\r
        //variable part is not presetnt in action def format 3\r
+       \r
+       link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"\r
+        link=link+meid\r
+        tmpr,err := http.Get(link)\r
+        if err != nil {\r
+                log.Fatalln(err)\r
+                l:=[]int64{0}\r
+                return l\r
+\r
+        }\r
+        defer tmpr.Body.Close()\r
+        var resp E2mgrResponse\r
+\r
+        err=json.NewDecoder(tmpr.Body).Decode(&resp)\r
+        if err != nil {\r
+                log.Fatalln(err)\r
+                l:=[]int64{0}\r
+                return l\r
+\r
+        }\r
+       counter:=0\r
+        //RanFunctionId=2 for kpm in viavi\r
+        for i := 0; i < len(resp.Gnb.RanFunctions); i++ {\r
+                if resp.Gnb.RanFunctions[i].RanFunctionId  == 2 {\r
+                        counter = i\r
+                        break\r
+                }\r
+        }\r
+        cString := C.CString(resp.Gnb.RanFunctions[counter].RanFunctionDefinition)\r
+        defer C.free(unsafe.Pointer(cString)) // Free the allocated C string when done\r
+        // Call the C function\r
+        determine := 4 //2 for format1 by name\r
+       \r
+       result:=C.encode_action_Definition(cString, C.int(determine))\r
+        for i := 0; i < int(result.length); i++ {\r
+                value := int64(*(*int64)(unsafe.Pointer(uintptr(unsafe.Pointer(result.array)) + uintptr(i*8))))\r
+               format3 = append(format3, value)\r
+\r
+        }\r
 \r
-       //for simulation-by measName(supported in Viavi 1.4)\r
-       format3 = []int64{0, 1, 3, 64, 0, 29, 0, 160, 68, 82, 66, 46, 85, 69, 67, 113, 105, 68, 108, 0, 0, 16, 0, 0, 0, 80, 68, 82, 66, 46, 85, 69, 67, 113, 105, 85, 108, 0, 0, 16, 0, 0, 0, 80, 68, 82, 66, 46, 85, 69, 84, 104, 112, 68, 108, 0, 0, 16, 0, 0, 0, 80, 68, 82, 66, 46, 85, 69, 84, 104, 112, 85, 108, 0, 0, 16, 0, 0, 0, 200, 81, 111, 115, 70, 108, 111, 119, 46, 84, 111, 116, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 68, 108, 0, 0, 16, 0, 0, 0, 96, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 68, 108, 0, 0, 16, 0, 0, 0, 96, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 85, 108, 0, 0, 16, 0, 0, 0, 80, 84, 66, 46, 84, 111, 116, 78, 98, 114, 68, 108, 0, 0, 16, 0, 0, 0, 80, 84, 66, 46, 84, 111, 116, 78, 98, 114, 85, 108, 0, 0, 16, 0, 0, 0, 96, 86, 105, 97, 118, 105, 46, 67, 101, 108, 108, 46, 105, 100, 0, 0, 16, 0, 0, 0, 80, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 120, 0, 0, 16, 0, 0, 0, 80, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 121, 0, 0, 16, 0, 0, 0, 80, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 122, 0, 0, 16, 0, 0, 0, 96, 86, 105, 97, 118, 105, 46, 81, 111, 83, 46, 53, 113, 105, 0, 0, 16, 0, 0, 0, 120, 86, 105, 97, 118, 105, 46, 81, 111, 83, 46, 67, 101, 108, 108, 73, 100, 0, 0, 16, 0, 0, 0, 112, 86, 105, 97, 118, 105, 46, 81, 111, 83, 46, 68, 114, 98, 73, 100, 0, 0, 16, 0, 0, 0, 104, 86, 105, 97, 118, 105, 46, 81, 111, 83, 46, 71, 102, 98, 114, 0, 0, 16, 0, 0, 0, 104, 86, 105, 97, 118, 105, 46, 83, 108, 105, 99, 101, 46, 105, 100, 0, 0, 16, 0, 0, 0, 112, 86, 105, 97, 118, 105, 46, 85, 69, 46, 66, 101, 97, 109, 73, 100, 0, 0, 16, 0, 0, 0, 128, 86, 105, 97, 118, 105, 46, 85, 69, 46, 70, 114, 97, 109, 101, 67, 110, 116, 0, 0, 16, 0, 0, 0, 112, 86, 105, 97, 118, 105, 46, 85, 69, 46, 82, 115, 83, 105, 110, 114, 0, 0, 16, 0, 0, 0, 96, 86, 105, 97, 118, 105, 46, 85, 69, 46, 82, 115, 114, 112, 0, 0, 16, 0, 0, 0, 96, 86, 105, 97, 118, 105, 46, 85, 69, 46, 82, 115, 114, 113, 0, 0, 16, 0, 0, 0, 112, 86, 105, 97, 118, 105, 46, 85, 69, 46, 84, 99, 82, 110, 116, 105, 0, 0, 16, 0, 0, 0, 136, 86, 105, 97, 118, 105, 46, 85, 69, 46, 97, 110, 111, 109, 97, 108, 105, 101, 115, 0, 0, 16, 0, 0, 0, 80, 86, 105, 97, 118, 105, 46, 85, 69, 46, 105, 100, 0, 0, 16, 0, 0, 0, 184, 86, 105, 97, 118, 105, 46, 85, 69, 46, 115, 101, 114, 118, 105, 110, 103, 68, 105, 115, 116, 97, 110, 99, 101, 0, 0, 16, 0, 0, 0, 104, 86, 105, 97, 118, 105, 46, 85, 69, 46, 115, 112, 101, 101, 100, 0, 0, 16, 0, 0, 0, 208, 86, 105, 97, 118, 105, 46, 85, 69, 46, 116, 97, 114, 103, 101, 116, 84, 104, 114, 111, 117, 103, 104, 112, 117, 116, 68, 108, 0, 0, 16, 0, 0, 0, 208, 86, 105, 97, 118, 105, 46, 85, 69, 46, 116, 97, 114, 103, 101, 116, 84, 104, 114, 111, 117, 103, 104, 112, 117, 116, 85, 108, 0, 0, 16, 0, 0, 32, 39, 15}\r
-\r
-       //variable part is not presetnt in action def format 3\r
 \r
-       //for e2test\r
-       //format3=[]int64{0,1,3,64,0,62,32,0,43,0,0,16,0,0,16,0,44,0,0,16,0,0,16,0,45,0,0,16,0,0,16,0,3,0,0,16,0,0,16,0,4,0,0,16,0,0,16,0,13,0,0,16,0,0,16,0,14,0,0,16,0,0,16,0,46,0,0,16,0,0,16,0,47,0,0,16,0,0,16,0,48,0,0,16,0,0,16,0,49,0,0,16,0,0,16,0,50,0,0,16,0,0,16,0,51,0,0,16,0,0,16,0,52,0,0,16,0,0,16,0,53,0,0,16,0,0,16,0,54,0,0,16,0,0,16,0,55,0,0,16,0,0,16,0,56,0,0,16,0,0,16,0,57,0,0,16,0,0,16,0,58,0,0,16,0,0,16,0,59,0,0,16,0,0,16,0,60,0,0,16,0,0,16,0,61,0,0,16,0,0,16,0,62,0,0,16,0,0,16,0,63,0,0,16,0,0,16,0,64,0,0,16,0,0,16,0,65,0,0,16,0,0,16,0,66,0,0,16,0,0,16,0,67,0,0,16,0,0,16,0,68,0,0,16,0,0,16,0,69,0,0,16,0,0,16,0,70,0,0,16,0,0,16,0,71,0,0,16,0,0,16,0,72,0,0,16,0,0,16,0,73,0,0,16,0,0,16,0,74,0,0,16,0,0,16,0,75,0,0,16,0,0,16,0,76,0,0,16,0,0,16,0,77,0,0,16,0,0,16,0,27,0,0,16,0,0,16,0,19,0,0,16,0,0,16,0,26,0,0,16,0,0,16,0,39,0,0,16,0,0,16,0,15,0,0,16,0,0,16,0,16,0,0,16,0,0,16,0,17,0,0,16,0,0,16,0,18,0,0,16,0,0,16,0,20,0,0,16,0,0,16,0,21,0,0,16,0,0,16,0,22,0,0,16,0,0,16,0,23,0,0,16,0,0,16,0,28,0,0,16,0,0,16,0,29,0,0,16,0,0,16,0,30,0,0,16,0,0,16,0,31,0,0,16,0,0,16,0,32,0,0,16,0,0,16,0,33,0,0,16,0,0,16,0,34,0,0,16,0,0,16,0,35,0,0,16,0,0,16,0,36,0,0,16,0,0,16,0,40,0,0,16,0,0,16,0,41,0,0,16,0,0,16,0,42,0,0,16,0,0,32,39,15}\r
        //variable part is not presetnt in action def format 3\r
        return format3\r
 }\r
 func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {\r
        var l clientmodel.ActionsToBeSetup\r
-       link := "http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"\r
-       link = link + meid\r
-       tmpr, err := http.Get(link)\r
+       link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"\r
+       link=link+meid\r
+       tmpr,err := http.Get(link)\r
        if err != nil {\r
-               log.Fatalln(err)\r
-               return l\r
+               log.Fatalln(err)\r
+               return l\r
        }\r
        defer tmpr.Body.Close()\r
        var resp E2mgrResponse\r
-\r
-       err = json.NewDecoder(tmpr.Body).Decode(&resp)\r
+       \r
+       err=json.NewDecoder(tmpr.Body).Decode(&resp)\r
        if err != nil {\r
-               log.Fatalln(err)\r
-               return l\r
-       }\r
+                log.Fatalln(err)\r
+                return l\r
+        }\r
 \r
+       \r
        counter := 0\r
        for i := 0; i < len(resp.Gnb.NodeConfigs); i++ {\r
                if resp.Gnb.NodeConfigs[i].E2nodeComponentInterfaceType == "f1" {\r
@@ -222,7 +283,7 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
        base64Text := make([]byte, base64.StdEncoding.DecodedLen(len(tm)))\r
        nl, _ := base64.StdEncoding.Decode(base64Text, []byte(tm))\r
        message := string(base64Text[:nl])\r
-\r
+       \r
        counter = 0\r
        for i := 0; i < len(meid); i++ {\r
                if meid[i] == '_' {\r
@@ -233,14 +294,14 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
                        break\r
                }\r
        }\r
-\r
+       \r
        ans := strings.ToUpper(meid[counter:len(meid)])\r
        l1 := int64(len(message))\r
        l2 := int64(len(ans))\r
        var cells []string\r
        for i := int64(0); i <= l1-l2; i++ {\r
                if strings.Contains(message[i:i+l2], ans) {\r
-                       Glob_cell[message[i:i+10]] = true\r
+                       Glob_cell[message[i:i+10]]=true\r
                        cells = append(cells, message[i:i+10])\r
                        fmt.Println(message[i : i+10])\r
                }\r
@@ -256,8 +317,8 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
                s := clientmodel.ActionToBeSetup{\r
                        ActionID:         lol,\r
                        ActionType:       &actionType,\r
-                       ActionDefinition: encode_action_format1(resp.GlobalNbId.PlmnId, cells[n-1]),\r
-                       SubsequentAction: &clientmodel.SubsequentAction{\r
+                       ActionDefinition: encode_action_format1(resp.GlobalNbId.PlmnId, cells[n-1],meid),\r
+                       SubsequentAction:  &clientmodel.SubsequentAction{\r
                                SubsequentActionType: &subsequentActionType,\r
                                TimeToWait:           &timeToWait,\r
                        },\r
@@ -268,24 +329,24 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
        }\r
        var tmp_act_id int64 = n\r
        /*\r
-               n = 1\r
-               // for action def 2\r
-               for n <= ue {\r
-                       var tmp int64 = tmp_act_id\r
-                       var lol *int64 = &tmp\r
-                       s := clientmodel.ActionToBeSetup{\r
-                               ActionID:         lol,\r
-                               ActionType:       &actionType,\r
-                               ActionDefinition: encode_action_format2(),\r
-                               SubsequentAction:  &clientmodel.SubsequentAction{\r
-                                       SubsequentActionType: &subsequentActionType,\r
-                                       TimeToWait:           &timeToWait,\r
-                               },\r
-                       }\r
-                       l = append(l, &s)\r
-                       tmp_act_id = tmp_act_id + 1\r
-                       n = n + 1\r
+       n = 1\r
+       // for action def 2\r
+       for n <= ue {\r
+               var tmp int64 = tmp_act_id\r
+               var lol *int64 = &tmp\r
+               s := clientmodel.ActionToBeSetup{\r
+                       ActionID:         lol,\r
+                       ActionType:       &actionType,\r
+                       ActionDefinition: encode_action_format2(),\r
+                       SubsequentAction:  &clientmodel.SubsequentAction{\r
+                               SubsequentActionType: &subsequentActionType,\r
+                               TimeToWait:           &timeToWait,\r
+                       },\r
                }\r
+               l = append(l, &s)\r
+               tmp_act_id = tmp_act_id + 1\r
+               n = n + 1\r
+       }\r
        */\r
 \r
        //for action def 3\r
@@ -294,8 +355,8 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
        s := clientmodel.ActionToBeSetup{\r
                ActionID:         lol,\r
                ActionType:       &actionType,\r
-               ActionDefinition: encode_action_format3(),\r
-               SubsequentAction: &clientmodel.SubsequentAction{\r
+               ActionDefinition: encode_action_format3(meid),\r
+               SubsequentAction:  &clientmodel.SubsequentAction{\r
                        SubsequentActionType: &subsequentActionType,\r
                        TimeToWait:           &timeToWait,\r
                },\r
@@ -308,35 +369,35 @@ func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
 func (c Control) sendSubscription(meid string) {\r
        //Create Subscription message and send it to RIC platform\r
        xapp.Logger.Info("Sending subscription request for MEID: %v", meid)\r
-       /*\r
-               subscritionParams := clientmodel.SubscriptionParams{\r
-                       ClientEndpoint: &clientEndpoint,\r
-                       Meid:           &meid,\r
-                       RANFunctionID:  &funcId,\r
-                       SubscriptionDetails: clientmodel.SubscriptionDetailsList{\r
-                               &clientmodel.SubscriptionDetail{\r
-                                       EventTriggers: clientmodel.EventTriggerDefinition{\r
-                                               8,39,15,\r
-                                       },\r
-                                       XappEventInstanceID: &seqId,\r
-                                       ActionToBeSetupList: clientmodel.ActionsToBeSetup{\r
-                                               &clientmodel.ActionToBeSetup{\r
-                                                       ActionID:   &actionId,\r
-                                                       ActionType: &actionType,\r
-                                                       ActionDefinition: clientmodel.ActionDefinition{\r
-                                                               5678,\r
-                                                       },\r
-                                                       SubsequentAction: &clientmodel.SubsequentAction{\r
-                                                               SubsequentActionType: &subsequentActionType,\r
-                                                               TimeToWait:           &timeToWait,\r
-                                                       },\r
+/*\r
+       subscritionParams := clientmodel.SubscriptionParams{\r
+               ClientEndpoint: &clientEndpoint,\r
+               Meid:           &meid,\r
+               RANFunctionID:  &funcId,\r
+               SubscriptionDetails: clientmodel.SubscriptionDetailsList{\r
+                       &clientmodel.SubscriptionDetail{\r
+                               EventTriggers: clientmodel.EventTriggerDefinition{\r
+                                       8,39,15,\r
+                               },\r
+                               XappEventInstanceID: &seqId,\r
+                               ActionToBeSetupList: clientmodel.ActionsToBeSetup{\r
+                                       &clientmodel.ActionToBeSetup{\r
+                                               ActionID:   &actionId,\r
+                                               ActionType: &actionType,\r
+                                               ActionDefinition: clientmodel.ActionDefinition{\r
+                                                       5678,\r
+                                               },\r
+                                               SubsequentAction: &clientmodel.SubsequentAction{\r
+                                                       SubsequentActionType: &subsequentActionType,\r
+                                                       TimeToWait:           &timeToWait,\r
                                                },\r
                                        },\r
                                },\r
                        },\r
-               }\r
+               },\r
+       }\r
        */\r
-\r
+       \r
        //8,39,15, for 10000 ms reporting period\r
        subscritionParams := clientmodel.SubscriptionParams{\r
                ClientEndpoint: &clientEndpoint,\r
@@ -345,7 +406,7 @@ func (c Control) sendSubscription(meid string) {
                SubscriptionDetails: clientmodel.SubscriptionDetailsList{\r
                        &clientmodel.SubscriptionDetail{\r
                                EventTriggers: clientmodel.EventTriggerDefinition{\r
-                                       8, 39, 15,\r
+                                       8,39,15,\r
                                },\r
                                XappEventInstanceID: &seqId,\r
                                ActionToBeSetupList: encode_actionsToBeSetup(meid),\r
@@ -368,188 +429,192 @@ func (c Control) sendSubscription(meid string) {
 }\r
 \r
 func Test() (err error) {\r
-       var e2ap *E2ap\r
-       //var e2sm *E2sm\r
+        var e2ap *E2ap\r
+        //var e2sm *E2sm\r
 \r
-       //indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)\r
+        //indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)\r
        indicationMsg, err := e2ap.GetIndicationM()\r
 \r
-       if err != nil {\r
-               xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)\r
-               return\r
-       }\r
-\r
-       //log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)\r
-       /*\r
-          indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)\r
-          if err != nil {\r
-                  xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)\r
-                  return\r
-          }\r
-       */\r
-\r
-       //Decoding message and put information into log\r
-       log.Printf("-----------RIC Indication Header-----------")\r
+        if err != nil {\r
+                xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)\r
+                return\r
+        }\r
+\r
+        //log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)\r
+        /*\r
+                indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)\r
+                if err != nil {\r
+                        xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)\r
+                        return\r
+                }\r
+        */\r
+\r
+        //Decoding message and put information into log\r
+        log.Printf("-----------RIC Indication Header-----------")\r
        log.Printf("indicationMsg.IndHeader= %x", indicationMsg.IndHeader)\r
-       /*\r
-               buf := new(bytes.Buffer) //create my buffer\r
-               binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)\r
-               log.Printf("binary Write buf= %x",buf )\r
-               b := buf.Bytes()\r
-               //str := buf.String()\r
-               //log.Printf(" buf Strin()= %s",str )\r
-               //cptr1:= unsafe.Pointer(C.CString(str))\r
-               cptr1:= unsafe.Pointer(&b[0])\r
-               defer C.free(cptr1)\r
-       */\r
-       cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])\r
-       decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))\r
+/*     \r
+       buf := new(bytes.Buffer) //create my buffer\r
+       binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)\r
+       log.Printf("binary Write buf= %x",buf )\r
+       b := buf.Bytes()\r
+       //str := buf.String()\r
+       //log.Printf(" buf Strin()= %s",str )\r
+       //cptr1:= unsafe.Pointer(C.CString(str))\r
+       cptr1:= unsafe.Pointer(&b[0])\r
+       defer C.free(cptr1)\r
+*/     \r
+        cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])\r
+        decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))\r
        //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(str)))\r
        //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(buf.Len()))\r
-       if decodedHdr == nil {\r
-               return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")\r
-       }\r
-       defer C.e2sm_free_ric_indication_header(decodedHdr)\r
-       IndHdrType := int32(decodedHdr.indicationHeader_formats.present)\r
-       if IndHdrType == 0 {\r
-               log.Printf("No Indication Header present")\r
-       }\r
-       if IndHdrType == 1 {\r
-               log.Printf("Indication Header format = %d", IndHdrType)\r
-               indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))\r
-               //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))\r
-               senderName_C := indHdrFormat1_C.senderName\r
-               var senderName []byte\r
-               senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))\r
-               log.Printf("Sender Name = %x", senderName)\r
+        if decodedHdr == nil {\r
+                return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")\r
+        }\r
+        defer C.e2sm_free_ric_indication_header(decodedHdr)\r
+        IndHdrType := int32(decodedHdr.indicationHeader_formats.present)\r
+        if IndHdrType==0{\r
+                log.Printf("No Indication Header present")\r
+        }\r
+        if IndHdrType==1{\r
+                log.Printf("Indication Header format = %d",IndHdrType)\r
+                indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))\r
+                //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))\r
+               senderName_C:=indHdrFormat1_C.senderName\r
+                var senderName []byte\r
+                senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))\r
+                log.Printf("Sender Name = %x",senderName)\r
+\r
+                //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))\r
+               senderType_C :=indHdrFormat1_C.senderType\r
+                //senderType []byte\r
+                senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))\r
+                log.Printf("Sender Type = %x",senderType)\r
+\r
+                //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))\r
+               vendorName_C :=indHdrFormat1_C.vendorName\r
+                //vendorName  []byte\r
+                vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))\r
+                log.Printf("Vendor Name = %x",vendorName)\r
+\r
+\r
+        }\r
+\r
+        /*\r
+                indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)\r
+                if err != nil {\r
+                        xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)\r
+                        return\r
+                }\r
+        */\r
+        log.Printf("-----------RIC Indication Message-----------")\r
+       log.Printf("indicationMsg.IndMessage= %x",indicationMsg.IndMessage)\r
+        cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])\r
+        indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))\r
+        if  indicationmessage == nil {\r
+                return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")\r
+        }\r
+        defer C.e2sm_free_ric_indication_message(indicationmessage)\r
+        IndMsgType := int32(indicationmessage.indicationMessage_formats.present)\r
+        if IndMsgType==1  {//parsing cell metrics\r
+                fmt.Printf(" parsing for cell metrics\n" )\r
+                indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
+                no_of_cell:=int32(indMsgFormat1_C .measData.list.count)\r
+               fmt.Printf(" \n No of cell = %d\n",no_of_cell )\r
+               //fmt.Println(no_of_cell)\r
+                for n := int32(0); n < no_of_cell; n++ {\r
+                                var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                                MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+                                no_of_cell_metrics:=int32(MeasurementDataItem_C.measRecord.list.count)\r
+                                var CellM CellMetricsEntry\r
+                                v := reflect.ValueOf(CellM)\r
+                               fmt.Printf(" \n No of cell metrics = %d\n",no_of_cell_metrics)\r
+                                values := make(map[string]interface{}, v.NumField())\r
+                                //assert no_of_cell_metrics == v.NumField()   they both should be equal.\r
+                                for i := int32(0); i < no_of_cell_metrics; i++ {\r
+                                       //fmt.Println(i)\r
+                                        if v.Field(int(i)).CanInterface() {\r
+                                                        var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
+                                                        MeasurementRecordItem_C:=*(**C. MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
+                                                        type_var:=int(MeasurementRecordItem_C.present)\r
+                                                        if type_var==1{\r
+                                                                var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                                                values[v.Type().Field(int(i)).Name]=int32(*cast_integer)\r
+                                                                }else if type_var==2{\r
+                                var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                values[v.Type().Field(int(i)).Name]=float64(*cast_float)\r
+                                                        }else{\r
+                                                        fmt.Printf("Wrong Data Type")\r
+                                                }\r
+\r
+                                                }else {\r
+                                                fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+                                                }\r
+                                        }//end of inner for loop\r
+\r
+\r
+                               fmt.Println(values)\r
+                               fmt.Printf("Parsing Cell Metric Done")\r
+                               //c.writeCellMetrics_db(&values)//push cellmetrics map entry to database.\r
+                        }//end of outer for loop\r
+                        //end of if IndMsgType==1 , parsing cell metrics done\r
+\r
+        }  else if IndMsgType==2  { //parsing ue metrics\r
+\r
+                fmt.Printf(" parsing for UE metrics" )\r
+                indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
+                no_of_ue_metrics:=int32(indMsgFormat2_C .measData.list.count)\r
+               fmt.Printf(" \n No of ue metrics = %d\n",no_of_ue_metrics)\r
+\r
+                var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+\r
+                no_of_ue:=int32(MeasurementDataItem_C.measRecord.list.count)\r
+               fmt.Printf(" \n No of ue= %d\n",no_of_ue)\r
+                for n := int32(0); n < no_of_ue; n++ {\r
+                                var UeM UeMetricsEntry\r
+                                v := reflect.ValueOf(UeM)\r
+                                values := make(map[string]interface{}, v.NumField())\r
+                                //assert no_of_ue_metrics == v.NumField()   they both should be equal.\r
+                                for i := int32(0); i < no_of_ue_metrics; i++ {\r
+                               //fmt.Println(i)\r
+                                if v.Field(int(i)).CanInterface() {\r
 \r
-               //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))\r
-               senderType_C := indHdrFormat1_C.senderType\r
-               //senderType []byte\r
-               senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))\r
-               log.Printf("Sender Type = %x", senderType)\r
+                                        var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                                        MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+                                        var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
+                                        MeasurementRecordItem_C:=*(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
 \r
-               //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))\r
-               vendorName_C := indHdrFormat1_C.vendorName\r
-               //vendorName  []byte\r
-               vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))\r
-               log.Printf("Vendor Name = %x", vendorName)\r
+                                        type_var:=int(MeasurementRecordItem_C.present)\r
+                                if type_var==1{\r
+                                        var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                        values[v.Type().Field(int(i)).Name]=int32(*cast_integer)\r
+                                }else if type_var==2{\r
+                                        var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                        values[v.Type().Field(int(i)).Name]=float64(*cast_float)\r
 \r
-       }\r
+                                        }else{\r
+                                        fmt.Printf("Wrong Data Type")\r
+                                }\r
 \r
-       /*\r
-          indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)\r
-          if err != nil {\r
-                  xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)\r
-                  return\r
-          }\r
-       */\r
-       log.Printf("-----------RIC Indication Message-----------")\r
-       log.Printf("indicationMsg.IndMessage= %x", indicationMsg.IndMessage)\r
-       cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])\r
-       indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))\r
-       if indicationmessage == nil {\r
-               return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")\r
-       }\r
-       defer C.e2sm_free_ric_indication_message(indicationmessage)\r
-       IndMsgType := int32(indicationmessage.indicationMessage_formats.present)\r
-       if IndMsgType == 1 { //parsing cell metrics\r
-               fmt.Printf(" parsing for cell metrics\n")\r
-               indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
-               no_of_cell := int32(indMsgFormat1_C.measData.list.count)\r
-               fmt.Printf(" \n No of cell = %d\n", no_of_cell)\r
-               //fmt.Println(no_of_cell)\r
-               for n := int32(0); n < no_of_cell; n++ {\r
-                       var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-                       MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-                       no_of_cell_metrics := int32(MeasurementDataItem_C.measRecord.list.count)\r
-                       var CellM CellMetricsEntry\r
-                       v := reflect.ValueOf(CellM)\r
-                       fmt.Printf(" \n No of cell metrics = %d\n", no_of_cell_metrics)\r
-                       values := make(map[string]interface{}, v.NumField())\r
-                       //assert no_of_cell_metrics == v.NumField()   they both should be equal.\r
-                       for i := int32(0); i < no_of_cell_metrics; i++ {\r
-                               //fmt.Println(i)\r
-                               if v.Field(int(i)).CanInterface() {\r
-                                       var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
-                                       MeasurementRecordItem_C := *(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
-                                       type_var := int(MeasurementRecordItem_C.present)\r
-                                       if type_var == 1 {\r
-                                               var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = int32(*cast_integer)\r
-                                       } else if type_var == 2 {\r
-                                               var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = float64(*cast_float)\r
-                                       } else {\r
-                                               fmt.Printf("Wrong Data Type")\r
-                                       }\r
-\r
-                               } else {\r
-                                       fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
-                               }\r
-                       } //end of inner for loop\r
+                        }else {\r
+                                fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+                                }\r
 \r
-                       fmt.Println(values)\r
-                       fmt.Printf("Parsing Cell Metric Done")\r
-                       //c.writeCellMetrics_db(&values)//push cellmetrics map entry to database.\r
-               } //end of outer for loop\r
-               //end of if IndMsgType==1 , parsing cell metrics done\r
-\r
-       } else if IndMsgType == 2 { //parsing ue metrics\r
-\r
-               fmt.Printf(" parsing for UE metrics")\r
-               indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
-               no_of_ue_metrics := int32(indMsgFormat2_C.measData.list.count)\r
-               fmt.Printf(" \n No of ue metrics = %d\n", no_of_ue_metrics)\r
-\r
-               var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-               MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-\r
-               no_of_ue := int32(MeasurementDataItem_C.measRecord.list.count)\r
-               fmt.Printf(" \n No of ue= %d\n", no_of_ue)\r
-               for n := int32(0); n < no_of_ue; n++ {\r
-                       var UeM UeMetricsEntry\r
-                       v := reflect.ValueOf(UeM)\r
-                       values := make(map[string]interface{}, v.NumField())\r
-                       //assert no_of_ue_metrics == v.NumField()   they both should be equal.\r
-                       for i := int32(0); i < no_of_ue_metrics; i++ {\r
-                               //fmt.Println(i)\r
-                               if v.Field(int(i)).CanInterface() {\r
-\r
-                                       var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-                                       MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-                                       var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
-                                       MeasurementRecordItem_C := *(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
-\r
-                                       type_var := int(MeasurementRecordItem_C.present)\r
-                                       if type_var == 1 {\r
-                                               var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = int32(*cast_integer)\r
-                                       } else if type_var == 2 {\r
-                                               var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = float64(*cast_float)\r
-\r
-                                       } else {\r
-                                               fmt.Printf("Wrong Data Type")\r
-                                       }\r
-\r
-                               } else {\r
-                                       fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
-                               }\r
 \r
-                       } //end of inner for loop\r
+                                        }       //end of inner for loop\r
                        fmt.Println(values)\r
-                       fmt.Printf("Parsing UE Metric Done")\r
-                       //c.writeUeMetrics_db(&values)//push UEmetrics map entry to database.\r
+                        fmt.Printf("Parsing UE Metric Done")\r
+                        //c.writeUeMetrics_db(&values)//push UEmetrics map entry to database.\r
 \r
-               // end of outer for loop\r
-               //parsing ue metrics done\r
-       } else {\r
-               fmt.Printf(" Invalid Indication message format")\r
+                        }// end of outer for loop\r
+        //parsing ue metrics done\r
+        }else{\r
+                fmt.Printf(" Invalid Indication message format" )\r
 \r
-       }\r
+        }\r
 \r
-       return nil\r
+\r
+        return nil\r
 }\r
 \r
 func (c *Control) controlLoop() {\r
@@ -586,176 +651,180 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) {
 \r
        //Decoding message and put information into log\r
        //log.Printf("-----------RIC Indication Header-----------")\r
-       //log.Printf("indicationMsg.IndHeader= %x", indicationMsg.IndHeader)\r
-       /*\r
-          buf := new(bytes.Buffer) //create my buffer\r
-          binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)\r
-          log.Printf("binary Write buf= %x",buf )\r
-          b := buf.Bytes()\r
-          //str := buf.String()\r
-          //log.Printf(" buf Strin()= %s",str )\r
-          //cptr1:= unsafe.Pointer(C.CString(str))\r
-          cptr1:= unsafe.Pointer(&b[0])\r
-          defer C.free(cptr1)\r
-       */\r
-       cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])\r
-       decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))\r
-       //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(str)))\r
-       //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(buf.Len()))\r
-       if decodedHdr == nil {\r
-               return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")\r
-       }\r
-       defer C.e2sm_free_ric_indication_header(decodedHdr)\r
-       IndHdrType := int32(decodedHdr.indicationHeader_formats.present)\r
-       if IndHdrType == 0 {\r
-               log.Printf("No Indication Header present")\r
-       }\r
-       if IndHdrType == 1 {\r
-               log.Printf("Indication Header format = %d", IndHdrType)\r
+        //log.Printf("indicationMsg.IndHeader= %x", indicationMsg.IndHeader)\r
+/*\r
+        buf := new(bytes.Buffer) //create my buffer\r
+        binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)\r
+        log.Printf("binary Write buf= %x",buf )\r
+        b := buf.Bytes()\r
+        //str := buf.String()\r
+        //log.Printf(" buf Strin()= %s",str )\r
+        //cptr1:= unsafe.Pointer(C.CString(str))\r
+        cptr1:= unsafe.Pointer(&b[0])\r
+        defer C.free(cptr1)\r
+*/\r
+        cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])\r
+        decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))\r
+        //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(str)))\r
+        //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(buf.Len()))\r
+        if decodedHdr == nil {\r
+                return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")\r
+        }\r
+        defer C.e2sm_free_ric_indication_header(decodedHdr)\r
+        IndHdrType := int32(decodedHdr.indicationHeader_formats.present)\r
+        if IndHdrType==0{\r
+                log.Printf("No Indication Header present")\r
+        }\r
+        if IndHdrType==1{\r
+                log.Printf("Indication Header format = %d",IndHdrType)\r
                /*\r
-                  indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))\r
-                  //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))\r
-                  senderName_C:=indHdrFormat1_C.senderName\r
-                  var senderName []byte\r
-                  senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))\r
-                  //log.Printf("Sender Name = %x",senderName)\r
-\r
-                  //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))\r
-                  senderType_C :=indHdrFormat1_C.senderType\r
-                  //senderType []byte\r
-                  senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))\r
-                  //log.Printf("Sender Type = %x",senderType)\r
-\r
-                  //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))\r
-                  vendorName_C :=indHdrFormat1_C.vendorName\r
-                  //vendorName  []byte\r
-                  vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))\r
-                  //log.Printf("Vendor Name = %x",vendorName)\r
+                indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))\r
+                //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))\r
+                senderName_C:=indHdrFormat1_C.senderName\r
+                var senderName []byte\r
+                senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))\r
+                //log.Printf("Sender Name = %x",senderName)\r
+\r
+                //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))\r
+                senderType_C :=indHdrFormat1_C.senderType\r
+                //senderType []byte\r
+                senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))\r
+                //log.Printf("Sender Type = %x",senderType)\r
+\r
+                //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))\r
+                vendorName_C :=indHdrFormat1_C.vendorName\r
+                //vendorName  []byte\r
+                vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))\r
+                //log.Printf("Vendor Name = %x",vendorName)\r
                */\r
 \r
-       }\r
-\r
-       /*\r
-          indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)\r
-          if err != nil {\r
-                  xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)\r
-                  return\r
-          }\r
-       */\r
-       //log.Printf("-----------RIC Indication Message-----------")\r
-       //log.Printf("indicationMsg.IndMessage= %x",indicationMsg.IndMessage)\r
-       cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])\r
-       indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))\r
-       if indicationmessage == nil {\r
-               return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")\r
-       }\r
-       defer C.e2sm_free_ric_indication_message(indicationmessage)\r
-       IndMsgType := int32(indicationmessage.indicationMessage_formats.present)\r
-       if IndMsgType == 1 { //parsing cell metrics\r
-               fmt.Printf(" parsing for cell metrics\n")\r
-               indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
-               no_of_cell := int32(indMsgFormat1_C.measData.list.count)\r
-               fmt.Printf(" \n No of cell = %d\n", no_of_cell)\r
-               //fmt.Println(no_of_cell)\r
-               for n := int32(0); n < no_of_cell; n++ {\r
-                       var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-                       MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-                       no_of_cell_metrics := int32(MeasurementDataItem_C.measRecord.list.count)\r
-                       var CellM CellMetricsEntry\r
-                       v := reflect.ValueOf(CellM)\r
-                       fmt.Printf(" \n No of cell metrics = %d\n", no_of_cell_metrics)\r
-                       values := make(map[string]interface{}, v.NumField())\r
-                       //assert no_of_cell_metrics == v.NumField()   they both should be equal.\r
-                       if int(no_of_cell_metrics) != v.NumField() {\r
-                               log.Printf("no_of_cell_metrics != v.NumField()")\r
-                               return errors.New("no_of_cell_metrics != v.NumField()")\r
-                       }\r
-                       for i := int32(0); i < no_of_cell_metrics; i++ {\r
-                               //fmt.Println(i)\r
-                               if v.Field(int(i)).CanInterface() {\r
-                                       var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
-                                       MeasurementRecordItem_C := *(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
-                                       type_var := int(MeasurementRecordItem_C.present)\r
-                                       if type_var == 1 {\r
-                                               var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = int32(*cast_integer)\r
-                                       } else if type_var == 2 {\r
-                                               var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = float64(*cast_float)\r
-                                       } else {\r
-                                               fmt.Printf("Wrong Data Type")\r
-                                       }\r
-\r
-                               } else {\r
-                                       fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+        }\r
+\r
+        /*\r
+                indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)\r
+                if err != nil {\r
+                        xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)\r
+                        return\r
+                }\r
+        */\r
+        //log.Printf("-----------RIC Indication Message-----------")\r
+        //log.Printf("indicationMsg.IndMessage= %x",indicationMsg.IndMessage)\r
+        cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])\r
+        indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))\r
+        if  indicationmessage == nil {\r
+                return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")\r
+        }\r
+        defer C.e2sm_free_ric_indication_message(indicationmessage)\r
+        IndMsgType := int32(indicationmessage.indicationMessage_formats.present)\r
+        if IndMsgType==1  {//parsing cell metrics\r
+                fmt.Printf(" parsing for cell metrics\n" )\r
+                indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
+                no_of_cell:=int32(indMsgFormat1_C .measData.list.count)\r
+                fmt.Printf(" \n No of cell = %d\n",no_of_cell )\r
+                //fmt.Println(no_of_cell)\r
+                for n := int32(0); n < no_of_cell; n++ {\r
+                                var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                                MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+                                no_of_cell_metrics:=int32(MeasurementDataItem_C.measRecord.list.count)\r
+                                var CellM CellMetricsEntry\r
+                                v := reflect.ValueOf(CellM)\r
+                                fmt.Printf(" \n No of cell metrics = %d\n",no_of_cell_metrics)\r
+                                values := make(map[string]interface{}, v.NumField())\r
+                                //assert no_of_cell_metrics == v.NumField()   they both should be equal.\r
+                               if (int(no_of_cell_metrics) != v.NumField()){\r
+                        log.Printf("no_of_cell_metrics != v.NumField()")\r
+                       return errors.New("no_of_cell_metrics != v.NumField()")\r
                                }\r
-                       } //end of inner for loop\r
-\r
-                       fmt.Println(values)\r
-                       fmt.Printf("Parsing Cell Metric Done")\r
-                       c.writeCellMetrics_db(&values) //push cellmetrics map entry to database.\r
-               } //end of outer for loop\r
-               //end of if IndMsgType==1 , parsing cell metrics done\r
-\r
-       } else if IndMsgType == 2 { //parsing ue metrics\r
-\r
-               fmt.Printf(" parsing for UE metrics")\r
-               indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
-               no_of_ue_metrics := int32(indMsgFormat2_C.measData.list.count)\r
-               fmt.Printf(" \n No of ue metrics = %d\n", no_of_ue_metrics)\r
-\r
-               var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-               MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-\r
-               no_of_ue := int32(MeasurementDataItem_C.measRecord.list.count)\r
-               fmt.Printf(" \n No of ue= %d\n", no_of_ue)\r
-               for n := int32(0); n < no_of_ue; n++ {\r
-                       var UeM UeMetricsEntry\r
-                       v := reflect.ValueOf(UeM)\r
-                       values := make(map[string]interface{}, v.NumField())\r
-                       //assert no_of_ue_metrics == v.NumField()   they both should be equal.\r
-                       if int(no_of_ue_metrics) != v.NumField() {\r
-                               log.Printf("no_of_ue_metrics != v.NumField()")\r
-                               return errors.New("no_of_ue_metrics != v.NumField()")\r
-                       }\r
-                       for i := int32(0); i < no_of_ue_metrics; i++ {\r
-                               //fmt.Println(i)\r
-                               if v.Field(int(i)).CanInterface() {\r
-\r
-                                       var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t\r
-                                       MeasurementDataItem_C := *(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
-                                       var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
-                                       MeasurementRecordItem_C := *(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
-\r
-                                       type_var := int(MeasurementRecordItem_C.present)\r
-                                       if type_var == 1 {\r
-                                               var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = int32(*cast_integer)\r
-                                       } else if type_var == 2 {\r
-                                               var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
-                                               values[v.Type().Field(int(i)).Name] = float64(*cast_float)\r
-\r
-                                       } else {\r
-                                               fmt.Printf("Wrong Data Type")\r
-                                       }\r
-\r
-                               } else {\r
-                                       fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+                                for i := int32(0); i < no_of_cell_metrics; i++ {\r
+                                        //fmt.Println(i)\r
+                                        if v.Field(int(i)).CanInterface() {\r
+                                                        var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
+                                                        MeasurementRecordItem_C:=*(**C. MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
+                                                        type_var:=int(MeasurementRecordItem_C.present)\r
+                                                        if type_var==1{\r
+                                                                var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                                                values[v.Type().Field(int(i)).Name]=int32(*cast_integer)\r
+                                                                }else if type_var==2{\r
+                                var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                values[v.Type().Field(int(i)).Name]=float64(*cast_float)\r
+                                                        }else{\r
+                                                        fmt.Printf("Wrong Data Type")\r
+                                                }\r
+\r
+                                                }else {\r
+                                                fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+                                                }\r
+                                        }//end of inner for loop\r
+\r
+\r
+                                fmt.Println(values)\r
+                                fmt.Printf("Parsing Cell Metric Done")\r
+                                c.writeCellMetrics_db(&values)//push cellmetrics map entry to database.\r
+                        }//end of outer for loop\r
+                        //end of if IndMsgType==1 , parsing cell metrics done\r
+\r
+        }  else if IndMsgType==2  { //parsing ue metrics\r
+\r
+                fmt.Printf(" parsing for UE metrics" )\r
+                indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))\r
+                no_of_ue_metrics:=int32(indMsgFormat2_C .measData.list.count)\r
+                fmt.Printf(" \n No of ue metrics = %d\n",no_of_ue_metrics)\r
+\r
+                var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+\r
+                no_of_ue:=int32(MeasurementDataItem_C.measRecord.list.count)\r
+                fmt.Printf(" \n No of ue= %d\n",no_of_ue)\r
+                for n := int32(0); n < no_of_ue; n++ {\r
+                                var UeM UeMetricsEntry\r
+                                v := reflect.ValueOf(UeM)\r
+                                values := make(map[string]interface{}, v.NumField())\r
+                                //assert no_of_ue_metrics == v.NumField()   they both should be equal.\r
+                               if (int(no_of_ue_metrics) != v.NumField()){\r
+                        log.Printf("no_of_ue_metrics != v.NumField()")\r
+                        return errors.New("no_of_ue_metrics != v.NumField()")\r
                                }\r
+                                for i := int32(0); i < no_of_ue_metrics; i++ {\r
+                                //fmt.Println(i)\r
+                                if v.Field(int(i)).CanInterface() {\r
 \r
-                       } //end of inner for loop\r
-                       fmt.Println(values)\r
-                       fmt.Printf("Parsing UE Metric Done")\r
-                       c.writeUeMetrics_db(&values) //push UEmetrics map entry to database.\r
+                                        var sizeof_MeasurementDataItem_t  *C.MeasurementDataItem_t\r
+                                        MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))\r
+                                        var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t\r
+                                        MeasurementRecordItem_C:=*(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))\r
 \r
-               } // end of outer for loop\r
-               //parsing ue metrics done\r
-       } else {\r
-               fmt.Printf(" Invalid Indication message format")\r
+                                        type_var:=int(MeasurementRecordItem_C.present)\r
+                                if type_var==1{\r
+                                        var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                        values[v.Type().Field(int(i)).Name]=int32(*cast_integer)\r
+                                }else if type_var==2{\r
+                                        var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))\r
+                                        values[v.Type().Field(int(i)).Name]=float64(*cast_float)\r
 \r
-       }\r
+                                        }else{\r
+                                        fmt.Printf("Wrong Data Type")\r
+                                }\r
+\r
+                        }else {\r
+                                fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)\r
+                                }\r
+\r
+\r
+                                        }       //end of inner for loop\r
+                        fmt.Println(values)\r
+                         fmt.Printf("Parsing UE Metric Done")\r
+                         c.writeUeMetrics_db(&values)//push UEmetrics map entry to database.\r
+\r
+                        }// end of outer for loop\r
+        //parsing ue metrics done\r
+        }else{\r
+                fmt.Printf(" Invalid Indication message format" )\r
+\r
+        }\r
+\r
+\r
+        return nil\r
 \r
-       return nil\r
 \r
 }\r
 \r
@@ -858,14 +927,6 @@ func (c Control) xAppStartCB(d interface{}) {
        // Get eNodeB list\r
        nbList := c.getnbList()\r
 \r
-       for {\r
-               time.Sleep(5 * time.Second)\r
-               if xapp.IsRegistered() {\r
-                       xapp.Logger.Info("App registration is done, ready to send subscription request.")\r
-                       break\r
-               }\r
-               xapp.Logger.Debug("App registration is not done yet, sleep 5s and check again")\r
-       }\r
        // Send subscription request to connected NodeB\r
        for _, nb := range nbList {\r
                if nb.ConnectionStatus == 1 {\r
@@ -875,8 +936,7 @@ func (c Control) xAppStartCB(d interface{}) {
                }\r
 \r
        }\r
-\r
-       fmt.Println("len of Glob_cell= ", len(Glob_cell))\r
+       fmt.Println("len of Glob_cell= ",len(Glob_cell))\r
        fmt.Println("Glob_cell map = ", Glob_cell)\r
 \r
        go c.controlLoop()\r
index 61ec30f..b2be196 100644 (file)
 #include "wrapper.h"
 #include <stdio.h>
 
+/*
+static int write_out(const void *buffer, size_t size, void *app_key) {
+        FILE *out_fp = app_key;
+        size_t wrote = fwrite(buffer, 1, size, out_fp);
+        return (wrote == size) ? 0 :-1;
+}
+*/
+
+//determine 
+//1 for format1 by id, 2 for format1 by name , 3 for format3 by id, 4 for format3 by name
+struct encode_act_Def_result encode_action_Definition(const char *hex_values, int determine){
+       
+       encode_act_Def_result_t res;    
+       int BUFFER_SIZE=10240;
+        // Calculate the length of the hex string
+        size_t hex_len = strlen(hex_values);
+
+        // Allocate memory for a char array to store the hex values
+        char *hex_buffer = (char *)malloc(hex_len / 2 + 1); // Each byte is represented by 2 characters, +1 for null terminator
+
+        if (hex_buffer == NULL) {
+                fprintf(stderr, "Memory allocation failed\n");
+                return res;
+        }
+
+        // Convert the hex string to binary data
+        for (size_t i = 0; i < hex_len; i += 2) {
+                char byte[3] = {hex_values[i], hex_values[i + 1], '\0'};
+                hex_buffer[i / 2] = (char)strtol(byte, NULL, 16);
+        }
+
+        // Null-terminate the char array
+        hex_buffer[hex_len / 2] = '\0';
+
+        // Now hex_buffer contains the binary data corresponding to the hex values
+
+        // Print the result
+        printf("Hex values as a string: %s\n", hex_buffer);
+
+        long *id_format1;
+        long *id_format3;
+        char **name_format1;
+        char **name_format3;
+        int sz1=0;
+        int sz3=0;
+
+        E2SM_KPM_RANfunction_Description_t * e2smKpmRanFunctDescrip=(E2SM_KPM_RANfunction_Description_t * )calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t ));
+
+        enum asn_transfer_syntax syntax;
+
+        syntax = ATS_ALIGNED_BASIC_PER;
+
+        asn_dec_rval_t rval =  asn_decode(NULL, syntax, &asn_DEF_E2SM_KPM_RANfunction_Description, (void**)&e2smKpmRanFunctDescrip, hex_buffer, hex_len);
+
+        if(rval.code == RC_OK)
+        {
+                printf( "[INFO] E2SM KPM RAN Function Description decode successfull rval.code = %d \n",rval.code);
+
+                asn_fprint(stdout, &asn_DEF_E2SM_KPM_RANfunction_Description, e2smKpmRanFunctDescrip);
+
+                for(int i=0; i< e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.count; i++){
+
+                        if(e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->ric_ActionFormat_Type==1){
+                                sz1=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.count;
+                                id_format1=(long *)calloc(sz1,sizeof(long));
+                                name_format1=(char **)malloc(sz1*sizeof(char *));
+                                for(int j=0;j<sz1;j++){
+                                        id_format1[j]=*(e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measID);
+                                        size_t bufsize=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measName.size;
+                                        name_format1[j]=(char*)malloc(bufsize);
+                                        name_format1[j]=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measName.buf;
+
+                                }
+
+                        }
+
+                        if(e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->ric_ActionFormat_Type==3){
+                                sz3=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.count;
+                                id_format3=(long *)calloc(sz3,sizeof(long));
+                                name_format3=(char **)malloc(sz3*sizeof(char *));
+                                for(int j=0;j<sz3;j++){
+                                        id_format3[j]=*(e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measID);
+                                        size_t bufsize=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measName.size;
+                                        name_format3[j]=(char*)malloc(bufsize);
+                                        name_format3[j]=e2smKpmRanFunctDescrip->ric_ReportStyle_List->list.array[i]->measInfo_Action_List.list.array[j]->measName.buf;
+
+                                }
+
+                        }
 
-// int main() {
 
-//     long id[] = {1,2,3,4};
 
-//     void *buffer[8] = {} ;
-//     unsigned int sizeBuffer = 8;
-//     long actionDefCount = 8;
-//     long measId = 1;
-//     long ricStyleType = 1;
-//     long periods = 1;
-//     void *plm[8] = {} ;
-//     unsigned int sizePlm = 8;
-//     void *nRc[8] = {} ;
-//     unsigned int sizenRc = 8;
+                }
+
+
+        }
+        else
+        {
+                 printf("[INFO] E2SM KPM RAN Function Description decode failed rval.code = %d \n", rval.code);
+        }
+        printf("\n");
+        printf("measID format 1\n");
+        for(int i=0;i<sz1;i++){
+                printf("%ld, ",id_format1[i]);
+        }
+        printf("\n");
+        printf("measName format 1\n");
+        for(int i=0;i<sz1;i++){
+                printf("%s, ",name_format1[i]);
+        }
+        printf("\n");
+        printf("measID format 3\n");
+        for(int i=0;i<sz3;i++){
+                printf("%ld, ",id_format3[i]);
+        }
+        printf("\n");
+        printf("measName format 3\n");
+        for(int i=0;i<sz1;i++){
+                printf("%s, ",name_format3[i]);
+        }
+
+
+        unsigned char bufFormat3[BUFFER_SIZE];
+        size_t buf_sizeFormat3 = BUFFER_SIZE;
+
+        long ricStyleTypeFormat3 = 3;
+        unsigned long granulPeriod = 10000;
+
+        int encodedLengthFormat3ByName = e2sm_encode_ric_action_definition_format3_by_name(&bufFormat3[0], &buf_sizeFormat3, name_format3, sz3, ricStyleTypeFormat3, granulPeriod);
+        printf("length of buff= %ld \n",strlen(bufFormat3));
+        printf("size of buff= %ld \n",sizeof(bufFormat3));
+        printf("declared size of buff= %ld \n",BUFFER_SIZE);
+        printf("encoded length of buff= %ld \n",encodedLengthFormat3ByName);
+       int arrayFormat3ByName[encodedLengthFormat3ByName];
+        for(int i=0;i<encodedLengthFormat3ByName;i++){
+                        //printf("%d ",(int)bufFormat3[i]);
+                       arrayFormat3ByName[i]=(int)bufFormat3[i];
+        }
+
+        unsigned char bufFormat1[BUFFER_SIZE];
+        size_t buf_sizeFormat1 = BUFFER_SIZE;
+
+        long ricStyleTypeFormat1 = 1;
+        //unsigned long granulPeriod = 10000;
+
+        //get plmn id during run time of kpimon
+        unsigned char p[] = {0x00, 0x1F, 0x01};
+
+        //get nr cell id for 5g cell or eutra cell id for 4g cell
+        unsigned char nR []= {0x12, 0x34, 0x56, 0x00, 0x10};
+
+        int encodedLengthFormat1ByName = e2sm_encode_ric_action_definition_format1_by_name(&bufFormat1[0], &buf_sizeFormat1, name_format1, sz1, ricStyleTypeFormat1, granulPeriod, p, nR);
+        printf("\n\n\n");
+       int arrayFormat1ByName[encodedLengthFormat1ByName];
+        for(int i=0;i<encodedLengthFormat1ByName;i++){
+                        //printf("%d ",(int)bufFormat1[i]);
+                       arrayFormat1ByName[i]=(int)bufFormat1[i];
+        }
+
+        unsigned char bufFormat1ById[BUFFER_SIZE];
+        size_t buf_sizeFormat1ById = BUFFER_SIZE;
+
+        int encodedLengthFormat1ById = e2sm_encode_ric_action_definition_format1_by_id(&bufFormat1ById[0], &buf_sizeFormat1ById, id_format1, sz1, ricStyleTypeFormat1, granulPeriod, p, nR);
+        printf("\n\n\n");
+       int arrayFormat1ById[encodedLengthFormat1ById];
+        for(int i=0;i<encodedLengthFormat1ById;i++){
+                        //printf("%d ",(int)bufFormat1ById[i]);
+                       arrayFormat1ById[i]=(int)bufFormat1ById[i];
+        }
+
+        unsigned char bufFormat3ById[BUFFER_SIZE];
+        size_t buf_sizeFormat3ById = BUFFER_SIZE;
 
-//     int a = e2sm_encode_ric_action_definition(buffer, sizeBuffer, actionDefCount, measId, ricStyleType, periods, plm, nRc);
+        int encodedLengthFormat3ById = e2sm_encode_ric_action_definition_format3_by_id(&bufFormat3ById[0], &buf_sizeFormat3ById, id_format3, sz3, ricStyleTypeFormat3, granulPeriod);
+        printf("\n\n\n");
+        int arrayFormat3ById[encodedLengthFormat3ById];
+       for(int i=0;i<encodedLengthFormat3ById;i++){
+                        //printf("%d ",(int)bufFormat3ById[i]);
+                       arrayFormat3ById[i]=(int)bufFormat3ById[i];
+
+        }
+
+
+
+
+        ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_RANfunction_Description, e2smKpmRanFunctDescrip);
+
+
+
+        // Don't forget to free the allocated memory when done
+        free(hex_buffer);
+       
+       free(id_format1);
+       free(id_format3);
+       for(int i=0; i<sz1;i++){
+               free(name_format1[i]);
+       }
+       free(name_format1);
+       
+       
+       for(int i=0; i<sz3;i++){
+               free(name_format3[i]);
+       }
+       free(name_format3);
+       switch(determine){
+               case 1:
+                       res.array=arrayFormat1ById;
+                       res.length=encodedLengthFormat1ById-8;//removing hardcoded plmn and cellid
+                       return res;
+               case 2:
+                       res.array=arrayFormat1ByName;
+                       res.length=encodedLengthFormat1ByName-8;//removing hardcoded plmn and cellid
+                       return res;
+               case 3:
+                       res.array=arrayFormat3ById;
+                       res.length=encodedLengthFormat3ById;
+                       return res;
+               case 4:
+                       res.array=arrayFormat3ByName;
+                       res.length=encodedLengthFormat3ByName;
+                       return res;
+                       break;
+
+       }
+       return res;
+
+
+
+}
+size_t e2sm_encode_ric_action_definition_format1_by_name(unsigned char *buf, size_t *buf_size, const char **id_tmp , size_t measIdcount, long ric_style_type, unsigned long granulPeriod, unsigned char  *p, unsigned char *nR) {
+        E2SM_KPM_ActionDefinition_t *actionDef = (E2SM_KPM_ActionDefinition_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_t));
+        if (!actionDef) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        E2SM_KPM_ActionDefinition_Format1_t *actionDefFor1 = (E2SM_KPM_ActionDefinition_Format1_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_Format1_t));
+        if (!actionDefFor1) {
+                ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+        CGI_t *cellGlobal = (CGI_t *)calloc(1, sizeof(CGI_t));
+        if (!cellGlobal) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        NR_CGI_t *nrCGIs = (NR_CGI_t *)calloc(1, sizeof(NR_CGI_t));
+        if (!nrCGIs) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+
+        PLMNIdentity_t *PLM=(PLMNIdentity_t *)calloc(1,sizeof(PLMNIdentity_t));
+        PLM->buf=(uint8_t *)calloc(3,sizeof(uint8_t));
+        memcpy(PLM->buf,p, 3);
+        PLM->size=3;
+
+
+        NRCellIdentity_t *NRC=(NRCellIdentity_t *)calloc(1,sizeof(NRCellIdentity_t));
+        NRC->buf=(uint8_t *)calloc(5,sizeof(uint8_t));
+        memcpy(NRC->buf,nR, 5);
+        NRC->size=5;
+        NRC->bits_unused=4;
+
+        nrCGIs->pLMNIdentity=*PLM;
+        nrCGIs->nRCellIdentity=*NRC;
+
+        cellGlobal->present = CGI_PR_nR_CGI;
+        cellGlobal->choice.nR_CGI = nrCGIs;
+
+
+
+
+        MeasurementInfoItem_t **infoItem = (MeasurementInfoItem_t **)calloc(measIdcount, sizeof(MeasurementInfoItem_t *));
+        int Label_Item_count=1;
+
+        long *no_label=(long *) calloc(1,sizeof(long));//not giving label to the cell metrics/// don't know its bheaviour
+        *no_label=0;
+        int index = 0;
+        int c=0;
+        while (index < measIdcount) {
+
+                infoItem[index] = (MeasurementInfoItem_t *)calloc(1, sizeof(MeasurementInfoItem_t ));
+                MeasurementType_t *Mtype=(MeasurementType_t *)calloc(1,sizeof(MeasurementType_t));
+                Mtype->present=MeasurementType_PR_measName;
+                 Mtype->choice.measName.buf=(uint8_t *)calloc(strlen(id_tmp[index]),sizeof(uint8_t));
+                  memcpy(Mtype->choice.measName.buf,id_tmp[index], strlen(id_tmp[index]));
+                  Mtype->choice.measName.size=strlen(id_tmp[index]);
+
+
+                infoItem[index]->measType=*Mtype;
+
+
+                LabelInfoItem_t **L_Item = (LabelInfoItem_t **)calloc(Label_Item_count, sizeof(LabelInfoItem_t *));
+                MeasurementLabel_t *M_Label=(MeasurementLabel_t *)calloc(1,sizeof(MeasurementLabel_t));
+                M_Label->noLabel=no_label;
+                L_Item[0] = (LabelInfoItem_t *)calloc(1, sizeof(LabelInfoItem_t ));
+                L_Item[0]->measLabel=*M_Label;
+                int result1 = ASN_SEQUENCE_ADD(&infoItem[index]->labelInfoList, L_Item[0]);
+                if (result1==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory to add labelInfoList %s",strerror(errno));
+                        return -1;
+                }
+
+                int result2 = ASN_SEQUENCE_ADD(&actionDefFor1->measInfoList, infoItem[index]);
+                if (result2==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory to add measInfoList %s",strerror(errno));
+                        return -1;
+                }
+
+
+                index++;
+        }
 
-//     printf("%d", a);
 
-//     return 0;
-// }
+        actionDefFor1->granulPeriod = granulPeriod;
+        actionDefFor1->cellGlobalID = cellGlobal;
+
+
+        actionDef->ric_Style_Type = ric_style_type;
+        actionDef->actionDefinition_formats.present = E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format1;
+        actionDef->actionDefinition_formats.choice.actionDefinition_Format1 = actionDefFor1;
+
+
+        char errbuf[128];
+        size_t errbuf_len = 128;
+
+        int ret_constr = asn_check_constraints(&asn_DEF_E2SM_KPM_ActionDefinition, (void *) actionDef, errbuf, &errbuf_len);
+        if(ret_constr){
+                fprintf(stderr,"Constraints failed for encoding subscription request, %s", strerror(errno));
+                return -1;
+        }
+        //ATS_ALIGNED_BASIC_PER
+        //ATS_ALIGNED_CANONICAL_PER
+        //ATS_DER
+        asn_enc_rval_t encode_result = asn_encode_to_buffer(0,ATS_ALIGNED_CANONICAL_PER,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef, buf, *buf_size);
+        //asn_enc_rval_t encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_ActionDefinition, NULL,actionDef, buf, *buf_size);
+        if (encode_result.encoded == -1) {
+                fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
+                return -1;
+        }
+        else {
+                fprintf(stderr, "successfully\n");
+                xer_fprint(stdout, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                /*
+                FILE *fp = fopen("sandeep.bin", "wb");
+
+                asn_enc_rval_t ec =asn_encode(0, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef, write_out, fp);
+                fclose(fp);
+                if(ec.encoded ==-1) {
+                        fprintf(stderr, "Could not encode action def (at %s)\n”,ec.failed_type ? ec.failed_type->name : ”unknown");
+                       // exit(1);
+                } else {
+                        fprintf(stderr, "Created sandeep binary  with ATS_ALIGNED_CANONICAL_PER encoded action def\n");
+                }
+                FILE *fp2 = fopen("sandy.txt", "w");
+                int r=asn_fprint(fp2,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef);
+                fclose(fp2);
+                if (r==-1)
+                         fprintf(stderr, "failed asn_fprint\n");
+                else
+                         fprintf(stderr, "successfull asn_fprint\n");
+                */
+
+
+
+                return encode_result.encoded;
+        }
+}
+
+size_t e2sm_encode_ric_action_definition_format1_by_id(unsigned char *buf, size_t *buf_size, long *id , size_t measIdcount, long ric_style_type, unsigned long granulPeriod, unsigned char  *p, unsigned char *nR) {
+        E2SM_KPM_ActionDefinition_t *actionDef = (E2SM_KPM_ActionDefinition_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_t));
+        if (!actionDef) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        E2SM_KPM_ActionDefinition_Format1_t *actionDefFor1 = (E2SM_KPM_ActionDefinition_Format1_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_Format1_t));
+        if (!actionDefFor1) {
+                ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+        CGI_t *cellGlobal = (CGI_t *)calloc(1, sizeof(CGI_t));
+        if (!cellGlobal) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        NR_CGI_t *nrCGIs = (NR_CGI_t *)calloc(1, sizeof(NR_CGI_t));
+        if (!nrCGIs) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+
+        PLMNIdentity_t *PLM=(PLMNIdentity_t *)calloc(1,sizeof(PLMNIdentity_t));
+        PLM->buf=(uint8_t *)calloc(3,sizeof(uint8_t));
+        memcpy(PLM->buf,p, 3);
+        PLM->size=3;
+
+
+        NRCellIdentity_t *NRC=(NRCellIdentity_t *)calloc(1,sizeof(NRCellIdentity_t));
+        NRC->buf=(uint8_t *)calloc(5,sizeof(uint8_t));
+        memcpy(NRC->buf,nR, 5);
+        NRC->size=5;
+        NRC->bits_unused=4;
+
+        nrCGIs->pLMNIdentity=*PLM;
+        nrCGIs->nRCellIdentity=*NRC;
+
+        cellGlobal->present = CGI_PR_nR_CGI;
+        cellGlobal->choice.nR_CGI = nrCGIs;
+
+
+
+
+        MeasurementInfoItem_t **infoItem = (MeasurementInfoItem_t **)calloc(measIdcount, sizeof(MeasurementInfoItem_t *));
+        int Label_Item_count=1;
+
+        long *no_label=(long *) calloc(1,sizeof(long));//not giving label to the cell metrics/// don't know its bheaviour
+        *no_label=0;
+        int index = 0;
+        while (index < measIdcount) {
+
+                infoItem[index] = (MeasurementInfoItem_t *)calloc(1, sizeof(MeasurementInfoItem_t ));
+                MeasurementType_t *Mtype=(MeasurementType_t *)calloc(1,sizeof(MeasurementType_t));
+                Mtype->present=MeasurementType_PR_measID;
+                Mtype->choice.measID = id[index];
+                infoItem[index]->measType=*Mtype;
+
+
+                LabelInfoItem_t **L_Item = (LabelInfoItem_t **)calloc(Label_Item_count, sizeof(LabelInfoItem_t *));
+                MeasurementLabel_t *M_Label=(MeasurementLabel_t *)calloc(1,sizeof(MeasurementLabel_t));
+                M_Label->noLabel=no_label;
+                L_Item[0] = (LabelInfoItem_t *)calloc(1, sizeof(LabelInfoItem_t ));
+                L_Item[0]->measLabel=*M_Label;
+                int result1 = ASN_SEQUENCE_ADD(&infoItem[index]->labelInfoList, L_Item[0]);
+                if (result1==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory to add labelInfoList %s",strerror(errno));
+                        return -1;
+                }
+
+                int result2 = ASN_SEQUENCE_ADD(&actionDefFor1->measInfoList, infoItem[index]);
+                if (result2==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory to add measInfoList %s",strerror(errno));
+                        return -1;
+                }
+
+
+                index++;
+        }
+
+
+        actionDefFor1->granulPeriod = granulPeriod;
+        actionDefFor1->cellGlobalID = cellGlobal;
+
+
+        actionDef->ric_Style_Type = ric_style_type;
+        actionDef->actionDefinition_formats.present = E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format1;
+        actionDef->actionDefinition_formats.choice.actionDefinition_Format1 = actionDefFor1;
+
+
+        char errbuf[128];
+        size_t errbuf_len = 128;
+
+        int ret_constr = asn_check_constraints(&asn_DEF_E2SM_KPM_ActionDefinition, (void *) actionDef, errbuf, &errbuf_len);
+        if(ret_constr){
+                fprintf(stderr,"Constraints failed for encoding subscription request, %s", strerror(errno));
+                return -1;
+        }
+        //ATS_ALIGNED_BASIC_PER
+        //ATS_ALIGNED_CANONICAL_PER
+        //ATS_DER
+        asn_enc_rval_t encode_result = asn_encode_to_buffer(0,ATS_ALIGNED_CANONICAL_PER,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef, buf, *buf_size);
+        //asn_enc_rval_t encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_ActionDefinition, NULL,actionDef, buf, *buf_size);
+        if (encode_result.encoded == -1) {
+                fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
+                return -1;
+        }
+        else {
+                fprintf(stderr, "successfully\n");
+                xer_fprint(stdout, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                /*
+                FILE *fp = fopen("sandeep.bin", "wb");
+
+                asn_enc_rval_t ec =asn_encode(0, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef, write_out, fp);
+                fclose(fp);
+                if(ec.encoded ==-1) {
+                        fprintf(stderr, "Could not encode action def (at %s)\n”,ec.failed_type ? ec.failed_type->name : ”unknown");
+                        exit(1);
+                } else {
+                        fprintf(stderr, "Created sandeep binary  with ATS_ALIGNED_CANONICAL_PER encoded action def\n");
+                }
+                FILE *fp2 = fopen("sandy.txt", "w");
+                int r=asn_fprint(fp2,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef);
+                fclose(fp2);
+                if (r==-1)
+                         fprintf(stderr, "failed asn_fprint\n");
+                else
+                         fprintf(stderr, "successfull asn_fprint\n");
+                */
+
+                return encode_result.encoded;
+        }
+}
 
 ssize_t e2sm_encode_ric_event_trigger_definition(void *buffer, size_t buf_size, size_t event_trigger_count, long *RT_periods) {
        E2SM_KPM_EventTriggerDefinition_t *eventTriggerDef = (E2SM_KPM_EventTriggerDefinition_t *)calloc(1, sizeof(E2SM_KPM_EventTriggerDefinition_t));
@@ -64,27 +555,225 @@ ssize_t e2sm_encode_ric_event_trigger_definition(void *buffer, size_t buf_size,
            return encode_result.encoded;
        }
 }
-// int main() {
+size_t e2sm_encode_ric_action_definition_format3_by_name(unsigned char *buf, size_t *buf_size, char **id_tmp , size_t measIdcount, long ric_style_type, unsigned long granulPeriod) {
+        E2SM_KPM_ActionDefinition_t *actionDef = (E2SM_KPM_ActionDefinition_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_t));
+        if (!actionDef) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        E2SM_KPM_ActionDefinition_Format3_t *actionDefFor3 = (E2SM_KPM_ActionDefinition_Format3_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_Format3_t));
+        if (!actionDefFor3) {
+                ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+
+
+        MeasurementCondItem_t **CondItem = (MeasurementCondItem_t **)calloc(measIdcount, sizeof(MeasurementCondItem_t *));
+        int Label_Item_count=1;
+
+        long *no_label=(long *) calloc(1,sizeof(long));//not giving label to the cell metrics/// don't know its bheaviour
+        *no_label=0;
+        int index = 0;
+        while (index < measIdcount) {
+
+                CondItem[index] = (MeasurementCondItem_t *)calloc(1, sizeof(MeasurementCondItem_t ));
+                MeasurementType_t *Mtype=(MeasurementType_t *)calloc(1,sizeof(MeasurementType_t));
+                Mtype->present=MeasurementType_PR_measName;
+                Mtype->choice.measName.buf=(uint8_t *)calloc(strlen(id_tmp[index]),sizeof(uint8_t));
+                memcpy(Mtype->choice.measName.buf,id_tmp[index], strlen(id_tmp[index]));
+                Mtype->choice.measName.size=strlen(id_tmp[index]);
+                CondItem[index]->measType=*Mtype;
+
+
+
+                MatchingCondItem_t **M_Item = (MatchingCondItem_t **)calloc(Label_Item_count, sizeof(MatchingCondItem_t *));
+                MeasurementLabel_t *M_Label=(MeasurementLabel_t *)calloc(1,sizeof(MeasurementLabel_t));
+                M_Label->noLabel=no_label;
+                M_Item[0] = (MatchingCondItem_t *)calloc(1, sizeof(MatchingCondItem_t ));
+                M_Item[0]->present=MatchingCondItem_PR_measLabel;
+                M_Item[0]->choice.measLabel=M_Label;
+                int result1 = ASN_SEQUENCE_ADD(&CondItem[index]->matchingCond, M_Item[0]);
+                if (result1==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory for matchingCond to add matchingCondItem_t %s",strerror(errno));
+                        return -1;
+                }
+
+                int result2 = ASN_SEQUENCE_ADD(&actionDefFor3->measCondList, CondItem[index]);
+                if (result2==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory for measCondList to add MeasurementCondItem_t %s",strerror(errno));
+                        return -1;
+                }
+
+
+                index++;
+        }
+
+
+        actionDefFor3->granulPeriod = granulPeriod;
+
+
+        actionDef->ric_Style_Type = ric_style_type;
+        actionDef->actionDefinition_formats.present = E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format3;
+        actionDef->actionDefinition_formats.choice.actionDefinition_Format3 = actionDefFor3;
+
+
+        char errbuf[128];
+        size_t errbuf_len = 128;
+
+        int ret_constr = asn_check_constraints(&asn_DEF_E2SM_KPM_ActionDefinition, (void *) actionDef, errbuf, &errbuf_len);
+        if(ret_constr){
+                fprintf(stderr,"Constraints failed for encoding subscription request, %s", strerror(errno));
+                return -1;
+        }
+        //ATS_ALIGNED_BASIC_PER
+        //ATS_ALIGNED_CANONICAL_PER
+        //ATS_DER
+        asn_enc_rval_t encode_result = asn_encode_to_buffer(0,ATS_ALIGNED_CANONICAL_PER,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef, buf, *buf_size);
+        //asn_enc_rval_t encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_ActionDefinition, NULL,actionDef, buf, *buf_size);
+        if (encode_result.encoded == -1) {
+                fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
+                return -1;
+        }
+        else {
+                fprintf(stderr, "successfully\n");
+
+                xer_fprint(stdout, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                /*
+                FILE *fp = fopen("sandeep.bin", "wb");
+
+                asn_enc_rval_t ec =asn_encode(0, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef, write_out, fp);
+                fclose(fp);
+                if(ec.encoded ==-1) {
+                        fprintf(stderr, "Could not encode action def (at %s)\n”,ec.failed_type ? ec.failed_type->name : ”unknown");
+                        exit(1);
+                } else {
+                        fprintf(stderr, "Created sandeep binary  with ATS_ALIGNED_CANONICAL_PER encoded action def\n");
+                }
+                FILE *fp2 = fopen("sandy.txt", "w");
+                int r=asn_fprint(fp2,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef);
+                fclose(fp2);
+                if (r==-1)
+                         fprintf(stderr, "failed asn_fprint\n");
+                else
+                         fprintf(stderr, "successfull asn_fprint\n");
+                */
+                return encode_result.encoded;
+        }
+}
+size_t e2sm_encode_ric_action_definition_format3_by_id(unsigned char *buf, size_t *buf_size, long *id , size_t measIdcount, long ric_style_type, unsigned long granulPeriod) {
+        E2SM_KPM_ActionDefinition_t *actionDef = (E2SM_KPM_ActionDefinition_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_t));
+        if (!actionDef) {
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
+        E2SM_KPM_ActionDefinition_Format3_t *actionDefFor3 = (E2SM_KPM_ActionDefinition_Format3_t *)calloc(1, sizeof(E2SM_KPM_ActionDefinition_Format3_t));
+        if (!actionDefFor3) {
+                ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                fprintf(stderr, "alloc RIC ActionDefinition failed\n");
+                return -1;
+        }
+
 
-//     long id[] = {1,2,3,4};
 
-//     void *buffer[8] = {} ;
-//     unsigned int sizeBuffer = 8;
-//     long actionDefCount = 8;
-//     long measId = 1;
-//     long ricStyleType = 1;
-//     long periods = 1;
-//     void *plm[8] = {} ;
-//     unsigned int sizePlm = 8;
-//     void *nRc[8] = {} ;
-//     unsigned int sizenRc = 8;
+        MeasurementCondItem_t **CondItem = (MeasurementCondItem_t **)calloc(measIdcount, sizeof(MeasurementCondItem_t *));
+        int Label_Item_count=1;
 
-//     int a = e2sm_encode_ric_action_definition(buffer, sizeBuffer, actionDefCount, measId, ricStyleType, periods, plm, nRc);
+        long *no_label=(long *) calloc(1,sizeof(long));//not giving label to the cell metrics/// don't know its bheaviour
+        *no_label=0;
+        int index = 0;
+        while (index < measIdcount) {
 
-//     printf("%d", a);
+                CondItem[index] = (MeasurementCondItem_t *)calloc(1, sizeof(MeasurementCondItem_t ));
+                MeasurementType_t *Mtype=(MeasurementType_t *)calloc(1,sizeof(MeasurementType_t));
+                Mtype->present=MeasurementType_PR_measID;
+                Mtype->choice.measID = id[index];
+                CondItem[index]->measType=*Mtype;
+
+
+                //LabelInfoList_t *L_List=(LabelInfoList_t *)calloc(1,sizeof(LabelInfoList_t ));
+                MatchingCondItem_t **M_Item = (MatchingCondItem_t **)calloc(Label_Item_count, sizeof(MatchingCondItem_t *));
+                MeasurementLabel_t *M_Label=(MeasurementLabel_t *)calloc(1,sizeof(MeasurementLabel_t));
+                M_Label->noLabel=no_label;
+                M_Item[0] = (MatchingCondItem_t *)calloc(1, sizeof(MatchingCondItem_t ));
+                M_Item[0]->present=MatchingCondItem_PR_measLabel;
+                M_Item[0]->choice.measLabel=M_Label;
+                int result1 = ASN_SEQUENCE_ADD(&CondItem[index]->matchingCond, M_Item[0]);
+                if (result1==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory for matchingCond to add matchingCondItem_t %s",strerror(errno));
+                        return -1;
+                }
+
+                int result2 = ASN_SEQUENCE_ADD(&actionDefFor3->measCondList, CondItem[index]);
+                if (result2==-1)
+                {
+                        fprintf(stderr,"Unable to assign memory for measCondList to add MeasurementCondItem_t %s",strerror(errno));
+                        return -1;
+                }
+
+
+                index++;
+        }
+
+
+        actionDefFor3->granulPeriod = granulPeriod;
+        //actionDefFor3->cellGlobalID = cellGlobal; //optional
+
+
+        actionDef->ric_Style_Type = ric_style_type;
+        actionDef->actionDefinition_formats.present = E2SM_KPM_ActionDefinition__actionDefinition_formats_PR_actionDefinition_Format3;
+        actionDef->actionDefinition_formats.choice.actionDefinition_Format3 = actionDefFor3;
+
+
+        char errbuf[128];
+        size_t errbuf_len = 128;
+
+        int ret_constr = asn_check_constraints(&asn_DEF_E2SM_KPM_ActionDefinition, (void *) actionDef, errbuf, &errbuf_len);
+        if(ret_constr){
+                fprintf(stderr,"Constraints failed for encoding subscription request, %s", strerror(errno));
+                return -1;
+        }
+        //ATS_ALIGNED_BASIC_PER
+        //ATS_ALIGNED_CANONICAL_PER
+        //ATS_DER
+        asn_enc_rval_t encode_result = asn_encode_to_buffer(0,ATS_ALIGNED_CANONICAL_PER,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef, buf, *buf_size);
+        //asn_enc_rval_t encode_result = uper_encode_to_buffer(&asn_DEF_E2SM_KPM_ActionDefinition, NULL,actionDef, buf, *buf_size);
+        if (encode_result.encoded == -1) {
+                fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
+                return -1;
+        }
+        else {
+                fprintf(stderr, "successfully\n");
+                xer_fprint(stdout, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef);
+                /*
+                FILE *fp = fopen("sandeep.bin", "wb");
+
+                asn_enc_rval_t ec =asn_encode(0, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_E2SM_KPM_ActionDefinition, actionDef, write_out, fp);
+                fclose(fp);
+                if(ec.encoded ==-1) {
+                        fprintf(stderr, "Could not encode action def (at %s)\n”,ec.failed_type ? ec.failed_type->name : ”unknown");
+                        exit(1);
+                } else {
+                        fprintf(stderr, "Created sandeep binary  with ATS_ALIGNED_CANONICAL_PER encoded action def\n");
+                }
+                FILE *fp2 = fopen("sandy.txt", "w");
+                int r=asn_fprint(fp2,&asn_DEF_E2SM_KPM_ActionDefinition,actionDef);
+                fclose(fp2);
+                if (r==-1)
+                         fprintf(stderr, "failed asn_fprint\n");
+                else
+                         fprintf(stderr, "successfull asn_fprint\n");
+                */
+                return encode_result.encoded;
+        }
+}
 
-//     return 0;
-// }
 
 /*
 ssize_t e2sm_encode_ric_action_definition(void *buffer, size_t buf_size, long action_Def_count, long meas_ID, long ric_style_type, long GR_periods, Plm plm, Nrc nRc) {
index a3bb5f3..fb2a636 100644 (file)
@@ -52,6 +52,9 @@
 #include<MeasurementCondList.h>
 #include<MeasurementCondItem.h>
 #include<MatchingCondItem.h>
+#include<E2SM-KPM-RANfunction-Description.h>
+#include<RIC-ReportStyle-Item.h>
+#include<MeasurementInfo-Action-Item.h>
 
 #include <MeasurementTypeID.h>
 #include <LabelInfoItem.h>
@@ -93,9 +96,26 @@ typedef struct Nrc {
        int size;
        int bits_unused;
 } Nrc;
+
 */
+typedef struct encode_act_Def_result{
+       int * array;
+       int length;
+} encode_act_Def_result_t;
 ssize_t e2sm_encode_ric_event_trigger_definition(void *buffer, size_t buf_size, size_t event_trigger_count, long *RT_periods);
 //ssize_t e2sm_encode_ric_action_definition(void *buffer, size_t buf_size, long action_Def_count, long meas_ID, long ric_style_type, long GR_periods, Plm plm, Nrc nRc);
+//
+
+struct encode_act_Def_result encode_action_Definition(const char *hex_values, int determine);
+
+size_t e2sm_encode_ric_action_definition_format1_by_name(unsigned char *buf, size_t *buf_size, const char **id_tmp , size_t measIdcount, long ric_style_type, unsigned long granulPeriod, unsigned char  *p, unsigned char *nR);
+
+size_t e2sm_encode_ric_action_definition_format1_by_id(unsigned char *buf, size_t *buf_size, long *id , size_t measIdcount, long ric_style_type, unsigned long granulPeriod, unsigned char  *p, unsigned char *nR);
+
+size_t e2sm_encode_ric_action_definition_format3_by_name(unsigned char *buf, size_t *buf_size, char **id_tmp , size_t measIdcount, long ric_style_type, unsigned long granulPeriod);
+
+size_t e2sm_encode_ric_action_definition_format3_by_id(unsigned char *buf, size_t *buf_size, long *id , size_t measIdcount, long ric_style_type, unsigned long granulPeriod);
+
 E2SM_KPM_IndicationHeader_t* e2sm_decode_ric_indication_header(void *buffer, size_t buf_size);
 void e2sm_free_ric_indication_header(E2SM_KPM_IndicationHeader_t* indHdr);
 E2SM_KPM_IndicationMessage_t* e2sm_decode_ric_indication_message(void *buffer, size_t buf_size);