Bug 2176

Summary: Building Ipv4 address from char* doesn't look reliable
Product: ns-3 Reporter: Matthieu Coudron <mattator>
Component: internetAssignee: George Riley <riley>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, tommaso.pecorella
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   

Description Matthieu Coudron 2015-09-04 19:17:13 UTC
I forgot a "." when building the string "10.2.0.0" (was doing "10.2.00") and then instead of failing ns3 builded the ip "0.10.2.0".

I think ns3 should either:
- fail in such a case (this is the class constructor)
- or change the API to allow for the conversion to fail and be checked.
Comment 1 Matthieu Coudron 2015-09-04 19:17:56 UTC
Tried to look for a test suite to add my test but could not find it thus the addition of a test suite for that would be nice too.
Comment 2 Tommaso Pecorella 2015-11-07 17:41:11 UTC
I don't think that we need a test case for this.
The constructor now fails with an assert in the following cases:
1) missing a dot (i.e., less than 3 dots),
2) leading dot in the string (e.g., ".1.1.1")
3) trailing dot in the string (e.g., "1.1.1.")

Pushed in changeset:   11754:b3aa90cf76b9
Comment 3 Tommaso Pecorella 2015-11-07 17:48:34 UTC
changeset:   11755:82d8459595ce

Forgot one last case: "1..1.1", as is, the user forgot one number in the middle. Forgetting 2 numbers (3 dots in a row) is included in this one.