Skip to content

Commit ef6c252

Browse files
committed
Auto merge of #770 - jack-pappas:dccp, r=alexcrichton
Define DCCP constants This PR defines constants needed to utilize [DCCP](https://en.wikipedia.org/wiki/Datagram_Congestion_Control_Protocol) in Linux and NetBSD.
2 parents 322e59f + 787addf commit ef6c252

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

libc-test/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ fn main() {
239239
}
240240
}
241241

242+
if linux || android {
243+
// DCCP support
244+
if !uclibc && !musl && !emscripten {
245+
cfg.header("linux/dccp.h");
246+
}
247+
}
248+
242249
if freebsd {
243250
cfg.header("pthread_np.h");
244251
cfg.header("sched.h");
@@ -253,6 +260,9 @@ fn main() {
253260
cfg.header("ufs/ufs/quota.h");
254261
cfg.header("ufs/ufs/quota1.h");
255262
cfg.header("sys/ioctl_compat.h");
263+
264+
// DCCP support
265+
cfg.header("netinet/dccp.h");
256266
}
257267

258268
if openbsd {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,65 @@ pub const MAP_NORESERVE : ::c_int = 0x40;
465465
pub const MAP_HASSEMAPHORE : ::c_int = 0x200;
466466
pub const MAP_WIRED: ::c_int = 0x800;
467467

468+
pub const DCCP_TYPE_REQUEST: ::c_int = 0;
469+
pub const DCCP_TYPE_RESPONSE: ::c_int = 1;
470+
pub const DCCP_TYPE_DATA: ::c_int = 2;
471+
pub const DCCP_TYPE_ACK: ::c_int = 3;
472+
pub const DCCP_TYPE_DATAACK: ::c_int = 4;
473+
pub const DCCP_TYPE_CLOSEREQ: ::c_int = 5;
474+
pub const DCCP_TYPE_CLOSE: ::c_int = 6;
475+
pub const DCCP_TYPE_RESET: ::c_int = 7;
476+
pub const DCCP_TYPE_MOVE: ::c_int = 8;
477+
478+
pub const DCCP_FEATURE_CC: ::c_int = 1;
479+
pub const DCCP_FEATURE_ECN: ::c_int = 2;
480+
pub const DCCP_FEATURE_ACKRATIO: ::c_int = 3;
481+
pub const DCCP_FEATURE_ACKVECTOR: ::c_int = 4;
482+
pub const DCCP_FEATURE_MOBILITY: ::c_int = 5;
483+
pub const DCCP_FEATURE_LOSSWINDOW: ::c_int = 6;
484+
pub const DCCP_FEATURE_CONN_NONCE: ::c_int = 8;
485+
pub const DCCP_FEATURE_IDENTREG: ::c_int = 7;
486+
487+
pub const DCCP_OPT_PADDING: ::c_int = 0;
488+
pub const DCCP_OPT_DATA_DISCARD: ::c_int = 1;
489+
pub const DCCP_OPT_SLOW_RECV: ::c_int = 2;
490+
pub const DCCP_OPT_BUF_CLOSED: ::c_int = 3;
491+
pub const DCCP_OPT_CHANGE_L: ::c_int = 32;
492+
pub const DCCP_OPT_CONFIRM_L: ::c_int = 33;
493+
pub const DCCP_OPT_CHANGE_R: ::c_int = 34;
494+
pub const DCCP_OPT_CONFIRM_R: ::c_int = 35;
495+
pub const DCCP_OPT_INIT_COOKIE: ::c_int = 36;
496+
pub const DCCP_OPT_NDP_COUNT: ::c_int = 37;
497+
pub const DCCP_OPT_ACK_VECTOR0: ::c_int = 38;
498+
pub const DCCP_OPT_ACK_VECTOR1: ::c_int = 39;
499+
pub const DCCP_OPT_RECV_BUF_DROPS: ::c_int = 40;
500+
pub const DCCP_OPT_TIMESTAMP: ::c_int = 41;
501+
pub const DCCP_OPT_TIMESTAMP_ECHO: ::c_int = 42;
502+
pub const DCCP_OPT_ELAPSEDTIME: ::c_int = 43;
503+
pub const DCCP_OPT_DATACHECKSUM: ::c_int = 44;
504+
505+
pub const DCCP_REASON_UNSPEC: ::c_int = 0;
506+
pub const DCCP_REASON_CLOSED: ::c_int = 1;
507+
pub const DCCP_REASON_INVALID: ::c_int = 2;
508+
pub const DCCP_REASON_OPTION_ERR: ::c_int = 3;
509+
pub const DCCP_REASON_FEA_ERR: ::c_int = 4;
510+
pub const DCCP_REASON_CONN_REF: ::c_int = 5;
511+
pub const DCCP_REASON_BAD_SNAME: ::c_int = 6;
512+
pub const DCCP_REASON_BAD_COOKIE: ::c_int = 7;
513+
pub const DCCP_REASON_INV_MOVE: ::c_int = 8;
514+
pub const DCCP_REASON_UNANSW_CH: ::c_int = 10;
515+
pub const DCCP_REASON_FRUITLESS_NEG: ::c_int = 11;
516+
517+
pub const DCCP_CCID: ::c_int = 1;
518+
pub const DCCP_CSLEN: ::c_int = 2;
519+
pub const DCCP_MAXSEG: ::c_int = 4;
520+
pub const DCCP_SERVICE: ::c_int = 8;
521+
522+
pub const DCCP_NDP_LIMIT: ::c_int = 16;
523+
pub const DCCP_SEQ_NUM_LIMIT: ::c_int = 16777216;
524+
pub const DCCP_MAX_OPTIONS: ::c_int = 32;
525+
pub const DCCP_MAX_PKTS: ::c_int = 100;
526+
468527
pub const _PC_LINK_MAX : ::c_int = 1;
469528
pub const _PC_MAX_CANON : ::c_int = 2;
470529
pub const _PC_MAX_INPUT : ::c_int = 3;

src/unix/notbsd/android/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131;
485485
pub const SOCK_STREAM: ::c_int = 1;
486486
pub const SOCK_DGRAM: ::c_int = 2;
487487
pub const SOCK_SEQPACKET: ::c_int = 5;
488+
pub const SOCK_DCCP: ::c_int = 6;
489+
pub const SOCK_PACKET: ::c_int = 10;
488490

489491
pub const SOL_SOCKET: ::c_int = 1;
490492
pub const SOL_SCTP: ::c_int = 132;
@@ -499,6 +501,27 @@ pub const AF_MAX: ::c_int = 43;
499501
#[doc(hidden)]
500502
pub const PF_MAX: ::c_int = AF_MAX;
501503

504+
/* DCCP socket options */
505+
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
506+
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
507+
pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
508+
pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
509+
pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
510+
pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
511+
pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
512+
pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
513+
pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
514+
pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
515+
pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
516+
pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
517+
pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
518+
pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
519+
pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
520+
pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
521+
522+
/// maximum number of services provided on the same listening port
523+
pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
524+
502525
pub const SO_REUSEADDR: ::c_int = 2;
503526
pub const SO_TYPE: ::c_int = 3;
504527
pub const SO_ERROR: ::c_int = 4;

src/unix/notbsd/linux/mips/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ pub const MAP_STACK: ::c_int = 0x40000;
294294
pub const SOCK_STREAM: ::c_int = 2;
295295
pub const SOCK_DGRAM: ::c_int = 1;
296296
pub const SOCK_SEQPACKET: ::c_int = 5;
297+
pub const SOCK_DCCP: ::c_int = 6;
298+
pub const SOCK_PACKET: ::c_int = 10;
297299

298300
pub const SOL_SOCKET: ::c_int = 0xffff;
299301

@@ -353,6 +355,27 @@ pub const SO_INCOMING_CPU: ::c_int = 49;
353355
pub const SO_ATTACH_BPF: ::c_int = 50;
354356
pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER;
355357

358+
/* DCCP socket options */
359+
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
360+
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
361+
pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
362+
pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
363+
pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
364+
pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
365+
pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
366+
pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
367+
pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
368+
pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
369+
pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
370+
pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
371+
pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
372+
pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
373+
pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
374+
pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
375+
376+
/// maximum number of services provided on the same listening port
377+
pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
378+
356379
pub const FIOCLEX: ::c_ulong = 0x6601;
357380
pub const FIONBIO: ::c_ulong = 0x667e;
358381

src/unix/notbsd/linux/musl/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ pub const RLIMIT_NLIMITS: ::c_int = 16;
140140

141141
pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
142142

143+
pub const SOCK_DCCP: ::c_int = 6;
144+
pub const SOCK_PACKET: ::c_int = 10;
145+
143146
pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
144147
pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
145148
pub const TCP_THIN_DUPACK: ::c_int = 17;

src/unix/notbsd/linux/other/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ pub const EREMOTEIO: ::c_int = 121;
247247
pub const SOCK_STREAM: ::c_int = 1;
248248
pub const SOCK_DGRAM: ::c_int = 2;
249249
pub const SOCK_SEQPACKET: ::c_int = 5;
250+
pub const SOCK_DCCP: ::c_int = 6;
251+
pub const SOCK_PACKET: ::c_int = 10;
250252

251253
pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
252254
pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
@@ -259,6 +261,27 @@ pub const TCP_REPAIR_OPTIONS: ::c_int = 22;
259261
pub const TCP_FASTOPEN: ::c_int = 23;
260262
pub const TCP_TIMESTAMP: ::c_int = 24;
261263

264+
/* DCCP socket options */
265+
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
266+
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
267+
pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
268+
pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
269+
pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
270+
pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
271+
pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
272+
pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
273+
pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
274+
pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
275+
pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
276+
pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
277+
pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
278+
pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
279+
pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
280+
pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
281+
282+
/// maximum number of services provided on the same listening port
283+
pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
284+
262285
pub const SIGTTIN: ::c_int = 21;
263286
pub const SIGTTOU: ::c_int = 22;
264287
pub const SIGXCPU: ::c_int = 24;

0 commit comments

Comments
 (0)