Misc fixes for ZDS compile/build

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1451 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-12-12 18:01:25 +00:00
parent a51a122fb8
commit 703a3b1e88
17 changed files with 264 additions and 229 deletions
+10 -4
View File
@@ -45,6 +45,7 @@ typedef unsigned int uint32;
typedef unsigned char boolean; typedef unsigned char boolean;
# define HTONS(a) htons(a) # define HTONS(a) htons(a)
# define HTONL(a) htonl(a) # define HTONL(a) htonl(a)
# define CONFIG_CPP_HAVE_WARNING 1
# define dbg(...) printf(__VA_ARGS__) # define dbg(...) printf(__VA_ARGS__)
# define vdbg(...) printf(__VA_ARGS__) # define vdbg(...) printf(__VA_ARGS__)
# define TRUE (1) # define TRUE (1)
@@ -54,6 +55,7 @@ typedef unsigned char boolean;
#else #else
# include <nuttx/config.h> # include <nuttx/config.h>
# include <debug.h> # include <debug.h>
# include <nuttx/compiler.h>
# include <net/uip/dhcpd.h> # include <net/uip/dhcpd.h>
#endif #endif
@@ -389,8 +391,10 @@ in_addr_t dhcpd_allocipaddr(void)
lease = dhcpd_findbyipaddr(ipaddr); lease = dhcpd_findbyipaddr(ipaddr);
if ((!lease || dhcpd_leaseexpired(lease))) if ((!lease || dhcpd_leaseexpired(lease)))
{ {
#warning "FIXME: Should check if anything responds to an ARP request or ping" #ifdef CONFIG_CPP_HAVE_WARNING
#warning " to verify that there is no other user of this IP address" # warning "FIXME: Should check if anything responds to an ARP request or ping"
# warning " to verify that there is no other user of this IP address"
#endif
memset(g_state.ds_leases[ipaddr - CONFIG_NETUTILS_DHCPD_STARTIP].mac, 0, DHCP_HLEN_ETHERNET); memset(g_state.ds_leases[ipaddr - CONFIG_NETUTILS_DHCPD_STARTIP].mac, 0, DHCP_HLEN_ETHERNET);
g_state.ds_leases[ipaddr - CONFIG_NETUTILS_DHCPD_STARTIP].allocated = TRUE; g_state.ds_leases[ipaddr - CONFIG_NETUTILS_DHCPD_STARTIP].allocated = TRUE;
#ifdef HAVE_LEASE_TIME #ifdef HAVE_LEASE_TIME
@@ -412,7 +416,7 @@ static inline boolean dhcpd_parseoptions(void)
uint8 *ptr; uint8 *ptr;
uint8 overloaded; uint8 overloaded;
uint8 currfield; uint8 currfield;
int optlen; int optlen = 0;
int remaining; int remaining;
/* Verify that the option field starts with a valid magic number */ /* Verify that the option field starts with a valid magic number */
@@ -775,6 +779,8 @@ static inline int dhcpd_openresponder(void)
static void dhcpd_initpacket(uint8 mtype) static void dhcpd_initpacket(uint8 mtype)
{ {
uint32 nulladdr = 0;
/* Set up the generic parts of the DHCP server message */ /* Set up the generic parts of the DHCP server message */
memset(&g_state.ds_outpacket, 0, sizeof(struct dhcpmsg_s)); memset(&g_state.ds_outpacket, 0, sizeof(struct dhcpmsg_s));
@@ -786,7 +792,7 @@ static void dhcpd_initpacket(uint8 mtype)
memcpy(&g_state.ds_outpacket.xid, &g_state.ds_inpacket.xid, 4); memcpy(&g_state.ds_outpacket.xid, &g_state.ds_inpacket.xid, 4);
memcpy(g_state.ds_outpacket.chaddr, g_state.ds_inpacket.chaddr, 16); memcpy(g_state.ds_outpacket.chaddr, g_state.ds_inpacket.chaddr, 16);
if (g_state.ds_outpacket.giaddr) if (memcmp(g_state.ds_outpacket.giaddr, &nulladdr, 4) != 0)
{ {
g_state.ds_outpacket.flags = g_state.ds_inpacket.flags; g_state.ds_outpacket.flags = g_state.ds_inpacket.flags;
} }
+9 -5
View File
@@ -344,15 +344,16 @@ int recv_response(struct sockaddr_in *addr)
/* Get the binding for name. */ /* Get the binding for name. */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
int resolv_query(const char *name, struct sockaddr_in6 *addr) int resolv_query(FAR const char *name, FAR struct sockaddr_in6 *addr)
#else #else
int resolv_query(const char *name, struct sockaddr_in *addr) int resolv_query(FAR const char *name, FAR struct sockaddr_in *addr)
#endif #endif
{ {
int retries; int retries;
int ret; int ret;
// Loop while receive timeout errors occur and there are remaining retries /* Loop while receive timeout errors occur and there are remaining retries */
for (retries = 0; retries < 3; retries++) for (retries = 0; retries < 3; retries++)
{ {
if (send_query(name, addr) < 0) if (send_query(name, addr) < 0)
@@ -364,16 +365,19 @@ int resolv_query(const char *name, struct sockaddr_in *addr)
if (ret >= 0) if (ret >= 0)
{ {
/* Response received successfully */ /* Response received successfully */
return OK; return OK;
} }
else if (*get_errno_ptr() != EAGAIN) else if (errno != EAGAIN)
{ {
/* Some failure other than receive timeout occurred */ /* Some failure other than receive timeout occurred */
return ERROR; return ERROR;
} }
} }
return ret;
return ERROR;
} }
/* Obtain the currently configured DNS server. */ /* Obtain the currently configured DNS server. */
+1 -2
View File
@@ -350,7 +350,6 @@ static void *telnetd_handler(void *arg)
if (pstate) if (pstate)
{ {
/* Initialize the thread state structure */ /* Initialize the thread state structure */
memset(pstate, 0, sizeof(struct telnetd_s)); memset(pstate, 0, sizeof(struct telnetd_s));
@@ -389,7 +388,7 @@ static void *telnetd_handler(void *arg)
dbg("[%d] Exitting\n", sockfd); dbg("[%d] Exitting\n", sockfd);
close(sockfd); close(sockfd);
pthread_exit(NULL); return NULL;
} }
/**************************************************************************** /****************************************************************************
+4 -1
View File
@@ -42,6 +42,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <nuttx/compiler.h>
#include <net/uip/uipopt.h> #include <net/uip/uipopt.h>
/**************************************************************************** /****************************************************************************
@@ -88,7 +89,9 @@
#if UIP_UDP_MSS < TFTP_MAXPACKETSIZE #if UIP_UDP_MSS < TFTP_MAXPACKETSIZE
# define TFTP_PACKETSIZE UIP_UDP_MSS # define TFTP_PACKETSIZE UIP_UDP_MSS
# warning "uIP MSS is too small for TFTP" # ifdef CONFIG_CPP_HAVE_WARNING
# warning "uIP MSS is too small for TFTP"
# endif
#else #else
# define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE # define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE
#endif #endif
+2 -2
View File
@@ -34,5 +34,5 @@
############################################################################ ############################################################################
UIPLIB_ASRCS = UIPLIB_ASRCS =
UIPLIB_CSRCS = uiplib.c uip-setmacaddr.c uip-getmacaddr.c uip-sethostaddr.c \ UIPLIB_CSRCS = uiplib.c uip_setmacaddr.c uip_getmacaddr.c uip_sethostaddr.c \
uip-gethostaddr.c uip-setdraddr.c uip-setnetmask.c uip-server.c uip_gethostaddr.c uip_setdraddr.c uip_setnetmask.c uip_server.c
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-gethostaddr.c * netutils/uiplib/uip_gethostaddr.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-getmacaddr.c * netutils/uiplib/uip_getmacaddr.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-server.c * netutils/uiplib/uip_server.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-setdraddr.c * netutils/uiplib/uip_setdraddr.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-sethostaddr.c * netutils/uiplib/uip_sethostaddr.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-setmacaddr.c * netutils/uiplib/uip_setmacaddr.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/uiplib/uip-setnetmask.c * netutils/uiplib/uip_setnetmask.c
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
+25 -7
View File
@@ -53,6 +53,8 @@
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <nuttx/compiler.h>
#include <net/uip/uip.h> #include <net/uip/uip.h>
#include <net/uip/resolv.h> #include <net/uip/resolv.h>
@@ -360,7 +362,9 @@ static void newdata(struct uip_driver_s *dev)
uint8 uip_interrupt_event(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags) uint8 uip_interrupt_event(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags)
{ {
#warning OBSOLETE -- needs to be redesigned #ifdef CONFIG_CPP_HAVE_WARNING
# warning OBSOLETE -- needs to be redesigned
#endif
g_return = flags; g_return = flags;
if ((flags & UIP_CONNECTED) != 0) if ((flags & UIP_CONNECTED) != 0)
@@ -442,26 +446,40 @@ uint8 uip_interrupt_event(struct uip_driver_s *dev, struct uip_conn *conn, uint8
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: webclient_init
****************************************************************************/
void webclient_init(void) void webclient_init(void)
{ {
} }
unsigned char webclient_get(const char *host, uint16 port, char *file) /****************************************************************************
* Name: webclient_get
****************************************************************************/
unsigned char webclient_get(FAR const char *host, uint16 port, FAR char *file)
{ {
uip_ipaddr_t *ipaddr;
static uip_ipaddr_t addr; static uip_ipaddr_t addr;
struct sockaddr_in server; struct sockaddr_in server;
int sockfd; int sockfd;
/* First check if the host is an IP address. */ /* First check if the host is an IP address. */
ipaddr = &addr; if (!uiplib_ipaddrconv(host, (unsigned char *)addr))
if (uiplib_ipaddrconv(host, (unsigned char *)addr) == 0)
{ {
if (resolv_query(host, &ipaddr) < 0) /* 'host' does not point to a avalid address string. Try to resolve
* the host name to an IP address.
*/
if (resolv_query(host, &server) < 0)
{ {
return ERROR; return ERROR;
} }
/* Save the host address */
addr = server.sin_addr.s_addr;
} }
/* Create a socket */ /* Create a socket */
@@ -473,7 +491,7 @@ unsigned char webclient_get(const char *host, uint16 port, char *file)
} }
/* Connect to server. First we have to set some fields in the /* Connect to server. First we have to set some fields in the
* 'server' structure. The system will assign me an arbitrary * 'server' address structure. The system will assign me an arbitrary
* local port that is not in use. * local port that is not in use.
*/ */
+5 -1
View File
@@ -34,6 +34,8 @@
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <nuttx/compiler.h>
#include <net/uip/uip.h> #include <net/uip/uip.h>
#include <net/uip/httpd.h> #include <net/uip/httpd.h>
@@ -115,7 +117,9 @@ httpd_cgifunction httpd_cgi(char *name)
return (*f)->function; return (*f)->function;
} }
} }
#warning REVISIT -- must wait to return #ifdef CONFIG_CPP_HAVE_WARNING
# warning REVISIT -- must wait to return
#endif
return nullfunction; return nullfunction;
} }
+4 -3
View File
@@ -37,13 +37,14 @@
#include "httpd.h" #include "httpd.h"
typedef void (* httpd_cgifunction)(struct httpd_state *, char *); typedef void (*httpd_cgifunction)(struct httpd_state *, char *);
httpd_cgifunction httpd_cgi(char *name); httpd_cgifunction httpd_cgi(char *name);
struct httpd_cgi_call { struct httpd_cgi_call
{
const char *name; const char *name;
const httpd_cgifunction function; httpd_cgifunction function;
}; };
/** /**
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -489,7 +489,7 @@ static void *httpd_handler(void *arg)
dbg("[%d] Exitting\n", sockfd); dbg("[%d] Exitting\n", sockfd);
close(sockfd); close(sockfd);
pthread_exit(NULL); return NULL;
} }
/**************************************************************************** /****************************************************************************