Skip to content

Commit 2026c86

Browse files
committed
Auto merge of #1392 - stefano-garzarella:vsock, r=gnzlbg
linux: add VSOCK struct and constants Add struct sockaddr_vm and VMADDR_ constants to use VSOCK on Linux. VSOCK is present since Linux 3.9
2 parents d5a599e + 4825678 commit 2026c86

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,7 @@ fn test_linux(target: &str) {
20002000
"linux/rtnetlink.h",
20012001
"linux/seccomp.h",
20022002
"linux/sockios.h",
2003+
"linux/vm_sockets.h",
20032004
"sys/auxv.h",
20042005
}
20052006

src/unix/linux_like/linux/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,14 @@ s! {
474474
pub cookie: u32,
475475
pub len: u32
476476
}
477+
478+
pub struct sockaddr_vm {
479+
pub svm_family: ::sa_family_t,
480+
pub svm_reserved1: ::c_ushort,
481+
pub svm_port: ::c_uint,
482+
pub svm_cid: ::c_uint,
483+
pub svm_zero: [u8; 4]
484+
}
477485
}
478486

479487
s_no_extra_traits!{
@@ -2000,6 +2008,13 @@ pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5;
20002008
pub const ALG_OP_DECRYPT: ::c_int = 0;
20012009
pub const ALG_OP_ENCRYPT: ::c_int = 1;
20022010

2011+
// uapi/linux/vm_sockets.h
2012+
pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF;
2013+
pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0;
2014+
pub const VMADDR_CID_RESERVED: ::c_uint = 1;
2015+
pub const VMADDR_CID_HOST: ::c_uint = 2;
2016+
pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF;
2017+
20032018
// uapi/linux/inotify.h
20042019
pub const IN_ACCESS: u32 = 0x0000_0001;
20052020
pub const IN_MODIFY: u32 = 0x0000_0002;

0 commit comments

Comments
 (0)