static void delete_cb(void *data, const struct sol_http_progressive_response *sse) { sol_ptr_vector_remove(&responses, sse); if (should_quit && !sol_ptr_vector_get_len(&responses)) sol_quit(); }
static int bootstrap_request(void *data, struct sol_coap_server *coap, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr) { struct sol_lwm2m_bootstrap_client_info *bs_cinfo; struct sol_lwm2m_bootstrap_server *server = data; struct sol_coap_packet *response; struct sol_str_slice client_name = SOL_STR_SLICE_EMPTY; int r; size_t i; bool know_client = false; SOL_DBG("Client Bootstrap Request received"); response = sol_coap_packet_new(req); SOL_NULL_CHECK(response, -ENOMEM); r = extract_bootstrap_client_info(req, &client_name); SOL_INT_CHECK_GOTO(r, < 0, err_exit); for (i = 0; server->known_clients[i]; i++) { if (sol_str_slice_str_eq(client_name, server->known_clients[i])) know_client = true; } if (!know_client) { SOL_WRN("Client %.*s bootstrap request received, but this Bootstrap Server" " doesn't have Bootstrap Information for this client.", SOL_STR_SLICE_PRINT(client_name)); goto err_exit; } r = new_bootstrap_client_info(&bs_cinfo, cliaddr, client_name); SOL_INT_CHECK_GOTO(r, < 0, err_exit); r = sol_ptr_vector_append(&server->clients, bs_cinfo); SOL_INT_CHECK_GOTO(r, < 0, err_exit_del_client); r = sol_coap_header_set_code(response, SOL_COAP_RESPONSE_CODE_CHANGED); SOL_INT_CHECK_GOTO(r, < 0, err_exit_del_client_list); SOL_DBG("Client %s bootstrap request received." " Bootstrap Process will start now.", bs_cinfo->name); r = sol_coap_send_packet(coap, response, cliaddr); dispatch_bootstrap_event_to_server(server, bs_cinfo); return r; err_exit_del_client_list: sol_ptr_vector_remove(&server->clients, bs_cinfo); err_exit_del_client: bootstrap_client_info_del(bs_cinfo); err_exit: sol_coap_header_set_code(response, SOL_COAP_RESPONSE_CODE_BAD_REQUEST); sol_coap_send_packet(coap, response, cliaddr); return r; }