From 359fb8caf417570856ca61d6ff90df1fc452d659 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 30 Jun 2013 15:27:10 +0200 Subject: 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. --- src/common/abis.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/common/abis.c') diff --git a/src/common/abis.c b/src/common/abis.c index 596184ad..2017f0a4 100644 --- a/src/common/abis.c +++ b/src/common/abis.c @@ -139,6 +139,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 #include -- cgit v1.2.3