mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Embed: (wiki syntax)

« Back to documentation index

M2MSecurity Class Reference

M2MSecurity. More...

#include <m2msecurity.h>

Inherits M2MObject.

Public Types

enum  SecurityResource
 

Enum defining all resources associated with a Security Object in the LWM2M framework.

More...
enum  SecurityModeType
 

Enum defining the type of a security attribute used by the Security Object.

More...
enum  ServerType
 

Enum defining an interface operation that can be handled by the Security Object.

More...
enum  BaseType
 

Enum to define the type of object.

More...
enum  Observation
 

Enum to define observation level.

More...
enum  Mode
 

Enum defining an operation that can be supported by a given resource.

More...
enum  Operation
 

Enum defining an operation that can be supported by a given resource.

More...

Public Member Functions

virtual ~M2MSecurity ()
 Destructor.
M2MResourcecreate_resource (SecurityResource rescource, uint32_t value)
 Creates a new resource for given resource enum.
bool delete_resource (SecurityResource rescource)
 Deletes the resource with the given resource enum.
bool set_resource_value (SecurityResource resource, const String &value)
 Sets the value of the given resource enum.
bool set_resource_value (SecurityResource resource, uint32_t value)
 Sets the value of the given resource enum.
bool set_resource_value (SecurityResource resource, const uint8_t *value, const uint16_t length)
 Sets the value of the given resource enum.
String resource_value_string (SecurityResource resource) const
 Returns the value of the given resource enum, in String.
uint32_t resource_value_buffer (SecurityResource resource, uint8_t *&data) const
 Populates the data buffer and returns the size of the buffer.
uint32_t resource_value_int (SecurityResource resource) const
 Returns the value of the given resource name, in Integer.
bool is_resource_present (SecurityResource resource) const
 Returns whether the resource instance with given resource enum exists or not.
uint16_t total_resource_count () const
 Returns the total number of resources for a security object.
ServerType server_type () const
 Returns the type of the Security Object.
M2MObjectInstancecreate_object_instance (uint16_t instance_id=0)
 Creates a new object instance for a given mbed Client Interface object.
virtual bool remove_object_instance (uint16_t instance_id=0)
 Removes the object instance resource with the given instance id.
virtual M2MObjectInstanceobject_instance (uint16_t instance_id=0) const
 Returns object instance with the the given instance id.
virtual const
M2MObjectInstanceList & 
instances () const
 Returns a list of object instances.
virtual uint16_t instance_count () const
 Returns the total number of instances with the object.
virtual M2MBase::BaseType base_type () const
 Returns object type.
virtual void add_observation_level (M2MBase::Observation observation_level)
 Adds the observation level for the object.
virtual void remove_observation_level (M2MBase::Observation observation_level)
 Removes the observation level from the object.
virtual sn_coap_hdr_shandle_get_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
 Handles GET request for the registered objects.
virtual sn_coap_hdr_shandle_put_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
 Handles PUT request for the registered objects.
virtual sn_coap_hdr_shandle_post_request (nsdl_s *nsdl, sn_coap_hdr_s *received_coap_header, M2MObservationHandler *observation_handler=NULL)
 Handles GET request for the registered objects.
virtual void set_operation (M2MBase::Operation operation)
 Sets the operation type for an object.
virtual void set_interface_description (const String &description)
 Sets the interface description of the object.
virtual void set_resource_type (const String &resource_type)
 Sets the resource type of the object.
virtual void set_coap_content_type (const uint8_t content_type)
 Sets the CoAP content type of the object.
virtual void set_observable (bool observable)
 Sets the observable mode for the object.
virtual void set_under_observation (bool observed, M2MObservationHandler *handler)
 Sets the object under observation.
virtual void set_observation_token (const uint8_t *token, const uint8_t length)
 Sets the observation token value.
virtual void set_instance_id (const uint16_t instance_id)
 Sets the instance ID of the object.
virtual void set_observation_number (const uint16_t observation_number)
 Sets the observation number of the object.
virtual M2MBase::Operation operation () const
 Returns the operation type of the object.
virtual const String & name () const
 Returns the object name.
virtual int32_t name_id () const
 Returns the object name in integer.
virtual uint16_t instance_id () const
 Returns the object's Instance ID.
