pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/35234?usp=email )


Change subject: examples/stream-* try to support SCTP when called with "-s" 
argument
......................................................................

examples/stream-* try to support SCTP when called with "-s" argument

Change-Id: I4137cdf1e21cb669b632fe5c126ec27475d98400
---
M examples/stream-client.c
M examples/stream-server.c
2 files changed, 44 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/34/35234/1

diff --git a/examples/stream-client.c b/examples/stream-client.c
index 6781c72..e42748f 100644
--- a/examples/stream-client.c
+++ b/examples/stream-client.c
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <netinet/in.h>

 #include <osmocom/core/select.h>
 #include <osmocom/core/talloc.h>
@@ -89,10 +90,21 @@
        return 0;
 }

-int main(void)
+int main(int argc, char **argv)
 {
        struct osmo_fd *kbd_ofd;
-       int rc;
+       bool use_sctp = false;
+       int opt, rc;
+
+       while ((opt = getopt(argc, argv, "s")) != -1) {
+               switch (opt) {
+               case 's':
+                       use_sctp = true;
+                       break;
+               default:
+                       break;
+               }
+       }

        tall_test = talloc_named_const(NULL, 1, "osmo_stream_cli_test");
        msgb_talloc_ctx_init(tall_test, 0);
@@ -111,12 +123,16 @@
        osmo_stream_cli_set_name(conn, "stream_client");
        osmo_stream_cli_set_addr(conn, "127.0.0.1");
        osmo_stream_cli_set_port(conn, 10000);
+       if (use_sctp)
+               osmo_stream_cli_set_proto(conn, IPPROTO_SCTP);
+
        osmo_stream_cli_set_connect_cb(conn, connect_cb);
        osmo_stream_cli_set_disconnect_cb(conn, disconnect_cb);
        osmo_stream_cli_set_read_cb2(conn, read_cb);

-       if (osmo_stream_cli_open(conn) < 0) {
-               fprintf(stderr, "cannot open cli\n");
+       rc = osmo_stream_cli_open(conn);
+       if (rc < 0) {
+               fprintf(stderr, "cannot open cli: %d\n", rc);
                exit(EXIT_FAILURE);
        }

diff --git a/examples/stream-server.c b/examples/stream-server.c
index 8aa8b9b..9faf307 100644
--- a/examples/stream-server.c
+++ b/examples/stream-server.c
@@ -117,9 +117,21 @@
        return 0;
 }

-int main(void)
+int main(int argc, char **argv)
 {
        struct osmo_fd *kbd_ofd;
+       bool use_sctp = false;
+       int opt;
+
+       while ((opt = getopt(argc, argv, "s")) != -1) {
+               switch (opt) {
+               case 's':
+                       use_sctp = true;
+                       break;
+               default:
+                       break;
+               }
+       }

        tall_test = talloc_named_const(NULL, 1, "osmo_stream_srv_test");
        msgb_talloc_ctx_init(tall_test, 0);
@@ -137,6 +149,8 @@
        }
        osmo_stream_srv_link_set_addr(srv, "127.0.0.1");
        osmo_stream_srv_link_set_port(srv, 10000);
+       if (use_sctp)
+               osmo_stream_srv_link_set_proto(srv, IPPROTO_SCTP);
        osmo_stream_srv_link_set_accept_cb(srv, accept_cb);

        if (osmo_stream_srv_link_open(srv) < 0) {

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/35234?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I4137cdf1e21cb669b632fe5c126ec27475d98400
Gerrit-Change-Number: 35234
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-CC: laforge <lafo...@osmocom.org>
Gerrit-MessageType: newchange

Reply via email to