Closed Bug 25127 Opened 26 years ago Closed 26 years ago

PR_StringToNetaddr for non-Ipv6 platforms

Categories

(NSPR :: NSPR, defect, P3)

All
Windows NT
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: srinivas, Assigned: wtc)

Details

Attachments

(4 files)

PR_StringToNetAddr needs to modified to work on non-Ipv6 platforms for Ipv6 addresses. It is probably better to introduce a new function that accepts an address family parameter. Who wants to work on this?
PR_StringToNetAddr() should work the same on both ipv6 and non-ipv6 platforms. The reason to introduce a new function would be to get inputs like "205.13.41.1" to produce an ipv4 mapped ipv6 function.
I'll take a whack at it.
Assignee: srinivas → jgmyers
Attached file test cases
Status: NEW → ASSIGNED
Attached patch Proposed fixSplinter Review
Reassign for review and checkin
Assignee: jgmyers → srinivas
Status: ASSIGNED → NEW
I'm reviewing jgmyers's patch.
Assignee: srinivas → wtc
Comments on my proposed changes to StringToV6Addr() (attachment 4837 [details] [diff] [review]): 1. Added comments to explain the return value and the two main variables ('section' and 'double_colon') of the function. 2. Check for input that is too long at the beginning of the while loop to also catch the double colon case. The original code fails to catch "1:2:3:4:5:6:7::8". 3. Make sure there are digits between ':' and '.'. The original code parses "::.1.2.3" as a valid string. 4. Stretch the double colon at the end, for trailing v4 format addresses too. Store the v4 address byte by byte.
Per my reading of the draft, a v4 format address is only legal at the end.
jgmyers@netscape.com wrote: > Per my reading of the draft, a v4 format address is > only legal at the end. This is correct. What I meant is that we only need to stretch the double colon at the end of the StringToV6Addr() function. (The original code has two copies of the double colon stretching code.) It is okay to convert the v4 format address first, before stretching the double colon. The v4 format address conversion code already makes sure that the v4 format address is at the end of the string: if (*s) return 0; /* must have exactly 4 decimal numbers */
The only new thing in this patch is to change V6AddrToString to match inet_ntop closer. I also added some comments to aid (my own) understanding. Excellent piece of code you wrote in just one day, John!
You may want to add a comment that double_colon_length is used to select the longest sequence of zeros.
I checked in my proposed changes (attachment 4844 [details] [diff] [review]), plus a comment about double_colon_length that jgmyers suggested. I also added a test program based on jgmyers's test cases (attachment 4591 [details]). Note that this test is not added to the test harness runtests.ksh because the inet_pton() function is broken on Linux and AIX. NSPRPUB_RELEASE_4_0_BRANCH: /cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c, revision 3.11.4.13 /cvsroot/mozilla/nsprpub/pr/tests/addrstr.c, revision 1.1.2.1 (new file) /cvsroot/mozilla/nsprpub/pr/tests/Makefile, revision 3.47.2.2 /cvsroot/mozilla/nsprpub/pr/tests/Makefile.in, revision 1.10.6.1
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
No longer depends on: 344809
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: