anjay
Loading...
Searching...
No Matches
server.h File Reference
#include <anjay/anjay_config.h>
#include <anjay/dm.h>
#include <avsystem/commons/avs_stream.h>

Go to the source code of this file.

Data Structures

struct  anjay_server_instance_t
 

Functions

int anjay_server_object_add_instance (anjay_t *anjay, const anjay_server_instance_t *instance, anjay_iid_t *inout_iid)
 
void anjay_server_object_purge (anjay_t *anjay)
 
AVS_LIST[const anjay_ssid_tanjay_server_get_ssids (anjay_t *anjay)
 
avs_error_t anjay_server_object_persist (anjay_t *anjay, avs_stream_t *out_stream)
 
avs_error_t anjay_server_object_restore (anjay_t *anjay, avs_stream_t *in_stream)
 
bool anjay_server_object_is_modified (anjay_t *anjay)
 
int anjay_server_object_install (anjay_t *anjay)
 
int anjay_server_object_set_lifetime (anjay_t *anjay, anjay_iid_t iid, int32_t lifetime)
 

Function Documentation

◆ anjay_server_get_ssids()

AVS_LIST[ const anjay_ssid_t] anjay_server_get_ssids ( anjay_t anjay)

Retrieves a list of SSIDs currently present in the Server object. The SSIDs are NOT guaranteed to be returned in any particular order. Returned list may not be freed nor modified.

Attempting to call this function if anjay_server_object_install has not been previously successfully called on the same Anjay instance yields undefined behavior.

The returned list pointer shall be considered invalidated by any call to anjay_sched_run, anjay_serve, anjay_server_object_add_instance, anjay_server_object_purge, anjay_server_object_restore, or, if called from within some callback handler, on return from that handler.

If a transaction on the Server object is currently ongoing (e.g., during Bootstrap), last known state from before the transaction will be returned.

NOTE: If Anjay is compiled with thread safety enabled, the list that is returned is normally accessed with the Anjay mutex locked. You will need to ensure thread safety yourself if using this function. It is recommended to only call it from callback functions called from within Anjay, or in scheduler jobs.

Parameters
anjayAnjay instance with Server Object installed.
Returns
A list of known SSIDs on success, NULL when the object is empty.

◆ anjay_server_object_add_instance()

int anjay_server_object_add_instance ( anjay_t anjay,
const anjay_server_instance_t instance,
anjay_iid_t inout_iid 
)

Adds new Instance of Server Object and returns newly created Instance id via inout_iid .

Note: if *inout_iid is set to ANJAY_ID_INVALID then the Instance id is generated automatically, otherwise value of *inout_iid is used as a new Server Instance Id.

Note: instance may be safely freed by the user code after this function finishes (internally a deep copy of anjay_server_instance_t is performed).

Parameters
anjayAnjay instance with Server Object installed to operate on.
instanceServer Instance to insert.
inout_iidServer Instance id to use or ANJAY_ID_INVALID .
Returns
0 on success, negative value in case of an error or if the instance of specified id already exists.

◆ anjay_server_object_install()

int anjay_server_object_install ( anjay_t anjay)

Installs the Server Object in an Anjay instance.

The Server module does not require explicit cleanup; all resources will be automatically freed up during the call to anjay_delete.

Parameters
anjayAnjay instance for which the Server Object is installed.
Returns
0 on success, or a negative value in case of error.

◆ anjay_server_object_is_modified()

bool anjay_server_object_is_modified ( anjay_t anjay)

Checks whether the Server Object from Anjay instance has been modified since last successful call to anjay_server_object_persist or anjay_server_object_restore.

◆ anjay_server_object_persist()

avs_error_t anjay_server_object_persist ( anjay_t anjay,
avs_stream_t *  out_stream 
)

Dumps Server Object Instances into the out_stream .

Parameters
anjayAnjay instance with Server Object installed.
out_streamStream to write to.
Returns
AVS_OK in case of success, or an error code.

◆ anjay_server_object_purge()

void anjay_server_object_purge ( anjay_t anjay)

Removes all instances of Server Object leaving it in an empty state.

Parameters
anjayAnjay instance with Server Object installed to purge.

◆ anjay_server_object_restore()

avs_error_t anjay_server_object_restore ( anjay_t anjay,
avs_stream_t *  in_stream 
)

Attempts to restore Server Object Instances from specified in_stream .

Note: if restore fails, then Server Object will be left untouched, on success though all Instances stored within the Object will be purged.

Parameters
anjayAnjay instance with Server Object installed.
in_streamStream to read from.
Returns
AVS_OK in case of success, or an error code.

◆ anjay_server_object_set_lifetime()

int anjay_server_object_set_lifetime ( anjay_t anjay,
anjay_iid_t  iid,
int32_t  lifetime 
)

Sets the Lifetime value for the specified Server Instance ID.

NOTE: Calling this function MAY trigger sending LwM2M Update message to an associated LwM2M Server.

Parameters
anjayAnjay instance for which the Server Object is installed.
iidServer Object Instance for which the Lifetime shall be altered.
lifetimeNew value of the Lifetime Resource. MUST BE strictly positive.
Returns
0 on success, negative value in case of an error. If an error is returned, the Lifetime value remains unchanged.