Hi,
If you are not busy, please check if you can review it.
Thanks
-Nagu
> -----Original Message-----
> From: Nagendra Kumar
> Sent: 14 April 2017 18:52
> To: [email protected]; Praveen Malviya;
> [email protected]; [email protected]
> Cc: [email protected]
> Subject: [devel] [PATCH 1 of 1] amfd: disallow delete of CtCs object if Ct
> maps to comp [#2428]
>
> osaf/services/saf/amf/amfd/ctcstype.cc | 60
> ++++++++++++++++++++++++++++++++-
> 1 files changed, 58 insertions(+), 2 deletions(-)
>
>
> diff --git a/osaf/services/saf/amf/amfd/ctcstype.cc
> b/osaf/services/saf/amf/amfd/ctcstype.cc
> --- a/osaf/services/saf/amf/amfd/ctcstype.cc
> +++ b/osaf/services/saf/amf/amfd/ctcstype.cc
> @@ -26,7 +26,7 @@
> #include <include/csi.h>
>
> AmfDb<std::string, AVD_CTCS_TYPE> *ctcstype_db = nullptr;
> -
> +static void find_ct_name_from_association(const SaNameT *haystack,
> +SaNameT *dn, const char *needle);
> static void ctcstype_db_add(AVD_CTCS_TYPE *ctcstype) {
> unsigned int rc = ctcstype_db->insert(ctcstype->name,ctcstype);
> @@ -185,17 +185,73 @@ static SaAisErrorT ctcstype_ccb_complete
> report_ccb_validation_error(opdata, "Modification of
> SaAmfCtCsType not supported");
> break;
> case CCBUTIL_DELETE:
> + AVD_CTCS_TYPE *ctcstype;
> + SaNameT ct_name;
> + AVD_COMP_TYPE *comp_type;
> + AVD_COMP *comp;
> + CcbUtilOperationData_t *t_opData;
> +
> + ctcstype = ctcstype_db->find(Amf::to_string(&opdata-
> >objectName));
> + if (ctcstype != nullptr) {
> + find_ct_name_from_association(&opdata-
> >objectName, &ct_name, ",safVersion");
> + TRACE("'%s'", ct_name.value);
> + comp_type = comptype_db-
> >find(Amf::to_string(&ct_name));
> + if ((comp_type) && (nullptr != comp_type-
> >list_of_comp)) {
> + /* check whether there exists a delete
> operation for
> + * each of the Comp in the comp_type list in
> the current CCB
> + */
> + bool comp_exist = false;
> + TRACE("SaAmfCompType '%s' has
> components", comp_type->name.value);
> + comp = comp_type->list_of_comp;
> + while (comp != nullptr) {
> + TRACE("%s", comp-
> >comp_info.name.value);
> + t_opData =
> ccbutil_getCcbOpDataByDN(opdata->ccbId, &comp->comp_info.name);
> + TRACE("%p", t_opData);
> + if ((t_opData == nullptr) ||
> (t_opData->operationType != CCBUTIL_DELETE)) {
> + TRACE("Here %p",
> t_opData);
> + comp_exist = true;
> + break;
> + }
> + comp = comp-
> >comp_type_list_comp_next;
> + }
> + if (comp_exist == true) {
> + rc = SA_AIS_ERR_BAD_OPERATION;
> + report_ccb_validation_error(opdata,
> "SaAmfCompType '%s' is in use", comp_type->name.value);
> + goto done;
> + }
> + } else
> + TRACE("SaAmfCompType '%p'.
> SaAmfCompType '%s' has no components", comp_type, ct_name.value);
> + }
> rc = SA_AIS_OK;
> break;
> default:
> osafassert(0);
> break;
> }
> -
> +done:
> TRACE_LEAVE2("%u", rc);
> return rc;
> }
>
> +/**
> + * Initialize a DN by searching for needle in haystack where two times
> safVersion comes.
> + * @param haystack
> + * @param dn
> + * @param needle
> + * @note:
> "safSupportedCsType=safVersion=1\,safCSType=AmfDemo1,safVersion=1,sa
> fCompType=AmfDemo1"
> + */
> +static void find_ct_name_from_association(const SaNameT *haystack,
> +SaNameT *dn, const char *needle) {
> + char *p;
> +
> + memset(dn, 0, sizeof(SaNameT));
> + p = strstr((char*)haystack->value, needle);
> + osafassert(p);
> + p++; /* Increament after comma (,) */
> + dn->length = strlen(p);
> + memcpy(dn->value, p, dn->length); }
> +
> static void ctcstype_ccb_apply_cb(CcbUtilOperationData_t *opdata) {
> AVD_CTCS_TYPE *ctcstype;
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most engaging
> tech sites, Slashdot.org! https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__sdm.link_slashdot&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5
> YTpkKY057SbK10&r=Msq2CEtg63eU7sEKWk3a28RY1AX1Y11SftpoiJrP_ek&m
> =M3Ag1M0fFQVzdtCcU2Qc5VLvDlJmhCSJtKV8tw1yWpo&s=cNxpPHnUTchxh
> MKKWZY19fO0DZ62QViysjKT_0iecoQ&e=
> _______________________________________________
> Opensaf-devel mailing list
> [email protected]
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__lists.sourceforge.net_lists_listinfo_opensaf-
> 2Ddevel&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PQcxBKCX5YTpkKY057SbK
> 10&r=Msq2CEtg63eU7sEKWk3a28RY1AX1Y11SftpoiJrP_ek&m=M3Ag1M0fFQ
> VzdtCcU2Qc5VLvDlJmhCSJtKV8tw1yWpo&s=M4Y5zQciWbdMyye3-
> JUPqT73k1HdPmu-j6S-6Vmfts8&e=
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel