diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index 400cd39b4..000993ab9 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -38,7 +38,8 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - const char *locator = NULL; + const char *clocator = NULL; + const char *llocator = NULL; const char *value = NULL; int opt; @@ -48,14 +49,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -74,8 +74,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 5697d5c4f..2740d5110 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -29,20 +29,20 @@ void print_zid(const z_id_t *id, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index cc4252b24..e4f96b7ea 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -27,7 +27,8 @@ int main(int argc, char **argv) { char *const default_value = "Pub from Pico!"; char *value = default_value; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int n = 10; int opt; @@ -40,14 +41,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'n': n = atoi(optarg); @@ -66,8 +66,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index c8440b2e9..f2b0fef79 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index c4aca1cc9..0445d48f9 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 392778381..31a7d10ba 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -38,7 +38,8 @@ void query_handler(const z_query_t *query, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { @@ -47,14 +48,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -73,8 +73,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index d004ead95..7b097fe72 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 103c68a06..567290484 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index b7097b445..65e22f91b 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -38,7 +38,8 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - const char *locator = NULL; + const char *clocator = NULL; + const char *llocator = NULL; const char *value = NULL; int opt; @@ -48,14 +49,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -74,8 +74,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index 0497ea6f8..901587bd8 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -29,20 +29,20 @@ void print_zid(const z_id_t *id, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index bd83501f5..8ee66dfdb 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_pub_st.c b/examples/unix/c99/z_pub_st.c index 36ec2457f..96eeba2a4 100644 --- a/examples/unix/c99/z_pub_st.c +++ b/examples/unix/c99/z_pub_st.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 461fa7a32..be22b6eea 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index 9a76be6d7..8ddcf74e6 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -34,7 +34,8 @@ void query_handler(const z_query_t *query, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + const char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { @@ -49,11 +50,10 @@ int main(int argc, char **argv) { mode = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { @@ -69,8 +69,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index a04d9e03c..0f616525f 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *arg) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index e3f7f6dec..fac31bd46 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *arg) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/src/net/session.c b/src/net/session.c index 28ceb6725..e00988f10 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -16,7 +16,10 @@ #include #include +#include "zenoh-pico/api/primitives.h" #include "zenoh-pico/collections/bytes.h" +#include "zenoh-pico/collections/string.h" +#include "zenoh-pico/config.h" #include "zenoh-pico/net/memory.h" #include "zenoh-pico/protocol/core.h" #include "zenoh-pico/session/utils.h" @@ -61,7 +64,9 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { if (config != NULL) { _z_str_array_t locators = _z_str_array_empty(); - if (_z_config_get(config, Z_CONFIG_CONNECT_KEY) == NULL) { // Scout if peer is not configured + char *connect = _z_config_get(config, Z_CONFIG_CONNECT_KEY); + char *listen = _z_config_get(config, Z_CONFIG_CONNECT_KEY); + if (connect == NULL && listen == NULL) { // Scout if peer is not configured opt_as_str = _z_config_get(config, Z_CONFIG_SCOUTING_WHAT_KEY); if (opt_as_str == NULL) { opt_as_str = Z_CONFIG_SCOUTING_WHAT_DEFAULT; @@ -88,8 +93,17 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { } _z_hello_list_free(&hellos); } else { + int key = Z_CONFIG_CONNECT_KEY; + if (listen != NULL) { + if (connect == NULL) { + key = Z_CONFIG_LISTEN_KEY; + _zp_config_insert(config, Z_CONFIG_MODE_KEY, _z_string_make(Z_CONFIG_MODE_PEER)); + } else { + return _Z_ERR_GENERIC; + } + } locators = _z_str_array_make(1); - locators.val[0] = _z_str_clone(_z_config_get(config, Z_CONFIG_CONNECT_KEY)); + locators.val[0] = _z_str_clone(_z_config_get(config, key)); } ret = _Z_ERR_SCOUT_NO_RESULTS; diff --git a/zenohpico.pc b/zenohpico.pc index 743095b12..3254c5f2a 100644 --- a/zenohpico.pc +++ b/zenohpico.pc @@ -3,6 +3,6 @@ prefix=/usr/local Name: zenohpico Description: URL: -Version: 0.10.20230913dev +Version: 0.10.20230915dev Cflags: -I${prefix}/ Libs: -L${prefix}/ -lzenohpico