virtual const String & interface_description () const
 Returns the interface description of the object.
virtual const String & resource_type () const
 Returns the resource type of the object.
virtual uint8_t coap_content_type () const
 Returns the CoAP content type of the object.
virtual bool is_observable () const
 Returns the observation status of the object.
virtual M2MBase::Observation observation_level () const
 Returns the observation level of the object.
virtual void get_observation_token (uint8_t *&token, uint32_t &token_length)
 Provides the observation token of the object.
virtual Mode mode () const
 Returns the mode of the resource.
virtual uint16_t observation_number () const
 Returns the observation number.
virtual bool handle_observation_attribute (char *&query)
 Parses the received query for the notification attribute.

Protected Member Functions

virtual void observation_to_be_sent ()
 Observation callback to be sent to the server due to a change in the observed parameter.
virtual void set_base_type (M2MBase::BaseType type)
 Sets the Base type for object.
virtual void remove_resource_from_coap (const String &resource_name)
 Removes resource from the CoAP structure.
virtual void remove_object_from_coap ()
 Removes object from NSDL list.
virtual void * memory_alloc (uint16_t size)
 Memory Allocation required for libCoap.
virtual void memory_free (void *ptr)
 Memory free functions required for libCoap.
M2MReportHandlerreport_handler ()
 Returns Report Handler object.
M2MObservationHandlerobservation_handler ()
 Returns Observation Handler object.

Friends

class M2MInterfaceFactory
class M2MNsdlInterface

Detailed Description

M2MSecurity.

This class represents an interface for the Security Object model of the LWM2M framework. It handles the security object instances and all corresponding resources.

Definition at line 31 of file m2msecurity.h.


Member Enumeration Documentation

enum BaseType [inherited]

Enum to define the type of object.

Definition at line 45 of file m2mbase.h.

enum Mode [inherited]

Enum defining an operation that can be supported by a given resource.

Definition at line 71 of file m2mbase.h.

enum Observation [inherited]

Enum to define observation level.

Definition at line 55 of file m2mbase.h.

enum Operation [inherited]

Enum defining an operation that can be supported by a given resource.

Definition at line 81 of file m2mbase.h.

Enum defining the type of a security attribute used by the Security Object.

Definition at line 61 of file m2msecurity.h.

Enum defining all resources associated with a Security Object in the LWM2M framework.

Definition at line 42 of file m2msecurity.h.

enum ServerType

Enum defining an interface operation that can be handled by the Security Object.

Definition at line 72 of file m2msecurity.h.


Constructor & Destructor Documentation

~M2MSecurity (  ) [virtual]

Destructor.

Definition at line 87 of file m2msecurity.cpp.


Member Function Documentation

void add_observation_level ( M2MBase::Observation  observation_level ) [virtual, inherited]

Adds the observation level for the object.

Parameters:
observation_level,Levelof observation.

Reimplemented from M2MBase.

Definition at line 177 of file m2mobject.cpp.

M2MBase::BaseType base_type (  ) const [virtual, inherited]

Returns object type.

Returns:
BaseType.

Reimplemented from M2MBase.

Definition at line 172 of file m2mobject.cpp.

uint8_t coap_content_type (  ) const [virtual, inherited]

Returns the CoAP content type of the object.

Returns:
Content type of the object.

Definition at line 261 of file m2mbase.cpp.

M2MObjectInstance * create_object_instance ( uint16_t  instance_id = 0 ) [inherited]

Creates a new object instance for a given mbed Client Interface object.

With this, the client can respond to server's GET methods with the provided value.

Returns:
M2MObjectInstance, Object instance for managing other client operations.

Definition at line 89 of file m2mobject.cpp.

M2MResource * create_resource ( SecurityResource  rescource,
uint32_t  value 
)

Creates a new resource for given resource enum.

Parameters:
rescource,Withthis function, the following resources can be created: ' BootstrapServer', 'SecurityMode', 'SMSSecurityMode', 'M2MServerSMSNumber', 'ShortServerID', 'ClientHoldOffTime'.
value,Valueto be set on the resource, in Integer format.
Returns:
M2MResource if created successfully, else NULL.

Definition at line 92 of file m2msecurity.cpp.

bool delete_resource ( SecurityResource  rescource )

