X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-unit.c;h=e01faa9116f3fe505da716b856a2922c1e453bde;hb=6008a3ec4d1c0ed5df338b7c5f0775585ab51cfb;hp=cca718f32db911a298921be134572d89fd05cca8;hpb=9e6f77ae43af16d2af9bdb1ae8d20aed5deaac7d;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-unit.c b/src/wgtpkg-unit.c index cca718f..e01faa9 100644 --- a/src/wgtpkg-unit.c +++ b/src/wgtpkg-unit.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2016, 2017, 2018 IoT.bzh + Copyright (C) 2016-2019 IoT.bzh author: José Bollo @@ -375,18 +375,28 @@ int unit_generator_open_template(const char *filename) static int add_metadata(struct json_object *jdesc, const struct unitconf *conf) { struct json_object *targets, *targ; - char portstr[30]; - int port, i, n; + char portstr[30], afidstr[30]; + int port, afid, i, n; if (json_object_object_get_ex(jdesc, string_targets, &targets)) { n = json_object_array_length(targets); for (i = 0 ; i < n ; i++) { targ = json_object_array_get_idx(targets, i); - port = conf->port(); - if (port < 0) - return port; + if (!conf->new_afid) { + afid = 0; + port = 0; + } else { + afid = conf->new_afid(); + if (afid < 0) + return afid; + port = conf->base_http_ports + afid; + } + sprintf(afidstr, "%d", afid); sprintf(portstr, "%d", port); - if (!j_add_string_m(targ, "#metatarget.http-port", portstr)) + if (!j_add_many_strings_m(targ, + "#metatarget.http-port", portstr, + "#metatarget.afid", afidstr, + NULL)) return -1; } }