All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Paarvai Naai <opensource3141@gmail.com>, linux-can@vger.kernel.org
Subject: Re: getifaddrs and SocketCAN interfaces
Date: Sun, 29 Mar 2015 20:36:48 +0200	[thread overview]
Message-ID: <55184640.8030900@hartkopp.net> (raw)
In-Reply-To: <CAE+ymrs_yWEgR6OVP8rCiqCr4wJtXUGkYVJNMbgZxufTROeZ4Q@mail.gmail.com>

On 28.03.2015 21:30, Paarvai Naai wrote:
> I recently tried using getifaddrs to list all of the SocketCAN
> interfaces on my system programmatically.
> 
> However, I found that the SocketCAN interfaces do not have their
> ifa_addr field in the returned ifaddrs structure set.  This makes it
> not possible to identifying the interface as type SocketCAN.
> Presumably if the ifa_addr field was set, we could look at the
> sa_family field and check if it is AF_CAN.

Hi Paarvai,

on the CAN bus you don't have node addresses - so there's nothing comparable
to ethernet devices which have an IP-address bound to them.

The CAN netdevice stuff in linux/driver/net/can is currently separated from
the network layer stuff in linux/net/can pretty good.

So attaching a (useless) sock_addr from the network layer to the CAN
interface seems inappropriate.

Do you know about the network device ARPHRD definitions:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/if_arp.h#n55

> The other option is to use netlink to query the network devices, but
> that is more involved.  Is there an easier way?

E.g. you can get this netdevice type information from

$ cat /sys/class/net/vcan0/type
280

Regards,
Oliver


  reply	other threads:[~2015-03-29 18:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-28 20:30 getifaddrs and SocketCAN interfaces Paarvai Naai
2015-03-29 18:36 ` Oliver Hartkopp [this message]
2015-03-29 19:40   ` dev.kurt
2015-03-30 21:46     ` Paarvai Naai
2015-03-29 22:23 ` Tom Evans

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55184640.8030900@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=opensource3141@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.