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).
This commit is contained in:
parent
4ab2991438
commit
b247d6df81
|
@ -65,7 +65,7 @@ struct ipaccess_unit {
|
|||
struct osmo_fd;
|
||||
struct tlv_parsed;
|
||||
|
||||
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 osmo_ipa_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
|
||||
int osmo_ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
16
src/ipa.c
16
src/ipa.c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue