The following commit has been merged in the next branch: commit e2c2190a1a5b1b95ef30adba9b18503bb4b7359e Author: Marek Lindner lindner_marek@yahoo.de Date: Sat Jan 9 14:43:58 2010 +0100
batctl: add support for gateway mode
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
diff --git a/debug.c b/debug.c index c77b1e4..1dbc204 100644 --- a/debug.c +++ b/debug.c @@ -61,6 +61,15 @@ void trans_global_usage(void) printf(" \t -w [interval] watch mode - refresh the global translation table continuously\n"); }
+void gateways_usage(void) +{ + printf("Usage: batctl [options] gateways \n"); + printf("options:\n"); + printf(" \t -h print this help\n"); + printf(" \t -n don't replace mac addresses with bat-host names\n"); + printf(" \t -w [interval] watch mode - refresh the gateway server list continuously\n"); +} + int handle_debug_table(char *mesh_iface, int argc, char **argv, char *file_path, void table_usage(void)) { diff --git a/debug.h b/debug.h index 54c4a45..8bed80e 100644 --- a/debug.h +++ b/debug.h @@ -24,12 +24,14 @@ #define DEBUG_ORIGINATORS "originators" #define DEBUG_TRANSTABLE_LOCAL "transtable_local" #define DEBUG_TRANSTABLE_GLOBAL "transtable_global" +#define DEBUG_GATEWAYS "gateways" #define DEBUG_VIS_DATA "vis_data" #define DEBUG_LOG "log"
void originators_usage(void); void trans_local_usage(void); void trans_global_usage(void); +void gateways_usage(void); int handle_debug_table(char *mesh_iface, int argc, char **argv, char *file_path, void table_usage(void)); int log_print(char *mesh_iface, int argc, char **argv); diff --git a/main.c b/main.c index 0e335d1..5e3f5d8 100644 --- a/main.c +++ b/main.c @@ -48,6 +48,8 @@ void print_usage(void) { printf(" \tinterval|it [orig_interval] \tdisplay or modify the originator interval (in ms)\n"); printf(" \tloglevel|ll [level] \tdisplay or modify the log level\n"); printf(" \tlog|l \tread the log produced by the kernel module\n"); + printf(" \tgw_mode|gw [mode] \tdisplay or modify the gateway mode\n"); + printf(" \tgateways|gwl \tdisplay the gateway server list\n"); printf(" \ttranslocal|tl \tdisplay the local translation table\n"); printf(" \ttransglobal|tg \tdisplay the global translation table\n"); printf(" \tvis_mode|vm [mode] \tdisplay or modify the status of the VIS server\n"); @@ -156,6 +158,16 @@ int main(int argc, char **argv)
ret = vis_data(mesh_iface, argc - 1, argv + 1);
+ } else if ((strcmp(argv[1], "gw_mode") == 0) || (strcmp(argv[1], "gw") == 0)) { + + ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, + SYS_GW_MODE, gw_mode_usage, sysfs_param_server); + + } else if ((strcmp(argv[1], "gateways") == 0) || (strcmp(argv[1], "gwl") == 0)) { + + ret = handle_debug_table(mesh_iface, argc - 1, argv + 1, + DEBUG_GATEWAYS, gateways_usage); + } else if ((strcmp(argv[1], "aggregation") == 0) || (strcmp(argv[1], "ag") == 0)) {
ret = handle_sys_setting(mesh_iface, argc - 1, argv + 1, diff --git a/man/batctl.8 b/man/batctl.8 index c4fa9b0..d206328 100644 --- a/man/batctl.8 +++ b/man/batctl.8 @@ -70,6 +70,51 @@ If no parameter is given the current log level settings are displayed otherwise .IP "\fBlog\fP|\fBl\fP [\fB-n\fP]\fP" batctl will read the batman-adv debug log which has to be compiled into the kernel module. If "-n" is given batctl will not replace the MAC addresses with bat-host names in the output. .br +.IP "\fBgw_mode|gw\fP [\fBoff\fP|\fBclient\fP|\fBserver\fP] [\fBgw_class\fP]\fP" +If no parameter is given the current gateway mode is displayed otherwise the parameter is used to set the gateway mode. The second (optional) argument specifies the gateway class. Its function depends on whether the node is a server or a client. If the node is a server this parameter is used to inform other nodes in the network about this node's internet connection bandwidth. Just enter any number (optionally followed by "kbit" or "mbit") and the batman-adv module will guess your appropriate gateway class. Use "/" to separate the down(hy and upload rates. You can omit the upload rate and the module will assume an upload of download / 5. +.RS 17 +default: 2000 -> gateway class 20 +.RE +.RS 16 +examples: 5000 -> gateway class 49 +.RE +.RS 25 + 5000kbit + 5mbit + 5mbit/1024 + 5mbit/1024kbit + 5mbit/1mbit +.RE +.RS 7 +If the node is a gateway client the parameter will decide which criterias to consider when the batman-adv module has to choose between different internet connections announced by the aforementioned servers. +.RE +.RS 17 +default: 20 -> late switch (TQ 20) +.RE +.RS 16 +examples: 1 -> fast connection +.RS 16 +consider the gateway's advertised throughput as well as the link quality towards the gateway +.RE +.RE +.RS 25 + 2 -> stable connection +.RS 7 +chooses the gateway with the best link quality and stick with it (ignore the advertised throughput) +.RE + 3 -> fast switch connection +.RS 7 +chooses the gateway with the best link quality but switches to another gateway as soon as a better one is found +.RE + XX -> late switch connection +.RS 7 +chooses the gateway with the best link quality but switches to another gateway as soon as a better one is found which is at least XX TQ better than the currently selected gateway (XX has to be a number between 3 and 256). +.RE +.RE +.br +.IP "\fBgateways|gwl\fP [\fB-w\fP [\fI\interval\fP]][\fB-n\fP]" +Once started batctl will display the list of announced gateways in the network. Use the "-w" option to let batctl refresh the list every second or add a number to let it refresh at a custom interval in seconds (with optional decimal places). If "-n" was given batctl will not replace the mac addresses with bat-host names in the output. +.br .IP "\fBtranslocal\fP|\fBtl\fP [\fB-w\fP [\fI\interval\fP]][\fB-n\fP]" Display the local translation table. batctl will refresh the list every second if the "-w" option was given or add a number to let it refresh at a custom interval in seconds (with optional decimal places). Use "-n" to let batctl not replace the MAC addresses with bat-host names in the output. .br diff --git a/packet.h b/packet.h index 2693383..b49fdf7 100644 --- a/packet.h +++ b/packet.h @@ -32,7 +32,7 @@ #define BAT_UNICAST_FRAG 0x06
/* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 13 +#define COMPAT_VERSION 12 #define DIRECTLINK 0x40 #define VIS_SERVER 0x20 #define PRIMARIES_FIRST_HOP 0x10 @@ -61,6 +61,8 @@ struct batman_packet { uint8_t prev_sender[6]; uint8_t ttl; uint8_t num_hna; + uint8_t gw_flags; /* flags related to gateway class */ + uint8_t align; } __attribute__((packed));
#define BAT_PACKET_LEN sizeof(struct batman_packet) diff --git a/sys.c b/sys.c index ff7fc54..79d9612 100644 --- a/sys.c +++ b/sys.c @@ -239,6 +239,13 @@ void bonding_usage(void) printf(" \t -h print this help\n"); }
+void gw_mode_usage(void) +{ + printf("Usage: batctl [options] gw_mode [mode]\n"); + printf("options:\n"); + printf(" \t -h print this help\n"); +} + void vis_mode_usage(void) { printf("Usage: batctl [options] vis_mode [mode]\n"); diff --git a/sys.h b/sys.h index 5ffa455..71362f1 100644 --- a/sys.h +++ b/sys.h @@ -25,6 +25,7 @@ #define SYS_LOG "log" #define SYS_AGGR "aggregated_ogms" #define SYS_BONDING "bonding" +#define SYS_GW_MODE "gw_mode" #define SYS_VIS_MODE "vis_mode" #define SYS_ORIG_INTERVAL "orig_interval" #define SYS_IFACE_PATH "/sys/class/net" @@ -38,6 +39,7 @@ extern const char *sysfs_param_server[]; void aggregation_usage(void); void bonding_usage(void); void fragmentation_usage(void); +void gw_mode_usage(void); void vis_mode_usage(void); void orig_interval_usage(void); int interface(char *mesh_iface, int argc, char **argv); diff --git a/tcpdump.c b/tcpdump.c index 7511b40..08a662a 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -262,13 +262,14 @@ static void dump_batman_ogm(unsigned char *packet_buff, ssize_t buff_len, int re printf("BAT %s: ", get_name_by_macaddr((struct ether_addr *)batman_packet->orig, read_opt));
- printf("OGM via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c], length %zu\n", + printf("OGM via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c%c], length %zu\n", get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt), ntohl(batman_packet->seqno), batman_packet->tq, batman_packet->ttl, batman_packet->version, (batman_packet->flags & DIRECTLINK ? 'D' : '.'), (batman_packet->flags & VIS_SERVER ? 'V' : '.'), (batman_packet->flags & PRIMARIES_FIRST_HOP ? 'F' : '.'), + (batman_packet->gw_flags ? 'G' : '.'), (size_t)buff_len - sizeof(struct ether_header)); }