rb-wartslib 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ /*
2
+ ** Ruby bindings to scamper_trace_t and its nested structures (e.g.,
3
+ ** scamper_list_t, scamper_cycle_t, and scamper_trace_hop_t).
4
+ **
5
+ ** --------------------------------------------------------------------------
6
+ ** Copyright (C) 2007 The Regents of the University of California.
7
+ **
8
+ ** This program is free software; you can redistribute it and/or modify
9
+ ** it under the terms of the GNU General Public License as published by
10
+ ** the Free Software Foundation; either version 2 of the License, or
11
+ ** (at your option) any later version.
12
+ **
13
+ ** This program is distributed in the hope that it will be useful,
14
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ ** GNU General Public License for more details.
17
+ **
18
+ ** You should have received a copy of the GNU General Public License
19
+ ** along with this program; if not, write to the Free Software
20
+ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ **
22
+ ** $Id: sctrace.h,v 1.3 2007/11/29 01:33:42 youngh Exp $
23
+ **/
24
+
25
+ #ifndef __SCFILE_H
26
+ #define __SCFILE_H
27
+
28
+ #include "scamper_list.h"
29
+ #include "scamper_addr.h"
30
+ #include "scamper_trace.h"
31
+
32
+ VALUE sctrace_create(scamper_trace_t *trace);
33
+ void Init_sctrace(void);
34
+
35
+ #endif # __SCFILE_H
@@ -0,0 +1,27 @@
1
+ #############################################################################
2
+ ## Pulls in all wartslib files, including the compiled extension and
3
+ ## Ruby-based augmentation of extension classes.
4
+ ##
5
+ ## --------------------------------------------------------------------------
6
+ ## Copyright (C) 2007 The Regents of the University of California.
7
+ ##
8
+ ## This program is free software; you can redistribute it and/or modify
9
+ ## it under the terms of the GNU General Public License as published by
10
+ ## the Free Software Foundation; either version 2 of the License, or
11
+ ## (at your option) any later version.
12
+ ##
13
+ ## This program is distributed in the hope that it will be useful,
14
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ ## GNU General Public License for more details.
17
+ ##
18
+ ## You should have received a copy of the GNU General Public License
19
+ ## along with this program; if not, write to the Free Software
20
+ ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ ##
22
+ ## $Id: wartslib.rb,v 1.3 2007/11/29 01:22:53 youngh Exp $
23
+ #############################################################################
24
+
25
+ require "wartslibext"
26
+ require "wartslib/wl-file.rb"
27
+ require "wartslib/wl-trace.rb"
@@ -0,0 +1,85 @@
1
+ #############################################################################
2
+ ## Some additional methods of wartslib classes.
3
+ ##
4
+ ## --------------------------------------------------------------------------
5
+ ## Copyright (C) 2007 The Regents of the University of California.
6
+ ##
7
+ ## This program is free software; you can redistribute it and/or modify
8
+ ## it under the terms of the GNU General Public License as published by
9
+ ## the Free Software Foundation; either version 2 of the License, or
10
+ ## (at your option) any later version.
11
+ ##
12
+ ## This program is distributed in the hope that it will be useful,
13
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ ## GNU General Public License for more details.
16
+ ##
17
+ ## You should have received a copy of the GNU General Public License
18
+ ## along with this program; if not, write to the Free Software
19
+ ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ ##
21
+ ## $Id: wl-file.rb,v 1.8 2007/11/29 01:25:42 youngh Exp $
22
+ #############################################################################
23
+
24
+ module Warts
25
+
26
+ class File
27
+
28
+ class <<self
29
+ alias_method :__raw_open, :open
30
+ end
31
+
32
+ def self.open(path_or_fd, mode="r", type=nil, &block)
33
+ if path_or_fd == nil
34
+ raise ArgumentError, "missing path or fd"
35
+ elsif path_or_fd.kind_of?(Integer) || path_or_fd.kind_of?(IO)
36
+ __raw_open path_or_fd, mode, type, &block
37
+ else
38
+ path = path_or_fd.to_s
39
+ return nil if mode == "r" && !::File.exists?(path)
40
+
41
+ if path =~ /\.(warts|arts)(\.gz|\.bz2|\.lzo)?$/
42
+ type = $1 unless type
43
+ end
44
+
45
+ command = nil
46
+ case path
47
+ when /\.gz$/: command = "gzip -dc"
48
+ when /\.bz2$/: command = "bzip2 -dc"
49
+ when /\.lzo$/: command = "lzop -dc"
50
+ end
51
+
52
+ if mode == "r" && command
53
+ io = IO.popen "#{command} #{path}"
54
+ begin
55
+ retval = __raw_open io, mode, type, &block
56
+ unless block
57
+ retval.instance_variable_set :@___popen_io, io
58
+ retval
59
+ end
60
+ rescue
61
+ io.close rescue nil
62
+ raise
63
+ ensure
64
+ io.close rescue nil if block
65
+ end
66
+ else
67
+ __raw_open path, mode, type, &block
68
+ end
69
+ end
70
+ end
71
+
72
+ alias_method :__raw_close, :close
73
+
74
+ def close
75
+ __raw_close
76
+ io = instance_variable_get :@___popen_io
77
+ if io
78
+ io.close rescue nil
79
+ instance_variable_set :@___popen_io, nil
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -0,0 +1,111 @@
1
+ #############################################################################
2
+ ## Some additional methods of wartslib classes.
3
+ ##
4
+ ## --------------------------------------------------------------------------
5
+ ## Copyright (C) 2007 The Regents of the University of California.
6
+ ##
7
+ ## This program is free software; you can redistribute it and/or modify
8
+ ## it under the terms of the GNU General Public License as published by
9
+ ## the Free Software Foundation; either version 2 of the License, or
10
+ ## (at your option) any later version.
11
+ ##
12
+ ## This program is distributed in the hope that it will be useful,
13
+ ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ ## GNU General Public License for more details.
16
+ ##
17
+ ## You should have received a copy of the GNU General Public License
18
+ ## along with this program; if not, write to the Free Software
19
+ ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ ##
21
+ ## $Id: wl-trace.rb,v 1.5 2007/11/29 01:26:43 youngh Exp $
22
+ #############################################################################
23
+
24
+ module Warts
25
+
26
+ class Trace
27
+
28
+ private
29
+
30
+ HALT_REASON = []
31
+ HALT_REASON[Warts::Trace::STOP_COMPLETED] = "S"
32
+ HALT_REASON[Warts::Trace::STOP_NONE] = "S"
33
+ HALT_REASON[Warts::Trace::STOP_UNREACH] = "U"
34
+ HALT_REASON[Warts::Trace::STOP_LOOP] = "L"
35
+ HALT_REASON[Warts::Trace::STOP_DEAD] = "G"
36
+
37
+ public
38
+
39
+ # The length of the path (in hops), taking any responding destination into
40
+ # account.
41
+ #
42
+ # The hop_count attribute doesn't provide this value because hop_count
43
+ # gives the number of hops probed (that is, attempted) and not the number
44
+ # of hops with responses (or, alternatively, the highest TTL of responding
45
+ # hops).
46
+ def path_length
47
+ dest_response = find_dest_response
48
+ if dest_response
49
+ dest_response[0] + 1
50
+ else
51
+ return 0 if hop_count == 0
52
+ (hop_count-1).downto(0) do |hop|
53
+ return hop + 1 if hop_exists? hop
54
+ end
55
+ return 0
56
+ end
57
+ end
58
+
59
+ def dump
60
+ fields = ["T"]
61
+
62
+ fields.push src, dst, list_id, cycle_id, start
63
+
64
+ dest_response = find_dest_response
65
+ if dest_response
66
+ fields.push "R", hop_rtt_str(*dest_response),
67
+ hop_probe_ttl(*dest_response),
68
+ hop_reply_ttl(*dest_response)
69
+ else
70
+ fields.push "N", 0, 0, 0
71
+ end
72
+
73
+ fields.push(HALT_REASON[stop_reason] || "?")
74
+ fields.push stop_data
75
+
76
+ fields.push(complete? ? "C" : "I")
77
+
78
+ # For compatibility with sc_analysis_dump, we don't print missing hops
79
+ # at the end of the trace.
80
+ unresponsive = 0
81
+ each_hop do |hop, exists|
82
+ if exists
83
+ hop_str = ""
84
+ each_attempt(hop) do |attempt|
85
+ # sc_analysis_dump compatibility
86
+ next if dest_response &&
87
+ hop == dest_response[0] && attempt == dest_response[1]
88
+
89
+ hop_str << ";" unless hop_str.empty?
90
+ hop_str << hop_addr(hop, attempt)
91
+ hop_str << "," << hop_rtt_str(hop, attempt)
92
+ hop_str << "," << hop_probe_id(hop, attempt).to_s
93
+ end
94
+
95
+ unless hop_str.empty?
96
+ unresponsive.times { fields.push "q" }
97
+ unresponsive = 0
98
+
99
+ fields.push hop_str
100
+ end
101
+ else
102
+ unresponsive += 1
103
+ end
104
+ end
105
+
106
+ fields.join("\t")
107
+ end
108
+
109
+ end
110
+
111
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: rb-wartslib
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.9.10
7
+ date: 2007-11-29 00:00:00 -08:00
8
+ summary: Ruby extension for reading/writing warts files
9
+ require_paths:
10
+ - lib
11
+ email: youngh@rubyforge.org
12
+ homepage: http://rb-wartslib.rubyforge.org/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: wartslib
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Young Hyun
31
+ files:
32
+ - bin/analyze-order
33
+ - bin/scdump
34
+ - bin/wdump
35
+ - lib/wartslib
36
+ - lib/wartslib.rb
37
+ - lib/wartslib/wl-file.rb
38
+ - lib/wartslib/wl-trace.rb
39
+ - ext/extconf.rb
40
+ - ext/scaddr.c
41
+ - ext/scaddr.h
42
+ - ext/scext.c
43
+ - ext/scfile.c
44
+ - ext/scfile.h
45
+ - ext/sclist.c
46
+ - ext/sclist.h
47
+ - ext/sctrace.c
48
+ - ext/sctrace.h
49
+ - COPYING
50
+ - README
51
+ - CHANGES
52
+ test_files: []
53
+
54
+ rdoc_options: []
55
+
56
+ extra_rdoc_files:
57
+ - COPYING
58
+ - README
59
+ - CHANGES
60
+ executables: []
61
+
62
+ extensions:
63
+ - ext/extconf.rb
64
+ requirements: []
65
+
66
+ dependencies: []
67
+