Skip to content

Commit

Permalink
Auto merge of #3117 - devnexen:linux_sctp2, r=JohnTitor
Browse files Browse the repository at this point in the history
linux SCTP support part 2

Fixes #2962
  • Loading branch information
bors committed Feb 21, 2023
2 parents 90531f6 + a79c3a1 commit b86fa3d
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 5 deletions.
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,7 @@ fn test_linux(target: &str) {
"netdb.h",
"netinet/in.h",
"netinet/ip.h",
//"netinet/sctp.h",
"netinet/tcp.h",
"netinet/udp.h",
"netpacket/packet.h",
Expand Down Expand Up @@ -3431,6 +3432,11 @@ fn test_linux(target: &str) {
"ptrace_rseq_configuration" if sparc64 => true,
"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,
"sctp_stream_reset_event"
| "sctp_assoc_change"
| "sctp_remote_error"
| "sctp_send_failed"
| "sctp_send_failed_event" => true,

_ => false,
}
Expand Down
18 changes: 18 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2161,18 +2161,33 @@ SCM_J1939_PRIO
SCM_TIMESTAMP
SCM_TIMESTAMPING
SCTP_ABORT
SCTP_ADDR_ADDED
SCTP_ADDR_AVAILABLE
SCTP_ADDR_CONFIRMED
SCTP_ADDR_MADE_PRIM
SCTP_ADDR_OVER
SCTP_ADDR_POTENTIALLY_FAILED
SCTP_ADDR_REMOVED
SCTP_ADDR_UNREACHABLE
SCTP_ALL_ASSOC
SCTP_ASSOCINFO
SCTP_AUTH_CHUNK
SCTP_AUTH_ACTIVE_KEY
SCTP_AUTH_DEACTIVATE_KEY
SCTP_AUTH_DELETE_KEY
SCTP_AUTH_FREE_KEY
SCTP_AUTH_KEY
SCTP_AUTH_NEW_KEY
SCTP_AUTH_NO_AUTH
SCTP_AUTO_ASCONF
SCTP_AUTOCLOSE
SCTP_CANT_STR_ASSOC
SCTP_COMM_LOST
SCTP_COMM_UP
SCTP_CONTEXT
SCTP_CURRENT_ASSOC
SCTP_DATA_SENT
SCTP_DATA_UNSENT
SCTP_DELAYED_ACK
SCTP_DELAYED_ACK_TIME
SCTP_DELAYED_SACK
Expand All @@ -2199,6 +2214,7 @@ SCTP_MAXSEG
SCTP_NODELAY
SCTP_NOTIFICATION
SCTP_NXTINFO
SCTP_PARTIAL_DELIVERY_ABORTED
SCTP_PARTIAL_DELIVERY_POINT
SCTP_PEER_ADDR_PARAMS
SCTP_PEER_ADDR_THLDS
Expand All @@ -2214,11 +2230,13 @@ SCTP_PR_SCTP_TTL
SCTP_PRIMARY_ADDR
SCTP_RECVNXTINFO
SCTP_RECVRCVINFO
SCTP_RESTART
SCTP_REUSE_PORT
SCTP_RTOINFO
SCTP_SACK_IMMEDIATELY
SCTP_SENDALL
SCTP_SET_PEER_PRIMARY_ADDR
SCTP_SHUTDOWN_COMP
SCTP_SNDRCV
SCTP_STATUS
SCTP_STREAM_RESET_INCOMING
Expand Down
183 changes: 178 additions & 5 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub type __u16 = ::c_ushort;
pub type __s16 = ::c_short;
pub type __u32 = ::c_uint;
pub type __s32 = ::c_int;
pub type __be16 = ::__u16;

pub type Elf32_Half = u16;
pub type Elf32_Word = u32;
Expand Down Expand Up @@ -616,11 +617,11 @@ s! {
pub port: ::c_uchar,
}

pub struct in6_ifreq {
pub ifr6_addr: ::in6_addr,
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: ::c_int,
}
pub struct in6_ifreq {
pub ifr6_addr: ::in6_addr,
pub ifr6_prefixlen: u32,
pub ifr6_ifindex: ::c_int,
}

pub struct option {
pub name: *const ::c_char,
Expand Down Expand Up @@ -685,6 +686,132 @@ s! {
pub struct sctp_authinfo {
pub auth_keynumber: ::__u16,
}

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_remote_error {
pub sre_type: ::__u16,
pub sre_flags: ::__u16,
pub sre_length: ::__u32,
pub sre_error: ::__be16,
pub sre_assoc_id: ::sctp_assoc_t,
pub sre_data: [::__u8; 0],
}

pub struct sctp_send_failed {
pub ssf_type: ::__u16,
pub ssf_flags: ::__u16,
pub ssf_length: ::__u32,
pub ssf_error: ::__u32,
pub ssf_info: sctp_sndrcvinfo,
pub ssf_assoc_id: ::sctp_assoc_t,
pub ssf_data: [::__u8; 0],
}

pub struct sctp_send_failed_event {
pub ssf_type: ::__u16,
pub ssf_flags: ::__u16,
pub ssf_length: ::__u32,
pub ssf_error: ::__u32,
pub ssfe_info: sctp_sndinfo,
pub ssf_assoc_id: ::sctp_assoc_t,
pub ssf_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_pdapi_event {
pub pdapi_type: ::__u16,
pub pdapi_flags: ::__u16,
pub pdapi_length: ::__u32,
pub pdapi_indication: ::__u32,
pub pdapi_assoc_id: ::sctp_assoc_t,
pub pdapi_stream: ::__u32,
pub pdapi_seq: ::__u32,
}

pub struct sctp_authkey_event {
pub auth_type: ::__u16,
pub auth_flags: ::__u16,
pub auth_length: ::__u32,
pub auth_keynumber: ::__u16,
pub auth_altkeynumber: ::__u16,
pub auth_indication: ::__u32,
pub auth_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_assoc_reset_event {
pub assocreset_type: ::__u16,
pub assocreset_flags: ::__u16,
pub assocreset_length: ::__u32,
pub assocreset_assoc_id: ::sctp_assoc_t,
pub assocreset_local_tsn: ::__u32,
pub assocreset_remote_tsn: ::__u32,
}

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,
}

pub struct sctp_event_subscribe {
pub sctp_data_io_event: ::__u8,
pub sctp_association_event: ::__u8,
pub sctp_address_event: ::__u8,
pub sctp_send_failure_event: ::__u8,
pub sctp_peer_error_event: ::__u8,
pub sctp_shutdown_event: ::__u8,
pub sctp_partial_delivery_event: ::__u8,
pub sctp_adaptation_layer_event: ::__u8,
pub sctp_authentication_event: ::__u8,
pub sctp_sender_dry_event: ::__u8,
pub sctp_stream_reset_event: ::__u8,
pub sctp_assoc_reset_event: ::__u8,
pub sctp_stream_change_event: ::__u8,
pub sctp_send_failure_event_event: ::__u8,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -798,6 +925,17 @@ s_no_extra_traits! {
#[cfg(not(libc_union))]
pub ifr_ifru: ::sockaddr,
}

#[cfg_attr(libc_packedN, repr(packed(4)))]
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: ::c_int,
pub spc_error: ::c_int,
pub spc_assoc_id: ::sctp_assoc_t,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1221,6 +1359,18 @@ cfg_if! {
.finish()
}
}
impl ::fmt::Debug for sctp_paddr_change {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sctp_paddr_change")
.field("spc_type", &{self.spc_type})
.field("spc_flags", &{self.spc_flags})
.field("spc_aaddr", &{self.spc_aaddr})
.field("spc_state", &{self.spc_state})
.field("spc_error", &{self.spc_error})
.field("spc_assoc_id", &{self.spc_assoc_id})
.finish()
}
}
}
}

Expand Down Expand Up @@ -3788,6 +3938,29 @@ pub const SCTP_PR_SCTP_ALL: ::c_int = 1 << 7;
pub const SCTP_NOTIFICATION: ::c_int = MSG_NOTIFICATION;
pub const SCTP_EOF: ::c_int = ::MSG_FIN;

pub const SCTP_COMM_UP: ::c_int = 0;
pub const SCTP_COMM_LOST: ::c_int = 1;
pub const SCTP_RESTART: ::c_int = 2;
pub const SCTP_SHUTDOWN_COMP: ::c_int = 3;
pub const SCTP_CANT_STR_ASSOC: ::c_int = 4;

pub const SCTP_ADDR_AVAILABLE: ::c_int = 0;
pub const SCTP_ADDR_UNREACHABLE: ::c_int = 1;
pub const SCTP_ADDR_REMOVED: ::c_int = 2;
pub const SCTP_ADDR_ADDED: ::c_int = 3;
pub const SCTP_ADDR_MADE_PRIM: ::c_int = 4;
pub const SCTP_ADDR_CONFIRMED: ::c_int = 5;
pub const SCTP_ADDR_POTENTIALLY_FAILED: ::c_int = 6;

pub const SCTP_DATA_UNSENT: ::c_int = 0;
pub const SCTP_DATA_SENT: ::c_int = 1;

pub const SCTP_PARTIAL_DELIVERY_ABORTED: ::c_int = 0;

pub const SCTP_AUTH_NEW_KEY: ::c_int = 0;
pub const SCTP_AUTH_FREE_KEY: ::c_int = 1;
pub const SCTP_AUTH_NO_AUTH: ::c_int = 2;

f! {
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
Expand Down

0 comments on commit b86fa3d

Please sign in to comment.