diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2012-08-16 00:31:40 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@gnumonks.org> | 2012-08-16 00:31:40 +0200 |
commit | b247d6df8161eb3dfd9f99002b541b72e2b1ac9f (patch) | |
tree | 451bdc46e70548e686371585f0938e7a44828b5b /src | |
parent | 4ab29914389f850b5ca9f1f44ce90e9f25076960 (diff) |
ipa: change osmo_ipa_rcvmsg_base to take argument depending on role
If we're acting as client, we don't have to reply ID_ACK to
one received ID_ACK (otherwise, we enter a loop).
Diffstat (limited to 'src')
-rw-r--r-- | src/channel/abis_ipa_client.c | 10 | ||||
-rw-r--r-- | src/channel/abis_ipa_server.c | 4 | ||||
-rw-r--r-- | src/ipa.c | 16 |
3 files changed, 22 insertions, 8 deletions
diff --git a/src/channel/abis_ipa_client.c b/src/channel/abis_ipa_client.c index 9c3554d..079ad35 100644 --- a/src/channel/abis_ipa_client.c +++ b/src/channel/abis_ipa_client.c @@ -154,6 +154,14 @@ void osmo_abis_ipa_cli_set_rsl_port(struct osmo_chan *c, uint16_t port) osmo_stream_cli_set_port(s->rsl, port); } +void osmo_abis_ipa_cli_set_unit(struct osmo_chan *c, struct ipaccess_unit *unit) +{ + struct chan_abis_ipa_cli *s = (struct chan_abis_ipa_cli *)&c->data; + + osmo_ipa_unit_free(s->unit); + s->unit = unit; +} + void osmo_abis_ipa_cli_set_cb_signalmsg(struct osmo_chan *c, void (*signal_msg)(struct msgb *msg, int type)) { @@ -257,7 +265,7 @@ abis_ipa_cli_rcvmsg(struct osmo_chan *c, struct osmo_stream_cli *conn, int ret; /* Handle IPA PING, PONG and ID_ACK messages. */ - if (osmo_ipa_rcvmsg_base(msg, ofd)) + if (osmo_ipa_rcvmsg_base(msg, ofd, 0)) /* XXX: 0 indicates client */ return 0; if (msg_type == IPAC_MSGT_ID_GET) { diff --git a/src/channel/abis_ipa_server.c b/src/channel/abis_ipa_server.c index b971b50..e4fac1c 100644 --- a/src/channel/abis_ipa_server.c +++ b/src/channel/abis_ipa_server.c @@ -346,8 +346,8 @@ abis_ipa_srv_rcvmsg(struct osmo_chan *c, char *unitid; int len, ret; - /* Handle IPA PING, PONG and ID_ACK messages. */ - if (osmo_ipa_rcvmsg_base(msg, ofd)) + /* Handle IPA PING, PONG and ID_ACK messages */ + if (osmo_ipa_rcvmsg_base(msg, ofd, 1)) /* XXX: 1 indicates server */ return 0; if (msg_type == IPAC_MSGT_ID_RESP) { @@ -216,7 +216,7 @@ int ipaccess_send_id_req(int fd) } /* base handling of the ip.access protocol */ -int osmo_ipa_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd) +int osmo_ipa_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd, int server) { int ipa_ccm = 0; uint8_t msg_type = *(msg->l2h); @@ -224,17 +224,23 @@ int osmo_ipa_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd) switch (msg_type) { case IPAC_MSGT_PING: + LOGP(DLINP, LOGL_DEBUG, "PING!\n"); ipa_ccm = 1; ret = ipaccess_send_pong(bfd->fd); break; case IPAC_MSGT_PONG: - DEBUGP(DLMI, "PONG!\n"); + LOGP(DLINP, LOGL_DEBUG, "PONG!\n"); ipa_ccm = 1; break; case IPAC_MSGT_ID_ACK: - DEBUGP(DLMI, "ID_ACK? -> ACK!\n"); - ipa_ccm = 1; - ret = ipaccess_send_id_ack(bfd->fd); + if (server) { + LOGP(DLINP, LOGL_DEBUG, "ID_ACK? -> ACK!\n"); + ipa_ccm = 1; + ret = ipaccess_send_id_ack(bfd->fd); + } else { + LOGP(DLINP, LOGL_DEBUG, "ID_ACK! OK!\n"); + ipa_ccm = 1; + } break; } return ipa_ccm; |