summaryrefslogtreecommitdiffstats
path: root/src/gb
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-25 11:59:58 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-25 12:06:36 +0100
commit2c3393d9e3fc1999641d8dab3b59418393c4b616 (patch)
tree9c6468a3a3697401968fcf9e08f1c80cd8624dcf /src/gb
parent1c83e36cc930f5efc17fd66ccb9a6c541e44c5de (diff)
gprs_ns: Allow to set the DSCP for the UDP socket.
Allow to tag the NS service with a custom DSCP.
Diffstat (limited to 'src/gb')
-rw-r--r--src/gb/Makefile.am3
-rw-r--r--src/gb/gprs_ns.c7
-rw-r--r--src/gb/gprs_ns_vty.c14
3 files changed, 24 insertions, 0 deletions
diff --git a/src/gb/Makefile.am b/src/gb/Makefile.am
index 8b7473db..af457205 100644
--- a/src/gb/Makefile.am
+++ b/src/gb/Makefile.am
@@ -1,3 +1,6 @@
+# FIXME: LIBVERSION adjustments required for next version
+# ABI of gprs_ns structure changed by adding DSCP.
+#
# This is _NOT_ the library release version, it's an API version.
# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
LIBVERSION=2:0:0
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index cdcf36e1..ef937d9e 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -1051,6 +1051,13 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
if (ret < 0)
return ret;
+ ret = setsockopt(nsi->nsip.fd.fd, IPPROTO_IP, IP_TOS,
+ &nsi->nsip.dscp, sizeof(nsi->nsip.dscp));
+ if (ret < 0)
+ LOGP(DNS, LOGL_ERROR,
+ "Failed to set the DSCP to %d with ret(%d) errno(%d)\n",
+ nsi->nsip.dscp, ret, errno);
+
return ret;
}
diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c
index fac431cb..a2e7beb9 100644
--- a/src/gb/gprs_ns_vty.c
+++ b/src/gb/gprs_ns_vty.c
@@ -131,6 +131,9 @@ static int config_write_ns(struct vty *vty)
if (vty_nsi->nsip.local_port)
vty_out(vty, " encapsulation udp local-port %u%s",
vty_nsi->nsip.local_port, VTY_NEWLINE);
+ if (vty_nsi->nsip.dscp)
+ vty_out(vty, " encapsulation udp dscp %d%s",
+ vty_nsi->nsip.dscp, VTY_NEWLINE);
vty_out(vty, " encapsulation framerelay-gre enabled %u%s",
vty_nsi->frgre.enabled ? 1 : 0, VTY_NEWLINE);
@@ -454,6 +457,16 @@ DEFUN(cfg_nsip_local_port, cfg_nsip_local_port_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_nsip_dscp, cfg_nsip_dscp_cmd,
+ "encapsulation udp dscp <0-255>",
+ ENCAPS_STR "NS over UDP Encapsulation\n"
+ "Set DSCP/TOS on the UDP socket\n" "DSCP Value\n")
+{
+ int dscp = atoi(argv[0]);
+ vty_nsi->nsip.dscp = dscp;
+ 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"
@@ -572,6 +585,7 @@ int gprs_ns_vty_init(struct gprs_ns_inst *nsi)
install_element(L_NS_NODE, &cfg_ns_timer_cmd);
install_element(L_NS_NODE, &cfg_nsip_local_ip_cmd);
install_element(L_NS_NODE, &cfg_nsip_local_port_cmd);
+ install_element(L_NS_NODE, &cfg_nsip_dscp_cmd);
install_element(L_NS_NODE, &cfg_frgre_enable_cmd);
install_element(L_NS_NODE, &cfg_frgre_local_ip_cmd);