title: How can I programmatically find the IP address/netmask/gateway configured for a specific network device in Linux?
body: <p>I would like to write a piece of code which checks, for each network device (e.g. eth0, lo, master devices) some statistics and configuration data about that device.<br>
  I could find the statistics data (and most of the configuration data) in /sys/class/net/..., however, I couldn't find any C/C++ API or any entry in procfs/sysfs listing the inet addr, netmask and gateway.  </p>
  
  <p>Some alternatives I checked:</p>
  
  <ul>
  <li>parsing the output from ifconfig/route/some other utilities: I don't want to start a subprocess every time I need to do the inspection.</li>
  <li>parsing /etc/sysconfig/network-scripts/: will give me only the start-up configuration, and not the current state.</li>
  </ul>
  
  <p>Also, since this code is intended for a product in my workplace, where every external library is inspected thoroughly (meaning it will take me forever to add any external library) I prefer solutions which rely on Linux native API and not external libraries.</p>
  
  <p>Thanks!</p>