rethtool 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/VERSION +1 -1
- data/lib/rethtool.rb +8 -5
- data/lib/rethtool/ethtool_cmd.rb +26 -0
- data/lib/rethtool/interface_settings.rb +27 -2
- metadata +13 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4db6e4f08553fb426f053a306cb165aaa72bdd4b
|
4
|
+
data.tar.gz: 91cc79990c7f9b4c2e74e36ca66886f7c9d8c1a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f15308539e56008091de3c06b2f0b54a6fe6d9defdb817249668b6f5b3414fbe4faa1243878994303fcb27c5dfab0c13075d3e6fd5e1b47c75afe735d8e130bc
|
7
|
+
data.tar.gz: 8a7775619bcaaa5075df7cb4757b8d2f5a314b2bd96e1a831154b45115611b0c9fc863c8249674a1f547db9930fa7afb2263309ea669c0a3943ed40f7bfb508c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/rethtool.rb
CHANGED
@@ -19,8 +19,11 @@ class Rethtool
|
|
19
19
|
SIOCETHTOOL = 0x8946
|
20
20
|
|
21
21
|
# From /u/i/linux/ethtool.h
|
22
|
-
ETHTOOL_CMD_GLINK
|
23
|
-
ETHTOOL_CMD_GSET
|
22
|
+
ETHTOOL_CMD_GLINK = 0x0000000a
|
23
|
+
ETHTOOL_CMD_GSET = 0x00000001
|
24
|
+
ETHTOOL_CMD_GDRVINFO = 0x00000003
|
25
|
+
ETHTOOL_CMD_GRINGPARAM = 0x00000010
|
26
|
+
ETHTOOL_CMD_SRINGPARAM = 0x00000011
|
24
27
|
|
25
28
|
class << self
|
26
29
|
# Issue an SIOCETHTOOL ioctl. ecmd must respond to #data (such
|
@@ -31,12 +34,11 @@ class Rethtool
|
|
31
34
|
def ioctl(interface, ecmd)
|
32
35
|
sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
|
33
36
|
|
34
|
-
|
37
|
+
rv = ecmd.clone
|
38
|
+
ifreq = [interface, ecmd.data].pack("a16P#{rv.data.length}")
|
35
39
|
|
36
40
|
sock.ioctl(SIOCETHTOOL, ifreq)
|
37
41
|
|
38
|
-
rv = ecmd.class.new
|
39
|
-
rv.data = ifreq.unpack("a16p")[1]
|
40
42
|
rv
|
41
43
|
end
|
42
44
|
end
|
@@ -44,3 +46,4 @@ end
|
|
44
46
|
|
45
47
|
require 'rethtool/interface_settings'
|
46
48
|
require 'rethtool/link_status'
|
49
|
+
require 'rethtool/ring_settings'
|
data/lib/rethtool/ethtool_cmd.rb
CHANGED
@@ -21,3 +21,29 @@ class Rethtool::EthtoolCmd < CStruct
|
|
21
21
|
uint32 :reserved2
|
22
22
|
uint32 :reserved3
|
23
23
|
end
|
24
|
+
|
25
|
+
class Rethtool::EthtoolCmdDriver < CStruct
|
26
|
+
uint32 :cmd
|
27
|
+
char :driver,[32]
|
28
|
+
char :version,[32]
|
29
|
+
char :fw_version,[32]
|
30
|
+
char :bus_info,[32]
|
31
|
+
char :reserved1,[32]
|
32
|
+
char :reserved2,[16]
|
33
|
+
uint32 :n_stats
|
34
|
+
uint32 :testinfo_len
|
35
|
+
uint32 :eedump_len
|
36
|
+
uint32 :regdump_len
|
37
|
+
end
|
38
|
+
|
39
|
+
class Rethtool::EthtoolCmdRing < CStruct
|
40
|
+
uint32 :cmd
|
41
|
+
uint32 :rx_max_pending
|
42
|
+
uint32 :rx_mini_max_pending
|
43
|
+
uint32 :rx_jumbo_max_pending
|
44
|
+
uint32 :tx_max_pending
|
45
|
+
uint32 :rx_pending
|
46
|
+
uint32 :rx_mini_pending
|
47
|
+
uint32 :rx_jumbo_pending
|
48
|
+
uint32 :tx_pending
|
49
|
+
end
|
@@ -39,9 +39,20 @@ class Rethtool::InterfaceSettings
|
|
39
39
|
@interface = interface
|
40
40
|
cmd = Rethtool::EthtoolCmd.new
|
41
41
|
cmd.cmd = Rethtool::ETHTOOL_CMD_GSET
|
42
|
-
|
43
42
|
@data = Rethtool.ioctl(interface, cmd)
|
43
|
+
|
44
|
+
@driver_info = Rethtool::DriverSettings.new(interface)
|
44
45
|
end
|
46
|
+
|
47
|
+
# Returns a string with the value of the interface driver (kernel module).
|
48
|
+
def driver
|
49
|
+
@driver_info.driver
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a string with the bus information of the interface.
|
53
|
+
def bus_info
|
54
|
+
@driver_info.bus_info
|
55
|
+
end
|
45
56
|
|
46
57
|
# Return an array of the modes supported by the interface. Returns an
|
47
58
|
# array of Mode objects.
|
@@ -128,11 +139,25 @@ class Rethtool::InterfaceSettings
|
|
128
139
|
1 << 17 => Mode.new(1000, :full, 'KX'),
|
129
140
|
1 << 18 => Mode.new(10000, :full, 'KX4'),
|
130
141
|
1 << 19 => Mode.new(10000, :full, 'KR'),
|
131
|
-
1 << 20 => Mode.new(10000, :fec, 'R')
|
142
|
+
1 << 20 => Mode.new(10000, :fec, 'R'),
|
143
|
+
1 << 21 => Mode.new(20000, :full, 'MLD2'),
|
144
|
+
1 << 22 => Mode.new(20000, :full, 'KR2'),
|
145
|
+
1 << 23 => Mode.new(40000, :full, 'KR4'),
|
146
|
+
1 << 24 => Mode.new(40000, :full, 'CR4'),
|
147
|
+
1 << 25 => Mode.new(40000, :full, 'SR4'),
|
148
|
+
1 << 26 => Mode.new(40000, :full, 'LR4'),
|
149
|
+
1 << 27 => Mode.new(56000, :full, 'KR4'),
|
150
|
+
1 << 28 => Mode.new(56000, :full, 'CR4'),
|
151
|
+
1 << 29 => Mode.new(56000, :full, 'SR4'),
|
152
|
+
1 << 30 => Mode.new(56000, :full, 'LR4'),
|
132
153
|
}
|
133
154
|
|
134
155
|
# Turn a uint32 of bits into a list of supported modes. Sigh.
|
135
156
|
def modes(data)
|
136
157
|
PossibleModes.find_all { |m| (m[0] & data) > 0 }.map { |m| m[1] }
|
137
158
|
end
|
159
|
+
|
160
|
+
def as_str(str)
|
161
|
+
str.pack('c*').delete("\000")
|
162
|
+
end
|
138
163
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rethtool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Palmer
|
@@ -14,65 +13,57 @@ dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: cstruct
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '10.0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '10.0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '1.0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '1.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rdoc
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '2.4'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '2.4'
|
78
69
|
description:
|
@@ -94,28 +85,24 @@ files:
|
|
94
85
|
homepage: http://theshed.hezmatt.org/rethtool
|
95
86
|
licenses:
|
96
87
|
- GPLv3
|
88
|
+
metadata: {}
|
97
89
|
post_install_message:
|
98
90
|
rdoc_options: []
|
99
91
|
require_paths:
|
100
92
|
- lib
|
101
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
94
|
requirements:
|
104
|
-
- -
|
95
|
+
- - ">="
|
105
96
|
- !ruby/object:Gem::Version
|
106
97
|
version: '0'
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
hash: 2868922360395750442
|
110
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
99
|
requirements:
|
113
|
-
- -
|
100
|
+
- - ">="
|
114
101
|
- !ruby/object:Gem::Version
|
115
102
|
version: '0'
|
116
103
|
requirements: []
|
117
104
|
rubyforge_project:
|
118
|
-
rubygems_version:
|
105
|
+
rubygems_version: 2.2.2
|
119
106
|
signing_key:
|
120
107
|
specification_version: 3
|
121
108
|
summary: Partial Ruby wrapper around the SIOCETHTOOL ioctl
|