summaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/gprs_ns.h8
-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
4 files changed, 104 insertions, 6 deletions
diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/openbsc/gprs_ns.h
index 319ff3d3..1ec66316 100644
--- a/openbsc/include/openbsc/gprs_ns.h
+++ b/openbsc/include/openbsc/gprs_ns.h
@@ -134,10 +134,14 @@ struct gprs_ns_inst {
/* NS-over-IP specific bits */
struct {
struct bsc_fd fd;
+ uint32_t local_ip;
+ uint16_t local_port;
} nsip;
/* NS-over-FR-over-GRE-over-IP specific bits */
struct {
struct bsc_fd fd;
+ uint32_t local_ip;
+ int enabled:1;
} frgre;
};
@@ -188,7 +192,7 @@ struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb);
void gprs_ns_destroy(struct gprs_ns_inst *nsi);
/* Listen for incoming GPRS packets via NS/UDP */
-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);
struct sockaddr_in;
@@ -200,7 +204,7 @@ int gprs_ns_tx_block(struct gprs_nsvc *nsvc, uint8_t cause);
int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc);
/* Listen for incoming GPRS packets via NS/FR/GRE */
-int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi, uint32_t ip);
+int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi);
/* Establish a connection (from the BSS) to the SGSN */
struct gprs_nsvc *nsip_connect(struct gprs_ns_inst *nsi,
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);