Squash-merging e2ap-v2.0 branch
[ric-plt/e2mgr.git] / E2Manager / models / ric_service_update_ack_message.go
index 1388f14..9ba085c 100644 (file)
 package models
 
 import (
-        "encoding/xml"
+       "encoding/xml"
 )
 
 type RicServiceAckRANFunctionIDItem struct {
        Text                string `xml:",chardata"`
-        RanFunctionID       uint32 `xml:"ranFunctionID"`
-        RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
+       RanFunctionID       uint32 `xml:"ranFunctionID"`
+       RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
 }
 
 type RICserviceUpdateAcknowledgeProtocolIESingleContainer struct {
-               Text        string `xml:",chardata"`
-               Id          string `xml:"id"`
-               Criticality struct {
-                               Text   string `xml:",chardata"`
-                               //Ignore string `xml:"ignore"`
-                               Reject string `xml:"reject"`
-               } `xml:"criticality"`
-               Value struct {
-                               Text              string `xml:",chardata"`
-                               RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"`
-               } `xml:"value"`
+       Text        string `xml:",chardata"`
+       Id          string `xml:"id"`
+       Criticality struct {
+               Text string `xml:",chardata"`
+               //Ignore string `xml:"ignore"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
+       Value struct {
+               Text              string                         `xml:",chardata"`
+               RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"`
+       } `xml:"value"`
 }
 
 type RICserviceUpdateAcknowledgeIEs struct {
        Text        string `xml:",chardata"`
-        ID          string `xml:"id"`
-        Criticality struct {
-                Text   string `xml:",chardata"`
-                Reject string `xml:"reject"`
-        } `xml:"criticality"`
-        Value struct {
+       ID          string `xml:"id"`
+       Criticality struct {
                Text   string `xml:",chardata"`
-               RANfunctionsIDList struct {
-                       Text   string `xml:",chardata"`
-                       ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
-               } `xml:"RANfunctionsID-List"`
-       }`xml:"value"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
+       Value interface{} `xml:"value"`
 }
 
+type RICserviceUpdateAcknowledgeTransactionID struct {
+       Text          string `xml:",chardata"`
+       TransactionID string `xml:"TransactionID"`
+}
+
+type RICserviceUpdateAcknowledgeRANfunctionsList struct {
+       Text               string `xml:",chardata"`
+       RANfunctionsIDList struct {
+               Text                      string                                                 `xml:",chardata"`
+               ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+       } `xml:"RANfunctionsID-List"`
+}
 type RicServiceUpdateAckSuccessfulOutcome struct {
-       XMLName xml.Name        `xml:"successfulOutcome"`
-        Text          string `xml:",chardata"`
-        ProcedureCode string `xml:"procedureCode"`
-        Criticality   struct {
-                Text   string `xml:",chardata"`
-                Reject string `xml:"reject"`
-        } `xml:"criticality"`
+       XMLName       xml.Name `xml:"successfulOutcome"`
+       Text          string   `xml:",chardata"`
+       ProcedureCode string   `xml:"procedureCode"`
+       Criticality   struct {
+               Text   string `xml:",chardata"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
        Value struct {
-               Text            string `xml:",chardata"`
-               RICserviceUpdateAcknowledge  RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
+               Text                        string                      `xml:",chardata"`
+               RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
        } `xml:"value"`
 }
 
 type RICserviceUpdateAcknowledge struct {
        Text        string `xml:",chardata"`
        ProtocolIEs struct {
-               Text               string `xml:",chardata"`
+               Text                           string                           `xml:",chardata"`
                RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
        } `xml:"protocolIEs"`
 }
 
 type RicServiceUpdateAckE2APPDU struct {
-        XMLName xml.Name `xml:"E2AP-PDU"`
-        Text    string `xml:",chardata"`
-        InitiatingMessage interface{}
+       XMLName           xml.Name `xml:"E2AP-PDU"`
+       Text              string   `xml:",chardata"`
+       SuccessfulOutcome interface{}
 }
 
-func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem) RicServiceUpdateAckE2APPDU {
-       successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{}
-       successfulOutcome.ProcedureCode = "7"
-       if len(ricServiceUpdate) == 0 {
-               return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
+func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem, txId string) RicServiceUpdateAckE2APPDU {
+
+       txIE := RICserviceUpdateAcknowledgeIEs{
+               ID: ProtocolIE_ID_id_TransactionID,
+               Value: RICserviceUpdateAcknowledgeTransactionID{
+                       TransactionID: txId,
+               },
        }
 
-       ricServiceUpdateAcknowledgeIEs := make([]RICserviceUpdateAcknowledgeIEs, 1)
-       ricServiceUpdateAcknowledgeIEs[0].ID = "9"
        protocolIESingleContainer := make([]RICserviceUpdateAcknowledgeProtocolIESingleContainer, len(ricServiceUpdate))
        for i := 0; i < len(ricServiceUpdate); i++ {
                protocolIESingleContainer[i].Value.RANfunctionIDItem = ricServiceUpdate[i]
-               protocolIESingleContainer[i].Id = "6"
+               protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item
+       }
+
+       // mandatory RANFunctionsAccepted
+       functionListIE := RICserviceUpdateAcknowledgeIEs{
+               ID: ProtocolIE_ID_id_RANfunctionsAccepted,
+               Value: RICserviceUpdateAcknowledgeRANfunctionsList{
+                       RANfunctionsIDList: struct {
+                               Text                      string                                                 `xml:",chardata"`
+                               ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+                       }{
+                               ProtocolIESingleContainer: protocolIESingleContainer,
+                       },
+               },
        }
-       ricServiceUpdateAcknowledgeIEs[0].Value.RANfunctionsIDList.ProtocolIESingleContainer = protocolIESingleContainer
-       successfulOutcome.Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs = ricServiceUpdateAcknowledgeIEs
-       return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
-}
 
+       successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{
+               ProcedureCode: ProcedureCode_id_RICserviceUpdate,
+               Value: struct {
+                       Text                        string                      `xml:",chardata"`
+                       RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
+               }{
+                       RICserviceUpdateAcknowledge: RICserviceUpdateAcknowledge{
+                               ProtocolIEs: struct {
+                                       Text                           string                           `xml:",chardata"`
+                                       RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
+                               }{
+                                       RICserviceUpdateAcknowledgeIEs: []RICserviceUpdateAcknowledgeIEs{txIE, functionListIE},
+                               },
+                       },
+               },
+       }
+
+       return RicServiceUpdateAckE2APPDU{SuccessfulOutcome: successfulOutcome}
+}