CBSP: rewrite the CBSP link setup and 'cbc' VTY section

Firstly, make CBSP server and client mutually exclusive: Do not allow osmo-bsc
to be configured as CBC client *and* CBC server at the same time.
cbsp_link.c expects at most one CBSP link to be established, and, upon sending
CBSP messages, probes whether to send the message to a CBSP server or client
link. When both listen-port and remote-ip are configured (regardless of an
actual CBSP connection), osmo-bsc gets confused about where to send CBSP
messages.

One solution would be more accurate probing for an actual established TCP
connection. But the simpler and less confusing solution is to force the user to
configure only server or only client mode, never both.

Introduce 'cbc' / 'mode (server|client|disabled)'.

Secondly, clarify the 'cbc' config structure into distinct 'server' and
'client' subnodes. Refactor the 'cbc' VTY node in such a way that the IP
addresses for server and client mode can remain configured when the CBSP link
is switched between server/client/disabled modes.

To implement the above, switch the struct bsc_cbc_link to use osmo_sockaddr_str
for address configuration.

Related: OS#4702
Related: I7eea0dd39de50ed80af79e0f10c836b8685d8644 (osmo-ttcn3-hacks)
Related: I9e9760121265b3661f1c179610e975cf7a0873f1 (docker-playground)
Change-Id: Icaa2775cc20a99227dabe38a775ff808b374cf98
diff --git a/include/osmocom/bsc/smscb.h b/include/osmocom/bsc/smscb.h
index 22a258d..c7002f6 100644
--- a/include/osmocom/bsc/smscb.h
+++ b/include/osmocom/bsc/smscb.h
@@ -2,6 +2,7 @@
 #include <osmocom/bsc/gsm_data.h>
 
 #include <osmocom/core/msgb.h>
+#include <osmocom/core/sockaddr_str.h>
 #include <osmocom/netif/stream.h>
 #include <osmocom/gsm/cbsp.h>
 
@@ -27,21 +28,25 @@
 			       uint8_t slot_count);
 void bts_cbch_timer_schedule(struct gsm_bts *bts);
 
+enum bsc_cbc_link_mode {
+	BSC_CBC_LINK_MODE_DISABLED = 0,
+	BSC_CBC_LINK_MODE_SERVER,
+	BSC_CBC_LINK_MODE_CLIENT,
+};
+
+extern const struct value_string bsc_cbc_link_mode_names[];
+static inline const char *bsc_cbc_link_mode_name(enum bsc_cbc_link_mode val)
+{ return get_value_string(bsc_cbc_link_mode_names, val); }
+
+extern const struct osmo_sockaddr_str bsc_cbc_default_server_local_addr;
+
 /* cbsp_link.c */
 struct bsc_cbc_link {
 	struct gsm_network *net;
-	struct {
-		/* hostname/IP of CBC */
-		char *cbc_hostname;
-		/* TCP port (Default: 48049) of CBC */
-		int cbc_port;
-		/* local listening port (0 for disabling local server) */
-		int listen_port;
-		/* local listening hostname/IP */
-		char *listen_hostname;
-	} config;
+	enum bsc_cbc_link_mode mode;
 	/* for handling inbound TCP connections */
 	struct {
+		struct osmo_sockaddr_str local_addr;
 		struct osmo_stream_srv *srv;
 		struct osmo_stream_srv_link *link;
 		char *sock_name;
@@ -49,6 +54,7 @@
 	} server;
 	/* for handling outbound TCP connections */
 	struct {
+		struct osmo_sockaddr_str remote_addr;
 		struct osmo_stream_cli *cli;
 		char *sock_name;
 		struct msgb *msg;
diff --git a/include/osmocom/bsc/vty.h b/include/osmocom/bsc/vty.h
index 10ce16b..ba44f5e 100644
--- a/include/osmocom/bsc/vty.h
+++ b/include/osmocom/bsc/vty.h
@@ -25,6 +25,8 @@
 	OM2K_CON_GROUP_NODE,
 	BSC_NODE,
 	CBC_NODE,
+	CBC_SERVER_NODE,
+	CBC_CLIENT_NODE,
 };
 
 struct log_info;