osmo-pcu[master]: Add pcu-socket vty config

2017-08-09 Thread Harald Welte

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3443
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Add pcu-socket vty config

2017-08-09 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Add pcu-socket vty config
..


Add pcu-socket vty config

osmo-bts already supports configuring a different path for the bts<->pcu
socket by using the 'pcu-socket' config field.

Change-Id: I9b3e1171da467519750b201849ec892a1e318129
---
M include/osmocom/pcu/pcuif_proto.h
M src/bts.h
M src/osmobts_sock.cpp
M src/pcu_main.cpp
M src/pcu_vty.c
5 files changed, 30 insertions(+), 1 deletion(-)

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



diff --git a/include/osmocom/pcu/pcuif_proto.h 
b/include/osmocom/pcu/pcuif_proto.h
index 88dc09e..39103ee 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -3,6 +3,8 @@
 
 #include 
 
+#define PCU_SOCK_DEFAULT   "/tmp/pcu_bts"
+
 #define PCU_IF_VERSION 0x07
 #define TXT_MAX_LEN128
 
diff --git a/src/bts.h b/src/bts.h
index 25193f9..cff0020 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -233,6 +233,9 @@
 * period.
 */
struct BTS *bts;
+
+   /* Path to be used for the pcu-bts socket */
+   char *pcu_sock_path;
 };
 
 #ifdef __cplusplus
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index d7e55e7..e9b85ab 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -223,6 +223,7 @@
struct sockaddr_un local;
unsigned int namelen;
int rc;
+   struct gprs_rlcmac_bts *bts = bts_main_data();
 
LOGP(DL1IF, LOGL_INFO, "Opening OsmoPCU L1 interface to OsmoBTS\n");
 
@@ -244,7 +245,7 @@
}
 
local.sun_family = AF_UNIX;
-   strncpy(local.sun_path, "/tmp/pcu_bts", sizeof(local.sun_path));
+   strncpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path));
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
 
/* we use the same magic that X11 uses in Xtranssock.c for
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index b69e446..8e7cde8 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -216,6 +216,8 @@
 */
bts->dl_arq_type = EGPRS_ARQ1;
 
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT);
+
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 
osmo_init_logging(_log_info);
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index cd22e38..68d2f55 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "pcu_vty.h"
 #include "gprs_rlcmac.h"
 #include "bts.h"
@@ -233,6 +234,8 @@
if (bts->dl_tbf_idle_msec)
vty_out(vty, " dl-tbf-idle-time %d%s", bts->dl_tbf_idle_msec,
VTY_NEWLINE);
+   if (strcmp(bts->pcu_sock_path, PCU_SOCK_DEFAULT))
+   vty_out(vty, " pcu-socket %s%s", bts->pcu_sock_path, 
VTY_NEWLINE);
 
for (i = 0; i < 32; i++) {
unsigned int cs = (1 << i);
@@ -966,6 +969,23 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_pcu_sock,
+  cfg_pcu_sock_cmd,
+  "pcu-socket PATH",
+  "Configure the osmo-bts PCU socket file/path name\n"
+  "Path of the socket to connect to\n")
+{
+   struct gprs_rlcmac_bts *bts = bts_main_data();
+
+   if (bts->pcu_sock_path) {
+   /* FIXME: close the interface? */
+   talloc_free(bts->pcu_sock_path);
+   }
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, argv[0]);
+   /* FIXME: re-open the interface? */
+
+   return CMD_SUCCESS;
+}
 
 DEFUN(show_tbf,
   show_tbf_cmd,
@@ -1096,6 +1116,7 @@
install_element(PCU_NODE, _pcu_no_ms_idle_time_cmd);
install_element(PCU_NODE, _pcu_gsmtap_categ_cmd);
install_element(PCU_NODE, _pcu_no_gsmtap_categ_cmd);
+   install_element(PCU_NODE, _pcu_sock_cmd);
 
install_element_ve(_bts_stats_cmd);
install_element_ve(_tbf_cmd);

-- 
To view, visit https://gerrit.osmocom.org/3443
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] osmo-pcu[master]: Add pcu-socket vty config

