diff options
| author | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-25 11:59:58 +0100 | 
|---|---|---|
| committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-25 12:06:36 +0100 | 
| commit | 2c3393d9e3fc1999641d8dab3b59418393c4b616 (patch) | |
| tree | 9c6468a3a3697401968fcf9e08f1c80cd8624dcf | |
| parent | 1c83e36cc930f5efc17fd66ccb9a6c541e44c5de (diff) | |
gprs_ns: Allow to set the DSCP for the UDP socket.
Allow to tag the NS service with a custom DSCP.
| -rw-r--r-- | include/osmocom/gprs/gprs_ns.h | 1 | ||||
| -rw-r--r-- | src/gb/Makefile.am | 3 | ||||
| -rw-r--r-- | src/gb/gprs_ns.c | 7 | ||||
| -rw-r--r-- | src/gb/gprs_ns_vty.c | 14 | 
4 files changed, 25 insertions, 0 deletions
| diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index a7f32b25..8fca70cb 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -73,6 +73,7 @@ struct gprs_ns_inst {  		struct osmo_fd fd;  		uint32_t local_ip;  		uint16_t local_port; +		int dscp;  	} nsip;  	/*! \brief NS-over-FR-over-GRE-over-IP specific bits */  	struct { 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); | 
