summaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-19 15:09:09 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-19 15:09:09 +0200
commit7fb05234a7bd8c16eba2cad3074411f86b104c20 (patch)
treed95ab519bc65288765f633f8b3cc52e74887c260 /openbsc/src
parentb3ee265b69aef02b702baa45dee0d48723261398 (diff)
[GPRS] NS: VTY: Move all local ip/port bind values into 'ns' node
This removes the requirement for gb_proxy and sgsn to have duplicate vty parsing code
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/gprs/gprs_ns.c5
-rw-r--r--openbsc/src/gprs/gprs_ns_frgre.c8
-rw-r--r--openbsc/src/gprs/gprs_ns_vty.c89
3 files changed, 98 insertions, 4 deletions
diff --git a/openbsc/src/gprs/gprs_ns.c b/openbsc/src/gprs/gprs_ns.c
index 4ef3603a..8b226b89 100644
--- a/openbsc/src/gprs/gprs_ns.c
+++ b/openbsc/src/gprs/gprs_ns.c
@@ -903,11 +903,12 @@ static int nsip_fd_cb(struct bsc_fd *bfd, unsigned int what)
}
/* Listen for incoming GPRS packets */
-int nsip_listen(struct gprs_ns_inst *nsi, uint32_t ip, uint16_t udp_port)
+int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
{
int ret;
- ret = make_sock(&nsi->nsip.fd, IPPROTO_UDP, ip, udp_port, nsip_fd_cb);
+ ret = make_sock(&nsi->nsip.fd, IPPROTO_UDP, nsi->nsip.local_ip,
+ nsi->nsip.local_port, nsip_fd_cb);
if (ret < 0)
return ret;
diff --git a/openbsc/src/gprs/gprs_ns_frgre.c b/openbsc/src/gprs/gprs_ns_frgre.c
index d58c1d9d..979442b8 100644
--- a/openbsc/src/gprs/gprs_ns_frgre.c
+++ b/openbsc/src/gprs/gprs_ns_frgre.c
@@ -202,7 +202,7 @@ static int nsfrgre_fd_cb(struct bsc_fd *bfd, unsigned int what)
return rc;
}
-int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi, uint32_t ip)
+int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi)
{
int rc;
@@ -210,7 +210,11 @@ int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi, uint32_t ip)
if (nsi->frgre.fd.fd)
close(nsi->frgre.fd.fd);
- rc = make_sock(&nsi->frgre.fd, IPPROTO_GRE, ip, 0, nsfrgre_fd_cb);
+ if (!nsi->frgre.enabled)
+ return 0;
+
+ rc = make_sock(&nsi->frgre.fd, IPPROTO_GRE, nsi->frgre.local_ip,
+ 0, nsfrgre_fd_cb);
if (rc < 0) {
LOGP(DNS, LOGL_ERROR, "Error creating GRE socket (%s)\n",
strerror(errno));
diff --git a/openbsc/src/gprs/gprs_ns_vty.c b/openbsc/src/gprs/gprs_ns_vty.c
index 7d439445..1922b024 100644
--- a/openbsc/src/gprs/gprs_ns_vty.c
+++ b/openbsc/src/gprs/gprs_ns_vty.c
@@ -68,6 +68,7 @@ static int config_write_ns(struct vty *vty)
{
struct gprs_nsvc *nsvc;
unsigned int i;
+ struct in_addr ia;
vty_out(vty, "ns%s", VTY_NEWLINE);
@@ -111,6 +112,21 @@ static int config_write_ns(struct vty *vty)
get_value_string(gprs_ns_timer_strs, i),
vty_nsi->timeout[i], VTY_NEWLINE);
+ if (vty_nsi->nsip.local_ip) {
+ ia.s_addr = htonl(vty_nsi->nsip.local_ip);
+ vty_out(vty, " encapsulation udp local-ip %s%s",
+ inet_ntoa(ia), VTY_NEWLINE);
+ vty_out(vty, " encapsulation udp local-port %u%s",
+ vty_nsi->nsip.local_port);
+ }
+ vty_out(vty, " encapsulation framerelay-gre enabled %u%s",
+ vty_nsi->frgre.enabled ? 1 : 0, VTY_NEWLINE);
+ if (vty_nsi->frgre.enabled) {
+ ia.s_addr = htonl(vty_nsi->frgre.local_ip);
+ vty_out(vty, " encapsulation framerelay-gre local-ip %s%s",
+ inet_ntoa(ia), VTY_NEWLINE);
+ }
+
return CMD_SUCCESS;
}
@@ -142,6 +158,15 @@ static void dump_nse(struct vty *vty, struct gprs_nsvc *nsvc, int stats)
static void dump_ns(struct vty *vty, struct gprs_ns_inst *nsi, int stats)
{
struct gprs_nsvc *nsvc;
+ struct in_addr ia;
+
+ ia.s_addr = htonl(vty_nsi->nsip.local_ip);
+ vty_out(vty, "NS-UDP-IP Encapsulation: Local IP: %s, UDP Port: %u%s",
+ inet_ntoa(ia), vty_nsi->nsip.local_port, VTY_NEWLINE);
+
+ ia.s_addr = htonl(vty_nsi->frgre.local_ip);
+ vty_out(vty, "NS-FR-GRE-IP Encapsulation: Local IP: %s%s",
+ inet_ntoa(ia), VTY_NEWLINE);
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
if (nsvc == nsi->unknown_nsvc)
@@ -387,6 +412,66 @@ DEFUN(cfg_ns_timer, cfg_ns_timer_cmd,
return CMD_SUCCESS;
}
+#define ENCAPS_STR "NS encapsulation options\n"
+
+DEFUN(cfg_nsip_local_ip, cfg_nsip_local_ip_cmd,
+ "encapsulation udp local-ip A.B.C.D",
+ ENCAPS_STR "NS over UDP Encapsulation\n"
+ "Set the IP address on which we listen for NS/UDP\n"
+ "IP Address\n")
+{
+ struct in_addr ia;
+
+ inet_aton(argv[0], &ia);
+ vty_nsi->nsip.local_ip = ntohl(ia.s_addr);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nsip_local_port, cfg_nsip_local_port_cmd,
+ "encapsulation udp local-port <0-65535>",
+ ENCAPS_STR "NS over UDP Encapsulation\n"
+ "Set the UDP port on which we listen for NS/UDP\n"
+ "UDP port number\n")
+{
+ unsigned int port = atoi(argv[0]);
+
+ vty_nsi->nsip.local_port = port;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_frgre_local_ip, cfg_frgre_local_ip_cmd,
+ "encapsulation framerelay-gre local-ip A.B.C.D",
+ ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n"
+ "Set the IP address on which we listen for NS/FR/GRE\n"
+ "IP Address\n")
+{
+ struct in_addr ia;
+
+ if (!vty_nsi->frgre.enabled) {
+ vty_out(vty, "FR/GRE is not enabled%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ inet_aton(argv[0], &ia);
+ vty_nsi->frgre.local_ip = ntohl(ia.s_addr);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_frgre_enable, cfg_frgre_enable_cmd,
+ "encapsulation framerelay-gre enabled (1|0)",
+ ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n"
+ "Enable or disable Frame Relay over GRE\n"
+ "Enable\n" "Disable\n")
+{
+ int enabled = atoi(argv[0]);
+
+ vty_nsi->frgre.enabled = enabled;
+
+ return CMD_SUCCESS;
+}
+
DEFUN(nsvc_nsei, nsvc_nsei_cmd,
"nsvc nsei <0-65535> (block|unblock|reset)",
"Perform an operation on a NSVC\n"
@@ -472,6 +557,10 @@ int gprs_ns_vty_init(struct gprs_ns_inst *nsi)
install_element(NS_NODE, &cfg_nse_remoterole_cmd);
install_element(NS_NODE, &cfg_no_nse_cmd);
install_element(NS_NODE, &cfg_ns_timer_cmd);
+ install_element(NS_NODE, &cfg_nsip_local_ip_cmd);
+ install_element(NS_NODE, &cfg_nsip_local_port_cmd);
+ install_element(NS_NODE, &cfg_frgre_enable_cmd);
+ install_element(NS_NODE, &cfg_frgre_local_ip_cmd);
install_element(ENABLE_NODE, &nsvc_nsei_cmd);