sctp-socket 0.0.7 → 0.1.0

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
2
  SHA256:
3
- metadata.gz: 0475ccb484ff3e6e758c037edf11b16fdb833e49aee961a98532dfb67c84f799
4
- data.tar.gz: 70f7add0defeeb84a1ab6bb38ed3aeabb5f643bb05dea06a00a11c1934f588ed
3
+ metadata.gz: a483264dd5712655f641ade00e03177756f25340c2fd398bed3ad453bc6a9cdb
4
+ data.tar.gz: 719857e2ce3a5db341aa317f23ec0bf2fa674dd9b427b502f99e3515cb786dac
5
5
  SHA512:
6
- metadata.gz: e5e40484afdf170570c38ab9331c99ae4a6f42ba217d97e91ecd5bfbf9296c2ef95f219498fba13b524ad08a1f00271de8be6f358f2982a4c5e45fdc190f0951
7
- data.tar.gz: f9b9dac418aeae1c79916e732d7310049812c2456c0f4f1c578641f145c2c72b73fbceb655954ad99b03c3c69a890cab9a7455930199902a40aed9de239754a8
6
+ metadata.gz: 3dd98e9076f37396a55339fa20f1097ab5c582a418d885d8599b320b5cf722acb3c296b8afb798faadbee67519ee9368e87596c60d8658ef35a23a01d76c0d82
7
+ data.tar.gz: 4c7adf403e6075eb53129e9f4b92a97e3887518afa15458bf8b74fa7765478c54001d5f5f6cd997c2a4e44e1cba8783ee329ff9c3125f62fb9ae87e53c7e06b7
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.1.0 - 31-May-2024
2
+ * Added support for sender dry events.
3
+ * Added the get_peer_address_params method.
4
+ * Comments were added to methods that were missing them.
5
+ * Remove version locking for dev dependencies, doesn't matter to me.
6
+ * Bumped version to 0.1.0, I guess I'll declare it stable.
7
+
1
8
  ## 0.0.7 - 28-May-2024
2
9
  * Added the recvv method.
3
10
  * The getlocalnames and getpeernames methods now accept optional fileno and
data/ext/sctp/socket.c CHANGED
@@ -23,6 +23,8 @@ VALUE v_sctp_associnfo_struct;
23
23
  VALUE v_sctp_default_send_params_struct;
24
24
  VALUE v_sctp_event_subscribe_struct;
25
25
  VALUE v_sctp_receive_info_struct;
26
+ VALUE v_sctp_peer_addr_params_struct;
27
+ VALUE v_sender_dry_event_struct;
26
28
 
27
29
  #if !defined(IOV_MAX)
28
30
  #if defined(_SC_IOV_MAX)
@@ -180,6 +182,7 @@ static VALUE rsctp_bindx(int argc, VALUE* argv, VALUE self){
180
182
  if(port == 0){
181
183
  struct sockaddr_in sin;
182
184
  socklen_t len = sizeof(sin);
185
+ bzero(&sin, len);
183
186
 
184
187
  if(getsockname(fileno, (struct sockaddr *)&sin, &len) == -1)
185
188
  rb_raise(rb_eSystemCallError, "getsockname: %s", strerror(errno));
@@ -913,6 +916,7 @@ static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
913
916
 
914
917
  v_notification = rb_struct_new(v_remote_error_struct,
915
918
  UINT2NUM(snp->sn_remote_error.sre_type),
919
+ UINT2NUM(snp->sn_remote_error.sre_flags),
916
920
  UINT2NUM(snp->sn_remote_error.sre_length),
917
921
  UINT2NUM(snp->sn_remote_error.sre_error),
918
922
  UINT2NUM(snp->sn_remote_error.sre_assoc_id),
@@ -994,6 +998,14 @@ static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
994
998
  UINT2NUM(snp->sn_authkey_event.auth_assoc_id)
995
999
  );
996
1000
  break;
1001
+ case SCTP_SENDER_DRY_EVENT:
1002
+ v_notification = rb_struct_new(v_sender_dry_event_struct,
1003
+ UINT2NUM(snp->sn_sender_dry_event.sender_dry_type),
1004
+ UINT2NUM(snp->sn_sender_dry_event.sender_dry_flags),
1005
+ UINT2NUM(snp->sn_sender_dry_event.sender_dry_length),
1006
+ UINT2NUM(snp->sn_sender_dry_event.sender_dry_assoc_id)
1007
+ );
1008
+ break;
997
1009
  }
998
1010
  }
