aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/ipa-stream-client.c28
-rw-r--r--examples/ipa-stream-server.c50
-rw-r--r--examples/stream-client.c40
-rw-r--r--examples/stream-server.c46
4 files changed, 82 insertions, 82 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c
index 9302825..b771fa3 100644
--- a/examples/ipa-stream-client.c
+++ b/examples/ipa-stream-client.c
@@ -43,7 +43,7 @@ const struct log_info osmo_stream_client_test_log_info = {
.num_cat = ARRAY_SIZE(osmo_stream_client_test_cat),
};
-static struct osmo_stream_client_conn *conn;
+static struct osmo_stream_cli *conn;
void sighandler(int foo)
{
@@ -51,9 +51,9 @@ void sighandler(int foo)
exit(EXIT_SUCCESS);
}
-static int connect_cb(struct osmo_stream_client_conn *conn)
+static int connect_cb(struct osmo_stream_cli *conn)
{
- int *__num_msgs = osmo_stream_client_conn_get_data(conn);
+ int *__num_msgs = osmo_stream_cli_get_data(conn);
int num_msgs = *__num_msgs, i;
LOGP(DIPATEST, LOGL_NOTICE, "connected\n");
@@ -85,7 +85,7 @@ static int connect_cb(struct osmo_stream_client_conn *conn)
osmo_ipa_msg_push_header(msg, IPAC_PROTO_OSMO);
- osmo_stream_client_conn_send(conn, msg);
+ osmo_stream_cli_send(conn, msg);
LOGP(DIPATEST, LOGL_DEBUG, "enqueueing msg %d of "
"%d bytes to be sent\n", i, msg->len);
@@ -93,10 +93,10 @@ static int connect_cb(struct osmo_stream_client_conn *conn)
return 0;
}
-static int read_cb(struct osmo_stream_client_conn *conn)
+static int read_cb(struct osmo_stream_cli *conn)
{
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_client_conn_get_ofd(conn);
+ struct osmo_fd *ofd = osmo_stream_cli_get_ofd(conn);
LOGP(DIPATEST, LOGL_DEBUG, "received message from stream\n");
@@ -162,24 +162,24 @@ int main(int argc, char *argv[])
* initialize stream client.
*/
- conn = osmo_stream_client_conn_create(tall_test);
+ conn = osmo_stream_cli_create(tall_test);
if (conn == NULL) {
fprintf(stderr, "cannot create client\n");
exit(EXIT_FAILURE);
}
- osmo_stream_client_conn_set_addr(conn, "127.0.0.1");
- osmo_stream_client_conn_set_port(conn, 10000);
- osmo_stream_client_conn_set_connect_cb(conn, connect_cb);
- osmo_stream_client_conn_set_read_cb(conn, read_cb);
- osmo_stream_client_conn_set_data(conn, &num_msgs);
+ osmo_stream_cli_set_addr(conn, "127.0.0.1");
+ osmo_stream_cli_set_port(conn, 10000);
+ osmo_stream_cli_set_connect_cb(conn, connect_cb);
+ osmo_stream_cli_set_read_cb(conn, read_cb);
+ osmo_stream_cli_set_data(conn, &num_msgs);
- if (osmo_stream_client_conn_open(conn) < 0) {
+ if (osmo_stream_cli_open(conn) < 0) {
fprintf(stderr, "cannot open client\n");
exit(EXIT_FAILURE);
}
int on = 1, ret;
- struct osmo_fd *ofd = osmo_stream_client_conn_get_ofd(conn);
+ struct osmo_fd *ofd = osmo_stream_cli_get_ofd(conn);
ret = setsockopt(ofd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
if (ret < 0) {
diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c
index 5dfd4c9..69e0280 100644
--- a/examples/ipa-stream-server.c
+++ b/examples/ipa-stream-server.c
@@ -1,4 +1,4 @@
-/* IPA stream server example */
+/* IPA stream srv example */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -19,7 +19,7 @@ static void *tall_test;
#define DSTREAMTEST 0
-struct log_info_cat osmo_stream_server_test_cat[] = {
+struct log_info_cat osmo_stream_srv_test_cat[] = {
[DSTREAMTEST] = {
.name = "DSTREAMTEST",
.description = "STREAMSERVER-mode test",
@@ -28,14 +28,14 @@ struct log_info_cat osmo_stream_server_test_cat[] = {
},
};
-const struct log_info osmo_stream_server_test_log_info = {
+const struct log_info osmo_stream_srv_test_log_info = {
.filter_fn = NULL,
- .cat = osmo_stream_server_test_cat,
- .num_cat = ARRAY_SIZE(osmo_stream_server_test_cat),
+ .cat = osmo_stream_srv_test_cat,
+ .num_cat = ARRAY_SIZE(osmo_stream_srv_test_cat),
};
-static struct osmo_stream_server_link *server;
-static struct osmo_stream_server_conn *conn;
+static struct osmo_stream_srv_link *srv;
+static struct osmo_stream_srv *conn;
void sighandler(int foo)
{
@@ -43,10 +43,10 @@ void sighandler(int foo)
exit(EXIT_SUCCESS);
}
-int read_cb(struct osmo_stream_server_conn *conn)
+int read_cb(struct osmo_stream_srv *conn)
{
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_server_conn_get_ofd(conn);
+ struct osmo_fd *ofd = osmo_stream_srv_get_ofd(conn);
LOGP(DSTREAMTEST, LOGL_DEBUG, "received message from stream\n");
@@ -57,21 +57,21 @@ int read_cb(struct osmo_stream_server_conn *conn)
}
if (osmo_ipa_msg_recv(ofd->fd, msg) <= 0) {
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n");
- osmo_stream_server_conn_destroy(conn);
+ osmo_stream_srv_destroy(conn);
msgb_free(msg);
return 0;
}
- osmo_stream_server_conn_send(conn, msg);
+ osmo_stream_srv_send(conn, msg);
return 0;
}
-static int close_cb(struct osmo_stream_server_conn *dummy)
+static int close_cb(struct osmo_stream_srv *dummy)
{
conn = NULL;
return 0;
}
-static int accept_cb(struct osmo_stream_server_link *server, int fd)
+static int accept_cb(struct osmo_stream_srv_link *srv, int fd)
{
if (conn != NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR, "Sorry, this example only "
@@ -79,8 +79,8 @@ static int accept_cb(struct osmo_stream_server_link *server, int fd)
return -1;
}
- conn = osmo_stream_server_conn_create(tall_test, server, fd,
- read_cb, close_cb, NULL);
+ conn = osmo_stream_srv_create(tall_test, srv, fd,
+ read_cb, close_cb, NULL);
if (conn == NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR,
"error while creating connection\n");
@@ -92,28 +92,28 @@ static int accept_cb(struct osmo_stream_server_link *server, int fd)
int main(void)
{
- tall_test = talloc_named_const(NULL, 1, "osmo_stream_server_test");
+ tall_test = talloc_named_const(NULL, 1, "osmo_stream_srv_test");
- osmo_init_logging(&osmo_stream_server_test_log_info);
+ osmo_init_logging(&osmo_stream_srv_test_log_info);
log_set_log_level(osmo_stderr_target, LOGL_NOTICE);
/*
- * initialize stream server.
+ * initialize stream srv.
*/
- server = osmo_stream_server_link_create(tall_test);
- if (server == NULL) {
+ srv = osmo_stream_srv_link_create(tall_test);
+ if (srv == NULL) {
fprintf(stderr, "cannot create client\n");
exit(EXIT_FAILURE);
}
- osmo_stream_server_link_set_addr(server, "127.0.0.1");
- osmo_stream_server_link_set_port(server, 10000);
- osmo_stream_server_link_set_accept_cb(server, accept_cb);
+ osmo_stream_srv_link_set_addr(srv, "127.0.0.1");
+ osmo_stream_srv_link_set_port(srv, 10000);
+ osmo_stream_srv_link_set_accept_cb(srv, accept_cb);
int on = 1, ret;
- struct osmo_fd *ofd = osmo_stream_server_link_get_ofd(server);
+ struct osmo_fd *ofd = osmo_stream_srv_link_get_ofd(srv);
- if (osmo_stream_server_link_open(server) < 0) {
+ if (osmo_stream_srv_link_open(srv) < 0) {
fprintf(stderr, "cannot open client\n");
exit(EXIT_FAILURE);
}
diff --git a/examples/stream-client.c b/examples/stream-client.c
index 8836223..a1f57b0 100644
--- a/examples/stream-client.c
+++ b/examples/stream-client.c
@@ -14,7 +14,7 @@
#define DSTREAMTEST 0
-struct log_info_cat osmo_stream_client_test_cat[] = {
+struct log_info_cat osmo_stream_cli_test_cat[] = {
[DSTREAMTEST] = {
.name = "DSTREAMTEST",
.description = "STREAMCLIENT-mode test",
@@ -23,13 +23,13 @@ struct log_info_cat osmo_stream_client_test_cat[] = {
},
};
-const struct log_info osmo_stream_client_test_log_info = {
+const struct log_info osmo_stream_cli_test_log_info = {
.filter_fn = NULL,
- .cat = osmo_stream_client_test_cat,
- .num_cat = ARRAY_SIZE(osmo_stream_client_test_cat),
+ .cat = osmo_stream_cli_test_cat,
+ .num_cat = ARRAY_SIZE(osmo_stream_cli_test_cat),
};
-static struct osmo_stream_client_conn *conn;
+static struct osmo_stream_cli *conn;
void sighandler(int foo)
{
@@ -37,13 +37,13 @@ void sighandler(int foo)
exit(EXIT_SUCCESS);
}
-static int connect_cb(struct osmo_stream_client_conn *conn)
+static int connect_cb(struct osmo_stream_cli *conn)
{
LOGP(DSTREAMTEST, LOGL_NOTICE, "connected\n");
return 0;
}
-static int read_cb(struct osmo_stream_client_conn *conn)
+static int read_cb(struct osmo_stream_cli *conn)
{
struct msgb *msg;
@@ -54,7 +54,7 @@ static int read_cb(struct osmo_stream_client_conn *conn)
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- if (osmo_stream_client_conn_recv(conn, msg) < 0) {
+ if (osmo_stream_cli_recv(conn, msg) < 0) {
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n");
return 0;
}
@@ -83,7 +83,7 @@ static int kbd_cb(struct osmo_fd *fd, unsigned int what)
ptr = msgb_put(msg, strlen(buf));
memcpy(ptr, buf, ret);
- osmo_stream_client_conn_send(conn, msg);
+ osmo_stream_cli_send(conn, msg);
LOGP(DSTREAMTEST, LOGL_NOTICE, "message of %d bytes sent\n", msg->len);
@@ -94,27 +94,27 @@ int main(void)
{
struct osmo_fd *kbd_ofd;
- tall_test = talloc_named_const(NULL, 1, "osmo_stream_client_test");
+ tall_test = talloc_named_const(NULL, 1, "osmo_stream_cli_test");
- osmo_init_logging(&osmo_stream_client_test_log_info);
+ osmo_init_logging(&osmo_stream_cli_test_log_info);
log_set_log_level(osmo_stderr_target, 1);
/*
- * initialize stream client.
+ * initialize stream cli.
*/
- conn = osmo_stream_client_conn_create(tall_test);
+ conn = osmo_stream_cli_create(tall_test);
if (conn == NULL) {
- fprintf(stderr, "cannot create client\n");
+ fprintf(stderr, "cannot create cli\n");
exit(EXIT_FAILURE);
}
- osmo_stream_client_conn_set_addr(conn, "127.0.0.1");
- osmo_stream_client_conn_set_port(conn, 10000);
- osmo_stream_client_conn_set_connect_cb(conn, connect_cb);
- osmo_stream_client_conn_set_read_cb(conn, read_cb);
+ osmo_stream_cli_set_addr(conn, "127.0.0.1");
+ osmo_stream_cli_set_port(conn, 10000);
+ osmo_stream_cli_set_connect_cb(conn, connect_cb);
+ osmo_stream_cli_set_read_cb(conn, read_cb);
- if (osmo_stream_client_conn_open(conn) < 0) {
- fprintf(stderr, "cannot open client\n");
+ if (osmo_stream_cli_open(conn) < 0) {
+ fprintf(stderr, "cannot open cli\n");
exit(EXIT_FAILURE);
}
diff --git a/examples/stream-server.c b/examples/stream-server.c
index ec9f903..82fb20a 100644
--- a/examples/stream-server.c
+++ b/examples/stream-server.c
@@ -16,7 +16,7 @@ static void *tall_test;
#define DSTREAMTEST 0
-struct log_info_cat osmo_stream_server_test_cat[] = {
+struct log_info_cat osmo_stream_srv_test_cat[] = {
[DSTREAMTEST] = {
.name = "DSTREAMTEST",
.description = "STREAMSERVER-mode test",
@@ -25,14 +25,14 @@ struct log_info_cat osmo_stream_server_test_cat[] = {
},
};
-const struct log_info osmo_stream_server_test_log_info = {
+const struct log_info osmo_stream_srv_test_log_info = {
.filter_fn = NULL,
- .cat = osmo_stream_server_test_cat,
- .num_cat = ARRAY_SIZE(osmo_stream_server_test_cat),
+ .cat = osmo_stream_srv_test_cat,
+ .num_cat = ARRAY_SIZE(osmo_stream_srv_test_cat),
};
-static struct osmo_stream_server_link *server;
-static struct osmo_stream_server_conn *conn;
+static struct osmo_stream_srv_link *srv;
+static struct osmo_stream_srv *conn;
void sighandler(int foo)
@@ -41,7 +41,7 @@ void sighandler(int foo)
exit(EXIT_SUCCESS);
}
-int read_cb(struct osmo_stream_server_conn *conn)
+int read_cb(struct osmo_stream_srv *conn)
{
struct msgb *msg;
@@ -52,7 +52,7 @@ int read_cb(struct osmo_stream_server_conn *conn)
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- if (osmo_stream_server_conn_recv(conn, msg) < 0) {
+ if (osmo_stream_srv_recv(conn, msg) < 0) {
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n");
return 0;
}
@@ -60,13 +60,13 @@ int read_cb(struct osmo_stream_server_conn *conn)
return 0;
}
-static int close_cb(struct osmo_stream_server_conn *dummy)
+static int close_cb(struct osmo_stream_srv *dummy)
{
conn = NULL;
return 0;
}
-static int accept_cb(struct osmo_stream_server_link *server, int fd)
+static int accept_cb(struct osmo_stream_srv_link *srv, int fd)
{
if (conn != NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR, "Sorry, this example only "
@@ -74,7 +74,7 @@ static int accept_cb(struct osmo_stream_server_link *server, int fd)
return -1;
}
- conn = osmo_stream_server_conn_create(tall_test, server, fd, read_cb,
+ conn = osmo_stream_srv_create(tall_test, srv, fd, read_cb,
close_cb, NULL);
if (conn == NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR,
@@ -101,14 +101,14 @@ static int kbd_cb(struct osmo_fd *fd, unsigned int what)
return 0;
}
- msg = msgb_alloc(1024, "osmo_stream_server_test");
+ msg = msgb_alloc(1024, "osmo_stream_srv_test");
if (msg == NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
ptr = msgb_put(msg, strlen(buf));
memcpy(ptr, buf, strlen(buf));
- osmo_stream_server_conn_send(conn, msg);
+ osmo_stream_srv_send(conn, msg);
LOGP(DSTREAMTEST, LOGL_NOTICE, "message of %d bytes sent\n", msg->len);
@@ -119,25 +119,25 @@ int main(void)
{
struct osmo_fd *kbd_ofd;
- tall_test = talloc_named_const(NULL, 1, "osmo_stream_server_test");
+ tall_test = talloc_named_const(NULL, 1, "osmo_stream_srv_test");
- osmo_init_logging(&osmo_stream_server_test_log_info);
+ osmo_init_logging(&osmo_stream_srv_test_log_info);
log_set_log_level(osmo_stderr_target, 1);
/*
- * initialize stream server.
+ * initialize stream srv.
*/
- server = osmo_stream_server_link_create(tall_test);
- if (server == NULL) {
+ srv = osmo_stream_srv_link_create(tall_test);
+ if (srv == NULL) {
fprintf(stderr, "cannot create client\n");
exit(EXIT_FAILURE);
}
- osmo_stream_server_link_set_addr(server, "127.0.0.1");
- osmo_stream_server_link_set_port(server, 10000);
- osmo_stream_server_link_set_accept_cb(server, accept_cb);
+ osmo_stream_srv_link_set_addr(srv, "127.0.0.1");
+ osmo_stream_srv_link_set_port(srv, 10000);
+ osmo_stream_srv_link_set_accept_cb(srv, accept_cb);
- if (osmo_stream_server_link_open(server) < 0) {
+ if (osmo_stream_srv_link_open(srv) < 0) {
fprintf(stderr, "cannot open client\n");
exit(EXIT_FAILURE);
}
@@ -149,7 +149,7 @@ int main(void)
}
kbd_ofd->fd = STDIN_FILENO;
kbd_ofd->when = BSC_FD_READ;
- kbd_ofd->data = server;
+ kbd_ofd->data = srv;
kbd_ofd->cb = kbd_cb;
osmo_fd_register(kbd_ofd);