#include "log.h"
#include "mantissa.h"
#include "net_olsr.h"
+#include "gateway.h"
#define BMSG_DBGLVL 5
if (olsr_cnf->smart_gateway_active && h->net.prefix_len == 0) {
/* this is the default route, overwrite it with the smart gateway */
- ip_addr.v4 = olsr_cnf->smart_gateway_netmask.v4;
+ ip_addr.v4 = smart_gateway_netmask.v4;
}
else {
olsr_prefix_to_netmask(&ip_addr, h->net.prefix_len);
olsr_prefix_to_netmask(&tmp_netmask, h->net.prefix_len);
if (olsr_cnf->smart_gateway_active && h->net.prefix_len == 0) {
/* this is the default gateway, so overwrite it with the smart one */
- tmp_netmask = olsr_cnf->smart_gateway_netmask;
+ tmp_netmask = smart_gateway_netmask;
}
else {
olsr_prefix_to_netmask(&tmp_netmask, h->net.prefix_len);
%token TOK_MIN_TC_VTIME
%token TOK_LOCK_FILE
%token TOK_USE_NIIT
+%token TOK_SMART_GW
+%token TOK_SMART_GW_SPEED
%token TOK_HOSTLABEL
%token TOK_NETLABEL
| amin_tc_vtime
| alock_file
| suse_niit
+ | bsmart_gw
+ | ismart_gw_speed
;
block: TOK_HNA4 hna4body
bclear_screen: TOK_CLEAR_SCREEN TOK_BOOLEAN
{
- PARSER_DEBUG_PRINTF("Clear screen %s\n", olsr_cnf->clear_screen ? "enabled" : "disabled");
+ PARSER_DEBUG_PRINTF("Clear screen %s\n", $2->boolean ? "enabled" : "disabled");
olsr_cnf->clear_screen = $2->boolean;
free($2);
}
}
;
+bsmart_gw: TOK_SMART_GW TOK_BOOLEAN
+{
+ PARSER_DEBUG_PRINTF("Smart gateway system: %s\n", $2->boolean ? "enabled" : "disabled");
+ olsr_cnf->smart_gateway_active = $2->boolean;
+ free($2);
+}
+;
+
+ismart_gw_speed: TOK_SMART_GW_SPEED TOK_INTEGER TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway speed: %u uplink/%u downlink kbit/s\n", $2->integer, $3->integer);
+ olsr_cnf->smart_gateway_uplink = $2->integer;
+ olsr_cnf->smart_gateway_downlink = $3->integer;
+ free($2);
+ free($3);
+}
+;
+
plblock: TOK_PLUGIN TOK_STRING
{
return TOK_CLEAR_SCREEN;
}
+"SmartGateway" {
+ yylval = NULL;
+ return TOK_SMART_GW;
+}
+
+"SmartGatewaySpeed" {
+ yylval = NULL;
+ return TOK_SMART_GW_SPEED;
+}
+
"UseNiit" {
yylval = NULL;
return TOK_USE_NIIT;
#include "gateway.h"
struct avl_tree gateway_tree;
-
struct olsr_cookie_info *gw_mem_cookie = NULL;
+union olsr_ip_addr smart_gateway_netmask;
static uint32_t deserialize_gw_speed(uint8_t value) {
uint32_t speed, exp;
avl_init(&gateway_tree, avl_comp_default);
- memset(&olsr_cnf->smart_gateway_netmask, 0, sizeof(olsr_cnf->smart_gateway_netmask));
+ memset(&smart_gateway_netmask, 0, sizeof(smart_gateway_netmask));
if (olsr_cnf->smart_gateway_active) {
union olsr_ip_addr gw_net;
while (ip_prefix_list_remove(&olsr_cnf->hna_entries, &gw_net, prefix));
}
- ip = (uint8_t *) &olsr_cnf->smart_gateway_netmask;
+ ip = (uint8_t *) &smart_gateway_netmask;
ip[olsr_cnf->ipsize - 2] = serialize_gw_speed(olsr_cnf->smart_gateway_uplink);
ip[olsr_cnf->ipsize - 1] = serialize_gw_speed(olsr_cnf->smart_gateway_downlink);
}
bool olsr_is_smart_gateway(union olsr_ip_addr *net, union olsr_ip_addr *mask);
void olsr_print_gateway(void);
+extern union olsr_ip_addr smart_gateway_netmask;
+
#endif /* GATEWAY_H_ */
/* Initialize HNA set */
olsr_init_hna_set();
-#if 0
- /* Initialize Layer 1/2 database */
- olsr_initialize_layer12();
-#endif
+ /* Initialize smart gateways */
+ olsr_init_gateways();
/* Start periodic SPF and RIB recalculation */
if (olsr_cnf->lq_dinter > 0.0) {
bool smart_gateway_active;
uint32_t smart_gateway_uplink;
uint32_t smart_gateway_downlink;
- union olsr_ip_addr smart_gateway_netmask;
int ioctl_s; /* Socket used for ioctl calls */
#if LINUX_POLICY_ROUTING