You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/06/30 02:07:14 UTC

[incubator-nuttx-apps] branch master updated (7650a3c -> 8750db6)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git.


    from 7650a3c  make/import: override the ld group if undeclared
     new 24407f1  net/sockopt: change the socket option style from Linux to BSD
     new 8750db6  examples: fix nxstyle warning

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 examples/mld/mld_main.c    | 12 +++++++-----
 examples/netloop/lo_main.c | 23 +++++++++++++++--------
 netutils/dhcpc/dhcpc.c     |  2 +-
 3 files changed, 23 insertions(+), 14 deletions(-)


[incubator-nuttx-apps] 01/02: net/sockopt: change the socket option style from Linux to BSD

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 24407f16f5e548bc8dbf223b42fb5f9d7fb4ec68
Author: chao.an <an...@xiaomi.com>
AuthorDate: Mon Jun 29 14:14:42 2020 +0800

    net/sockopt: change the socket option style from Linux to BSD
    
    Linux Programmer's Manual
    ...
    IP(7)
    ...
    NOTES
    ...
        Using the SOL_IP socket options level isn't portable;
        BSD-based stacks use the IPPROTO_IP level.
    
    Change-Id: I143477d8884dd44913c5685028ee62854e4c11ac
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 examples/mld/mld_main.c    | 4 ++--
 examples/netloop/lo_main.c | 6 +++---
 netutils/dhcpc/dhcpc.c     | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/examples/mld/mld_main.c b/examples/mld/mld_main.c
index e27a268..59b7bbd 100644
--- a/examples/mld/mld_main.c
+++ b/examples/mld/mld_main.c
@@ -335,7 +335,7 @@ int main(int argc, FAR char *argv[])
   memcpy(mrec.ipv6mr_multiaddr.s6_addr16, g_grp_addr, sizeof(struct in6_addr));
   mrec.ipv6mr_interface = if_nametoindex("eth0");
 
-  ret = setsockopt(sockfd, SOL_IPV6, IPV6_JOIN_GROUP, (FAR void *)&mrec,
+  ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (FAR void *)&mrec,
                    sizeof(struct ipv6_mreq));
   if (ret < 0)
     {
@@ -438,7 +438,7 @@ int main(int argc, FAR char *argv[])
   /* Leave the group */
 
   printf("Leave group...\n");
-  ret = setsockopt(sockfd, SOL_IPV6, IPV6_LEAVE_GROUP, (FAR void *)&mrec,
+  ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (FAR void *)&mrec,
                    sizeof(struct ipv6_mreq));
   if (ret < 0)
     {
diff --git a/examples/netloop/lo_main.c b/examples/netloop/lo_main.c
index 1c25c36..8ad45bf 100644
--- a/examples/netloop/lo_main.c
+++ b/examples/netloop/lo_main.c
@@ -114,7 +114,7 @@ static int lo_client(void)
   tv.tv_sec  = 5;
   tv.tv_usec = 0;
 
-  ret = setsockopt(sockfd, SOL_TCP, TCP_KEEPIDLE, &tv, sizeof(struct timeval));
+  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, &tv, sizeof(struct timeval));
   if (ret < 0)
     {
       ret = -errno;
@@ -125,7 +125,7 @@ static int lo_client(void)
   tv.tv_sec  = 1;
   tv.tv_usec = 0;
 
-  ret = setsockopt(sockfd, SOL_TCP, TCP_KEEPINTVL, &tv, sizeof(struct timeval));
+  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL, &tv, sizeof(struct timeval));
   if (ret < 0)
     {
       ret = -errno;
@@ -134,7 +134,7 @@ static int lo_client(void)
     }
 
   value = 3;
-  ret = setsockopt(sockfd, SOL_TCP, TCP_KEEPCNT, &value, sizeof(int));
+  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPCNT, &value, sizeof(int));
   if (ret < 0)
     {
       ret = -errno;
diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c
index 083187e..61afcf2 100644
--- a/netutils/dhcpc/dhcpc.c
+++ b/netutils/dhcpc/dhcpc.c
@@ -467,7 +467,7 @@ FAR void *dhcpc_open(FAR const char *interface, FAR const void *macaddr,
        * by definition and purpose of DHCP, undefined yet).
        */
 
-      ret = setsockopt(pdhcpc->sockfd, SOL_UDP, UDP_BINDTODEVICE,
+      ret = setsockopt(pdhcpc->sockfd, IPPROTO_UDP, UDP_BINDTODEVICE,
                        pdhcpc->interface, strlen(pdhcpc->interface));
       if (ret < 0)
         {


[incubator-nuttx-apps] 02/02: examples: fix nxstyle warning

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 8750db6090e9879d748bfc182179b3bdc9ef9209
Author: chao.an <an...@xiaomi.com>
AuthorDate: Mon Jun 29 14:23:56 2020 +0800

    examples: fix nxstyle warning
    
    Change-Id: I617d9033604a4a85ae065ed67b9aa6128218ae49
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 examples/mld/mld_main.c    |  8 +++++---
 examples/netloop/lo_main.c | 21 ++++++++++++++-------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/examples/mld/mld_main.c b/examples/mld/mld_main.c
index 59b7bbd..8bac0b4 100644
--- a/examples/mld/mld_main.c
+++ b/examples/mld/mld_main.c
@@ -189,7 +189,7 @@ void mld_catfile(FAR const char *filepath, FAR char **iobuffer)
 
   /* And just dump it byte for byte into stdout */
 
-  for (;;)
+  for (; ; )
     {
       ssize_t nbytesread = read(fd, *iobuffer, IOBUFFERSIZE);
 
@@ -332,7 +332,8 @@ int main(int argc, FAR char *argv[])
   printf("Join group...\n");
   mld_dumpstats(&iobuffer);
 
-  memcpy(mrec.ipv6mr_multiaddr.s6_addr16, g_grp_addr, sizeof(struct in6_addr));
+  memcpy(mrec.ipv6mr_multiaddr.s6_addr16,
+         g_grp_addr, sizeof(struct in6_addr));
   mrec.ipv6mr_interface = if_nametoindex("eth0");
 
   ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (FAR void *)&mrec,
@@ -411,7 +412,8 @@ int main(int argc, FAR char *argv[])
       /* Send a garbage packet */
 
       ret = sendto(sockfd, g_garbage, sizeof(g_garbage), 0,
-                   (FAR struct sockaddr *)&target, sizeof(struct sockaddr_in6));
+                   (FAR struct sockaddr *)&target,
+                   sizeof(struct sockaddr_in6));
       if (ret < 0)
         {
           fprintf(stderr, "ERROR: sendto() failed: %d\n", errno);
diff --git a/examples/netloop/lo_main.c b/examples/netloop/lo_main.c
index 8ad45bf..6d69692 100644
--- a/examples/netloop/lo_main.c
+++ b/examples/netloop/lo_main.c
@@ -114,7 +114,8 @@ static int lo_client(void)
   tv.tv_sec  = 5;
   tv.tv_usec = 0;
 
-  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, &tv, sizeof(struct timeval));
+  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
+                   &tv, sizeof(struct timeval));
   if (ret < 0)
     {
       ret = -errno;
@@ -125,7 +126,8 @@ static int lo_client(void)
   tv.tv_sec  = 1;
   tv.tv_usec = 0;
 
-  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL, &tv, sizeof(struct timeval));
+  ret = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
+                   &tv, sizeof(struct timeval));
   if (ret < 0)
     {
       ret = -errno;
@@ -149,8 +151,10 @@ static int lo_client(void)
   myaddr.sin_port        = htons(LISTENER_PORT);
   myaddr.sin_addr.s_addr = htonl(LO_ADDRESS);
 
-  printf("lo_client: Connecting to %08x:%d...\n", LO_ADDRESS, LISTENER_PORT);
-  if (connect( sockfd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0)
+  printf("lo_client: Connecting to %08x:%d...\n",
+         LO_ADDRESS, LISTENER_PORT);
+  if (connect(sockfd,
+              (struct sockaddr *)&myaddr, sizeof(struct sockaddr_in)) < 0)
     {
       ret = -errno;
       printf("lo_client: connect failure: %d\n", ret);
@@ -179,7 +183,8 @@ static int lo_client(void)
       else if (nbytessent != len)
         {
           ret = -EINVAL;
-          printf("lo_client: Bad send length: %d Expected: %d\n", nbytessent, len);
+          printf("lo_client: Bad send length: %d Expected: %d\n",
+                 nbytessent, len);
           goto errout_with_socket;
         }
 
@@ -205,7 +210,8 @@ static int lo_client(void)
       if (nbytesrecvd != len)
         {
           ret = -EINVAL;
-          printf("lo_client: Bad recv length: %d Expected: %d\n", nbytesrecvd, len);
+          printf("lo_client: Bad recv length: %d Expected: %d\n",
+                 nbytesrecvd, len);
           goto errout_with_socket;
         }
       else if (memcmp(inbuf, outbuf, len) != 0)
@@ -216,7 +222,8 @@ static int lo_client(void)
         }
 
 #ifdef CONFIG_EXAMPLES_NETLOOP_KEEPALIVE
-      /* Send four messages, then wait a longer amount of time ... longer than
+      /* Send four messages, then wait a longer amount of time ...
+       * longer than:
        * TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT = 5 + 3 * 1 = 8 seconds.
        */