[Olsr-dev] [PATCH v2 1/4] cfg: add SmartGateway weighing parameters
Ferry Huberts
(spam-protected)
Fri Aug 3 11:33:01 CEST 2012
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
files/olsrd.conf.default.full | 24 ++++++++++++++++++++++
files/olsrd.conf.default.lq | 24 ++++++++++++++++++++++
files/olsrd.conf.default.lq-fisheye | 24 ++++++++++++++++++++++
src/cfgparser/cfgfile_gen.c | 37 ++++++++++++++++++++++++++++++++++
src/cfgparser/olsrd_conf.c | 11 ++++++++++
src/cfgparser/oparse.y | 40 +++++++++++++++++++++++++++++++++++++
src/cfgparser/oscan.lex | 20 +++++++++++++++++++
src/olsr_cfg.h | 8 ++++++++
8 files changed, 188 insertions(+)
diff --git a/files/olsrd.conf.default.full b/files/olsrd.conf.default.full
index 077d718..71a33f5 100644
--- a/files/olsrd.conf.default.full
+++ b/files/olsrd.conf.default.full
@@ -168,6 +168,30 @@
# SmartGatewayThreshold 0
+# The weighing factor for the gateway uplink bandwidth (exit link, uplink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkUp 1
+
+# The weighing factor for the gateway downlink bandwidth (exit link, downlink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkDown 1
+
+# The weighing factor for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightEtx 1
+
+# The divider for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 0)
+
+# SmartGatewayDividerEtx 0
+
# Defines what kind of Uplink this node will publish as a
# smartgateway. The existence of the uplink is detected by
# a route to 0.0.0.0/0, ::ffff:0:0/96 and/or 2000::/3.
diff --git a/files/olsrd.conf.default.lq b/files/olsrd.conf.default.lq
index 8859eb1..4ed0650 100644
--- a/files/olsrd.conf.default.lq
+++ b/files/olsrd.conf.default.lq
@@ -105,6 +105,30 @@
# SmartGatewayThreshold 0
+# The weighing factor for the gateway uplink bandwidth (exit link, uplink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkUp 1
+
+# The weighing factor for the gateway downlink bandwidth (exit link, downlink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkDown 1
+
+# The weighing factor for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightEtx 1
+
+# The divider for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 0)
+
+# SmartGatewayDividerEtx 0
+
# Defines what kind of Uplink this node will publish as a
# smartgateway. The existence of the uplink is detected by
# a route to 0.0.0.0/0, ::ffff:0:0/96 and/or 2000::/3.
diff --git a/files/olsrd.conf.default.lq-fisheye b/files/olsrd.conf.default.lq-fisheye
index bfbd4f5..0437239 100644
--- a/files/olsrd.conf.default.lq-fisheye
+++ b/files/olsrd.conf.default.lq-fisheye
@@ -105,6 +105,30 @@
# SmartGatewayThreshold 0
+# The weighing factor for the gateway uplink bandwidth (exit link, uplink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkUp 1
+
+# The weighing factor for the gateway downlink bandwidth (exit link, downlink).
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightExitLinkDown 1
+
+# The weighing factor for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 1)
+
+# SmartGatewayWeightEtx 1
+
+# The divider for the ETX costs.
+# See README-Olsr-Extensions for a description of smart gateways.
+# (default is 0)
+
+# SmartGatewayDividerEtx 0
+
# Defines what kind of Uplink this node will publish as a
# smartgateway. The existence of the uplink is detected by
# a route to 0.0.0.0/0, ::ffff:0:0/96 and/or 2000::/3.
diff --git a/src/cfgparser/cfgfile_gen.c b/src/cfgparser/cfgfile_gen.c
index c5a6ef2..f3153d9 100644
--- a/src/cfgparser/cfgfile_gen.c
+++ b/src/cfgparser/cfgfile_gen.c
@@ -474,6 +474,43 @@ void olsrd_write_cnf_autobuf(struct autobuf *out, struct olsrd_config *cnf) {
cnf->smart_gw_thresh);
abuf_puts(out,
"\n"
+ "# The weighing factor for the gateway uplink bandwidth (exit link, uplink).\n"
+ "# See README-Olsr-Extensions for a description of smart gateways.\n"
+ "# (default is 1)\n"
+ "\n");
+ abuf_appendf(out, "%sSmartGatewayWeightExitLinkUp %d\n",
+ cnf->smart_gw_weight_exitlink_up == DEF_GW_WEIGHT_EXITLINK_UP ? "# " : "",
+ cnf->smart_gw_weight_exitlink_up);
+ abuf_puts(out,
+ "\n"
+ "# The weighing factor for the gateway downlink bandwidth (exit link, downlink).\n"
+ "# See README-Olsr-Extensions for a description of smart gateways.\n"
+ "# (default is 1)\n"
+ "\n");
+ abuf_appendf(out, "%sSmartGatewayWeightExitLinkDown %d\n",
+ cnf->smart_gw_weight_exitlink_down == DEF_GW_WEIGHT_EXITLINK_DOWN ? "# " : "",
+ cnf->smart_gw_weight_exitlink_down);
+ abuf_puts(out,
+ "\n"
+ "# The weighing factor for the ETX costs.\n"
+ "# See README-Olsr-Extensions for a description of smart gateways.\n"
+ "# (default is 1)\n"
+ "\n");
+ abuf_appendf(out, "%sSmartGatewayWeightEtx %d\n",
+ cnf->smart_gw_weight_etx == DEF_GW_WEIGHT_ETX ? "# " : "",
+ cnf->smart_gw_weight_etx);
+
+ abuf_puts(out,
+ "\n"
+ "# The divider for the ETX costs.\n"
+ "# See README-Olsr-Extensions for a description of smart gateways.\n"
+ "# (default is 0)\n"
+ "\n");
+ abuf_appendf(out, "%sSmartGatewayDividerEtx %d\n",
+ cnf->smart_gw_divider_etx == DEF_GW_DIVIDER_ETX ? "# " : "",
+ cnf->smart_gw_divider_etx);
+ abuf_puts(out,
+ "\n"
"# Defines what kind of Uplink this node will publish as a\n"
"# smartgateway. The existence of the uplink is detected by\n"
"# a route to 0.0.0.0/0, ::ffff:0:0/96 and/or 2000::/3.\n"
diff --git a/src/cfgparser/olsrd_conf.c b/src/cfgparser/olsrd_conf.c
index 32db6bf..0534034 100644
--- a/src/cfgparser/olsrd_conf.c
+++ b/src/cfgparser/olsrd_conf.c
@@ -569,6 +569,13 @@ olsrd_sanity_check_cnf(struct olsrd_config *cnf)
return -1;
}
+ /* no checks are needed on:
+ * - cnf->smart_gw_weight_exitlink_up
+ * - cnf->smart_gw_weight_exitlink_down
+ * - cnf->smart_gw_weight_etx
+ * - cnf->smart_gw_divider_etx
+ */
+
if (cnf->smart_gw_type >= GW_UPLINK_CNT) {
fprintf(stderr, "Error, illegal gateway uplink type: %d\n", cnf->smart_gw_type);
return -1;
@@ -781,6 +788,10 @@ set_default_cnf(struct olsrd_config *cnf)
cnf->smart_gw_period = DEF_GW_PERIOD;
cnf->smart_gw_stablecount = DEF_GW_STABLE_COUNT;
cnf->smart_gw_thresh = DEF_GW_THRESH;
+ cnf->smart_gw_weight_exitlink_up = DEF_GW_WEIGHT_EXITLINK_UP;
+ cnf->smart_gw_weight_exitlink_down = DEF_GW_WEIGHT_EXITLINK_DOWN;
+ cnf->smart_gw_weight_etx = DEF_GW_WEIGHT_ETX;
+ cnf->smart_gw_divider_etx = DEF_GW_DIVIDER_ETX;
cnf->smart_gw_type = DEF_GW_TYPE;
cnf->smart_gw_uplink = DEF_UPLINK_SPEED;
cnf->smart_gw_uplink_nat = DEF_GW_UPLINK_NAT;
diff --git a/src/cfgparser/oparse.y b/src/cfgparser/oparse.y
index a6da2b3..cfea5ef 100644
--- a/src/cfgparser/oparse.y
+++ b/src/cfgparser/oparse.y
@@ -219,6 +219,10 @@ static int add_ipv6_addr(YYSTYPE ipaddr_arg, YYSTYPE prefixlen_arg)
%token TOK_SMART_GW_PERIOD
%token TOK_SMART_GW_STABLECOUNT
%token TOK_SMART_GW_THRESH
+%token TOK_SMART_GW_WEIGHT_EXITLINK_UP
+%token TOK_SMART_GW_WEIGHT_EXITLINK_DOWN
+%token TOK_SMART_GW_WEIGHT_ETX
+%token TOK_SMART_GW_DIVIDER_ETX
%token TOK_SMART_GW_UPLINK
%token TOK_SMART_GW_UPLINK_NAT
%token TOK_SMART_GW_SPEED
@@ -302,6 +306,10 @@ stmt: idebug
| ismart_gw_period
| asmart_gw_stablecount
| asmart_gw_thresh
+ | asmart_gw_weight_exitlink_up
+ | asmart_gw_weight_exitlink_down
+ | asmart_gw_weight_etx
+ | asmart_gw_divider_etx
| ssmart_gw_uplink
| bsmart_gw_uplink_nat
| ismart_gw_speed
@@ -1318,6 +1326,38 @@ asmart_gw_thresh: TOK_SMART_GW_THRESH TOK_INTEGER
}
;
+asmart_gw_weight_exitlink_up: TOK_SMART_GW_WEIGHT_EXITLINK_UP TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway exitlink uplink weight: %d\n", $2->integer);
+ olsr_cnf->smart_gw_weight_exitlink_up = $2->integer;
+ free($2);
+}
+;
+
+asmart_gw_weight_exitlink_down: TOK_SMART_GW_WEIGHT_EXITLINK_DOWN TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway exitlink downlink weight: %d\n", $2->integer);
+ olsr_cnf->smart_gw_weight_exitlink_down = $2->integer;
+ free($2);
+}
+;
+
+asmart_gw_weight_etx: TOK_SMART_GW_WEIGHT_ETX TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway ETX weight: %d\n", $2->integer);
+ olsr_cnf->smart_gw_weight_etx = $2->integer;
+ free($2);
+}
+;
+
+asmart_gw_divider_etx: TOK_SMART_GW_DIVIDER_ETX TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway ETX divider: %d\n", $2->integer);
+ olsr_cnf->smart_gw_divider_etx = $2->integer;
+ free($2);
+}
+;
+
ssmart_gw_uplink: TOK_SMART_GW_UPLINK TOK_STRING
{
PARSER_DEBUG_PRINTF("Smart gateway uplink: %s\n", $2->string);
diff --git a/src/cfgparser/oscan.lex b/src/cfgparser/oscan.lex
index 7c8200c..194c53a 100644
--- a/src/cfgparser/oscan.lex
+++ b/src/cfgparser/oscan.lex
@@ -486,6 +486,26 @@ IPV6ADDR {IPV6PAT1}|{IPV6PAT2}|{IPV6PAT3}|{IPV6PAT4}|{IPV6PAT5}|{IPV6PAT6}|{IPV6
return TOK_SMART_GW_THRESH;
}
+"SmartGatewayWeightExitLinkUp" {
+ yylval = NULL;
+ return TOK_SMART_GW_WEIGHT_EXITLINK_UP;
+}
+
+"SmartGatewayWeightExitLinkDown" {
+ yylval = NULL;
+ return TOK_SMART_GW_WEIGHT_EXITLINK_DOWN;
+}
+
+"SmartGatewayWeightEtx" {
+ yylval = NULL;
+ return TOK_SMART_GW_WEIGHT_ETX;
+}
+
+"SmartGatewayDividerEtx" {
+ yylval = NULL;
+ return TOK_SMART_GW_DIVIDER_ETX;
+}
+
"SmartGatewayUplink" {
yylval = NULL;
return TOK_SMART_GW_UPLINK;
diff --git a/src/olsr_cfg.h b/src/olsr_cfg.h
index 8dc83ec..59e6d1e 100644
--- a/src/olsr_cfg.h
+++ b/src/olsr_cfg.h
@@ -85,6 +85,10 @@
#define DEF_GW_STABLE_COUNT 6
#define DEF_GW_ALLOW_NAT true
#define DEF_GW_THRESH 0
+#define DEF_GW_WEIGHT_EXITLINK_UP 1
+#define DEF_GW_WEIGHT_EXITLINK_DOWN 1
+#define DEF_GW_WEIGHT_ETX 1
+#define DEF_GW_DIVIDER_ETX 0
#define DEF_GW_TYPE GW_UPLINK_IPV46
#define DEF_GW_UPLINK_NAT true
#define DEF_UPLINK_SPEED 128
@@ -275,6 +279,10 @@ struct olsrd_config {
uint32_t smart_gw_period;
uint8_t smart_gw_stablecount;
uint8_t smart_gw_thresh;
+ uint8_t smart_gw_weight_exitlink_up;
+ uint8_t smart_gw_weight_exitlink_down;
+ uint8_t smart_gw_weight_etx;
+ uint8_t smart_gw_divider_etx;
enum smart_gw_uplinktype smart_gw_type;
uint32_t smart_gw_uplink, smart_gw_downlink;
struct olsr_ip_prefix smart_gw_prefix;
--
1.7.11.2
More information about the Olsr-dev
mailing list