net: apps: Add DHCP client sample application
Change-Id: I9c3f317fb13bce56ee93d66d692618145087a6a9 Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
0de956d53f
commit
6a9817a091
25
samples/net/dhcp_client/Makefile
Normal file
25
samples/net/dhcp_client/Makefile
Normal file
|
@ -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
|
5
samples/net/dhcp_client/prj.mdef
Normal file
5
samples/net/dhcp_client/prj.mdef
Normal file
|
@ -0,0 +1,5 @@
|
|||
% Application : echo client
|
||||
|
||||
% TASK NAME PRIO ENTRY STACK GROUPS
|
||||
% ==================================
|
||||
TASK MAIN 7 main 2048 [EXE]
|
34
samples/net/dhcp_client/prj_galileo.conf
Normal file
34
samples/net/dhcp_client/prj_galileo.conf
Normal file
|
@ -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
|
6
samples/net/dhcp_client/src/Makefile
Normal file
6
samples/net/dhcp_client/src/Makefile
Normal file
|
@ -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
|
52
samples/net/dhcp_client/src/dhcp-client.c
Normal file
52
samples/net/dhcp_client/src/dhcp-client.c
Normal file
|
@ -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 <stdio.h>
|
||||
#define PRINT printf
|
||||
#else
|
||||
#include <misc/printk.h>
|
||||
#define PRINT printk
|
||||
#endif
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <sections.h>
|
||||
|
||||
#include <net/ip_buf.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_socket.h>
|
||||
#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();
|
||||
}
|
5
samples/net/dhcp_client/testcase.ini
Normal file
5
samples/net/dhcp_client/testcase.ini
Normal file
|
@ -0,0 +1,5 @@
|
|||
[test]
|
||||
tags = net
|
||||
build_only = true
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = galileo
|
Loading…
Reference in a new issue