From: storm@cua.dk (Kim F. Storm)
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Patch for network-interface-{list,info}
Date: 17 Nov 2003 13:23:32 +0100 [thread overview]
Message-ID: <m3k75zyyij.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <87ad6w2hm6.fsf@Dora.local.>
[To RMS: We need papers from Alex to use his patches]
Alex Plotnick <shrike@netaxs.com> writes:
> I noticed that the functions `network-interface-info' and
> `network-interface-list' did not work on Darwin 6.8 (Mac OS X 10.2.8).
> After some investigation, I determined that they probably would not work on
> some other BSDs as well. The following patch addresses some of the issues.
>
> The use of ioctl(SIOCGIFCONF) to fetch the list of network interfaces is
> prone to some interesting problems. In particular, the size of the
> returned structures (struct ifreq) is not constant on some systems (e.g.,
> Darwin), making the buffer resizing and list iteration somewhat tricky.
Ah, yes, I'd forgotten all about the sa_len issue... Thanks for
pointing that out.
> My
> patch fixes these errors, and the SIOCGIFCONF now works properly under both
> GNU/Linux and Darwin. However, it seems to be preferable to just use
> getifaddrs() when available, as it's a much cleaner interface. To my mind,
> it's tempting to get rid of the SIOCGIFCONF code all together, but I've
> left it in for now.
It's definitely a cleaner interface, yes, and maybe it is as widely
available as SIOCGIFCONF these days...?
But in any case, since network-interface-list is a new addition in CVS
emacs, I think it would be alright for us to restrict its availability
to those systems which do support getifaddrs (in some form -- AFAIK,
there are variations in the amount of useful information returned by
getifaddrs on different systems [and I have seen bug reports about
traps in getifaddrs if there are many interfaces]).
If we settle on using only getifaddrs, I would suggest that we change
network-interface-list to return all the available information about
each interface (based on the information returned by getifaddrs),
similar to what network-interface-info return now, and just let
network-interface-info do something like
(defun network-interface-info (INTERFACE)
(assoc-default INTERFACE (network-interface-list)))
>
> In the case of `network-interface-info', certain of the requested ioctl()s
> are non-existent on Darwin (and, again, presumably on some other BSDs); in
> particular, SIOCGIFNETMASK and SIOCGIFHWADDR. I've got some code that
> uses getifaddrs() to fetch all of this info (instead of doing separate
> ioctl() calls), but have not included it in this patch. If people think
> this is the correct way to go, I'll send it on. (For those that care: the
> downside of this is the difference between the link-layer sockaddrs on BSD
> (struct sockaddr_dl) and Linux (struct sockaddr_ll).)
This is unclear to me.
How does getifaddrs return the hw address? In ifaddr->ifa_data ?
Is that portable? If not, maybe it could use SIOCGIFHWADDR as
a fallback.
I haven't found any docs about the value of ifa_data on GNU/Linux.
Do you have ref. pointers for this?
>
> Comments, suggestions, bug-fixes, and test reports are all welcome.
If you want to modify network-interface-list and -info according to
the suggestions above, I would appreciate it.
However, AFAICS, you have not signed papers for contributing to emacs,
and your changes are a little too big to be considered a tiny change.
Are you interested in signing papers for your changes?
Otherwise, I will work on this myself. Thank you for your input.
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
next parent reply other threads:[~2003-11-17 12:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87ad6w2hm6.fsf@Dora.local.>
2003-11-17 12:23 ` Kim F. Storm [this message]
2003-11-18 5:49 ` Patch for network-interface-{list,info} Alex Plotnick
[not found] ` <8765hi2pl7.fsf@Dora.local.>
2003-11-18 9:46 ` Kim F. Storm
2003-11-16 20:17 Alex Plotnick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3k75zyyij.fsf@kfs-l.imdomain.dk \
--to=storm@cua.dk \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).