dear christian helmuth, Here i attached the client-server program used in genodetoolchain. Basically i'm trying to build a client-server program with encryption facilities. But problem i'm facing here is while sending a string from client to server only the first character in the string is received remaining characters were scrambled.please kindly give some suggestion. Thanking you, with regards, B.Pruthiviraj.
Happy New Year,
On Wed, Dec 28, 2011 at 05:28:02PM +0530, Pruthivi Raj wrote:
Here i attached the client-server program used in genodetoolchain. Basically i'm trying to build a client-server program with encryption facilities. But problem i'm facing here is while sending a string from client to server only the first character in the string is received remaining characters were scrambled.please kindly give some suggestion.
You declared your interface as
virtual char* message(char* m) = 0; /* API */ GENODE_RPC(Rpc_message,char*,message,char*); /* RPC definition */
Then, the Genode RPC framework generates code to transfer _one_ character in the client request and _one_ character in the server response. That is exactly what you saw, but not expected. A rationale can be found here
http://genode.org/documentation/release-notes/11.05#section-4
The reference also states that this behavior is not finalized yet, which indicates we are still looking for the right way to handle these types.
There are two ways to solve your issue depending on your needs. If your API just depends on constant-size messages, you may define a struct for the message payload and use this type
struct Payload { char buf[64]; };
Payload message(Payload) = 0; /* API */ GENODE_RPC(Rpc_message, Payload, message, Payload); /* RPC definition */
This may fit the common Crypto_init, _update, _final cycle. Alternatively, if you intend to send variable-sized messages to the server, Rpc_in_buffer is the tool of choice
#include <base/rpc_args.h>
typedef Rpc_in_buffer<64> String; void message(String) = 0; GENODE_RPC(Rpc_message, String, message);
Unfortunately, Rpc_in_buffer cannot be used for the response currently. The reason is that the RPC framework needs the buffer space to copy the response to before the RPC function returns. But, the function caller does not provide any space and the function just declares the return type. So, for the response you had to use a constant-size type as described above. A good example for string-based RPC is in base/include/log_session/log_session.h.
Regards