net-proto 1.2.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9ad82469ee27db26ef64fc237b2f0997c128e491
4
- data.tar.gz: b75d18a5640061415124e0db9a4c9d984a09e1af
2
+ SHA256:
3
+ metadata.gz: b1bb0410a112bffe12fb31973dae5747d6b7fee011b0c6004bb3b70a113705d5
4
+ data.tar.gz: 1520a184788ead801920378b3900924d20f34181b5aa3ffb26cc1863b3cafe7d
5
5
  SHA512:
6
- metadata.gz: bc8b339c75aa05037c264351888309c7d65392f3db57cdaf89cab05ca46584a8747501e905b999e0fb0f2aa30b7a6f1fb12bbea84d0baaddf8c2995e694c58bd
7
- data.tar.gz: b056f5cb415e6cbf756c5e9e4e36f77f29bf66844e493f243ace79ee5f1ce662a35a9924963f62c30c1f386ae29aa58f78a99275fa5204a3739e1a25d2906a1e
6
+ metadata.gz: 0022bcec3b3fcd9e6070b04fe0a619bab1508b7a939865ffd26f068ac57ddbc69ff89ec35a1b040075ff4f88eac0d7aba69369244fea8426eea9240963e0aae0
7
+ data.tar.gz: e31b0e71126f44869040fb630968aaaea482a83aef4599f2389198f90ec26b57db0e2e82b9b526323f4135799f77e8d76054bf628e2860df7dacb471ac47a392
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -1,13 +1,33 @@
1
- == 1.2.0 - 3-Nov-2014
1
+ ## 1.4.1 - 18-Feb-2021
2
+ * Switch rdoc format to markdown where appropriate.
3
+
4
+ ## 1.4.0 - 17-Aug-2020
5
+ * Switched from test-unit to rspec.
6
+
7
+ ## 1.3.1 - 30-Jul-2020
8
+ * Add a LICENSE file as required by the Apache-2.0 license.
9
+
10
+ ## 1.3.0 - 10-Jan-2019
11
+ * Changed license to Apache-2.0.
12
+ * The VERSION constant is now frozen.
13
+ * Added metadata to the gemspec.
14
+ * Updated cert, should be good for about 10 years now.
15
+
16
+ ## 1.2.1 - 4-Jan-2016
17
+ * This gem is now signed.
18
+ * The gem related tasks in the Rakefile now assume Rubygems 2.x.
19
+ * Added a net-proto.rb file for convenience.
20
+
21
+ ## 1.2.0 - 3-Nov-2014
2
22
  * The getprotobynumber and getprotobyname methods on MS Windows now accept
3
23
  optional window and message arguments. If used, the method becomes
4
24
  asynchronous and yields a block instead.
5
25
 
6
- == 1.1.1 - 9-Oct-2014
26
+ ## 1.1.1 - 9-Oct-2014
7
27
  * Implemented getprotoent on Windows using pure Ruby.
8
28
  * Miscellaneous minor updates to the Rakefile, gemspec and docs.
9
29
 
10
- == 1.1.0 - 18-Jan-2012
30
+ ## 1.1.0 - 18-Jan-2012
11
31
  * Switched to FFI instead of C backend. Now works with JRuby, too.
12
32
  * Added the generic get_protocol instance method that accepts either a
13
33
  string or an integer and does the right thing. This method should be
@@ -16,19 +36,19 @@
16
36
  * Refactored the test suite to use features of test-unit 2.x.
17
37
  * Added a default rake task.
18
38
 
19
- == 1.0.6 - 22-Oct-2010
39
+ ## 1.0.6 - 22-Oct-2010
20
40
  * Refactored the test suite and removed one test that was implementation
21
41
  dependent and not useful.
22
42
  * Updates to the README and gemspec.
23
43
 
24
- == 1.0.5 - 12-Sep-2009
44
+ ## 1.0.5 - 12-Sep-2009
25
45
  * Changed license to Artistic 2.0.
26
46
  * Added a build_binary_gem task.
27
47
  * Cleaned up and refactored the gemspec a bit, including the addition of
28
48
  a license and an updated description.
29
49
  * Switched test-unit from a runtime dependency to a dev dependency.
30
50
 
31
- == 1.0.4 - 6-Jan-2008
51
+ ## 1.0.4 - 6-Jan-2008
32
52
  * The struct returned by Net::Proto.getprotoent is now frozen. This is
33
53
  strictly read-only data.
34
54
  * It is now explicitly illegal to call Net::Proto.new.
@@ -37,31 +57,31 @@
37
57
  * Renamed and refactored the test suite. This library now requires test-unit
38
58
  version 2.0.2 or later.
39
59
 
40
- == 1.0.3 - 13-Aug-2007
60
+ ## 1.0.3 - 13-Aug-2007
41
61
  * Fix for OS X (whining about malloced pointer).
42
62
  * Added a Rakefile along with tasks for installation and testing.
43
63
  * Major internal reorganization.
44
64
  * Fixed Proto::VERSION test.
45
65
 
46
- == 1.0.2 - 18-Nov-2006
66
+ ## 1.0.2 - 18-Nov-2006
47
67
  * Updated the README, gemspec and netproto.txt files.
48
68
  * No code changes.
49
69
 
50
- == 1.0.1 - 30-Jun-2006
70
+ ## 1.0.1 - 30-Jun-2006
51
71
  * Added rdoc to the source files.
52
72
  * Added a gemspec.
53
73
 
54
- == 1.0.0 - 14-Jul-2005
74
+ ## 1.0.0 - 14-Jul-2005
55
75
  * Moved project to RubyForge.
56
76
  * Minor directory layout change.
57
77
  * Minor changes to the extconf.rb file.
58
78
  * Officially bumped VERSION to 1.0.0.
59
79
 
60
- == 0.2.5 - 18-Apr-2005
80
+ ## 0.2.5 - 18-Apr-2005
61
81
  * The Unix versions now call setprotoent(0) and endprotoent() internally
62
82
  before each call.
63
83
 
64
- == 0.2.4 - 12-Apr-2005
84
+ ## 0.2.4 - 12-Apr-2005
65
85
  * Added internal taint checking for the Proto.getprotobyname method.
66
86
  * Removed the INSTALL file. Installation instructions are now in the README.
67
87
  * Moved the sample script into the 'examples' directory.
@@ -70,13 +90,13 @@
70
90
  * Removed the netproto.rd and netproto.html files. The netproto.txt file is
71
91
  now rdoc friendly.
72
92
 
73
- == 0.2.3 - 13-Sep-2004
93
+ ## 0.2.3 - 13-Sep-2004
74
94
  * Replaced all instances of the deprecated STR2CSTR() function with the
75
95
  StringValuePtr() function. That means that, as of this release, this
76
96
  package requires Ruby 1.8.0 or later.
77
97
  * Minor documentation corrections.
78
98
 
79
- == 0.2.2 - 10-Apr-2004
99
+ ## 0.2.2 - 10-Apr-2004
80
100
  * No longer returns an Array in block form. Only the non-block form returns
81
101
  an array. The block form returns nil.
82
102
  * Updated the documentation, warranty information included, license changed
@@ -85,7 +105,7 @@
85
105
  * Changed "tc_all.rb" to "tc_netproto.rb".
86
106
  * Changed "netproto.rd2" to "netproto.rd".
87
107
 
88
- == 0.2.1 - 29-Jul-2003
108
+ ## 0.2.1 - 29-Jul-2003
89
109
  * Code cleanup (-Wall warnings on Linux)
90
110
  * Removed VERSION() class method. Use the constant instead
91
111
  * The getprotoent() method now returns an array of structs in non-block form
@@ -95,7 +115,7 @@
95
115
  TestUnit installed, instead of dynamically generating one
96
116
  * Fixed up TestUnit test suite
97
117
 
98
- == 0.2.0 - 26-Feb-2003
118
+ ## 0.2.0 - 26-Feb-2003
99
119
  * Added MS Windows support (except 'getprotoent()' - see docs)
100
120
  * For protocols that aren't defined, nil is now returned instead
101
121
  of crashing (always a good thing)
@@ -110,7 +130,7 @@
110
130
  * Manifest now MANIFEST
111
131
  * Package name changed to lower case
112
132
 
113
- == 0.1.0 - 13-Aug-2002
133
+ ## 0.1.0 - 13-Aug-2002
114
134
  * Fixed bug with getprotoent_r function for Linux
115
135
  * Added a 'generic' source file that uses the non-reentrant functions for
116
136
  those platforms that are not specifically supported.
@@ -119,5 +139,5 @@
119
139
  * Added a changelog :)
120
140
  * Added a manifest
121
141
 
122
- == 0.0.1 - 12-Aug-2002
142
+ ## 0.0.1 - 12-Aug-2002
123
143
  * Initial release (though written earlier)
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -1,13 +1,16 @@
1
- * CHANGES
2
- * MANIFEST
3
- * README
1
+ * CHANGES.md
2
+ * LICENSE
3
+ * MANIFEST.md
4
+ * README.md
4
5
  * Rakefile
5
6
  * doc/netproto.txt
6
7
  * net-proto.gemspec
8
+ * certs/djberg96_pub.pem
9
+ * lib/net-proto.rb
7
10
  * lib/net/proto.rb
8
11
  * lib/net/proto/common.rb
9
12
  * lib/generic/net/proto.rb
10
13
  * lib/linux/net/proto.rb
11
14
  * lib/sunos/net/proto.rb
12
15
  * examples/example_net_proto.rb
13
- * test/test_net_proto.rb
16
+ * spec/net_proto_spec.rb
@@ -1,17 +1,18 @@
1
- == Description
1
+ ## Description
2
2
  The net-proto package provides a way to get protocol information.
3
3
 
4
- This is a wrapper for the getprotobyname(), getprotobynumber() and
5
- the getprotoent() functions.
4
+ This is a wrapper for the `getprotobyname`, `getprotobynumber` and
5
+ the `getprotoent` C functions.
6
6
 
7
- == Installation
8
- gem install net-proto
7
+ ## Installation
8
+ `gem install net-proto`
9
9
 
10
- == Prerequisites
11
- ffi 1.0.0 or later.
10
+ ## Prerequisites
11
+ * ffi 1.0.0 or later.
12
12
 
13
- == Synopsis
14
- require 'net/proto'
13
+ ## Synopsis
14
+ ```ruby
15
+ require 'net/proto' # or 'net-proto'
15
16
 
16
17
  # Using generic method
17
18
  Net::Proto.get_protocol(1) # => 'icmp'
@@ -25,13 +26,14 @@ Net::Proto.getprotobyname('tcp') # => 6
25
26
  Net::Proto.getprotoent do |ent|
26
27
  p ent
27
28
  end
29
+ ```
28
30
 
29
- == Why should I use this?
31
+ ## Why should I use this?
30
32
  Ruby has a predefined set of constants in socket.c in the general form of
31
33
  IPPROTO_XXX, Y. However, using constants in this fashion can be unreliable
32
34
  because it's easy to define your own protocols (I set 'echo' to 7, for
33
35
  example), or to modify/delete entries in /etc/protocols.
34
36
 
35
- == Further Documentation
36
- See the 'netproto.txt' file under the 'doc' directory for more details. There
37
+ ## Further Documentation
38
+ See the 'netproto.rdoc' file under the 'doc' directory for more details. There
37
39
  is also an example under the 'examples' directory.
data/Rakefile CHANGED
@@ -1,19 +1,17 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/clean'
4
+ require 'rspec/core/rake_task'
4
5
 
5
6
  CLEAN.include('**/*.gem', '**/*.rbx', '**/*.rbc')
6
7
 
7
8
  namespace 'gem' do
8
9
  desc 'Create the net-proto gem'
9
10
  task :create => :clean do
11
+ require 'rubygems/package'
10
12
  spec = eval(IO.read('net-proto.gemspec'))
11
- if Gem::VERSION.to_f < 2.0
12
- Gem::Builder.new(spec).build
13
- else
14
- require 'rubygems/package'
15
- Gem::Package.build(spec)
16
- end
13
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
14
+ Gem::Package.build(spec, true)
17
15
  end
18
16
 
19
17
  desc 'Install the net-proto gem'
@@ -28,9 +26,8 @@ task :example do
28
26
  ruby '-Ilib examples/example_net_proto.rb'
29
27
  end
30
28
 
31
- Rake::TestTask.new do |t|
32
- t.warning = true
33
- t.verbose = true
29
+ RSpec::Core::RakeTask.new(:spec) do |t|
30
+ t.pattern = ['spec/net_proto_spec.rb']
34
31
  end
35
32
 
36
- task :default => :test
33
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
7
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
8
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
9
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
10
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
11
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
12
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
13
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
14
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
15
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
26
+ -----END CERTIFICATE-----
@@ -59,7 +59,7 @@ Proto.getprotoent{ |struct| ... }
59
59
  at https://github.com/djberg96/net-proto.
60
60
 
61
61
  == Copyright
62
- (C) 2003-2014 Daniel J. Berger
62
+ (C) 2003-2020 Daniel J. Berger
63
63
  All rights reserved.
64
64
 
65
65
  == Warranty
@@ -68,7 +68,7 @@ Proto.getprotoent{ |struct| ... }
68
68
  warranties of merchantability and fitness for a particular purpose.
69
69
 
70
70
  == License
71
- Artistic 2.0
71
+ Apache-2.0
72
72
 
73
73
  == Author
74
74
  Daniel J. Berger
