Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Cross-Endian Message Passing with IO_MSG: (7 Items)
   
Cross-Endian Message Passing with IO_MSG  
Hi there...

I'd like to use out of band messages (_io_msg) for communication.
Communication is also needed between platforms of different endian-ness.
Of course I need to take care of endianness myself when sending my data, but what about the struct _io_msg ?

It looks as follows:
struct _io_msg {
	_Uint16t					type;
	_Uint16t					combine_len;
	_Uint16t					mgrid;
	_Uint16t					subtype;
};

Obviously, I have to convert those values myself before sending (and after receiving) from/to Network Byte Order. 
Correct?

But how is this usually done? QNX 6.4.0 QNET is supposed to work cross-endian, so even for read, write, devctl, mount, .
.. those values would have to be converted. Are those converted? By whom? The ResMgr Framework? Is this backwards 
compatible when with older Clients/Frameworks? (After all, those don't necessarily use Network Byte Order when sending 
the structs...?)

Greetings,
 Marc
Re: Cross-Endian Message Passing with IO_MSG  
to be a bite more clear: I'm using type "_IO_MSG", but this really does not make any difference..
Re: Cross-Endian Message Passing with IO_MSG  
It is all done in side the resource manager framework.

Basically, when resmgr_attach(), you should set the resmsg_attr.flag to RESMGR_FLAG_CROSS_ENDIAN, this tells the resmgr 
frame work your resource manager is willing to accept cross endian request.

The framework will then swap the message structure if a message is comming from a different endian client.

I think the "mqueue" is cross-endian safe now, so you may take a look of this source.

http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/services/mqueue/?root=coreos_pub&system=exsy1001

Re: Cross-Endian Message Passing with IO_MSG  
Hi,

on the resource manager side, yes.. but on the client side there is no framework, so I do (straight from the QNX Course 
material):

msg.hdr.type = _IO_MSG;
....
MsgSend(fd, &msg, sizeof(msg), &reply, sizeof(reply));

Do I need to change this to network byte order myself?
And how does the ResMgr know that the application has different endianness? Do I need to tell this to the ResMgr somehow
 or is this handled by QNet?

Thanks & Greetings,
 Marc

P.S.: Can't access the URL, says "Could not authenticate user for SCM viewer" despite being logged in.. any other way to
 access this?
RE: Cross-Endian Message Passing with IO_MSG  
The client side should be just as usual. Everything suppose to be done
in server (resource manager) side. Please note this also means when you
"reply", you also need to swap your own data if the request is coming
from a cross-endian client. 

As a resource manager you know a request comes from cross endian client
by testing

	if (ctp->info.flags & _NTO_MI_ENDIAN_DIFF)

The client does not need to do anything, the under layer QNET would know
a message is come from a same-endian/cross-endian machine, and pass this
information through.

-xtang

> -----Original Message-----
> From: Marc Roessler [mailto:community-noreply@qnx.com] 
> Sent: Tuesday, February 24, 2009 7:49 AM
> To: ostech-core_os
> Subject: Re: Cross-Endian Message Passing with IO_MSG
> 
> Hi,
> 
> on the resource manager side, yes.. but on the client side 
> there is no framework, so I do (straight from the QNX Course 
> material):
> 
> msg.hdr.type = _IO_MSG;
> ....
> MsgSend(fd, &msg, sizeof(msg), &reply, sizeof(reply));
> 
> Do I need to change this to network byte order myself?
> And how does the ResMgr know that the application has 
> different endianness? Do I need to tell this to the ResMgr 
> somehow or is this handled by QNet?
> 
> Thanks & Greetings,
>  Marc
> 
> P.S.: Can't access the URL, says "Could not authenticate user 
> for SCM viewer" despite being logged in.. any other way to 
> access this?
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post22804
> 
> 
Re: RE: Cross-Endian Message Passing with IO_MSG  
hmm.. I'm just wondering why this flag is port of the ctb, shouldn't it be part of the ocb?
(i.e. per-open()-basis)?
Re: RE: Cross-Endian Message Passing with IO_MSG  
> hmm.. I'm just wondering why this flag is port of the ctb, shouldn't it be 
> part of the ocb?
> (i.e. per-open()-basis)?

I assume you are talking aout "_NTO_MI_ENDIAN_DIFF" flag?

ctp->info is actually the "recvinfo" you get from a MsgReceive(). This flag is actually filled in by kernel during a 
message pass.

The flag is not open/ocb based, because we don't want to limit that information only for resource manager.