diff options
author | Harald Welte <laforge@gnumonks.org> | 2013-06-30 15:27:10 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2013-06-30 15:30:15 +0200 |
commit | 654d663bde32b9c5626150f3ac566de3cd193fc7 (patch) | |
tree | 7366d85b972053b912be4ec89ca8804b73d5af70 | |
parent | 6d5228fdf3fe973ed2223be1d1619814eb75a860 (diff) |
abis: Use OML remote (BSC) address if RSL CONNECT contains no IP
This introduces a new get_signlink_remote_ip() function whcih we also
use in the RSL code to determine the RTP remote address if the CRCX/MDCX
contains no remote IP address IE.
-rw-r--r-- | include/osmo-bts/abis.h | 2 | ||||
-rw-r--r-- | src/common/abis.c | 21 | ||||
-rw-r--r-- | src/common/oml.c | 3 | ||||
-rw-r--r-- | src/common/rsl.c | 6 |
4 files changed, 25 insertions, 7 deletions
diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h index 6e26cafd..9d47aa54 100644 --- a/include/osmo-bts/abis.h +++ b/include/osmo-bts/abis.h @@ -23,4 +23,6 @@ struct e1inp_line *abis_open(struct gsm_bts *bts, const char *dst_host, int abis_oml_sendmsg(struct msgb *msg); int abis_rsl_sendmsg(struct msgb *msg); +uint32_t get_signlink_remote_ip(struct e1inp_sign_link *link); + #endif /* _ABIS_H */ diff --git a/src/common/abis.c b/src/common/abis.c index 0e4981ca..6f1d0f27 100644 --- a/src/common/abis.c +++ b/src/common/abis.c @@ -138,6 +138,27 @@ static int sign_link_cb(struct msgb *msg) return 0; } +uint32_t get_signlink_remote_ip(struct e1inp_sign_link *link) +{ + int fd = link->ts->driver.ipaccess.fd.fd; + struct sockaddr_in sin; + socklen_t slen = sizeof(sin); + int rc; + + rc = getpeername(fd, (struct sockaddr *)&sin, &slen); + if (rc < 0) { + LOGP(DOML, LOGL_ERROR, "Cannot determine remote IP Addr: %s\n", + strerror(errno)); + return 0; + } + + /* we assume that the soket is AF_INET. As Abis/IP contains + * lots of hard-coded IPv4 addresses, this safe */ + OSMO_ASSERT(sin.sin_family == AF_INET); + + return ntohl(sin.sin_addr.s_addr); +} + #include <sys/ioctl.h> #include <net/if.h> diff --git a/src/common/oml.c b/src/common/oml.c index ddf1b579..20c1d740 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -993,13 +993,12 @@ static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg) return oml_fom_ack_nack(msg, rc); } - static int rx_oml_ipa_rsl_connect(struct gsm_bts_trx *trx, struct msgb *msg, struct tlv_parsed *tp) { struct e1inp_sign_link *oml_link = trx->bts->oml_link; uint16_t port = IPA_TCP_PORT_RSL; - uint32_t ip;//FIXME = oml_link->ip; + uint32_t ip = get_signlink_remote_ip(oml_link); struct in_addr in; int rc; diff --git a/src/common/rsl.c b/src/common/rsl.c index 6406cf39..79da6532 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1365,12 +1365,8 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg) if (connect_ip == 0) { struct e1inp_sign_link *sign_link = lchan->ts->trx->rsl_link; - int rsl_fd = sign_link->ts->driver.ipaccess.fd.fd; - struct sockaddr_in sin; - socklen_t slen = sizeof(sin); - getpeername(rsl_fd, (struct sockaddr *)&sin, &slen); - ia = sin.sin_addr; + ia.s_addr = htonl(get_signlink_remote_ip(sign_link)); } else ia.s_addr = connect_ip; rc = osmo_rtp_socket_connect(lchan->abis_ip.rtp_socket, |