@@ -13,8 +13,6 @@ module Net
13
13
  ffi_convention :stdcall
14
14
  end
15
15
 
16
- private
17
-
18
16
  # These should exist on every platform.
19
17
  attach_function :getprotobyname_c, :getprotobyname, [:string], :pointer
20
18
  attach_function :getprotobynumber_c, :getprotobynumber, [:int], :pointer
@@ -35,8 +33,6 @@ module Net
35
33
  private_class_method :getprotobyname_c
36
34
  private_class_method :getprotobynumber_c
37
35
 
38
- public
39
-
40
36
  # If given a protocol string, returns the corresponding number. If
41
37
  # given a protocol number, returns the corresponding string.
42
38
  #
@@ -7,8 +7,6 @@ module Net
7
7
  class Proto
8
8
  ffi_lib FFI::Library::LIBC
9
9
 
10
- private
11
-
12
10
  attach_function :setprotoent, [:int], :void
13
11
  attach_function :endprotoent, [], :void
14
12
  attach_function :getprotobyname_r, [:string, :pointer, :pointer, :long, :pointer], :int
@@ -18,8 +16,6 @@ module Net
18
16
  private_class_method :setprotoent, :endprotoent, :getprotobyname_r
19
17
  private_class_method :getprotobynumber_r, :getprotoent_r
20
18
 
21
- public
22
-
23
19
  # If given a protocol string, returns the corresponding number. If
24
20
  # given a protocol number, returns the corresponding string.
25
21
  #
data/lib/net-proto.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative 'net/proto'
@@ -5,7 +5,7 @@ module Net
5
5
  extend FFI::Library
6
6
 
7
7
  # The version of the net-proto library
8
- VERSION = '1.2.0'
8
+ VERSION = '1.4.1'.freeze
9
9
 
10
10
  private_class_method :new
11
11
 
@@ -16,8 +16,6 @@ module Net
16
16
  private_class_method :setprotoent, :endprotoent, :getprotobyname_r
17
17
  private_class_method :getprotobynumber_r, :getprotoent_r
18
18
 
19
- public
20
-
21
19
  # If given a protocol string, returns the corresponding number. If
22
20
  # given a protocol number, returns the corresponding string.
23
21
  #
@@ -10,8 +10,6 @@ module Net
10
10
  ffi_lib 'ws2_32'
11
11
  ffi_convention :stdcall
12
12
 
13
- private
14
-
15
13
  # These should exist on every platform.
16
14
  attach_function :getprotobyname_c, :getprotobyname, [:string], :pointer
17
15
  attach_function :getprotobynumber_c, :getprotobynumber, [:int], :pointer
@@ -25,8 +23,6 @@ module Net
25
23
  private_class_method :WSAAsyncGetProtoByNumber
26
24
  private_class_method :WSAGetLastError
27
25
 
28
- public
29
-
30
26
  # If given a protocol string, returns the corresponding number. If
31
27
  # given a protocol number, returns the corresponding string.
32
28
  #
@@ -126,7 +122,7 @@ module Net
126
122
  endprotoent() if respond_to?(:endprotoent, true)
127
123
  end
128
124
 
129
- ptr.null? ? nil: struct[:p_name]
125
+ ptr.null? ? nil : struct[:p_name]
130
126
  end
131
127
  end
132
128
 
data/net-proto.gemspec CHANGED
@@ -1,23 +1,33 @@
1
1
  require 'rubygems'
2
2
 
3
- Gem::Specification.new do |gem|
4
- gem.name = 'net-proto'
5
- gem.version = '1.2.0'
6
- gem.author = 'Daniel J. Berger'
7
- gem.license = 'Artistic 2.0'
8
- gem.email = 'djberg96@gmail.com'
9
- gem.homepage = 'https://github.com/djberg96/net-proto'
10
- gem.summary = 'A Ruby interface for determining protocol information'
11
- gem.test_file = 'test/test_net_proto.rb'
12
- gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'net-proto'
5
+ spec.version = '1.4.1'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Apache-2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'https://github.com/djberg96/net-proto'
10
+ spec.summary = 'A Ruby interface for determining protocol information'
11
+ spec.test_file = 'spec/net_proto_spec.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') || f.include?('rubocop') }
13
+ spec.cert_chain = Dir['certs/*']
13
14
 
14
- gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/netproto.txt']
15
+ spec.extra_rdoc_files = ['doc/netproto.rdoc']
15
16
 
16
- gem.add_dependency('ffi', '>= 1.0.0')
17
- gem.add_development_dependency('test-unit', '>= 2.2.0')
18
- gem.add_development_dependency('rake')
17
+ spec.add_dependency('ffi', '~> 1.0')
18
+ spec.add_development_dependency('rspec', '~> 3.9')
19
+ spec.add_development_dependency('rake')
19
20
 
20
- gem.description = <<-EOF
21
+ spec.metadata = {
22
+ 'homepage_uri' => 'https://github.com/djberg96/net-proto',
23
+ 'bug_tracker_uri' => 'https://github.com/djberg96/net-proto/issues',
24
+ 'changelog_uri' => 'https://github.com/djberg96/net-proto/blob/ffi/CHANGES',
25
+ 'documentation_uri' => 'https://github.com/djberg96/net-proto/wiki',
26
+ 'source_code_uri' => 'https://github.com/djberg96/net-proto',
27
+ 'wiki_uri' => 'https://github.com/djberg96/net-proto/wiki'
28
+ }
29
+
30
+ spec.description = <<-EOF
21
31
  The net-proto library provides an interface for get protocol information
22
32
  by name or by number. It can also iterate over the list of protocol
23
33
  entries defined on your system.
@@ -0,0 +1,123 @@
1
+ ###########################################################################
2
+ # net_proto_spec.rb
3
+ #
4
+ # Test suite for net-proto on all platforms. This test suite should be run
5
+ # via the 'rake spec' task.
6
+ ###########################################################################
7
+ require 'net/proto'
8
+ require 'rspec'
9
+
10
+ RSpec.describe Net::Proto do
11
+ # These were the protocols listed in my own /etc/protocols file on Solaris 9
12
+ let(:protocols) do
13
+ %w[
14
+ ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
15
+ xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
16
+ mobile ospf pim ipcomp vrrp sctp hopopt ipv6
17
+ ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
18
+ ]
19
+ end
20
+
21
+ example "version number is set to expected value" do
22
+ expect(Net::Proto::VERSION).to eq('1.4.1')
23
+ expect(Net::Proto::VERSION).to be_frozen
24
+ end
25
+
26
+ example "get_protocol method basic functionality" do
27
+ expect(Net::Proto).to respond_to(:get_protocol)
28
+ end
29
+
30
+ example "get_protocol method accepts a string or a number" do
31
+ expect{ Net::Proto.get_protocol(1) }.not_to raise_error
32
+ expect{ Net::Proto.get_protocol('tcp') }.not_to raise_error
33
+ end
34
+
35
+ example "get_protocol returns nil if protocol not found" do
36
+ expect(Net::Proto.get_protocol(9999999)).to be_nil
37
+ end
38
+
39
+ example "get_protocol fails if an invalid type is passed" do
40
+ expect{ Net::Proto.get_protocol([]) }.to raise_error(TypeError)
41
+ end
42
+
43
+ example "getprotobynumber basic functionality" do
44
+ expect(Net::Proto).to respond_to(:getprotobynumber)
45
+ expect{ 0.upto(132){ |n| Net::Proto.getprotobynumber(n) } }.not_to raise_error
46
+ expect(Net::Proto.getprotobynumber(1)).to be_kind_of(String)
47
+ end
48
+
49
+ example "getprotobynumber returns the expected result" do
50
+ expect(Net::Proto.getprotobynumber(1)).to eq('icmp')
51
+ expect(Net::Proto.getprotobynumber(6)).to eq('tcp')
52
+ end
53
+
54
+ example "getprotobynumber returns nil if not found" do
55
+ expect(Net::Proto.getprotobynumber(9999999)).to eq(nil)
56
+ expect(Net::Proto.getprotobynumber(-1)).to eq(nil)
57
+ end
58
+
59
+ example "getprotobynumber raises a TypeError if a non-numeric arg is used" do
60
+ expect{ Net::Proto.getprotobynumber('foo') }.to raise_error(TypeError)
61
+ expect{ Net::Proto.getprotobynumber(nil) }.to raise_error(TypeError)
62
+ end
63
+
64
+ example "getprotobyname method basic functionality" do
65
+ expect(Net::Proto).to respond_to(:getprotobyname)
66
+ protocols.each{ |n| expect{ Net::Proto.getprotobyname(n) }.not_to raise_error }
67
+ end
68
+
69
+ example "getprotobyname returns the expected result" do
70
+ expect(Net::Proto.getprotobyname('icmp')).to eq(1)
71
+ expect(Net::Proto.getprotobyname('tcp')).to eq(6)
72
+ end
73
+
74
+ example "getprotobyname returns nil if the protocol is not found" do
75
+ expect(Net::Proto.getprotobyname('foo')).to be_nil
76
+ expect(Net::Proto.getprotobyname('tcpx')).to be_nil
77
+ expect(Net::Proto.getprotobyname('')).to be_nil
78
+ end
79
+
80
+ example "getprotobyname raises a TypeError if an invalid arg is passed" do
81
+ expect{ Net::Proto.getprotobyname(1) }.to raise_error(TypeError)
82
+ expect{ Net::Proto.getprotobyname(nil) }.to raise_error(TypeError)
83
+ end
84
+
85
+ example "getprotoent basic functionality" do
86
+ expect(Net::Proto).to respond_to(:getprotoent)
87
+ expect{ Net::Proto.getprotoent }.not_to raise_error
88
+ expect(Net::Proto.getprotoent).to be_kind_of(Array)
89
+ end
90
+
91
+ example "getprotoent method returns the expected results" do
92
+ expect(Net::Proto.getprotoent.first).to be_kind_of(Struct::ProtoStruct)
93
+ expect(Net::Proto.getprotoent{}).to be_nil
94
+ end
95
+
96
+ example "struct returned by getprotoent method contains the expected data" do
97
+ protoent = Net::Proto.getprotoent.first
98
+ expect( protoent.members).to eq([:name, :aliases, :proto])
99
+ expect( protoent.name).to be_kind_of(String)
100
+ expect( protoent.aliases).to be_kind_of(Array)
101
+ expect( protoent.proto).to be_kind_of(Integer)
102
+ end
103
+
104
+ example "all members of the aliases struct member are strings" do
105
+ protoent = Net::Proto.getprotoent.first
106
+ expect(protoent.aliases.all?{ |e| e.is_a?(String) }).to eq(true)
107
+ end
108
+
109
+ example "struct returned by getprotoent method is frozen" do
110
+ protoent = Net::Proto.getprotoent.first
111
+ expect(protoent.frozen?).to eq(true)
112
+ end
113
+
114
+ example "there is no constructor" do
115
+ expect{ Net::Proto.new }.to raise_error(NoMethodError)
116
+ end
117
+
118
+ example "ffi functions are private" do
119
+ methods = Net::Proto.methods(false)
120
+ expect(methods.include?(:setprotoent)).to eq(false)
121
+ expect(methods.include?(:endprotoent)).to eq(false)
122
+ end
123
+ end
metadata CHANGED
@@ -1,55 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-proto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
18
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
19
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
20
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
21
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
22
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
23
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
24
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
25
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
27
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
28
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
29
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
30
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
31
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
32
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
33
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
34
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
35
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
+ -----END CERTIFICATE-----
38
+ date:
12
39
  dependencies:
