This is used together with delta update to get where the ZCLK file is
stored. In many case, as with Hawkbit, the URL is not known at build
time and cannot be stored into sw-description. Hawkbit generates a URL
when the file is uploaded, and sends this URL back in the list of
Software Modules. SWUpdate had ignored this as it is not a SWU file.
By adding rules for files in Hawkbiot connector, suricatta sends the
list of received URLs to the core, anbd this can be used later by a
handler (delta) when it runs.
Signed-off-by: Stefano Babic <
stefan...@swupdate.org>
---
core/installer.c | 5 +++++
core/network_thread.c | 17 +++++++++++++++++
include/network_ipc.h | 7 +++++++
include/swupdate.h | 1 +
ipc/network_ipc-if.c | 17 +++++++++++++++++
suricatta/server_hawkbit.c | 4 ++--
6 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/core/installer.c b/core/installer.c
index 29d5ed83..e87474b0 100644
--- a/core/installer.c
+++ b/core/installer.c
@@ -557,6 +557,11 @@ void cleanup_files(struct swupdate_cfg *software) {
dict_drop_db(&software->bootloader);
dict_drop_db(&software->vars);
+ /*
+ * Drop per update URLs
+ */
+ dict_drop_db(&software->external_urls);
+
/*
* Drop Lua State if instantiated
*/
diff --git a/core/network_thread.c b/core/network_thread.c
index 6d4c259a..45ce48a3 100644
--- a/core/network_thread.c
+++ b/core/network_thread.c
@@ -629,6 +629,23 @@ void *network_thread (void *data)
} else
msg.type = NACK;
break;
+ case SET_DELTA_URL:
+ cfg = get_swupdate_cfg();
+
+ /*
+ * check strings in IPC
+ */
+ msg.data.dwl_url.filename[sizeof(msg.data.dwl_url.filename) - 1] = '\0';
+ msg.data.dwl_url.url[sizeof(msg.data.dwl_url.url) - 1] = '\0';
+ /*
+ * Check for mutex: there is currently no other users, one writer and one reader
+ * for the list (the handler).
+ */
+ TRACE("EXTERNAL URL: %s:%s",msg.data.dwl_url.filename, msg.data.dwl_url.url );
+ msg.type = dict_insert_value(&cfg->external_urls,
+ msg.data.dwl_url.filename,
+ msg.data.dwl_url.url) == 0 ? ACK : NACK;
+ break;
default:
msg.type = NACK;
}
diff --git a/include/network_ipc.h b/include/network_ipc.h
index 8eb64cdf..813ffce0 100644
--- a/include/network_ipc.h
+++ b/include/network_ipc.h
@@ -40,6 +40,7 @@ typedef enum {
GET_HW_REVISION,
SET_SWUPDATE_VARS,
GET_SWUPDATE_VARS,
+ SET_DELTA_URL,
} msgtype;
/*
@@ -127,6 +128,10 @@ typedef union {
char varname[256];
char varvalue[256];
} vars;
+ struct {
+ char filename[256];
+ char url[1024];
+ } dwl_url;
} msgdata;
typedef struct {
@@ -164,6 +169,8 @@ int swupdate_set_version_range_type(const char *updatetype,
const char *minversion,
const char *maxversion,
const char *currentversion);
+int swupdate_dwl_url (const char *artifact_name, const char *url);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/swupdate.h b/include/swupdate.h
index 59b085b6..9f98a29e 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -104,6 +104,7 @@ struct swupdate_cfg {
struct dict bootloader;
struct dict vars;
struct dict accepted_set;
+ struct dict external_urls;
struct proclist extprocs;
void *dgst; /* Structure for signed images */
struct swupdate_parms parms;
diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c
index cd0d4e5d..732f3ad5 100644
--- a/ipc/network_ipc-if.c
+++ b/ipc/network_ipc-if.c
@@ -405,6 +405,23 @@ int swupdate_set_version_range(const char *minversion,
NULL);
}
+int swupdate_dwl_url (const char *artifact_name, const char *url)
+{
+ ipc_message msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.magic = IPC_MAGIC;
+ msg.type = SET_DELTA_URL;
+
+ strlcpy(msg.data.dwl_url.filename,
+ artifact_name,
+ sizeof(msg.data.dwl_url.filename) - 1);
+ strlcpy(msg.data.dwl_url.url,
+ url,
+ sizeof(msg.data.dwl_url.url) - 1);
+ return ipc_send_cmd(&msg);
+}
+
void swupdate_prepare_req(struct swupdate_request *req) {
if (!req)
return;
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index c7b3f1fc..84ec3600 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -49,8 +49,8 @@ static bool swu_rule(artifact_t __attribute__ ((__unused__)) *artifact) {
return true;
}
static bool zck_rule(artifact_t *artifact) {
- artifact = artifact;
- return true;
+ artifact->skip = true;
+ return swupdate_dwl_url(artifact->filename, artifact->url);
}
static bool reject_rule(artifact_t __attribute__ ((__unused__)) *artifact) {
return false;
--
2.43.0