Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2019-01-04 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..

mgcp_client: make domain part of endpoint configurable

So far, both osmo-msc and osmo-bsc always pass endpoint names of the form
'...@mgw' to osmo-mgw. Allow configuring the 'mgw' part.

Note that the actual way to pass a differing name is to pass a composed
'rtpbridge/*@foo' to mgcp_msg_gen() in the struct mgcp_msg. So this merely adds
a common VTY config for the domain name part, changes to clients are necessary.

- add mgcp_client_rtpbridge_wildcard() (useful for AoIP endpoints)
- add mgcp_client_endpoint_domain() (useful for SCCPlite endpoints)
- add mgcp client vty cfg 'mgw endpoint-domain NAME'

Rationale: reading pcaps becomes so much easier when each of osmo-bsc and
osmo-msc address their MGW with differing domain names. Otherwise, both will
have a '0@mgw' endpoint and it gets really confusing.

Also: our MGCP clients osmo-bsc and osmo-msc use code dup to compose the
initial 'rtpbridge/*@mgw' rtpbridge wildcard. It should be defined by this API
instead.

This will be used by:
* osmo-msc I87ac11847d1a6d165ee9a2b5d8a4978e7ac73433
* osmo-bsc I492023e9dca0233ec0a077032455d9f2e3880f78

After these, with according configuration, there can be a '0@bsc' and a '0@msc'
endpoint on two separate osmo-mgw instances:

osmo-mgw-for-bsc.cfg:
 mgcp
  domain bsc

osmo-bsc.cfg:
 msc 0
  mgw endpoint-domain bsc

osmo-mgw-for-msc.cfg:
 mgcp
  domain msc

osmo-msc.cfg:
 msc
  mgw endpoint-domain msc

There can also be '0@bsc' and '1@msc' endpoints on one single osmo-mgw instance 
with:

osmo-mgw.cfg:
 mgcp
  domain *

and same osmo-{bsc,msc}.cfg as above.

(By default, everything will still use '@mgw')

Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
---
M include/osmocom/mgcp_client/mgcp_client.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_vty.c
M tests/mgcp_client/mgcp_client_test.err
4 files changed, 66 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index c1fd1b0..98e58d7 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -22,6 +22,10 @@
int local_port;
const char *remote_addr;
int remote_port;
+
+   /* By default, we are always addressing the MGW with e.g. 
'rtpbridge/123@mgw'.
+* If this is nonempty, the contained name will be used instead of 
'mgw'. */
+   char endpoint_domain_name[MGCP_ENDPOINT_MAXLEN];
 };

 typedef unsigned int mgcp_trans_id_t;
@@ -120,6 +124,9 @@
 uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
 uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp);

+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp);
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp);
+
 /* Invoked when an MGCP response is received or sending failed.  When the
  * response is passed as NULL, this indicates failure during transmission. */
 typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void 
*priv);
diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 8fa82cd..03e1da7 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -705,6 +705,16 @@
mgcp->actual.remote_port = conf->remote_port >= 0 ? 
(uint16_t)conf->remote_port :
MGCP_CLIENT_REMOTE_PORT_DEFAULT;

+   if (osmo_strlcpy(mgcp->actual.endpoint_domain_name, 
conf->endpoint_domain_name,
+sizeof(mgcp->actual.endpoint_domain_name))
+   >= sizeof(mgcp->actual.endpoint_domain_name)) {
+   LOGP(DLMGCP, LOGL_ERROR, "MGCP client: endpoint domain name is 
too long, max length is %zu: '%s'\n",
+sizeof(mgcp->actual.endpoint_domain_name) - 1, 
conf->endpoint_domain_name);
+   talloc_free(mgcp);
+   return NULL;
+   }
+   LOGP(DLMGCP, LOGL_NOTICE, "MGCP client: using endpoint domain '@%s'\n", 
mgcp_client_endpoint_domain(mgcp));
+
return mgcp;
 }

@@ -811,6 +821,32 @@
return mgcp->remote_addr;
 }

+/* To compose endpoint names, usually for CRCX, use this as domain name.
+ * For example, snprintf("rtpbridge\*@%s", mgcp_client_endpoint_domain(mgcp)). 
*/
+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp)
+{
+   return mgcp->actual.endpoint_domain_name[0] ? 
mgcp->actual.endpoint_domain_name : "mgw";
+}
+
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp)
+{
+   static char endpoint[MGCP_ENDPOINT_MAXLEN];
+   int rc;
+
+#define RTPBRIDGE_WILDCARD_FMT "rtpbridge/*@%s"
+   rc = 

Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2019-01-03 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 4: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 4
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 03 Jan 2019 16:13:26 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2019-01-02 Thread Neels Hofmeyr
Neels Hofmeyr has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 4:

(3 comments)

https://gerrit.osmocom.org/#/c/12357/3//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/#/c/12357/3//COMMIT_MSG@20
PS3, Line 20: Rationale: reading pcaps becomes so much easier when each of 
osmo-bsc and
: osmo-msc address their MGW with differing domain names. 
Otherwise, both will
: have a '0@mgw' endpoint and it gets really confusing.
> How cold both use the same endpoint?  The endpoint names (local part in front 
> of @) is allocated by  […]
In a scenario where both osmo-msc and osmo-bsc use the same osmo-mgw, indeed 
each new endpoint will get a new number. But when you have one osmo-mgw each, 
then both osmo-mgw instances independently create endpoints, so for the first 
call occuring, both actually create a '0@mgw' and wireshark shows identically 
named endpoints on separate osmo-mgw instances. Then there is the need to also 
look at the source/dest address and/or port numbers to figure out what is going 
on.


https://gerrit.osmocom.org/#/c/12357/3/include/osmocom/mgcp_client/mgcp_client.h
File include/osmocom/mgcp_client/mgcp_client.h:

https://gerrit.osmocom.org/#/c/12357/3/include/osmocom/mgcp_client/mgcp_client.h@28
PS3, Line 28: MG
> why 64? Is there some kind of maximum DNS domain name length we should use?
I'm not sure at all. In fact I was just picking something at random and not 
bothering with details, just to quickly use this at 35c3. Same with other parts 
of this patch. I'm glad code review worked nicely here :)

Found MGCP_ENDPOINT_MAXLEN, though that would include the "123@" part, it is a 
good rough choice I guess.


https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c@830
PS3, Line 830:
> Oh, wow, this breaks Gerrit's syntax highlighting :D
yeah, I'm also getting C comment warnings when trying to write 
'rtpbridge/*@foo' in a comment :P



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 4
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 03 Jan 2019 01:20:31 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2019-01-02 Thread Neels Hofmeyr
Hello Max, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/12357

to look at the new patch set (#4).

Change subject: mgcp_client: make domain part of endpoint configurable
..

mgcp_client: make domain part of endpoint configurable

So far, both osmo-msc and osmo-bsc always pass endpoint names of the form
'...@mgw' to osmo-mgw. Allow configuring the 'mgw' part.

Note that the actual way to pass a differing name is to pass a composed
'rtpbridge/*@foo' to mgcp_msg_gen() in the struct mgcp_msg. So this merely adds
a common VTY config for the domain name part, changes to clients are necessary.

- add mgcp_client_rtpbridge_wildcard() (useful for AoIP endpoints)
- add mgcp_client_endpoint_domain() (useful for SCCPlite endpoints)
- add mgcp client vty cfg 'mgw endpoint-domain NAME'

Rationale: reading pcaps becomes so much easier when each of osmo-bsc and
osmo-msc address their MGW with differing domain names. Otherwise, both will
have a '0@mgw' endpoint and it gets really confusing.

Also: our MGCP clients osmo-bsc and osmo-msc use code dup to compose the
initial 'rtpbridge/*@mgw' rtpbridge wildcard. It should be defined by this API
instead.

This will be used by:
* osmo-msc I87ac11847d1a6d165ee9a2b5d8a4978e7ac73433
* osmo-bsc I492023e9dca0233ec0a077032455d9f2e3880f78

After these, with according configuration, there can be a '0@bsc' and a '0@msc'
endpoint on two separate osmo-mgw instances:

osmo-mgw-for-bsc.cfg:
 mgcp
  domain bsc

osmo-bsc.cfg:
 msc 0
  mgw endpoint-domain bsc

osmo-mgw-for-msc.cfg:
 mgcp
  domain msc

osmo-msc.cfg:
 msc
  mgw endpoint-domain msc

There can also be '0@bsc' and '1@msc' endpoints on one single osmo-mgw instance 
with:

osmo-mgw.cfg:
 mgcp
  domain *

and same osmo-{bsc,msc}.cfg as above.

(By default, everything will still use '@mgw')

Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
---
M include/osmocom/mgcp_client/mgcp_client.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_vty.c
M tests/mgcp_client/mgcp_client_test.err
4 files changed, 66 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/57/12357/4
--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 4
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-22 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 3:

(2 comments)

https://gerrit.osmocom.org/#/c/12357/3//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/#/c/12357/3//COMMIT_MSG@20
PS3, Line 20: Rationale: reading pcaps becomes so much easier when each of 
osmo-bsc and
: osmo-msc address their MGW with differing domain names. 
Otherwise, both will
: have a '0@mgw' endpoint and it gets really confusing.
How cold both use the same endpoint?  The endpoint names (local part in front 
of @) is allocated by the mgw, so if osmo-bsc uses 0@mgw, osmo-msc will get 
allocated foo@mgw where foo != "0".


https://gerrit.osmocom.org/#/c/12357/3/include/osmocom/mgcp_client/mgcp_client.h
File include/osmocom/mgcp_client/mgcp_client.h:

https://gerrit.osmocom.org/#/c/12357/3/include/osmocom/mgcp_client/mgcp_client.h@28
PS3, Line 28: 64
why 64? Is there some kind of maximum DNS domain name length we should use?



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Sat, 22 Dec 2018 20:23:53 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-20 Thread Stefan Sperling
Stefan Sperling has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 3:

(2 comments)

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c@709
PS3, Line 709:   sizeof(mgcp->actual.endpoint_domain_name));
Check for truncation and log a warning if name is truncated?
Or perhaps even error out because truncation of multiple names risks duplicates?

if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname))
goto toolong;
http://man.openbsd.org/strlcpy#EXAMPLES


https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client_vty.c
File src/libosmo-mgcp-client/mgcp_client_vty.c:

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client_vty.c@147
PS3, Line 147:   
sizeof(global_mgcp_client_conf->endpoint_domain_name));
Truncation check?



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 20 Dec 2018 17:16:25 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-20 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 3:

(1 comment)

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c@833
PS3, Line 833:  LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum 
length ('" RTPBRIDGE_WILDCARD_FMT "')\n",
Better say what is the expected max length in the log message.



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 20 Dec 2018 10:13:17 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-19 Thread Vadim Yanitskiy
Vadim Yanitskiy has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 3:

(2 comments)

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c
File src/libosmo-mgcp-client/mgcp_client.c:

https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c@822
PS3, Line 822: name[0]?
Missing space.


https://gerrit.osmocom.org/#/c/12357/3/src/libosmo-mgcp-client/mgcp_client.c@830
PS3, Line 830: "rtpbridge/*@%s"
Oh, wow, this breaks Gerrit's syntax highlighting :D



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 20 Dec 2018 00:41:38 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-19 Thread Neels Hofmeyr
Neels Hofmeyr has removed a vote on this change.

Change subject: mgcp_client: make domain part of endpoint configurable
..


Removed Code-Review-1 by Max 
--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: deleteVote
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-19 Thread Neels Hofmeyr
Neels Hofmeyr has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 3:

I'm going to remove that -1 because I think it is not actual code review 
related to this patch, more like a general question on how our MGCP works.


--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Comment-Date: Wed, 19 Dec 2018 23:56:34 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-19 Thread Neels Hofmeyr
Neels Hofmeyr has posted comments on this change. ( 
https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12357/1//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/#/c/12357/1//COMMIT_MSG@37
PS1, Line 37:   domain bsc
> Does this have to match the "mgw endpoint-domain" value in osmo-bsc. […]
of course.

The server already allows changing the expected domain name, but the client 
does not until this patch gets merged. This patch does not affect the server 
side, only the client.

The default expected one is 'mgw', but you can set '*' to accept any (which was 
added for SCCPlite, where the MSC tested actually sent an IP address)

  DEFUN(cfg_mgcp_domain,
cfg_mgcp_domain_cmd,
"domain NAME",
"Set the domain part expected in MGCP messages' endpoint names\n"
"Qualified domain name expected in MGCP endpoint names, or '*' to 
accept any domain\n")

What happens if they differ: osmo-mgw rejects the CRCX. It's all up to your 
.cfg files.

Actually, to do it really right, the goal would be to have that domain name 
match the actual server domain name and/or any IP addresses it listens on. This 
patch is mere cosmetics to improve the context and help analyse RTP streams.

In the long run, we might place the 'mgw remote-addr' in there as 
endpoint-domain by default, and setting this endpoint-domain could manually 
override that; osmo-mgw could accept all with '*' or compare to the interface 
the MGCP was received on / have a list of accepted domains... But there isn't 
really a benefit to that, so I doubt that we will need that ever, really.



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Comment-Date: Wed, 19 Dec 2018 17:13:23 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-19 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12357 )

Change subject: mgcp_client: make domain part of endpoint configurable
..


Patch Set 1: Code-Review-1

(1 comment)

Please clarify.

https://gerrit.osmocom.org/#/c/12357/1//COMMIT_MSG
Commit Message:

https://gerrit.osmocom.org/#/c/12357/1//COMMIT_MSG@37
PS1, Line 37:   domain bsc
Does this have to match the "mgw endpoint-domain" value in osmo-bsc.cfg? What 
happens if they differ?



--
To view, visit https://gerrit.osmocom.org/12357
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
Gerrit-Change-Number: 12357
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Comment-Date: Wed, 19 Dec 2018 12:26:51 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in osmo-mgw[master]: mgcp_client: make domain part of endpoint configurable

2018-12-18 Thread Neels Hofmeyr
Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/12357


Change subject: mgcp_client: make domain part of endpoint configurable
..

mgcp_client: make domain part of endpoint configurable

So far, both osmo-msc and osmo-bsc always pass endpoint names of the form
'...@mgw' to osmo-mgw. Allow configuring the 'mgw' part.

Note that the actual way to pass a differing name is to pass a composed
'rtpbridge/*@foo' to mgcp_msg_gen() in the struct mgcp_msg. So this merely adds
a common VTY config for the domain name part, changes to clients are necessary.

- add mgcp_client_rtpbridge_wildcard() (useful for AoIP endpoints)
- add mgcp_client_endpoint_domain() (useful for SCCPlite endpoints)
- add mgcp client vty cfg 'mgw endpoint-domain NAME'

Rationale: reading pcaps becomes so much easier when each of osmo-bsc and
osmo-msc address their MGW with differing domain names. Otherwise, both will
have a '0@mgw' endpoint and it gets really confusing.

Also: our MGCP clients osmo-bsc and osmo-msc use code dup to compose the
initial 'rtpbridge/*@mgw' rtpbridge wildcard. It should be defined by this API
instead.

This will be used by:
* osmo-msc I87ac11847d1a6d165ee9a2b5d8a4978e7ac73433
* osmo-bsc I492023e9dca0233ec0a077032455d9f2e3880f78

After these, with according configuration, there can be a '0@bsc' and a '0@msc'
endpoint.

osmo-mgw-for-bsc.cfg:
 mgcp
  domain bsc

osmo-bsc.cfg:
 msc 0
  mgw endpoint-domain bsc

osmo-mgw-for-msc.cfg:
 mgcp
  domain msc

osmo-msc.cfg:
 msc
  mgw endpoint-domain msc

(By default, everything will still use '@mgw')

Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
---
M include/osmocom/mgcp_client/mgcp_client.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_vty.c
M tests/mgcp_client/mgcp_client_test.err
4 files changed, 55 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/57/12357/1

diff --git a/include/osmocom/mgcp_client/mgcp_client.h 
b/include/osmocom/mgcp_client/mgcp_client.h
index c1fd1b0..d284f49 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -22,6 +22,10 @@
int local_port;
const char *remote_addr;
int remote_port;
+
+   /* By default, we are always addressing the MGW with e.g. 
'rtpbridge/123@mgw'.
+* If this is nonempty, the contained name will be used instead of 
'mgw'. */
+   char endpoint_domain_name[64];
 };

 typedef unsigned int mgcp_trans_id_t;
@@ -120,6 +124,9 @@
 uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
 uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp);

+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp);
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp);
+
 /* Invoked when an MGCP response is received or sending failed.  When the
  * response is passed as NULL, this indicates failure during transmission. */
 typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void 
*priv);
diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index 2ceab3c..2284e32 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -703,6 +703,10 @@
mgcp->actual.remote_port = conf->remote_port >= 0 ? 
(uint16_t)conf->remote_port :
MGCP_CLIENT_REMOTE_PORT_DEFAULT;

+   osmo_strlcpy(mgcp->actual.endpoint_domain_name, 
conf->endpoint_domain_name,
+sizeof(mgcp->actual.endpoint_domain_name));
+   LOGP(DLMGCP, LOGL_NOTICE, "MGCP client: using endpoint domain '@%s'\n", 
mgcp_client_endpoint_domain(mgcp));
+
return mgcp;
 }

@@ -811,6 +815,32 @@
return mgcp->remote_addr;
 }

+/* To compose endpoint names, usually for CRCX, use this as domain name.
+ * For example, snprintf("rtpbridge\*@%s", mgcp_client_endpoint_domain(mgcp)). 
*/
+const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp)
+{
+   return mgcp->actual.endpoint_domain_name[0]? 
mgcp->actual.endpoint_domain_name : "mgw";
+}
+
+const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp)
+{
+   static char endpoint[MGCP_ENDPOINT_MAXLEN];
+   int rc;
+
+#define RTPBRIDGE_WILDCARD_FMT "rtpbridge/*@%s"
+   rc = snprintf(endpoint, sizeof(endpoint), RTPBRIDGE_WILDCARD_FMT, 
mgcp_client_endpoint_domain(mgcp));
+   if (rc > sizeof(endpoint) - 1) {
+   LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length 
('" RTPBRIDGE_WILDCARD_FMT "')\n",
+mgcp_client_endpoint_domain(mgcp));
+   return NULL;
+   }
+   if (rc < 1) {
+   LOGP(DLMGCP, LOGL_ERROR, "Cannot compose MGCP endpoint name\n");
+   return NULL;
+   }
+   return endpoint;
+}
+
 struct mgcp_response_pending * mgcp_client_pending_add(