Changeset 1595
- Timestamp:
- 03/11/10 20:19:01 (6 months ago)
- Location:
- trunk/batctl
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/batctl/functions.c
r1585 r1595 37 37 #include "bat-hosts.h" 38 38 39 #define BATMAN_ADV_TAG "batman-adv:"40 41 39 static struct timeval start_time; 42 40 static char *host_name; … … 176 174 read: 177 175 while ((read = getline(&line_ptr, &len, fp)) != -1) { 176 if (read_opt & SEARCH_ARGS) { 177 /* omit log lines which don't start with the correct tag */ 178 if (strncmp(line_ptr, SEARCH_ARGS_TAG, strlen(SEARCH_ARGS_TAG)) == 0) 179 break; 180 181 continue; 182 } 178 183 179 184 /* the buffer will be handled elsewhere */ -
trunk/batctl/functions.h
r1511 r1595 26 26 27 27 #define ETH_STR_LEN 17 28 #define BATMAN_ADV_TAG "batman-adv:" 29 #define SEARCH_ARGS_TAG "commands:" 28 30 29 31 /* return time delta from start to end in milliseconds */ … … 46 48 LOG_MODE = 0x08, 47 49 USE_READ_BUFF = 0x10, 50 SEARCH_ARGS = 0x20, 48 51 }; -
trunk/batctl/main.c
r1541 r1595 103 103 } else if ((strcmp(argv[1], "originators") == 0) || (strcmp(argv[1], "o") == 0)) { 104 104 105 ret = handle_ table(argc - 1, argv + 1, PROC_ORIGINATORS, originators_usage);105 ret = handle_sys_table(argc - 1, argv + 1, SYS_ORIGINATORS, originators_usage); 106 106 107 107 } else if ((strcmp(argv[1], "translocal") == 0) || (strcmp(argv[1], "tl") == 0)) { 108 108 109 ret = handle_ table(argc - 1, argv + 1, PROC_TRANSTABLE_LOCAL, trans_local_usage);109 ret = handle_sys_table(argc - 1, argv + 1, SYS_TRANSTABLE_LOCAL, trans_local_usage); 110 110 111 111 } else if ((strcmp(argv[1], "transglobal") == 0) || (strcmp(argv[1], "tg") == 0)) { 112 112 113 ret = handle_ table(argc - 1, argv + 1, PROC_TRANSTABLE_GLOBAL, trans_global_usage);113 ret = handle_sys_table(argc - 1, argv + 1, SYS_TRANSTABLE_GLOBAL, trans_global_usage); 114 114 115 115 } else if ((strcmp(argv[1], "loglevel") == 0) || (strcmp(argv[1], "ll") == 0)) { … … 143 143 } else if ((strcmp(argv[1], "aggregation") == 0) || (strcmp(argv[1], "ag") == 0)) { 144 144 145 ret = handle_ proc_setting(argc - 1, argv + 1, PROC_AGGR, aggregation_usage);145 ret = handle_sys_setting(argc - 1, argv + 1, SYS_AGGR, aggregation_usage); 146 146 147 147 } else if ((strcmp(argv[1], "bisect") == 0)) { -
trunk/batctl/proc.c
r1560 r1595 69 69 } 70 70 71 void originators_usage(void)72 {73 printf("Usage: batctl [options] originators \n");74 printf("options:\n");75 printf(" \t -h print this help\n");76 printf(" \t -n don't replace mac addresses with bat-host names\n");77 printf(" \t -w watch mode - refresh the originator table continuously\n");78 }79 80 void trans_local_usage(void)81 {82 printf("Usage: batctl [options] translocal \n");83 printf("options:\n");84 printf(" \t -h print this help\n");85 printf(" \t -n don't replace mac addresses with bat-host names\n");86 printf(" \t -w watch mode - refresh the local translation table continuously\n");87 }88 89 void trans_global_usage(void)90 {91 printf("Usage: batctl [options] transglobal \n");92 printf("options:\n");93 printf(" \t -h print this help\n");94 printf(" \t -n don't replace mac addresses with bat-host names\n");95 printf(" \t -w watch mode - refresh the global translation table continuously\n");96 }97 98 71 void gw_srv_list_usage(void) 99 72 { … … 115 88 { 116 89 printf("Usage: batctl [options] vis_server \n"); 117 printf("options:\n");118 printf(" \t -h print this help\n");119 }120 121 void aggregation_usage(void)122 {123 printf("Usage: batctl [options] aggregation \n");124 90 printf("options:\n"); 125 91 printf(" \t -h print this help\n"); -
trunk/batctl/proc.h
r1541 r1595 22 22 #define PROC_ROOT_PATH "/proc/net/batman-adv/" 23 23 #define PROC_INTERFACES "interfaces" 24 #define PROC_ORIGINATORS "originators"25 24 #define PROC_ORIG_INTERVAL "orig_interval" 26 #define PROC_TRANSTABLE_LOCAL "transtable_local"27 #define PROC_TRANSTABLE_GLOBAL "transtable_global"28 25 #define PROC_VIS_SERVER "vis_server" 29 26 #define PROC_VIS_DATA "vis_data" 30 #define PROC_AGGR "aggregate_ogm"31 27 #define PROC_GW_MODE "gateway_mode" 32 28 #define PROC_GW_SRV_LIST "gateway_srv_list" … … 34 30 int interface(int argc, char **argv); 35 31 36 void originators_usage(void);37 void trans_local_usage(void);38 void trans_global_usage(void);39 32 void orig_interval_usage(void); 40 33 void vis_server_usage(void); 41 void aggregation_usage(void);42 34 void gw_mode_usage(void); 43 35 void gw_srv_list_usage(void); -
trunk/batctl/sys.c
r1567 r1595 1 1 /* 2 * Copyright (C) 2009 B.A.T.M.A.N. contributors:2 * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: 3 3 * 4 4 * Marek Lindner <lindner_marek@yahoo.de> … … 95 95 96 96 if (argc != 1) { 97 res = write_file(SYS_ ROOT_PATH, SYS_LOG_LEVEL, argv[1]);97 res = write_file(SYS_MODULE_PATH, SYS_LOG_LEVEL, argv[1]); 98 98 goto out; 99 99 } 100 100 101 res = read_file(SYS_ ROOT_PATH, SYS_LOG_LEVEL, SINGLE_READ | USE_READ_BUFF);101 res = read_file(SYS_MODULE_PATH, SYS_LOG_LEVEL, SINGLE_READ | USE_READ_BUFF); 102 102 103 103 if (res != EXIT_SUCCESS) … … 119 119 return res; 120 120 } 121 122 void originators_usage(void) 123 { 124 printf("Usage: batctl [options] originators \n"); 125 printf("options:\n"); 126 printf(" \t -h print this help\n"); 127 printf(" \t -n don't replace mac addresses with bat-host names\n"); 128 printf(" \t -w watch mode - refresh the originator table continuously\n"); 129 } 130 131 void trans_local_usage(void) 132 { 133 printf("Usage: batctl [options] translocal \n"); 134 printf("options:\n"); 135 printf(" \t -h print this help\n"); 136 printf(" \t -n don't replace mac addresses with bat-host names\n"); 137 printf(" \t -w watch mode - refresh the local translation table continuously\n"); 138 } 139 140 void trans_global_usage(void) 141 { 142 printf("Usage: batctl [options] transglobal \n"); 143 printf("options:\n"); 144 printf(" \t -h print this help\n"); 145 printf(" \t -n don't replace mac addresses with bat-host names\n"); 146 printf(" \t -w watch mode - refresh the global translation table continuously\n"); 147 } 148 149 int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void)) 150 { 151 int optchar, read_opt = USE_BAT_HOSTS; 152 153 while ((optchar = getopt(argc, argv, "hnw")) != -1) { 154 switch (optchar) { 155 case 'h': 156 table_usage(); 157 return EXIT_SUCCESS; 158 case 'n': 159 read_opt &= ~USE_BAT_HOSTS; 160 break; 161 case 'w': 162 read_opt |= CLR_CONT_READ; 163 break; 164 default: 165 table_usage(); 166 return EXIT_FAILURE; 167 } 168 } 169 170 return read_file(SYS_BATIF_PATH, file_path, read_opt); 171 } 172 173 void aggregation_usage(void) 174 { 175 printf("Usage: batctl [options] aggregation \n"); 176 printf("options:\n"); 177 printf(" \t -h print this help\n"); 178 } 179 180 int handle_sys_setting(int argc, char **argv, char *file_path, void setting_usage(void)) 181 { 182 int optchar, res; 183 char *space_ptr, *comma_char, *cmds = NULL; 184 185 while ((optchar = getopt(argc, argv, "h")) != -1) { 186 switch (optchar) { 187 case 'h': 188 setting_usage(); 189 return EXIT_SUCCESS; 190 default: 191 setting_usage(); 192 return EXIT_FAILURE; 193 } 194 } 195 196 if (argc == 1) 197 return read_file(SYS_BATIF_PATH, file_path, SINGLE_READ); 198 199 res = read_file(SYS_BATIF_PATH, file_path, SEARCH_ARGS); 200 if (res != EXIT_SUCCESS) 201 return res; 202 203 while ((space_ptr = strchr(line_ptr, ' ')) != NULL) { 204 *space_ptr = '\0'; 205 206 if (strncmp(line_ptr, SEARCH_ARGS_TAG, strlen(SEARCH_ARGS_TAG)) == 0) { 207 cmds = space_ptr + 1; 208 goto next; 209 } 210 211 comma_char = NULL; 212 if (line_ptr[strlen(line_ptr) - 1] == ',') { 213 comma_char = line_ptr + strlen(line_ptr) - 1; 214 *comma_char = '\0'; 215 } 216 217 if (strcmp(line_ptr, argv[1]) == 0) 218 goto write_file; 219 220 *space_ptr = ' '; 221 if (comma_char) 222 *comma_char = ','; 223 224 next: 225 line_ptr = space_ptr + 1; 226 } 227 228 if (!cmds) 229 goto write_file; 230 231 printf("Error - the supplied argument is invalid: %s\n", argv[1]); 232 printf("The following values are allowed: %s", cmds); 233 return EXIT_FAILURE; 234 235 write_file: 236 return write_file(SYS_BATIF_PATH, file_path, argv[1]); 237 } -
trunk/batctl/sys.h
r1483 r1595 1 1 /* 2 * Copyright (C) 2009 B.A.T.M.A.N. contributors:2 * Copyright (C) 2009-2010 B.A.T.M.A.N. contributors: 3 3 * 4 4 * Marek Lindner <lindner_marek@yahoo.de> … … 21 21 22 22 23 #define SYS_ROOT_PATH "/sys/module/batman_adv/" 23 #define SYS_MODULE_PATH "/sys/module/batman_adv/" 24 #define SYS_BATIF_PATH "/sys/class/net/bat0/mesh/" 24 25 #define SYS_LOG_LEVEL "parameters/debug" 25 26 #define SYS_LOG "log" 27 #define SYS_ORIGINATORS "originators" 28 #define SYS_TRANSTABLE_LOCAL "transtable_local" 29 #define SYS_TRANSTABLE_GLOBAL "transtable_global" 30 #define SYS_AGGR "aggregate_ogm" 26 31 27 32 void originators_usage(void); 33 void trans_local_usage(void); 34 void trans_global_usage(void); 35 void aggregation_usage(void); 36 void bonding_usage(void); 28 37 int log_print(int argc, char **argv); 29 38 int handle_loglevel(int argc, char **argv); 39 int handle_sys_table(int argc, char **argv, char *file_path, void table_usage(void)); 40 int handle_sys_setting(int argc, char **argv, char *file_path, void setting_usage(void));
