Linux CAN drivers development
 help / color / mirror / Atom feed
* programatically determine netlink-type: can or vcan ...
@ 2016-06-21 14:40 ajneu
  2016-06-21 15:26 ` ajneu
  0 siblings, 1 reply; 5+ messages in thread
From: ajneu @ 2016-06-21 14:40 UTC (permalink / raw)
  To: linux-can

Hi,

how can one determine the netlink-type (can or vcan, ...) of an
interface-name (e.g. can1), from a C program?

It would be great if I can e.g. get that from /sys/class/net/can1 somehow.

What would work, but is NOT nice (because of portability problems), is to
use the C-function system:

if (system("test \"$(ip link show can1 type vcan)\" !=  \"\"")) {
   printf("can1 is not vcan\n");
} else {
   printf("can1 is vcan\n");
}

Thanks.
ajneu




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

* Re: programatically determine netlink-type: can or vcan ...
  2016-06-21 14:40 programatically determine netlink-type: can or vcan ajneu
@ 2016-06-21 15:26 ` ajneu
  2016-06-21 20:48   ` ajneu
  0 siblings, 1 reply; 5+ messages in thread
From: ajneu @ 2016-06-21 15:26 UTC (permalink / raw)
  To: linux-can

ajneu <ajneu1 <at> gmail.com> writes:

> 
> Hi,
> 
> how can one determine the netlink-type (can or vcan, ...) of an
> interface-name (e.g. can1), from a C program?
> 
> It would be great if I can e.g. get that from /sys/class/net/can1 somehow.
> 
> What would work, but is NOT nice (because of portability problems), is to
> use the C-function system:
> 
> if (system("test \"$(ip link show can1 type vcan)\" !=  \"\"")) {
>    printf("can1 is not vcan\n");
> } else {
>    printf("can1 is vcan\n");
> }
(on command line: 
   test "$(ip link show can1 type vcan)" !=  "" )

This would be nice in libsocketcan, but it's not in there. Somewhat limited...

Missing also, from libsocketcan, is the ability to determine if a device
such as can1 exists.
(What I do now, is to just check if /sys/class/net/can1 exists.)


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

* Re: programatically determine netlink-type: can or vcan ...
  2016-06-21 15:26 ` ajneu
@ 2016-06-21 20:48   ` ajneu
  2016-06-23  7:09     ` ajneu
  0 siblings, 1 reply; 5+ messages in thread
From: ajneu @ 2016-06-21 20:48 UTC (permalink / raw)
  To: linux-can

ajneu <ajneu1 <at> gmail.com> writes:

> 
> This would be nice in libsocketcan, but it's not in there. Somewhat limited...
> 
> Missing also, from libsocketcan, is the ability to determine if a device
> such as can1 exists.
> (What I do now, is to just check if /sys/class/net/can1 exists.)
> 

OK, it turns out that it was quite manageable, to add the desired
functionality to libsocketcan.
See 
https://github.com/ajneu/libsocketcan
https://github.com/ajneu/libsocketcan/commit/26ef



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

* Re: programatically determine netlink-type: can or vcan ...
  2016-06-21 20:48   ` ajneu
@ 2016-06-23  7:09     ` ajneu
  2016-07-19 14:57       ` @Marc Kleine-Budde ajneu
  0 siblings, 1 reply; 5+ messages in thread
From: ajneu @ 2016-06-23  7:09 UTC (permalink / raw)
  To: linux-can

ajneu <ajneu1 <at> gmail.com> writes:

> OK, it turns out that it was quite manageable, to add the desired
> functionality to libsocketcan.
> See 
> https://github.com/ajneu/libsocketcan
> https://github.com/ajneu/libsocketcan/commit/26ef

Added another commit, that adds function: device_is_up()

Why? The existing can_get_state() is limited only to can devices. It does
not work for vcan.

I hope Marc Kleine-Budde can integrate these changes into the official git.

Regards,
ajneu


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

* Re: @Marc Kleine-Budde
  2016-06-23  7:09     ` ajneu
@ 2016-07-19 14:57       ` ajneu
  0 siblings, 0 replies; 5+ messages in thread
From: ajneu @ 2016-07-19 14:57 UTC (permalink / raw)
  To: linux-can

ajneu <ajneu1 <at> gmail.com> writes:
> > https://github.com/ajneu/libsocketcan
> > https://github.com/ajneu/libsocketcan/commit/26ef

@Marc Kleine-Budde: Any chance, to see this go into upstream (pengutronix
git repo)???

Thanks.


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

end of thread, other threads:[~2016-07-19 14:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-21 14:40 programatically determine netlink-type: can or vcan ajneu
2016-06-21 15:26 ` ajneu
2016-06-21 20:48   ` ajneu
2016-06-23  7:09     ` ajneu
2016-07-19 14:57       ` @Marc Kleine-Budde ajneu

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