-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LocalIp: support get interface flags #1315
Conversation
{ | ||
.flag = IFF_UP, | ||
.name = "UP", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer { IFF_UP, "UP" }
so that they take less spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
{ | ||
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) == 0) | ||
writeNIFlagsToStrBuf(&iface->flags, ifr.ifr_flags, nicFlags); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it ifa->ifa_flags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getifaddrs will return all interfaces in the local system which we already got. It might be heavier than creating a socket then calling a ioctl.
And manpages say this function is not a part of the standard, it could be different on other systems.
So, I think using ioctl and ifreq here may be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we have already called getifaddrs. Why not reuse its result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, getifaddrs already called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this advice, I'll change to reuse its result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
You should add it to |
6eb7ad1
to
d6c8bd7
Compare
Done. |
d6c8bd7
to
e27e910
Compare
Each net interface has its flags. These flags show the interface and its IP's status/capabilities.
Flags have already been reported by 'ifconfig' and 'ip addr' commands:
Add the same capability to fastfetch:
I also added a new option '--localip-show-flags' to control whether getting interface flags (the default value is FALSE).