aboutsummaryrefslogtreecommitdiffstats
path: root/src/channel
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 /src/channel
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 'src/channel')
-rw-r--r--src/channel/abis/ipa_stream_client.c10
-rw-r--r--src/channel/abis/ipa_stream_server.c9
2 files changed, 13 insertions, 6 deletions
diff --git a/src/channel/abis/ipa_stream_client.c b/src/channel/abis/ipa_stream_client.c
index e6565c4..5745e2a 100644
--- a/src/channel/abis/ipa_stream_client.c
+++ b/src/channel/abis/ipa_stream_client.c
@@ -288,7 +288,6 @@ static int read_cb(struct osmo_stream_cli *conn, int type)
{
int ret;
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_cli_get_ofd(conn);
struct osmo_chan *chan = osmo_stream_cli_get_data(conn);
struct chan_abis_ipa_cli *s;
struct ipa_head *hh;
@@ -300,8 +299,7 @@ static int read_cb(struct osmo_stream_cli *conn, int type)
LOGP(DLINP, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- /* XXX replace with generic stream reader */
- ret = osmo_ipa_msg_recv(ofd->fd, msg);
+ ret = osmo_stream_cli_recv(conn, msg);
if (ret < 0) {
LOGP(DLINP, LOGL_ERROR, "cannot receive message\n");
msgb_free(msg);
@@ -314,6 +312,12 @@ static int read_cb(struct osmo_stream_cli *conn, int type)
return 0;
}
+ if (osmo_ipa_process_msg(msg) < 0) {
+ LOGP(DLINP, LOGL_ERROR, "Bad IPA message\n");
+ msgb_free(msg);
+ return -EIO;
+ }
+
hh = (struct ipa_head *) msg->data;
if (hh->proto == IPAC_PROTO_IPACCESS) {
abis_ipa_cli_rcvmsg(chan, conn, msg, type);
diff --git a/src/channel/abis/ipa_stream_server.c b/src/channel/abis/ipa_stream_server.c
index a47b0f6..21a82f8 100644
--- a/src/channel/abis/ipa_stream_server.c
+++ b/src/channel/abis/ipa_stream_server.c
@@ -341,7 +341,6 @@ static int read_cb(struct osmo_stream_srv *conn, int type)
{
int ret;
struct msgb *msg;
- struct osmo_fd *ofd = osmo_stream_srv_get_ofd(conn);
struct osmo_ipa_unit *unit = osmo_stream_srv_get_data(conn);
struct chan_abis_ipa_srv_conn *inst;
struct ipa_head *hh;
@@ -353,7 +352,7 @@ static int read_cb(struct osmo_stream_srv *conn, int type)
LOGP(DLINP, LOGL_ERROR, "cannot allocate message\n");
return 0;
}
- ret = osmo_ipa_msg_recv(ofd->fd, msg);
+ ret = osmo_stream_srv_recv(conn, msg);
if (ret < 0) {
LOGP(DLINP, LOGL_ERROR, "cannot receive message\n");
msgb_free(msg);
@@ -369,7 +368,11 @@ static int read_cb(struct osmo_stream_srv *conn, int type)
return 0;
}
- /* XXX: missing IPA message validation */
+ ret = osmo_ipa_process_msg(msg);
+ if (ret < 0) {
+ LOGP(DLINP, LOGL_ERROR, "invalid IPA message\n");
+ msgb_free(msg);
+ }
hh = (struct ipa_head *) msg->data;
if (hh->proto == IPAC_PROTO_IPACCESS) {