IP Device driver

Anything QL Software or Programming Related.
Martin_Head
Gold Card
Posts: 436
Joined: Tue Dec 17, 2013 1:17 pm

IP Device driver

Postby Martin_Head » Tue Jul 16, 2019 11:08 am

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 18 times


User avatar
XorA
Super Gold Card
Posts: 593
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: IP Device driver

Postby XorA » Tue Jul 16, 2019 6:44 pm

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
Gold Card
Posts: 436
Joined: Tue Dec 17, 2013 1:17 pm

Re: IP Device driver

Postby Martin_Head » Wed Jul 17, 2019 1:52 pm

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
Aurora
Posts: 781
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Postby NormanDunbar » Wed Jul 17, 2019 10:12 pm

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?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
User avatar
tofro
QL Wafer Drive
Posts: 1667
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: IP Device driver

Postby tofro » Wed Jul 17, 2019 11:26 pm

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
Aurora
Posts: 781
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Postby NormanDunbar » Thu Jul 18, 2019 4:16 pm

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

Cheers,
Norm.


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
User avatar
NormanDunbar
Aurora
Posts: 781
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: IP Device driver

Postby NormanDunbar » Thu Jul 18, 2019 10:01 pm

:D :D :D


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
Martin_Head
Gold Card
Posts: 436
Joined: Tue Dec 17, 2013 1:17 pm

Re: IP Device driver

Postby Martin_Head » Fri Jul 19, 2019 9:28 am

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
Super Gold Card
Posts: 593
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: IP Device driver

Postby XorA » Fri Jul 19, 2019 10:59 am

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!



Who is online

Users browsing this forum: No registered users and 13 guests