Lines Matching +full:url +full:- +full:base
2 * Copyright (c) 2016-2017 Linaro Limited
6 * Copyright (c) 2021 G-Technologies Sdn. Bhd.
8 * SPDX-License-Identifier: Apache-2.0
47 #define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8"
137 struct hawkbit_ctl_res base; member
203 JSON_OBJ_DESCR_OBJECT_NAMED(struct hawkbit_dep_res_links, "download-http", download_http,
205 JSON_OBJ_DESCR_OBJECT_NAMED(struct hawkbit_dep_res_links, "md5sum-http", md5sum_http,
250 return -EINVAL; in hawkbit_settings_set()
265 return -EINVAL; in hawkbit_settings_set()
279 return -EINVAL; in hawkbit_settings_set()
302 return -EINVAL; in hawkbit_settings_set()
322 return -ENOENT; in hawkbit_settings_set()
346 int ret = -1; in start_http_client()
360 while (resolve_attempts--) { in start_http_client()
374 hb_context.sock = zsock_socket(addr->ai_family, SOCK_STREAM, protocol); in start_http_client()
396 if (zsock_connect(hb_context.sock, addr->ai_addr, addr->ai_addrlen) < 0) { in start_http_client()
428 return -1; in hawkbit_time2sec()
480 return -EIO; in hawkbit_device_acid_update()
495 return -EAGAIN; in hawkbit_reset_action_id()
504 * Update sleep interval, based on results from hawkBit base polling
510 const char *sleep = hawkbit_res->config.polling.sleep; in hawkbit_update_sleep()
524 * Find URL component for the device cancel operation and action id
532 href = res->_links.cancelAction.href; in hawkbit_find_cancelAction_base()
542 /* A badly formatted cancel base is a server error */ in hawkbit_find_cancelAction_base()
544 return -EINVAL; in hawkbit_find_cancelAction_base()
548 if (len > CANCEL_BASE_SIZE - 1) { in hawkbit_find_cancelAction_base()
551 CANCEL_BASE_SIZE - 1); in hawkbit_find_cancelAction_base()
552 return -ENOMEM; in hawkbit_find_cancelAction_base()
559 return -EINVAL; in hawkbit_find_cancelAction_base()
564 return -EINVAL; in hawkbit_find_cancelAction_base()
570 return -EINVAL; in hawkbit_find_cancelAction_base()
577 * Find URL component for the device's deployment operations
586 href = res->_links.deploymentBase.href; in hawkbit_find_deployment_base()
596 /* A badly formatted deployment base is a server error */ in hawkbit_find_deployment_base()
598 return -EINVAL; in hawkbit_find_deployment_base()
602 if (len > DEPLOYMENT_BASE_SIZE - 1) { in hawkbit_find_deployment_base()
605 DEPLOYMENT_BASE_SIZE - 1); in hawkbit_find_deployment_base()
606 return -ENOMEM; in hawkbit_find_deployment_base()
614 * Find URL component for this device's deployment operations
628 hb_context.action_id = strtol(res->id, &endptr, 10); in hawkbit_parse_deployment()
631 return -EINVAL; in hawkbit_parse_deployment()
636 num_chunks = res->deployment.num_chunks; in hawkbit_parse_deployment()
639 return -ENOSPC; in hawkbit_parse_deployment()
642 chunk = &res->deployment.chunks[0]; in hawkbit_parse_deployment()
643 if (strcmp("bApp", chunk->part)) { in hawkbit_parse_deployment()
644 LOG_ERR("Only part 'bApp' is supported; got %s", chunk->part); in hawkbit_parse_deployment()
645 return -EINVAL; in hawkbit_parse_deployment()
648 num_artifacts = chunk->num_artifacts; in hawkbit_parse_deployment()
651 return -EINVAL; in hawkbit_parse_deployment()
654 artifact = &chunk->artifacts[0]; in hawkbit_parse_deployment()
655 if (hex2bin(artifact->hashes.sha256, SHA256_HASH_SIZE << 1, hb_context.dl.file_hash, in hawkbit_parse_deployment()
657 return -EINVAL; in hawkbit_parse_deployment()
660 size = artifact->size; in hawkbit_parse_deployment()
664 return -ENOSPC; in hawkbit_parse_deployment()
668 * Find the download-http href. We only support the DEFAULT in hawkbit_parse_deployment()
671 href = artifact->_links.download_http.href; in hawkbit_parse_deployment()
673 LOG_ERR("Missing expected %s href", "download-http"); in hawkbit_parse_deployment()
674 return -EINVAL; in hawkbit_parse_deployment()
679 LOG_ERR("Unexpected %s href format: %s", "download-http", helper); in hawkbit_parse_deployment()
680 return -EINVAL; in hawkbit_parse_deployment()
685 LOG_ERR("Empty %s", "download-http"); in hawkbit_parse_deployment()
686 return -EINVAL; in hawkbit_parse_deployment()
687 } else if (len > DOWNLOAD_HTTP_SIZE - 1) { in hawkbit_parse_deployment()
688 LOG_ERR("%s %s is too big (len %zu, max %zu)", "download-http", helper, len, in hawkbit_parse_deployment()
689 DOWNLOAD_HTTP_SIZE - 1); in hawkbit_parse_deployment()
690 return -ENOMEM; in hawkbit_parse_deployment()
701 struct hawkbit_dep_res_chunk *c = &d->deployment.chunks[0]; in hawkbit_dump_deployment()
702 struct hawkbit_dep_res_arts *a = &c->artifacts[0]; in hawkbit_dump_deployment()
703 struct hawkbit_dep_res_links *l = &a->_links; in hawkbit_dump_deployment()
705 LOG_DBG("%s=%s", "id", d->id); in hawkbit_dump_deployment()
706 LOG_DBG("%s=%s", "download", d->deployment.download); in hawkbit_dump_deployment()
707 LOG_DBG("%s=%s", "update", d->deployment.update); in hawkbit_dump_deployment()
708 LOG_DBG("chunks[0].%s=%s", "part", c->part); in hawkbit_dump_deployment()
709 LOG_DBG("chunks[0].%s=%s", "name", c->name); in hawkbit_dump_deployment()
710 LOG_DBG("chunks[0].%s=%s", "version", c->version); in hawkbit_dump_deployment()
711 LOG_DBG("chunks[0].artifacts[0].%s=%s", "filename", a->filename); in hawkbit_dump_deployment()
712 LOG_DBG("chunks[0].artifacts[0].%s=%s", "hashes.sha1", a->hashes.sha1); in hawkbit_dump_deployment()
713 LOG_DBG("chunks[0].artifacts[0].%s=%s", "hashes.md5", a->hashes.md5); in hawkbit_dump_deployment()
714 LOG_DBG("chunks[0].artifacts[0].%s=%s", "hashes.sha256", a->hashes.sha256); in hawkbit_dump_deployment()
715 LOG_DBG("chunks[0].size=%d", a->size); in hawkbit_dump_deployment()
716 LOG_DBG("%s=%s", "download-http", l->download_http.href); in hawkbit_dump_deployment()
717 LOG_DBG("%s=%s", "md5sum-http", l->md5sum_http.href); in hawkbit_dump_deployment()
725 return -EINVAL; in hawkbit_set_custom_data_cb()
732 return -ENOTSUP; in hawkbit_set_custom_data_cb()
750 if (config->server_addr != NULL) { in hawkbit_set_config()
751 strncpy(hb_cfg.server_addr, config->server_addr, in hawkbit_set_config()
755 if (config->server_port != 0) { in hawkbit_set_config()
757 config->server_port); in hawkbit_set_config()
761 if (config->auth_token != NULL) { in hawkbit_set_config()
762 strncpy(hb_cfg.ddi_security_token, config->auth_token, in hawkbit_set_config()
769 if (config->tls_tag != 0) { in hawkbit_set_config()
770 hb_cfg.tls_tag = config->tls_tag; in hawkbit_set_config()
778 return -EAGAIN; in hawkbit_set_config()
866 if (rsp->http_status_code != 200) { in response_cb()
867 LOG_ERR("HTTP request denied (%s): %d", (char *)userdata, rsp->http_status_code); in response_cb()
868 if (rsp->http_status_code == 401 || rsp->http_status_code == 403) { in response_cb()
879 hb_context.dl.http_content_size = rsp->content_length; in response_cb()
882 if (rsp->body_found) { in response_cb()
883 body_data = rsp->body_frag_start; in response_cb()
884 body_len = rsp->body_frag_len; in response_cb()
914 ARRAY_SIZE(json_ctl_res_descr), &hawkbit_results.base); in response_cb()
930 hb_context.dl.http_content_size = rsp->content_length; in response_cb()
933 if (rsp->body_found) { in response_cb()
934 body_data = rsp->body_frag_start; in response_cb()
935 body_len = rsp->body_frag_len; in response_cb()
976 hb_context.dl.http_content_size = rsp->content_length; in response_cb()
979 if (rsp->body_found) { in response_cb()
980 body_data = rsp->body_frag_start; in response_cb()
981 body_len = rsp->body_frag_len; in response_cb()
1015 char header[DDI_SECURITY_TOKEN_SIZE + sizeof(AUTH_HEADER_START) + sizeof(HTTP_CRLF) - 1]; in send_request()
1026 hb_context.http_req.url = hb_context.url_buffer; in send_request()
1120 * Resource for software module (Deployment Base) in send_request()
1173 * Resource for software module (Deployment Base) in send_request()
1278 * Query the hawkBit base polling resource. in hawkbit_probe()
1285 snprintk(hb_context.url_buffer, sizeof(hb_context.url_buffer), "%s/%s-%s", in hawkbit_probe()
1287 memset(&hawkbit_results.base, 0, sizeof(hawkbit_results.base)); in hawkbit_probe()
1301 if (hawkbit_results.base.config.polling.sleep) { in hawkbit_probe()
1303 hawkbit_update_sleep(&hawkbit_results.base); in hawkbit_probe()
1304 LOG_DBG("config.polling.sleep=%s", hawkbit_results.base.config.polling.sleep); in hawkbit_probe()
1308 if (hawkbit_results.base._links.cancelAction.href) { in hawkbit_probe()
1309 ret = hawkbit_find_cancelAction_base(&hawkbit_results.base, cancel_base); in hawkbit_probe()
1313 "%s/%s-%s/%s/feedback", HAWKBIT_JSON_URL, CONFIG_BOARD, device_id, in hawkbit_probe()
1328 if (hawkbit_results.base._links.configData.href) { in hawkbit_probe()
1330 hawkbit_results.base._links.configData.href); in hawkbit_probe()
1333 snprintk(hb_context.url_buffer, sizeof(hb_context.url_buffer), "%s/%s-%s/%s", in hawkbit_probe()
1344 ret = hawkbit_find_deployment_base(&hawkbit_results.base, deployment_base); in hawkbit_probe()
1347 LOG_ERR("Unable to find URL for the device's deploymentBase: %d", ret); in hawkbit_probe()
1359 snprintk(hb_context.url_buffer, sizeof(hb_context.url_buffer), "%s/%s-%s/%s", in hawkbit_probe()
1390 "%s/%s-%s/%s/%d/feedback", HAWKBIT_JSON_URL, CONFIG_BOARD, in hawkbit_probe()