13
40
  - !ruby/object:Gem::Dependency
14
41
  name: ffi
15
42
  requirement: !ruby/object:Gem::Requirement
16
43
  requirements:
17
- - - '>='
44
+ - - "~>"
18
45
  - !ruby/object:Gem::Version
19
- version: 1.0.0
46
+ version: '1.0'
20
47
  type: :runtime
21
48
  prerelease: false
22
49
  version_requirements: !ruby/object:Gem::Requirement
23
50
  requirements:
24
- - - '>='
51
+ - - "~>"
25
52
  - !ruby/object:Gem::Version
26
- version: 1.0.0
53
+ version: '1.0'
27
54
  - !ruby/object:Gem::Dependency
28
- name: test-unit
55
+ name: rspec
29
56
  requirement: !ruby/object:Gem::Requirement
30
57
  requirements:
31
- - - '>='
58
+ - - "~>"
32
59
  - !ruby/object:Gem::Version
33
- version: 2.2.0
60
+ version: '3.9'
34
61
  type: :development
35
62
  prerelease: false
36
63
  version_requirements: !ruby/object:Gem::Requirement
37
64
  requirements:
38
- - - '>='
65
+ - - "~>"
39
66
  - !ruby/object:Gem::Version
40
- version: 2.2.0
67
+ version: '3.9'
41
68
  - !ruby/object:Gem::Dependency
42
69
  name: rake
43
70
  requirement: !ruby/object:Gem::Requirement
44
71
  requirements:
45
- - - '>='
72
+ - - ">="
46
73
  - !ruby/object:Gem::Version
47
74
  version: '0'
48
75
  type: :development
49
76
  prerelease: false
50
77
  version_requirements: !ruby/object:Gem::Requirement
51
78
  requirements:
52
- - - '>='
79
+ - - ">="
53
80
  - !ruby/object:Gem::Version
54
81
  version: '0'
55
82
  description: |2
@@ -60,48 +87,68 @@ email: djberg96@gmail.com
60
87
  executables: []
61
88
  extensions: []
62
89
  extra_rdoc_files:
63
- - CHANGES
64
- - README
65
- - MANIFEST
66
- - doc/netproto.txt
90
+ - doc/netproto.rdoc
67
91
  files:
68
- - CHANGES
69
- - MANIFEST
70
- - README
92
+ - LICENSE
93
+ - spec
94
+ - spec/net_proto_spec.rb
95
+ - README.md
71
96
  - Rakefile
72
- - doc/netproto.txt
97
+ - MANIFEST.md
98
+ - certs
99
+ - certs/djberg96_pub.pem
100
+ - examples
73
101
  - examples/example_net_proto.rb
74
- - lib/generic/net/proto.rb
75
- - lib/linux/net/proto.rb
102
+ - lib
103
+ - lib/net
76
104
  - lib/net/proto.rb
105
+ - lib/net/proto
77
106
  - lib/net/proto/common.rb
107
+ - lib/sunos
108
+ - lib/sunos/net
78
109
  - lib/sunos/net/proto.rb
110
+ - lib/net-proto.rb
111
+ - lib/linux
112
+ - lib/linux/net
113
+ - lib/linux/net/proto.rb
114
+ - lib/generic
115
+ - lib/generic/net
116
+ - lib/generic/net/proto.rb
117
+ - lib/windows
118
+ - lib/windows/net
79
119
  - lib/windows/net/proto.rb
120
+ - CHANGES.md
121
+ - doc
122
+ - doc/netproto.rdoc
80
123
  - net-proto.gemspec
81
- - test/test_net_proto.rb
82
124
  homepage: https://github.com/djberg96/net-proto
83
125
  licenses:
84
- - Artistic 2.0
85
- metadata: {}
86
- post_install_message:
126
+ - Apache-2.0
127
+ metadata:
128
+ homepage_uri: https://github.com/djberg96/net-proto
129
+ bug_tracker_uri: https://github.com/djberg96/net-proto/issues
130
+ changelog_uri: https://github.com/djberg96/net-proto/blob/ffi/CHANGES
131
+ documentation_uri: https://github.com/djberg96/net-proto/wiki
132
+ source_code_uri: https://github.com/djberg96/net-proto
133
+ wiki_uri: https://github.com/djberg96/net-proto/wiki
134
+ post_install_message:
87
135
  rdoc_options: []
88
136
  require_paths:
89
137
  - lib
90
138
  required_ruby_version: !ruby/object:Gem::Requirement
91
139
  requirements:
92
- - - '>='
140
+ - - ">="
93
141
  - !ruby/object:Gem::Version
94
142
  version: '0'
95
143
  required_rubygems_version: !ruby/object:Gem::Requirement
96
144
  requirements:
97
- - - '>='
145
+ - - ">="
98
146
  - !ruby/object:Gem::Version
99
147
  version: '0'
100
148
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.4.2
103
- signing_key:
149
+ rubygems_version: 3.0.3
150
+ signing_key:
104
151
  specification_version: 4
105
152
  summary: A Ruby interface for determining protocol information
106
153
  test_files:
