sctp-socket 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +9 -0
- data/Rakefile +3 -1
- data/ext/sctp/socket.c +147 -53
- data/sctp-socket.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +2 -4
- metadata.gz.sig +0 -0
- data/.github/FUNDING.yml +0 -4
- data/.github/workflows/ruby.yml +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d41294806b8cc4ed6b74131f494a4a4309cac02ba490e3bbe20ef0f2cb89a09e
|
|
4
|
+
data.tar.gz: 3a8d7207263715d37f7a42986ee734dd225af23e3e071daefcb35f0c53786cfe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60fa99a73f494affaf1b6f68ce35178e64642e4c26feff61f349db97bec4f0240c268ef406150e0bc78fb78a6634ec7d5876490b722d84aef858f9e030085a0f
|
|
7
|
+
data.tar.gz: '0925c76359dd0f1168c08556673a4f4d5db03bc891699042458e69f10509baf242ed95084ba97722f6a4ba24e5f88e43be39c1f9bb21a22fd6fbf8801f3446b9'
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 0.2.1 - 17-Aug-2025
|
|
2
|
+
* Several auth related methods were fixed.
|
|
3
|
+
* The recvv and recvmsg methods now allow for an optional buffer size argument.
|
|
4
|
+
* Several methods now explictly check for closed sockets internally.
|
|
5
|
+
* The specs that were previously all lumped together have been split out
|
|
6
|
+
for individual methods (or related methods) for ease of maintenance and
|
|
7
|
+
generally easier debugging.
|
|
8
|
+
* In the process of splitting out the specs, many were heavily refactored.
|
|
9
|
+
|
|
1
10
|
## 0.2.0 - 3-Aug-2025
|
|
2
11
|
* Added an SCTP::Server class, generally modelled on the TCPServer class.
|
|
3
12
|
* Added the map_ipv4? method to query IPv4 mapping status.
|
data/Rakefile
CHANGED
data/ext/sctp/socket.c
CHANGED
|
@@ -851,6 +851,8 @@ static VALUE rsctp_sendv(VALUE self, VALUE v_options){
|
|
|
851
851
|
|
|
852
852
|
Check_Type(v_message, T_ARRAY);
|
|
853
853
|
|
|
854
|
+
CHECK_SOCKET_CLOSED(self);
|
|
855
|
+
|
|
854
856
|
if(!NIL_P(v_addresses)){
|
|
855
857
|
Check_Type(v_addresses, T_ARRAY);
|
|
856
858
|
num_ip = (int)RARRAY_LEN(v_addresses);
|
|
@@ -925,24 +927,48 @@ static VALUE rsctp_sendv(VALUE self, VALUE v_options){
|
|
|
925
927
|
#endif
|
|
926
928
|
|
|
927
929
|
#ifdef HAVE_SCTP_RECVV
|
|
930
|
+
/*
|
|
931
|
+
* call-seq:
|
|
932
|
+
* SCTP::Socket#recvv(flags=0, buffer_size=1024)
|
|
933
|
+
*
|
|
934
|
+
* Receive a message using sctp_recvv from another SCTP endpoint.
|
|
935
|
+
*
|
|
936
|
+
* The optional buffer_size parameter specifies the size of the receive buffer
|
|
937
|
+
* in bytes. Defaults to 1024 bytes if not specified.
|
|
938
|
+
*
|
|
939
|
+
* Example:
|
|
940
|
+
*
|
|
941
|
+
* begin
|
|
942
|
+
* socket = SCTP::Socket.new
|
|
943
|
+
* socket.bind(:port => 62534, :addresses => ['10.0.4.5', '10.0.5.5'])
|
|
944
|
+
* socket.listen
|
|
945
|
+
*
|
|
946
|
+
* while true
|
|
947
|
+
* info = socket.recvv
|
|
948
|
+
* puts "Received message: #{info.message}"
|
|
949
|
+
*
|
|
950
|
+
* # Or with custom buffer size
|
|
951
|
+
* info = socket.recvv(0, 4096)
|
|
952
|
+
* puts "Received message: #{info.message}"
|
|
953
|
+
* end
|
|
954
|
+
* ensure
|
|
955
|
+
* socket.close
|
|
956
|
+
* end
|
|
957
|
+
*/
|
|
928
958
|
static VALUE rsctp_recvv(int argc, VALUE* argv, VALUE self){
|
|
929
|
-
VALUE v_flags;
|
|
930
|
-
int fileno, flags, on;
|
|
959
|
+
VALUE v_flags, v_buffer_size;
|
|
960
|
+
int fileno, flags, on, buffer_size;
|
|
931
961
|
ssize_t bytes;
|
|
932
962
|
uint infotype;
|
|
933
963
|
socklen_t infolen;
|
|
934
964
|
struct iovec iov[1];
|
|
935
965
|
struct sctp_rcvinfo info;
|
|
936
|
-
char buffer
|
|
966
|
+
char *buffer;
|
|
937
967
|
|
|
938
968
|
bzero(&iov, sizeof(iov));
|
|
939
969
|
bzero(&info, sizeof(info));
|
|
940
|
-
bzero(&buffer, sizeof(buffer));
|
|
941
|
-
|
|
942
|
-
iov->iov_base = buffer;
|
|
943
|
-
iov->iov_len = sizeof(buffer);
|
|
944
970
|
|
|
945
|
-
rb_scan_args(argc, argv, "
|
|
971
|
+
rb_scan_args(argc, argv, "02", &v_flags, &v_buffer_size);
|
|
946
972
|
|
|
947
973
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
948
974
|
|
|
@@ -951,9 +977,28 @@ static VALUE rsctp_recvv(int argc, VALUE* argv, VALUE self){
|
|
|
951
977
|
else
|
|
952
978
|
flags = NUM2INT(v_flags);
|
|
953
979
|
|
|
980
|
+
if(NIL_P(v_buffer_size))
|
|
981
|
+
buffer_size = 1024;
|
|
982
|
+
else
|
|
983
|
+
buffer_size = NUM2INT(v_buffer_size);
|
|
984
|
+
|
|
985
|
+
if(buffer_size <= 0)
|
|
986
|
+
rb_raise(rb_eArgError, "buffer size must be positive");
|
|
987
|
+
|
|
988
|
+
buffer = (char*)malloc(buffer_size);
|
|
989
|
+
if(buffer == NULL)
|
|
990
|
+
rb_raise(rb_eNoMemError, "failed to allocate buffer");
|
|
991
|
+
|
|
992
|
+
bzero(buffer, buffer_size);
|
|
993
|
+
|
|
994
|
+
iov->iov_base = buffer;
|
|
995
|
+
iov->iov_len = buffer_size;
|
|
996
|
+
|
|
954
997
|
on = 1;
|
|
955
|
-
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(on)) < 0)
|
|
998
|
+
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(on)) < 0){
|
|
999
|
+
free(buffer);
|
|
956
1000
|
rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(errno));
|
|
1001
|
+
}
|
|
957
1002
|
|
|
958
1003
|
infolen = sizeof(struct sctp_rcvinfo);
|
|
959
1004
|
infotype = 0;
|
|
@@ -970,16 +1015,19 @@ static VALUE rsctp_recvv(int argc, VALUE* argv, VALUE self){
|
|
|
970
1015
|
&flags
|
|
971
1016
|
);
|
|
972
1017
|
|
|
973
|
-
if(bytes < 0)
|
|
1018
|
+
if(bytes < 0){
|
|
1019
|
+
free(buffer);
|
|
974
1020
|
rb_raise(rb_eSystemCallError, "sctp_recvv: %s", strerror(errno));
|
|
1021
|
+
}
|
|
975
1022
|
|
|
976
1023
|
if(infotype != SCTP_RECVV_RCVINFO){
|
|
1024
|
+
free(buffer);
|
|
977
1025
|
return Qnil;
|
|
978
1026
|
}
|
|
979
1027
|
else{
|
|
980
|
-
|
|
1028
|
+
VALUE result = rb_struct_new(
|
|
981
1029
|
v_sctp_receive_info_struct,
|
|
982
|
-
|
|
1030
|
+
rb_str_new(iov->iov_base, bytes),
|
|
983
1031
|
UINT2NUM(info.rcv_sid),
|
|
984
1032
|
UINT2NUM(info.rcv_ssn),
|
|
985
1033
|
UINT2NUM(info.rcv_flags),
|
|
@@ -989,6 +1037,8 @@ static VALUE rsctp_recvv(int argc, VALUE* argv, VALUE self){
|
|
|
989
1037
|
UINT2NUM(info.rcv_context),
|
|
990
1038
|
UINT2NUM(info.rcv_assoc_id)
|
|
991
1039
|
);
|
|
1040
|
+
free(buffer);
|
|
1041
|
+
return result;
|
|
992
1042
|
}
|
|
993
1043
|
}
|
|
994
1044
|
#endif
|
|
@@ -1264,10 +1314,13 @@ static VALUE rsctp_sendmsg(VALUE self, VALUE v_options){
|
|
|
1264
1314
|
|
|
1265
1315
|
/*
|
|
1266
1316
|
* call-seq:
|
|
1267
|
-
* SCTP::Socket#recvmsg(flags=0)
|
|
1317
|
+
* SCTP::Socket#recvmsg(flags=0, buffer_size=1024)
|
|
1268
1318
|
*
|
|
1269
1319
|
* Receive a message from another SCTP endpoint.
|
|
1270
1320
|
*
|
|
1321
|
+
* The optional buffer_size parameter specifies the size of the receive buffer
|
|
1322
|
+
* in bytes. Defaults to 1024 bytes if not specified.
|
|
1323
|
+
*
|
|
1271
1324
|
* Example:
|
|
1272
1325
|
*
|
|
1273
1326
|
* begin
|
|
@@ -1279,46 +1332,64 @@ static VALUE rsctp_sendmsg(VALUE self, VALUE v_options){
|
|
|
1279
1332
|
* while true
|
|
1280
1333
|
* info = socket.recvmsg
|
|
1281
1334
|
* puts "Received message: #{info.message}"
|
|
1335
|
+
*
|
|
1336
|
+
* # Or with custom buffer size
|
|
1337
|
+
* info = socket.recvmsg(0, 4096)
|
|
1338
|
+
* puts "Received message: #{info.message}"
|
|
1282
1339
|
* end
|
|
1283
1340
|
* ensure
|
|
1284
1341
|
* socket.close
|
|
1285
1342
|
* end
|
|
1286
1343
|
*/
|
|
1287
1344
|
static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
|
|
1288
|
-
VALUE v_flags, v_notification, v_message;
|
|
1345
|
+
VALUE v_flags, v_buffer_size, v_notification, v_message;
|
|
1289
1346
|
struct sctp_sndrcvinfo sndrcvinfo;
|
|
1290
1347
|
struct sockaddr_in clientaddr;
|
|
1291
|
-
int flags, fileno;
|
|
1348
|
+
int flags, fileno, buffer_size;
|
|
1292
1349
|
ssize_t bytes;
|
|
1293
|
-
char buffer
|
|
1350
|
+
char *buffer;
|
|
1294
1351
|
socklen_t length;
|
|
1295
1352
|
|
|
1296
|
-
rb_scan_args(argc, argv, "
|
|
1353
|
+
rb_scan_args(argc, argv, "02", &v_flags, &v_buffer_size);
|
|
1297
1354
|
|
|
1298
1355
|
if(NIL_P(v_flags))
|
|
1299
1356
|
flags = 0;
|
|
1300
1357
|
else
|
|
1301
1358
|
flags = NUM2INT(v_flags);
|
|
1302
1359
|
|
|
1360
|
+
if(NIL_P(v_buffer_size))
|
|
1361
|
+
buffer_size = 1024;
|
|
1362
|
+
else
|
|
1363
|
+
buffer_size = NUM2INT(v_buffer_size);
|
|
1364
|
+
|
|
1365
|
+
if(buffer_size <= 0)
|
|
1366
|
+
rb_raise(rb_eArgError, "buffer size must be positive");
|
|
1367
|
+
|
|
1368
|
+
buffer = (char*)malloc(buffer_size);
|
|
1369
|
+
if(buffer == NULL)
|
|
1370
|
+
rb_raise(rb_eNoMemError, "failed to allocate buffer");
|
|
1371
|
+
|
|
1303
1372
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
1304
1373
|
length = sizeof(struct sockaddr_in);
|
|
1305
1374
|
|
|
1306
|
-
bzero(buffer,
|
|
1375
|
+
bzero(buffer, buffer_size);
|
|
1307
1376
|
bzero(&clientaddr, sizeof(clientaddr));
|
|
1308
1377
|
bzero(&sndrcvinfo, sizeof(sndrcvinfo));
|
|
1309
1378
|
|
|
1310
1379
|
bytes = (ssize_t)sctp_recvmsg(
|
|
1311
1380
|
fileno,
|
|
1312
1381
|
buffer,
|
|
1313
|
-
|
|
1382
|
+
buffer_size,
|
|
1314
1383
|
(struct sockaddr*)&clientaddr,
|
|
1315
1384
|
&length,
|
|
1316
1385
|
&sndrcvinfo,
|
|
1317
1386
|
&flags
|
|
1318
1387
|
);
|
|
1319
1388
|
|
|
1320
|
-
if(bytes < 0)
|
|
1389
|
+
if(bytes < 0){
|
|
1390
|
+
free(buffer);
|
|
1321
1391
|
rb_raise(rb_eSystemCallError, "sctp_recvmsg: %s", strerror(errno));
|
|
1392
|
+
}
|
|
1322
1393
|
|
|
1323
1394
|
v_notification = Qnil;
|
|
1324
1395
|
|
|
@@ -1330,6 +1401,8 @@ static VALUE rsctp_recvmsg(int argc, VALUE* argv, VALUE self){
|
|
|
1330
1401
|
else
|
|
1331
1402
|
v_message = Qnil;
|
|
1332
1403
|
|
|
1404
|
+
free(buffer);
|
|
1405
|
+
|
|
1333
1406
|
return rb_struct_new(v_sndrcv_struct,
|
|
1334
1407
|
v_message,
|
|
1335
1408
|
UINT2NUM(sndrcvinfo.sinfo_stream),
|
|
@@ -2239,6 +2312,8 @@ static VALUE rsctp_enable_auth_support(int argc, VALUE* argv, VALUE self){
|
|
|
2239
2312
|
|
|
2240
2313
|
rb_scan_args(argc, argv, "01", &v_assoc_id);
|
|
2241
2314
|
|
|
2315
|
+
CHECK_SOCKET_CLOSED(self);
|
|
2316
|
+
|
|
2242
2317
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
2243
2318
|
size = sizeof(struct sctp_assoc_value);
|
|
2244
2319
|
|
|
@@ -2250,8 +2325,8 @@ static VALUE rsctp_enable_auth_support(int argc, VALUE* argv, VALUE self){
|
|
|
2250
2325
|
assoc_value.assoc_id = assoc_id;
|
|
2251
2326
|
assoc_value.assoc_value = 1;
|
|
2252
2327
|
|
|
2253
|
-
if(
|
|
2254
|
-
rb_raise(rb_eSystemCallError, "
|
|
2328
|
+
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_AUTH_SUPPORTED, (void*)&assoc_value, size) < 0)
|
|
2329
|
+
rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(errno));
|
|
2255
2330
|
|
|
2256
2331
|
return self;
|
|
2257
2332
|
}
|
|
@@ -2295,7 +2370,7 @@ static VALUE rsctp_get_auth_support(int argc, VALUE* argv, VALUE self){
|
|
|
2295
2370
|
|
|
2296
2371
|
/*
|
|
2297
2372
|
* call-seq:
|
|
2298
|
-
* SCTP::Socket#set_shared_key(key, keynum, association_id=nil)
|
|
2373
|
+
* SCTP::Socket#set_shared_key(key, keynum=1, association_id=nil)
|
|
2299
2374
|
*
|
|
2300
2375
|
* This option will set a shared secret key which is used to build an
|
|
2301
2376
|
* association shared key.
|
|
@@ -2331,18 +2406,11 @@ static VALUE rsctp_set_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2331
2406
|
|
|
2332
2407
|
rb_scan_args(argc, argv, "12", &v_key, &v_keynumber, &v_assoc_id);
|
|
2333
2408
|
|
|
2409
|
+
CHECK_SOCKET_CLOSED(self);
|
|
2410
|
+
|
|
2334
2411
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
2335
2412
|
key = StringValuePtr(v_key);
|
|
2336
|
-
len =
|
|
2337
|
-
unsigned char byte_array[len+1];
|
|
2338
|
-
|
|
2339
|
-
for(size_t i = 0; i < len; i++)
|
|
2340
|
-
byte_array[i] = key[i];
|
|
2341
|
-
|
|
2342
|
-
byte_array[len] = '\0';
|
|
2343
|
-
|
|
2344
|
-
auth_key = malloc(sizeof(auth_key) + sizeof(char[strlen(key)+1]));
|
|
2345
|
-
size = sizeof(auth_key);
|
|
2413
|
+
len = RSTRING_LEN(v_key); // Use Ruby's string length, not strlen
|
|
2346
2414
|
|
|
2347
2415
|
if(NIL_P(v_assoc_id))
|
|
2348
2416
|
assoc_id = NUM2INT(rb_iv_get(self, "@association_id"));
|
|
@@ -2354,14 +2422,25 @@ static VALUE rsctp_set_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2354
2422
|
else
|
|
2355
2423
|
keynum = NUM2INT(v_keynumber);
|
|
2356
2424
|
|
|
2425
|
+
// Allocate the structure with space for the key
|
|
2426
|
+
size = sizeof(struct sctp_authkey) + len;
|
|
2427
|
+
auth_key = malloc(size);
|
|
2428
|
+
|
|
2429
|
+
if (auth_key == NULL)
|
|
2430
|
+
rb_raise(rb_eNoMemError, "Failed to allocate memory for auth key");
|
|
2431
|
+
|
|
2357
2432
|
auth_key->sca_assoc_id = assoc_id;
|
|
2358
2433
|
auth_key->sca_keynumber = keynum;
|
|
2359
|
-
auth_key->sca_keylength =
|
|
2360
|
-
memcpy(auth_key->sca_key,
|
|
2434
|
+
auth_key->sca_keylength = len;
|
|
2435
|
+
memcpy(auth_key->sca_key, key, len);
|
|
2361
2436
|
|
|
2362
|
-
if(
|
|
2363
|
-
|
|
2437
|
+
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_AUTH_KEY, (void*)auth_key, size) < 0) {
|
|
2438
|
+
int err = errno;
|
|
2439
|
+
free(auth_key);
|
|
2440
|
+
rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(err));
|
|
2441
|
+
}
|
|
2364
2442
|
|
|
2443
|
+
free(auth_key);
|
|
2365
2444
|
return self;
|
|
2366
2445
|
}
|
|
2367
2446
|
|
|
@@ -2377,14 +2456,19 @@ static VALUE rsctp_get_active_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2377
2456
|
struct sctp_authkeyid authkey;
|
|
2378
2457
|
sctp_assoc_t assoc_id;
|
|
2379
2458
|
VALUE v_assoc_id, v_keynum;
|
|
2380
|
-
|
|
2459
|
+
int keynum;
|
|
2381
2460
|
|
|
2382
2461
|
rb_scan_args(argc, argv, "11", &v_keynum, &v_assoc_id);
|
|
2383
2462
|
|
|
2384
2463
|
bzero(&authkey, sizeof(authkey));
|
|
2385
2464
|
|
|
2465
|
+
// Cast it later, we want to force a validity check.
|
|
2466
|
+
keynum = FIX2INT(v_keynum);
|
|
2467
|
+
|
|
2468
|
+
if(keynum < 0)
|
|
2469
|
+
rb_raise(rb_eArgError, "invalid keynum value");
|
|
2470
|
+
|
|
2386
2471
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
2387
|
-
keynum = NUM2UINT(v_keynum);
|
|
2388
2472
|
|
|
2389
2473
|
if(NIL_P(v_assoc_id))
|
|
2390
2474
|
assoc_id = NUM2INT(rb_iv_get(self, "@association_id"));
|
|
@@ -2392,7 +2476,7 @@ static VALUE rsctp_get_active_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2392
2476
|
assoc_id = NUM2INT(v_assoc_id);
|
|
2393
2477
|
|
|
2394
2478
|
authkey.scact_assoc_id = assoc_id;
|
|
2395
|
-
authkey.scact_keynumber = keynum;
|
|
2479
|
+
authkey.scact_keynumber = (uint)keynum;
|
|
2396
2480
|
|
|
2397
2481
|
size = sizeof(struct sctp_authkeyid);
|
|
2398
2482
|
|
|
@@ -2413,7 +2497,7 @@ static VALUE rsctp_get_active_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2413
2497
|
* authenticated chunks. The key identifier MUST correspond to an existing
|
|
2414
2498
|
* shared key. Note that shared key identifier '0' defaults to a null key.
|
|
2415
2499
|
*
|
|
2416
|
-
* The
|
|
2500
|
+
* The association_id parameter, if non-zero, indicates what association that
|
|
2417
2501
|
* the shared key identifier is being set active upon. If this element contains
|
|
2418
2502
|
* zero, then the activation applies to the endpoint and all future
|
|
2419
2503
|
* associations will use the specified shared key identifier.
|
|
@@ -2430,11 +2514,15 @@ static VALUE rsctp_set_active_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2430
2514
|
struct sctp_authkeyid authkey;
|
|
2431
2515
|
sctp_assoc_t assoc_id;
|
|
2432
2516
|
VALUE v_assoc_id, v_keynum;
|
|
2433
|
-
|
|
2517
|
+
int keynum;
|
|
2434
2518
|
|
|
2435
2519
|
rb_scan_args(argc, argv, "11", &v_keynum, &v_assoc_id);
|
|
2436
2520
|
|
|
2437
|
-
keynum =
|
|
2521
|
+
keynum = FIX2INT(v_keynum);
|
|
2522
|
+
|
|
2523
|
+
if(keynum < 0)
|
|
2524
|
+
rb_raise(rb_eArgError, "invalid keynum value");
|
|
2525
|
+
|
|
2438
2526
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
2439
2527
|
|
|
2440
2528
|
if(NIL_P(v_assoc_id))
|
|
@@ -2443,11 +2531,11 @@ static VALUE rsctp_set_active_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2443
2531
|
assoc_id = NUM2INT(v_assoc_id);
|
|
2444
2532
|
|
|
2445
2533
|
authkey.scact_assoc_id = assoc_id;
|
|
2446
|
-
authkey.scact_keynumber = keynum;
|
|
2534
|
+
authkey.scact_keynumber = (uint)keynum;
|
|
2447
2535
|
size = sizeof(struct sctp_authkeyid);
|
|
2448
2536
|
|
|
2449
|
-
if(
|
|
2450
|
-
rb_raise(rb_eSystemCallError, "
|
|
2537
|
+
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, (void*)&authkey, size) < 0)
|
|
2538
|
+
rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(errno));
|
|
2451
2539
|
|
|
2452
2540
|
return self;
|
|
2453
2541
|
}
|
|
@@ -2487,6 +2575,8 @@ static VALUE rsctp_delete_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2487
2575
|
|
|
2488
2576
|
rb_scan_args(argc, argv, "11", &v_keynum, &v_assoc_id);
|
|
2489
2577
|
|
|
2578
|
+
CHECK_SOCKET_CLOSED(self);
|
|
2579
|
+
|
|
2490
2580
|
bzero(&authkey, sizeof(authkey));
|
|
2491
2581
|
|
|
2492
2582
|
fileno = NUM2INT(rb_iv_get(self, "@fileno"));
|
|
@@ -2502,8 +2592,8 @@ static VALUE rsctp_delete_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2502
2592
|
|
|
2503
2593
|
size = sizeof(struct sctp_authkeyid);
|
|
2504
2594
|
|
|
2505
|
-
if(
|
|
2506
|
-
rb_raise(rb_eSystemCallError, "
|
|
2595
|
+
if(setsockopt(fileno, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, (void*)&authkey, size) < 0)
|
|
2596
|
+
rb_raise(rb_eSystemCallError, "setsockopt: %s", strerror(errno));
|
|
2507
2597
|
|
|
2508
2598
|
return INT2NUM(authkey.scact_keynumber);
|
|
2509
2599
|
}
|
|
@@ -2512,10 +2602,14 @@ static VALUE rsctp_delete_shared_key(int argc, VALUE* argv, VALUE self){
|
|
|
2512
2602
|
* call-seq:
|
|
2513
2603
|
* SCTP::Socket#map_ipv4=(bool)
|
|
2514
2604
|
*
|
|
2515
|
-
* If set to true and the socket is type
|
|
2605
|
+
* If set to true and the socket is type xF_INET6, then IPv4 addresses will be
|
|
2516
2606
|
* mapped to V6 representation. If set to false (the default), then no mapping
|
|
2517
|
-
* will be done of V4 addresses and a user will receive both
|
|
2518
|
-
*
|
|
2607
|
+
* will be done of V4 addresses and a user will receive both xF_INET6 and
|
|
2608
|
+
* xF_INET type addresses on the socket.
|
|
2609
|
+
*
|
|
2610
|
+
* Note that setting this to true on a socket that is not type xF_INET6 is
|
|
2611
|
+
* undefined behavior, and may raise an error on your platform. Otherwise it's
|
|
2612
|
+
* a no-op.
|
|
2519
2613
|
*/
|
|
2520
2614
|
static VALUE rsctp_map_ipv4(VALUE self, VALUE v_bool){
|
|
2521
2615
|
int fileno, boolean;
|
|
@@ -2899,8 +2993,8 @@ void Init_socket(void){
|
|
|
2899
2993
|
rb_define_attr(cSocket, "association_id", 1, 1);
|
|
2900
2994
|
rb_define_attr(cSocket, "port", 1, 1);
|
|
2901
2995
|
|
|
2902
|
-
/* 0.
|
|
2903
|
-
rb_define_const(cSocket, "VERSION", rb_str_new2("0.2.
|
|
2996
|
+
/* 0.2.0: The version of this library */
|
|
2997
|
+
rb_define_const(cSocket, "VERSION", rb_str_new2("0.2.1"));
|
|
2904
2998
|
|
|
2905
2999
|
/* send flags */
|
|
2906
3000
|
|
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.2.
|
|
3
|
+
spec.version = '0.2.1'
|
|
4
4
|
spec.author = 'Daniel Berger'
|
|
5
5
|
spec.email = 'djberg96@gmail.com'
|
|
6
6
|
spec.summary = 'Ruby bindings for SCTP sockets'
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.cert_chain = ['certs/djberg96_pub.pem']
|
|
10
10
|
|
|
11
11
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
12
|
-
f.match(%r{^(test|spec|features)/})
|
|
12
|
+
f.match(%r{^(test|spec|features|.github)/})
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
spec.extensions = ['ext/sctp/extconf.rb']
|
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.2.
|
|
4
|
+
version: 0.2.1
|
|
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: 2025-08-
|
|
38
|
+
date: 2025-08-17 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: bundler
|
|
@@ -103,8 +103,6 @@ extensions:
|
|
|
103
103
|
- ext/sctp/extconf.rb
|
|
104
104
|
extra_rdoc_files: []
|
|
105
105
|
files:
|
|
106
|
-
- ".github/FUNDING.yml"
|
|
107
|
-
- ".github/workflows/ruby.yml"
|
|
108
106
|
- ".gitignore"
|
|
109
107
|
- CHANGES.md
|
|
110
108
|
- Gemfile
|
metadata.gz.sig
CHANGED
|
Binary file
|
data/.github/FUNDING.yml
DELETED
data/.github/workflows/ruby.yml
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
name: Ruby
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
paths-ignore:
|
|
7
|
-
- '**/*.md'
|
|
8
|
-
pull_request:
|
|
9
|
-
branches: [ main ]
|
|
10
|
-
paths-ignore:
|
|
11
|
-
- '**/*.md'
|
|
12
|
-
workflow_dispatch:
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
test:
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
strategy:
|
|
18
|
-
matrix:
|
|
19
|
-
ruby-version: ['3.2', '3.3', '3.4']
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v4
|
|
22
|
-
- name: Install SCTP headers
|
|
23
|
-
run: |
|
|
24
|
-
sudo apt-get install libsctp-dev lksctp-tools
|
|
25
|
-
sudo ip link add dummy1 type dummy
|
|
26
|
-
sudo ip link add dummy2 type dummy
|
|
27
|
-
sudo ip addr add 1.1.1.1/24 dev dummy1
|
|
28
|
-
sudo ip addr add 1.1.1.2/24 dev dummy2
|
|
29
|
-
sudo ip link set dummy1 up
|
|
30
|
-
sudo ip link set dummy2 up
|
|
31
|
-
- name: Setup Ruby
|
|
32
|
-
uses: ruby/setup-ruby@v1
|
|
33
|
-
with:
|
|
34
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
35
|
-
bundler-cache: true
|
|
36
|
-
- name: Run Specs
|
|
37
|
-
run: bundle exec rake
|
|
38
|
-
freebsd:
|
|
39
|
-
runs-on: ubuntu-latest
|
|
40
|
-
steps:
|
|
41
|
-
- uses: actions/checkout@v4
|
|
42
|
-
- name: Test in FreeBSD
|
|
43
|
-
id: test
|
|
44
|
-
uses: vmactions/freebsd-vm@v1
|
|
45
|
-
with:
|
|
46
|
-
usesh: true
|
|
47
|
-
prepare: |
|
|
48
|
-
pkg install -y llvm ruby devel/ruby-gems sctplib git-tiny
|
|
49
|
-
|
|
50
|
-
run: |
|
|
51
|
-
git config --global --add safe.directory /home/runner/work/sctp-socket/sctp-socket
|
|
52
|
-
kldload sctp
|
|
53
|
-
ifconfig lo1 create
|
|
54
|
-
ifconfig lo1 1.1.1.1/24 up
|
|
55
|
-
ifconfig lo2 create
|
|
56
|
-
ifconfig lo2 1.1.1.2/24 up
|
|
57
|
-
gem install bundler --no-document
|
|
58
|
-
bundle install --quiet
|
|
59
|
-
bundle exec rake
|