<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Feb 24, 2016 at 2:16 AM Michael Santos <<a href="mailto:michael.santos@gmail.com">michael.santos@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Feb 24, 2016 at 12:35:21AM +0000, Benoit Chesneau wrote:<br>
> On Tue, Feb 23, 2016 at 9:34 PM Kenneth Lakin <<a href="mailto:kennethlakin@gmail.com" target="_blank">kennethlakin@gmail.com</a>><br>
> wrote:<br>
><br>
> > On 02/23/2016 12:12 PM, Benoit Chesneau wrote:<br>
> > > I'm looking at the result of `inet:getifaddrs/0` and i'm not sure how to<br>
> > > use the interface name "//DEVICE/...". Is this a device id? Any idea how<br>
> > > i could query it using wmic?<br>
> ><br>
> > On my machine, the GUID part of the ifname (which is formatted as<br>
> > \\DEvICE\TCPIP_$GUID on my Windows 7 system) corresponds to the<br>
> > interface with the that GUID in the "SettingID" property of the "wmic<br>
> > nicconfig show" spew.<br>
> ><br>
> > I've never used wmic before, so I don't know how to get the nicconfig<br>
> > subcommand to only emit the information for a single interface, but<br>
> > maybe you do?<br>
> ><br>
> ><br>
> Thanks for the hint about SettingId, it helped a lot :)<br>
><br>
> Here is the final result getting the default route for an interface:<br>
> <a href="https://github.com/benoitc/inet_ext/blob/master/src/inet_ext.erl#L49-L56" rel="noreferrer" target="_blank">https://github.com/benoitc/inet_ext/blob/master/src/inet_ext.erl#L49-L56</a><br>
><br>
> the code could probably be improved, but it works enough for now :)<br>
<br>
inet_ext:gateway_for("foo ; touch /tmp/flag; echo").<br>
<br>
:) On linux, the default gateway can be read from /proc/net/route. The<br>
flags are defined in /usr/include/linux/route.h. So a value of 3 for<br>
flags means RTF_UP|RTF_GATEWAY.<br></blockquote><div><br></div><div><br></div><div>oups :) i tagged the 0.4 that is no exposing this API anymore. Thanks!</div><div><br></div><div>Thanks for the tip anyway I should have a look. For now the lib does the job but the final goal would be having some portable C code to skip the need to call and parse the results from a script.  Hopefully that won't be that hard :)</div><div><br></div><div>- benoi</div></div></div>