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.
- data/README.rdoc +10 -1
- data/VERSION +1 -1
- data/lib/trisulrp/guids.rb +43 -0
- data/lib/trisulrp/keys.rb +200 -0
- data/lib/trisulrp/protocol.rb +103 -0
- data/lib/{trp.pb.rb → trisulrp/trp.pb.rb} +91 -48
- data/lib/{trp.proto → trisulrp/trp.proto} +84 -49
- data/lib/trisulrp.rb +6 -5
- data/test/Demo_Client.key +13 -16
- data/test/test_alerts.rb +84 -0
- data/test/test_cap.rb +55 -0
- data/test/test_key_flows.rb +61 -0
- data/test/test_resources.rb +76 -0
- data/test/test_trisulrp.rb +13 -4
- data/trisulrp.gemspec +15 -5
- metadata +17 -7
- data/lib/trplib.rb +0 -330
@@ -1,6 +1,6 @@
|
|
1
1
|
// Trisul Remote Protocol (TRP) definition
|
2
2
|
// Based on Google Protocol Buffers
|
3
|
-
// (c) 2010, Unleash Networks
|
3
|
+
// (c) 2010-11, Unleash Networks
|
4
4
|
//
|
5
5
|
package TRP;
|
6
6
|
|
@@ -124,6 +124,8 @@ message Message {
|
|
124
124
|
RESOURCE_ITEM_RESPONSE=47;
|
125
125
|
RESOURCE_GROUP_REQUEST=48;
|
126
126
|
RESOURCE_GROUP_RESPONSE=49;
|
127
|
+
KEY_LOOKUP_REQUEST=50;
|
128
|
+
KEY_LOOKUP_RESPONSE=51;
|
127
129
|
}
|
128
130
|
|
129
131
|
required Command trp_command=1;
|
@@ -169,6 +171,8 @@ message Message {
|
|
169
171
|
optional ResourceItemResponse resource_item_response=46;
|
170
172
|
optional ResourceGroupRequest resource_group_request=47;
|
171
173
|
optional ResourceGroupResponse resource_group_response=48;
|
174
|
+
optional KeyLookupRequest key_lookup_request=49;
|
175
|
+
optional KeyLookupResponse key_lookup_response=50;
|
172
176
|
}
|
173
177
|
|
174
178
|
///////////////////////////////
|
@@ -277,7 +281,8 @@ message FilteredDatagramResponse{
|
|
277
281
|
required TimeInterval time_interval=3;
|
278
282
|
required int64 num_datagrams=4;
|
279
283
|
required int64 num_bytes=5;
|
280
|
-
required string
|
284
|
+
required string sha1=6;
|
285
|
+
required bytes contents=7;
|
281
286
|
}
|
282
287
|
|
283
288
|
//////////////////////////////////////////
|
@@ -298,7 +303,7 @@ message ControlledContextResponse{
|
|
298
303
|
///////////////////////////////////////
|
299
304
|
// SearchkeysRequest
|
300
305
|
message SearchKeysRequest{
|
301
|
-
optional int64 context=1;
|
306
|
+
optional int64 context=1[default=0];
|
302
307
|
required string counter_group=2;
|
303
308
|
required string pattern=3;
|
304
309
|
required int64 maxitems=4;
|
@@ -315,7 +320,7 @@ message SearchKeysResponse{
|
|
315
320
|
/////////////////////////////////////
|
316
321
|
/// CounterGroupInfoRequest
|
317
322
|
message CounterGroupInfoRequest{
|
318
|
-
optional int64 context=1;
|
323
|
+
optional int64 context=1[default=0];
|
319
324
|
optional string counter_group=2;
|
320
325
|
}
|
321
326
|
|
@@ -329,34 +334,39 @@ message CounterGroupInfoResponse{
|
|
329
334
|
/////////////////////////////////////
|
330
335
|
// SessionItemRequest
|
331
336
|
message SessionItemRequest{
|
332
|
-
optional int64 context=1;
|
333
|
-
|
334
|
-
|
335
|
-
|
337
|
+
optional int64 context=1[default=0];
|
338
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
339
|
+
repeated string session_keys=3;
|
340
|
+
repeated SessionID session_ids=4;
|
336
341
|
}
|
337
342
|
|
338
343
|
////////////////////////////////////
|
339
344
|
// SessionItemResponse
|
340
345
|
message SessionItemResponse{
|
341
|
-
optional int64 context=1;
|
346
|
+
optional int64 context=1[default=0];
|
342
347
|
required string session_group=2;
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
348
|
+
|
349
|
+
message Item {
|
350
|
+
optional string session_key=1;
|
351
|
+
optional SessionID session_id=2;
|
352
|
+
optional string user_label=3;
|
353
|
+
required TimeInterval time_interval=4;
|
354
|
+
required int64 state=5;
|
355
|
+
required int64 az_bytes=6;
|
356
|
+
required int64 za_bytes=7;
|
357
|
+
required KeyDetails key1A=8;
|
358
|
+
required KeyDetails key2A=9;
|
359
|
+
required KeyDetails key1Z=10;
|
360
|
+
required KeyDetails key2Z=11;
|
361
|
+
}
|
362
|
+
|
363
|
+
repeated Item items=3;
|
354
364
|
}
|
355
365
|
|
356
366
|
//////////////////////////////////////////
|
357
367
|
// BulkCounterItemRequest
|
358
368
|
message BulkCounterItemRequest{
|
359
|
-
optional int64 context=1;
|
369
|
+
optional int64 context=1[default=0];
|
360
370
|
required string counter_group=2;
|
361
371
|
required int64 meter=3;
|
362
372
|
required TimeInterval time_interval=4;
|
@@ -373,7 +383,7 @@ message BulkCounterItemResponse{
|
|
373
383
|
///////////////////////////////////////////
|
374
384
|
/// TopperSnapshotRequest
|
375
385
|
message TopperSnapshotRequest{
|
376
|
-
optional int64 context=1;
|
386
|
+
optional int64 context=1[default=0];
|
377
387
|
required string counter_group=2;
|
378
388
|
required int64 meter=3;
|
379
389
|
required TimeInterval Time=4;
|
@@ -397,7 +407,7 @@ message TopperSnapshotResponse{
|
|
397
407
|
/// UpdatekeysRequest
|
398
408
|
/// Response = OKResponse or ErrorResponse
|
399
409
|
message UpdateKeyRequest{
|
400
|
-
optional int64 context=1;
|
410
|
+
optional int64 context=1[default=0];
|
401
411
|
required string counter_group=2;
|
402
412
|
required string key=4;
|
403
413
|
required string label=5;
|
@@ -407,12 +417,12 @@ message UpdateKeyRequest{
|
|
407
417
|
///////////////////////////////////
|
408
418
|
// KeySessionActivityrequest
|
409
419
|
message KeySessionActivityRequest{
|
410
|
-
optional int64 context=1;
|
411
|
-
|
420
|
+
optional int64 context=1[default=0];
|
421
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
412
422
|
required string key=3;
|
413
|
-
|
414
|
-
|
415
|
-
|
423
|
+
optional int64 maxitems=4[default=100];
|
424
|
+
optional int64 volume_filter=5[default=0];
|
425
|
+
optional int64 duration_filter=6[default=0];
|
416
426
|
required TimeInterval time_interval=7;
|
417
427
|
}
|
418
428
|
|
@@ -427,8 +437,8 @@ message KeySessionActivityResponse{
|
|
427
437
|
/////////////////////////////////////
|
428
438
|
// SessionTrackerRequest
|
429
439
|
message SessionTrackerRequest {
|
430
|
-
optional int64 context=1;
|
431
|
-
|
440
|
+
optional int64 context=1[default=0];
|
441
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
432
442
|
required int64 tracker_id=3 [default=1];
|
433
443
|
optional int64 maxitems=4 [default=100];
|
434
444
|
required TimeInterval time_interval=5;
|
@@ -445,8 +455,8 @@ message SessionTrackerResponse{
|
|
445
455
|
///////////////////////////////////
|
446
456
|
// SessionGroupRequest
|
447
457
|
message SessionGroupRequest {
|
448
|
-
optional int64 context=1;
|
449
|
-
|
458
|
+
optional int64 context=1[default=0];
|
459
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
450
460
|
optional int64 tracker_id=3;
|
451
461
|
optional string key_filter=4;
|
452
462
|
optional int64 maxitems=5 [default=100];
|
@@ -487,33 +497,36 @@ message ServerStatsResponse{
|
|
487
497
|
/////////////////////////////////////
|
488
498
|
// AlertItemRequest
|
489
499
|
message AlertItemRequest{
|
490
|
-
optional int64 context=1;
|
500
|
+
optional int64 context=1[default=0];
|
491
501
|
required string alert_group=2;
|
492
|
-
|
502
|
+
repeated AlertID alert_ids=3;
|
493
503
|
}
|
494
504
|
////////////////////////////////////
|
495
505
|
// AlertItemResponse
|
496
506
|
message AlertItemResponse{
|
497
507
|
optional int64 context=1;
|
498
508
|
required string alert_group=2;
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
509
|
+
message Item {
|
510
|
+
optional int64 sensor_id=1;
|
511
|
+
required Timestamp time=2;
|
512
|
+
optional string source_ip=3;
|
513
|
+
optional string source_port=4;
|
514
|
+
optional string destination_ip=5;
|
515
|
+
optional string destination_port=6;
|
516
|
+
required string sigid=7;
|
517
|
+
required string classification=8;
|
518
|
+
required string priority=9;
|
519
|
+
required Timestamp dispatch_time=10;
|
520
|
+
required string aux_message1=11;
|
521
|
+
required string aux_message2=12;
|
522
|
+
}
|
523
|
+
repeated Item items=3;
|
511
524
|
}
|
512
525
|
|
513
526
|
////////////////////////////////////
|
514
527
|
// AlertGroupQueryRequest
|
515
528
|
message AlertGroupRequest {
|
516
|
-
optional int64 context=1;
|
529
|
+
optional int64 context=1[default=0];
|
517
530
|
required string alert_group=2;
|
518
531
|
required TimeInterval time_interval=3;
|
519
532
|
optional int64 maxitems=5 [default=10];
|
@@ -539,7 +552,7 @@ message AlertGroupResponse {
|
|
539
552
|
/////////////////////////////////////
|
540
553
|
// ResourceRequest - mutliple
|
541
554
|
message ResourceItemRequest{
|
542
|
-
optional int64 context=1;
|
555
|
+
optional int64 context=1[default=0];
|
543
556
|
required string resource_group=2;
|
544
557
|
repeated ResourceID resource_ids=3;
|
545
558
|
}
|
@@ -564,7 +577,7 @@ message ResourceItemResponse{
|
|
564
577
|
////////////////////////////////////
|
565
578
|
// ResourceGroupRequest
|
566
579
|
message ResourceGroupRequest {
|
567
|
-
optional int64 context=1;
|
580
|
+
optional int64 context=1[default=0];
|
568
581
|
required string resource_group=2;
|
569
582
|
required TimeInterval time_interval=3;
|
570
583
|
optional int64 maxitems=4 [default=10];
|
@@ -583,3 +596,25 @@ message ResourceGroupResponse {
|
|
583
596
|
required string resource_group=2;
|
584
597
|
repeated ResourceID resources=3;
|
585
598
|
}
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
/////////////////////////////////////////////
|
603
|
+
// KeyLookup - mutliple keys from a single CG
|
604
|
+
message KeyLookupRequest {
|
605
|
+
optional int64 context=1[default=0];
|
606
|
+
required string counter_group=2;
|
607
|
+
repeated string keys=3;
|
608
|
+
}
|
609
|
+
|
610
|
+
|
611
|
+
/////////////////////////////////////////////
|
612
|
+
// KeyLookup
|
613
|
+
message KeyLookupResponse {
|
614
|
+
optional int64 context=1;
|
615
|
+
required string counter_group=2;
|
616
|
+
repeated KeyDetails key_details=3;
|
617
|
+
}
|
618
|
+
|
619
|
+
|
620
|
+
|
data/lib/trisulrp.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
-
# =
|
4
|
+
# =TrisulRP - Trisul Remote Protocol
|
5
5
|
# #
|
6
6
|
# #
|
7
7
|
# # Author:: Vivek Rajagopalan
|
8
8
|
# # Date:: 30 Dec 2010
|
9
|
-
|
10
|
-
module TRP
|
9
|
+
module TrisulRP
|
11
10
|
end
|
12
11
|
|
13
12
|
require 'rubygems'
|
14
|
-
require '
|
15
|
-
require '
|
13
|
+
require 'trisulrp/trp.pb'
|
14
|
+
require 'trisulrp/guids.rb'
|
15
|
+
require 'trisulrp/keys.rb'
|
16
|
+
require 'trisulrp/protocol.rb'
|
data/test/Demo_Client.key
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
9whz5JBEivzaMUXuS3SuYAN0qs5H0CPkY3o/Zz2vwauPD5Sgj4yZ8g3LFfWYCUXj
|
16
|
-
3FTQbUdPZLbymdgrto4XYt99Bdt0PbfVAAecjxGM5mlRsvw0tVkU6rn2F6PFJPtd
|
17
|
-
OL8voxUdgGfXemPGokYhVnZfJF6ch9pqYPRO1seE3zg=
|
2
|
+
MIICWwIBAAKBgQC3+D5b5aaHtuNdkavx42B0eNfnOVHBWV8pQuADttXwNu6Ujt82
|
3
|
+
ApqjlSq446p+dYQ2ame4uMk9zDYlgPNkn3eK9zfB7Lq1KGphs1Qmp4lze0eN/GcA
|
4
|
+
2jWRYh7KHTNUudIc6OLcmY4l3HveIefOo35oB63JOnFgbUXyNPJ3HDGKMQIDAQAB
|
5
|
+
AoGAc9oxsv95EqgaoJcW1/ofiNl85VDUalVUtxA1MEGYknCVaBpc+I9FQNS0FcDR
|
6
|
+
YlexDe+OJ+a+XFtYkd+V5v0BcwDlJhuyBRUQNFURUZL7XHaT6Ppj6Xmz00Y8zaxT
|
7
|
+
5BIteHR3jCdkggCfOa0mG4QD4ax0J/FlMepbp7b4p7k5Au0CQQDomrmzVmIdS5Pl
|
8
|
+
khGRRMk4OCdHDuOl/KFALJbGohuxRR5U3vggusgMb0BM51aRfhKq9+tmIpk0kCv4
|
9
|
+
+MRYBySbAkEAynk8MwO3Lr3n6pELYKj4LuX+TjJh9ZiWQIz9AydBkXOgeW325rMj
|
10
|
+
0im+VtFJHqpIUlJVEHZucscxEB/w64yrIwJAUFUvkVpiJE/30i9yVcN14y6xkf74
|
11
|
+
bFklr642nH9cJQsEALfI5jTb5j9965Fx+mmaNOXOrMWCN/8a0K/Jz8UXxQJAOYqE
|
12
|
+
yja3G4iK3UXFRv4eMi3YvN5iqopnwQaQbRH991k19OyEa4HjnzmPx1qI/jcEgKi3
|
13
|
+
VgtiTio/zkZVkIuUowJAUx0rfsJgMl1wIJhrKSPjLWcT12P2nZc3wgzS3IvHOc7j
|
14
|
+
ANFiajPo3y0qV3AJHbSnz8FejOCDUHLttA5kvsF4dw==
|
18
15
|
-----END RSA PRIVATE KEY-----
|
data/test/test_alerts.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Trisul Remote Protocol TRP Demo script
|
2
|
+
# Akhil.M & Dhinesh.K (c) 2010 Unleash Networks
|
3
|
+
# Testing change
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require './helper'
|
7
|
+
include TRPLib
|
8
|
+
|
9
|
+
GUID_CG_APP = "{C51B48D4-7876-479E-B0D9-BD9EFF03CE2E}"
|
10
|
+
|
11
|
+
AG_IDS = "{9AFD8C08-07EB-47E0-BF05-28B4A7AE8DC9}"
|
12
|
+
CG_SIGDS = "{A0FA9464-B496-4A20-A9AB-4D2D09AFF902}"
|
13
|
+
|
14
|
+
CG_HOSTS = "{4CD742B1-C1CA-4708-BE78-0FCA2EB01A86}"
|
15
|
+
CG_APPS = "{C51B48D4-7876-479E-B0D9-BD9EFF03CE2E}"
|
16
|
+
|
17
|
+
|
18
|
+
class TestTrisulrp < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
if @trp_conn.nil?
|
22
|
+
@trp_conn=TRPLib::connect_trp("127.0.0.1",
|
23
|
+
12001,
|
24
|
+
"Demo_Client.crt",
|
25
|
+
"Demo_Client.key")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def test_query_alerts
|
31
|
+
|
32
|
+
target_ip = "0A.02.C7.EB" # 10.2.199.235"
|
33
|
+
tm_arr = TRPLib::get_available_time(@trp_conn)
|
34
|
+
|
35
|
+
# The Request
|
36
|
+
# ----------
|
37
|
+
req =TRP::Message.new(:trp_command => TRP::Message::Command::ALERT_GROUP_REQUEST)
|
38
|
+
req.alert_group_request =TRP::AlertGroupRequest.new( :context => 0,
|
39
|
+
:alert_group => AG_IDS,
|
40
|
+
:source_ip => target_ip,
|
41
|
+
:maxitems => 1000,
|
42
|
+
:time_interval => TRPLib.mk_time_interval(tm_arr)
|
43
|
+
)
|
44
|
+
|
45
|
+
# The Response
|
46
|
+
# ------------
|
47
|
+
get_trp_response(@trp_conn,req) do |resp|
|
48
|
+
|
49
|
+
follow_up = TRP::Message.new(:trp_command => TRP::Message::Command::ALERT_ITEM_REQUEST)
|
50
|
+
follow_up.alert_item_request = TRP::AlertItemRequest.new(:alert_group => AG_IDS)
|
51
|
+
resp.alert_group_response.alerts.each do |al|
|
52
|
+
follow_up.alert_item_request.alert_ids << TRP::AlertID.new(:slice_id => al.slice_id, :alert_id => al.alert_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
get_trp_response(@trp_conn,follow_up) do | resp2 |
|
56
|
+
|
57
|
+
resp=resp2.alert_item_response
|
58
|
+
resolv_candidates = resp.items.collect { |item| [item.source_ip, item.source_port, item.destination_ip, item.destination_port,item.sigid] }
|
59
|
+
resolv_arr = resolv_candidates.transpose
|
60
|
+
|
61
|
+
|
62
|
+
sip_names = TRPLib::get_labels_for_keys(@trp_conn,CG_HOSTS, resolv_arr[0])
|
63
|
+
sport_names = TRPLib::get_labels_for_keys(@trp_conn,CG_APPS, resolv_arr[1])
|
64
|
+
dip_names = TRPLib::get_labels_for_keys(@trp_conn,CG_HOSTS, resolv_arr[2])
|
65
|
+
dport_names = TRPLib::get_labels_for_keys(@trp_conn,CG_APPS, resolv_arr[3])
|
66
|
+
sigid_names = TRPLib::get_labels_for_keys(@trp_conn,CG_SIGDS, resolv_arr[4])
|
67
|
+
|
68
|
+
resp.items.each do |item|
|
69
|
+
print "#{Time.at(item.time.tv_sec)} "
|
70
|
+
print "#{sip_names[item.source_ip]}".ljust(28)
|
71
|
+
print "#{sport_names[item.source_port]}".ljust(11)
|
72
|
+
print "#{dip_names[item.destination_ip]}".ljust(28)
|
73
|
+
print "#{dport_names[item.destination_port]}".ljust(11)
|
74
|
+
print "#{sigid_names[item.sigid]}".rjust(10)
|
75
|
+
print "\n"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
data/test/test_cap.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Trisul Remote Protocol TRP Demo script
|
2
|
+
# Akhil.M & Dhinesh.K (c) 2010 Unleash Networks
|
3
|
+
# Testing change
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require './helper'
|
7
|
+
include TRPLib
|
8
|
+
require 'guidmap'
|
9
|
+
|
10
|
+
|
11
|
+
class TestCap < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@trp_conn=TRPLib::connect("127.0.0.1",
|
15
|
+
12001,
|
16
|
+
"Demo_Client.crt",
|
17
|
+
"Demo_Client.key")
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def test_dpi
|
22
|
+
|
23
|
+
target_sess = TRP::SessionID.new(:slice_id => 2, :session_id => 207)
|
24
|
+
#target_sess = TRP::SessionID.new(:slice_id => 2, :session_id => 4375 )
|
25
|
+
|
26
|
+
# get session time
|
27
|
+
req =TRP::Message.new(:trp_command => TRP::Message::Command::SESSION_ITEM_REQUEST )
|
28
|
+
req.session_item_request =
|
29
|
+
TRP::SessionItemRequest.new(:session_ids => [target_sess])
|
30
|
+
|
31
|
+
resp=TRPLib::get_trp_response(@trp_conn,req) do |resp|
|
32
|
+
si = resp.session_item_response.items[0]
|
33
|
+
|
34
|
+
follow_up = TRP::Message.new(:trp_command => TRP::Message::Command::FILTERED_DATAGRAMS_REQUEST)
|
35
|
+
follow_up.filtered_datagram_request = TRP::FilteredDatagramRequest.new(
|
36
|
+
:filter_expression => "#{GUIDMap::SG_TCP}=#{si.session_key}",
|
37
|
+
:time_interval => si.time_interval )
|
38
|
+
TRPLib::get_trp_response(@trp_conn,follow_up) do |resp|
|
39
|
+
fdr=resp.filtered_datagram_response
|
40
|
+
|
41
|
+
p "Number of bytes = #{fdr.num_bytes}\n"
|
42
|
+
p "Number of pkts = #{fdr.num_datagrams}\n"
|
43
|
+
p "Hash = #{fdr.sha1}\n"
|
44
|
+
|
45
|
+
File.open("t.pcap","wb") do |f|
|
46
|
+
f.write(fdr.contents)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Trisul Remote Protocol TRP Demo script
|
2
|
+
# Akhil.M & Dhinesh.K (c) 2010 Unleash Networks
|
3
|
+
# Testing change
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
|
7
|
+
require './helper'
|
8
|
+
include TRPLib
|
9
|
+
|
10
|
+
GUID_CG_APP = "{C51B48D4-7876-479E-B0D9-BD9EFF03CE2E}"
|
11
|
+
|
12
|
+
class TestTrisulrp < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@trp_conn=TRPLib::connect_trp("127.0.0.1",
|
16
|
+
12001,
|
17
|
+
"Demo_Client.crt",
|
18
|
+
"Demo_Client.key")
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_flows_for_host
|
23
|
+
|
24
|
+
target_key = "0A.01.3C.BB"
|
25
|
+
|
26
|
+
tmarr = TRPLib::get_available_time(@trp_conn)
|
27
|
+
|
28
|
+
# create a new command of type CounterItemRequest
|
29
|
+
req =TRP::Message.new(:trp_command => TRP::Message::Command::KEY_SESS_ACTIVITY_REQUEST )
|
30
|
+
|
31
|
+
req.key_session_activity_request =
|
32
|
+
TRP::KeySessionActivityRequest.new( :key => target_key ,
|
33
|
+
:time_interval => TRPLib::mk_time_interval(tmarr))
|
34
|
+
TRPLib::get_trp_response(@trp_conn,req) do |resp|
|
35
|
+
|
36
|
+
all_sids = resp.key_session_activity_response.sessions.collect { |ai| TRP::SessionID.new(:slice_id => ai.slice_id, :session_id => ai.session_id ) }
|
37
|
+
|
38
|
+
follow_up = TRP::Message.new(:trp_command => TRP::Message::Command::SESSION_ITEM_REQUEST)
|
39
|
+
follow_up.session_item_request = TRP::SessionItemRequest.new(:session_ids => all_sids)
|
40
|
+
TRPLib::get_trp_response(@trp_conn,follow_up) do |resp|
|
41
|
+
resp.session_item_response.items.each do |item|
|
42
|
+
print "#{item.state} "
|
43
|
+
print "#{Time.at(item.time_interval.from.tv_sec)} "
|
44
|
+
print "#{item.time_interval.to.tv_sec-item.time_interval.from.tv_sec} ".rjust(8)
|
45
|
+
print "#{item.key1A.label}".ljust(28)
|
46
|
+
print "#{item.key2A.label}".ljust(11)
|
47
|
+
print "#{item.key1Z.label}".ljust(28)
|
48
|
+
print "#{item.key2Z.label}".ljust(11)
|
49
|
+
print "#{item.az_bytes}".rjust(10)
|
50
|
+
print "#{item.za_bytes}".rjust(10)
|
51
|
+
print "\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Trisul Remote Protocol TRP Demo script
|
2
|
+
# Akhil.M & Dhinesh.K (c) 2010 Unleash Networks
|
3
|
+
# Testing change
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
|
7
|
+
require './helper'
|
8
|
+
include TRPLib
|
9
|
+
|
10
|
+
GUID_CG_APP = "{C51B48D4-7876-479E-B0D9-BD9EFF03CE2E}"
|
11
|
+
|
12
|
+
class TestTrisulrp < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
if @trp_conn.nil?
|
16
|
+
@trp_conn=TRPLib::connect_trp("127.0.0.1",
|
17
|
+
12001,
|
18
|
+
"Demo_Client.crt",
|
19
|
+
"Demo_Client.key")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def itest_resource_items
|
25
|
+
req=TRPLib::mk_resource_item_request(1,[574,575])
|
26
|
+
get_trp_response(@trp_conn,req) do |resp|
|
27
|
+
TRPLib::print_resource_item_response(resp)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_query_resources
|
32
|
+
|
33
|
+
target_ip = "0A.02.C7.EB" # 10.2.199.235"
|
34
|
+
tm_arr = TRPLib::get_available_time(@trp_conn)
|
35
|
+
|
36
|
+
|
37
|
+
# The Request
|
38
|
+
# ----------
|
39
|
+
req =TRP::Message.new(:trp_command => TRP::Message::Command::RESOURCE_GROUP_REQUEST)
|
40
|
+
req.resource_group_request =TRP::ResourceGroupRequest.new( :context => 0,
|
41
|
+
:resource_group => "{4EF9DEB9-4332-4867-A667-6A30C5900E9E}",
|
42
|
+
:uri_pattern => "dll",
|
43
|
+
:maxitems => 1000,
|
44
|
+
:time_interval => TRPLib.mk_time_interval(tm_arr)
|
45
|
+
)
|
46
|
+
|
47
|
+
# The Response
|
48
|
+
# ------------
|
49
|
+
get_trp_response(@trp_conn,req) do |resp|
|
50
|
+
|
51
|
+
follow_up = TRP::Message.new(:trp_command => TRP::Message::Command::RESOURCE_ITEM_REQUEST)
|
52
|
+
follow_up.resource_item_request = TRP::ResourceItemRequest.new(:context => 0, :resource_group => "{4EF9DEB9-4332-4867-A667-6A30C5900E9E}")
|
53
|
+
resp.resource_group_response.resources.each do |res|
|
54
|
+
follow_up.resource_item_request.resource_ids << TRP::ResourceID.new(:slice_id => res.slice_id, :resource_id => res.resource_id)
|
55
|
+
end
|
56
|
+
|
57
|
+
get_trp_response(@trp_conn,follow_up) do | resp2 |
|
58
|
+
|
59
|
+
resp=resp2.resource_item_response
|
60
|
+
resp.items.each do |item|
|
61
|
+
print "#{Time.at(item.time.tv_sec)} "
|
62
|
+
print "#{item.source_ip}".ljust(28)
|
63
|
+
print "#{item.source_port}".ljust(11)
|
64
|
+
print "#{item.destination_ip}".ljust(28)
|
65
|
+
print "#{item.destination_port}".ljust(11)
|
66
|
+
print "#{item.uri}".rjust(10)
|
67
|
+
print "\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
data/test/test_trisulrp.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require './helper'
|
2
|
+
|
3
|
+
include TrisulRP::Protocol
|
2
4
|
|
3
5
|
class TestTrisulrp < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
def test_basic
|
8
|
+
|
9
|
+
TrisulRP::Protocol.connect("127.0.0.1", 12001,
|
10
|
+
"Demo_Client.crt", "Demo_Client.key") do |conn|
|
11
|
+
TrisulRP::Protocol.get_available_time(conn)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
7
16
|
end
|
data/trisulrp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{trisulrp}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["vivek"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-06}
|
13
13
|
s.description = %q{This gem deals about the trisul remote protocol}
|
14
14
|
s.email = %q{vivek_rajagopal@yahoo.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,12 +25,18 @@ Gem::Specification.new do |s|
|
|
25
25
|
"VERSION",
|
26
26
|
"examples/strp.rb",
|
27
27
|
"lib/trisulrp.rb",
|
28
|
-
"lib/
|
29
|
-
"lib/
|
30
|
-
"lib/
|
28
|
+
"lib/trisulrp/guids.rb",
|
29
|
+
"lib/trisulrp/keys.rb",
|
30
|
+
"lib/trisulrp/protocol.rb",
|
31
|
+
"lib/trisulrp/trp.pb.rb",
|
32
|
+
"lib/trisulrp/trp.proto",
|
31
33
|
"test/Demo_Client.crt",
|
32
34
|
"test/Demo_Client.key",
|
33
35
|
"test/helper.rb",
|
36
|
+
"test/test_alerts.rb",
|
37
|
+
"test/test_cap.rb",
|
38
|
+
"test/test_key_flows.rb",
|
39
|
+
"test/test_resources.rb",
|
34
40
|
"test/test_trisulrp.rb",
|
35
41
|
"trisulrp.gemspec"
|
36
42
|
]
|
@@ -42,6 +48,10 @@ Gem::Specification.new do |s|
|
|
42
48
|
s.test_files = [
|
43
49
|
"examples/strp.rb",
|
44
50
|
"test/helper.rb",
|
51
|
+
"test/test_alerts.rb",
|
52
|
+
"test/test_cap.rb",
|
53
|
+
"test/test_key_flows.rb",
|
54
|
+
"test/test_resources.rb",
|
45
55
|
"test/test_trisulrp.rb"
|
46
56
|
]
|
47
57
|
|