![]() |
HAN-FUN API
1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
|
This module contains the classes that implement the Session Management functionality. More...
Data Structures | |
struct | HF::Core::SessionManagement::StartResponse |
Start Read Session Command Message. More... | |
struct | HF::Core::SessionManagement::GetEntriesMessage |
Get Entries Command Message. More... | |
struct | HF::Core::SessionManagement::IServer |
Session Management API : Server side. More... | |
struct | HF::Core::SessionManagement::AbstractServer::Session |
Session database entry. More... | |
class | HF::Core::SessionManagement::AbstractServer |
Parent class for session management functionality - Server side. More... | |
class | HF::Core::SessionManagement::EntriesWrapper< Parent > |
Wrapper over persistent storage APIs to invalidate sessions on save and destroy. More... | |
struct | HF::Core::SessionManagement::Server< _Entries > |
Helper template to inject session management functionality into services requiring it - Server side. More... | |
class | HF::Core::SessionManagement::AbstractClient |
Parent class for session management functionality - Client side. More... | |
struct | HF::Core::SessionManagement::Client< _Entry > |
Helper template to inject session management functionality into services requiring it - Client side. More... | |
Enumerations | |
enum | HF::Core::SessionManagement::CMD { HF::Core::SessionManagement::START, HF::Core::SessionManagement::GET, HF::Core::SessionManagement::END } |
Available commands for session management. More... | |
Functions | |
HF::Core::SessionManagement::StartResponse::StartResponse (uint16_t count=0) | |
Constructor. More... | |
uint16_t | HF::Core::SessionManagement::GetEntriesMessage::size () const |
Number bytes needed to serialize the message. More... | |
uint16_t | HF::Core::SessionManagement::GetEntriesMessage::pack (Common::ByteArray &array, uint16_t offset=0) const |
Write the object on to a ByteArray so it can be sent over the network. More... | |
uint16_t | HF::Core::SessionManagement::GetEntriesMessage::unpack (const Common::ByteArray &array, uint16_t offset=0) |
Read a message from a ByteArray. More... | |
virtual void | HF::Core::SessionManagement::IServer::start_session (uint16_t address)=0 |
Start a session for the device with the given address . More... | |
virtual void | HF::Core::SessionManagement::IServer::end_session (uint16_t address)=0 |
Terminate the session associated with the device with the given address . More... | |
virtual bool | HF::Core::SessionManagement::IServer::exists (uint16_t address) const =0 |
Check if a session for the device with the given address exists. More... | |
virtual bool | HF::Core::SessionManagement::IServer::is_valid (uint16_t address) const =0 |
Check if the session for the device with the given address is valid, i.e., the underling entries have not been modified since the start of the session. More... | |
HF::Core::SessionManagement::AbstractServer::Session::Session (uint16_t _address=HF::Protocol::BROADCAST_ADDR, bool _valid=false) | |
Constructor. More... | |
HF::Core::SessionManagement::AbstractServer::AbstractServer () | |
Constructor. | |
void | HF::Core::SessionManagement::AbstractServer::start_session (uint16_t address) |
Start a session for the device with the given address . More... | |
void | HF::Core::SessionManagement::AbstractServer::end_session (uint16_t address) |
Terminate the session associated with the device with the given address . More... | |
bool | HF::Core::SessionManagement::AbstractServer::exists (uint16_t address) const |
Check if a session for the device with the given address exists. More... | |
bool | HF::Core::SessionManagement::AbstractServer::is_valid (uint16_t address) const |
Check if the session for the device with the given address is valid, i.e., the underling entries have not been modified since the start of the session. More... | |
void | HF::Core::SessionManagement::AbstractServer::invalidate () |
Invalidate all sessions. | |
Common::Result | HF::Core::SessionManagement::AbstractServer::handle_command (CMD cmd, Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset=0) |
Handle command request/response messages. More... | |
iterator | HF::Core::SessionManagement::AbstractServer::find (uint16_t address) |
Find the session associated with the given device address . More... | |
const_iterator | HF::Core::SessionManagement::AbstractServer::find (uint16_t address) const |
Find the session associated with the given device address . More... | |
uint16_t | HF::Core::SessionManagement::AbstractServer::payload_size (CMD cmd) const |
Get the minimum number of bytes necessary to pack/unpack a message of the given command. More... | |
Common::Result | HF::Core::SessionManagement::AbstractServer::check_offset (uint16_t offset, uint8_t &count, uint16_t size) const |
Check if the given offset is valid and adjust the count value if necessary. More... | |
virtual void | HF::Core::SessionManagement::AbstractServer::send (const Protocol::Address &addr, Protocol::Message &message)=0 |
Send message msg to the network address given by addr . More... | |
virtual uint16_t | HF::Core::SessionManagement::AbstractServer::entries_size () const =0 |
Get the number of entries present in the container. More... | |
virtual Common::Result | HF::Core::SessionManagement::AbstractServer::entries (uint16_t offset, uint8_t count, Common::ByteArray &payload)=0 |
Create a GetEntriesResponse message message with, count entries starting from the given offset and serialize the created message into the given byte array in payload . More... | |
Common::Result | HF::Core::SessionManagement::AbstractServer::check_session (uint16_t address, Common::ByteArray &payload) const |
Check if a session for the given device address exists and if it is valid. More... | |
HF::Core::SessionManagement::EntriesWrapper< Parent >::EntriesWrapper (AbstractServer &_manager) | |
Constructor. More... | |
HF::Core::SessionManagement::EntriesWrapper< Parent >::EntriesWrapper (const EntriesWrapper &other, AbstractServer &_manager) | |
Constructor. More... | |
Common::Result | HF::Core::SessionManagement::EntriesWrapper< Parent >::save (const value_type &entry) |
Store the given entry to persistent storage. More... | |
Common::Result | HF::Core::SessionManagement::EntriesWrapper< Parent >::destroy (const value_type &entry) |
Destroy the given entry in the persistent storage. More... | |
Container & | HF::Core::SessionManagement::Server< _Entries >::entries () const |
Return the container for the service entries. More... | |
HF::Core::SessionManagement::Server< _Entries >::Server (const Server &other) | |
Copy-Constructor. More... | |
uint16_t | HF::Core::SessionManagement::Server< _Entries >::entries_size () const |
Get the number of entries present in the container. More... | |
Common::Result | HF::Core::SessionManagement::Server< _Entries >::entries (uint16_t offset, uint8_t count, Common::ByteArray &payload) |
Create a GetEntriesResponse message message with, count entries starting from the given offset and serialize the created message into the given byte array in payload . More... | |
Common::Result | HF::Core::SessionManagement::AbstractClient::handle_command (CMD cmd, Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset=0) |
Handle command request/response messages. More... | |
uint16_t | HF::Core::SessionManagement::AbstractClient::payload_size (CMD cmd) const |
Get the minimum number of bytes necessary to pack/unpack a message of the given command. More... | |
template<uint8_t _role, uint16_t _uid, uint8_t _member> | |
void | HF::Core::SessionManagement::AbstractClient::get_entries (uint16_t offset, uint8_t count=0) const |
Helper method to send a message to read, count entries starting at offset from the server. More... | |
template<uint8_t _role, uint16_t _uid, uint8_t _member> | |
void | HF::Core::SessionManagement::AbstractClient::request () const |
Helper method to create a session management request. More... | |
virtual void | HF::Core::SessionManagement::AbstractClient::send (const Protocol::Address &addr, Protocol::Message &message)=0 |
Send message msg to the network address given by addr . More... | |
Events | |
virtual void | HF::Core::SessionManagement::Client< _Entry >::entries (const GetEntriesResponse< _Entry > &response) |
This event is called when a response to a get entries is received. More... | |
This module contains the classes that implement the Session Management functionality.
Available commands for session management.
Enumerator | |
---|---|
START | Start a new session for a device. |
GET | Retrieve information. |
END | End the session for device. |
Definition at line 42 of file session_management.h.
|
inline |
Constructor.
[in] | _manager | session manager the entries are associated to. |
Definition at line 557 of file session_management.h.
|
inline |
Constructor.
[in] | other | entries container to wrap. |
[in] | _manager | session manager the entries are associated to. |
Definition at line 567 of file session_management.h.
|
inlineprotected |
Copy-Constructor.
Make sure that the entries are copied maintaining this object as the session manager.
[in] | other | reference to the object to copy from. |
Definition at line 627 of file session_management.h.
|
inline |
Constructor.
[in] | _address | device address this session belongs to. |
[in] | _valid | true if the session is valid, false otherwise. |
Definition at line 330 of file session_management.h.
|
inline |
Constructor.
[in] | count | number of entries available. |
Definition at line 65 of file session_management.h.
|
protected |
Check if the given offset
is valid and adjust the count
value if necessary.
[in] | offset | offset to start reading the entries from. |
[in,out] | count | number of entries to read. |
[in] | size | number of entries present in the underling container. |
HF::Common::Result::OK | if entries can be read. |
HF::Common::Result::FAIL_ARG | if the offset value is invalid. |
Referenced by HF::Core::SessionManagement::Server< Entries >::entries().
|
protected |
Check if a session for the given device address
exists and if it is valid.
In case a session does not exist or is invalid, place an GetEntriesEmptyResponse into the byte array given by payload
to be sent to the remote device.
[in] | address | device address to check the session for. |
[out] | payload | the byte array to place the response in case of error. |
Common::Result::FAIL_READ_SESSION | if the session does not exist; |
Common::Result::FAIL_FAIL_MODIFIED | if the session is not valid; |
Common::Result::OK | a session exists an is valid. |
|
inline |
Destroy the given entry
in the persistent storage.
[in] | entry | reference to the entry to erase. |
Common::Result::OK,if | the entry was destroyed. |
Common::Result::FAIL_ARG | otherwise. |
Definition at line 584 of file session_management.h.
|
pure virtual |
Terminate the session associated with the device with the given address
.
[in] | address | device address to end the session for. |
Implemented in HF::Core::SessionManagement::AbstractServer.
|
inlinevirtual |
Terminate the session associated with the device with the given address
.
[in] | address | device address to end the session for. |
Implements HF::Core::SessionManagement::IServer.
Definition at line 369 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::find(), and HF::Core::SessionManagement::AbstractServer::sessions.
|
protectedpure virtual |
Create a GetEntriesResponse message message with, count
entries starting from the given offset
and serialize the created message into the given byte array in payload
.
offset + count > [number of entries]
, the message will truncated to the available entries starting from the given offset
.[in] | offset | the offset to start reading the entries. |
[in] | count | number of entries to read. |
[out] | payload | byte array to serialize the entries to. |
Common::Result::OK | message created successfully; |
Common::Result::FAIL_ARG | if offset is bigger than the number of entries. |
Implemented in HF::Core::SessionManagement::Server< _Entries >, and HF::Core::SessionManagement::Server< Entries >.
|
inline |
Return the container for the service entries.
Definition at line 607 of file session_management.h.
Referenced by HF::Core::BindManagement::Server< Entries >::entries(), and HF::Core::DeviceManagement::Server< Entries >::entries().
|
inlineprotectedvirtual |
Create a GetEntriesResponse message message with, count
entries starting from the given offset
and serialize the created message into the given byte array in payload
.
offset + count > [number of entries]
, the message will truncated to the available entries starting from the given offset
.[in] | offset | the offset to start reading the entries. |
[in] | count | number of entries to read. |
[out] | payload | byte array to serialize the entries to. |
Common::Result::OK | message created successfully; |
Common::Result::FAIL_ARG | if offset is bigger than the number of entries. |
Implements HF::Core::SessionManagement::AbstractServer.
Definition at line 642 of file session_management.h.
|
inlinevirtual |
This event is called when a response to a get entries is received.
[in] | response | the response received. |
Definition at line 837 of file session_management.h.
|
protectedpure virtual |
Get the number of entries present in the container.
Implemented in HF::Core::SessionManagement::Server< _Entries >, and HF::Core::SessionManagement::Server< Entries >.
|
inlineprotectedvirtual |
Get the number of entries present in the container.
Implements HF::Core::SessionManagement::AbstractServer.
Definition at line 635 of file session_management.h.
Referenced by HF::Core::SessionManagement::Server< Entries >::entries().
|
pure virtual |
Check if a session for the device with the given address
exists.
[in] | address | device address to check is a session exists. |
true | if a session exists, |
false | otherwise. |
Implemented in HF::Core::SessionManagement::AbstractServer.
|
inlinevirtual |
Check if a session for the device with the given address
exists.
[in] | address | device address to check is a session exists. |
true | if a session exists, |
false | otherwise. |
Implements HF::Core::SessionManagement::IServer.
Definition at line 379 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::find(), and HF::Core::SessionManagement::AbstractServer::sessions.
|
inlineprotected |
Find the session associated with the given device address
.
[in] | address | device address to search a session for. |
Definition at line 438 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::sessions.
Referenced by HF::Core::SessionManagement::AbstractServer::end_session(), HF::Core::SessionManagement::AbstractServer::exists(), HF::Core::SessionManagement::AbstractServer::is_valid(), and HF::Core::SessionManagement::AbstractServer::start_session().
|
inlineprotected |
Find the session associated with the given device address
.
[in] | address | device address to search a session for. |
Definition at line 456 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::sessions.
|
inlineprotected |
Helper method to send a message to read, count
entries starting at offset
from the server.
[in] | offset | index to start reading the entries from. |
[in] | count | number of entries to read. |
Definition at line 776 of file session_management.h.
References HF::Common::Interface::id, HF::Protocol::Message::itf, HF::Protocol::Message::Interface::member, HF::Core::SessionManagement::GetEntriesMessage::pack(), HF::Protocol::Message::payload, HF::Common::Interface::role, HF::Core::SessionManagement::AbstractClient::send(), and HF::Core::SessionManagement::GetEntriesMessage::size().
|
protected |
Handle command request/response messages.
[in] | cmd | the session operation to process. |
[in] | packet | the packet receive from the network. |
[in] | payload | the byte array containing the data received from the network. |
[in] | offset | the offset the payload start at in the byte array. |
|
protected |
Handle command request/response messages.
[in] | cmd | the session operation to process. |
[in] | packet | the packet receive from the network. |
[in] | payload | the byte array containing the data received from the network. |
[in] | offset | the offset the payload start at in the byte array. |
|
pure virtual |
Check if the session for the device with the given address
is valid, i.e., the underling entries have not been modified since the start of the session.
[in] | address | device address to check is the session is valid. |
true | if the session exists and is valid, |
false | otherwise. |
Implemented in HF::Core::SessionManagement::AbstractServer.
|
inlinevirtual |
Check if the session for the device with the given address
is valid, i.e., the underling entries have not been modified since the start of the session.
[in] | address | device address to check is the session is valid. |
true | if the session exists and is valid, |
false | otherwise. |
Implements HF::Core::SessionManagement::IServer.
Definition at line 384 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::find(), and HF::Core::SessionManagement::AbstractServer::sessions.
|
inline |
Write the object on to a ByteArray so it can be sent over the network.
The buffer passed in MUST have enough size to hold the serialized object, e.g.,
[in,out] | array | ByteArray reference to write the object to. |
[in] | offset | offset to start writing to. |
Definition at line 121 of file session_management.h.
References HF_SERIALIZABLE_CHECK, HF::Core::SessionManagement::GetEntriesMessage::min_size, HF::Core::SessionManagement::GetEntriesMessage::offset, and HF::Common::ByteArray::write().
Referenced by HF::Core::SessionManagement::AbstractClient::get_entries().
|
protected |
Get the minimum number of bytes necessary to pack/unpack a message of the given command.
[in] | cmd | the command to get the number of bytes for. |
|
protected |
Get the minimum number of bytes necessary to pack/unpack a message of the given command.
[in] | cmd | the command to get the number of bytes for. |
|
inlineprotected |
Helper method to create a session management request.
_role | role to use in the created message. |
_uid | interface UID to use in the message. |
_member | interface member ID to use. |
Definition at line 803 of file session_management.h.
References HF::Common::Interface::id, HF::Protocol::Message::itf, HF::Protocol::Message::Interface::member, HF::Common::Interface::role, and HF::Core::SessionManagement::AbstractClient::send().
Referenced by HF::Core::BindManagement::Client::end_session(), HF::Core::DeviceManagement::Client::end_session(), HF::Core::BindManagement::Client::start_session(), and HF::Core::DeviceManagement::Client::start_session().
|
inline |
Store the given entry
to persistent storage.
[in] | entry | the entry to save to storage. |
Common::Result::OK | if the entry was saved, |
Common::Result::FAIL_UNKNOWN | otherwise. |
Definition at line 575 of file session_management.h.
|
protectedpure virtual |
Send message msg
to the network address given by addr
.
[in] | addr | HF network address. |
[in] | message | pointer to the message to be sent to the network. |
Implemented in HF::Core::DeviceManagement::Server< _Entries >, HF::Core::DeviceManagement::Server< Entries >, HF::Core::BindManagement::Server< _Entries >, and HF::Core::BindManagement::Server< Entries >.
|
protectedpure virtual |
Send message msg
to the network address given by addr
.
[in] | addr | HF network address. |
[in] | message | pointer to the message to be sent to the network. |
Implemented in HF::Core::DeviceManagement::Client, and HF::Core::BindManagement::Client.
Referenced by HF::Core::SessionManagement::AbstractClient::get_entries(), and HF::Core::SessionManagement::AbstractClient::request().
|
inline |
Number bytes needed to serialize the message.
Definition at line 115 of file session_management.h.
References HF::Core::SessionManagement::GetEntriesMessage::min_size.
Referenced by HF::Core::SessionManagement::AbstractClient::get_entries().
|
pure virtual |
Start a session for the device with the given address
.
Only one session is associated with any given device at any time.
[in] | address | device address to start the session for. |
Implemented in HF::Core::SessionManagement::AbstractServer.
|
inlinevirtual |
Start a session for the device with the given address
.
Only one session is associated with any given device at any time.
[in] | address | device address to start the session for. |
Implements HF::Core::SessionManagement::IServer.
Definition at line 355 of file session_management.h.
References HF::Core::SessionManagement::AbstractServer::find(), and HF::Core::SessionManagement::AbstractServer::sessions.
|
inline |
Read a message from a ByteArray.
[in] | array | ByteArray reference to read the message from. |
[in] | offset | offset to start reading from. |
Definition at line 132 of file session_management.h.
References HF_SERIALIZABLE_CHECK, HF::Core::SessionManagement::GetEntriesMessage::min_size, HF::Core::SessionManagement::GetEntriesMessage::offset, and HF::Common::ByteArray::read().
uint16_t HF::Core::SessionManagement::AbstractServer::Session::address |
Device address for session.
Definition at line 321 of file session_management.h.
uint16_t HF::Core::SessionManagement::StartResponse::count |
Number of device entries.
Definition at line 58 of file session_management.h.
uint8_t HF::Core::SessionManagement::GetEntriesMessage::count |
Number of entries to be sent in the response.
Definition at line 104 of file session_management.h.
uint16_t HF::Core::SessionManagement::GetEntriesMessage::offset |
Start index for the first entry to be provided.
Definition at line 103 of file session_management.h.
Referenced by HF::Core::SessionManagement::GetEntriesMessage::pack(), and HF::Core::SessionManagement::GetEntriesMessage::unpack().
bool HF::Core::SessionManagement::AbstractServer::Session::valid |
Indicate if the session is still valid.
Definition at line 322 of file session_management.h.