trisulrp 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 3
9
- version: 1.2.3
8
+ - 4
9
+ version: 1.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - vivek
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-03 00:00:00 +05:30
17
+ date: 2011-01-06 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -121,12 +121,18 @@ files:
121
121
  - VERSION
122
122
  - examples/strp.rb
123
123
  - lib/trisulrp.rb
124
- - lib/trp.pb.rb
125
- - lib/trp.proto
126
- - lib/trplib.rb
124
+ - lib/trisulrp/guids.rb
125
+ - lib/trisulrp/keys.rb
126
+ - lib/trisulrp/protocol.rb
127
+ - lib/trisulrp/trp.pb.rb
128
+ - lib/trisulrp/trp.proto
127
129
  - test/Demo_Client.crt
128
130
  - test/Demo_Client.key
129
131
  - test/helper.rb
132
+ - test/test_alerts.rb
133
+ - test/test_cap.rb
134
+ - test/test_key_flows.rb
135
+ - test/test_resources.rb
130
136
  - test/test_trisulrp.rb
131
137
  - trisulrp.gemspec
132
138
  has_rdoc: true
@@ -143,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
149
  requirements:
144
150
  - - ">="
145
151
  - !ruby/object:Gem::Version
146
- hash: 113684307
152
+ hash: -497000077
147
153
  segments:
148
154
  - 0
149
155
  version: "0"
@@ -165,4 +171,8 @@ summary: trisul trp
165
171
  test_files:
166
172
  - examples/strp.rb
167
173
  - test/helper.rb
174
+ - test/test_alerts.rb
175
+ - test/test_cap.rb
176
+ - test/test_key_flows.rb
177
+ - test/test_resources.rb
168
178
  - test/test_trisulrp.rb
