New submgr for testing. Tagged as ric-plt-submgr:r3-test-v2. Tested that submgr can receive and forward messages correctly.

Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
Change-Id: Ib6a472c3205fbf2e2d9a030282b7071a12ee8b0d
diff --git a/e2ap/wrapper.c b/e2ap/wrapper.c
index 231e777..9e535c8 100644
--- a/e2ap/wrapper.c
+++ b/e2ap/wrapper.c
@@ -206,3 +206,95 @@
     }
     return -1;
 }
+
+// This function is not used currently. Can be deleted if not needed
+ssize_t  e2ap_set_ric_subscription_failure_sequence_number(void *buffer, size_t buf_size, long sequence_number)
+{
+    E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size);
+    if ( pdu != NULL && pdu->present == E2AP_PDU_PR_unsuccessfulOutcome )
+    {
+        UnsuccessfulOutcome_t* unsuccessfulOutcome = pdu->choice.unsuccessfulOutcome;
+        if ( unsuccessfulOutcome->procedureCode == ProcedureCode_id_ricSubscription
+            && unsuccessfulOutcome->value.present == UnsuccessfulOutcome__value_PR_RICsubscriptionFailure )
+        {
+            RICsubscriptionFailure_t* subscriptionFailure = &unsuccessfulOutcome->value.choice.RICsubscriptionFailure;
+            for (int i = 0; i < subscriptionFailure->protocolIEs.list.count; ++i )
+            {
+                if ( subscriptionFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID )
+                {
+                    subscriptionFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number;
+                    return encode_E2AP_PDU(pdu, buffer, buf_size);
+                }
+            }
+        }
+    }
+    return -1;
+}
+
+long e2ap_get_ric_subscription_failure_sequence_number(void *buffer, size_t buf_size)
+{
+    E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size);
+    if ( pdu != NULL && pdu->present == E2AP_PDU_PR_unsuccessfulOutcome )
+    {
+        UnsuccessfulOutcome_t* unsuccessfulOutcome = pdu->choice.unsuccessfulOutcome;
+        if ( unsuccessfulOutcome->procedureCode == ProcedureCode_id_ricSubscription
+            && unsuccessfulOutcome->value.present == UnsuccessfulOutcome__value_PR_RICsubscriptionFailure )
+        {
+            RICsubscriptionFailure_t* subscriptionFailure = &unsuccessfulOutcome->value.choice.RICsubscriptionFailure;;
+            for (int i = 0; i < subscriptionFailure->protocolIEs.list.count; ++i )
+            {
+                if ( subscriptionFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID )
+                {
+                    return subscriptionFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber;
+                }
+            }
+        }
+    }
+    return -1;
+}
+
+// This function is not used currently. Can be deleted if not needed
+ssize_t  e2ap_set_ric_subscription_delete_failure_sequence_number(void *buffer, size_t buf_size, long sequence_number)
+{
+    E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size);
+    if ( pdu != NULL && pdu->present == E2AP_PDU_PR_unsuccessfulOutcome )
+    {
+        UnsuccessfulOutcome_t* unsuccessfulOutcome = pdu->choice.unsuccessfulOutcome;
+        if ( unsuccessfulOutcome->procedureCode == ProcedureCode_id_ricSubscriptionDelete
+            && unsuccessfulOutcome->value.present == UnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure )
+        {
+            RICsubscriptionDeleteFailure_t* subscriptionDeleteFailure = &unsuccessfulOutcome->value.choice.RICsubscriptionDeleteFailure;
+            for (int i = 0; i < subscriptionDeleteFailure->protocolIEs.list.count; ++i )
+            {
+                if ( subscriptionDeleteFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID )
+                {
+                    subscriptionDeleteFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number;
+                    return encode_E2AP_PDU(pdu, buffer, buf_size);
+                }
+            }
+        }
+    }
+    return -1;
+}
+
+long e2ap_get_ric_subscription_delete_failure_sequence_number(void *buffer, size_t buf_size)
+{
+    E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size);
+    if ( pdu != NULL && pdu->present == E2AP_PDU_PR_unsuccessfulOutcome )
+    {
+        UnsuccessfulOutcome_t* unsuccessfulOutcome = pdu->choice.unsuccessfulOutcome;
+        if ( unsuccessfulOutcome->procedureCode == ProcedureCode_id_ricSubscriptionDelete
+            && unsuccessfulOutcome->value.present == UnsuccessfulOutcome__value_PR_RICsubscriptionDeleteFailure )
+        {
+            RICsubscriptionDeleteFailure_t* subscriptionDeleteFailure = &unsuccessfulOutcome->value.choice.RICsubscriptionDeleteFailure;;
+            for (int i = 0; i < subscriptionDeleteFailure->protocolIEs.list.count; ++i )
+            {
+                if ( subscriptionDeleteFailure->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID )
+                {
+                    return subscriptionDeleteFailure->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber;
+                }
+            }
+        }
+    }
+    return -1;
+}
diff --git a/e2ap/wrapper.h b/e2ap/wrapper.h
index 4a79beb..4138d62 100644
--- a/e2ap/wrapper.h
+++ b/e2ap/wrapper.h
@@ -5,9 +5,12 @@
 #include "RICsubscriptionResponse.h"
 #include "RICsubscriptionDeleteRequest.h"
 #include "RICsubscriptionDeleteResponse.h"
+#include "RICsubscriptionFailure.h"
+#include "RICsubscriptionDeleteFailure.h"
 #include "E2AP-PDU.h"
 #include "InitiatingMessage.h"
 #include "SuccessfulOutcome.h"
+#include "UnsuccessfulOutcome.h"
 #include "ProtocolIE-Container.h"
 #include "ProtocolIE-Field.h"
 
@@ -30,6 +33,14 @@
 long e2ap_get_ric_subscription_delete_response_sequence_number(void *buffer, size_t buf_size);
 ssize_t  e2ap_set_ric_subscription_delete_response_sequence_number(void *buffer, size_t buf_size, long sequence_number);
 
+/* RICsubscriptionFailure */
+long e2ap_get_ric_subscription_failure_sequence_number(void *buffer, size_t buf_size);
+// This function is not used currently. Can be deleted if not needed
+ssize_t  e2ap_set_ric_subscription_failure_sequence_number(void *buffer, size_t buf_size, long sequence_number);
 
+/* RICsubscriptionFailure */
+long e2ap_get_ric_subscription_delete_failure_sequence_number(void *buffer, size_t buf_size);
+// This function is not used currently. Can be deleted if not needed
+ssize_t  e2ap_set_ric_subscription_delete_failure_sequence_number(void *buffer, size_t buf_size, long sequence_number);
 
 #endif /* _WRAPPER_H_ */
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..830fedf
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,269 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.1 h1:9RfO/Whehaaq5KiJTT7s+YOzmi9mT1C3HktfhwwMEmw=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21 h1:eK9nUZOTMJ/EnMpH9bkWtMgOvCn3u4+PNCb9gu10s6w=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21 h1:PQ/Mu2ol+8Oh/0BqCWWhPlVVoRCg5dQDEGm4+Opp5w4=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21/go.mod h1:GXiXLz4ORBeIr0FLIbzENRykgh3Po5uPkX2jICxnRF0=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21 h1:N3UbqJ9WqC8JEz/TwHHwZwCFAW6VTlZLpD5lnbdD+Y8=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21/go.mod h1:SQBZLy1HP94i1vQ3y730wGFsrHqZtgPaEkzPgtqBNw0=
+gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0 h1:7edCLIQtk9xCwxTtLRUlXr8wQ6nmr/Mo4ZoqjF3m0NE=
+gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0/go.mod h1:2Y8gw2jqj9urI8VFqFQn7BX0J3A852+YrXVV9V8gOt4=
+gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.20 h1:qf/oWdgXq5iCB38rHO/NfHgD21DOGpKELPgkmvpDExA=
+gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.20/go.mod h1:WHzMFLWFYnKZzAT76Lu8wXqcM9MQ9hHM0sxlV45icSw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
+github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
+github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
+github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
+github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
+github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
+github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
+github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
+github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk=
+github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk=
+github.com/go-openapi/analysis v0.19.5 h1:8b2ZgKfKIUTVQpTb77MoRDIMEIwvDVw40o3aOXdfYzI=
+github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU=
+github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0=
+github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0=
+github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY=
+github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94=
+github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
+github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
+github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
+github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
+github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
+github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
+github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
+github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
+github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
+github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
+github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
+github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
+github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs=
+github.com/go-openapi/loads v0.19.3 h1:jwIoahqCmaA5OBoc/B+1+Mu2L0Gr8xYQnbeyQEo/7b0=
+github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI=
+github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA=
+github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64=
+github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4=
+github.com/go-openapi/runtime v0.19.7 h1:b2zcE9GCjDVtguugU7+S95vkHjwQEjz/lB+8LOuA9Nw=
+github.com/go-openapi/runtime v0.19.7/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo=
+github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
+github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
+github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
+github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc=
+github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
+github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
+github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
+github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY=
+github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU=
+github.com/go-openapi/strfmt v0.19.3 h1:eRfyY5SkaNJCAwmmMcADjY31ow9+N7MCLW7oRkbsINA=
+github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU=
+github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
+github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
+github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
+github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4=
+github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA=
+github.com/go-openapi/validate v0.19.3 h1:PAH/2DylwWcIU1s0Y7k3yNmeAgWOcKrNE2Q7Ww/kCg4=
+github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo=
+github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4=
+github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
+github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
+github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
+github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
+github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
+github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
+github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.3 h1:9iH4JKXLzFbOAdtqv/a+j8aewx2Y8lAjAydhbaScPF8=
+github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/common v0.4.0 h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM=
+github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084 h1:sofwID9zm4tzrgykg80hfFph1mryUeLRsUfoocVVmRY=
+github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
+github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
+github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
+github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
+github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
+go.mongodb.org/mongo-driver v1.1.1 h1:Sq1fR+0c58RME5EoqKdjkiQAmPjmfHlZOoRI6fTUOcs=
+go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
+golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/pkg/control/client.go b/pkg/control/client.go
index 14e2455..d377d8e 100644
--- a/pkg/control/client.go
+++ b/pkg/control/client.go
@@ -35,14 +35,10 @@
 	xappDeleteParams *rtmgrhandle.DeleteXappSubscriptionHandleParams
 }
 
-func (rc *RtmgrClient) SubscriptionRequestUpdate() error {
+func (rc *RtmgrClient) SubscriptionRequestUpdate(subRouteAction SubRouteInfo) error {
 	xapp.Logger.Debug("SubscriptionRequestUpdate() invoked")
-	subRouteAction := <-SubscriptionReqChan
-	// Routing manager handles subscription id as int32 to accomodate -1 and uint16 values
 	subID := int32(subRouteAction.SubID)
-
-	xapp.Logger.Debug("Subscription action details received: ", subRouteAction)
-
+	xapp.Logger.Debug("Subscription action details received. subRouteAction.Command: %v, Address %s, Port %v, subID %v", int16(subRouteAction.Command), subRouteAction.Address, subRouteAction.Port, subID)
 	xappSubReq := rtmgr_models.XappSubscriptionData{&subRouteAction.Address, &subRouteAction.Port, &subID}
 
 	switch subRouteAction.Command {
@@ -65,6 +61,7 @@
 			return nil
 		}
 	default:
+		xapp.Logger.Debug("Unknown subRouteAction.Command: %v, subID: %v", subRouteAction.Command, subRouteAction.Address, subRouteAction.Port, subID)
 		return nil
 	}
 }
diff --git a/pkg/control/control.go b/pkg/control/control.go
index dc8c5e0..af629a1 100644
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -32,23 +32,30 @@
 	"math/rand"
 	"strconv"
 	"time"
+	"sync"	
 )
 
+var rmrSendMutex = &sync.Mutex{}
+
+var subReqTime time.Duration = 2 * time.Second
+var SubDelReqTime time.Duration = 2 * time.Second
+
 type Control struct {
 	e2ap        *E2ap
 	registry    *Registry
 	rtmgrClient *RtmgrClient
 	tracker     *Tracker
 	rcChan      chan *xapp.RMRParams
+	timerMap	*TimerMap
 }
 
 type RMRMeid struct {
 	PlmnID string
 	EnbID  string
+	RanName string
 }
 
 var seedSN uint16
-var SubscriptionReqChan = make(chan SubRouteInfo, 10)
 
 const (
 	CREATE Action = 0
@@ -57,6 +64,7 @@
 )
 
 func init() {
+	xapp.Logger.Info("SUBMGR /ric-plt-submgr:r3-test-v2")
 	viper.AutomaticEnv()
 	viper.SetEnvPrefix("submgr")
 	viper.AllowEmptyEnv(true)
@@ -78,13 +86,16 @@
 	tracker := new(Tracker)
 	tracker.Init()
 
+	timerMap := new(TimerMap)
+	timerMap.Init()
+
 	transport := httptransport.New(viper.GetString("rtmgr.HostAddr")+":"+viper.GetString("rtmgr.port"), viper.GetString("rtmgr.baseUrl"), []string{"http"})
 	client := rtmgrclient.New(transport, strfmt.Default)
 	handle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
 	deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
 	rtmgrClient := RtmgrClient{client, handle, deleteHandle}
 
-	return Control{new(E2ap), registry, &rtmgrClient, tracker, make(chan *xapp.RMRParams)}
+	return Control{new(E2ap), registry, &rtmgrClient, tracker, make(chan *xapp.RMRParams),timerMap}
 }
 
 func (c *Control) Run() {
@@ -98,16 +109,33 @@
 }
 
 func (c *Control) rmrSend(params *xapp.RMRParams) (err error) {
+	status := false
+	i := 1
+	rmrSendMutex.Lock()
+	for ; i <= 10 && status == false; i++ { 
+		status = xapp.Rmr.Send(params, false)
+		if status == false {
+			xapp.Logger.Info("rmr.Send() failed. Retry count %v, Mtype: %v, SubId: %v, Xid %s",i, params.Mtype, params.SubId, params.Xid)
+			time.Sleep(500 * time.Millisecond)
+		}
+	}
+	if status == false {
+		err = errors.New("rmr.Send() failed")
+		xapp.Rmr.Free(params.Mbuf)
+	}
+	rmrSendMutex.Unlock()
+	
+	/*
 	if !xapp.Rmr.Send(params, false) {
 		err = errors.New("rmr.Send() failed")
+		xapp.Rmr.Free(params.Mbuf)
 	}
+	*/	
 	return
 }
 
 func (c *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) {
-	if !xapp.Rmr.Send(params, true) {
-		err = errors.New("rmr.Send() failed")
-	}
+	c.rmrSend(params)
 	return
 }
 
@@ -116,13 +144,15 @@
 		msg := <-c.rcChan
 		switch msg.Mtype {
 		case xapp.RICMessageTypes["RIC_SUB_REQ"]:
-			c.handleSubscriptionRequest(msg)
+			go c.handleSubscriptionRequest(msg)
 		case xapp.RICMessageTypes["RIC_SUB_RESP"]:
-			c.handleSubscriptionResponse(msg)
+			go c.handleSubscriptionResponse(msg)
+		case xapp.RICMessageTypes["RIC_SUB_FAILURE"]:
+			go c.handleSubscriptionFailure(msg)
 		case xapp.RICMessageTypes["RIC_SUB_DEL_REQ"]:
-			c.handleSubscriptionDeleteRequest(msg)
+			go c.handleSubscriptionDeleteRequest(msg)
 		case xapp.RICMessageTypes["RIC_SUB_DEL_RESP"]:
-			c.handleSubscriptionDeleteResponse(msg)
+			go c.handleSubscriptionDeleteResponse(msg)
 		default:
 			err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded")
 			xapp.Logger.Error("Unknown message type: %v", err)
@@ -131,15 +161,16 @@
 }
 
 func (c *Control) handleSubscriptionRequest(params *xapp.RMRParams) (err error) {
-	payloadSeqNum, err := c.e2ap.GetSubscriptionRequestSequenceNumber(params.Payload)
-	if err != nil {
-		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
-		return
-	}
-	xapp.Logger.Info("Subscription Request Received. RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum)
+	xapp.Logger.Info("Subscription Request Received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Src, params.Mtype, params.SubId, params.Xid, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
 
 	/* Reserve a sequence number and set it in the payload */
-	newSubId := c.registry.ReserveSequenceNumber()
+	newSubId, isIdValid := c.registry.ReserveSequenceNumber()
+	if isIdValid != true {
+		xapp.Logger.Info("Further processing of this SubscriptionRequest stopped. SubId: %v, Xid: %s",params.SubId, params.Xid)
+		return 
+	}
 
 	_, err = c.e2ap.SetSubscriptionRequestSequenceNumber(params.Payload, newSubId)
 	if err != nil {
@@ -164,39 +195,165 @@
 
 	/* Update routing manager about the new subscription*/
 	subRouteAction := SubRouteInfo{CREATE, *srcAddr, *srcPort, newSubId}
-	go c.rtmgrClient.SubscriptionRequestUpdate()
-	SubscriptionReqChan <- subRouteAction
+	xapp.Logger.Info("Starting routing manager update")
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	//time.Sleep(3 * time.Second)
 
 	// Setting new subscription ID in the RMR header
 	params.SubId = int(newSubId)
-
-	xapp.Logger.Info("Generated ID: %v. Forwarding to E2 Termination...", int(newSubId))
-	c.rmrSend(params)
+	xapp.Logger.Info("Forwarding Subscription Request to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrSend(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send request to E2T %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	} /*else {
+		c.timerMap.StartTimer(newSubId, subReqTime, c.handleSubscriptionRequestTimer)
+	}*/
 	xapp.Logger.Debug("--- Debugging transaction table = %v", c.tracker.transactionTable)
 	return
 }
 
 func (c *Control) handleSubscriptionResponse(params *xapp.RMRParams) (err error) {
+	xapp.Logger.Info("Subscription Response Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Xid, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
+
 	payloadSeqNum, err := c.e2ap.GetSubscriptionResponseSequenceNumber(params.Payload)
 	if err != nil {
 		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
 		return
 	}
-	xapp.Logger.Info("Subscription Response Received. RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum)
+
+	xapp.Logger.Info("Received payloadSeqNum: %v",payloadSeqNum)
 	if !c.registry.IsValidSequenceNumber(payloadSeqNum) {
 		err = errors.New("Unknown Subscription ID: " + strconv.Itoa(int(payloadSeqNum)) + " in Subscritpion Response. Message discarded.")
 		return
 	}
+
+//	c.timerMap.StopTimer(payloadSeqNum)
+
 	c.registry.setSubscriptionToConfirmed(payloadSeqNum)
-	xapp.Logger.Info("Subscription Response Registered. Forwarding to Requestor...")
-	transaction, err := c.tracker.completeTransaction(payloadSeqNum, CREATE)
+	var transaction Transaction
+	transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, CREATE)
+	if err != nil {
+		xapp.Logger.Error("Failed to retrive transaction record. Err: %v", err)
+		xapp.Logger.Info("Further processing of this Subscription Response stopped. SubId: %v, Xid: %s",params.SubId, params.Xid)
+		return
+	}
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Retrieved old subId...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
+
+    params.SubId = int(payloadSeqNum)
+    params.Xid = transaction.OrigParams.Xid
+	
+	xapp.Logger.Info("Forwarding Subscription Response to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	}
+
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
+	transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
 	if err != nil {
 		xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err)
 		return
 	}
-	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding to E2 Termination...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
-	params.Mbuf = transaction.OrigParams.Mbuf
-	c.rmrReplyToSender(params)
+	return
+}
+
+func (c *Control) handleSubscriptionFailure(params *xapp.RMRParams) (err error) {
+	xapp.Logger.Info("Subscription Failure Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
+
+	payloadSeqNum, err := c.e2ap.GetSubscriptionFailureSequenceNumber(params.Payload)
+	if err != nil {
+		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
+		return
+	}
+	xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum)
+
+	// should here be IsValidSequenceNumber check?
+
+//	c.timerMap.StopTimer(payloadSeqNum)
+
+	var transaction Transaction
+	transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, CREATE)
+	if  err != nil {
+		xapp.Logger.Error("Failed to retrive transaction record. Err %v", err)
+		xapp.Logger.Info("Further processing of this Subscription Failure stopped. SubId: %v, Xid: %s",params.SubId, params.Xid)
+		return
+	}
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
+
+	params.SubId = int(payloadSeqNum)
+	params.Xid = transaction.OrigParams.Xid
+
+	xapp.Logger.Info("Forwarding Subscription Failure to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	}
+
+	time.Sleep(3 * time.Second)
+
+	xapp.Logger.Info("Starting routing manager update")
+	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	xapp.Logger.Info("Deleting trancaction record")
+	if c.registry.releaseSequenceNumber(payloadSeqNum) {
+		transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
+		if err != nil {
+			xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err)
+			return
+		}
+	}
+	return
+}
+
+func (c *Control) handleSubscriptionRequestTimer(subId uint16) {
+	xapp.Logger.Info("Subscription Request timer expired. SubId: %v",subId)
+/*	
+	transaction, err := c.tracker.completeTransaction(subId, CREATE)
+	if err != nil {
+		xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err)
+		return
+	}
+	xapp.Logger.Info("SubId: %v, Xid %v, Meid: %v",subId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
+
+	var params xapp.RMRParams
+	params.Mtype = 12012 //xapp.RICMessageTypes["RIC_SUB_FAILURE"]
+	params.SubId = int(subId)
+	params.Meid = transaction.OrigParams.Meid
+	params.Xid = transaction.OrigParams.Xid
+	payload := []byte("40C9408098000003EA7E00050000010016EA6300020021EA6E00808180EA6F000400000000EA6F000400010040EA6F000400020080EA6F0004000300C0EA6F000400040100EA6F000400050140EA6F000400060180EA6F0004000701C0EA6F000400080200EA6F000400090240EA6F0004000A0280EA6F0004000B02C0EA6F0004000C0300EA6F0004000D0340EA6F0004000E0380EA6F0004000F03C0")
+	params.PayloadLen = len(payload)
+	params.Payload = payload
+
+	xapp.Logger.Info("Forwarding Subscription Failure to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(&params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	}
+*/
+/*
+	time.Sleep(3 * time.Second)
+
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(subId), transaction.XappInstanceAddress, transaction.XappPort)
+
+	xapp.Logger.Info("Starting routing manager update")
+	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	xapp.Logger.Info("Deleting trancaction record")
+	if c.registry.releaseSequenceNumber(payloadSeqNum) {
+		transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE)
+		if err != nil {
+			xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err)
+			return
+		}
+	}
+*/
 	return
 }
 
@@ -223,12 +380,16 @@
 }
 
 func (c *Control) handleSubscriptionDeleteRequest(params *xapp.RMRParams) (err error) {
+	xapp.Logger.Info("Subscription Delete Request Received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Src, params.Mtype, params.SubId, params.Xid, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
+
 	payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteRequestSequenceNumber(params.Payload)
 	if err != nil {
 		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
 		return
 	}
-	xapp.Logger.Info("Subscription Delete Request Received. RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum)
+	xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum)
 	if c.registry.IsValidSequenceNumber(payloadSeqNum) {
 		c.registry.deleteSubscription(payloadSeqNum)
 		trackErr := c.trackDeleteTransaction(params, payloadSeqNum)
@@ -237,8 +398,14 @@
 			return trackErr
 		}
 	}
-	xapp.Logger.Info("Subscription ID: %v. Forwarding to E2 Termination...", int(payloadSeqNum))
+
+	xapp.Logger.Info("Forwarding Delete Subscription Request to E2T: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
 	c.rmrSend(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send request to E2T %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	} /*else {
+		c.timerMap.StartTimer(payloadSeqNum, SubDelReqTime, c.handleSubscriptionDeleteRequestTimer)
+	}*/
 	return
 }
 
@@ -254,27 +421,146 @@
 }
 
 func (c *Control) handleSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
+	xapp.Logger.Info("Subscription Delete Response Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
+
 	payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteResponseSequenceNumber(params.Payload)
 	if err != nil {
 		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
 		return
 	}
-	var transaction, _ = c.tracker.RetriveTransaction(payloadSeqNum, DELETE)
-	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
-	go c.rtmgrClient.SubscriptionRequestUpdate()
-	SubscriptionReqChan <- subRouteAction
+	xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum)
 
-	xapp.Logger.Info("Subscription Delete Response Received. RMR SUBSCRIPTION_ID: %v | PAYLOAD SEQUENCE_NUMBER: %v", params.SubId, payloadSeqNum)
+	// should here be IsValidSequenceNumber check?
+//	c.timerMap.StopTimer(payloadSeqNum)
+	
+	var transaction Transaction
+	transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, DELETE)
+	if  err != nil {
+		xapp.Logger.Error("Failed to retrive transaction record. Err %v", err)
+		xapp.Logger.Info("Further processing of this Subscription Delete Response stopped. SubId: %v, Xid: %s",params.SubId, params.Xid)
+		return
+	}
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
+
+    params.SubId = int(payloadSeqNum)
+    params.Xid = transaction.OrigParams.Xid
+	xapp.Logger.Info("Forwarding Subscription Delete Response to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+//		return
+	}
+
+	time.Sleep(3 * time.Second)
+
+	xapp.Logger.Info("Starting routing manager update")
+	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	xapp.Logger.Info("Deleting trancaction record")
 	if c.registry.releaseSequenceNumber(payloadSeqNum) {
 		transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
 		if err != nil {
 			xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err)
 			return
 		}
-		xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding to E2 Termination...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
-		//params.Src = xAddress + ":" + strconv.Itoa(int(xPort))
-		params.Mbuf = transaction.OrigParams.Mbuf
-		c.rmrReplyToSender(params)
 	}
 	return
 }