107
- - test/test_net_proto.rb
154
+ - spec/net_proto_spec.rb
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ��"=W�}X� �ӋĶ���c��̚���Ρ~�G�����[UE��ׅ�"E'S�@Ʃ��W<��C�.�)���`�"A��ȉ�T��g�͙��x��獟�����w=�� ��W��V��'����r�L2���?���@ �<���bd�V�0�3l�7�s�
@@ -1,135 +0,0 @@
1
- ###########################################################################
2
- # test_net_netproto.rb
3
- #
4
- # Test suite for net-proto - all platforms. This test suite should be run
5
- # via the 'rake test' task.
6
- ###########################################################################
7
- require 'net/proto'
8
- require 'test-unit'
9
-
10
- class TC_Net_Proto < Test::Unit::TestCase
11
-
12
- # These were the protocols listed in my own /etc/protocols file on Solaris 9
13
- def self.startup
14
- @@protocols = %w/
15
- ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
16
- xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
17
- mobile ospf pim ipcomp vrrp sctp hopopt ipv6
18
- ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
19
- /
20
- end
21
-
22
- def setup
23
- @protoent = nil
24
- end
25
-
26
- test "version number is set to expected value" do
27
- assert_equal('1.2.0', Net::Proto::VERSION)
28
- end
29
-
30
- test "get_protocol method basic functionality" do
31
- assert_respond_to(Net::Proto, :get_protocol)
32
- end
33
-
34
- test "get_protocol method accepts a string or a number" do
35
- assert_nothing_raised{ Net::Proto.get_protocol(1) }
36
- assert_nothing_raised{ Net::Proto.get_protocol('tcp') }
37
- end
38
-
39
- test "get_protocol returns nil if protocol not found" do
40
- assert_nil(Net::Proto.get_protocol(9999999))
41
- end
42
-
43
- test "get_protocol fails if an invalid type is passed" do
44
- assert_raise(TypeError){ Net::Proto.get_protocol([]) }
45
- end
46
-
47
- test "getprotobynumber basic functionality" do
48
- assert_respond_to(Net::Proto, :getprotobynumber)
49
- assert_nothing_raised{ 0.upto(132){ |n| Net::Proto.getprotobynumber(n) } }
50
- assert_kind_of(String, Net::Proto.getprotobynumber(1))
51
- end
52
-
53
- test "getprotobynumber returns the expected result" do
54
- assert_equal('icmp', Net::Proto.getprotobynumber(1))
55
- assert_equal('tcp', Net::Proto.getprotobynumber(6))
56
- end
57
-
58
- test "getprotobynumber returns nil if not found" do
59
- assert_equal(nil, Net::Proto.getprotobynumber(9999999))
60
- assert_equal(nil, Net::Proto.getprotobynumber(-1))
61
- end
62
-
63
- test "getprotobynumber raises a TypeError if a non-numeric arg is used" do
64
- assert_raise(TypeError){ Net::Proto.getprotobynumber('foo') }
65
- assert_raise(TypeError){ Net::Proto.getprotobynumber(nil) }
66
- end
67
-
68
- test "getprotobyname method basic functionality" do
69
- assert_respond_to(Net::Proto, :getprotobyname)
70
- @@protocols.each{ |n| assert_nothing_raised{ Net::Proto.getprotobyname(n) } }
71
- end
72
-
73
- test "getprotobyname returns the expected result" do
74
- assert_equal(1, Net::Proto.getprotobyname('icmp'))
75
- assert_equal(6, Net::Proto.getprotobyname('tcp'))
76
- end
77
-
78
- test "getprotobyname returns nil if the protocol is not found" do
79
- assert_nil(Net::Proto.getprotobyname('foo'))
80
- assert_nil(Net::Proto.getprotobyname('tcpx'))
81
- assert_nil(Net::Proto.getprotobyname(''))
82
- end
83
-
84
- test "getprotobyname raises a TypeError if an invalid arg is passed" do
85
- assert_raises(TypeError){ Net::Proto.getprotobyname(1) }
86
- assert_raises(TypeError){ Net::Proto.getprotobyname(nil) }
87
- end
88
-
89
- test "getprotoent basic functionality" do
90
- assert_respond_to(Net::Proto, :getprotoent)
91
- assert_nothing_raised{ Net::Proto.getprotoent }
92
- assert_kind_of(Array, Net::Proto.getprotoent)
93
- end
94
-
95
- test "getprotoent method returns the expected results" do
96
- assert_kind_of(Struct::ProtoStruct, Net::Proto.getprotoent.first)
97
- assert_nil(Net::Proto.getprotoent{})
98
- end
99
-
100
- test "struct returned by getprotoent method contains the expected data" do
101
- @protoent = Net::Proto.getprotoent.first
102
- assert_equal([:name, :aliases, :proto], @protoent.members)
103
- assert_kind_of(String, @protoent.name)
104
- assert_kind_of(Array, @protoent.aliases)
105
- assert_kind_of(Integer, @protoent.proto)
106
- end
107
-
108
- test "all members of the aliases struct member are strings" do
109
- @protoent = Net::Proto.getprotoent.first
110
- assert_true(@protoent.aliases.all?{ |e| e.is_a?(String) })
111
- end
112
-
113
- test "struct returned by getprotoent method is frozen" do
114
- @protoent = Net::Proto.getprotoent.first
115
- assert_true(@protoent.frozen?)
116
- end
117
-
118
- test "there is no constructor" do
119
- assert_raise(NoMethodError){ Net::Proto.new }
120
- end
121
-
122
- test "ffi functions are private" do
123
- methods = Net::Proto.methods(false).map{ |m| m.to_sym }
124
- assert_false(methods.include?(:setprotoent))
125
- assert_false(methods.include?(:endprotoent))
126
- end
127
-
128
- def teardown
129
- @protoent = nil
130
- end
131
-
132
- def self.shutdown
133
- @@protocols = nil
134
- end
135
- end