🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.linux.development.apps
Article #21

Re: Getting eth0 device information in C or perl.

#21
From: Fraser Stewart
Date: Wed, 20 Dec 2000 18:41
26 lines
2361 bytes
michael scott frank wrote:
> 
> If you want to do it in C, you use the ioctl SIOCGIFADDR.  Here's a small
> program i wrote a while ago, modified a bit for what you need.  Its a bit
> of work to do it the 'real' way, as you can see.  the ifreq struct is
> particularily nasty, if you look at how it is defined in the headers.  If
> you are interested in this stuff like i am tho, you should definitely pick
> up "UNIX network programming" by W. Richard Stevens.  it is _the_ book on
> the subject, and has an excellent chapter on network related ioctls.
> 
> #include <stdio.h>
> #include <sys/socket.h>
> #include <sys/ioctl.h>
> #include <netinet/in.h>
> #include <net/if.h>
> 
> int main(void) {
>         int fd;
>         struct sockaddr_in *addr_ptr;
> <<<<SNIP>>>>>


Oops, I've just stolen that!

Luvly!
Fraser.
Technical Details
Message-ID: <3A40FD53.C213C6FB@madasafish.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
References: <FjhX5.92$UI4.5375@nsw.nnrp.telstra.net> <Pine.A41.4.21.0012052304150.112374-100000@dante11.u.washington.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5392,ea95fbf156eacc4e
X-Google-Attributes: gidf5392,public
X-Google-Thread: 10c696,ea95fbf156eacc4e
X-Google-Attributes: gid10c696,public
X-Google-Thread: 10669a,ea95fbf156eacc4e
X-Google-Attributes: gid10669a,public
X-Google-Thread: 1078db,ea95fbf156eacc4e
X-Google-Attributes: gid1078db,public
X-Google-Thread: 102983,ea95fbf156eacc4e
X-Google-Attributes: gid102983,public
X-Google-Thread: 10aedf,ea95fbf156eacc4e
X-Google-Attributes: gid10aedf,public
X-Google-Thread: 10cce4,ea95fbf156eacc4e
X-Google-Attributes: gid10cce4,public
X-Google-ArrivalTime: 2000-12-20 10:35:46 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
From: Fraser Stewart <fstewart@madasafish.com>
Newsgroups: comp.os.linux.development.apps,comp.os.linux.development.system,comp.os.linux.networking,linux.dev.apps,linux.dev.c-programming,linux.dev.net,aus.computers.linux
Subject: Re: Getting eth0 device information in C or perl.
Date: Wed, 20 Dec 2000 18:41:23 +0000
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <3A40FD53.C213C6FB@madasafish.com>
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
References: <FjhX5.92$UI4.5375@nsw.nnrp.telstra.net> <Pine.A41.4.21.0012052304150.112374-100000@dante11.u.washington.edu>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: newsabuse@supernews.com
Lines: 26