data/lib/trplib.rb DELETED
@@ -1,330 +0,0 @@
1
- # TRP Helper functions
2
- #
3
- # dependency = ruby_protobuf
4
- #
5
- # Akhil.M & Dhinesh.K (c) 2010 Unleash Networks
6
-
7
- require 'openssl'
8
- require 'socket'
9
- require 'time'
10
- require 'trp.pb'
11
-
12
- module TRPLib
13
-
14
- # dispatch and get trp response
15
- def get_trp_response(trp_socket,trp_request)
16
-
17
- outbuf=""
18
- outbuf=trp_request.serialize_to_string
19
- trp_socket.write([outbuf.length].pack("N*"))
20
- trp_socket.write(outbuf)
21
- inbuf = trp_socket.read(4)
22
- buflenarr=inbuf.unpack("N*")
23
- datalen=buflenarr[0]
24
- dataarray=trp_socket.read(datalen)
25
- resp =TRP::Message.new
26
- resp.parse dataarray
27
- yield resp if block_given?
28
- return resp
29
- end
30
-
31
- def connect_trp(server,port,client_cert_file,client_key_file)
32
- tcp_sock=TCPSocket.open(server,port)
33
- ctx = OpenSSL::SSL::SSLContext.new
34
- ctx.cert = OpenSSL::X509::Certificate.new(File.read(client_cert_file))
35
- ctx.key = OpenSSL::PKey::RSA.new(File.read(client_key_file))
36
- ssl_sock = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx)
37
- ssl_sock.connect
38
- yield ssl_sock if block_given?
39
- return ssl_sock
40
- end
41
-
42
-
43
-
44
- # creates a counter item request message by filling in the
45
- # protobuf
46
- def mk_counter_item_request(guid,key,time_from,time_to)
47
-
48
- # create a new command of type CounterItemRequest
49
- msg =TRP::Message.new
50
- msg.trp_command = TRP::Message::Command::COUNTER_ITEM_REQUEST
51
- msg.counter_item_request =TRP:: CounterItemRequest.new
52
- cir_msg=msg.counter_item_request
53
-
54
- # fill in basic info
55
- cir_msg.context =0
56
- cir_msg.counter_group=guid
57
- cir_msg.meter=0
58
- cir_msg.key=key
59
-
60
- # fill in time_interval
61
- cir_msg.time_interval=TRP::TimeInterval.new
62
- tint=cir_msg.time_interval
63
- tint.from=TRP::Timestamp.new
64
- tint.from.tv_sec=time_from.tv_sec
65
- tint.from.tv_usec=0
66
- tint.to=TRP::Timestamp.new
67
- tint.to.tv_sec=time_to.tv_sec
68
- tint.to.tv_usec=0
69
- return msg
70
- end
71
-
72
- # print stats
73
- def print_counter_item_response(resp_in)
74
-
75
- resp=resp_in.counter_item_response
76
- p "---------------------"
77
- p "Counter Item Response"
78
- p "---------------------"
79
- p "Key = " + resp.stats.key
80
- p "CounterGroup = " + resp.stats.counter_group
81
- p "Context = #{ resp.stats.context}"
82
- resp.stats.meters.each do |meter|
83
- p "Meter = #{meter.meter }"
84
- meter.values.each do |stats_tuple|
85
- print Time.at(stats_tuple.ts.tv_sec)
86
- print "#{stats_tuple.val }".rjust(16)
87
- print "\n"
88
- end
89
- end
90
-
91
- end
92
-
93
- def mk_counter_group_info_request(guid)
94
-
95
- # create a new command of type CounterGroupInfoRequest
96
-
97
- msg =TRP::Message.new
98
- msg.trp_command = TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST
99
- msg.counter_group_info_request =TRP:: CounterGroupInfoRequest.new
100
- cgir_msg=msg.counter_group_info_request
101
-
102
- # fill in basic info
103
-
104
- cgir_msg.context =0
105
- cgir_msg.counter_group=guid
106
- return msg
107
-
108
- end
109
-
110
-
111
- def print_counter_group_info_response(resp_in)
112
-
113
- resp=resp_in.counter_group_info_response
114
-
115
- p "----------------------------"
116
- p "Counter Group Info Response"
117
- p "----------------------------"
118
- p "Context = #{ resp.context}"
119
- resp.group_details.each do |group_detail|
120
- p "Name = #{ group_detail.name}"
121
- p "Guid = " + group_detail.guid
122
- p "Bucket Size = #{ group_detail.bucket_size}"
123
- p Time.at(group_detail.time_interval.from.tv_sec)
124
- p Time.at(group_detail.time_interval.to.tv_sec)
125
- end
126
- end
127
-
128
-
129
-
130
- def mk_session_group_request()
131
-
132
- # create a new command of type CounterItemRequest
133
- msg =TRP::Message.new
134
- msg.trp_command = TRP::Message::Command::SESSION_GROUP_REQUEST
135
- msg.session_group_request =TRP:: SessionGroupRequest.new
136
- sgr_msg=msg.session_group_request
137
-
138
- # fill in basic info
139
- sgr_msg.context =0
140
- sgr_msg.maxitems=100
141
- sgr_msg.tracker_id=1
142
- sgr_msg.session_group="{99A78737-4B41-4387-8F31-8077DB917336}"
143
-
144
- return msg
145
-
146
- end
147
-
148
- def print_session_group_response(resp_in)
149
-
150
- resp=resp_in.session_group_response
151
-
152
- p "----------------------------"
153
- p "Session Group Response"
154
- p "----------------------------"
155
- p "Context = #{ resp.context}"
156
- p "Session Group = " + resp.session_group
157
- resp.session_keys.each do |session_key|
158
- p "Session Key = " + session_key
159
- end
160
-
161
- end
162
-
163
- # creates a counter group request message by filling in the
164
- # protobuf
165
-
166
- def mk_counter_group_request(guid,time_from,time_to,time_instant)
167
-
168
- # create a new command of type CounterGroupRequest
169
- msg =TRP::Message.new
170
- msg.trp_command = TRP::Message::Command::COUNTER_GROUP_REQUEST
171
- msg.counter_group_request =TRP:: CounterGroupRequest.new
172
- cir_msg=msg.counter_group_request
173
-
174
- # fill in basic info
175
- cir_msg.context =0
176
- cir_msg.counter_group=guid
177
- cir_msg.meter=0
178
- cir_msg.maxitems=20
179
-
180
-
181
- # fill in time_interval
182
- cir_msg.time_interval=TRP::TimeInterval.new
183
- tint=cir_msg.time_interval
184
- tint.from=TRP::Timestamp.new
185
- tint.from.tv_sec=time_from.tv_sec
186
- tint.from.tv_usec=0
187
- tint.to=TRP::Timestamp.new
188
- tint.to.tv_sec=time_to.tv_sec
189
- tint.to.tv_usec=0
190
-
191
- #fill in time_instant
192
- #cir_msg.time_instant=TRP::Timestamp.new
193
- #cir_msg.time_instant.tv_sec=time_instant.tv_sec+1000
194
- #cir_msg.time_instant.tv_usec=0
195
- return msg
196
- end
197
-
198
- # print response
199
-
200
- def print_counter_group_response(resp_in)
201
- resp=resp_in.counter_group_response
202
- p "..........................."
203
- p "Counter Group Response"
204
- p "---------------------"
205
- p "Context = #{ resp.context}"
206
- p "CounterGroup = " + resp.counter_group
207
- p "Meters= #{resp.meter}"
208
- resp.keys.each do|key|
209
- p "key => " + key.label
210
- end
211
- end
212
-
213
- def mk_key_session_activity_request(key,time_from,time_to)
214
-
215
- # create a new command of type CounterItemRequest
216
- msg =TRP::Message.new
217
- msg.trp_command = TRP::Message::Command::KEY_SESS_ACTIVITY_REQUEST
218
- msg.key_session_activity_request =TRP::KeySessionActivityRequest.new
219
- ksar_msg=msg.key_session_activity_request
220
-
221
- # fill in basic info
222
- ksar_msg.context =0
223
- ksar_msg.maxitems=100
224
- ksar_msg.session_group="{99A78737-4B41-4387-8F31-8077DB917336}"
225
- ksar_msg.key= key
226
- ksar_msg.duration_filter=9
227
- ksar_msg.volume_filter=10
228
-
229
- # fill in time_interval
230
- ksar_msg.time_interval=TRP::TimeInterval.new
231
- tint=ksar_msg.time_interval
232
- tint.from=TRP::Timestamp.new
233
- tint.from.tv_sec=time_from.tv_sec
234
- tint.from.tv_usec=0
235
- tint.to=TRP::Timestamp.new
236
- tint.to.tv_sec=time_to.tv_sec
237
- tint.to.tv_usec=0
238
- return msg
239
-
240
- end
241
-
242
- def print_key_session_activity_response(resp_in)
243
-
244
- resp=resp_in.key_session_activity_response
245
-
246
- p "----------------------------"
247
- p "Session Item Response"
248
- p "----------------------------"
249
- p "Context = #{ resp.context}"
250
- p "Session Group = " + resp.session_group
251
-
252
- end
253
-
254
- # creates a session item request
255
- # gets details about a sessionid
256
- def mk_session_item_request(slice_id,session_id)
257
-
258
- # create a new command of type SessionItemRequest
259
- msg =TRP::Message.new
260
- msg.trp_command = TRP::Message::Command::SESSION_ITEM_REQUEST
261
- msg.session_item_request =TRP::SessionItemRequest.new
262
- cir_msg=msg.session_item_request
263
-
264
- # fill in basic info (guid = session id for flows)
265
- cir_msg.context =0
266
- cir_msg.session_group="{99A78737-4B41-4387-8F31-8077DB917336}"
267
- cir_msg.session_id = TRP::SessionID.new
268
- cir_msg.session_id.slice_id=slice_id
269
- cir_msg.session_id.session_id=session_id
270
-
271
- return msg
272
- end
273
-
274
- # prints a neat table of session activity
275
- def print_session_item_response(resp_in)
276
- resp=resp_in.session_item_response
277
- print "#{resp.state} "
278
- print "#{Time.at(resp.time_interval.from.tv_sec)} "
279
- print "#{resp.time_interval.to.tv_sec-resp.time_interval.from.tv_sec} ".rjust(8)
280
- print "#{resp.key1A.label}".ljust(28)
281
- print "#{resp.key2A.label}".ljust(11)
282
- print "#{resp.key1Z.label}".ljust(28)
283
- print "#{resp.key2Z.label}".ljust(11)
284
- print "#{resp.az_bytes}".rjust(10)
285
- print "#{resp.za_bytes}".rjust(10)
286
- print "\n"
287
-
288
- end
289
-
290
-
291
- def mk_session_tracker_request(time_from,time_to)
292
-
293
- # create a new command of type CounterItemRequest
294
- msg =TRP::Message.new
295
- msg.trp_command = TRP::Message::Command::SESSION_TRACKER_REQUEST
296
- msg.session_tracker_request =TRP:: SessionTrackerRequest.new
297
- str_msg=msg.session_tracker_request
298
-
299
- # fill in basic info
300
- str_msg.context =0
301
- str_msg.maxitems=100
302
- str_msg.tracker_id=1
303
- str_msg.session_group="{99A78737-4B41-4387-8F31-8077DB917336}"
304
-
305
- # fill in time_interval
306
- str_msg.time_interval=TRP::TimeInterval.new
307
- tint=str_msg.time_interval
308
- tint.from=TRP::Timestamp.new
309
- tint.from.tv_sec=time_from.tv_sec
310
- tint.from.tv_usec=0
311
- tint.to=TRP::Timestamp.new
312
- tint.to.tv_sec=time_to.tv_sec
313
- tint.to.tv_usec=0
314
- return msg
315
-
316
- end
317
-
318
- def print_session_tracker_response(resp_in)
319
-
320
- resp=resp_in.session_tracker_response
321
-
322
- p "----------------------------"
323
- p "Session Tracker Response"
324
- p "----------------------------"
325
- p "Context = #{ resp.context}"
326
- p "Session Group = " + resp.session_group
327
-
328
- end
329
-
330
- end