The `f_network_from_ip_string()` is incorrectly referencing IPv6 bracket notation.
Make it clear that ports are not supported.
Make it clear that IPv6 bracket notation is not supported.
Clean up the `f_network_from_ip_string()`, removing unnecessary nesting.
if (!from.used || to->type == f_network_family_none_e) return F_data_not;
- {
- const int result = (to->type == f_network_family_ip_4_e)
- ? inet_pton(AF_INET, from.string, (void *) & to->address.v4)
- : inet_pton(AF_INET6, from.string, (void *) & to->address.v6);
+ const int result = (to->type == f_network_family_ip_4_e)
+ ? inet_pton(AF_INET, from.string, (void *) & to->address.v4)
+ : inet_pton(AF_INET6, from.string, (void *) & to->address.v6);
- if (result == -1) {
- if (errno == EAFNOSUPPORT) return F_status_set_error(F_support_not);
+ if (result == -1) {
+ if (errno == EAFNOSUPPORT) return F_status_set_error(F_support_not);
- return F_status_set_error(F_failure);
- }
- else if (result) {
- return F_okay;
- }
+ return F_status_set_error(F_failure);
}
- return F_status_set_error(F_address_not);
+ return result ? F_okay : F_status_set_error(F_address_not);
}
#endif // _di_f_network_from_ip_string_
* Convert from a human-friendly string representing the IP address digit into a network IP address digit.
*
* This is for the IP address and is not for the Domain Name.
+ * This does not get the port number and passed address must neither contain the port number nor IPv6 address brackets.
*
* @param from
- * The human-friendly IP address string.
+ * The human-friendly IP version 4 or version 6 family address string.
+ *
+ * This must be a NULL terminated string.
* @param to
* The converted IP version 4 or version 6 family integer.
- * For IPv6, the use of a port number requires the address to be encases in brackets, like: [::1]:80.
*
* @return
* F_okay on success.
.PP
Convert from a human-friendly string representing the IP address digit into a network IP address digit.
.PP
-This is for the IP address and is not for the Domain Name.
+This is for the IP address and is not for the Domain Name. This does not get the port number and from string must neither contain the port number nor IPv6 address brackets.
.PP
F_address_not (with error bit) if from is not a valid address. F_parameter (with error bit) if a parameter is invalid. F_space_not (with error bit) if not enough space is available in to.string. F_support_not (with error bit) if an invalid address family type is passed to inet_pton(). F_failure (with error bit) on any other error.
.SH PARAMETERS
.TP
.B from
-The human-friendly IP address string.
+The human-friendly IP version 4 or version 6 family address string. This must be a NULL terminated string.
.TP
.B to
-The converted IP version 4 or version 6 family integer. For IPv6, the use of a port number requires the address to be encases in brackets, like: [::1]:80.
+The converted IP version 4 or version 6 family integer.
.SH STRUCTURES
.SS ""