summaryrefslogtreecommitdiffstats
path: root/cmds/dumpstate/utils.c
diff options
context:
space:
mode:
authorSreeram Ramachandran <sreeram@google.com>2014-07-09 00:13:15 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-09 00:13:15 +0000
commit928e05b12b21a846ac956e83d46635bbab592ea7 (patch)
tree9bb8ae9030940bd07b5deca7a714ef5af4d2200e /cmds/dumpstate/utils.c
parent1aa9565ce1c6c12c3c5b38f8fdaddd489d18fea6 (diff)
parent0d2bee0c0baec56ec98867d7e044602097525248 (diff)
downloadframeworks_native-928e05b12b21a846ac956e83d46635bbab592ea7.zip
frameworks_native-928e05b12b21a846ac956e83d46635bbab592ea7.tar.gz
frameworks_native-928e05b12b21a846ac956e83d46635bbab592ea7.tar.bz2
am 0d2bee0c: Merge "Dump all the correct routing tables."
* commit '0d2bee0c0baec56ec98867d7e044602097525248': Dump all the correct routing tables.
Diffstat (limited to 'cmds/dumpstate/utils.c')
-rw-r--r--cmds/dumpstate/utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index ef5072a..b6110c6 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -593,3 +593,22 @@ error_close_fd:
void play_sound(const char* path) {
run_command(NULL, 5, "/system/bin/stagefright", "-o", "-a", path, NULL);
}
+
+void dump_route_tables() {
+ const char* const RT_TABLES_PATH = "/data/misc/net/rt_tables";
+ dump_file("RT_TABLES", RT_TABLES_PATH);
+ FILE* fp = fopen(RT_TABLES_PATH, "r");
+ if (!fp) {
+ printf("*** %s: %s\n", RT_TABLES_PATH, strerror(errno));
+ return;
+ }
+ char table[16];
+ // Each line has an integer (the table number), a space, and a string (the table name). We only
+ // need the table number. It's a 32-bit unsigned number, so max 10 chars. Skip the table name.
+ // Add a fixed max limit so this doesn't go awry.
+ for (int i = 0; i < 64 && fscanf(fp, " %10s %*s", table) == 1; ++i) {
+ run_command("ROUTE TABLE IPv4", 10, "ip", "-4", "route", "show", "table", table, NULL);
+ run_command("ROUTE TABLE IPv6", 10, "ip", "-6", "route", "show", "table", table, NULL);
+ }
+ fclose(fp);
+}