Commit 72abe3c1 authored by Jaehyun Cho's avatar Jaehyun Cho Committed by Uze Choi

Make st regarding logic to library.

To st_things modules use commonly, it need to
make that library. Make st_framework module in service
layer, and move st_app modules to there.

To make prebuilt library for st-app-fw, use make_prebuilt.py
script in tools folder. thil will copy dependency header in
prebuilt folder and copy library about st-app-fw(libst-app-framwork.a)
Detailed usage can check in make_prebuilt.py script file.

Please Add build option ST_APP_FW to build st-app-fw library.

-------------------------------
Test Case
  st_app (out of box)
     Create Soft-AP  : OK
     Provisioning : OK
     Controlled by ST android app :OK
  st_app (setup is done)  -  OK
  st_app (with reset)  - OK

Change-Id: Ie44b7053a69afe9ad230ecde1655f252bdd45ae7
Signed-off-by: default avatarJaehyun Cho <jaehyun3.cho@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/25629Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent ea2508e6
...@@ -16,6 +16,8 @@ port/linux/server_multithread_linux ...@@ -16,6 +16,8 @@ port/linux/server_multithread_linux
port/linux/client_multithread_linux port/linux/client_multithread_linux
port/linux/easysetup_linux port/linux/easysetup_linux
port/linux/easysetup_linux_creds/ port/linux/easysetup_linux_creds/
port/linux/sc_easysetup_linux
port/linux/sc_easysetup_linux_creds/
port/linux/mfgserver port/linux/mfgserver
port/linux/mfgserver_creds/ port/linux/mfgserver_creds/
port/linux/st_things port/linux/st_things
...@@ -26,6 +28,7 @@ port/linux/libiotivity-constrained-client-server.* ...@@ -26,6 +28,7 @@ port/linux/libiotivity-constrained-client-server.*
port/linux/libiotivity-constrained-cloudaccess.* port/linux/libiotivity-constrained-cloudaccess.*
port/linux/libiotivity-constrained-rd-client.* port/linux/libiotivity-constrained-rd-client.*
port/linux/libiotivity-constrained-easysetup.* port/linux/libiotivity-constrained-easysetup.*
port/linux/libst-app-framework.*
port/linux/iotivity-constrained-server.pc port/linux/iotivity-constrained-server.pc
port/linux/iotivity-constrained-client.pc port/linux/iotivity-constrained-client.pc
port/linux/iotivity-constrained-client-server.pc port/linux/iotivity-constrained-client-server.pc
...@@ -49,6 +52,7 @@ port/openthread/output ...@@ -49,6 +52,7 @@ port/openthread/output
.clang-format .clang-format
_clang-format _clang-format
port/linux/platformtest port/linux/platformtest
prebuilt
#creds files #creds files
port/linux/client_creds port/linux/client_creds
...@@ -63,6 +67,7 @@ port/linux/multi_device_client_creds ...@@ -63,6 +67,7 @@ port/linux/multi_device_client_creds
port/linux/multi_device_server_creds port/linux/multi_device_server_creds
port/linux/server_multithread_linux_creds port/linux/server_multithread_linux_creds
port/linux/client_multithread_linux_creds port/linux/client_multithread_linux_creds
port/linux/cloud_linux_creds
#vscode setting files #vscode setting files
.vscode .vscode
#!/usr/bin/make -f
# -*- makefile -*-
# ex: set tabstop=4 noexpandtab:
#{
# Copyright 2018 Samsung Electronics France SAS
#
# 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.
#}
port?=linux
srcs?=$(wildcard *.c ${port}/*.c)
objs?=${srcs:.c=.o}
topdir?=../..
CFLAGS+=-I${topdir}
CFLAGS+=-I${topdir}/include
CFLAGS+=-I${topdir}/port
CFLAGS+=-I${topdir}/port/${port}
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include
CFLAGS+=-I${topdir}/service/cloud-access/include
CFLAGS+=-I${topdir}/service/resource-directory/client/include
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include/samsung
all: ${objs}
ls $<
clean:
rm -f ${objs}
...@@ -26,6 +26,11 @@ CFLAGS+=-I${topdir} ...@@ -26,6 +26,11 @@ CFLAGS+=-I${topdir}
CFLAGS+=-I${topdir}/include CFLAGS+=-I${topdir}/include
CFLAGS+=-I${topdir}/port/ CFLAGS+=-I${topdir}/port/
CFLAGS+=-I${topdir}/port/${port} CFLAGS+=-I${topdir}/port/${port}
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include
CFLAGS+=-I${topdir}/service/cloud-access/include
CFLAGS+=-I${topdir}/service/resource-directory/client/include
CFLAGS+=-I${topdir}/service/easy-setup/enrollee/include/samsung
CFLAGS+=-I${topdir}/service/st-app-fw/include
all: ${objs} all: ${objs}
ls $< ls $<
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
****************************************************************************/ ****************************************************************************/
#include "oc_assert.h" #include "oc_assert.h"
#include "../st_manager.h" #include "st_manager.h"
#include "../st_port.h" #include "st_resource_manager.h"
#include "../st_resource_manager.h"
static const char *switch_rsc_uri = "/capability/switch/main/0"; static const char *switch_rsc_uri = "/capability/switch/main/0";
static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0"; static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0";
......
CC = gcc
CFLAGS=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I./ -I../ -I../../ -I../../include/ -std=gnu99 -Wall -Wextra #-Wl,-Map,client.map
CFLAGS += -I./include
LIBS?= -lm -pthread -lrt
all: st_things
st_things:
@mkdir -p $@_creds
${CC} -o $@ st_ref_app.c \
lib/libst-app-framework.a ${CFLAGS} ${LIBS}
\ No newline at end of file
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
* *
****************************************************************************/ ****************************************************************************/
#include "../st_manager.h" #include "st_manager.h"
#include "../st_port.h" #include "st_resource_manager.h"
#include "../st_resource_manager.h"
static const char *switch_rsc_uri = "/capability/switch/main/0"; static const char *switch_rsc_uri = "/capability/switch/main/0";
static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0"; static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0";
...@@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request) ...@@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request)
strlen(color_temp_rsc_uri)) == 0) { strlen(color_temp_rsc_uri)) == 0) {
color_temp_resource_construct(); color_temp_resource_construct();
} else { } else {
st_print_log("[ST_APP] invalid uri %s\n", printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
oc_string(request->resource->uri));
return false; return false;
} }
...@@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep) ...@@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep)
if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) { if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) {
strncpy(power, m_power, len); strncpy(power, m_power, len);
power[len] = '\0'; power[len] = '\0';
st_print_log("[ST_APP] %s : %s\n", oc_string(rep->name), power); printf("[ST_APP] %s : %s\n", oc_string(rep->name), power);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -96,7 +94,7 @@ static void ...@@ -96,7 +94,7 @@ static void
switchlevel_resource_change(oc_rep_t *rep) switchlevel_resource_change(oc_rep_t *rep)
{ {
if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) { if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting); printf("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -106,7 +104,7 @@ static void ...@@ -106,7 +104,7 @@ static void
color_temp_resource_change(oc_rep_t *rep) color_temp_resource_change(oc_rep_t *rep)
{ {
if (oc_rep_get_int(rep, ct_prop_key, &ct)) { if (oc_rep_get_int(rep, ct_prop_key, &ct)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), ct); printf("[ST_APP] %s : %d\n", oc_string(rep->name), ct);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request) ...@@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request)
color_temp_resource_change(request->request_payload); color_temp_resource_change(request->request_payload);
color_temp_resource_construct(); color_temp_resource_construct();
} else { } else {
st_print_log("[ST_APP] invalid uri %s\n", printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
oc_string(request->resource->uri));
return false; return false;
} }
...@@ -139,14 +136,14 @@ set_resource_handler(oc_request_t *request) ...@@ -139,14 +136,14 @@ set_resource_handler(oc_request_t *request)
static bool static bool
otm_confirm_handler(void) otm_confirm_handler(void)
{ {
st_print_log("[ST_APP] OTM request is comming. Will you confirm?[y/n]\n"); printf("[ST_APP] OTM request is comming. Will you confirm?[y/n]\n");
char ret[10]; char ret[10];
scanf("%s", ret); scanf("%s", ret);
if (ret[0] == 'y' || ret[0] == 'Y') { if (ret[0] == 'y' || ret[0] == 'Y') {
st_print_log("[ST_APP] CONFIRMED.\n"); printf("[ST_APP] CONFIRMED.\n");
return true; return true;
} else { } else {
st_print_log("[ST_APP] DENIED.\n"); printf("[ST_APP] DENIED.\n");
return false; return false;
} }
} }
...@@ -155,7 +152,7 @@ int ...@@ -155,7 +152,7 @@ int
main(void) main(void)
{ {
if (st_manager_initialize() != 0) { if (st_manager_initialize() != 0) {
st_print_log("[ST_APP] st_manager_initialize failed.\n"); printf("[ST_APP] st_manager_initialize failed.\n");
return -1; return -1;
} }
...@@ -163,7 +160,7 @@ main(void) ...@@ -163,7 +160,7 @@ main(void)
st_register_otm_confirm_handler(otm_confirm_handler); st_register_otm_confirm_handler(otm_confirm_handler);
if (st_manager_start() != 0) { if (st_manager_start() != 0) {
st_print_log("[ST_APP] st_manager_start failed.\n"); printf("[ST_APP] st_manager_start failed.\n");
} }
st_manager_stop(); st_manager_stop();
......
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
* *
****************************************************************************/ ****************************************************************************/
#include "../st_manager.h" #include "st_manager.h"
#include "../st_port.h" #include "st_resource_manager.h"
#include "../st_resource_manager.h"
static const char *switch_rsc_uri = "/capability/switch/main/0"; static const char *switch_rsc_uri = "/capability/switch/main/0";
static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0"; static const char *switchlevel_rsc_uri = "/capability/switchLevel/main/0";
...@@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request) ...@@ -71,8 +70,7 @@ get_resource_handler(oc_request_t *request)
strlen(color_temp_rsc_uri)) == 0) { strlen(color_temp_rsc_uri)) == 0) {
color_temp_resource_construct(); color_temp_resource_construct();
} else { } else {
st_print_log("[ST_APP] invalid uri %s\n", printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
oc_string(request->resource->uri));
return false; return false;
} }
...@@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep) ...@@ -86,7 +84,7 @@ switch_resource_change(oc_rep_t *rep)
if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) { if (oc_rep_get_string(rep, power_prop_key, &m_power, &len)) {
strncpy(power, m_power, len); strncpy(power, m_power, len);
power[len] = '\0'; power[len] = '\0';
st_print_log("[ST_APP] %s : %s\n", oc_string(rep->name), power); printf("[ST_APP] %s : %s\n", oc_string(rep->name), power);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -96,7 +94,7 @@ static void ...@@ -96,7 +94,7 @@ static void
switchlevel_resource_change(oc_rep_t *rep) switchlevel_resource_change(oc_rep_t *rep)
{ {
if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) { if (oc_rep_get_int(rep, dimming_prop_key, &dimmingSetting)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting); printf("[ST_APP] %s : %d\n", oc_string(rep->name), dimmingSetting);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -106,7 +104,7 @@ static void ...@@ -106,7 +104,7 @@ static void
color_temp_resource_change(oc_rep_t *rep) color_temp_resource_change(oc_rep_t *rep)
{ {
if (oc_rep_get_int(rep, ct_prop_key, &ct)) { if (oc_rep_get_int(rep, ct_prop_key, &ct)) {
st_print_log("[ST_APP] %s : %d\n", oc_string(rep->name), ct); printf("[ST_APP] %s : %d\n", oc_string(rep->name), ct);
// TODO: device specific behavior. // TODO: device specific behavior.
} }
...@@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request) ...@@ -128,8 +126,7 @@ set_resource_handler(oc_request_t *request)
color_temp_resource_change(request->request_payload); color_temp_resource_change(request->request_payload);
color_temp_resource_construct(); color_temp_resource_construct();
} else { } else {
st_print_log("[ST_APP] invalid uri %s\n", printf("[ST_APP] invalid uri %s\n", oc_string(request->resource->uri));
oc_string(request->resource->uri));
return false; return false;
} }
...@@ -141,7 +138,7 @@ int ...@@ -141,7 +138,7 @@ int
stapp_main(void) stapp_main(void)
{ {
if (st_manager_initialize() != 0) { if (st_manager_initialize() != 0) {
st_print_log("[ST_APP] st_manager_initialize failed.\n"); printf("[ST_APP] st_manager_initialize failed.\n");
return -1; return -1;
} }
...@@ -150,7 +147,7 @@ stapp_main(void) ...@@ -150,7 +147,7 @@ stapp_main(void)
// TODO: callback registration. (ex. user confirm cb) // TODO: callback registration. (ex. user confirm cb)
if (st_manager_start() != 0) { if (st_manager_start() != 0) {
st_print_log("[ST_APP] st_manager_start failed.\n"); printf("[ST_APP] st_manager_start failed.\n");
} }
st_manager_stop(); st_manager_stop();
......
/* ****************************************************************
*
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* 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.
*
******************************************************************/
#include "wifi_soft_ap_util.h"
#include <net/lwip/dhcp.h>
#include <net/lwip/netif.h>
static int g_wifi_state;
static struct netif *gnet_if;
static slsi_security_config_t *es_get_security_config(const char *sec_type, const char *psk)
{
slsi_security_config_t *ret = NULL;
if (strncmp(SLSI_WIFI_SECURITY_OPEN,
sec_type, sizeof(SLSI_WIFI_SECURITY_OPEN)) != 0 ) {
ret = (slsi_security_config_t *)zalloc(sizeof(slsi_security_config_t));
if (ret) {
if (strncmp(SLSI_WIFI_SECURITY_WEP_OPEN,
sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_OPEN)) == 0) {
ret->secmode = SLSI_SEC_MODE_WEP;
} else if (strncmp(SLSI_WIFI_SECURITY_WEP_SHARED,
sec_type, sizeof(SLSI_WIFI_SECURITY_WEP_SHARED)) == 0) {
ret->secmode = SLSI_SEC_MODE_WEP_SHARED;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA_MIXED,
sec_type,sizeof(SLSI_WIFI_SECURITY_WPA_MIXED)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA_MIXED;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA_TKIP,
sec_type,sizeof(SLSI_WIFI_SECURITY_WPA_TKIP)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA_TKIP;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA_AES,
sec_type,sizeof(SLSI_WIFI_SECURITY_WPA_AES)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA_CCMP;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA2_MIXED,
sec_type,sizeof(SLSI_WIFI_SECURITY_WPA2_MIXED)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA2_MIXED;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA2_TKIP,
sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_TKIP)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA2_TKIP;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA2_AES,
sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_AES)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA2_CCMP;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA_PSK,
sec_type, sizeof(SLSI_WIFI_SECURITY_WPA_PSK)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA2_MIXED;
} else if (strncmp(SLSI_WIFI_SECURITY_WPA2_PSK,
sec_type, sizeof(SLSI_WIFI_SECURITY_WPA2_PSK)) == 0) {
ret->secmode = SLSI_SEC_MODE_WPA2_MIXED;
}
}
if(psk) {
memcpy(ret->passphrase, psk, strlen(psk));
} else {
free(ret);
ret = NULL;
}
}
return ret;
}
static void linkUpHandler(slsi_reason_t* reason)
{
g_wifi_state = WIFI_CONNECTED;
printf("Connected to network\n");
}
static void linkDownHandler(slsi_reason_t* reason)
{
if (reason) {
printf("Disconnected from network reason_code: %d %s\n", reason->reason_code,
reason->locally_generated ? "(locally_generated)": "");
} else {
printf("Disconnected from network\n");
}
}
int wifi_start_station(void)
{
int result = -1;
printf("Starting STA mode...\n");
g_wifi_state = WIFI_DISCONNECTED;
if (WiFiStart(SLSI_WIFI_STATION_IF, NULL) == SLSI_STATUS_SUCCESS) {
result = 0;
if (!WiFiRegisterLinkCallback(&linkUpHandler, &linkDownHandler)) {
printf("Link call back handles registered - per default!\n");
} else {
printf("Link call back handles registered - status failed !\n");
}
} else {
printf("WiFiStart STA mode failed !\n");
}
return result;
}
int es_create_softap(void)
{
printf("es_create_softap in\n");
slsi_ap_config_t *app_settings = (slsi_ap_config_t *)zalloc(sizeof(slsi_ap_config_t));
if(app_settings == NULL)
return -1;
g_wifi_state = WIFI_DISCONNECTED;
// SSID Format: <device name>_E1<MNID><onboarding id>0<last 2 segments of mac>
// device name - is as per device name (refer st_main.c)
// MNID and onboarding id - you get from s-devworkspace
char *es_softap_ssid = CONFIG_IOTLITE_SSID_SOFTAP;
char* es_softap_passphrase = CONFIG_IOTLITE_PWD_SOFTAP;
char *es_softap_security = CONFIG_IOTLITE_SECURITY_SOFTAP;
printf("SoftAP SSID : %s\n", es_softap_ssid);
memcpy(app_settings->ssid, (uint8_t *)es_softap_ssid, strlen(es_softap_ssid));
app_settings->ssid_len = strlen(es_softap_ssid);
app_settings->beacon_period = 100;
app_settings->DTIM = 2;
app_settings->channel = 1;
app_settings->phy_mode = 1;
app_settings->security = es_get_security_config(es_softap_security, es_softap_passphrase);
printf("Starting AP mode...\n");
if(WiFiStart(SLSI_WIFI_SOFT_AP_IF, app_settings) == SLSI_STATUS_SUCCESS) {
if (!WiFiRegisterLinkCallback(&linkUpHandler, &linkDownHandler)) {
printf("Link call back handles registered - per default!\n");
} else {
printf("Link call back handles registered - status failed !\n");
}
} else {
printf("WiFiStart AP mode failed !\n");
free(app_settings->security);
return -1;
}
free(app_settings->security);
printf("es_create_softap out\n");
return 0;
}
void es_stop_softap(void)
{
printf("es_stop_softap in\n");
stop_dhcp(SLSI_WIFI_SOFT_AP_IF);
printf("es_stop_softap out\n");
}
int wifi_join(const char *ssid, const char *security, const char *passwd)
{
printf("wifi_join in\n");
int ret;
slsi_security_config_t *security_config;
uint8_t ssid_len = strlen((char *)ssid);
security_config = es_get_security_config(security, passwd);
printf("Joining selected network...\n");
ret = WiFiNetworkJoin((uint8_t*)ssid, ssid_len, NULL, security_config);
if (ret != 0) {
printf("SLSI_WiFiNetworkJoin start failed, ret = %d!\n", ret);
return -1;
} else {
printf("WiFiNetworkJoin start success!\n");
}
if (security_config) {
free(security_config);
security_config = NULL;
}
printf("wifi_join out\n");
return ret;
}
int dhcpserver_start(void)
{
printf("dhcpserver_start in\n");
ip_addr_t ipaddr, netmask, gateway;
gnet_if = netif_find(CTRL_IFNAME);
if (gnet_if == NULL) {
return -1;
}
// Setting static IP as 192.168.43.10 in AP mode
ipaddr.addr = 0x0A2BA8C0;
netmask.addr = 0x00FFFFFF;
gateway.addr = 0x012FA8C0;
netif_set_addr(gnet_if, &ipaddr, &netmask, &gateway);
netif_set_up(gnet_if);
if (dhcps_start(gnet_if) != ERR_OK) {
printf("DHCP Server - started Fail\n");
return -1;
}
printf("dhcpserver_start out: start success\n");
return 0;
}
int dhcpc_start(void)
{
printf("dhcpc_start in\n");
gnet_if = netif_find(CTRL_IFNAME);
if (gnet_if == NULL) {
return -1;
}
if (gnet_if->dhcp != NULL){
gnet_if->dhcp = NULL;
}
printf( "netic hwaddr_len %d\n"
"netic hwaddr %x%x%x%x%x%x\n"
"netic mtu %d\n"
"netic flags %x\n",
gnet_if->hwaddr_len,
gnet_if->hwaddr[0], gnet_if->hwaddr[1], gnet_if->hwaddr[2],
gnet_if->hwaddr[3], gnet_if->hwaddr[4], gnet_if->hwaddr[5],
gnet_if->mtu, gnet_if->flags);
err_t res = dhcp_start(gnet_if);
if (res) {
printf("slsi_start_dhcp dhcp_start result %d\n", res);
return -1;
}