16 #define AC_OBJ_ID_MIN 0
17 #define AC_OBJ_ID_MAX (ID_T_MAX_VAL-1)
18 #define AC_OBJ_INST_ID_MIN 0
19 #define AC_OBJ_INST_ID_MAX ID_T_MAX_VAL
24 #define AC_OWNER_MIN 0
25 #define AC_OWNER_MAX ID_T_MAX_VAL
28 #define TAG "Lwm2mAccessControl"
35 lwm2m_ac_request_update_policy(&context,
false);
47 lwm2m_ac_request_update_policy(&
getContext(),
false);
57 if (!inst)
return NULL;
63 if (!inst)
return NULL;
73 lwm2m_ac_request_update_policy(&
getContext(),
false);
86 lwm2m_ac_request_update_policy(&
getContext(),
false);
90 void Lwm2mAccessControl::resourcesCreate() {
102 void Lwm2mAccessControl::resourcesInit() {
122 Lwm2mAccessControl * Lwm2mAccessControl::getAcInstForTarget(Object &acObj,
ID_T objId,
ID_T objInstId) {
124 for (
auto &inst : acObj.instances()) {
127 if (tmpObjId == objId && tmpObjInstId == objInstId)
return static_cast<Lwm2mAccessControl*
>(inst);
164 if (!acInst)
return false;
172 WppRegistry ®istry = targetObj.getRegistry();
176 if (!acInst || !acInst->isExist(
ACL_2, serverShortId))
return;
177 acInst->removeRes(
ACL_2, serverShortId);
213 if (!acInst)
return false;
220 WppRegistry ®istry = targetInst.getRegistry();
222 Lwm2mAccessControl *acInst = getAcInstForTarget(acObj, targetInst.getObjectID(), targetInst.getInstanceID());
224 if (!acInst || !acInst->isExist(
ACL_2, serverShortId))
return;
225 acInst->removeRes(
ACL_2, serverShortId);
#define AC_OBJ_INST_ID_MAX
#define AC_OBJ_INST_ID_MIN
#define AC_ACL_DEFAULT_ID
#define AC_OBJ_INST_NOT_SET
void operationNotify(Instance &inst, const ResLink &resLink, ItemOp::TYPE type)
Notifies the observers about an operation on an instance resource.
Instance is interface class that implements manipulation with derived class resources....
OBJ_ID getObjectID() const
WppRegistry & getRegistry()
Helpfull methods to get registry instances.
lwm2m_context_t & getContext()
Return context that can be used by derived class.
void notifyResChanged(ID_T resId, ID_T resInstId=ID_T_MAX_VAL)
Notify server about resource value change.
ID_T getInstanceID() const
Lwm2mAccessControl(lwm2m_context_t &context, const OBJ_LINK_T &id)
static bool removeInst(WppClient &ctx, ID_T instId)
Removes an instance of the object.
static Lwm2mAccessControl * createInst(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Creates an instance of the object.
void serverOperationNotifier(Instance *securityInst, ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
static Object & object(WppClient &ctx)
Gets the Object reference.
void userOperationNotifier(ItemOp::TYPE type, const ResLink &resLink) override
This method must be implemented by the derived class, and handle information about resource operation...
static void remove(Object &targetObj)
Delete Lwm2mAccessControl object instance for target object.
static Lwm2mAccessControl * create(Object &targetObj, uint8_t defaultAcl=NO_ACCESS)
Create Lwm2mAccessControl object instance for target object.
static Lwm2mAccessControl * instance(WppClient &ctx, ID_T instId=ID_T_MAX_VAL)
Gets an instance of the object.
static void removeAcl(Object &targetObj, ID_T serverShortId)
Remove ACL for target object.
static bool addAcl(Object &targetObj, ID_T serverShortId, uint8_t acl=ALL_OBJ_RIGHTS)
Add ACL for target object.
The Object class implements manipulation with Instance interface class and its inheritors.
Instance * instance(ID_T instanceID=ID_T_MAX_VAL)
Gets an instance of the object.
virtual Instance * createInstance(ID_T instanceID=ID_T_MAX_VAL)=0
Creates an instance of the object.
WppRegistry & getRegistry()
Helpfull methods to get registry instances.
bool remove(ID_T instanceID)
Removes an instance of the object.
OBJ_ID getObjectID() const
Gets the object ID.
void setupResources(const std::vector< Resource > &resources)
This methods setup resources list.
Resource * resource(ID_T resId)
This method return resource ptr if it exists. If resources does not exist then return NULL.
std::vector< Resource > & resources()
This method return list with all resources that has been defined.
bool set(ID_T resId, const T &value)
Set data value by copy for the resource.
bool set(const T &value, ID_T resInstId=SINGLE_INSTANCE_ID)
Set data value by copy for the resource (instance)
bool setDataVerifier(const DATA_VERIFIER_T &verifier)
Set data verifier for the resource.
Represents a client interface for Wpp library.
WppRegistry & registry()
Gets the WppRegistry associated with the WppClient.
The WppRegistry class represents a registry for managing LWM2M objects.
Object & lwm2mAccessControl()
The WppConnection class represents a connection interface for the Wpp library.
std::function< bool(const INT_T &)> VERIFY_INT_T
Data validation function types.
The ItemOp struct represents the operations that can be performed on a instance/resource.
TYPE
Enum representing the different types of operations.
ObjLink - (object ID):(instance ID), example: 1:3. Represent as two integers in lwm2m_data_t....