nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #664: Dns the dual stack support(part 2)
Date Tue, 31 Mar 2020 10:29:01 GMT
xiaoxiang781216 commented on a change in pull request #664: Dns the dual stack support(part
2)
URL: https://github.com/apache/incubator-nuttx/pull/664#discussion_r400806446
 
 

 ##########
 File path: include/netdb.h
 ##########
 @@ -184,14 +184,17 @@ struct hostent
   FAR char **h_aliases;    /* A pointer to an array of pointers to the
                             * alternative host names, terminated by a
                             * null pointer. */
-  int        h_addrtype;   /* Address type. */
-  int        h_length;     /* The length, in bytes, of the address. */
+  FAR int   *h_addrtypes;  /* A pointer to an array of address type. */
+  FAR int   *h_lengths;    /* A pointer to an array of the length, in bytes,
+                            * of the address. */
   FAR char **h_addr_list;  /* A pointer to an array of pointers to network
                             * addresses (in network byte order) for the host,
                             * terminated by a null pointer. */
 };
 
 #define h_addr h_addr_list[0] /* For backward compatibility */
+#define h_length h_lengths[0]
+#define h_addrtype h_addrtypes[0]
 
 Review comment:
   > i'm afraid that changing a structure which is a part of standard api this way.
   
   It's hard to return both IPv4 and IPv6 in one hostent, since hostent has only one h_addrtype/h_length
field. The modification extend h_addrtype/h_length to array by following h_addr_list/h_addr
design pattern, and provide macro to keep the backward  compatibility. The most caller work
fine with the new struct and macro.
   
   To keep the compatibility, caller shouldn't directly touch  h_lengths/h_addrtypes fields,
they must call the new getaddrinfo/freeaddrinfo API instead, like this:
   https://github.com/apache/incubator-nuttx-apps/pull/151
   https://github.com/apache/incubator-nuttx-apps/pull/153
   
   The array extension is used internally to support getaddrinfo:
   https://github.com/apache/incubator-nuttx/pull/664/files#diff-cf02c526db0b2c6580f921a4083b5ce8R290
   
   This method is simplest approach with some backword compatibility what I can think.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message