2017-08-09 Thread Pau Espin Pedrol
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3443

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

Add pcu-socket vty config

osmo-bts already supports configuring a different path for the bts<->pcu
socket by using the 'pcu-socket' config field.

Change-Id: I9b3e1171da467519750b201849ec892a1e318129
---
M include/osmocom/pcu/pcuif_proto.h
M src/bts.h
M src/osmobts_sock.cpp
M src/pcu_main.cpp
M src/pcu_vty.c
5 files changed, 30 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/43/3443/3

diff --git a/include/osmocom/pcu/pcuif_proto.h 
b/include/osmocom/pcu/pcuif_proto.h
index 88dc09e..39103ee 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -3,6 +3,8 @@
 
 #include 
 
+#define PCU_SOCK_DEFAULT   "/tmp/pcu_bts"
+
 #define PCU_IF_VERSION 0x07
 #define TXT_MAX_LEN128
 
diff --git a/src/bts.h b/src/bts.h
index 25193f9..cff0020 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -233,6 +233,9 @@
 * period.
 */
struct BTS *bts;
+
+   /* Path to be used for the pcu-bts socket */
+   char *pcu_sock_path;
 };
 
 #ifdef __cplusplus
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index d7e55e7..e9b85ab 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -223,6 +223,7 @@
struct sockaddr_un local;
unsigned int namelen;
int rc;
+   struct gprs_rlcmac_bts *bts = bts_main_data();
 
LOGP(DL1IF, LOGL_INFO, "Opening OsmoPCU L1 interface to OsmoBTS\n");
 
@@ -244,7 +245,7 @@
}
 
local.sun_family = AF_UNIX;
-   strncpy(local.sun_path, "/tmp/pcu_bts", sizeof(local.sun_path));
+   strncpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path));
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
 
/* we use the same magic that X11 uses in Xtranssock.c for
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index b69e446..8e7cde8 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -216,6 +216,8 @@
 */
bts->dl_arq_type = EGPRS_ARQ1;
 
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT);
+
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 
osmo_init_logging(_log_info);
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index cd22e38..68d2f55 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "pcu_vty.h"
 #include "gprs_rlcmac.h"
 #include "bts.h"
@@ -233,6 +234,8 @@
if (bts->dl_tbf_idle_msec)
vty_out(vty, " dl-tbf-idle-time %d%s", bts->dl_tbf_idle_msec,
VTY_NEWLINE);
+   if (strcmp(bts->pcu_sock_path, PCU_SOCK_DEFAULT))
+   vty_out(vty, " pcu-socket %s%s", bts->pcu_sock_path, 
VTY_NEWLINE);
 
for (i = 0; i < 32; i++) {
unsigned int cs = (1 << i);
@@ -966,6 +969,23 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_pcu_sock,
+  cfg_pcu_sock_cmd,
+  "pcu-socket PATH",
+  "Configure the osmo-bts PCU socket file/path name\n"
+  "Path of the socket to connect to\n")
+{
+   struct gprs_rlcmac_bts *bts = bts_main_data();
+
+   if (bts->pcu_sock_path) {
+   /* FIXME: close the interface? */
+   talloc_free(bts->pcu_sock_path);
+   }
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, argv[0]);
+   /* FIXME: re-open the interface? */
+
+   return CMD_SUCCESS;
+}
 
 DEFUN(show_tbf,
   show_tbf_cmd,
@@ -1096,6 +1116,7 @@
install_element(PCU_NODE, _pcu_no_ms_idle_time_cmd);
install_element(PCU_NODE, _pcu_gsmtap_categ_cmd);
install_element(PCU_NODE, _pcu_no_gsmtap_categ_cmd);
+   install_element(PCU_NODE, _pcu_sock_cmd);
 
install_element_ve(_bts_stats_cmd);
install_element_ve(_tbf_cmd);

-- 
To view, visit https://gerrit.osmocom.org/3443
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


osmo-pcu[master]: Add pcu-socket vty config

2017-08-09 Thread Harald Welte

Patch Set 2: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/3443/2/src/pcu_vty.h
File src/pcu_vty.h:

Line 7: #define PCU_SOCK_DEFAULT  "/tmp/pcu_bts"
this should probably be part of pcuif_proto.h


-- 
To view, visit https://gerrit.osmocom.org/3443
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


[PATCH] osmo-pcu[master]: Add pcu-socket vty config

2017-08-08 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/3443

Add pcu-socket vty config

osmo-bts already supports configuring a different path for the bts<->pcu
socket by using the 'pcu-socket' config field.

Change-Id: I9b3e1171da467519750b201849ec892a1e318129
---
M src/bts.h
M src/osmobts_sock.cpp
M src/pcu_main.cpp
M src/pcu_vty.c
M src/pcu_vty.h
5 files changed, 27 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/43/3443/1

diff --git a/src/bts.h b/src/bts.h
index 25193f9..cff0020 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -233,6 +233,9 @@
 * period.
 */
struct BTS *bts;
+
+   /* Path to be used for the pcu-bts socket */
+   char *pcu_sock_path;
 };
 
 #ifdef __cplusplus
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index d7e55e7..e9b85ab 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -223,6 +223,7 @@
struct sockaddr_un local;
unsigned int namelen;
int rc;
+   struct gprs_rlcmac_bts *bts = bts_main_data();
 
