From 563ced5a52a1260c2165435a103c204c39a658f0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 30 Nov 2007 20:46:29 +0000 Subject: Add examples/dhcpd git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@413 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/include/net/if.h | 85 ++++++++++++++++++++++++++++++++++++++++ nuttx/include/net/ioctls.h | 30 -------------- nuttx/include/net/uip/dhcpc.h | 26 ++++++++---- nuttx/include/net/uip/dhcpd.h | 73 ++++++++++++++++++++++++++++++++++ nuttx/include/net/uip/uip-arch.h | 1 + 5 files changed, 178 insertions(+), 37 deletions(-) create mode 100644 nuttx/include/net/if.h create mode 100644 nuttx/include/net/uip/dhcpd.h (limited to 'nuttx/include/net') diff --git a/nuttx/include/net/if.h b/nuttx/include/net/if.h new file mode 100644 index 000000000..7d8ea6007 --- /dev/null +++ b/nuttx/include/net/if.h @@ -0,0 +1,85 @@ +/**************************************************************************** + * net/if.h + * + * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __NET_IF_H +#define __NET_IF_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Sizing parameters */ + +#define IFNAMSIZ 6 +#define IFHWADDRLEN 6 + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +struct ifreq +{ + char ifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */ + union + { + struct sockaddr ifru_addr; /* IP Address */ + struct sockaddr ifru_dstaddr; /* P-to-P Address */ + struct sockaddr ifru_broadaddr; /* Broadcast address */ + struct sockaddr ifru_netmask; /* Netmask */ + struct sockaddr ifru_hwaddr; /* MAC address */ + int ifru_count; /* Number of devices */ + int ifru_mtu; /* MTU size */ + } ifr_ifru; +}; + +#define ifr_addr ifr_ifru.ifru_addr /* IP address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* P-to-P Address */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* Broadcast address */ +#define ifr_netmask ifr_ifru.ifru_netmask /* Interface net mask */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +#define ifr_mtu ifr_ifru.ifru_mtu /* MTU */ +#define ifr_count ifr_ifru.ifru_count /* Number of devices */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#endif /* __NET_IF_H */ diff --git a/nuttx/include/net/ioctls.h b/nuttx/include/net/ioctls.h index 4be5727ac..785c7d4f2 100644 --- a/nuttx/include/net/ioctls.h +++ b/nuttx/include/net/ioctls.h @@ -40,8 +40,6 @@ * Included Files ****************************************************************************/ -#include - /**************************************************************************** * Definitions ****************************************************************************/ @@ -69,38 +67,10 @@ #define SIOCDIFADDR (_SIOCBASE|0x000c) /* Delete IP address */ #define SIOCGIFCOUNT (_SIOCBASE|0x000d) /* Get number of devices */ -/* Sizing parameters */ - -#define IFNAMSIZ 6 -#define IFHWADDRLEN 6 - /**************************************************************************** * Type Definitions ****************************************************************************/ -struct ifreq -{ - char ifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */ - union - { - struct sockaddr ifru_addr; /* IP Address */ - struct sockaddr ifru_dstaddr; /* P-to-P Address */ - struct sockaddr ifru_broadaddr; /* Broadcast address */ - struct sockaddr ifru_netmask; /* Netmask */ - struct sockaddr ifru_hwaddr; /* MAC address */ - int ifru_count; /* Number of devices */ - int ifru_mtu; /* MTU size */ - } ifr_ifru; -}; - -#define ifr_addr ifr_ifru.ifru_addr /* IP address */ -#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* P-to-P Address */ -#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* Broadcast address */ -#define ifr_netmask ifr_ifru.ifru_netmask /* Interface net mask */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ -#define ifr_mtu ifr_ifru.ifru_mtu /* MTU */ -#define ifr_count ifr_ifru.ifru_count /* Number of devices */ - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/nuttx/include/net/uip/dhcpc.h b/nuttx/include/net/uip/dhcpc.h index 12f3f0a9b..606d818b0 100644 --- a/nuttx/include/net/uip/dhcpc.h +++ b/nuttx/include/net/uip/dhcpc.h @@ -1,5 +1,5 @@ /**************************************************************************** - * dhcpc.c + * net/uip/dhcpc.n * * Copyright (C) 2007 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -35,8 +35,8 @@ * SUCH DAMAGE. */ -#ifndef NET_UIP_DHCP_H__ -#define NET_UIP_DHCP_H__ +#ifndef __NET_UIP_DHCPC_H +#define __NET_UIP_DHCPC_H /**************************************************************************** * Included Files @@ -66,8 +66,20 @@ struct dhcpc_state * Public Function Prototypes ****************************************************************************/ -void *dhcpc_open(const void *mac_addr, int mac_len); -int dhcpc_request(void *handle, struct dhcpc_state *presult); -void dhcpc_close(void *handle); +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif -#endif /* NET_UIP_DHCP_H__ */ +EXTERN void *dhcpc_open(const void *mac_addr, int mac_len); +EXTERN int dhcpc_request(void *handle, struct dhcpc_state *presult); +EXTERN void dhcpc_close(void *handle); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __NET_UIP_DHCPC_H */ diff --git a/nuttx/include/net/uip/dhcpd.h b/nuttx/include/net/uip/dhcpd.h new file mode 100644 index 000000000..ed8770f03 --- /dev/null +++ b/nuttx/include/net/uip/dhcpd.h @@ -0,0 +1,73 @@ +/**************************************************************************** + * net/uipt/dhcpd.h + * + * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * This logic was leveraged from uIP which also has a BSD-style license: + * + * Copyright (c) 2005, Swedish Institute of Computer Science + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __NET_UIP_DHCPD_H +#define __NET_UIP_DHCPD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN int dhcpd_run(void); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __NET_UIP_DHCPD_H */ diff --git a/nuttx/include/net/uip/uip-arch.h b/nuttx/include/net/uip/uip-arch.h index eb5a0e5ba..9de911e00 100644 --- a/nuttx/include/net/uip/uip-arch.h +++ b/nuttx/include/net/uip/uip-arch.h @@ -45,6 +45,7 @@ #include #include #include +#include #include /**************************************************************************** -- cgit v1.2.3