diff --git a/samples/net/dhcp_client/Makefile b/samples/net/dhcp_client/Makefile new file mode 100644 index 00000000000..045b2fd32a6 --- /dev/null +++ b/samples/net/dhcp_client/Makefile @@ -0,0 +1,25 @@ +# Makefile - echo client test application + +# +# Copyright (c) 2015 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +NET_IFACE ?= galileo +MDEF_FILE = prj.mdef +KERNEL_TYPE ?= nano +BOARD ?= galileo +CONF_FILE ?= prj_$(NET_IFACE).conf + +include $(ZEPHYR_BASE)/Makefile.inc diff --git a/samples/net/dhcp_client/prj.mdef b/samples/net/dhcp_client/prj.mdef new file mode 100644 index 00000000000..865de24b6ff --- /dev/null +++ b/samples/net/dhcp_client/prj.mdef @@ -0,0 +1,5 @@ +% Application : echo client + +% TASK NAME PRIO ENTRY STACK GROUPS +% ================================== + TASK MAIN 7 main 2048 [EXE] diff --git a/samples/net/dhcp_client/prj_galileo.conf b/samples/net/dhcp_client/prj_galileo.conf new file mode 100644 index 00000000000..5a4ae10f05a --- /dev/null +++ b/samples/net/dhcp_client/prj_galileo.conf @@ -0,0 +1,34 @@ +# +#console +# +CONFIG_STDOUT_CONSOLE=y +CONFIG_CONSOLE_HANDLER=y +CONFIG_CONSOLE_HANDLER_SHELL=y +CONFIG_PRINTK=y +CONFIG_MINIMAL_LIBC_EXTENDED=y +# +# networking +# +CONFIG_NETWORKING=y +CONFIG_IP_BUF_RX_SIZE=2 +CONFIG_IP_BUF_TX_SIZE=3 +CONFIG_NETWORKING_WITH_IPV4=y +CONFIG_TEST_RANDOM_GENERATOR=y +CONFIG_NETWORKING_WITH_TCP=y +CONFIG_DHCP=y +CONFIG_NANO_TIMEOUTS=y + +CONFIG_NETWORKING_WITH_LOGGING=y +CONFIG_NETWORK_IP_STACK_DEBUG_DHCP=y +CONFIG_NETWORK_IP_STACK_DEBUG_PRINT=y +CONFIG_NETWORK_IP_STACK_DEBUG_RECV_SEND=y +CONFIG_NETWORK_IP_STACK_DEBUG_IPV4=y +CONFIG_NETWORK_IP_STACK_DEBUG_CONTEXT=y +CONFIG_NETWORK_IP_STACK_DEBUG_NET_BUF=y +# +# Ethernet +# +CONFIG_ETHERNET=y +#CONFIG_ETHERNET_DEBUG=y +CONFIG_ETH_DW=y +CONFIG_PCI_ENUMERATION=y diff --git a/samples/net/dhcp_client/src/Makefile b/samples/net/dhcp_client/src/Makefile new file mode 100644 index 00000000000..a6f327dd680 --- /dev/null +++ b/samples/net/dhcp_client/src/Makefile @@ -0,0 +1,6 @@ +ccflags-y +=-I${srctree}/net/ip/contiki +ccflags-y +=-I${srctree}/net/ip/contiki/os/lib +ccflags-y +=-I${srctree}/net/ip/contiki/os +ccflags-y +=-I${srctree}/net/ip + +obj-y = dhcp-client.o diff --git a/samples/net/dhcp_client/src/dhcp-client.c b/samples/net/dhcp_client/src/dhcp-client.c new file mode 100644 index 00000000000..3fb0e5607c3 --- /dev/null +++ b/samples/net/dhcp_client/src/dhcp-client.c @@ -0,0 +1,52 @@ +/* dhcp-client.c - Get IPv4 address */ + +/* + * Copyright (c) 2016 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(CONFIG_STDOUT_CONSOLE) +#include +#define PRINT printf +#else +#include +#define PRINT printk +#endif + +#include +#include + +#include +#include +#include +#include "contiki/ip/dhcpc.h" + + +static void dhcpc_configured_cb(void) +{ + PRINT("%s\n", __func__); + PRINT("Got IP address %d.%d.%d.%d\n", uip_ipaddr_to_quad(&uip_hostaddr)); +} + +static void dhcpc_unconfigured_cb(void) +{ + PRINT("%s\n", __func__); +} + +void main(void) +{ + PRINT("run dhcp client\n"); + dhcpc_set_callbacks(dhcpc_configured_cb, dhcpc_unconfigured_cb); + net_init(); +} diff --git a/samples/net/dhcp_client/testcase.ini b/samples/net/dhcp_client/testcase.ini new file mode 100644 index 00000000000..99297a6174e --- /dev/null +++ b/samples/net/dhcp_client/testcase.ini @@ -0,0 +1,5 @@ +[test] +tags = net +build_only = true +arch_whitelist = x86 +platform_whitelist = galileo