diff options
Diffstat (limited to 'apps/netutils')
-rw-r--r-- | apps/netutils/ftpc/ftpc_connect.c | 18 | ||||
-rw-r--r-- | apps/netutils/ftpc/ftpc_socket.c | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/apps/netutils/ftpc/ftpc_connect.c b/apps/netutils/ftpc/ftpc_connect.c index ff19af324..ccd68cb03 100644 --- a/apps/netutils/ftpc/ftpc_connect.c +++ b/apps/netutils/ftpc/ftpc_connect.c @@ -98,9 +98,19 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server) /* Initialize the session structure */ session->addr.s_addr = server->addr.s_addr; - session->port = server->port ? server->port : CONFIG_FTP_DEFPORT; session->pid = getpid(); + /* Use the default port if the user specified port number zero */ + + if (!server->port) + { + session->port = HTONS(CONFIG_FTP_DEFPORT); + } + else + { + session->port = htons(server->port); + } + /* Create up a timer to prevent hangs */ session->wdog = wd_create(); @@ -165,7 +175,7 @@ int ftpc_reconnect(FAR struct ftpc_session_s *session) #ifdef CONFIG_DEBUG tmp = inet_ntoa(session->addr); - ndbg("Connecting to server address %s:%d\n", tmp, ntohl(session->port)); + ndbg("Connecting to server address %s:%d\n", tmp, ntohs(session->port)); #endif addr.sin_family = AF_INET; @@ -211,9 +221,9 @@ int ftpc_reconnect(FAR struct ftpc_session_s *session) #ifdef CONFIG_DEBUG ndbg("Connected\n"); tmp = inet_ntoa(session->cmd.raddr.sin_addr); - ndbg(" Remote address: %s:%d\n", tmp, ntohl(session->cmd.raddr.sin_port)); + ndbg(" Remote address: %s:%d\n", tmp, ntohs(session->cmd.raddr.sin_port)); tmp = inet_ntoa(session->cmd.laddr.sin_addr); - ndbg(" Local address: %s:d\n", tmp, ntohl(session->cmd.laddr.sin_port)); + ndbg(" Local address: %s:d\n", tmp, ntohs(session->cmd.laddr.sin_port)); #endif return OK; diff --git a/apps/netutils/ftpc/ftpc_socket.c b/apps/netutils/ftpc/ftpc_socket.c index 500f20995..a77481403 100644 --- a/apps/netutils/ftpc/ftpc_socket.c +++ b/apps/netutils/ftpc/ftpc_socket.c @@ -377,10 +377,10 @@ int ftpc_sockprintf(struct ftpc_socket_s *sock, const char *str, ...) int ftpc_sockgetsockname(FAR struct ftpc_socket_s *sock, FAR struct sockaddr_in *addr) { - unsigned int len = sizeof(struct sockaddr_in); + socklen_t len = sizeof(struct sockaddr_in); int ret; - ret = getsockname(sock->sd, (struct sockaddr *)addr, &len); + ret = getsockname(sock->sd, (FAR struct sockaddr *)addr, &len); if (ret < 0) { ndbg("getsockname failed: %d\n", errno); |