Deletes the resource with the given resource enum.

Mandatory resources cannot be deleted.

Parameters:
resource,Resourceto be deleted.
Returns:
True if deleted, else false.

Definition at line 136 of file m2msecurity.cpp.

void get_observation_token ( uint8_t *&  token,
uint32_t &  token_length 
) [virtual, inherited]

Provides the observation token of the object.

Parameters:
value[OUT],pointerto the value of the token.
value_length[OUT],lengthof the token pointer.

Definition at line 276 of file m2mbase.cpp.

sn_coap_hdr_s * handle_get_request ( nsdl_s *  nsdl,
sn_coap_hdr_s received_coap_header,
M2MObservationHandler observation_handler = NULL 
) [virtual, inherited]

Handles GET request for the registered objects.

Parameters:
nsdl,NSDLhandler for the CoAP library.
received_coap_header,CoAPmessage received from the server.
observation_handler,Handlerobject for sending observation callbacks.
Returns:
sn_coap_hdr_s, Message that needs to be sent to server.

Reimplemented from M2MBase.

Definition at line 201 of file m2mobject.cpp.

bool handle_observation_attribute ( char *&  query ) [virtual, inherited]

Parses the received query for the notification attribute.

Parameters:
query,Querythat needs to be parsed.
Returns:
True if required attributes are present, else false.

Reimplemented in M2MResource.

Definition at line 301 of file m2mbase.cpp.

sn_coap_hdr_s * handle_post_request ( nsdl_s *  nsdl,
sn_coap_hdr_s received_coap_header,
M2MObservationHandler observation_handler = NULL 
) [virtual, inherited]

Handles GET request for the registered objects.

Parameters:
nsdl,NSDLhandler for the CoAP library.
received_coap_header,CoAPmessage received from the server.
observation_handler,Handlerobject for sending observation callbacks.
Returns:
sn_coap_hdr_s, Message that needs to be sent to server.

Reimplemented from M2MBase.

Definition at line 390 of file m2mobject.cpp.

sn_coap_hdr_s * handle_put_request ( nsdl_s *  nsdl,
sn_coap_hdr_s received_coap_header,
M2MObservationHandler observation_handler = NULL 
) [virtual, inherited]

Handles PUT request for the registered objects.

Parameters:
nsdl,NSDLhandler for the CoAP library.
received_coap_header,CoAPmessage received from the server.
observation_handler,Handlerobject for sending observation callbacks.
Returns:
sn_coap_hdr_s, Message that needs to be sent to server.

Reimplemented from M2MBase.

Definition at line 338 of file m2mobject.cpp.

uint16_t instance_count (  ) const [virtual, inherited]

Returns the total number of instances with the object.

Returns:
Total number of the object instances.

Definition at line 167 of file m2mobject.cpp.

uint16_t instance_id (  ) const [virtual, inherited]

Returns the object's Instance ID.

Returns:
Instance ID of the object.

Definition at line 246 of file m2mbase.cpp.

const M2MObjectInstanceList & instances (  ) const [virtual, inherited]

Returns a list of object instances.

Returns:
List of instances with the object.

Definition at line 162 of file m2mobject.cpp.

const String & interface_description (  ) const [virtual, inherited]

Returns the interface description of the object.

Returns:
Description of the object.

Definition at line 251 of file m2mbase.cpp.

bool is_observable (  ) const [virtual, inherited]

Returns the observation status of the object.

Returns:
True if observable, else false.

Definition at line 266 of file m2mbase.cpp.

bool is_resource_present ( SecurityResource  resource ) const

Returns whether the resource instance with given resource enum exists or not.

Parameters:
resource,Resourceenum.
Returns:
True if at least one instance exists, else false.

Definition at line 288 of file m2msecurity.cpp.

void * memory_alloc ( uint16_t  size ) [protected, virtual, inherited]

Memory Allocation required for libCoap.

Parameters:
size,Sizeof memory to be reserved.

Definition at line 369 of file m2mbase.cpp.

void memory_free ( void *  ptr ) [protected, virtual, inherited]

Memory free functions required for libCoap.

Parameters:
ptr,Objectwhose memory needs to be freed.

Definition at line 377 of file m2mbase.cpp.

M2MBase::Mode mode (  ) const [virtual, inherited]

Returns the mode of the resource.

Returns:
Mode of the resource.

Definition at line 291 of file m2mbase.cpp.

const String & name (  ) const [virtual, inherited]

Returns the object name.

Returns:
Name for the object.

Definition at line 236 of file m2mbase.cpp.

int32_t name_id (  ) const [virtual, inherited]

Returns the object name in integer.

Returns:
Name for the object in integer.

Definition at line 241 of file m2mbase.cpp.

M2MObjectInstance * object_instance ( uint16_t  instance_id = 0 ) const [virtual, inherited]

Returns object instance with the the given instance id.

Parameters:
instance_id,InstanceID of the requested object instance id, default is 0.
Returns:
Object instance reference if found, else NULL.

Definition at line 144 of file m2mobject.cpp.

M2MObservationHandler * observation_handler (  ) [protected, inherited]

Returns Observation Handler object.

Returns:
M2MObservationHandler object.

Definition at line 388 of file m2mbase.cpp.

M2MBase::Observation observation_level (  ) const [virtual, inherited]

Returns the observation level of the object.

Returns:
Observation level of the object.

Definition at line 271 of file m2mbase.cpp.

uint16_t observation_number (  ) const [virtual, inherited]

Returns the observation number.

Returns:
Observation number for the object.

Definition at line 296 of file m2mbase.cpp.

void observation_to_be_sent (  ) [protected, virtual, inherited]

Observation callback to be sent to the server due to a change in the observed parameter.

Implements M2MReportObserver.

Definition at line 318 of file m2mbase.cpp.

M2MBase::Operation operation (  ) const [virtual, inherited]

Returns the operation type of the object.

Returns:
Operation, Supported operation on the object.

Definition at line 231 of file m2mbase.cpp.

void remove_object_from_coap (  ) [protected, virtual, inherited]

Removes object from NSDL list.

Definition at line 338 of file m2mbase.cpp.

bool remove_object_instance ( uint16_t  instance_id = 0 ) [virtual, inherited]

Removes the object instance resource with the given instance id.

Parameters:
instance_id,InstanceID of the object instance to be removed, default is 0.
Returns:
True if removed, else false.

Definition at line 106 of file m2mobject.cpp.

void remove_observation_level ( M2MBase::Observation  observation_level ) [virtual, inherited]

Removes the observation level from the object.

Parameters:
observation_level,Levelof observation.

Reimplemented from M2MBase.

Definition at line 189 of file m2mobject.cpp.

void remove_resource_from_coap ( const String &  resource_name ) [protected, virtual, inherited]

Removes resource from the CoAP structure.

Parameters:
resource_name,Nameof the resource.

Definition at line 331 of file m2mbase.cpp.

M2MReportHandler * report_handler (  ) [protected, inherited]

Returns Report Handler object.

Returns:
M2MReportHandler object.

Definition at line 383 of file m2mbase.cpp.

const String & resource_type (  ) const [virtual, inherited]

Returns the resource type of the object.

Returns:
Resource type of the object.

Definition at line 256 of file m2mbase.cpp.

uint32_t resource_value_buffer ( SecurityResource  resource,
uint8_t *&  data 
) const

Populates the data buffer and returns the size of the buffer.

Parameters:
resource,Withthis fucntion, the following resources can return a value: 'PublicKey', 'ServerPublicKey', 'Secretkey'.
[OUT]data, Data buffer that contains the value.
Returns:
Size of the populated buffer.

Definition at line 249 of file m2msecurity.cpp.

uint32_t resource_value_int ( SecurityResource  resource ) const

Returns the value of the given resource name, in Integer.

Parameters:
resource,Withthis function, the following resources can return a value: 'BootstrapServer', 'SecurityMode', 'SMSSecurityMode', 'M2MServerSMSNumber', 'ShortServerID', 'ClientHoldOffTime'.
Returns:
Value associated with the resource. If the resource is not valid 0 is returned.

Definition at line 265 of file m2msecurity.cpp.

String resource_value_string ( SecurityResource  resource ) const

Returns the value of the given resource enum, in String.

Parameters:
resource,Withthis function, the following resources can return a value: 'M2MServerUri','SMSBindingKey', 'SMSBindingSecretKey'.
Returns:
Value associated with that resource. If the resource is not valid an empty string is returned.

Definition at line 221 of file m2msecurity.cpp.

M2MSecurity::ServerType server_type (  ) const

Returns the type of the Security Object.

It can be either Bootstrap or M2MServer.

Returns:
ServerType, Type of the Security Object.

Definition at line 307 of file m2msecurity.cpp.

void set_base_type ( M2MBase::BaseType  type ) [protected, virtual, inherited]

Sets the Base type for object.

Parameters:
type,Typeof the base object.

Definition at line 326 of file m2mbase.cpp.

void set_coap_content_type ( const uint8_t  content_type ) [virtual, inherited]

Sets the CoAP content type of the object.

Parameters:
content_type,ContentType to be set based on CoAP specifications.

Definition at line 156 of file m2mbase.cpp.

void set_instance_id ( const uint16_t  instance_id ) [virtual, inherited]

Sets the instance ID of the object.

Parameters:
instance_id,InstanceID of the object.

Definition at line 216 of file m2mbase.cpp.

void set_interface_description ( const String &  description ) [virtual, inherited]

Sets the interface description of the object.

Parameters:
description,Descriptionto be set.

Definition at line 146 of file m2mbase.cpp.

void set_observable ( bool  observable ) [virtual, inherited]

Sets the observable mode for the object.

Parameters:
observable,Valuefor the observation.

Definition at line 161 of file m2mbase.cpp.

void set_observation_number ( const uint16_t  observation_number ) [virtual, inherited]

Sets the observation number of the object.

Parameters:
observation_number,Observationnumber of the object.

Definition at line 221 of file m2mbase.cpp.

void set_observation_token ( const uint8_t *  token,
const uint8_t  length 
) [virtual, inherited]

Sets the observation token value.

Parameters:
token,Pointerto the token of the resource.
length,Lengthof the token pointer.

Definition at line 198 of file m2mbase.cpp.

void set_operation ( M2MBase::Operation  operation ) [virtual, inherited]

Sets the operation type for an object.

Parameters:
operation,Operationto be set.

Definition at line 135 of file m2mbase.cpp.

void set_resource_type ( const String &  resource_type ) [virtual, inherited]

Sets the resource type of the object.

Parameters:
resource_type,Resourcetype to be set.

Definition at line 151 of file m2mbase.cpp.

bool set_resource_value ( SecurityResource  resource,
const uint8_t *  value,
const uint16_t  length 
)

Sets the value of the given resource enum.

Parameters:
resource,Withthis function, a value can be set for the follwing resources: 'PublicKey', 'ServerPublicKey', 'Secretkey'.
value,Valueto be set on the resource, in uint8_t format.
size,Sizeof the buffer value to be set on the resource.
Returns:
True if successfully set, else false.

Definition at line 205 of file m2msecurity.cpp.

bool set_resource_value ( SecurityResource  resource,
const String &  value 
)

Sets the value of the given resource enum.

Parameters:
resource,Withthis function, a value can be set for the following resources: 'M2MServerUri', 'SMSBindingKey', 'SMSBindingSecretKey'.
value,Valueto be set on the resource, in String format.
Returns:
True if successfully set, else false.

Definition at line 167 of file m2msecurity.cpp.

bool set_resource_value ( SecurityResource  resource,
uint32_t  value 
)

Sets the value of the given resource enum.

Parameters:
resource,Withthis function, a value can be set for the following resourecs: 'BootstrapServer', 'SecurityMode', 'SMSSecurityMode', 'M2MServerSMSNumber', 'ShortServerID', 'ClientHoldOffTime'.
value,Valueto be set on the resource, in Integer format.
Returns:
True if successfully set, else false.

Definition at line 180 of file m2msecurity.cpp.

void set_under_observation ( bool  observed,
M2MObservationHandler handler 
) [virtual, inherited]

Sets the object under observation.

Parameters:
observed,Valuefor the observation. When true, starts observing. When false, ongoing observation is cancelled.
handler,Handlerobject for sending observation callbacks.

Definition at line 176 of file m2mbase.cpp.

uint16_t total_resource_count (  ) const

Returns the total number of resources for a security object.

Returns:
Total number of resources.

Definition at line 298 of file m2msecurity.cpp.