[erlang-questions] inet:getifaddrs/0 and windows

Michael Santos michael.santos@REDACTED
Wed Feb 24 02:18:24 CET 2016


On Wed, Feb 24, 2016 at 12:35:21AM +0000, Benoit Chesneau wrote:
> On Tue, Feb 23, 2016 at 9:34 PM Kenneth Lakin <kennethlakin@REDACTED>
> wrote:
> 
> > On 02/23/2016 12:12 PM, Benoit Chesneau wrote:
> > > I'm looking at the result of `inet:getifaddrs/0` and i'm not sure how to
> > > use the interface name "//DEVICE/...". Is this a device id? Any idea how
> > > i could query it using wmic?
> >
> > On my machine, the GUID part of the ifname (which is formatted as
> > \\DEvICE\TCPIP_$GUID on my Windows 7 system) corresponds to the
> > interface with the that GUID in the "SettingID" property of the "wmic
> > nicconfig show" spew.
> >
> > I've never used wmic before, so I don't know how to get the nicconfig
> > subcommand to only emit the information for a single interface, but
> > maybe you do?
> >
> >
> Thanks for the hint about SettingId, it helped a lot :)
> 
> Here is the final result getting the default route for an interface:
> https://github.com/benoitc/inet_ext/blob/master/src/inet_ext.erl#L49-L56
> 
> the code could probably be improved, but it works enough for now :)

inet_ext:gateway_for("foo ; touch /tmp/flag; echo").

:) On linux, the default gateway can be read from /proc/net/route. The
flags are defined in /usr/include/linux/route.h. So a value of 3 for
flags means RTF_UP|RTF_GATEWAY.



More information about the erlang-questions mailing list