| To: | Stephen Waters <swaters@xxxxxxxxxx> |
|---|---|
| Subject: | Re: C and/or ioctl question |
| From: | James Morris <jmorris@xxxxxxxxxxxxxxxx> |
| Date: | Thu, 9 Aug 2001 03:43:13 +1000 (EST) |
| Cc: | <netdev@xxxxxxxxxxx> |
| In-reply-to: | <997289138.21407.20.camel@caligula> |
| Sender: | owner-netdev@xxxxxxxxxxx |
On 8 Aug 2001, Stephen Waters wrote:
> hi, I've been studying the net-tools ifconfig implementation a bit in my
> efforts to better learn C and ioctl for Linux.
>
> int main () {
> struct ifconf ifc;
> int skfd;
> skfd = socket(AF_INET, SOCK_DGRAM, 0);
> if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) {
You need to set up the ifconf structure first and allocate enough memory
in it for a payload of ifreq structures to be returned from the kernel.
Have a look at if_readconf() in net-tools/lib/interface.c
- James
--
James Morris
<jmorris@xxxxxxxxxxxxxxxx>
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | C and/or ioctl question, Stephen Waters |
|---|---|
| Next by Date: | Re: C and/or ioctl question, Stephen Waters |
| Previous by Thread: | C and/or ioctl question, Stephen Waters |
| Next by Thread: | Re: C and/or ioctl question, Stephen Waters |
| Indexes: | [Date] [Thread] [Top] [All Lists] |