Go to the source code of this file.
Legato Low-Level Messaging API include file.
Copyright (C) Sierra Wireless, Inc. 2014. All rights reserved. Use of this work is subject to license.
#define LE_KILL_CLIENT | ( | formatString, | |
... | |||
) |
{ \ le_msg_MessageRef_t msgRef = le_msg_GetServiceRxMsg(); \ LE_FATAL_IF(msgRef == NULL, formatString, ##__VA_ARGS__); \ LE_EMERG(formatString, ##__VA_ARGS__); \ le_msg_CloseSession(le_msg_GetSession(msgRef)); \ }
Logs an error message (at EMERGENCY level) and:
typedef struct le_msg_Message* le_msg_MessageRef_t |
Reference to a message.
typedef struct le_msg_Protocol* le_msg_ProtocolRef_t |
Reference to a protocol.
typedef void(* le_msg_ReceiveHandler_t)(le_msg_MessageRef_t msgRef, void *contextPtr) |
Receive handler function prototype.
See le_msg_SetSessionRecvHandler() and le_msg_SetServiceRecvHandler().
msgRef | [in] Reference to the received message. Don't forget to release this using le_msg_ReleaseMsg() when you are finished with it. |
contextPtr | [in] Opaque contextPtr value provided when the handler was registered. |
typedef void(* le_msg_ResponseCallback_t)(le_msg_MessageRef_t msgRef, void *contextPtr) |
Asynchronous response callback function prototype.
msgRef | [in] Reference to the received response message, or NULL if the transaction failed and no response was received. If not NULL, don't forget to release it by calling le_msg_ReleaseMsg() when you are finished with it. |
contextPtr | [in] Opaque contextPtr value passed to le_msg_RequestResponse(). |
typedef struct le_msg_Service* le_msg_ServiceRef_t |
Reference to a server's service instance.
typedef void(* le_msg_SessionEventHandler_t)(le_msg_SessionRef_t sessionRef, void *contextPtr) |
Handler function prototype for handlers that take session references as their arguments.
See le_msg_SetSessionCloseHandler(), le_msg_SetServiceOpenHandler(), and le_msg_SetServiceCloseHandler().
sessionRef | [in] Reference to the session that experienced the event. |
contextPtr | [in] Opaque contextPtr value provided when the handler was registered. |
typedef struct le_msg_Session* le_msg_SessionRef_t |
Reference to a client-server session.
void le_msg_AddRef | ( | le_msg_MessageRef_t | msgRef | ) |
Adds to the reference count on a message object.
[in] | msgRef | Reference to the message. |
void le_msg_AdvertiseService | ( | le_msg_ServiceRef_t | serviceRef | ) |
Makes a given service available for clients to find.
[in] | serviceRef | Reference to the service. |
void le_msg_CloseSession | ( | le_msg_SessionRef_t | sessionRef | ) |
Terminates a session.
[in] | sessionRef | Reference to the session. |
le_msg_MessageRef_t le_msg_CreateMsg | ( | le_msg_SessionRef_t | sessionRef | ) |
Creates a message to be sent over a given session.
[in] | sessionRef | Reference to the session. |
le_msg_ServiceRef_t le_msg_CreateService | ( | le_msg_ProtocolRef_t | protocolRef, |
const char * | serviceName | ||
) |
Creates a service that is accessible using a protocol.
[in] | protocolRef | Reference to the protocol to be used. |
[in] | serviceName | Service instance name. |
le_msg_SessionRef_t le_msg_CreateSession | ( | le_msg_ProtocolRef_t | protocolRef, |
const char * | serviceName | ||
) |
Creates a session that will make use of a protocol to talk to a given service.
[in] | protocolRef | Reference to the protocol to be used. |
[in] | serviceName | Name of the service instance. |
void le_msg_DeleteService | ( | le_msg_ServiceRef_t | serviceRef | ) |
Deletes a service. Any open sessions will be terminated.
[in] | serviceRef | Reference to the service. |
void le_msg_DeleteSession | ( | le_msg_SessionRef_t | sessionRef | ) |
Deletes a session. This will end the session and free up any resources associated with it. Any pending request-response transactions in this sesssion will be terminated. If the far end has registered a session close handler callback, it will be called.
[in] | sessionRef | Reference to the session. |
le_result_t le_msg_GetClientUserId | ( | le_msg_SessionRef_t | sessionRef, |
uid_t * | userIdPtr | ||
) |
Fetches the user ID of the client at the far end of a given IPC session.
[in] | sessionRef | Reference to the session. |
[out] | userIdPtr | Ptr to where the result is to be stored on success. |
size_t le_msg_GetMaxPayloadSize | ( | le_msg_MessageRef_t | msgRef | ) |
Gets the size, in bytes, of the message payload memory buffer.
[in] | msgRef | Reference to the message. |
void* le_msg_GetPayloadPtr | ( | le_msg_MessageRef_t | msgRef | ) |
Gets a pointer to the message payload memory buffer.
[in] | msgRef | Reference to the message. |
const char* le_msg_GetProtocolIdStr | ( | le_msg_ProtocolRef_t | protocolRef | ) |
Gets the unique identifier string of the protocol.
[in] | protocolRef | Reference to the protocol. |
size_t le_msg_GetProtocolMaxMsgSize | ( | le_msg_ProtocolRef_t | protocolRef | ) |
Gets the protocol's maximum message size.
[in] | protocolRef | Reference to the protocol. |
le_msg_ProtocolRef_t le_msg_GetProtocolRef | ( | const char * | protocolId, |
size_t | largestMsgSize | ||
) |
Gets a reference to refer to a particular version of a particular protocol.
Used to help match clients with services that use the same protocol.
[in] | protocolId | String uniquely identifying the the protocol and version. |
[in] | largestMsgSize | Size (in bytes) of the largest message in the protocol. |
void* le_msg_GetServiceContextPtr | ( | le_msg_ServiceRef_t | serviceRef | ) |
Fetches the opaque context value (void pointer) associated with a specified service using le_msg_SetServiceContextPtr().
[in] | serviceRef | Reference to the service. |
const char* le_msg_GetServiceName | ( | le_msg_ServiceRef_t | serviceRef | ) |
Fetches a pointer to the name of a service.
[in] | serviceRef | Reference to the service. |
le_msg_ProtocolRef_t le_msg_GetServiceProtocol | ( | le_msg_ServiceRef_t | serviceRef | ) |
Fetches a reference to the protocol supported by a specified Service.
[in] | serviceRef | Reference to the service. |
Check if the calling thread is currently running a Service's message receive handler; if so, return a reference to the message object being handled.
Gets a reference to the session to which a given message belongs.
[in] | msgRef | Reference to the message. |
void* le_msg_GetSessionContextPtr | ( | le_msg_SessionRef_t | sessionRef | ) |
Fetches the opaque context value (void pointer) that was set earlier using le_msg_SetSessionContextPtr().
[in] | sessionRef | Reference to the session. |
le_msg_ProtocolRef_t le_msg_GetSessionProtocol | ( | le_msg_SessionRef_t | sessionRef | ) |
Fetches a reference to the protocol that is being used for a given session.
[in] | sessionRef | Reference to the session. |
le_msg_ServiceRef_t le_msg_GetSessionService | ( | le_msg_SessionRef_t | sessionRef | ) |
Fetches a reference to the service that is associated with a given session.
[in] | sessionRef | Reference to the session. |
void le_msg_HideService | ( | le_msg_ServiceRef_t | serviceRef | ) |
Makes a specified service unavailable for clients to find without terminating any ongoing sessions.
[in] | serviceRef | Reference to the service. |
bool le_msg_NeedsResponse | ( | le_msg_MessageRef_t | msgRef | ) |
Checks whether a message requires a response or not.
[in] | msgRef | Reference to the message. |
void le_msg_OpenSession | ( | le_msg_SessionRef_t | sessionRef, |
le_msg_SessionEventHandler_t | callbackFunc, | ||
void * | contextPtr | ||
) |
Opens a session with a service, providing a function to be called-back when the session is open.
[in] | sessionRef | Reference to the session. |
[in] | callbackFunc | Function to be called when open. NULL if no notification is needed. |
[in] | contextPtr | Opaque value to pass to the callback. |
le_result_t le_msg_OpenSessionSync | ( | le_msg_SessionRef_t | sessionRef | ) |
Synchronously open a session with a service. Blocks until the session is open or the attempt is rejected.
[in] | sessionRef | Reference to the session. |
void le_msg_ReleaseMsg | ( | le_msg_MessageRef_t | msgRef | ) |
Releases a message object, decrementing its reference count. If the reference count has reached zero, the message object is deleted.
[in] | msgRef | Reference to the message. |
void le_msg_RequestResponse | ( | le_msg_MessageRef_t | msgRef, |
le_msg_ResponseCallback_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Requests a response from a server by sending it a request. Doesn't block. Instead, provides a callback function to be called when the response arrives or the transaction terminates without a response (due to the session terminating or the server deleting the request without responding).
[in] | msgRef | Reference to the request message. |
[in] | handlerFunc | Function to be called when transaction done. |
[in] | contextPtr | Opaque value to be passed to handler function. |
Requests a response from a server by sending it a request. Blocks until the response arrives or until the transaction terminates without a response (i.e., if the session terminates or the server deletes the request without responding).
[in] | msgRef | Reference to the request message. |
void le_msg_Respond | ( | le_msg_MessageRef_t | msgRef | ) |
Sends a response back to the client that send the request message.
Takes a reference to the request message. Copy the response payload (if any) into the same payload buffer that held the request payload, then call le_msg_Respond().
The messaging system will delete the message automatically when it's finished sending the response.
[in] | msgRef | Reference to the request message. |
void le_msg_Send | ( | le_msg_MessageRef_t | msgRef | ) |
Sends a message. No response expected.
[in] | msgRef | Reference to the message. |
void le_msg_SetServiceCloseHandler | ( | le_msg_ServiceRef_t | serviceRef, |
le_msg_SessionEventHandler_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Registers a function to be called whenever one of this service's sessions is closed by the client.
[in] | serviceRef | Reference to the service. |
[in] | handlerFunc | Handler function. |
[in] | contextPtr | Opaque pointer value to pass to handler. |
void le_msg_SetServiceContextPtr | ( | le_msg_ServiceRef_t | serviceRef, |
void * | contextPtr | ||
) |
Associates an opaque context value (void pointer) with a given service that can be retrieved later using le_msg_GetServiceContextPtr().
[in] | serviceRef | Reference to the service. |
[in] | contextPtr | Opaque value to be returned by le_msg_GetServiceContextPtr(). |
void le_msg_SetServiceOpenHandler | ( | le_msg_ServiceRef_t | serviceRef, |
le_msg_SessionEventHandler_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Registers a function to be called when clients open sessions with this service.
[in] | serviceRef | Reference to the service. |
[in] | handlerFunc | Handler function. |
[in] | contextPtr | Opaque pointer value to pass to handler. |
void le_msg_SetServiceRecvHandler | ( | le_msg_ServiceRef_t | serviceRef, |
le_msg_ReceiveHandler_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Registers a function to be called when messages are received from clients via sessions that they have open with this service.
[in] | serviceRef | Reference to the service. |
[in] | handlerFunc | Handler function. |
[in] | contextPtr | Opaque pointer value to pass to the handler. |
void le_msg_SetSessionCloseHandler | ( | le_msg_SessionRef_t | sessionRef, |
le_msg_SessionEventHandler_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Sets the handler callback function to be called when the session is closed from the other end. A local termination of the session will not trigger this callback.
The handler function will be called by the Legato event loop of the thread that created the session.
[in] | sessionRef | Reference to the session. |
[in] | handlerFunc | Handler function. |
[in] | contextPtr | Opaque pointer value to pass to handler. |
void le_msg_SetSessionContextPtr | ( | le_msg_SessionRef_t | sessionRef, |
void * | contextPtr | ||
) |
Sets an opaque context value (void pointer) that can be retrieved from that session later using le_msg_GetSessionContextPtr().
[in] | sessionRef | Reference to the session. |
[in] | contextPtr | Opaque value to be returned by le_msg_GetSessionContextPtr(). |
void le_msg_SetSessionRecvHandler | ( | le_msg_SessionRef_t | sessionRef, |
le_msg_ReceiveHandler_t | handlerFunc, | ||
void * | contextPtr | ||
) |
Sets the receive handler callback function to be called when a non-response message arrives on this session.
The handler function will be called by the Legato event loop of the thread that created the session.
[in] | sessionRef | Reference to the session. |
[in] | handlerFunc | Handler function. |
[in] | contextPtr | Opaque pointer value to pass to the handler. |