pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39180?usp=email )
Change subject: mgcp-cli: Fix filling in wrong local IP address of SDP Origin o=
......................................................................
mgcp-cli: Fix filling in wrong local IP address of SDP Origin o=
If user (VTY) configured the local IP address to use for MGCP, and that
IP address was not the one selected by kernel routing table lookup, the
IP address filled in the MGCP message would be wrong, not matching the
one sending the MGCP message.
Change-Id: I35624db853dc1f0fee85503105960613f70473c6
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 34 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/80/39180/1
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 1c89e69..8a7c1f6 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -1320,6 +1320,36 @@
#undef MSGB_PRINTF_OR_RET
}
+/* Helper function to obtain local IP address used in MGCP towards MGW,
+ * in string format, to fill the SDP "Origin" ("o=") field.
+ * return 0 on success, negative on error.
+ */
+static int get_mgcp_local_addr(const struct mgcp_client *mgcp, char *local_ip, size_t local_ip_len)
+{
+ int fd;
+
+ /* Try to get the socket local IP address if available: */
+ if (mgcp->iofd && ((fd = osmo_iofd_get_fd(mgcp->iofd)) >= 0)) {
+ if (osmo_sock_get_local_ip(fd, local_ip, local_ip_len) == 0)
+ return 0;
+ /* else: continue below */
+ }
+
+ /* If MGCP local address was explicitly specified in config, use it: */
+ if (mgcp->actual.local_addr) {
+ osmo_strlcpy(local_ip, mgcp->actual.local_addr, local_ip_len);
+ return 0;
+ }
+
+ /* Guess our local address based on system routing towards MGW: */
+ OSMO_ASSERT(local_ip_len >= INET6_ADDRSTRLEN);
+ if (osmo_sock_local_ip(local_ip, mgcp->actual.remote_addr) == 0)
+ return 0;
+
+ LOGPMGW(mgcp, LOGL_ERROR, "Could not determine local IP-Address!\n");
+ return -EINVAL;
+}
+
/* Helper function for mgcp_msg_gen(): Add SDP information to MGCP message */
static int add_sdp(struct msgb *msg, struct mgcp_msg *mgcp_msg, struct mgcp_client *mgcp)
{
@@ -1329,6 +1359,7 @@
const char *codec;
unsigned int pt;
uint16_t audio_port;
+ int rc;
#define MSGB_PRINTF_OR_RET(FMT, ARGS...) do { \
if (msgb_printf(msg, FMT, ##ARGS) != 0) { \
@@ -1344,13 +1375,9 @@
MSGB_PRINTF_OR_RET("v=0\r\n");
/* Determine local IP-Address */
- if (mgcp->actual.local_addr) {
- OSMO_STRLCPY_ARRAY(local_ip, mgcp->actual.local_addr);
- } else if (osmo_sock_local_ip(local_ip, mgcp->actual.remote_addr) < 0) {
- LOGPMGW(mgcp, LOGL_ERROR,
- "Could not determine local IP-Address!\n");
- return -EINVAL;
- }
+ rc = get_mgcp_local_addr(mgcp, local_ip, sizeof(local_ip));
+ if (rc < 0)
+ return rc;
local_ip_family = osmo_ip_str_type(local_ip);
if (local_ip_family == AF_UNSPEC)
return -EINVAL;
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39180?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I35624db853dc1f0fee85503105960613f70473c6
Gerrit-Change-Number: 39180
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39176?usp=email )
Change subject: pcap-client: Allow recording on several interfaces
......................................................................
pcap-client: Allow recording on several interfaces
This commit enables basic support for multi-interface capturing.
The transmitted data to the osmo-pcap-server is not yet in pcapng
format, which means no information regarding the iface it was captured
on is provided when opening the resulting pcap file.
Related: SYS#5822
Change-Id: I082b0bd38cf1829937c5e643f0ee31f9d56a07a7
---
M src/osmo_client_vty.c
1 file changed, 1 insertion(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/76/39176/1
diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c
index c976a1a..009c735 100644
--- a/src/osmo_client_vty.c
+++ b/src/osmo_client_vty.c
@@ -170,14 +170,8 @@
PCAP_STRING "the device to filter\n" "device name\n")
{
struct osmo_pcap_handle *ph = osmo_client_find_handle(pcap_client, argv[0]);
- if (!ph) {
- /* Only allow max one for now:*/
- if (llist_count(&pcap_client->handles) > 0) {
- vty_out(vty, "Only one 'pcap device' allowed! Remove the old one with 'no pcap device' first!%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!ph)
osmo_pcap_handle_alloc(pcap_client, argv[0]);
- }
return CMD_SUCCESS;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39176?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I082b0bd38cf1829937c5e643f0ee31f9d56a07a7
Gerrit-Change-Number: 39176
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>