@@ -29,7 +29,7 @@ def initialize
29
29
register_options (
30
30
[
31
31
OptString . new ( 'INTERFACE' , [ true , 'Set an interface' , 'eth0' ] ) ,
32
- OptInt . new ( 'TIMEOUT ' , [ true , 'Seconds to wait, set longer on slower networks' , 2 ] )
32
+ OptInt . new ( 'ANSWERTIME ' , [ true , 'Seconds to wait for answers , set longer on slower networks' , 2 ] )
33
33
] , self . class
34
34
)
35
35
end
@@ -107,23 +107,19 @@ def parse_profinet(data)
107
107
end
108
108
end
109
109
110
- def receive ( iface , timeout )
110
+ def receive ( iface , answertime )
111
111
capture = PacketFu ::Capture . new ( iface : iface , start : true , filter : 'ether proto 0x8892' )
112
- sleep timeout
112
+ sleep answertime
113
113
capture . save
114
114
i = 0
115
115
capture . array . each do |packet |
116
- begin
117
- data = bin_to_hex ( packet ) . downcase
118
- mac = data [ 12 ..13 ] + ':' + data [ 14 ..15 ] + ':' + data [ 16 ..17 ] + ':' + data [ 18 ..19 ] + ':' + data [ 20 ..21 ] + ':' + data [ 22 ..23 ]
119
- next unless data [ 28 ..31 ] == 'feff'
120
- print_good ( "Parsing packet from #{ mac } " )
121
- parse_profinet ( data [ 28 ..-1 ] )
122
- print_line ( '' )
123
- i += 1
124
- rescue
125
- next
126
- end
116
+ data = bin_to_hex ( packet ) . downcase
117
+ mac = data [ 12 ..13 ] + ':' + data [ 14 ..15 ] + ':' + data [ 16 ..17 ] + ':' + data [ 18 ..19 ] + ':' + data [ 20 ..21 ] + ':' + data [ 22 ..23 ]
118
+ next unless data [ 28 ..31 ] == 'feff'
119
+ print_good ( "Parsing packet from #{ mac } " )
120
+ parse_profinet ( data [ 28 ..-1 ] )
121
+ print_line ( '' )
122
+ i += 1
127
123
end
128
124
if i . zero?
129
125
print_warning ( 'No devices found, maybe you are running virtually?' )
@@ -134,7 +130,7 @@ def receive(iface, timeout)
134
130
135
131
def run
136
132
iface = datastore [ 'INTERFACE' ]
137
- timeout = datastore [ 'TIMEOUT ' ]
133
+ answertime = datastore [ 'ANSWERTIME ' ]
138
134
packet = "\x00 \x00 \x88 \x92 \xfe \xfe \x05 \x00 \x04 \x00 \x00 \x03 \x00 \x80 \x00 \x04 \xff \xff \x00 \x00 \x00 \x00 "
139
135
packet += "\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 "
140
136
@@ -151,6 +147,6 @@ def run
151
147
print_status ( "Sending packet out to #{ iface } " )
152
148
eth_pkt . to_w ( iface )
153
149
154
- receive ( iface , timeout )
150
+ receive ( iface , answertime )
155
151
end
156
152
end
0 commit comments