+
+func (c *Control) handleSubscriptionDeleteFailure(params *xapp.RMRParams) (err error) {
+	xapp.Logger.Info("Subscription Delete Failure Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid)
+	xapp.Rmr.Free(params.Mbuf)
+	params.Mbuf = nil
+
+	payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteFailureSequenceNumber(params.Payload)
+	if err != nil {
+		err = errors.New("Unable to get Subscription Sequence Number from Payload due to: " + err.Error())
+		return
+	}
+	xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum)
+
+	// should here be IsValidSequenceNumber check?
+//	c.timerMap.StopTimer(payloadSeqNum)
+
+	var transaction Transaction
+	transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, DELETE)
+	if  err != nil {
+		xapp.Logger.Error("Failed to retrive transaction record. Err %v", err)
+		xapp.Logger.Info("Further processing of this Subscription Delete Failure stopped. SubId: %v, Xid: %s",params.SubId, params.Xid)
+		return
+	}
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort)
+
+    params.SubId = int(payloadSeqNum)
+    params.Xid = transaction.OrigParams.Xid
+	xapp.Logger.Info("Forwarding Subscription Delete Failure to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+//		return
+	}
+
+	time.Sleep(3 * time.Second)
+
+	xapp.Logger.Info("Starting routing manager update")
+	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	xapp.Logger.Info("Deleting trancaction record")
+	if c.registry.releaseSequenceNumber(payloadSeqNum) {
+		transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
+		if err != nil {
+			xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err)
+			return
+		}
+	}
+	return
+}
+
+func (c *Control) handleSubscriptionDeleteRequestTimer(subId uint16) {
+	xapp.Logger.Info("Subscription Delete Request timer expired. SubId: %v",subId)
+/*	
+	transaction, err := c.tracker.completeTransaction(subId, DELETE)
+	if err != nil {
+		xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err)
+		return
+	}
+	xapp.Logger.Info("SubId: %v, Xid %v, Meid: %v",subId, transaction.OrigParams.Xid, transaction.OrigParams.Meid)
+
+	var params xapp.RMRParams
+	params.Mtype = 12022 //xapp.RICMessageTypes["RIC_SUB_DEL_FAILURE"]
+	params.SubId = int(subId)
+	params.Meid = transaction.OrigParams.Meid
+	params.Xid = transaction.OrigParams.Xid
+	payload := []byte("40CA4018000003EA7E00050000010016EA6300020021EA74000200C0")
+	params.PayloadLen = len(payload)
+	params.Payload = payload
+
+	xapp.Logger.Info("Forwarding Subscription Delete Failure to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid)
+	err = c.rmrReplyToSender(&params)
+	if err != nil {
+		xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid)
+	}
+*/	
+/*
+	time.Sleep(3 * time.Second)
+	xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(subId), transaction.XappInstanceAddress, transaction.XappPort)
+
+	xapp.Logger.Info("Starting routing manager update")
+	subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum}
+	c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+
+	xapp.Logger.Info("Deleting trancaction record")
+	if c.registry.releaseSequenceNumber(payloadSeqNum) {
+		transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE)
+		if err != nil {
+			xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err)
+			return
+		}
+	}
+*/
+	return
+	}
diff --git a/pkg/control/e2ap.go b/pkg/control/e2ap.go
index 6f5edcb..f9580d9 100644
--- a/pkg/control/e2ap.go
+++ b/pkg/control/e2ap.go
@@ -117,3 +117,49 @@
 	newPayload = C.GoBytes(cptr, C.int(size))
 	return
 }
+
+/* RICsubscriptionRequestFailure */
+
+func (c *E2ap) GetSubscriptionFailureSequenceNumber(payload []byte) (subId uint16, err error) {
+	cptr := unsafe.Pointer(&payload[0])
+	cret := C.e2ap_get_ric_subscription_failure_sequence_number(cptr, C.size_t(len(payload)))
+	if cret < 0 {
+		return 0, errors.New("e2ap wrapper is unable to get Subscirption Failure Sequence Number due to wrong or invalid payload")
+	}
+	subId = uint16(cret)
+	return
+}
+
+// This function is not used currently. Can be deleted if not needed
+func (c *E2ap) SetSubscriptionFailureSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
+	cptr := unsafe.Pointer(&payload[0])
+	size := C.e2ap_set_ric_subscription_failure_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
+	if size < 0 {
+		return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Failure Sequence Number due to wrong or invalid payload")
+	}
+	newPayload = C.GoBytes(cptr, C.int(size))
+	return
+}
+
+/* RICsubscriptionDeleteFailure */
+
+func (c *E2ap) GetSubscriptionDeleteFailureSequenceNumber(payload []byte) (subId uint16, err error) {
+	cptr := unsafe.Pointer(&payload[0])
+	cret := C.e2ap_get_ric_subscription_delete_failure_sequence_number(cptr, C.size_t(len(payload)))
+	if cret < 0 {
+		return 0, errors.New("e2ap wrapper is unable to get Subscirption Delete Failure Sequence Number due to wrong or invalid payload")
+	}
+	subId = uint16(cret)
+	return
+}
+
+// This function is not used currently. Can be deleted if not needed
+func (c *E2ap) SetSubscriptionDeleteFailureSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
+	cptr := unsafe.Pointer(&payload[0])
+	size := C.e2ap_set_ric_subscription_delete_failure_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
+	if size < 0 {
+		return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Failure Sequence Number due to wrong or invalid payload")
+	}
+	newPayload = C.GoBytes(cptr, C.int(size))
+	return
+}
diff --git a/pkg/control/registry.go b/pkg/control/registry.go
index 6717612..98aa97e 100644
--- a/pkg/control/registry.go
+++ b/pkg/control/registry.go
@@ -19,7 +19,12 @@
 
 package control
 
-import "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"sync"
+)
+
+var registryMutex = &sync.Mutex{}
 
 type Registry struct {
 	register map[uint16]bool
@@ -33,16 +38,30 @@
 }
 
 // Reserves and returns the next free sequence number
-func (r *Registry) ReserveSequenceNumber() uint16 {
-	if r.IsValidSequenceNumber(r.counter) {	}
+func (r *Registry) ReserveSequenceNumber() (uint16, bool) {
+	// Check is current SequenceNumber valid
+	registryMutex.Lock()
+	defer registryMutex.Unlock()
 	sequenceNumber := r.counter
+	if _, ok := r.register[sequenceNumber]; ok {
+		xapp.Logger.Error("Invalid SeqenceNumber sequenceNumber: %v",sequenceNumber)
+		return sequenceNumber, false
+	}
 	r.register[sequenceNumber] = false
-	r.shift()
-	return sequenceNumber
+
+	// Allocate next SequenceNumber value
+	if r.counter == 65535 {
+		r.counter = 0
+	} else {
+		r.counter++
+	}
+	return sequenceNumber, true
 }
 
 // This function checks the validity of the given subscription id
 func (r *Registry) IsValidSequenceNumber(sn uint16) bool {
+	registryMutex.Lock()
+	defer registryMutex.Unlock()
 	xapp.Logger.Debug("Registry map: %v", r.register)
 	if _, ok := r.register[sn]; ok {
 		return true
@@ -52,27 +71,25 @@
 
 // This function sets the give id as confirmed in the register
 func (r *Registry) setSubscriptionToConfirmed(sn uint16) {
+	registryMutex.Lock()
+	defer registryMutex.Unlock()
 	r.register[sn] = true
 }
 
-func (r *Registry) shift() {
-	if r.counter == 65535 {
-		r.counter = 0
-	} else {
-		r.counter++
-	}
-}
-
 //This function sets the given id as unused in the register
 func (r *Registry) deleteSubscription(sn uint16) {
+	registryMutex.Lock()
+	defer registryMutex.Unlock()
 	r.register[sn] = false
 }
 
 //This function releases the given id as unused in the register
 func (r *Registry) releaseSequenceNumber(sn uint16) bool {
+	registryMutex.Lock()
+	defer registryMutex.Unlock()
 	if r.register[sn] {
 		return false
-	} else {
+		} else {
 		delete(r.register, sn)
 		return true
 	}
diff --git a/pkg/control/timers.go b/pkg/control/timers.go
new file mode 100644
index 0000000..6f64c5b
--- /dev/null
+++ b/pkg/control/timers.go
@@ -0,0 +1,108 @@
+/*
+==================================================================================
+  Copyright (c) 2019 AT&T Intellectual Property.
+  Copyright (c) 2019 Nokia
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+package control
+
+import (
+	"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+	"sync"
+	"time"
+)
+
+var timerMutex = &sync.Mutex{}
+
+type TimerInfo struct {
+	timerAddress *time.Timer	
+	timerFunctionAddress func()
+}
+
+type TimerMap struct {
+	timer map[uint16] TimerInfo
+}
+
+// This method should run as a constructor
+func (t *TimerMap) Init() {
+	t.timer = make(map[uint16] TimerInfo)
+}
+
+func (t *TimerMap) StartTimer(subId uint16, expireAfterTime time.Duration, timerFunction func(subId uint16)) bool {
+	timerMutex.Lock()
+	defer timerMutex.Unlock()
+	if (timerFunction == nil) {
+		xapp.Logger.Error("StartTimer() timerFunc == nil")
+		return false
+	}
+
+	// Stop timer if there is already timer running with the same id
+	if val, ok := t.timer[subId]; ok {
+		xapp.Logger.Error("StartTimer() old timer found")
+		if val.timerAddress != nil {
+			xapp.Logger.Error("StartTimer() deleting old timer")
+			val.timerAddress.Stop()
+		}
+		delete(t.timer, subId)
+	}
+
+	// Store timer + timer function excecutor function and the function to be excecuted when timer expires, in map
+	t.timer[subId] = TimerInfo{timerAddress: time.AfterFunc(expireAfterTime, func(){t.timerFunctionExcecutor(subId)}),
+							   timerFunctionAddress: func(){timerFunction(subId)}}
+	return true
+}
+
+func (t *TimerMap) StopTimer(subId uint16) bool {
+	timerMutex.Lock()
+	defer timerMutex.Unlock()
+	if val, ok := t.timer[subId]; ok {
+		if val.timerAddress != nil {
+			val.timerAddress.Stop()
+			delete(t.timer, subId)
+			return true
+		} else {
+			xapp.Logger.Error("StopTimer() timerAddress == nil")
+			return false
+		}
+	} else {
+		xapp.Logger.Info("StopTimer() Timer not found. May be expired or stopped already. subId: %v",subId)
+		return false
+	}
+}
+
+func (t *TimerMap) timerFunctionExcecutor(subId uint16) {
+	timerMutex.Lock()
+	if val, ok := t.timer[subId]; ok {
+		if val.timerFunctionAddress != nil {
+			// Take local copy of timer function address
+			f := val.timerFunctionAddress
+			// Delete timer instance from map
+			delete(t.timer, subId)
+			timerMutex.Unlock()
+			// Excecute the timer function
+			f()
+			return
+		} else {
+			xapp.Logger.Error("timerExcecutorFunc() timerFunctionAddress == nil")
+			timerMutex.Unlock()
+			return
+		}
+	} else {
+		xapp.Logger.Error("timerExcecutorFunc() Timer not anymore in map. subId: %v",subId)
+		timerMutex.Unlock()
+		return
+	}
+}
diff --git a/pkg/control/tracker.go b/pkg/control/tracker.go
index eddfbda..dfab96e 100644
--- a/pkg/control/tracker.go
+++ b/pkg/control/tracker.go
@@ -21,8 +21,11 @@
 
 import (
 	"fmt"
+	"sync"
 )
 
+var trackerMutex = &sync.Mutex{}
+
 /*
 Implements a record of ongoing transactions and helper functions to CRUD the records.
 */
@@ -39,6 +42,8 @@
 Returns error if there is similar transatcion ongoing.
 */
 func (t *Tracker) TrackTransaction(key TransactionKey, xact Transaction) error {
+	trackerMutex.Lock()
+	defer trackerMutex.Unlock()
 	if _, ok := t.transactionTable[key]; ok {
 		// TODO: Implement merge related check here. If the key is same but the value is different.
 		err := fmt.Errorf("transaction tracker: Similar transaction with sub id %d and type %s is ongoing", key.SubID, key.transType)
@@ -54,6 +59,8 @@
 */
 func (t *Tracker) UpdateTransaction(SubID uint16, transType Action, xact Transaction) error {
 	key := TransactionKey{SubID, transType}
+	trackerMutex.Lock()
+	defer trackerMutex.Unlock()
 	if _, ok := t.transactionTable[key]; ok {
 		// TODO: Implement merge related check here. If the key is same but the value is different.
 		err := fmt.Errorf("transaction tracker: Similar transaction with sub id %d and type %v is ongoing", key.SubID, key.transType)
@@ -69,6 +76,8 @@
 */
 func (t *Tracker) RetriveTransaction(subID uint16, act Action) (Transaction, error) {
 	key := TransactionKey{subID, act}
+	trackerMutex.Lock()
+	defer trackerMutex.Unlock()
 	var xact Transaction
 	if xact, ok := t.transactionTable[key]; ok {
 		return xact, nil
@@ -84,6 +93,8 @@
 func (t *Tracker) completeTransaction(subID uint16, act Action) (Transaction, error) {
 	key := TransactionKey{subID, act}
 	var emptyTransaction Transaction
+	trackerMutex.Lock()
+	defer trackerMutex.Unlock()
 	if xact, ok := t.transactionTable[key]; ok {
 		delete(t.transactionTable, key)
 		return xact, nil