Class: Rethtool
- Inherits:
-
Object
- Object
- Rethtool
- Defined in:
- lib/rethtool.rb
Overview
A (very) partial implementation of the functionality available in ethtool (and the associated ioctl interface) in pure Ruby.
Why? Because I like to do crazy things.
All the functionality you’re likely to actually want is in subclasses of Rethtool itself:
Rethtool::InterfaceSettings
Get the settings (speed, duplex, etc) of an interface
Rethtool::LinkStatus
Whether the link is up or down
Defined Under Namespace
Classes: DriverSettings, EthtoolCmd, EthtoolCmdDriver, EthtoolCmdRing, EthtoolValue, InterfaceSettings, LinkStatus, RingSettings
Constant Summary collapse
- SIOCETHTOOL =
From /u/i/linux/sockios.h
0x8946
- ETHTOOL_CMD_GLINK =
From /u/i/linux/ethtool.h
0x0000000a
- ETHTOOL_CMD_GSET =
0x00000001
- ETHTOOL_CMD_GDRVINFO =
0x00000003
- ETHTOOL_CMD_GRINGPARAM =
0x00000010
- ETHTOOL_CMD_SRINGPARAM =
0x00000011
Class Method Summary collapse
-
.ioctl(interface, ecmd) ⇒ Object
Issue an SIOCETHTOOL ioctl.
Class Method Details
.ioctl(interface, ecmd) ⇒ Object
Issue an SIOCETHTOOL ioctl. ecmd must respond to #data (such as a CStruct subclass instance). The modified data will be unserialized and returned. The data you pass in WILL NOT be modified, you must capture the return value if you want any results.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rethtool.rb', line 34 def ioctl(interface, ecmd) sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0) rv = ecmd.clone ifreq = [interface, ecmd.data].pack("a16P#{rv.data.length}") sock.ioctl(SIOCETHTOOL, ifreq) rv end |