LOGP(DL1IF, LOGL_INFO, "Opening OsmoPCU L1 interface to OsmoBTS\n");
 
@@ -244,7 +245,7 @@
}
 
local.sun_family = AF_UNIX;
-   strncpy(local.sun_path, "/tmp/pcu_bts", sizeof(local.sun_path));
+   strncpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path));
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
 
/* we use the same magic that X11 uses in Xtranssock.c for
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index b69e446..8e7cde8 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -216,6 +216,8 @@
 */
bts->dl_arq_type = EGPRS_ARQ1;
 
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT);
+
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
 
osmo_init_logging(_log_info);
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index cd22e38..0fc9db3 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -233,6 +233,8 @@
if (bts->dl_tbf_idle_msec)
vty_out(vty, " dl-tbf-idle-time %d%s", bts->dl_tbf_idle_msec,
VTY_NEWLINE);
+   if (strcmp(bts->pcu_sock_path, PCU_SOCK_DEFAULT))
+   vty_out(vty, " pcu-socket %s%s", bts->pcu_sock_path, 
VTY_NEWLINE);
 
for (i = 0; i < 32; i++) {
unsigned int cs = (1 << i);
@@ -966,6 +968,21 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_pcu_sock, cfg_pcu_sock_cmd,
+   "pcu-socket PATH",
+   "Configure the osmo-bts PCU socket file/path name\n")
+{
+   struct gprs_rlcmac_bts *bts = bts_main_data();
+
+   if (bts->pcu_sock_path) {
+   /* FIXME: close the interface? */
+   talloc_free(bts->pcu_sock_path);
+   }
+   bts->pcu_sock_path = talloc_strdup(tall_pcu_ctx, argv[0]);
+   /* FIXME: re-open the interface? */
+
+   return CMD_SUCCESS;
+}
 
 DEFUN(show_tbf,
   show_tbf_cmd,
@@ -1096,6 +1113,7 @@
install_element(PCU_NODE, _pcu_no_ms_idle_time_cmd);
install_element(PCU_NODE, _pcu_gsmtap_categ_cmd);
install_element(PCU_NODE, _pcu_no_gsmtap_categ_cmd);
+   install_element(PCU_NODE, _pcu_sock_cmd);
 
install_element_ve(_bts_stats_cmd);
install_element_ve(_tbf_cmd);
diff --git a/src/pcu_vty.h b/src/pcu_vty.h
index c00b882..09cd8cf 100644
--- a/src/pcu_vty.h
+++ b/src/pcu_vty.h
@@ -4,6 +4,8 @@
 #include 
 #include 
 
+#define PCU_SOCK_DEFAULT  "/tmp/pcu_bts"
+
 enum pcu_vty_node {
PCU_NODE = _LAST_OSMOVTY_NODE + 1,
 };

-- 
To view, visit https://gerrit.osmocom.org/3443
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b3e1171da467519750b201849ec892a1e318129
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol