/*---------------------------------------------------------------------------*/ PROCESS_THREAD(udp_server_process, ev, data) { PROCESS_BEGIN(); dtls_init(); init_dtls(); print_local_addresses(); if (!dtls_context) { dtls_emerg("cannot create context\n"); PROCESS_EXIT(); } #ifdef ENABLE_POWERTRACE powertrace_start(CLOCK_SECOND * 2); #endif while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { dtls_handle_read(dtls_context); } } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(udp_server_process, ev, data) { PROCESS_BEGIN(); print_local_addresses(); dtls_init(); init_dtls(); if (!dtls_context) { dsrv_log(LOG_EMERG, "cannot create context\n"); PROCESS_EXIT(); } while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { dtls_handle_read(dtls_context); } #if 0 if (bytes_read > 0) { /* dtls_handle_message(dtls_context, &the_session, readbuf, bytes_read); */ read_from_peer(dtls_context, &the_session, readbuf, bytes_read); } dtls_handle_message(ctx, &session, uip_appdata, bytes_read); #endif } PROCESS_END(); }
static void init_everything(void) { log_init("rtpengine"); log_format(rtpe_config.log_format); recording_fs_init(rtpe_config.spooldir, rtpe_config.rec_method, rtpe_config.rec_format); rtpe_ssl_init(); #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif #if !(GLIB_CHECK_VERSION(2,36,0)) g_type_init(); #endif signals(); resources(); sdp_init(); dtls_init(); ice_init(); crypto_init_main(); interfaces_init(&rtpe_config.interfaces); iptables_init(); control_ng_init(); if (call_interfaces_init()) abort(); statistics_init(); codeclib_init(0); media_player_init(); }
/*---------------------------------------------------------------------------*/ void coap_context_init(void) { dtls_init(); coap_context_event = process_alloc_event(); process_start(&coap_context_process, NULL); }
dtls_context_t * get_dtls_context(dtls_connection_t * connList) { if (dtlsContext == NULL) { dtls_init(); dtlsContext = dtls_new_context(connList); if (dtlsContext == NULL) fprintf(stderr, "Failed to create the DTLS context\r\n"); dtls_set_handler(dtlsContext, &cb); }else{ dtlsContext->app = connList; } return dtlsContext; }
int main (int argc, const char * argv[]) { // send_image_file(0,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAP.tar"); cw_log_name="AC-Tube"; read_config("ac.conf"); cw_log_debug_level=conf_debug_level; cw_log(LOG_INFO,"Starting AC-Tube, Name=%s, ID=%s",conf_acname,conf_acid); // cw_dbg_opt_level= DBG_CW_MSGELEM_DMP | // DBG_CW_MSGELEM | DBG_CW_PKT| DBG_CW_RFC | DBG_ERR | DBG_CW_MSG | DBG_DTLS ; //| DBG_ALL; cw_dbg_opt_detail=DBG_DETAIL_ASC_DMP; // cw_log_dbg(DBG_CW_MSG,"Hello %s","World"); db_init(); db_start(); db_ping(); pthread_t alth; pthread_create (&alth, NULL, alive_thread, (void *)0); #ifdef WITH_DTLS dtls_init(); #endif if (!socklist_init()) goto errX; if (!wtplist_init()) goto errX; int rc = ac_run(); errX: wtplist_destroy(); socklist_destroy(); return rc; }
static void init_everything() { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); srandom(ts.tv_sec ^ ts.tv_nsec); SSL_library_init(); SSL_load_error_strings(); #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif if (!_log_stderr) openlog("rtpengine", LOG_PID | LOG_NDELAY, _log_facility); signals(); resources(); sdp_init(); dtls_init(); }
PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(pjmedia_endpt *endpt) { pj_status_t status = PJ_SUCCESS; if (libsrtp_initialized) return PJ_SUCCESS; #if PJMEDIA_LIBSRTP_AUTO_INIT_DEINIT /* Init libsrtp */ { srtp_err_status_t err; err = srtp_init(); if (err != srtp_err_status_ok) { PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s", get_libsrtp_errstr(err))); return PJMEDIA_ERRNO_FROM_LIBSRTP(err); } } #endif #if defined(PJMEDIA_SRTP_HAS_DTLS) && (PJMEDIA_SRTP_HAS_DTLS != 0) dtls_init(); #endif if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS) { /* There will be memory leak when it fails to schedule libsrtp * deinitialization, however the memory leak could be harmless, * since in modern OS's memory used by an application is released * when the application terminates. */ PJ_LOG(4, (THIS_FILE, "Failed to register libsrtp deinit.")); } libsrtp_initialized = PJ_TRUE; return status; }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(udp_server_process, ev, data) { static int connected = 0; static session_t dst; PROCESS_BEGIN(); dtls_init(); init_dtls(&dst); serial_line_init(); if (!dtls_context) { dsrv_log(LOG_EMERG, "cannot create context\n"); PROCESS_EXIT(); } while(1) { PROCESS_YIELD(); if(ev == tcpip_event) { dtls_handle_read(dtls_context); } else if (ev == serial_line_event_message) { register size_t len = min(strlen(data), sizeof(buf) - buflen); memcpy(buf + buflen, data, len); buflen += len; if (buflen < sizeof(buf) - 1) buf[buflen++] = '\n'; /* serial event does not contain LF */ } if (buflen) { if (!connected) connected = dtls_connect(dtls_context, &dst) >= 0; try_send(dtls_context, &dst); } } PROCESS_END(); }
int main(int argc, char **argv) { dtls_context_t *dtls_context = NULL; fd_set rfds, wfds; struct timeval timeout; unsigned short port = DEFAULT_PORT; char port_str[NI_MAXSERV] = "0"; log_t log_level = LOG_WARN; int fd, result; int on = 1; int opt, res; session_t dst; dtls_init(); snprintf(port_str, sizeof(port_str), "%d", port); while ((opt = getopt(argc, argv, "p:o:v:")) != -1) { switch (opt) { case 'p' : strncpy(port_str, optarg, NI_MAXSERV-1); port_str[NI_MAXSERV - 1] = '\0'; break; case 'o' : output_file.length = strlen(optarg); output_file.s = (unsigned char *)malloc(output_file.length + 1); if (!output_file.s) { dsrv_log(LOG_CRIT, "cannot set output file: insufficient memory\n"); exit(-1); } else { /* copy filename including trailing zero */ memcpy(output_file.s, optarg, output_file.length + 1); } break; case 'v' : log_level = strtol(optarg, NULL, 10); break; default: usage(argv[0], PACKAGE_VERSION); exit(1); } } set_log_level(log_level); if (argc <= optind) { usage(argv[0], PACKAGE_VERSION); exit(1); } memset(&dst, 0, sizeof(session_t)); /* resolve destination address where server should be sent */ res = resolve_address(argv[optind++], &dst.addr.sa); if (res < 0) { dsrv_log(LOG_EMERG, "failed to resolve address\n"); exit(-1); } dst.size = res; /* use port number from command line when specified or the listen port, otherwise */ dst.addr.sin.sin_port = htons(atoi(optind < argc ? argv[optind++] : port_str)); /* init socket and set it to non-blocking */ fd = socket(dst.addr.sa.sa_family, SOCK_DGRAM, 0); if (fd < 0) { dsrv_log(LOG_ALERT, "socket: %s\n", strerror(errno)); return 0; } if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on) ) < 0) { dsrv_log(LOG_ALERT, "setsockopt SO_REUSEADDR: %s\n", strerror(errno)); } #if 0 flags = fcntl(fd, F_GETFL, 0); if (flags < 0 || fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { dsrv_log(LOG_ALERT, "fcntl: %s\n", strerror(errno)); goto error; } #endif on = 1; #ifdef IPV6_RECVPKTINFO if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on) ) < 0) { #else /* IPV6_RECVPKTINFO */ if (setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on) ) < 0) { #endif /* IPV6_RECVPKTINFO */ dsrv_log(LOG_ALERT, "setsockopt IPV6_PKTINFO: %s\n", strerror(errno)); } dtls_context = dtls_new_context(&fd); if (!dtls_context) { dsrv_log(LOG_EMERG, "cannot create context\n"); exit(-1); } dtls_set_handler(dtls_context, &cb); dtls_connect(dtls_context, &dst); while (1) { FD_ZERO(&rfds); FD_ZERO(&wfds); FD_SET(fileno(stdin), &rfds); FD_SET(fd, &rfds); /* FD_SET(fd, &wfds); */ timeout.tv_sec = 5; timeout.tv_usec = 0; result = select(fd+1, &rfds, &wfds, 0, &timeout); if (result < 0) { /* error */ if (errno != EINTR) perror("select"); } else if (result == 0) { /* timeout */ } else { /* ok */ if (FD_ISSET(fd, &wfds)) /* FIXME */; else if (FD_ISSET(fd, &rfds)) dtls_handle_read(dtls_context); else if (FD_ISSET(fileno(stdin), &rfds)) handle_stdin(); } if (len) try_send(dtls_context, &dst); } dtls_free_context(dtls_context); exit(0); }
PROCESS_THREAD(cetic_6lbr_process, ev, data) { static struct etimer timer; static int addr_number; PROCESS_BEGIN(); /* Step 0: Basic infrastructure initialization */ LOG6LBR_NOTICE("Starting 6LBR version " CETIC_6LBR_VERSION " (" CONTIKI_VERSION_STRING ")\n"); //Turn off radio until 6LBR is properly configured NETSTACK_MAC.off(0); cetic_6lbr_restart_event = process_alloc_event(); cetic_6lbr_reload_event = process_alloc_event(); cetic_6lbr_startup = clock_seconds(); #if CETIC_6LBR_MULTI_RADIO network_itf_init(); #endif /* Step 1: Platform specific initialization */ platform_init(); /* Step 2: Register configuration hooks and set default configuration */ #if CETIC_6LBR_NODE_INFO node_info_config(); #endif /* Step 3: Load configuration from NVM and configuration file */ platform_load_config(CONFIG_LEVEL_BOOT); #if !LOG6LBR_STATIC if(nvm_data.log_level != 0xFF) { Log6lbr_level = nvm_data.log_level; Log6lbr_services = nvm_data.log_services; } LOG6LBR_NOTICE("Log level: %d (services: %x)\n", Log6lbr_level, Log6lbr_services); #else LOG6LBR_NOTICE("Log level: %d (services: %x)\n", LOG6LBR_LEVEL, LOG6LBR_SERVICE_DEFAULT); #endif /* Step 4: Initialize radio and network interfaces */ #if CETIC_6LBR_FRAMER_WRAPPER framer_wrapper_init(); #endif #if CETIC_6LBR_MAC_WRAPPER mac_wrapper_init(); #endif #if CETIC_6LBR_MULTI_RADIO CETIC_6LBR_MULTI_RADIO_DEFAULT_MAC.init(); #endif #if !CETIC_6LBR_ONE_ITF platform_radio_init(); while(!radio_ready) { PROCESS_PAUSE(); } #endif eth_drv_init(); while(!ethernet_ready) { PROCESS_PAUSE(); } //Turn on radio and keep it always on NETSTACK_MAC.off(1); /* Step 5: Initialize Network stack */ #if CETIC_6LBR_LLSEC_WRAPPER #if CETIC_6LBR_WITH_ADAPTIVESEC llsec_strategy_wrapper_init(); #endif llsec_wrapper_init(); #endif #if CETIC_6LBR_MULTICAST_WRAPPER multicast_wrapper_init(); #endif //6LoWPAN init memcpy(addr_contexts[0].prefix, nvm_data.wsn_6lowpan_context_0, sizeof(addr_contexts[0].prefix)); //clean up any early packet uip_len = 0; process_start(&tcpip_process, NULL); PROCESS_PAUSE(); /* Step 6: Configure network interfaces */ packet_filter_init(); cetic_6lbr_init(); //Wait result of DAD on 6LBR addresses addr_number = uip_ds6_get_addr_number(-1); LOG6LBR_INFO("Checking addresses duplication\n"); etimer_set(&timer, CLOCK_SECOND); while(uip_ds6_get_addr_number(ADDR_TENTATIVE) > 0) { PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); etimer_set(&timer, CLOCK_SECOND); } //Can not use equality as autoconf address could be created when running DAD if(uip_ds6_get_addr_number(-1) < addr_number) { LOG6LBR_FATAL("Addresses duplication failed\n"); cetic_6lbr_restart_type = CETIC_6LBR_RESTART; platform_restart(); } /* Step 7: Finalize configuration of network interfaces */ cetic_6lbr_init_finalize(); /* Step 8: Initialize 6LBR core and base applications */ platform_load_config(CONFIG_LEVEL_CORE); PROCESS_PAUSE(); #if CETIC_6LBR_WITH_WEBSERVER webserver_init(); #endif #if CETIC_6LBR_NODE_INFO node_info_init(); #endif #if CETIC_6LBR_NODE_CONFIG node_config_init(); #endif /* Step 9: Initialize and configure 6LBR applications */ platform_load_config(CONFIG_LEVEL_BASE); PROCESS_PAUSE(); #if CETIC_6LBR_WITH_UDPSERVER udp_server_init(); #endif #if UDPCLIENT process_start(&udp_client_process, NULL); #endif #if WITH_TINYDTLS dtls_init(); #endif #if WITH_COAPSERVER if((nvm_data.global_flags & CETIC_GLOBAL_DISABLE_COAP_SERVER) == 0) { coap_server_init(); } #endif #if WITH_DTLS_ECHO process_start(&dtls_echo_server_process, NULL); #endif #if CETIC_6LBR_WITH_NVM_PROXY nvm_proxy_init(); #endif #if CETIC_6LBR_WITH_DNS_PROXY dns_proxy_init(); #endif /* Step 10: Finalize platform configuration and load runtime configuration */ platform_finalize(); platform_load_config(CONFIG_LEVEL_APP); LOG6LBR_INFO("CETIC 6LBR Started\n"); PROCESS_WAIT_EVENT_UNTIL(ev == cetic_6lbr_restart_event); etimer_set(&timer, CLOCK_SECOND); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); /* Shutdown 6LBR */ //Turn off radio NETSTACK_MAC.off(0); platform_restart(); PROCESS_END(); }
int main() { int result; lwm2m_object_t * objArray[4]; printf("Start\n"); ethSetup(); printf("Initializing tinydtls\n"); // fake loading of PSK.. psk_id_length = strlen(PSK_DEFAULT_IDENTITY); psk_key_length = strlen(PSK_DEFAULT_KEY); memcpy(psk_id, PSK_DEFAULT_IDENTITY, psk_id_length); memcpy(psk_key, PSK_DEFAULT_KEY, psk_key_length); printf("Init\n"); dtls_init(); printf("New context\n"); dtls_context = dtls_new_context(&lwm2mH); if (dtls_context == NULL) { printf("error creating the dtls context\n"); } printf("Setting handlers\n"); dtls_set_handler(dtls_context, &cb); if (!dtls_context) { printf("can't create dtls_context\n"); exit(-1); } printf("Initialazing Wakaama\n"); // create objects objArray[0] = get_security_object(123, "coaps://5.39.83.206:5684", false); securityObjP = objArray[0]; objArray[1] = get_server_object(123, "U", 20, false); serverObject = objArray[1]; objArray[2] = get_object_device(); objArray[3] = get_object_firmware(); /* * The liblwm2m library is now initialized with the functions that will be in * charge of communication */ lwm2mH = lwm2m_init(prv_connect_server, prv_buffer_send, NULL); if (NULL == lwm2mH) { fprintf(stderr, "lwm2m_init() failed\r\n"); return -1; } // configure the liblwm2m lib result = lwm2m_configure(lwm2mH, "julien", NULL, 4, objArray); if (result != 0) { printf("lwm2m_configure() failed: 0x%X\n", result); return -1; } // start result = lwm2m_start(lwm2mH); if (result != 0) { printf("lwm2m_start() failed: 0x%X\n", result); return -1; } // main loop while (true) { char buffer[1024]; Endpoint server; printf("loop...\n"); struct timeval timeout; timeout.tv_sec = 10; timeout.tv_usec = 0; result = lwm2m_step(lwm2mH, &timeout); if (result != 0) { printf("lwm2m_step error %d\n", result); } int n = udp.receiveFrom(server, buffer, sizeof(buffer)); printf("Received packet from: %s of size %d\n", server.get_address(), n); if (n>0) { // TODO: find connection connection_t * connP = connList; while(connP != NULL) { if (strcmp(connP->host, server.get_address()) == 0) { printf("found connection\n"); // is it a secure connection? if (connP->dtlsSession != NULL) { printf("dtls session\n"); result = dtls_handle_message(dtls_context, connP->dtlsSession, buffer, n); printf("dtls handle message %d\n",result); } else { printf("nosec session\n"); lwm2m_handle_packet(lwm2mH, (uint8_t*)buffer, n, (void*)connP); } break; } } if (connP == NULL) printf("no connection\n"); } } }
int main(int argc, char **argv) { dtls_context_t *the_context = NULL; log_t log_level = DTLS_LOG_WARN; fd_set rfds, wfds; struct timeval timeout; int fd, opt, result; int on = 1; int ecdh_anon_enalbe = DTLS_CIPHER_DISABLE; struct sockaddr_in6 listen_addr; memset(&listen_addr, 0, sizeof(struct sockaddr_in6)); /* fill extra field for 4.4BSD-based systems (see RFC 3493, section 3.4) */ #if defined(SIN6_LEN) || defined(HAVE_SOCKADDR_IN6_SIN6_LEN) listen_addr.sin6_len = sizeof(struct sockaddr_in6); #endif listen_addr.sin6_family = AF_INET6; listen_addr.sin6_port = htons(DEFAULT_PORT); listen_addr.sin6_addr = in6addr_any; while ((opt = getopt(argc, argv, "A:p:v:a:")) != -1) { switch (opt) { case 'A' : if (resolve_address(optarg, (struct sockaddr *)&listen_addr) < 0) { fprintf(stderr, "cannot resolve address\n"); exit(-1); } break; case 'p' : listen_addr.sin6_port = htons(atoi(optarg)); break; case 'v' : log_level = strtol(optarg, NULL, 10); break; case 'a': if( strcmp(optarg, "enable") == 0) ecdh_anon_enalbe = DTLS_CIPHER_ENABLE; break; default: usage(argv[0], dtls_package_version()); exit(1); } } dtls_set_log_level(log_level); /* init socket and set it to non-blocking */ fd = socket(listen_addr.sin6_family, SOCK_DGRAM, 0); if (fd < 0) { dtls_alert("socket: %s\n", strerror(errno)); return 0; } if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on) ) < 0) { dtls_alert("setsockopt SO_REUSEADDR: %s\n", strerror(errno)); } #if 0 flags = fcntl(fd, F_GETFL, 0); if (flags < 0 || fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { dtls_alert("fcntl: %s\n", strerror(errno)); goto error; } #endif on = 1; #ifdef IPV6_RECVPKTINFO if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on) ) < 0) { #else /* IPV6_RECVPKTINFO */ if (setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on) ) < 0) { #endif /* IPV6_RECVPKTINFO */ dtls_alert("setsockopt IPV6_PKTINFO: %s\n", strerror(errno)); } if (bind(fd, (struct sockaddr *)&listen_addr, sizeof(listen_addr)) < 0) { dtls_alert("bind: %s\n", strerror(errno)); goto error; } dtls_init(); the_context = dtls_new_context(&fd); /* enable/disable tls_ecdh_anon_with_aes_128_cbc_sha */ dtls_enables_anon_ecdh(the_context, ecdh_anon_enalbe); dtls_set_handler(the_context, &cb); while (1) { FD_ZERO(&rfds); FD_ZERO(&wfds); FD_SET(fd, &rfds); /* FD_SET(fd, &wfds); */ timeout.tv_sec = 5; timeout.tv_usec = 0; result = select( fd+1, &rfds, &wfds, 0, &timeout); if (result < 0) { /* error */ if (errno != EINTR) perror("select"); } else if (result == 0) { /* timeout */ } else { /* ok */ if (FD_ISSET(fd, &wfds)) ; else if (FD_ISSET(fd, &rfds)) { dtls_handle_read(the_context); } } } error: dtls_free_context(the_context); exit(0); }
int main() { signal (SIGINT, sig_handler); wtpconf_preinit(); if (!read_config("./wtp_uci.conf")) { return 1; } // cw_dbg_opt_level = conf_dbg_level; if (!wtpconf_init()){ return 1; }; cw_dbg_opt_display = DBG_DISP_ASC_DMP | DBG_DISP_COLORS; dtls_init(); the_conn = conn_create_noq(-1, NULL); struct conn *conn = the_conn; conn->radios = mbag_i_create(); conn->radios_upd=mbag_i_create(); mbag_i_set_mbag(conn->radios,0,mbag_create()); mbag_i_set_mbag(conn->radios_upd,0,mbag_create()); #define CWMOD "cisco" #define CWBIND "cisco" //#define CWMOD "capwap" //#define CWBIND "capwap80211" struct mod_wtp *mod = modload_wtp(CWMOD); if (!mod) { printf("Can't load mod capwap\n"); exit(0); } mod->init(); mod->register_actions(&capwap_actions,MOD_MODE_CAPWAP); mod = modload_wtp(CWBIND); if (!mod) { printf("Can't load mod capwap80211\n"); exit(0); } int rc = mod->register_actions(&capwap_actions,MOD_MODE_BINDINGS); conn->detected = 1; conn->dtls_verify_peer=0; conn->dtls_mtu = 12000; conn->actions = &capwap_actions; conn->outgoing = mbag_create(); conn->incomming = mbag_create(); conn->local = mbag_create(); conn->config = mbag_create(); the_conn->strict_capwap = 0; cfg_from_json(conn); setup_conf(conn); mbag_t r; // r = mbag_i_get_mbag(conn->radios,0,NULL); r = conn->radios; MAVLITER_DEFINE(it,r); mavliter_foreach(&it){ struct mbag_item *i=mavliter_get(&it); printf("RID = %d\n",i->iid); printf("DATA: %p\n",i->data); mbag_t radio= (mbag_t)i->data; struct mbag_item *mri = mbag_get(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION); if (!mri){ printf("Setting to 8 %p %p\n",mri,r); mbag_set_dword(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION,1); } else{ printf("MRI %p\n",mri); } } mod_init_config(mod,conn->config); cfg_to_json(); mbag_t mb = mbag_get_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, NULL); printf("mbag %p\n", mb); cw_acpriolist_t acprios = cw_acpriolist_create(); cw_acpriolist_set(acprios, "Master AC", strlen("Master AC"), 1); cw_acpriolist_set(acprios, "AC8new", strlen("AC8new"), 12); mbag_set_byte(conn->local, CW_ITEM_WTP_MAC_TYPE, CW_WTP_MAC_TYPE_SPLIT); mbag_set_byte(conn->local, CW_ITEM_WTP_FRAME_TUNNEL_MODE, CW_WTP_FRAME_TUNNEL_MODE_E); conn->wbid=1; // cw_set_msg_end_callback(conn->actions,CW_STATE_RUN,CW_MSG_CONFIGURATION_UPDATE_REQUEST,handle_update_req); if (!discovery()) return -1; if (!join()) return -1; if (!configure()) return -1; cw_dbg(DBG_X,"Saveing config 0"); cfg_to_json(); changestate(); run(); //image_update(); return 0; }