999
1011
 
@@ -1025,10 +1037,10 @@ static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
1025
1037
  *
1026
1038
  * The following parameters can be configured:
1027
1039
  *
1028
- * :output_streams - The number of outbound SCTP streams an application would like to request.
1029
- * :input_streams - The maximum number of inbound streams an application is prepared to allow.
1030
- * :max_attempts - How many times the the SCTP stack should send the initial INIT message before it's considered unreachable.
1031
- * :timeout - The maximum RTO value for the INIT timer.
1040
+ * :output_streams - The number of outbound SCTP streams an application would like to request.
1041
+ * :input_streams - The maximum number of inbound streams an application is prepared to allow.
1042
+ * :max_attempts - How many times the the SCTP stack should send the initial INIT message before it's considered unreachable.
1043
+ * :timeout - The maximum RTO value for the INIT timer.
1032
1044
  *
1033
1045
  * By default these values are set to zero (i.e. ignored).
1034
1046
  */
@@ -1089,11 +1101,8 @@ static VALUE rsctp_set_initmsg(VALUE self, VALUE v_options){
1089
1101
  * :adaptation
1090
1102
  * :authentication
1091
1103
  * :partial_delivery
1092
- *
1093
- * Not yet supported:
1094
- *
1095
1104
  * :sender_dry
1096
- * :peer_error
1105
+ * :peer_error (aka remote error)
1097
1106
  *
1098
1107
  * Example:
1099
1108
  *
@@ -1206,7 +1215,7 @@ static VALUE rsctp_listen(int argc, VALUE* argv, VALUE self){
1206
1215
  * while true
1207
1216
  * info = socket.recvmsg
1208
1217
  * assoc_fileno = socket.peeloff(info.association_id)
1209
- * # ... Do something with this new
1218
+ * # ... Do something with this new fileno
1210
1219
  * end
1211
1220
  */
1212
1221
  static VALUE rsctp_peeloff(VALUE self, VALUE v_assoc_id){
@@ -1224,6 +1233,21 @@ static VALUE rsctp_peeloff(VALUE self, VALUE v_assoc_id){
1224
1233
  return INT2NUM(assoc_fileno);
1225
1234
  }
1226
1235
 
1236
+ /*
1237
+ * Returns the default set of parameters that a call to the sendto function
1238
+ * uses on this association. This is a struct that contains the following
1239
+ * members:
1240
+ *
1241
+ * * stream
1242
+ * * ssn
1243
+ * * flags
1244
+ * * ppid
1245
+ * * context
1246
+ * * ttl
1247
+ * * tsn
1248
+ * * cumtsn
1249
+ * * association_id
1250
+ */
1227
1251
  static VALUE rsctp_get_default_send_params(VALUE self){
1228
1252
  int fileno;
1229
1253
  socklen_t size;
@@ -1253,6 +1277,19 @@ static VALUE rsctp_get_default_send_params(VALUE self){
1253
1277
  );
1254
1278
  }
1255
1279
 
1280
+ /*
1281
+ * Returns the association specific parameters. This is a struct
1282
+ * that contains the following members:
1283
+ *
1284
+ * * association_id
1285
+ * * max_retransmission_count
1286
+ * * number_peer_destinations
1287
+ * * peer_receive_window
1288
+ * * local_receive_window
1289
+ * * cookie_life
1290
+ *
1291
+ * All values that refer to time values are measured in milliseconds.
1292
+ */
1256
1293
  static VALUE rsctp_get_association_info(VALUE self){
1257
1294
  int fileno;
1258
1295
  socklen_t size;
@@ -1279,6 +1316,18 @@ static VALUE rsctp_get_association_info(VALUE self){
1279
1316
  );
1280
1317
  }
1281
1318
 
1319
+ /*
1320
+ * Shuts down socket send and receive operations.
1321
+ *
1322
+ * Optionally accepts an argument that specifieds the type of shutdown.
1323
+ * This can be one of the following values:
1324
+ *
1325
+ * * SHUT_RD - Disables further receive operations.
1326
+ * * SHUT_WR - Disables further send operations.
1327
+ * * SHUT_RDWR - Disables further send and receive operations.
1328
+ *
1329
+ * The default is SHUT_RDWR.
1330
+ */
1282
1331
  static VALUE rsctp_shutdown(int argc, VALUE* argv, VALUE self){
1283
1332
  int how, fileno;
1284
1333
  VALUE v_how;
@@ -1301,6 +1350,16 @@ static VALUE rsctp_shutdown(int argc, VALUE* argv, VALUE self){
1301
1350
  return self;
1302
1351
  }
1303
1352
 
1353
+ /*
1354
+ * Returns the protocol parameters that are used to initialize and bind the
1355
+ * retransmission timeout (RTO) tunable. This is a struct with the following
1356
+ * members:
1357
+ *
1358
+ * * association_id
1359
+ * * initial
1360
+ * * max
1361
+ * * min
1362
+ */
1304
1363
  static VALUE rsctp_get_retransmission_info(VALUE self){
1305
1364
  int fileno;
1306
1365
  socklen_t size;
@@ -1389,6 +1448,26 @@ static VALUE rsctp_get_status(VALUE self){
1389
1448
  );
1390
1449
  }
1391
1450
 
1451
+ /*
1452
+ * Returns a struct of events detailing which events have been
1453
+ * subscribed to by the socket. The struct contains the following
1454
+ * members:
1455
+ *
1456
+ * * data_io
1457
+ * * association
1458
+ * * address
1459
+ * * send_failure
1460
+ * * peer_error
1461
+ * * shutdown
1462
+ * * partial_delivery
1463
+ * * adaptation_layer
1464
+ * * authentication
1465
+ * * sender_dry
1466
+ * * stream_reset
1467
+ * * assoc_reset
1468
+ * * stream_change
1469
+ * * send_failure_event
1470
+ */
1392
1471
  static VALUE rsctp_get_subscriptions(VALUE self){
1393
1472
  int fileno;
1394
1473
  socklen_t size;
@@ -1422,6 +1501,34 @@ static VALUE rsctp_get_subscriptions(VALUE self){
1422
1501
  );
1423
1502
  }
1424
1503
 
1504
+ static VALUE rsctp_get_peer_address_params(VALUE self){
1505
+ int fileno;
1506
+ char str[16];
1507
+ socklen_t size;
1508
+ sctp_assoc_t assoc_id;
1509
+ struct sctp_paddrparams paddr;
1510
+
1511
+ bzero(&paddr, sizeof(paddr));
1512
+ bzero(&str, sizeof(str));
1513
+
1514
+ fileno = NUM2INT(rb_iv_get(self, "@fileno"));
1515
+ assoc_id = NUM2INT(rb_iv_get(self, "@association_id"));
1516
+ size = sizeof(struct sctp_paddrparams);
1517
+
1518
+ if(sctp_opt_info(fileno, assoc_id, SCTP_PEER_ADDR_PARAMS, (void*)&paddr, &size) < 0)
1519
+ rb_raise(rb_eSystemCallError, "sctp_opt_info: %s", strerror(errno));
1520
+
1521
+ inet_ntop(AF_INET, ((struct sockaddr_in*)&paddr.spp_address), str, sizeof(str));
1522
+
1523
+ return rb_struct_new(
1524
+ v_sctp_peer_addr_params_struct,
1525
+ INT2NUM(paddr.spp_assoc_id),
1526
+ rb_str_new2(str),
1527
+ INT2NUM(paddr.spp_hbinterval),
1528
+ INT2NUM(paddr.spp_pathmaxrxt)
1529
+ );
1530
+ }
1531
+
1425
1532
  void Init_socket(void){
1426
1533
  mSCTP = rb_define_module("SCTP");
1427
1534
  cSocket = rb_define_class_under(mSCTP, "Socket", rb_cObject);
@@ -1442,7 +1549,7 @@ void Init_socket(void){
1442
1549
  );
1443
1550
 
1444
1551
  v_remote_error_struct = rb_struct_define(
1445
- "RemoteError", "type", "length", "error", "association_id", "data", NULL
1552
+ "RemoteError", "type", "flags", "length", "error", "association_id", "data", NULL
1446
1553
  );
1447
1554
 
1448
1555
  v_send_failed_event_struct = rb_struct_define(
@@ -1470,6 +1577,10 @@ void Init_socket(void){
1470
1577
  "AuthEvent", "type", "length", "key_number", "indication", "association_id", NULL
1471
1578
  );
1472
1579
 
1580
+ v_sender_dry_event_struct = rb_struct_define(
1581
+ "SenderDryEvent", "type", "flags", "length", "association_id", NULL
1582
+ );
1583
+
1473
1584
  v_sockaddr_in_struct = rb_struct_define(
1474
1585
  "SockAddrIn", "family", "port", "address", NULL
1475
1586
  );
@@ -1506,6 +1617,11 @@ void Init_socket(void){
1506
1617
  "cumtsn", "context", "assocation_id", NULL
1507
1618
  );
1508
1619
 
1620
+ v_sctp_peer_addr_params_struct = rb_struct_define(
1621
+ "PeerAddressParams", "association_id", "address", "heartbeat_interval",
1622
+ "max_retransmission_count", NULL
1623
+ );
1624
+
1509
1625
  rb_define_method(cSocket, "initialize", rsctp_init, -1);
1510
1626
 
1511
1627
  rb_define_method(cSocket, "bindx", rsctp_bindx, -1);
@@ -1518,6 +1634,7 @@ void Init_socket(void){
1518
1634
  rb_define_method(cSocket, "get_retransmission_info", rsctp_get_retransmission_info, 0);
1519
1635
  rb_define_method(cSocket, "get_association_info", rsctp_get_association_info, 0);
1520
1636
  rb_define_method(cSocket, "get_subscriptions", rsctp_get_subscriptions, 0);
1637
+ rb_define_method(cSocket, "get_peer_address_params", rsctp_get_peer_address_params, 0);
1521
1638
  rb_define_method(cSocket, "listen", rsctp_listen, -1);
1522
1639
  rb_define_method(cSocket, "peeloff", rsctp_peeloff, 1);
1523
1640
  rb_define_method(cSocket, "recvmsg", rsctp_recvmsg, -1);
@@ -1542,8 +1659,8 @@ void Init_socket(void){
1542
1659
  rb_define_attr(cSocket, "association_id", 1, 1);
1543
1660
  rb_define_attr(cSocket, "port", 1, 1);
1544
1661
 
1545
- /* 0.0.7: The version of this library */
1546
- rb_define_const(cSocket, "VERSION", rb_str_new2("0.0.7"));
1662
+ /* 0.1.0: The version of this library */
1663
+ rb_define_const(cSocket, "VERSION", rb_str_new2("0.1.0"));
1547
1664
 
1548
1665
  /* send flags */
1549
1666
 
data/sctp-socket.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'sctp-socket'
3
- spec.version = '0.0.7'
3
+ spec.version = '0.1.0'
4
4
  spec.author = 'Daniel Berger'
5
5
  spec.email = 'djberg96@gmail.com'
6
6
  spec.summary = 'Ruby bindings for SCTP sockets'
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.extensions = ['ext/sctp/extconf.rb']
16
16
 
17
- spec.add_development_dependency 'bundler', '~> 2.1'
18
- spec.add_development_dependency 'rake', '~> 13.0'
19
- spec.add_development_dependency 'rake-compiler', '~> 1.1'
20
- spec.add_development_dependency 'rspec', '~> 3.9'
17
+ spec.add_development_dependency 'bundler'
18
+ spec.add_development_dependency 'rake'
19
+ spec.add_development_dependency 'rake-compiler'
20
+ spec.add_development_dependency 'rspec'
21
21
 
22
22
  spec.metadata = {
23
23
  'homepage_uri' => 'https://github.com/djberg96/sctp-socket',
data.tar.gz.sig CHANGED
Binary file
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.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
@@ -35,64 +35,64 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2024-05-28 00:00:00.000000000 Z
38
+ date: 2024-06-01 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: bundler
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '2.1'
46
+ version: '0'
47
47
  type: :development
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '2.1'
53
+ version: '0'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: rake
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '13.0'
60
+ version: '0'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '13.0'
67
+ version: '0'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: rake-compiler
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '1.1'
74
+ version: '0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '1.1'
81
+ version: '0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rspec
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '3.9'
88
+ version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '3.9'
95
+ version: '0'
96
96
  description: |2
97
97
  The sctp-socket library provides Ruby bindings for SCTP sockets. is a
98
98
  message oriented, reliable transport protocol with direct support for
metadata.gz.sig CHANGED
Binary file