aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2012-08-19 19:49:07 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2012-08-19 20:14:25 +0200
commit9ae91e594c129ddffaf3217da5834bf6d7d822f0 (patch)
tree01f4fe75ef0ade5731f3bbd8d84aa24c2f168b92 /examples
parent7a3e8d01f54e68997c22036b1291f7f90a018def (diff)
ipa: add osmo_ipa_process_msg and remove osmo_ipa_recv_msg
This patch removes osmo_ipa_recv_msg, it performs two syscall invocations and it's stream generic. Now we use the specific receival function we want to use (no matter if stream or datagram based) and then we call osmo_ipa_process_msg to check that the IPA message correct.
Diffstat (limited to 'examples')
-rw-r--r--examples/ipa-stream-client.c7
-rw-r--r--examples/ipa-stream-server.c9
2 files changed, 12 insertions, 4 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c
index b771fa3..db1ce62 100644
--- a/examples/ipa-stream-client.c
+++ b/examples/ipa-stream-client.c
@@ -96,7 +96,6 @@ static int connect_cb(struct osmo_stream_cli *conn)
static int read_cb(struct osmo_stream_cli *conn)
{
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_cli_get_ofd(conn);
LOGP(DIPATEST, LOGL_DEBUG, "received message from stream\n");
@@ -105,10 +104,14 @@ static int read_cb(struct osmo_stream_cli *conn)
LOGP(DIPATEST, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- if (osmo_ipa_msg_recv(ofd->fd, msg) <= 0) {
+ if (osmo_stream_cli_recv(conn, msg) <= 0) {
LOGP(DIPATEST, LOGL_ERROR, "cannot receive message\n");
return 0;
}
+ if (osmo_ipa_process_msg(msg) < 0) {
+ LOGP(DIPATEST, LOGL_ERROR, "bad IPA message\n");
+ return 0;
+ }
int num;
struct msg_sent *cur, *tmp, *found = NULL;
diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c
index 69e0280..c370d5f 100644
--- a/examples/ipa-stream-server.c
+++ b/examples/ipa-stream-server.c
@@ -46,7 +46,6 @@ void sighandler(int foo)
int read_cb(struct osmo_stream_srv *conn)
{
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_srv_get_ofd(conn);
LOGP(DSTREAMTEST, LOGL_DEBUG, "received message from stream\n");
@@ -55,12 +54,18 @@ int read_cb(struct osmo_stream_srv *conn)
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- if (osmo_ipa_msg_recv(ofd->fd, msg) <= 0) {
+ if (osmo_stream_srv_recv(conn, msg) <= 0) {
LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n");
osmo_stream_srv_destroy(conn);
msgb_free(msg);
return 0;
}
+ if (osmo_ipa_process_msg(msg) < 0) {
+ LOGP(DSTREAMTEST, LOGL_ERROR, "Bad IPA message\n");
+ msgb_free(msg);
+ return 0;
+ }
+
osmo_stream_srv_send(conn, msg);
return 0;
}