public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* Use ioctl() to list all network interfaces.
@ 2011-01-06 15:33 Chin Shi Hong
  2011-01-06 16:11 ` Rémi Denis-Courmont
  2011-01-06 17:07 ` Alexander Clouter
  0 siblings, 2 replies; 5+ messages in thread
From: Chin Shi Hong @ 2011-01-06 15:33 UTC (permalink / raw)
  To: netdev

Dear all,

The following codes are just part of my application's source codes:

--begin of some codes--
ifconf ifc;
ret = ioctl(n, SIOCGIFCONF,&ifc);
--End of some codes--

My application's role is to display all network interfaces, including
the network interface which are down.

However, with the above codes, my application only display the network
interface which are already up. The network interface which are down
will not be displayed.

So, what can I do to make my application display all network
interfaces, including the network interface which are down?

regards,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Use ioctl() to list all network interfaces.
  2011-01-06 15:33 Use ioctl() to list all network interfaces Chin Shi Hong
@ 2011-01-06 16:11 ` Rémi Denis-Courmont
  2011-01-07  5:40   ` Chin Shi Hong
  2011-01-06 17:07 ` Alexander Clouter
  1 sibling, 1 reply; 5+ messages in thread
From: Rémi Denis-Courmont @ 2011-01-06 16:11 UTC (permalink / raw)
  To: Chin Shi Hong; +Cc: netdev

Le jeudi 6 janvier 2011 17:33:39 Chin Shi Hong, vous avez écrit :
> My application's role is to display all network interfaces, including
> the network interface which are down.

You should use if_nameindex() then.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Use ioctl() to list all network interfaces.
  2011-01-06 15:33 Use ioctl() to list all network interfaces Chin Shi Hong
  2011-01-06 16:11 ` Rémi Denis-Courmont
@ 2011-01-06 17:07 ` Alexander Clouter
  2011-01-07  5:41   ` Chin Shi Hong
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Clouter @ 2011-01-06 17:07 UTC (permalink / raw)
  To: netdev

Chin Shi Hong <cshong87@gmail.com> wrote:
>
> The following codes are just part of my application's source codes:
> 
> --begin of some codes--
> ifconf ifc;
> ret = ioctl(n, SIOCGIFCONF,&ifc);
> --End of some codes--
> 
> My application's role is to display all network interfaces, including
> the network interface which are down.
> 
> However, with the above codes, my application only display the network
> interface which are already up. The network interface which are down
> will not be displayed.
> 
> So, what can I do to make my application display all network
> interfaces, including the network interface which are down?
>
getifaddrs(), you get the IPv6 ones too this way.

Cheers

-- 
Alexander Clouter
.sigmonster says: I've only got 12 cards.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Use ioctl() to list all network interfaces.
  2011-01-06 16:11 ` Rémi Denis-Courmont
@ 2011-01-07  5:40   ` Chin Shi Hong
  0 siblings, 0 replies; 5+ messages in thread
From: Chin Shi Hong @ 2011-01-07  5:40 UTC (permalink / raw)
  To: Rémi Denis-Courmont; +Cc: netdev

2011/1/7 Rémi Denis-Courmont <remi@remlab.net>:
> Le jeudi 6 janvier 2011 17:33:39 Chin Shi Hong, vous avez écrit :
>> My application's role is to display all network interfaces, including
>> the network interface which are down.
>
> You should use if_nameindex() then.
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
> http://fi.linkedin.com/in/remidenis
>

Thank you. if_nameindex() really help me.

Regards,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Use ioctl() to list all network interfaces.
  2011-01-06 17:07 ` Alexander Clouter
@ 2011-01-07  5:41   ` Chin Shi Hong
  0 siblings, 0 replies; 5+ messages in thread
From: Chin Shi Hong @ 2011-01-07  5:41 UTC (permalink / raw)
  To: Alexander Clouter; +Cc: netdev

On Fri, Jan 7, 2011 at 1:07 AM, Alexander Clouter <alex@digriz.org.uk> wrote:
> Chin Shi Hong <cshong87@gmail.com> wrote:
>>
>> The following codes are just part of my application's source codes:
>>
>> --begin of some codes--
>> ifconf ifc;
>> ret = ioctl(n, SIOCGIFCONF,&ifc);
>> --End of some codes--
>>
>> My application's role is to display all network interfaces, including
>> the network interface which are down.
>>
>> However, with the above codes, my application only display the network
>> interface which are already up. The network interface which are down
>> will not be displayed.
>>
>> So, what can I do to make my application display all network
>> interfaces, including the network interface which are down?
>>
> getifaddrs(), you get the IPv6 ones too this way.
>
> Cheers
>
> --
> Alexander Clouter
> .sigmonster says: I've only got 12 cards.
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

getifaddrs() helpful also. Thank you!

Regards,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-07  5:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06 15:33 Use ioctl() to list all network interfaces Chin Shi Hong
2011-01-06 16:11 ` Rémi Denis-Courmont
2011-01-07  5:40   ` Chin Shi Hong
2011-01-06 17:07 ` Alexander Clouter
2011-01-07  5:41   ` Chin Shi Hong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox