Go to the source code of this file.
Macros | |
#define | LE_KILL_CLIENT(formatString, ...) |
Typedefs | |
typedef struct le_msg_Protocol * | le_msg_ProtocolRef_t |
typedef struct le_msg_Interface * | le_msg_InterfaceRef_t |
typedef struct le_msg_Service * | le_msg_ServiceRef_t |
typedef struct le_msg_ClientInterface * | le_msg_ClientInterfaceRef_t |
typedef struct le_msg_Session * | le_msg_SessionRef_t |
typedef struct le_msg_Message * | le_msg_MessageRef_t |
typedef struct le_msg_SessionEventHandler * | le_msg_SessionEventHandlerRef_t |
typedef void(* | le_msg_SessionEventHandler_t) (le_msg_SessionRef_t sessionRef, void *contextPtr) |
typedef void(* | le_msg_ReceiveHandler_t) (le_msg_MessageRef_t msgRef, void *contextPtr) |
typedef void(* | le_msg_ResponseCallback_t) (le_msg_MessageRef_t msgRef, void *contextPtr) |
Legato Low-Level Messaging API include file.
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
#define LE_KILL_CLIENT | ( | formatString, | |
... | |||
) |
Logs an error message (at EMERGENCY level) and:
typedef struct le_msg_ClientInterface* le_msg_ClientInterfaceRef_t |
Reference to a client's service instance.
typedef struct le_msg_Interface* le_msg_InterfaceRef_t |
Reference to an interface's service instance.
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_AddServiceOpenHandler(), and le_msg_AddServiceCloseHandler().
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_SessionEventHandler* le_msg_SessionEventHandlerRef_t |
Reference to a handler (call-back) function for events that can occur on a service (such as opening and closing of sessions and receipt of messages).
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. |
le_msg_SessionEventHandlerRef_t le_msg_AddServiceCloseHandler | ( | 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. |
le_msg_SessionEventHandlerRef_t le_msg_AddServiceOpenHandler | ( | 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_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 * | interfaceName | ||
) |
Creates a service that is accessible using a protocol.
[in] | protocolRef | Reference to the protocol to be used. |
[in] | interfaceName | Server-side interface name. |
le_msg_SessionRef_t le_msg_CreateSession | ( | le_msg_ProtocolRef_t | protocolRef, |
const char * | interfaceName | ||
) |
Creates a session that will make use of a protocol to talk to a service on a given client interface.
[in] | protocolRef | Reference to the protocol to be used. |
[in] | interfaceName | Name of the client-side interface. |
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 session 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_GetClientProcessId | ( | le_msg_SessionRef_t | sessionRef, |
pid_t * | processIdPtr | ||
) |
Fetches the user PID of the client at the far end of a given IPC session.
[in] | sessionRef | Reference to the session. |
[out] | processIdPtr | Ptr to where the result is to be stored on success. |
le_result_t le_msg_GetClientUserCreds | ( | le_msg_SessionRef_t | sessionRef, |
uid_t * | userIdPtr, | ||
pid_t * | processIdPtr | ||
) |
Fetches the user credentials of the client at the far end of a given IPC session.
[in] | sessionRef | Reference to the session. |
[out] | userIdPtr | Ptr to where the uid is to be stored on success. |
[out] | processIdPtr | Ptr to where the pid is to be stored on success. |
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. |
int le_msg_GetFd | ( | le_msg_MessageRef_t | msgRef | ) |
Fetches a received file descriptor from the message.
[in] | msgRef | Reference to the message. |
const char* le_msg_GetInterfaceName | ( | le_msg_InterfaceRef_t | interfaceRef | ) |
Fetches a pointer to the name of an interface.
[in] | interfaceRef | Reference to the interface. |
le_msg_ProtocolRef_t le_msg_GetInterfaceProtocol | ( | le_msg_InterfaceRef_t | interfaceRef | ) |
Fetches a reference to the protocol supported by a specified interface.
[in] | interfaceRef | Reference to the interface. |
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.
[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. |
le_msg_MessageRef_t le_msg_GetServiceRxMsg | ( | void | ) |
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.
le_msg_SessionRef_t le_msg_GetSession | ( | le_msg_MessageRef_t | msgRef | ) |
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_InterfaceRef_t le_msg_GetSessionInterface | ( | le_msg_SessionRef_t | sessionRef | ) |
Fetches a reference to the interface that is associated with a given session.
[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. |
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. |
void le_msg_OpenSessionSync | ( | le_msg_SessionRef_t | sessionRef | ) |
Synchronously open a session with a service. Blocks until the session is open.
This function logs a fatal error and terminates the calling process if unsuccessful.
[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_RemoveServiceHandler | ( | le_msg_SessionEventHandlerRef_t | handlerRef | ) |
Remove a function previously registered by le_msg_AddServiceOpenHandler or le_msg_AddServiceCloseHandler.
[in] | handlerRef | Reference to a previously call of le_msg_AddServiceCloseHandler() |
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. |
le_msg_MessageRef_t le_msg_RequestSyncResponse | ( | le_msg_MessageRef_t | msgRef | ) |
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_SetFd | ( | le_msg_MessageRef_t | msgRef, |
int | fd | ||
) |
Sets the file descriptor to be sent with this message.
This file descriptor will be closed when the message is sent (or when it is deleted without being sent).
At most one file descriptor is allowed to be sent per message.
[in] | msgRef | Reference to the message. |
[in] | fd | File descriptor. |
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_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. |
le_result_t le_msg_TryOpenSessionSync | ( | le_msg_SessionRef_t | sessionRef | ) |
Synchronously open a session with a service. Does not wait for the session to become available if not available..
le_msg_TryOpenSessionSync() differs from le_msg_OpenSessionSync() in that le_msg_TryOpenSessionSync() will not wait for a server session to become available if it is not already available at the time of the call. That is, if the client's interface is not bound to any service, or if the service that it is bound to is not currently advertised by the server, then le_msg_TryOpenSessionSync() will return an error code, while le_msg_OpenSessionSync() will wait until the binding is created or the server advertises the service (or both).
[in] | sessionRef | Reference to the session. |