Describe messages and message contents.
More...
Protocols consist of an enumerated set of message tags. Each message tag has an associated marshaller type which describes the layout of the payload for that message. Protocols fully specify the messages available to peers communicating through an association.
A protocol object includes one or more protocol specifications, which are simple statically-initialized C arrays.
#define LWMSG_MESSAGE |
( |
|
tag, |
|
|
|
spec |
|
) |
| |
This macro is used in the construction of protocol specifications. It declares a message by its integer tag and associated marshaller type specification.
- Parameters
-
tag | the integer identifier for the message |
spec | the marshaller type specifier that describes the message payload |
#define LWMSG_PROTOCOL_END |
This macro marks the end of a protocol specification. All protocol specifications must end with this macro.
An opaque protocol object suitable for creating associations
Defines the messages and payload types available to a protocol. You should initialize a static array of this structure in your source code using LWMSG_MESSAGE() and LWMSG_PROTOCOL_END. The result will be suitable to pass to lwmsg_protocol_add_protocol_spec(). Consider the following example:
* enum FooMessageType
* {
* FOO_REQUEST_BAR = 1,
* FOO_REPLY_BAR = 2,
* FOO_REQUEST_BAZ = 3,
* FOO_REPLY_BAZ = 4
* };
*
* {
* };
*
This example assumes the existence of the marshaller type specifications foo_request_bar_spec
, foo_request_baz_spec
, foo_reply_bar_spec
, and foo_reply_baz_spec
. See Types for more information on specifying marshaller types.
Gets the marshaller type associated with a given message tag. The retrieved type may be passed directly to the marshaller to marshal or unmarshal message payloads of the given type.
- Parameters
-
[in] | prot | the protocol |
[in] | tag | the message tag |
[out] | out_type | the marshaller type |
- Return values
-
Gets the symbolic name of the given message tag.
- Parameters
-
[in] | prot | the protocol |
[in] | tag | the message tag |
[out] | name | the symbolic name of the tag |
- Return values
-
Creates a new protocol object with no known messages. Messages must be added with lwmsg_protocol_add_protocol_spec().
- Parameters
-
[in] | context | a marshalling context, or NULL for default settings |
[out] | prot | the created protocol |
- Return values
-
Adds all messages in the specified protocol specification to the specified protocol object. This may be performed multiple times to aggregate several protocol specifications.
- Parameters
-
[in,out] | prot | the protocol object |
[in] | spec | the protocol specification |
- Return values
-
Deletes the specified protocol object. It is the caller's responsibility to ensure than no users of the object remain.
- Parameters
-
[in,out] | prot | the protocol object to delete |