In order for the client and server to communicate, they must agree on a common message protocol. Creating a message protocol requires the following:
Because these elements are the same for both the client and server, they are factored out into their own library in the interest of efficiency.
The include file protocol.h contains the basic C type definitions and message tag enumeration for the Fserv message protocol. The type and protocol specifications are contained in protocol.c.
First, we define the types that will be used to transmit data between client and server:
Note the presence of the opaque FileHandle
structure. This type will be transmitted to the client as a handle. The actual definition of this structure is placed in protocol-server.h which the client does not include. This prevents client code from erroneously attempting to dereference opaque handle types.
Also note that there are no OpenReply
or CloseRequest
structures. This is because both can be represented as FileHandle
s without being wrapped in an outer structure – LWMsg permits any pointer or pointer-like type to be the payload of a message.
We then enumerates all possible message tags. These tags comprise the set of messages that may be sent between client and server. Each element of the enumeration has a comment specifying the C structure which is the payload for that type of message.
There is a request tag and response tag for each call we want to support. There is also a generic void tag which is used for call responses that contain no data, and a generic error tag for call responses that indicate an error.
LWMsg does not impose limitations on when certain message types can be sent or by whom. Although LWMsg guarantees that all message payloads are well-formed, it is up to the application to ensure that they are used appropriately.
Each C structure that we want to use in the message protocol must have a type specification describing it:
Finally, we need a protocol specification which binds together our enumerated set of messages tags and indicates the payload type of each message.
Likewise Message Library, part of the Likewise platform
Copyright © 2017 Likewise Software. All rights reserved.