Add examples/dhcpd

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@413 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-11-30 20:46:29 +00:00
parent 14dd3e6265
commit 5fe8b2974d
25 changed files with 317 additions and 120 deletions
+85
View File
@@ -0,0 +1,85 @@
/****************************************************************************
* net/if.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 <sys/socket.h>
/****************************************************************************
* 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 */
-30
View File
@@ -40,8 +40,6 @@
* Included Files
****************************************************************************/
#include <sys/socket.h>
/****************************************************************************
* 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
****************************************************************************/
+19 -7
View File
@@ -1,5 +1,5 @@
/****************************************************************************
* dhcpc.c
* net/uip/dhcpc.n
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@@ -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 */
+73
View File
@@ -0,0 +1,73 @@
/****************************************************************************
* net/uipt/dhcpd.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 <sys/types.h>
/****************************************************************************
* 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 */
+1
View File
@@ -45,6 +45,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/uip/uip.h>
/****************************************************************************