Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running ohNet on a PowerPC machine
19-01-2013, 12:26 PM
Post: #11
RE: Running ohNet on a PowerPC machine
(17-01-2013 12:03 PM)simonc Wrote:  Thanks, that'd be great. In case you haven't spotted it, Os.h contains a macro SwapEndian32() which might be useful here (if you continue to treat TIpAddress as an int; alternatives like converting it to a byte array may be preferable).

I think there's a similar problem in Posix/Os.c. In the following lines:

line 600: aAddr->sin_port = SwapEndian16(aPort);
line 669: uint16_t port = SwapEndian16(addr.sin_port);
line 806: *aPort = SwapEndian16(addr.sin_port);
line 896: *aClientPort = SwapEndian16(addr.sin_port);

the endian swapping is only correct on a little-endian machine. On a big-endian machine, the bytes should not be swapped.

This is confirmed by the following code in Volkano2/Os.c:

line 575: *aPort = (uint32_t) (ntohs(s.sin_port));
line 709: *aPort = ntohs(s.sin_port);

These lines correspond to lines 669 and 806 in Posix/Os.c, and they use the ntohs function. This will swap the bytes on a little-endian machine, but not on a big-endian machine.

I think this is why MinimServer isn't discoverable on a PowerPC Linux machine. The endianness problems in the Java bindings would cause Java code to malfunction, but they wouldn't cause ohNet to fail to respond to discovery messages. This Os.c problem with the port number would cause ohNet not to be discoverable because it's listening on the wrong port.

There's a similar assumption of little-endianness in Windows/Os.c. I think this is OK, as it's my understanding that Windows is (and always will be) limited to little-endian machines.
Find all posts by this user
19-01-2013, 06:41 PM
Post: #12
RE: Running ohNet on a PowerPC machine
(19-01-2013 12:26 PM)simoncn Wrote:  I think there's a similar problem in Posix/Os.c. In the following lines:

line 600: aAddr->sin_port = SwapEndian16(aPort);
line 669: uint16_t port = SwapEndian16(addr.sin_port);
line 806: *aPort = SwapEndian16(addr.sin_port);
line 896: *aClientPort = SwapEndian16(addr.sin_port);

Good spot. I'll try to fix this on Monday.
Find all posts by this user
19-01-2013, 08:23 PM (This post was last modified: 19-01-2013 10:18 PM by simoncn.)
Post: #13
RE: Running ohNet on a PowerPC machine
(19-01-2013 06:41 PM)simonc Wrote:  
(19-01-2013 12:26 PM)simoncn Wrote:  I think there's a similar problem in Posix/Os.c. In the following lines:

line 600: aAddr->sin_port = SwapEndian16(aPort);
line 669: uint16_t port = SwapEndian16(addr.sin_port);
line 806: *aPort = SwapEndian16(addr.sin_port);
line 896: *aClientPort = SwapEndian16(addr.sin_port);

Good spot. I'll try to fix this on Monday.

I've built a test version with these SwapEndian16 replaced by ntohs and htons as appropriate (as well as the Java binding fixes). I'm testing it now, but I've run into a different problem. More news later....

Edit: I've tracked down the other problem. See this thread.
Find all posts by this user
20-01-2013, 09:22 PM
Post: #14
RE: Running ohNet on a PowerPC machine
I'm attaching a patch to fix the endianness problems in the Java bindings and Os/Posix/Os.c. I've tested this on Intel and ARM machines (Linux and Windows). I've also built it for PowerPC Linux and sent this to two users for testing, with no feedback yet.

This patch leaves the signatures of the Java bindings APIs unchanged. It may require changes to Java application code that uses the following APIs:

DvInvocation.java and IDvInvocation.java:
int getAdapter()
int getClientAddress()

The return values from both these methods are now in network byte order.

IResourceManager.java:
void writeResource(String aUriTail, int aIpAddress, List<String> aLanguageList, IResourceWriter aWriter)

The aIpAddress parameter is now in network byte order.

This patch was created from code that had already had the debuglog.zip patch applied. It should be applied after the debuglog.zip patch to ensure matching line numbers.


Attached File(s)
.zip  endian.zip (Size: 2.18 KB / Downloads: 1)
Find all posts by this user
21-01-2013, 05:13 PM
Post: #15
RE: Running ohNet on a PowerPC machine
(20-01-2013 09:22 PM)simoncn Wrote:  I'm attaching a patch to fix the endianness problems in the Java bindings and Os/Posix/Os.c. I've tested this on Intel and ARM machines (Linux and Windows). I've also built it for PowerPC Linux and sent this to two users for testing, with no feedback yet.

Many thanks for this! The code should be available on github now.
Find all posts by this user
22-01-2013, 08:54 AM
Post: #16
RE: Running ohNet on a PowerPC machine
(21-01-2013 05:13 PM)simonc Wrote:  Many thanks for this! The code should be available on github now.

I see the code there, but I don't see a tag containing the changes. I'm not sure how and when tags are created. It normally seems to happen whenever there are new commits. I'd prefer to download a tag rather than just taking a snapshot of the master branch. Many thanks!
Find all posts by this user
22-01-2013, 09:04 AM
Post: #17
RE: Running ohNet on a PowerPC machine
(22-01-2013 08:54 AM)simoncn Wrote:  
(21-01-2013 05:13 PM)simonc Wrote:  Many thanks for this! The code should be available on github now.

I see the code there, but I don't see a tag containing the changes. I'm not sure how and when tags are created. It normally seems to happen whenever there are new commits. I'd prefer to download a tag rather than just taking a snapshot of the master branch. Many thanks!

The tags are created as part of our automated build/test/publish process. We were having some problems with this yesterday (the sheeva plug used for Linux ARM testing was hanging) so I manually pushed the code. I'm out of the office today so it'll be tomorrow before I can properly resolve this.
Find all posts by this user
22-01-2013, 09:27 AM
Post: #18
RE: Running ohNet on a PowerPC machine
(22-01-2013 09:04 AM)simonc Wrote:  The tags are created as part of our automated build/test/publish process. We were having some problems with this yesterday (the sheeva plug used for Linux ARM testing was hanging) so I manually pushed the code. I'm out of the office today so it'll be tomorrow before I can properly resolve this.

OK, thanks. I'll use the snapshot download until this is resolved.
Find all posts by this user


Forum Jump: