Get link speed programmatically?
问题 I am writing an application that reports attributes of network devices on the local machine. I need the mac address, mtu, link speed and a few others. I'm using udev for this. I've already figured out how to get the mac address and mtu, but not how to get the link speed. I can get it with ethtool from the terminal, but I need a way to get it programmatically. Does anyone know how I can get the link speed attribute with udev or another library? 回答1: You need to use the SIOCETHTOOL ioctl() call