Put some ioctls into helper routines and make them handle long names.
Put the code that binds an interface to a BPF device, and that attempts
to find out whether an interface exists by fetch its flags, into common
routines. Have the code that attempts to find out whether an interface
exists check for ioctl errors expected if the device doesn't exist, and
treat them differently from unexpected errors.
If LIFNAMSIZ is defined - meaning "newer version of Solaris with new
ioctls to handle longer interface names" - have both of those routines
use the newer ioctls.
Don't use the ioctl names in the error messages, as the ioctl names may
differ between platforms.