IP Device driver

Anything QL Software or Programming Related.
Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

IP Device driver

Post by Martin_Head »

Now I have a Linux box that I can run UQLX in. I have finally got around to trying my IPBasic extensions in Linux.

I have found quite a few things that don't act as expected, and need to looked into.

But something I have noticed which I am not sure whether it is a bug in either QPC2, or UQLX.
Or something about Windows/Linux.

When I use either IP_GETSOCKNAME$ or IP_GETPEERNAME$. Which returns a SockAddr structure, The 'family' part (a word) value is different.
qpc2.png
uqlx2.png
This is couple of screen dumps from QPC2 and UQLX both running my test program. Note the 'Family' values of 2 and 512. The expected value is 2, but in UQLX it's 512 which is the word value swapped around (big endian/little endian?)

So is this an emulator problem, or an issue with Windows/Linux?

I have also included the test programs. Start two copies of the emulator in one PC, LRESPR IPBasic_cde on each, and run the IPTests(erver) on one, and IPTestc(lient) on the other
Attachments
IPtests.zip
(6.62 KiB) Downloaded 90 times


User avatar
XorA
Site Admin
Posts: 1358
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: IP Device driver

Post by XorA »

32bit or 64bit uQlx, as we know 64bit still has many undiscovered variables issues due to terrible use of C types in the original source code.


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: IP Device driver

Post by Martin_Head »

XorA wrote:32bit or 64bit uQlx, as we know 64bit still has many undiscovered variables issues due to terrible use of C types in the original source code.
Pretty sure it's 32 bit. It's an old (Celeron?) Dell PC running Xubuntu.

I may make a test, and set a flag in IPBasic to indicate that the family value need to be swapped around when this problem happens. Or is it safe to assume that if the first byte of the family value is not zero, then the family value needs to be swapped? So basically is the family value ever going to be greater than 255?


User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Post by NormanDunbar »

Please ignore me if I'm talking bollox, again, but, I did some network programming on Unix and Windows back in the mid 1990s and I seem to remember getting back to front values. Have you neglected to call htons, htonl (host to network short/long) or ntohs/ntohl (network to host short/long) to get the socket address detail in the correct format for the host - big or little endian?

These functions: https://linux.die.net/man/3/htons

It might be ok on Linux or Windows on x86 as they are little endian, but the QL is big endian, and it sounds exactly like the problem I had, back then.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: IP Device driver

Post by tofro »

NormanDunbar wrote:Please ignore me if I'm talking bollox, again, but, I did some network programming on Unix
Norman,

Not bollocks. But 68k is big-endian and network byte order is big endian - ntohx() and htonx() are no-ops on proper CPUs like the 68k, and you only really need to swap stuff around on systems like the PC. Very probably, the missing byte swap is somewhere in the x86 code.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Post by NormanDunbar »

Thanks Tobias. I'll make a note, I wasn't talking bollox! :D

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
RalfR
Aurora
Posts: 870
Joined: Fri Jun 15, 2018 8:58 pm

Re: IP Device driver

Post by RalfR »

Image


4E75 7000
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Post by NormanDunbar »

:D :D :D


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: IP Device driver

Post by Martin_Head »

NormanDunbar wrote:Please ignore me if I'm talking bollox, again, but, I did some network programming on Unix and Windows back in the mid 1990s and I seem to remember getting back to front values. Have you neglected to call htons, htonl (host to network short/long) or ntohs/ntohl (network to host short/long) to get the socket address detail in the correct format for the host - big or little endian?

These functions: https://linux.die.net/man/3/htons

It might be ok on Linux or Windows on x86 as they are little endian, but the QL is big endian, and it sounds exactly like the problem I had, back then.

Cheers,
Norm.
I'm working in the IP device driver in QDOS, which I don't think support hton and ntoh.

And from QDOS it might be tricky trying to figure out what the architecture of the underlying system the emulator is running in.


User avatar
XorA
Site Admin
Posts: 1358
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: IP Device driver

Post by XorA »

Martin_Head wrote:
XorA wrote:32bit or 64bit uQlx, as we know 64bit still has many undiscovered variables issues due to terrible use of C types in the original source code.
Pretty sure it's 32 bit. It's an old (Celeron?) Dell PC running Xubuntu.

I may make a test, and set a flag in IPBasic to indicate that the family value need to be swapped around when this problem happens. Or is it safe to assume that if the first byte of the family value is not zero, then the family value needs to be swapped? So basically is the family value ever going to be greater than 255?
Best thing is if we just fix the uQlx source! We don't want "special" versions just for one emulator when its the easiest one to get fixed! I won't have time probably in the coming couple of weeks but anyone is free to post patch to github!


Post Reply