daisy
daisy

Reputation: 23499

How can one tell if an interface is a loopback device by it's sll_ifindex?

I have the ifindex number of an interface, now I want to know if that device is a loopback interface.

So far the only option seems to be retrieving its name first, then check if it start with lo.

Any better solution?

Upvotes: 0

Views: 977

Answers (2)

icbytes
icbytes

Reputation: 1851

You can get all of the flags, which are implemented by an interface by checking the corresponding flags.

You see the constants from the if.h file.

Upvotes: 0

rodrigo
rodrigo

Reputation: 98338

Look at the flags. There is the IFF_LOOPBACK flag that tells what you need.

There are several ways to get the flags, but if you know how to get the name from the ifindex, then retrieving the flags should be no problem at all.

Upvotes: 4

Related Questions