[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] getifaddrs wrapper

From: Ludovic Courtès
Subject: Re: [PATCH] getifaddrs wrapper
Date: Sat, 25 Jul 2015 14:59:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hi Rohan,

Sorry for the delay.  Commit e7f5691 adds the ‘getifaddrs’ bindings
under the name ‘network-interfaces’ (there was already a procedure with
that name, which I’ve renamed to ‘network-interface-names’ in b89e740.)

I ended up doing things differently from your patch, notably because I
was willing to get more support from ‘define-c-struct’, which led me to
find a couple of shortcomings that needed to be fixed (apologies for not
noticing these earlier!).

I’ve written tests which, unlike yours, do not use the ‘ifconfig’
command, mostly because there are several ‘ifconfig’ implementations so
I doubt we can reliably parse their output, and because I don’t want
tests to introduce an additional dependency.

Anyway, now one can do things like this:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix build syscalls)
scheme@(guile-user)> ,use(srfi srfi-1)
scheme@(guile-user)> (network-interfaces)
$13 = (#<interface "lo" up family:17 16cb380> #<interface "eno1" up family:17 
16cb340> #<interface "wlp0s29u1u2" up family:17 16cb300> #<interface "lo" up 16cb2c0> #<interface "wlp0s29u1u2" up 16cb280> 
#<interface "lo" up 0:0:0:1:: 16cb1c0> #<interface "wlp0s29u1u2" up 
6202:b4ff:fe99:9b36:300:: 16cb100>)
scheme@(guile-user)> (filter (lambda (i)
                               (= AF_INET6 (sockaddr:fam (interface-address 
$14 = (#<interface "lo" up 0:0:0:1:: 1ba0b80> #<interface "wlp0s29u1u2" up 
6202:b4ff:fe99:9b36:300:: 1ba0ac0>)
--8<---------------cut here---------------end--------------->8---

Pretty neat, no?  :-)

Note that family 17 is AF_PACKET.  Currently libguile does not support
AF_PACKET, which means we cannot do much with these addresses.

Comments & bug reports welcome!

Thanks again for your earlier work on this.  Even if the final patch is
different, your work and the discussions we’ve had have been helpful in
getting things into shape.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]