The contents of the analysis file / proc / net / route

How to analyze the contents of the / proc / net / route file for Android.

I use the "cat" command to read the file

 `process proc_route = Runtime.getRuntime().exec("cat /proc/net/route");`

He shows a conclusion like this

Iface Destination Gateway Flags RefCnt Use Metric Mask Mtu Window IRTT       
eth0  0202000A 00000000 0005 0 0 0 FFFFFFFF 0 0 0    
eth0  0002000A 00000000 0001 0 0 0 FFFFFFFF 0 0 0       
eth0  00000000 00000000 0003 0 0 0 00000000 0 0 0

I want the result to be like

Iface Destination Gateway  Flags RefCnt Use   Metric Mask               Mtu Window IRTT    
eth0  10.0.2.2    0.0.0.0  0005  0      0     0      255.255.255.255    0   0      0
eth0  10.0.2.0    0.0.0.0  0001  0      0     0      255.255.255.255    0   0      0
eth0  10.0.0.0    0.0.0.0  0003  0      0     0      0.0.0.0            0   0      0

Is there a command or utility for this?

+4
source share
1 answer

This link may help you later if someone else is looking for a solution to this problem Odd bits . Essentially, the address is in small form in endian hex format, and you need to convert it to decimal dotted form.

0
source

Source: https://habr.com/ru/post/1532271/


All Articles