I would like to check a network devices status e.g. promiscous mode. Basically like shown with ip a command.
Maybe someone could push me in the right direction?
I want to do this in C for linux so linux specific headers are available.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use the
SIOCGIFFLAGSioctl to retrieve the flags associated with an interface. You can then check if theIFF_PROMISCflag is set:If you want to set the interface to promiscuous mode, you will need root privileges, but you can simply set the field in
ifr_flagsand use theSIOCSIFFLAGSioctl: