On Thu, Sep 24, 2015 at 3:02 AM, Patrik Flykt <[email protected]>
wrote:
> On Thu, 2015-09-24 at 11:14 +0300, Patrik Flykt wrote:
> > > +
> > > + if (ret) {
> > > + connman_error("cannot get the server info");
> > > + return -1;
> > > + }
> > > +
> > > + family = info->ai_family;
> > > + if (family == AF_INET) {
> > > + if (inet_pton(family, server, &(((struct sockaddr_in
> *)×erver_addr)->sin_addr.s_addr)) == 0) {
> > > + connman_error("cannot convert ip address
> string");
> > > + return -1;
> > > + }
> > > + } else if (family == AF_INET6) {
> > > + if (inet_pton(family, server, ((struct sockaddr_in6
> *)×erver_addr)->sin6_addr.__in6_u.__u6_addr8) == 0) {
> > > + connman_error("cannot convert ipv6 address
> string");
> > > + return -1;
> > > + }
> > > + } else {
> > > + connman_error("Neither IPv4 nor IPv6 type");
> > > + return -1;
> >
> > This check has already happened in src/service.c, set_property() and
> > thus need not be re-done here. It is not done in src/clock.c
> > set_property(), neither for the main.conf FallbackTimeservers, so those
> > parts need a new patch each.
>
> Let me correct my comment above. Timeservers can also be specified using
> host names, so no IP address checks need to be done in the above places.
>
> src/timeservers.c has the code to figure out whether name resolution is
> needed or whether the given name is an IP address. So
> __connman_ntp_start() can therefore always expect to get either an IPv4
> or an IPv6 address.
>
Isn't the IPv4 or IPv6 address passed as an argument to __connman_ntp_start
a character array? We would still need to convert this character array to
the IP addresses and for that we would need to know the family. Do you
think there is any other way to do this without using inet_pton (which
requires the family knowledge). Let me know.
>
> Cheers,
>
> Patrik
>
> _______________________________________________
> connman mailing list
> [email protected]
> https://lists.connman.net/mailman/listinfo/connman
>
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman