From 36118a1b761c5d285a6f0c4392084f1404d23234 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 16 Jan 2015 12:30:18 -0600 Subject: [PATCH] Networking: Replace all references to net_ipaddr_t with either in_addr_t on net_ipv6addr_t. The goal is to support both IPv4 and IPv6 simultaneously. This requires that the two types be distinct and not conditionally typedef'ed to net_ipaddr_t. --- include/netutils/smtp.h | 4 ++-- netutils/smtp/smtp.c | 9 +++++---- nshlib/nsh_netcmds.c | 22 ++++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/netutils/smtp.h b/include/netutils/smtp.h index 2ca7f1e8c..684864c44 100644 --- a/include/netutils/smtp.h +++ b/include/netutils/smtp.h @@ -2,7 +2,7 @@ * apps/include/netutils/smtp.h * SMTP header file * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Heavily leveraged from uIP 1.0 which also has a BSD-like license: @@ -69,7 +69,7 @@ extern "C" void *smtp_open(void); void smtp_configure(FAR void *handle, FAR const char *localhostname, - FAR const net_ipaddr_t *paddr); + FAR const in_addr_t *paddr); int smtp_send(FAR void *handle, FAR const char *to, FAR const char *cc, FAR const char *from, FAR const char *subject, FAR const char *msg, int msglen); diff --git a/netutils/smtp/smtp.c b/netutils/smtp/smtp.c index 095a1c495..f33183ff6 100644 --- a/netutils/smtp/smtp.c +++ b/netutils/smtp/smtp.c @@ -2,7 +2,7 @@ * apps/netutitls/smtp/smtp.c * smtp SMTP E-mail sender * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Heavily leveraged from uIP 1.0 which also has a BSD-like license: @@ -63,7 +63,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define SMTP_INPUT_BUFFER_SIZE 512 @@ -89,7 +89,7 @@ struct smtp_state uint8_t state; bool connected; sem_t sem; - net_ipaddr_t smtpserver; + in_addr_t smtpserver; const char *localhostname; const char *to; const char *cc; @@ -286,7 +286,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp) */ void smtp_configure(FAR void *handle, FAR const char *lhostname, - FAR const net_ipaddr_t *paddr) + FAR const in_addr_t *paddr) { FAR struct smtp_state *psmtp = (FAR struct smtp_state *)handle; psmtp->localhostname = lhostname; @@ -364,6 +364,7 @@ void *smtp_open(void) memset(psmtp, 0, sizeof(struct smtp_state)); (void)sem_init(&psmtp->sem, 0, 0); } + return (void*)psmtp; } diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index 798879b55..7b902f9b5 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -455,6 +455,7 @@ int tftpc_parseargs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv, { goto errout; } + args->allocated = true; } @@ -797,8 +798,9 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) handle = dhcpc_open(&mac, IFHWADDRLEN); - /* Get an IP address. Note that there is no logic for renewing the IP address in this - * example. The address should be renewed in ds.lease_time/2 seconds. + /* Get an IP address. Note that there is no logic for renewing the IP + * address in this example. The address should be renewed in + * ds.lease_time/2 seconds. */ if (handle) @@ -843,7 +845,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR const char *fmt = g_fmtarginvalid; const char *staddr; - net_ipaddr_t ipaddr; + in_addr_t ipaddr; uint32_t start; uint32_t next; uint32_t dsec = 10; @@ -899,7 +901,9 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, then return without processing the + * command + */ if (badarg) { @@ -931,8 +935,8 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) id = ping_newid(); - /* The maximum wait for a response will be the larger of the inter-ping time and - * the configured maximum round-trip time. + /* The maximum wait for a response will be the larger of the inter-ping + * time and the configured maximum round-trip time. */ maxwait = MAX(dsec, CONFIG_NSH_MAX_ROUNDTRIP); @@ -960,7 +964,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { /* Get the elapsed time from the time that the request was * sent until the response was received. If we got a response - * to an earlier request, then fudge the elpased time. + * to an earlier request, then fudge the elapsed time. */ elapsed = TICK2MSEC(clock_systimer() - next); @@ -1091,7 +1095,9 @@ int cmd_wget(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, then return without processing the + * command + */ if (badarg) {