Skip to content

Commit 73c2437

Browse files
committed
Add sock_extended_err and associated constants from errqueue.h
sock_extended_err is a struct returned as a control message when the sockopt IP_RECVERR is set, when recvmsg has the MSG_ERRQUEUE flag set. IP_RECVERR and MSG_ERRQUEUE are constants both already defined here.
1 parent 104a3f2 commit 73c2437

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ fn test_linux(target: &str) {
21892189
cfg:
21902190
"asm/mman.h",
21912191
"linux/dccp.h",
2192+
"linux/errqueue.h",
21922193
"linux/falloc.h",
21932194
"linux/fs.h",
21942195
"linux/futex.h",

src/unix/linux_like/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ s! {
199199
pub msg_hdr: ::msghdr,
200200
pub msg_len: ::c_uint,
201201
}
202+
203+
pub struct sock_extended_err {
204+
pub ee_errno: u32,
205+
pub ee_origin: u8,
206+
pub ee_type: u8,
207+
pub ee_code: u8,
208+
pub ee_pad: u8,
209+
pub ee_info: u32,
210+
pub ee_data: u32
211+
}
202212
}
203213

204214
s_no_extra_traits! {
@@ -1189,6 +1199,13 @@ pub const ARPHRD_IEEE802154: u16 = 804;
11891199
pub const ARPHRD_VOID: u16 = 0xFFFF;
11901200
pub const ARPHRD_NONE: u16 = 0xFFFE;
11911201

1202+
pub const SO_EE_ORIGIN_NONE: u8 = 0;
1203+
pub const SO_EE_ORIGIN_LOCAL: u8 = 1;
1204+
pub const SO_EE_ORIGIN_ICMP: u8 = 2;
1205+
pub const SO_EE_ORIGIN_ICMP6: u8 = 3;
1206+
pub const SO_EE_ORIGIN_TXSTATUS: u8 = 4;
1207+
pub const SO_EE_ORIGIN_TIMESTAMPING: u8 = SO_EE_ORIGIN_TXSTATUS;
1208+
11921209
const_fn! {
11931210
{const} fn CMSG_ALIGN(len: usize) -> usize {
11941211
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
@@ -1294,6 +1311,10 @@ f! {
12941311
pub fn IPTOS_ECN(x: u8) -> u8 {
12951312
x & ::IPTOS_ECN_MASK
12961313
}
1314+
1315+
pub fn SO_EE_OFFENDER(ee: *const ::sock_extended_err) -> *mut ::sockaddr {
1316+
ee.offset(1) as *mut ::sockaddr
1317+
}
12971318
}
12981319

12991320
extern "C" {

0 commit comments

Comments
 (0)