From ca660ac9caff1cbf15e9bfa1820f49575f3a1f77 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 31 May 2010 10:36:35 +0800 Subject: [nat] Add ip-tos option to the nat. This is applied to all incoming BSC connections. --- openbsc/include/openbsc/bsc_nat.h | 1 + openbsc/src/nat/bsc_nat.c | 5 +++++ openbsc/src/nat/bsc_nat_vty.c | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 00d2cba13..f39afafb7 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -220,6 +220,7 @@ struct bsc_nat { /* known BSC's */ struct llist_head bsc_configs; int num_bsc; + int bsc_ip_tos; /* MGCP config */ struct mgcp_config *mgcp_cfg; diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index a10510e8d..de24fd3f5 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -872,6 +872,11 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) if (rc != 0) LOGP(DNAT, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); + rc = setsockopt(fd, IPPROTO_IP, IP_TOS, + &nat->bsc_ip_tos, sizeof(nat->bsc_ip_tos)); + if (rc != 0) + LOGP(DNAT, LOGL_ERROR, "Failed to set IP_TOS: %s\n", strerror(errno)); + /* todo... do something with the connection */ /* todo... use GNUtls to see if we want to trust this as a BTS */ diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index 56cd3c40a..cef47d1b3 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -61,6 +61,7 @@ static int config_write_nat(struct vty *vty) vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); if (_nat->token) vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); + vty_out(vty, " ip-tos %d%s", _nat->bsc_ip_tos, VTY_NEWLINE); return CMD_SUCCESS; } @@ -297,6 +298,14 @@ DEFUN(cfg_nat_token, cfg_nat_token_cmd, return CMD_SUCCESS; } +DEFUN(cfg_nat_bsc_ip_tos, cfg_nat_bsc_ip_tos_cmd, + "ip-tos <0-255>", + "Set the IP_TOS for the BSCs to use\n" "Set the IP_TOS attribute") +{ + _nat->bsc_ip_tos = atoi(argv[0]); + return CMD_SUCCESS; +} + /* per BSC configuration */ DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "Select a BSC to configure") { @@ -458,6 +467,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_ping_time_cmd); install_element(NAT_NODE, &cfg_nat_pong_time_cmd); install_element(NAT_NODE, &cfg_nat_token_cmd); + install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); /* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); -- cgit v1.2.3