Skip to content

Commit

Permalink
freebsd sctp support part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Feb 12, 2023
1 parent 35ad929 commit 6e67caa
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ fn test_freebsd(target: &str) {
"memory_type" => true,
"memory_type_list" => true,
"pidfh" => true,
"sctp_gen_error_cause" | "sctp_error_missing_param" => true,
"sctp_gen_error_cause" | "sctp_error_missing_param" | "sctp_remote_error" => true,

_ => false,
}
Expand Down Expand Up @@ -2426,6 +2426,10 @@ fn test_freebsd(target: &str) {
("statinfo", "snap_time") => true,
("sctp_sndrcvinfo", "__reserve_pad") => true,
("sctp_extrcvinfo", "__reserve_pad") => true,
// Those following are of C dynamic arrays type.
("sctp_assoc_change", "sac_info") => true,
("sctp_send_failed_event", "ssfe_data") => true,
("sctp_stream_reset_event", "strreset_stream_list") => true,
// `tcp_snd_wscale` and `tcp_rcv_wscale` are bitfields
("tcp_info", "tcp_snd_wscale") => true,
("tcp_info", "tcp_rcv_wscale") => true,
Expand Down
47 changes: 47 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1085,22 +1085,47 @@ SCHED_RR
SCM_CREDS
SCM_RIGHTS
SCM_TIMESTAMP
SCTP_ACTIVE
SCTP_ALL_ASSOC
SCTP_ADAPTATION_LAYER
SCTP_ADAPTION_LAYER
SCTP_ADDR_ADDED
SCTP_ADDR_AVAILABLE
SCTP_ADDR_CONFIRMED
SCTP_ADDR_MADE_PRIM
SCTP_ADDR_REMOVED
SCTP_ADDR_UNREACHABLE
SCTP_ADDR_OVER
SCTP_ASSOCINFO
SCTP_ASSOC_RESET_DENIED
SCTP_ASSOC_RESET_FAILED
SCTP_ASSOC_SUPPORTS_ASCONF
SCTP_ASSOC_SUPPORTS_AUTH
SCTP_ASSOC_SUPPORTS_INTERLEAVING
SCTP_ASSOC_SUPPORTS_MAX
SCTP_ASSOC_SUPPORTS_MULTIBUF
SCTP_ASSOC_SUPPORTS_PR
SCTP_ASSOC_SUPPORTS_RE_CONFIG
SCTP_AUTHINFO
SCTP_AUTH_CHUNK
SCTP_AUTH_ACTIVE_KEY
SCTP_AUTH_DEACTIVATE_KEY
SCTP_AUTH_DELETE_KEY
SCTP_AUTH_FREE_KEY
SCTP_AUTH_KEY
SCTP_AUTH_NEWKEY
SCTP_AUTH_NEW_KEY
SCTP_AUTH_NO_AUTH
SCTP_AUTOCLOSE
SCTP_AUTO_ASCONF
SCTP_CANT_STR_ASSOC
SCTP_COMM_LOST
SCTP_COMM_UP
SCTP_COMPLETE
SCTP_CONTEXT
SCTP_CURRENT_ASSOC
SCTP_DATA_SENT
SCTP_DATA_UNSENT
SCTP_DEFAULT_SEND_PARAM
SCTP_DELAYED_SACK
SCTP_DISABLE_FRAGMENTS
Expand All @@ -1114,6 +1139,7 @@ SCTP_EXTRCV
SCTP_FRAGMENT_INTERLEAVE
SCTP_FUTURE_ASSOC
SCTP_HMAC_IDENT
SCTP_INACTIVE
SCTP_INIT
SCTP_INITMSG
SCTP_I_WANT_MAPPED_V4_ADDR
Expand All @@ -1128,6 +1154,7 @@ SCTP_NODELAY
SCTP_NOTIFICATION
SCTP_NO_NEXT_MSG
SCTP_NXTINFO
SCTP_PARTIAL_DELIVERY_ABORTED
SCTP_PARTIAL_DELIVERY_POINT
SCTP_PEER_ADDR_PARAMS
SCTP_PRIMARY_ADDR
Expand All @@ -1138,6 +1165,7 @@ SCTP_PR_SCTP_NONE
SCTP_PR_SCTP_PRIO
SCTP_PR_SCTP_RTX
SCTP_PR_SCTP_TTL
SCTP_RESTART
SCTP_REUSE_PORT
SCTP_PRINFO
SCTP_RECVV_NOINFO
Expand All @@ -1156,8 +1184,16 @@ SCTP_SEND_AUTHINFO_VALID
SCTP_SEND_PRINFO_VALID
SCTP_SEND_SNDINFO_VALID
SCTP_SET_PEER_PRIMARY_ADDR
SCTP_SHUTDOWN_COMP
SCTP_SNDINFO
SCTP_SNDRCV
SCTP_STREAM_CHANGE_DENIED
SCTP_STREAM_CHANGE_FAILED
SCTP_STREAM_RESET_DENIED
SCTP_STREAM_RESET_FAILED
SCTP_STREAM_RESET_INCOMING_SSN
SCTP_STREAM_RESET_OUTGOING_SSN
SCTP_UNCONFIRMED
SCTP_UNORDERED
SCTP_USE_EXT_RCVINFO
SEEK_DATA
Expand Down Expand Up @@ -1968,6 +2004,8 @@ sched_rr_get_interval
sched_setparam
sched_setscheduler
sctphdr
sctp_adaptation_event
sctp_assoc_change
sctp_assoc_t
sctp_authinfo
sctp_bindx
Expand Down Expand Up @@ -1995,16 +2033,25 @@ sctp_gen_error_cause
sctp_initmsg
sctp_nxtinfo
sctp_opt_info
sctp_paddr_change
sctp_pdapi_event
sctp_peeloff
sctp_prinfo
sctp_rcvinfo
sctp_recvv_rn
sctp_remote_error
sctp_sender_dry_event
sctp_send_failed_event
sctp_sendv_spa
sctp_shutdown_event
sctp_sndinfo
sctp_sndrcvinfo
sctp_snd_all_completes
sctp_stream_change_event
sctp_stream_reset_event
sctp_paramhdr
sctp_pcbinfo
sctp_setadaptation
sctp_sockstat
sdallocx
seed48
Expand Down
140 changes: 140 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,100 @@ s! {
pub ss_total_sndbuf: u32,
pub ss_total_recv_buf: u32,
}

pub struct sctp_assoc_change {
pub sac_type: u16,
pub sac_flags: u16,
pub sac_length: u32,
pub sac_state: u16,
pub sac_error: u16,
pub sac_outbound_streams: u16,
pub sac_inbound_streams: u16,
pub sac_assoc_id: ::sctp_assoc_t,
pub sac_info: [u8; 0],
}

pub struct sctp_paddr_change {
pub spc_type: u16,
pub spc_flags: u16,
pub spc_length: u32,
pub spc_aaddr: ::sockaddr_storage,
pub spc_state: u32,
pub spc_error: u32,
pub spc_assoc_id: ::sctp_assoc_t,
}

pub struct sctp_remote_error {
pub sre_type: u16,
pub sre_flags: u16,
pub sre_length: u32,
pub sre_error: u16,
pub sre_assoc_id: ::sctp_assoc_t,
pub sre_data: [u8; 0],
}

pub struct sctp_send_failed_event {
pub ssfe_type: u16,
pub ssfe_flags: u16,
pub ssfe_length: u32,
pub ssfe_error: u32,
pub ssfe_info: sctp_sndinfo,
pub ssfe_assoc_id: ::sctp_assoc_t,
pub ssfe_data: [u8; 0],
}

pub struct sctp_shutdown_event {
pub sse_type: u16,
pub sse_flags: u16,
pub sse_length: u32,
pub sse_assoc_id: ::sctp_assoc_t,
}

pub struct sctp_adaptation_event {
pub sai_type: u16,
pub sai_flags: u16,
pub sai_length: u32,
pub sai_adaptation_ind: u32,
pub sai_assoc_id: ::sctp_assoc_t,
}

pub struct sctp_setadaptation {
pub ssb_adaptation_ind: u32,
}

pub struct sctp_pdapi_event {
pub pdapi_type: u16,
pub pdapi_flags: u16,
pub pdapi_length: u32,
pub pdapi_indication: u32,
pub pdapi_stream: u16,
pub pdapi_seq: u16,
pub pdapi_assoc_id: ::sctp_assoc_t,
}

pub struct sctp_sender_dry_event {
pub sender_dry_type: u16,
pub sender_dry_flags: u16,
pub sender_dry_length: u32,
pub sender_dry_assoc_id: ::sctp_assoc_t,
}

pub struct sctp_stream_reset_event {
pub strreset_type: u16,
pub strreset_flags: u16,
pub strreset_length: u32,
pub strreset_assoc_id: ::sctp_assoc_t,
pub strreset_stream_list: [u16; 0],
}

pub struct sctp_stream_change_event {
pub strchange_type: u16,
pub strchange_flags: u16,
pub strchange_length: u32,
pub strchange_assoc_id: ::sctp_assoc_t,
pub strchange_instrms: u16,
pub strchange_outstrms: u16,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -4493,6 +4587,52 @@ pub const SCTP_EXPLICIT_EOR: ::c_int = 0x00000001b;
pub const SCTP_REUSE_PORT: ::c_int = 0x00000001c;
pub const SCTP_AUTH_DEACTIVATE_KEY: ::c_int = 0x00000001d;

pub const SCTP_COMM_UP: ::c_int = 0x0001;
pub const SCTP_COMM_LOST: ::c_int = 0x0002;
pub const SCTP_RESTART: ::c_int = 0x0003;
pub const SCTP_SHUTDOWN_COMP: ::c_int = 0x0004;
pub const SCTP_CANT_STR_ASSOC: ::c_int = 0x0005;

pub const SCTP_ASSOC_SUPPORTS_PR: ::c_int = 0x01;
pub const SCTP_ASSOC_SUPPORTS_AUTH: ::c_int = 0x02;
pub const SCTP_ASSOC_SUPPORTS_ASCONF: ::c_int = 0x03;
pub const SCTP_ASSOC_SUPPORTS_MULTIBUF: ::c_int = 0x04;
pub const SCTP_ASSOC_SUPPORTS_RE_CONFIG: ::c_int = 0x05;
pub const SCTP_ASSOC_SUPPORTS_INTERLEAVING: ::c_int = 0x06;
pub const SCTP_ASSOC_SUPPORTS_MAX: ::c_int = 0x06;

pub const SCTP_ADDR_AVAILABLE: ::c_int = 0x0001;
pub const SCTP_ADDR_UNREACHABLE: ::c_int = 0x0002;
pub const SCTP_ADDR_REMOVED: ::c_int = 0x0003;
pub const SCTP_ADDR_ADDED: ::c_int = 0x0004;
pub const SCTP_ADDR_MADE_PRIM: ::c_int = 0x0005;
pub const SCTP_ADDR_CONFIRMED: ::c_int = 0x0006;

pub const SCTP_ACTIVE: ::c_int = 0x0001;
pub const SCTP_INACTIVE: ::c_int = 0x0002;
pub const SCTP_UNCONFIRMED: ::c_int = 0x0200;

pub const SCTP_DATA_UNSENT: ::c_int = 0x0001;
pub const SCTP_DATA_SENT: ::c_int = 0x0002;

pub const SCTP_PARTIAL_DELIVERY_ABORTED: ::c_int = 0x0001;

pub const SCTP_AUTH_NEW_KEY: ::c_int = 0x0001;
pub const SCTP_AUTH_NEWKEY: ::c_int = SCTP_AUTH_NEW_KEY;
pub const SCTP_AUTH_NO_AUTH: ::c_int = 0x0002;
pub const SCTP_AUTH_FREE_KEY: ::c_int = 0x0003;

pub const SCTP_STREAM_RESET_INCOMING_SSN: ::c_int = 0x0001;
pub const SCTP_STREAM_RESET_OUTGOING_SSN: ::c_int = 0x0002;
pub const SCTP_STREAM_RESET_DENIED: ::c_int = 0x0004;
pub const SCTP_STREAM_RESET_FAILED: ::c_int = 0x0008;

pub const SCTP_ASSOC_RESET_DENIED: ::c_int = 0x0004;
pub const SCTP_ASSOC_RESET_FAILED: ::c_int = 0x0008;

pub const SCTP_STREAM_CHANGE_DENIED: ::c_int = 0x0004;
pub const SCTP_STREAM_CHANGE_FAILED: ::c_int = 0x0008;

const_fn! {
{const} fn _ALIGN(p: usize) -> usize {
(p + _ALIGNBYTES) & !_ALIGNBYTES
Expand Down

0 comments on commit 6e67caa

Please sign in to comment.