Skip to content

Commit ddecba9

Browse files
committed
ppid should be u32 and network byte order.
1 parent 788c62b commit ddecba9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl SctpStream {
8484

8585
/// Send bytes on the specified SCTP stream. On success, returns the
8686
/// quantity of bytes read
87-
pub fn sendmsg(&self, msg: &[u8], ppid: u64, stream: u16) -> Result<usize> {
87+
pub fn sendmsg(&self, msg: &[u8], ppid: u32, stream: u16) -> Result<usize> {
8888
return self.0.sendmsg::<SocketAddr>(msg, None, ppid, stream, 0);
8989
}
9090

@@ -233,7 +233,7 @@ impl SctpEndpoint {
233233

234234
/// Send data in Sctp style, to the provided address on the stream `stream`.
235235
/// On success, returns the quantity on bytes sent
236-
pub fn send_to<A: ToSocketAddrs>(&self, msg: &mut [u8], address: A, ppid: u64, stream: u16) -> Result<usize> {
236+
pub fn send_to<A: ToSocketAddrs>(&self, msg: &mut [u8], address: A, ppid: u32, stream: u16) -> Result<usize> {
237237
return self.0.sendmsg(msg, Some(address), ppid, stream, 0);
238238
}
239239

src/sctpsock.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl SctpSocket {
358358

359359
/// Send data in Sctp style, to the provided address (may be `None` if the socket is connected), on the stream `stream`, with the TTL `ttl`.
360360
/// On success, returns the quantity on bytes sent
361-
pub fn sendmsg<A: ToSocketAddrs>(&self, msg: &[u8], address: Option<A>, ppid: u64, stream: u16, ttl: libc::c_ulong) -> Result<usize> {
361+
pub fn sendmsg<A: ToSocketAddrs>(&self, msg: &[u8], address: Option<A>, ppid: u32, stream: u16, ttl: libc::c_ulong) -> Result<usize> {
362362
let len = msg.len() as libc::size_t;
363363
let (raw_addr, addr_len) = match address {
364364
Some(a) => {
@@ -367,8 +367,9 @@ impl SctpSocket {
367367
},
368368
None => (std::ptr::null_mut(), 0)
369369
};
370+
let ppid = ppid.to_be();
370371
unsafe {
371-
return match sctp_sys::sctp_sendmsg(self.0, msg.as_ptr() as *const libc::c_void, len, raw_addr, addr_len, ppid, 0, stream, ttl, 0) {
372+
return match sctp_sys::sctp_sendmsg(self.0, msg.as_ptr() as *const libc::c_void, len, raw_addr, addr_len, ppid as libc::c_ulong, 0, stream, ttl, 0) {
372373
res if res > 0 => Ok(res as usize),
373374
_ => Err(Error::last_os_error())
374375
};

0 commit comments

Comments
 (0)