NETWORK softmodem.cpp patch for leading zero octet problem

Here you can discuss the development of patches.

NETWORK softmodem.cpp patch for leading zero octet problem

Postby Zorix » 2013-8-25 @ 20:00

Hi everyone.

I was having trouble today with a friend playing Rise of the Triad over modem. The setup.exe modem configuration section would not accept dots or semicolons in the dialer such as: 192.168.1.10:5000. I then tried: 1921680010105000 which dosbox then converted to 192.168.001.010:5000 and would not connect. Testing with Telix confirmed that it works using the dots and semicolon. Only thing I could think of is that the system didn't know how to handle the 0's in the octets. I checked the source code and created a small modification that removed the 0's and tested with success. This was tested on Ubuntu 10.04 and 12.04 with newest SVN release. I have created a diff that you all may find useful. Let me know what you all think about it. Thank you.

Code: Select all
--- softmodem.cpp.original   2013-08-25 15:12:21.757106249 -0400
+++ softmodem.cpp   2013-08-25 15:39:11.505100981 -0400
@@ -385,6 +385,19 @@
                }
                buffer[j] = 0;
                foundstr = buffer;
+               // Remove Zeros from beginning of octets
+               char obuffer[128];
+               Bitu k = 0;
+               for (Bitu i=0; i<strlen(foundstr); i++) {
+                  if (i < 2 && foundstr[i] == 0)
+                     continue;
+                  if (foundstr[i] == '0' && foundstr[i-1] == '.')
+                     continue;
+                  if (foundstr[i] == '0' && foundstr[i-1] == '0' && foundstr[i-2] == '.')
+                     continue;
+                  obuffer[k++] = foundstr[i];
+               }
+               foundstr = obuffer;
             }
          }
          Dial(foundstr);
Zorix
Newbie
 
Posts: 48
Joined: 2004-10-15 @ 03:15
Location: Florida

Re: softmodem.cpp patch for leading zero octet problem

Postby Qbix » 2013-9-12 @ 17:06

moved to patches section so it won't be forgotten
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10523
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: softmodem.cpp patch for leading zero octet problem

Postby Zorix » 2013-9-13 @ 14:31

Thank you.
Zorix
Newbie
 
Posts: 48
Joined: 2004-10-15 @ 03:15
Location: Florida

Re: softmodem.cpp patch for leading zero octet problem

Postby Qbix » 2013-11-06 @ 13:51

I am a bit surprised that this would be needed and wonder if it is needed only on Linux.
Aside from that. I would say that IPs that start with 101 would get translated to 11 , with this patch ? (the first if).
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10523
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: softmodem.cpp patch for leading zero octet problem

Postby Zorix » 2013-11-06 @ 14:58

Hi Qbix,

Thanks for looking at my suggested patch. I found an error with the patch. That whole first if statement is invalid. foundstr[i] == 0 should be foundstr[i] == '0' which does as you expect if it was written right. Turns out that I don't even need that check since the other if's are looking for the period in the octet anyways. However, I did encounter more problems when testing with something such as 012.101.101.001 for example. I adjusted it by adding this check in place of the first if statement:

Code: Select all
                  if (i == 0 && foundstr[i] == '0')
                     continue;
                  if (i == 1 && foundstr[i-1] == '0' && foundstr[i] == '0')
                     continue;


and it now behaves as it should.

Let me know what you think.

Also, this issue was originally encountered between a Windows 7 machine connecting to my Ubuntu 12.04 machine. Since the dialer part was handled on the Windows 7 side initially, this problem seemed to have been an issue there as well. However, during my testing I was using two Ubuntu 12.04 machines. An application such as Telix can be used to test further. However, I don't own any Windows machines, so I couldn't test. But the suggested change wouldn't impact how the Windows machines would function, even if it wasn't affected to begin with.

Thanks.
Last edited by Zorix on 2013-11-06 @ 15:04, edited 1 time in total.
Zorix
Newbie
 
Posts: 48
Joined: 2004-10-15 @ 03:15
Location: Florida

Re: softmodem.cpp patch for leading zero octet problem

Postby Qbix » 2013-11-06 @ 15:03

That was what I had in mind as well.
Thanks for the update
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10523
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: softmodem.cpp patch for leading zero octet problem

Postby Zorix » 2013-11-06 @ 15:05

Thanks Qbix, didn't think you would reply so fast so I edited the last message to clarify my testing scenario.
Zorix
Newbie
 
Posts: 48
Joined: 2004-10-15 @ 03:15
Location: Florida

Re: softmodem.cpp patch for leading zero octet problem

Postby Qbix » 2013-11-11 @ 12:55

I commited a modified version of it in r3843, improving a few things and fixing a few possible bugs (no trailing zero, increasing buffers scope until the dail command).

Please test if it works for you.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10523
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: softmodem.cpp patch for leading zero octet problem

Postby Zorix » 2013-11-11 @ 16:19

I have just compiled it and tested on Ubuntu 12.04 and also with 10.04 and I can confirm that it works perfectly. Thank you for taking the time to address this. I am really pleased.

Zorix
Zorix
Newbie
 
Posts: 48
Joined: 2004-10-15 @ 03:15
Location: Florida


Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest