RICPLT-2983 SubDelResp go asn into use 26/2226/1
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Tue, 14 Jan 2020 17:25:00 +0000 (19:25 +0200)
committerJuha Hyttinen <juha.hyttinen@nokia.com>
Tue, 14 Jan 2020 17:25:23 +0000 (19:25 +0200)
Change-Id: Ia62f16553d1b6db707cfab1b0e4b10418e505200
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
pkg/control/control.go
pkg/control/e2ap.go
pkg/control/transaction.go

index eb2852a..55f05e7 100755 (executable)
@@ -381,7 +381,7 @@ func (c *Control) handleSubscriptionFailure(params *RMRParams) {
        packedData, err := c.e2ap.PackSubscriptionFailure(trans.SubFailMsg)
        if err != nil {
                //TODO error handling improvement
-               xapp.Logger.Error("SubFail: %s for trans %s (continue still)", err.Error(), trans)
+               xapp.Logger.Error("SubFail: %s for trans %s (continuing cleaning)", err.Error(), trans)
        } else {
                //Optimize and store packed message to be sent.
                trans.Payload = packedData.Buf
@@ -556,25 +556,43 @@ func (c *Control) handleSubscriptionDeleteRequest(params *RMRParams) {
 func (c *Control) handleSubscriptionDeleteResponse(params *RMRParams) (err error) {
        xapp.Logger.Info("SubDelResp from E2T:%s", params.String())
 
-       payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteResponseSequenceNumber(params.Payload)
+       //
+       //
+       //
+       SubDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
        if err != nil {
-               xapp.Logger.Error("SubDelResp: Unable to get Sequence Number from Payload. Dropping this msg. Err: %v, SubId: %v, Xid: %s, Payload %X", err, params.SubId, params.Xid, params.Payload)
+               xapp.Logger.Error("SubDelResp: %s Dropping this msg. %s", err.Error(), params.String())
                return
        }
-       xapp.Logger.Info("SubDelResp: Received payloadSeqNum: %v", payloadSeqNum)
 
-       subs := c.registry.GetSubscription(payloadSeqNum)
+       //
+       //
+       //
+       subs := c.registry.GetSubscription(uint16(SubDelRespMsg.RequestId.Seq))
+       if subs == nil && params.SubId > 0 {
+               subs = c.registry.GetSubscription(uint16(params.SubId))
+       }
+
        if subs == nil {
-               xapp.Logger.Error("SubDelResp: Unknown payloadSeqNum. Dropping this msg. PayloadSeqNum: %v, SubId: %v", payloadSeqNum, params.SubId)
+               xapp.Logger.Error("SubDelResp: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", SubDelRespMsg.RequestId.Seq, params.SubId, params.String())
                return
        }
+       xapp.Logger.Info("SubDelResp: subscription found payloadSeqNum: %d, SubId: %d", SubDelRespMsg.RequestId.Seq, subs.GetSubId())
 
+       //
+       //
+       //
        trans := subs.GetTransaction()
        if trans == nil {
-               xapp.Logger.Error("SubDelResp: Unknown trans. Dropping this msg. PayloadSeqNum: %v, SubId: %v", subs.GetSubId(), params.SubId)
+               xapp.Logger.Error("SubDelResp: Unknown trans. Dropping this msg. SubId: %d", subs.GetSubId())
                return
        }
 
+       trans.SubDelRespMsg = SubDelRespMsg
+
+       //
+       //
+       //
        c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()))
 
        responseReceived := trans.CheckResponseReceived()
@@ -583,9 +601,19 @@ func (c *Control) handleSubscriptionDeleteResponse(params *RMRParams) (err error
                return
        }
 
-       if trans.ForwardRespToXapp == true {
-               c.rmrReplyToSender("SubDelResp to xapp", subs, trans, params.Mtype, params.Payload, params.PayloadLen)
-               time.Sleep(3 * time.Second)
+       packedData, err := c.e2ap.PackSubscriptionDeleteResponse(trans.SubDelRespMsg)
+       if err != nil {
+               xapp.Logger.Error("SubDelResp: %s for trans %s (continuing cleaning)", err.Error(), trans)
+       } else {
+               //Optimize and store packed message to be sent.
+               trans.Payload = packedData.Buf
+               trans.PayloadLen = len(packedData.Buf)
+
+               if trans.ForwardRespToXapp == true {
+                       c.rmrReplyToSender("SubDelResp to xapp", subs, trans, 12021, trans.Payload, trans.PayloadLen)
+                       time.Sleep(3 * time.Second)
+               }
+
        }
 
        trans.Release()
index 5f567ab..5f4bb44 100644 (file)
@@ -39,29 +39,6 @@ var packerif e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
 type E2ap struct {
 }
 
-/* RICsubscriptionDeleteResponse */
-
-// Used by submgr, e2t test stub
-func (c *E2ap) GetSubscriptionDeleteResponseSequenceNumber(payload []byte) (subId uint16, err error) {
-       cptr := unsafe.Pointer(&payload[0])
-       cret := C.e2ap_get_ric_subscription_delete_response_sequence_number(cptr, C.size_t(len(payload)))
-       if cret < 0 {
-               return 0, fmt.Errorf("e2ap wrapper is unable to get Subscirption Delete Response Sequence Number due to wrong or invalid payload. Erroxappde: %v", cret)
-       }
-       subId = uint16(cret)
-       return
-}
-
-// Used by e2t test stub
-func (c *E2ap) SetSubscriptionDeleteResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (err error) {
-       cptr := unsafe.Pointer(&payload[0])
-       size := C.e2ap_set_ric_subscription_delete_response_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
-       if size < 0 {
-               return fmt.Errorf("e2ap wrapper is unable to set Subscription Delete Response Sequence Number due to wrong or invalid payload. Erroxappde: %v", size)
-       }
-       return
-}
-
 /* RICsubscriptionDeleteFailure */
 
 // Used by submgr
index 5d13d8c..9821fac 100644 (file)
@@ -43,18 +43,19 @@ func (key *TransactionXappKey) String() string {
 //-----------------------------------------------------------------------------
 type Transaction struct {
        mutex             sync.Mutex
-       tracker           *Tracker                            //tracker instance
-       Subs              *Subscription                       //related subscription
-       RmrEndpoint       RmrEndpoint                         //xapp endpoint
-       Mtype             int                                 //type of initiating message
-       Xid               string                              //xapp xid in req
-       Meid              *xapp.RMRMeid                       //meid transaction related
-       SubReqMsg         *e2ap.E2APSubscriptionRequest       //SubReq TODO: maybe own transactions per type
-       SubRespMsg        *e2ap.E2APSubscriptionResponse      //SubResp TODO: maybe own transactions per type
-       SubFailMsg        *e2ap.E2APSubscriptionFailure       //SubFail TODO: maybe own transactions per type
-       SubDelReqMsg      *e2ap.E2APSubscriptionDeleteRequest //SubDelReq TODO: maybe own transactions per type
-       Payload           []byte                              //packed message to optimize retransmissions
-       PayloadLen        int                                 //packed message len to optimize  retransmissions
+       tracker           *Tracker                             //tracker instance
+       Subs              *Subscription                        //related subscription
+       RmrEndpoint       RmrEndpoint                          //xapp endpoint
+       Mtype             int                                  //type of initiating message
+       Xid               string                               //xapp xid in req
+       Meid              *xapp.RMRMeid                        //meid transaction related
+       SubReqMsg         *e2ap.E2APSubscriptionRequest        //SubReq TODO: maybe own transactions per type
+       SubRespMsg        *e2ap.E2APSubscriptionResponse       //SubResp TODO: maybe own transactions per type
+       SubFailMsg        *e2ap.E2APSubscriptionFailure        //SubFail TODO: maybe own transactions per type
+       SubDelReqMsg      *e2ap.E2APSubscriptionDeleteRequest  //SubDelReq TODO: maybe own transactions per type
+       SubDelRespMsg     *e2ap.E2APSubscriptionDeleteResponse //SubDelResp TODO: maybe own transactions per type
+       Payload           []byte                               //packed message to optimize retransmissions
+       PayloadLen        int                                  //packed message len to optimize  retransmissions
        RespReceived      bool
        ForwardRespToXapp bool
 }