Marshalling code library



next up previous
Next: About this document Up: MSRPC2 User Manual Previous: Runtime library interface

Marshalling code library

MSRPC2 uses the MSDR library to marshal and unmarshal data to/from the underlying communication format. MSDR defines a set of encoding and decoding rules for each possible data type. Each rule is specified in a functional form. Three types of operations can be invoked on an instance of a particular type, namely encoding, decoding and freeing. The encoding operation is used to encode an instance of a type into a form suitable for transmission using MSRPC2 protocols to the destination. The decoding rule is used by a receiver to convert the underlying protocol data into an instance of the appropriate type. The freeing rule is used to discard an instance of a particular type, once it is no longer required.

For each of the basic MSRPC2 types there is a corresponding MSDR type, listed below. For each MSDR type 3 functions are provided in the MSDR library to encode, decode and free data of that type. The encoding function is prefixed with m_, the decoding function is prefixed with u_, and the freeing function is prefixed with f_. The basic MSDR types are:

Constructed types, declared in MSRPC2 MIDDL interfaces, are also marshalled and unmarshalled using MSDR primitives. For each type in the interface, the interface compiler generates the 3 MSDR functions for encoding, decoding and freeing data of that type. These functions will make use of the basic MSDR primitives declared in the MSDR library. It is therefore possible to marshal data of any type, simply by making use of a set of basic marshalling primitives.

Associated with each MSRPC2 session binding at the client and server is an MSDR ``handle'' which refers to an object which maintains the state on the (de)serialisation of data corresponding to arguments and results of RPC calls. Both the client and server link with the same stub library and use the same MSDR routines to perform the (un)marshalling of the data. The MSDR object is initialised with a memory management structure containing pointers to 2 functions, for allocating and freeing memory. These are passed into the library by the client or server when creating the binding.

Wire representation

MSDR is endian dependent. Each interface reference contains information which describes the endian of the interface instance. A client is expected to marshal data in the endian format of the server. Similarly the client must convert data from the endian of the server into its own endian when results are received. This conversion is carried out automatically by the MSDR library. Each MSDR object has an associated endian, which it uses to marshal the data in the correct way. The endian of the data on the wire is thus the endian of the interface instance.

The wire representation of MSRPC2 RPC calls can differ according to the protocol being used for communication. For MSNL, the protocol defines two words of header per message. These are as follows:

For TCP, the protocol defines only one word of header per message. The protocol is as follows:



next up previous
Next: About this document Up: MSRPC2 User Manual Previous: Runtime library interface



Simon Crosby and Richard Hayton