aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-18 03:31:16 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-05-18 03:31:16 +0800
commit35e56453d2cb11847fe6b65752e1641987419773 (patch)
tree204dedf7090c0df7206a165d326deb27b7a0a90d /openbsc
parent4fcf80a59a58f920862eb6db5135e8d01e9b5e12 (diff)
msc: Add msc ip-tos NR option for the BSC
Allow to set the TOS field via the VTY interface. The SO_PRIORITY was not used as it has no effect on the packets being sent (in contrast to the documentation).
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/bsc_msc.h3
-rw-r--r--openbsc/include/openbsc/gsm_data.h1
-rw-r--r--openbsc/src/bsc_msc.c10
-rw-r--r--openbsc/src/bsc_msc_ip.c4
-rw-r--r--openbsc/src/nat/bsc_nat.c2
-rw-r--r--openbsc/src/vty_interface.c12
6 files changed, 28 insertions, 4 deletions
diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h
index 9b75def9..faf6faaa 100644
--- a/openbsc/include/openbsc/bsc_msc.h
+++ b/openbsc/include/openbsc/bsc_msc.h
@@ -32,6 +32,7 @@ struct bsc_msc_connection {
int is_authenticated;
const char *ip;
int port;
+ int prio;
void (*connection_loss) (struct bsc_msc_connection *);
void (*connected) (struct bsc_msc_connection *);
@@ -39,7 +40,7 @@ struct bsc_msc_connection {
struct timer_list timeout_timer;
};
-struct bsc_msc_connection *bsc_msc_create(const char *ip, int port);
+struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio);
int bsc_msc_connect(struct bsc_msc_connection *);
void bsc_msc_schedule_connect(struct bsc_msc_connection *);
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 65b5a3c3..4e73fd4f 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -675,6 +675,7 @@ struct gsm_network {
char *bsc_token;
char *msc_ip;
int msc_port;
+ int msc_prio;
struct bsc_msc_connection *msc_con;
int ping_timeout;
int pong_timeout;
diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c
index 3ecd1317..362450fa 100644
--- a/openbsc/src/bsc_msc.c
+++ b/openbsc/src/bsc_msc.c
@@ -163,6 +163,13 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
/* make it non blocking */
setnonblocking(fd);
+ /* set the socket priority */
+ ret = setsockopt(fd->fd, IPPROTO_IP, IP_TOS,
+ &con->prio, sizeof(con->prio));
+ if (ret != 0)
+ LOGP(DMSC, LOGL_ERROR, "Failed to set prio to %d. %s\n",
+ con->prio, strerror(errno));
+
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(con->port);
@@ -201,7 +208,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
}
-struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
+struct bsc_msc_connection *bsc_msc_create(const char *ip, int port, int prio)
{
struct bsc_msc_connection *con;
@@ -213,6 +220,7 @@ struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
con->ip = ip;
con->port = port;
+ con->prio = prio;
write_queue_init(&con->write_queue, 100);
con->write_queue.except_cb = bsc_msc_except;
return con;
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c
index 0166a76c..4d1c1a18 100644
--- a/openbsc/src/bsc_msc_ip.c
+++ b/openbsc/src/bsc_msc_ip.c
@@ -1233,7 +1233,9 @@ int main(int argc, char **argv)
if (msc_address)
msc = msc_address;
- bsc_gsmnet->msc_con = bsc_msc_create(msc, bsc_gsmnet->msc_port);
+ bsc_gsmnet->msc_con = bsc_msc_create(msc,
+ bsc_gsmnet->msc_port,
+ bsc_gsmnet->msc_prio);
if (!bsc_gsmnet->msc_con) {
fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
exit(1);
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 60af912b..a10510e8 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -1109,7 +1109,7 @@ int main(int argc, char** argv)
return -4;
/* connect to the MSC */
- nat->msc_con = bsc_msc_create(nat->msc_ip, nat->msc_port);
+ nat->msc_con = bsc_msc_create(nat->msc_ip, nat->msc_port, 0);
if (!nat->msc_con) {
fprintf(stderr, "Creating a bsc_msc_connection failed.\n");
exit(1);
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c
index aada5fa9..d16cc61f 100644
--- a/openbsc/src/vty_interface.c
+++ b/openbsc/src/vty_interface.c
@@ -27,6 +27,7 @@
#include <vty/vty.h>
#include <arpa/inet.h>
+#include <netinet/ip.h>
#include <osmocore/linuxlist.h>
#include <openbsc/gsm_data.h>
@@ -482,6 +483,7 @@ static int config_write_net(struct vty *vty)
vty_out(vty, " bsc_token %s%s", gsmnet->bsc_token, VTY_NEWLINE);
vty_out(vty, " msc ip %s%s", gsmnet->msc_ip, VTY_NEWLINE);
vty_out(vty, " msc port %d%s", gsmnet->msc_port, VTY_NEWLINE);
+ vty_out(vty, " msc ip-tos %d%s", gsmnet->msc_prio, VTY_NEWLINE);
vty_out(vty, " timeout ping %d%s", gsmnet->ping_timeout, VTY_NEWLINE);
vty_out(vty, " timeout pong %d%s", gsmnet->pong_timeout, VTY_NEWLINE);
@@ -1347,6 +1349,15 @@ DEFUN(cfg_net_msc_port,
return CMD_SUCCESS;
}
+DEFUN(cfg_net_msc_prio,
+ cfg_net_msc_prio_cmd,
+ "msc ip-tos <0-255>",
+ "Set the IP_TOS socket attribite")
+{
+ gsmnet->msc_prio = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_net_ping_time,
cfg_net_ping_time_cmd,
"timeout ping NR",
@@ -2114,6 +2125,7 @@ int bsc_vty_init(struct gsm_network *net)
install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
install_element(GSMNET_NODE, &cfg_net_msc_ip_cmd);
install_element(GSMNET_NODE, &cfg_net_msc_port_cmd);
+ install_element(GSMNET_NODE, &cfg_net_msc_prio_cmd);
install_element(GSMNET_NODE, &cfg_net_ping_time_cmd);
install_element(GSMNET_NODE, &cfg_net_pong_time_cmd);