From patchwork Wed Feb 24 18:06:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neels Hofmeyr X-Patchwork-Id: 587565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 85D3E140C46 for ; Thu, 25 Feb 2016 05:07:54 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 42A02192B4; Wed, 24 Feb 2016 18:07:53 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [IPv6:2001:bf0:c000::1:8]) by lists.osmocom.org (Postfix) with ESMTP id ADB441929C for ; Wed, 24 Feb 2016 18:07:51 +0000 (UTC) X-Envelope-From: nhofmeyr@sysmocom.de X-Envelope-To: Received: from localhost (ip3.vpn03b.berlin.freifunk.net [77.87.49.3] (may be forged)) (authenticated bits=0) by einhorn.in-berlin.de (8.14.4/8.14.4/Debian-4) with ESMTP id u1OI7nx8007609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 24 Feb 2016 19:07:51 +0100 From: Neels Hofmeyr To: openbsc@lists.osmocom.org Subject: [PATCH] ipa driver: make bind address vty configurable Date: Wed, 24 Feb 2016 19:06:53 +0100 Message-Id: <1456337213-8846-2-git-send-email-nhofmeyr@sysmocom.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456337213-8846-1-git-send-email-nhofmeyr@sysmocom.de> References: <1456337213-8846-1-git-send-email-nhofmeyr@sysmocom.de> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Add VTY function to set the ipa bind address: e1_input ipa bind A.B.C.D Add a priv pointer to struct e1inp_driver in order to communicate the bind address parameter to ipaccess_line_update(). Add two "internal.h" functions to get/set it in the ipa driver struct. Add static ip_bind_addr() to use the IP address set from the VTY or, if NULL, use "0.0.0.0". Apply in ipaccess_line_update(). --- include/internal.h | 3 +++ include/osmocom/abis/e1_input.h | 1 + src/e1_input_vty.c | 20 ++++++++++++++++++++ src/input/ipaccess.c | 26 ++++++++++++++++++++++++-- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/internal.h b/include/internal.h index 7f6e31a..740a86d 100644 --- a/include/internal.h +++ b/include/internal.h @@ -13,6 +13,9 @@ extern void *libosmo_abis_ctx; /* use libosmo_abis_init, this is only for internal use. */ void e1inp_init(void); +void e1inp_ipaccess_set_bind(const char *ip_bind_addr); +const char *e1inp_ipaccess_get_bind(void); + /* ipaccess.c requires these functions defined here */ struct msgb; struct msgb *ipa_msg_alloc(int headroom); diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index e5d2991..4d00e03 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -139,6 +139,7 @@ struct e1inp_driver { void (*vty_show)(struct vty *vty, struct e1inp_line *line); int default_delay; int has_keepalive; + void *priv; }; struct e1inp_line_ops { diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 0b4adb2..71747f0 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -168,6 +168,18 @@ DEFUN(cfg_e1inp, cfg_e1inp_cmd, return CMD_SUCCESS; } +DEFUN(cfg_ipa_bind, + cfg_ipa_bind_cmd, + "ipa bind A.B.C.D", + "ipa driver config\n" + "Set ipa local bind address\n" + "Listen on this IP address (default 0.0.0.0)\n") +{ + e1inp_ipaccess_set_bind(argv[0]); + return CMD_SUCCESS; +} + + static int e1inp_config_write(struct vty *vty) { struct e1inp_line *line; @@ -202,6 +214,12 @@ static int e1inp_config_write(struct vty *vty) VTY_NEWLINE); } + + const char *ipa_bind = e1inp_ipaccess_get_bind(); + if (ipa_bind) + vty_out(vty, " ipa bind %s%s", + ipa_bind, VTY_NEWLINE); + return CMD_SUCCESS; } @@ -351,6 +369,8 @@ int e1inp_vty_init(void) install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_no_keepalive_cmd); + install_element(L_E1INP_NODE, &cfg_ipa_bind_cmd); + install_element_ve(&show_e1drv_cmd); install_element_ve(&show_e1line_cmd); install_element_ve(&show_e1ts_cmd); diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 8ffdb19..8f4f027 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -804,6 +804,13 @@ struct ipaccess_line { int line_already_initialized; }; +static const char *ip_bind_addr() +{ + return ipaccess_driver.priv? + ((const char*)ipaccess_driver.priv) + : "0.0.0.0"; +} + static int ipaccess_line_update(struct e1inp_line *line) { int ret = -ENOENT; @@ -831,7 +838,7 @@ static int ipaccess_line_update(struct e1inp_line *line) LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BSC mode\n"); oml_link = ipa_server_link_create(tall_ipa_ctx, line, - "0.0.0.0", IPA_TCP_PORT_OML, + ip_bind_addr(), IPA_TCP_PORT_OML, ipaccess_bsc_oml_cb, NULL); if (oml_link == NULL) { LOGP(DLINP, LOGL_ERROR, "cannot create OML " @@ -845,7 +852,7 @@ static int ipaccess_line_update(struct e1inp_line *line) return -EIO; } rsl_link = ipa_server_link_create(tall_ipa_ctx, line, - "0.0.0.0", IPA_TCP_PORT_RSL, + ip_bind_addr(), IPA_TCP_PORT_RSL, ipaccess_bsc_rsl_cb, NULL); if (rsl_link == NULL) { LOGP(DLINP, LOGL_ERROR, "cannot create RSL " @@ -944,3 +951,18 @@ void e1inp_ipaccess_init(void) tall_ipa_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa"); e1inp_driver_register(&ipaccess_driver); } + +void e1inp_ipaccess_set_bind(const char *ip_bind_addr) +{ + talloc_free(ipaccess_driver.priv); + ipaccess_driver.priv = NULL; + + if (ip_bind_addr) + ipaccess_driver.priv = (void*)talloc_strdup(tall_ipa_ctx, + ip_bind_addr); +} + +const char *e1inp_ipaccess_get_bind(void) +{ + return (const char*)ipaccess_driver.priv; +}