libtransistor
A userland library for the Nintendo Switch
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Typedefs | Enumerations | Functions | Variables
ipc.h File Reference

Interprocess Communication data structures and functions. More...

#include <libtransistor/types.h>
Include dependency graph for ipc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ipc_domain_t
 Represents an IPC object domain. More...
 
struct  ipc_object_t
 Represents either an object within an IPC domain or a standalone object. More...
 
struct  ipc_multi_session_node_t
 
struct  ipc_multi_session_t
 A wrapper around a session that will clone it for use from multiple threads when necessary. More...
 
struct  ipc_buffer_t
 Buffer for transfer over IPC. More...
 
struct  ipc_request_t
 Represents an unmarshalled outgoing IPC request. More...
 
struct  ipc_request_fmt_t
 Describes format expectations for an incoming IPC request. More...
 
struct  ipc_response_t
 Represents an unmarshalled outgoing IPC response. More...
 
struct  ipc_response_fmt_t
 Describes format expectations for an incoming IPC response. More...
 
struct  ipc_message_t
 Describes an incoming IPC message. Used as an intermediate during unpacking. More...
 

Typedefs

typedef struct
ipc_multi_session_node_t 
ipc_multi_session_node_t
 

Enumerations

enum  ipc_debug_level_t {
  IPC_DEBUG_LEVEL_NONE, IPC_DEBUG_LEVEL_UNPACKING_ERRORS, IPC_DEBUG_LEVEL_UNFLATTENING_ERRORS, IPC_DEBUG_LEVEL_FLIGHT_ERRORS,
  IPC_DEBUG_LEVEL_ALL
}
 

Functions

result_t ipc_pack_request (uint32_t *buffer, const ipc_request_t *rq, ipc_object_t object)
 Packs the IPC request described by rq and object into buffer. More...
 
result_t ipc_pack_response (uint32_t *buffer, const ipc_response_t *rs, struct ipc_server_object_t *object)
 Packs the IPC response described by rs and object into buffer. More...
 
result_t ipc_unpack (uint32_t *buffer, ipc_message_t *msg)
 Unpacks the IPC message from buffer, filling out msg. More...
 
result_t ipc_unflatten_request (ipc_message_t *msg, ipc_request_fmt_t *rs, struct ipc_server_object_t *object)
 Unflattens the IPC request described by rq from msg More...
 
result_t ipc_unflatten_response (ipc_message_t *msg, ipc_response_fmt_t *rs, ipc_object_t object)
 Unflattens the IPC response described by rs from msg. More...
 
result_t ipc_send (ipc_object_t object, ipc_request_t *rq, ipc_response_fmt_t *rs)
 Send a request described by rq to object and then unpack the response. More...
 
result_t ipc_send_multi (ipc_multi_session_t *multi, ipc_request_t *rq, ipc_response_fmt_t *rs)
 Send a requst described by rq to multi and then unpack the response See ipc_send. NOTE: may call malloc if multiple threads are used.
 
result_t ipc_convert_to_domain (ipc_object_t *session, ipc_domain_t *domain)
 Converts session to a domain object and initializes domain. domain is only initialized if RESULT_OK is returned. More...
 
result_t ipc_convert_to_multi (ipc_multi_session_t *multi, ipc_object_t *object)
 Converts a session to a multi session.
 
result_t ipc_clone_current_object (ipc_object_t source, ipc_object_t *clone)
 Clones a session.
 
result_t ipc_close (ipc_object_t object)
 Closes the object More...
 
result_t ipc_close_domain (ipc_domain_t domain)
 Closes the whole domain More...
 
result_t ipc_close_multi (ipc_multi_session_t *multi)
 Closes a multi session. More...
 

Variables

ipc_request_t ipc_default_request
 An IPC request with default values set. More...
 
ipc_response_t ipc_default_response
 An IPC response with default values set. More...
 
ipc_request_fmt_t ipc_default_request_fmt
 An IPC request format with default values set. More...
 
ipc_response_fmt_t ipc_default_response_fmt
 An IPC response format with default values set. More...
 
ipc_object_t ipc_null_object
 An IPC object with default NULL values set. More...
 
ipc_debug_level_t ipc_debug_level
 Default: IPC_DEBUG_LEVEL_NONE.
 

Detailed Description

Interprocess Communication data structures and functions.

This file contains some of the types and functions required for IPC server functionality. The remaining functionality is found in ipcserver.h

Enumeration Type Documentation

Enumerator
IPC_DEBUG_LEVEL_NONE 

Do not log any IPC messages.

IPC_DEBUG_LEVEL_UNPACKING_ERRORS 

Hexdump responses that could not be unpacked.

IPC_DEBUG_LEVEL_UNFLATTENING_ERRORS 

Hexdump responses that could not be unflattened.

IPC_DEBUG_LEVEL_FLIGHT_ERRORS 

Hexdump requests that triggered an error in svcSendSyncRequest.

IPC_DEBUG_LEVEL_ALL 

Hexdump all requests and all responses.

Function Documentation

result_t ipc_close ( ipc_object_t  object)

Closes the object

Parameters
objectObject to close
result_t ipc_close_domain ( ipc_domain_t  domain)

Closes the whole domain

Parameters
domainDomain to close
result_t ipc_close_multi ( ipc_multi_session_t multi)

Closes a multi session.

It is illegal to call this while any threads are still using the multi session.

result_t ipc_convert_to_domain ( ipc_object_t session,
ipc_domain_t domain 
)

Converts session to a domain object and initializes domain. domain is only initialized if RESULT_OK is returned.

Parameters
sessionObject to convert to a domain object
domainDomain to initialize
result_t ipc_pack_request ( uint32_t *  buffer,
const ipc_request_t rq,
ipc_object_t  object 
)

Packs the IPC request described by rq and object into buffer.

Parameters
bufferTarget for marshalled IPC request
rqRequest to pack
objectObject to send the request to
result_t ipc_pack_response ( uint32_t *  buffer,
const ipc_response_t rs,
struct ipc_server_object_t object 
)

Packs the IPC response described by rs and object into buffer.

Used by IPC server.

Parameters
bufferTarget for marshalled IPC response
rsResponse to pack
objectObject to send the response from
result_t ipc_send ( ipc_object_t  object,
ipc_request_t rq,
ipc_response_fmt_t rs 
)

Send a request described by rq to object and then unpack the response.

Parameters
objectObject to send request to
rqRequest to send
rsResponse expectations
result_t ipc_unflatten_request ( ipc_message_t msg,
ipc_request_fmt_t rs,
struct ipc_server_object_t object 
)

Unflattens the IPC request described by rq from msg

It is expected that the decision for which object to dispatch to can be made based off of the fields in ipc_message_t alone, without having to unflatten it fully.

Used by IPC server.

Parameters
msgIPC message to unflatten
rsFormat expectations for incoming request
objectObject that the request is destined for.
result_t ipc_unflatten_response ( ipc_message_t msg,
ipc_response_fmt_t rs,
ipc_object_t  object 
)

Unflattens the IPC response described by rs from msg.

Parameters
bufferMarshalled IPC message
rsResponse format expectations
objectObject that the response was received from
result_t ipc_unpack ( uint32_t *  buffer,
ipc_message_t msg 
)

Unpacks the IPC message from buffer, filling out msg.

Parameters
bufferPacked IPC message
msgPartially unpacked IPC message

Variable Documentation

ipc_request_t ipc_default_request

An IPC request with default values set.

Parameters
typeDefault: 4
num_buffersDefault: 0
buffersDefault: NULL
request_idDefault: 0
raw_dataDefault: 0
raw_data_sizeDefault: 0
send_pidDefault: 0
num_copy_handlesDefault: 0
num_move_handlesDefault: 0
num_objectsDefault: 0
copy_handlesDefault: NULL
move_handlesDefault: NULL
objectsDefault: NULL
close_objectDefault: false
ipc_request_fmt_t ipc_default_request_fmt

An IPC request format with default values set.

Used for IPC server.

ipc_response_t ipc_default_response

An IPC response with default values set.

Used for IPC server.

ipc_response_fmt_t ipc_default_response_fmt

An IPC response format with default values set.

Parameters
num_copy_handlesDefault: 0
num_move_handlesDefault: 0
num_objectsDefault: 0
copy_handlesDefault: NULL
move_handlesDefault: NULL
objectsDefault: NULL
raw_data_sizeDefault: 0
raw_dataDefault: 0
has_pidDefault: false
pidDefault: 0
ipc_object_t ipc_null_object

An IPC object with default NULL values set.

Parameters
sessionDefault: 0
object_idDefault: 1