sctp-socket 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +6 -1
- data/README.md +1 -1
- data/ext/sctp/socket.c +67 -16
- data/sctp-socket.gemspec +2 -2
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac0fa4ee8107cb8b16e87b7313a8a14985ef78b01720fb1957240273e186536
|
4
|
+
data.tar.gz: 926f171e90bcbdad7b1923490cf3cebe81448ef3610c30d77dacb46060f73f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57506b9decdc8652e085cc2bdb5b41167e9bb64b8ae4966856a44b208c83e2e2a0fadce33e6711223d3e2aeebabc70feef5ec85b2a66c906feb642323b646736
|
7
|
+
data.tar.gz: 9d37cba691620fd8cc047da402a867c8ec60767fe5e05940a1a06d9ea1d2ac98e4dc9e52f2fb77c12c0485ac46f42aafcd0b8551147e3259850928b9fb80208d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
-
##
|
1
|
+
## 29-Nov-2020
|
2
|
+
* Fixed the homepage link in the gemspec metadata. Thanks go to Nick LaMuro for the patch.
|
3
|
+
* The getlocalnames and getpeernames now return an array of addresses.
|
4
|
+
* Added a shutdown method.
|
5
|
+
* Added more documentation.
|
2
6
|
|
7
|
+
## 24-Nov-2020
|
3
8
|
* Initial release.
|
data/README.md
CHANGED
data/ext/sctp/socket.c
CHANGED
@@ -215,16 +215,20 @@ static VALUE rsctp_close(VALUE self){
|
|
215
215
|
return self;
|
216
216
|
}
|
217
217
|
|
218
|
+
/*
|
219
|
+
* Return an array of all addresses of a peer.
|
220
|
+
*/
|
218
221
|
static VALUE rsctp_getpeernames(VALUE self){
|
219
|
-
VALUE v_assoc_id = rb_iv_get(self, "@assocation_id");
|
220
222
|
sctp_assoc_t assoc_id;
|
221
223
|
struct sockaddr* addrs;
|
222
224
|
int i, sock_fd, num_addrs;
|
225
|
+
char str[16];
|
226
|
+
VALUE v_array = rb_ary_new();
|
223
227
|
|
224
228
|
bzero(&addrs, sizeof(addrs));
|
225
229
|
|
226
230
|
sock_fd = NUM2INT(rb_iv_get(self, "@sock_fd"));
|
227
|
-
assoc_id = NUM2INT(
|
231
|
+
assoc_id = NUM2INT(rb_iv_get(self, "@association_id"));
|
228
232
|
|
229
233
|
num_addrs = sctp_getpaddrs(sock_fd, assoc_id, &addrs);
|
230
234
|
|
@@ -234,23 +238,36 @@ static VALUE rsctp_getpeernames(VALUE self){
|
|
234
238
|
}
|
235
239
|
|
236
240
|
for(i = 0; i < num_addrs; i++){
|
237
|
-
|
241
|
+
inet_ntop(AF_INET, &(((struct sockaddr_in *)&addrs[i])->sin_addr), str, sizeof(str));
|
242
|
+
rb_ary_push(v_array, rb_str_new2(str));
|
243
|
+
bzero(&str, sizeof(str));
|
238
244
|
}
|
239
245
|
|
240
246
|
sctp_freepaddrs(addrs);
|
241
247
|
|
242
|
-
return
|
248
|
+
return v_array;
|
243
249
|
}
|
244
250
|
|
251
|
+
/*
|
252
|
+
* Return an array of local addresses that are part of the association.
|
253
|
+
*
|
254
|
+
* Example:
|
255
|
+
*
|
256
|
+
* socket = SCTP::Socket.new
|
257
|
+
* socket.bind(:addresses => ['10.0.4.5', '10.0.5.5'])
|
258
|
+
* socket.getlocalnames # => ['10.0.4.5', '10.0.5.5'])
|
259
|
+
*/
|
245
260
|
static VALUE rsctp_getlocalnames(VALUE self){
|
246
261
|
sctp_assoc_t assoc_id;
|
247
262
|
struct sockaddr* addrs;
|
248
263
|
int i, sock_fd, num_addrs;
|
264
|
+
char str[16];
|
265
|
+
VALUE v_array = rb_ary_new();
|
249
266
|
|
250
267
|
bzero(&addrs, sizeof(addrs));
|
251
268
|
|
252
269
|
sock_fd = NUM2INT(rb_iv_get(self, "@sock_fd"));
|
253
|
-
assoc_id = NUM2INT(rb_iv_get(self, "@
|
270
|
+
assoc_id = NUM2INT(rb_iv_get(self, "@association_id"));
|
254
271
|
|
255
272
|
num_addrs = sctp_getladdrs(sock_fd, assoc_id, &addrs);
|
256
273
|
|
@@ -260,12 +277,14 @@ static VALUE rsctp_getlocalnames(VALUE self){
|
|
260
277
|
}
|
261
278
|
|
262
279
|
for(i = 0; i < num_addrs; i++){
|
263
|
-
|
280
|
+
inet_ntop(AF_INET, &(((struct sockaddr_in *)&addrs[i])->sin_addr), str, sizeof(str));
|
281
|
+
rb_ary_push(v_array, rb_str_new2(str));
|
282
|
+
bzero(&str, sizeof(str));
|
264
283
|
}
|
265
284
|
|
266
285
|
sctp_freeladdrs(addrs);
|
267
286
|
|
268
|
-
return
|
287
|
+
return v_array;
|
269
288
|
}
|
270
289
|
|
271
290
|
/*
|
@@ -474,12 +493,21 @@ static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
|
|
474
493
|
}
|
475
494
|
|
476
495
|
/*
|
477
|
-
*
|
478
|
-
*
|
479
|
-
*
|
480
|
-
*
|
481
|
-
*
|
482
|
-
*
|
496
|
+
* Set the initial parameters used by the socket when sending out the INIT message.
|
497
|
+
*
|
498
|
+
* Example:
|
499
|
+
*
|
500
|
+
* socket = SCTP::Socket.new
|
501
|
+
* socket.set_initmsg(:output_streams => 5, :input_streams => 5, :max_attempts => 4, :timeout => 30)
|
502
|
+
*
|
503
|
+
* The following parameters can be configured:
|
504
|
+
*
|
505
|
+
* :output_streams - The number of outbound SCTP streams an application would like to request.
|
506
|
+
* :input_streams - The maximum number of inbound streams an application is prepared to allow.
|
507
|
+
* :max_attempts - How many times the the SCTP stack should send the initial INIT message before it's considered unreachable.
|
508
|
+
* :timeout - The maximum RTO value for the INIT timer.
|
509
|
+
*
|
510
|
+
* By default these values are set to zero (i.e. ignored).
|
483
511
|
*/
|
484
512
|
static VALUE rsctp_set_initmsg(VALUE self, VALUE v_options){
|
485
513
|
int sock_fd;
|
@@ -645,13 +673,35 @@ static VALUE rsctp_peeloff(VALUE self, VALUE v_assoc_id){
|
|
645
673
|
return self;
|
646
674
|
}
|
647
675
|
|
676
|
+
static VALUE rsctp_shutdown(int argc, VALUE* argv, VALUE self){
|
677
|
+
int how, sock_fd;
|
678
|
+
VALUE v_how;
|
679
|
+
|
680
|
+
sock_fd = NUM2INT(rb_iv_get(self, "@sock_fd"));
|
681
|
+
|
682
|
+
rb_scan_args(argc, argv, "01", &v_how);
|
683
|
+
|
684
|
+
if(NIL_P(v_how)){
|
685
|
+
how = SHUT_RDWR;
|
686
|
+
}
|
687
|
+
else{
|
688
|
+
Check_Type(v_how, T_FIXNUM);
|
689
|
+
how = NUM2INT(v_how);
|
690
|
+
}
|
691
|
+
|
692
|
+
if(shutdown(sock_fd, how) < 0)
|
693
|
+
rb_raise(rb_eSystemCallError, "shutdown: %s", strerror(errno));
|
694
|
+
|
695
|
+
return self;
|
696
|
+
}
|
697
|
+
|
648
698
|
void Init_socket(){
|
649
699
|
mSCTP = rb_define_module("SCTP");
|
650
700
|
cSocket = rb_define_class_under(mSCTP, "Socket", rb_cObject);
|
651
701
|
|
652
702
|
v_sndrcv_struct = rb_struct_define(
|
653
703
|
"SndRecvInfo", "message", "stream", "flags",
|
654
|
-
"ppid", "context", "ttl", "
|
704
|
+
"ppid", "context", "ttl", "association_id", NULL
|
655
705
|
);
|
656
706
|
|
657
707
|
rb_define_method(cSocket, "initialize", rsctp_init, -1);
|
@@ -666,6 +716,7 @@ void Init_socket(){
|
|
666
716
|
rb_define_method(cSocket, "recvmsg", rsctp_recvmsg, -1);
|
667
717
|
rb_define_method(cSocket, "sendmsg", rsctp_sendmsg, 1);
|
668
718
|
rb_define_method(cSocket, "set_initmsg", rsctp_set_initmsg, 1);
|
719
|
+
rb_define_method(cSocket, "shutdown", rsctp_shutdown, -1);
|
669
720
|
rb_define_method(cSocket, "subscribe", rsctp_subscribe, 1);
|
670
721
|
|
671
722
|
rb_define_attr(cSocket, "domain", 1, 1);
|
@@ -674,6 +725,6 @@ void Init_socket(){
|
|
674
725
|
rb_define_attr(cSocket, "association_id", 1, 1);
|
675
726
|
rb_define_attr(cSocket, "port", 1, 1);
|
676
727
|
|
677
|
-
/* 0.0.
|
678
|
-
rb_define_const(cSocket, "VERSION", rb_str_new2("0.0.
|
728
|
+
/* 0.0.2: The version of this library */
|
729
|
+
rb_define_const(cSocket, "VERSION", rb_str_new2("0.0.2"));
|
679
730
|
}
|
data/sctp-socket.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'sctp-socket'
|
3
|
-
spec.version = '0.0.
|
3
|
+
spec.version = '0.0.2'
|
4
4
|
spec.author = 'Daniel Berger'
|
5
5
|
spec.email = 'djberg96@gmail.com'
|
6
6
|
spec.summary = 'Ruby bindings for SCTP sockets'
|
7
7
|
spec.description = 'Ruby bindings for SCTP sockets'
|
8
|
-
spec.homepage = 'https://github.com/djberg96/sctp-
|
8
|
+
spec.homepage = 'https://github.com/djberg96/sctp-socket'
|
9
9
|
spec.license = 'Apache-2.0'
|
10
10
|
spec.cert_chain = ['certs/djberg96_pub.pem']
|
11
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sctp-socket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Berger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-11-
|
38
|
+
date: 2020-11-29 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: bundler
|
@@ -116,7 +116,7 @@ files:
|
|
116
116
|
- ext/sctp/socket/client.c
|
117
117
|
- ext/sctp/socket/server.c
|
118
118
|
- sctp-socket.gemspec
|
119
|
-
homepage: https://github.com/djberg96/sctp-
|
119
|
+
homepage: https://github.com/djberg96/sctp-socket
|
120
120
|
licenses:
|
121
121
|
- Apache-2.0
|
122
122
|
metadata: {}
|
metadata.gz.sig
CHANGED
Binary file
|