• Home
  • Raw
  • Download

Lines Matching full:libc

32 /// Convert a std::net::Ipv4Addr into the libc form.
34 pub(crate) const fn ipv4addr_to_libc(addr: net::Ipv4Addr) -> libc::in_addr { in ipv4addr_to_libc()
35 libc::in_addr { in ipv4addr_to_libc()
40 /// Convert a std::net::Ipv6Addr into the libc form.
42 pub(crate) const fn ipv6addr_to_libc(addr: &net::Ipv6Addr) -> libc::in6_addr { in ipv6addr_to_libc()
43 libc::in6_addr { in ipv6addr_to_libc()
60 Unix = libc::AF_UNIX,
62 Inet = libc::AF_INET,
64 Inet6 = libc::AF_INET6,
67 Netlink = libc::AF_NETLINK,
70 Route = libc::PF_ROUTE,
73 Packet = libc::AF_PACKET,
76 System = libc::AF_SYSTEM,
79 Ax25 = libc::AF_AX25,
82 Ipx = libc::AF_IPX,
85 AppleTalk = libc::AF_APPLETALK,
89 NetRom = libc::AF_NETROM,
95 Bridge = libc::AF_BRIDGE,
98 AtmPvc = libc::AF_ATMPVC,
101 X25 = libc::AF_X25,
106 Rose = libc::AF_ROSE,
109 Decnet = libc::AF_DECnet,
112 NetBeui = libc::AF_NETBEUI,
116 Security = libc::AF_SECURITY,
119 Key = libc::AF_KEY,
122 Ash = libc::AF_ASH,
125 Econet = libc::AF_ECONET,
128 AtmSvc = libc::AF_ATMSVC,
131 Rds = libc::AF_RDS,
134 Sna = libc::AF_SNA,
137 Irda = libc::AF_IRDA,
140 Pppox = libc::AF_PPPOX,
144 Wanpipe = libc::AF_WANPIPE,
147 Llc = libc::AF_LLC,
150 Ib = libc::AF_IB,
153 Mpls = libc::AF_MPLS,
156 Can = libc::AF_CAN,
159 Tipc = libc::AF_TIPC,
168 Bluetooth = libc::AF_BLUETOOTH,
172 Iucv = libc::AF_IUCV,
175 RxRpc = libc::AF_RXRPC,
184 Isdn = libc::AF_ISDN,
187 Phonet = libc::AF_PHONET,
190 Ieee802154 = libc::AF_IEEE802154,
194 Caif = libc::AF_CAIF,
197 Alg = libc::AF_ALG,
200 Nfc = libc::AF_NFC,
203 Vsock = libc::AF_VSOCK,
206 ImpLink = libc::AF_IMPLINK,
209 Pup = libc::AF_PUP,
212 Chaos = libc::AF_CHAOS,
215 Ns = libc::AF_NS,
218 Iso = libc::AF_ISO,
221 Datakit = libc::AF_DATAKIT,
224 Ccitt = libc::AF_CCITT,
227 Dli = libc::AF_DLI,
230 Lat = libc::AF_LAT,
233 Hylink = libc::AF_HYLINK,
236 Link = libc::AF_LINK,
239 Coip = libc::AF_COIP,
242 Cnt = libc::AF_CNT,
245 Natm = libc::AF_NATM,
248 Unspec = libc::AF_UNSPEC,
252 /// Create a new `AddressFamily` from an integer value retrieved from `libc`, usually from
259 libc::AF_UNIX => Some(AddressFamily::Unix), in from_i32()
260 libc::AF_INET => Some(AddressFamily::Inet), in from_i32()
261 libc::AF_INET6 => Some(AddressFamily::Inet6), in from_i32()
263 libc::AF_NETLINK => Some(AddressFamily::Netlink), in from_i32()
265 libc::AF_SYSTEM => Some(AddressFamily::System), in from_i32()
267 libc::PF_ROUTE => Some(AddressFamily::Route), in from_i32()
269 libc::AF_PACKET => Some(AddressFamily::Packet), in from_i32()
271 libc::AF_LINK => Some(AddressFamily::Link), in from_i32()
273 libc::AF_VSOCK => Some(AddressFamily::Vsock), in from_i32()
284 sun: libc::sockaddr_un,
308 unsafe fn get(sun: &'a libc::sockaddr_un, sun_len: u8) -> Self { in get()
309 assert!(sun_len as usize >= offset_of!(libc::sockaddr_un, sun_path)); in get()
311 sun_len as usize - offset_of!(libc::sockaddr_un, sun_path); in get()
350 let mut ret = libc::sockaddr_un { in new()
362 + offset_of!(libc::sockaddr_un, sun_path)) in new()
390 let mut ret = libc::sockaddr_un { in new_abstract()
399 (path.len() + 1 + offset_of!(libc::sockaddr_un, sun_path)) in new_abstract()
418 let ret = libc::sockaddr_un { in new_unnamed()
424 offset_of!(libc::sockaddr_un, sun_path).try_into().unwrap(); in new_unnamed()
441 sun: libc::sockaddr_un, in from_raw_parts()
494 self.sun_len() as usize - offset_of!(libc::sockaddr_un, sun_path) in path_len()
498 pub fn as_ptr(&self) -> *const libc::sockaddr_un { in as_ptr()
503 pub fn as_mut_ptr(&mut self) -> *mut libc::sockaddr_un { in as_mut_ptr()
531 fn len(&self) -> libc::socklen_t { in len()
536 addr: *const libc::sockaddr, in from_raw()
537 len: Option<libc::socklen_t>, in from_raw()
543 if (l as usize) < offset_of!(libc::sockaddr_un, sun_path) in from_raw()
544 || l > u8::MAX as libc::socklen_t in from_raw()
549 if unsafe { (*addr).sa_family as i32 != libc::AF_UNIX } { in from_raw()
552 let mut su: libc::sockaddr_un = unsafe { mem::zeroed() }; in from_raw()
553 let sup = &mut su as *mut libc::sockaddr_un as *mut u8; in from_raw()
561 mem::size_of::<libc::sockaddr_un>() as libc::socklen_t in from_raw()
564 let su_len = unsafe { len.unwrap_or((*addr).sa_len as libc::socklen_t) }; in from_raw()
571 fn size() -> libc::socklen_t in size()
575 mem::size_of::<libc::sockaddr_un>() as libc::socklen_t in size()
597 impl AsRef<libc::sockaddr_un> for UnixAddr {
598 fn as_ref(&self) -> &libc::sockaddr_un { in as_ref()
642 /// Most implementors also implement `AsRef<libc::XXX>` to access their
647 fn as_ptr(&self) -> *const libc::sockaddr { in as_ptr()
648 self as *const Self as *const libc::sockaddr in as_ptr() constant
659 /// `libc::sockaddr`. For example, `libc::sockaddr_in`,
660 /// `libc::sockaddr_in6`, etc.
673 addr: *const libc::sockaddr, in from_raw()
674 len: Option<libc::socklen_t>, in from_raw()
699 (*(self as *const Self as *const libc::sockaddr)).sa_family as i32 in family() constant
710 fn len(&self) -> libc::socklen_t {
715 (*(self as *const Self as *const libc::sockaddr)).sa_len
724 fn len(&self) -> libc::socklen_t {
728 mem::size_of_val(self) as libc::socklen_t
734 fn size() -> libc::socklen_t in size()
738 mem::size_of::<Self>() as libc::socklen_t in size()
771 fn as_mut_ptr(&mut self) -> *mut libc::sockaddr { in as_mut_ptr()
781 fn as_ptr(&self) -> *const libc::sockaddr { in as_ptr()
786 _: *const libc::sockaddr, in from_raw()
787 _: Option<libc::socklen_t>, in from_raw()
799 fn len(&self) -> libc::socklen_t { in len()
808 pub struct SockaddrIn(libc::sockaddr_in);
822 Self(libc::sockaddr_in { in new()
832 sin_addr: libc::in_addr { in new()
851 addr: *const libc::sockaddr, in from_raw()
852 len: Option<libc::socklen_t>, in from_raw()
858 if l != mem::size_of::<libc::sockaddr_in>() as libc::socklen_t { in from_raw()
862 if unsafe { (*addr).sa_family as i32 != libc::AF_INET } { in from_raw()
870 impl AsRef<libc::sockaddr_in> for SockaddrIn {
871 fn as_ref(&self) -> &libc::sockaddr_in { in as_ref()
896 Self(libc::sockaddr_in { in from()
903 sin_len: mem::size_of::<libc::sockaddr_in>() as u8, in from()
935 pub struct SockaddrIn6(libc::sockaddr_in6);
977 addr: *const libc::sockaddr, in from_raw()
978 len: Option<libc::socklen_t>, in from_raw()
984 if l != mem::size_of::<libc::sockaddr_in6>() as libc::socklen_t { in from_raw()
988 if unsafe { (*addr).sa_family as i32 != libc::AF_INET6 } { in from_raw()
996 impl AsRef<libc::sockaddr_in6> for SockaddrIn6 {
997 fn as_ref(&self) -> &libc::sockaddr_in6 { in as_ref()
1021 Self(libc::sockaddr_in6 { in from()
1028 sin6_len: mem::size_of::<libc::sockaddr_in6>() as u8, in from()
1099 ss: libc::sockaddr_storage,
1107 addr: *const libc::sockaddr, in from_raw()
1108 l: Option<libc::socklen_t>, in from_raw()
1118 if ulen < offset_of!(libc::sockaddr, sa_data) in from_raw()
1119 || ulen > mem::size_of::<libc::sockaddr_storage>() in from_raw()
1123 let mut ss: libc::sockaddr_storage = unsafe { mem::zeroed() }; in from_raw()
1124 let ssp = &mut ss as *mut libc::sockaddr_storage as *mut u8; in from_raw()
1131 if i32::from(ss.ss_family) == libc::AF_UNIX { in from_raw()
1135 (*(&mut ss as *mut libc::sockaddr_storage in from_raw()
1148 libc::AF_ALG => unsafe { in from_raw()
1152 libc::AF_INET => unsafe { in from_raw()
1156 libc::AF_INET6 => unsafe { in from_raw()
1161 libc::AF_LINK => unsafe { in from_raw()
1165 libc::AF_NETLINK => unsafe { in from_raw()
1170 libc::AF_PACKET => unsafe { in from_raw()
1174 libc::AF_SYSTEM => unsafe { in from_raw()
1178 libc::AF_VSOCK => unsafe { in from_raw()
1187 fn len(&self) -> libc::socklen_t { in len()
1192 None => mem::size_of_val(self) as libc::socklen_t, in len()
1218 && self.len() >= mem::size_of::<$libc_ty>() as libc::socklen_t
1230 && self.len() >= mem::size_of::<$libc_ty>() as libc::socklen_t
1250 let p = unsafe{ &self.ss as *const libc::sockaddr_storage }; in as_unix_addr()
1262 || len < offset_of!(libc::sockaddr_un, sun_path) in as_unix_addr()
1263 || len > mem::size_of::<libc::sockaddr_un>() in as_unix_addr()
1279 let p = unsafe{ &self.ss as *const libc::sockaddr_storage }; in as_unix_addr_mut()
1291 || len < offset_of!(libc::sockaddr_un, sun_path) in as_unix_addr_mut()
1292 || len > mem::size_of::<libc::sockaddr_un>() in as_unix_addr_mut()
1302 AddressFamily::Alg, libc::sockaddr_alg, alg}
1308 AddressFamily::Packet, libc::sockaddr_ll, dl}
1314 AddressFamily::Link, libc::sockaddr_dl, dl}
1319 AddressFamily::Inet, libc::sockaddr_in, sin}
1324 AddressFamily::Inet6, libc::sockaddr_in6, sin6}
1328 AddressFamily::Netlink, libc::sockaddr_nl, nl}
1333 AddressFamily::System, libc::sockaddr_ctl, sctl}
1337 AddressFamily::Vsock, libc::sockaddr_vm, vsock}
1355 libc::AF_ALG => self.alg.fmt(f), in fmt()
1357 libc::AF_INET => self.sin.fmt(f), in fmt()
1359 libc::AF_INET6 => self.sin6.fmt(f), in fmt()
1362 libc::AF_LINK => self.dl.fmt(f), in fmt()
1364 libc::AF_NETLINK => self.nl.fmt(f), in fmt()
1367 libc::AF_PACKET => self.dl.fmt(f), in fmt()
1370 libc::AF_SYSTEM => self.sctl.fmt(f), in fmt()
1371 libc::AF_UNIX => self.su.fmt(f), in fmt()
1373 libc::AF_VSOCK => self.vsock.fmt(f), in fmt()
1417 libc::AF_ALG => self.alg.hash(s), in hash()
1419 libc::AF_INET => self.sin.hash(s), in hash()
1421 libc::AF_INET6 => self.sin6.hash(s), in hash()
1424 libc::AF_LINK => self.dl.hash(s), in hash()
1426 libc::AF_NETLINK => self.nl.hash(s), in hash()
1429 libc::AF_PACKET => self.dl.hash(s), in hash()
1432 libc::AF_SYSTEM => self.sctl.hash(s), in hash()
1433 libc::AF_UNIX => self.su.hash(s), in hash()
1435 libc::AF_VSOCK => self.vsock.hash(s), in hash()
1447 (libc::AF_ALG, libc::AF_ALG) => self.alg == other.alg, in eq()
1449 (libc::AF_INET, libc::AF_INET) => self.sin == other.sin, in eq()
1451 (libc::AF_INET6, libc::AF_INET6) => self.sin6 == other.sin6, in eq()
1454 (libc::AF_LINK, libc::AF_LINK) => self.dl == other.dl, in eq()
1456 (libc::AF_NETLINK, libc::AF_NETLINK) => self.nl == other.nl, in eq()
1459 (libc::AF_PACKET, libc::AF_PACKET) => self.dl == other.dl, in eq()
1462 (libc::AF_SYSTEM, libc::AF_SYSTEM) => self.sctl == other.sctl, in eq()
1463 (libc::AF_UNIX, libc::AF_UNIX) => self.su == other.su, in eq()
1465 (libc::AF_VSOCK, libc::AF_VSOCK) => self.vsock == other.vsock, in eq()
1482 fn as_mut_ptr(&mut self) -> *mut libc::sockaddr { in as_mut_ptr()
1483 self as *mut Self as *mut libc::sockaddr in as_mut_ptr()
1492 use libc::{sa_family_t, sockaddr_nl};
1530 addr: *const libc::sockaddr, in from_raw()
1531 len: Option<libc::socklen_t>, in from_raw()
1537 if l != mem::size_of::<libc::sockaddr_nl>() as libc::socklen_t { in from_raw()
1541 if unsafe { (*addr).sa_family as i32 != libc::AF_NETLINK } { in from_raw()
1548 impl AsRef<libc::sockaddr_nl> for NetlinkAddr {
1549 fn as_ref(&self) -> &libc::sockaddr_nl { in as_ref()
1564 use libc::{sockaddr_alg, AF_ALG};
1577 addr: *const libc::sockaddr, in from_raw()
1578 l: Option<libc::socklen_t>, in from_raw()
1584 if l != mem::size_of::<libc::sockaddr_alg>() as libc::socklen_t in from_raw()
1589 if unsafe { (*addr).sa_family as i32 != libc::AF_ALG } { in from_raw()
1596 impl AsRef<libc::sockaddr_alg> for AlgAddr {
1597 fn as_ref(&self) -> &libc::sockaddr_alg { in as_ref()
1685 use libc::{self, c_uchar};
1691 // FIXME: Move type into `libc`
1713 pub struct SysControlAddr(pub(in super::super) libc::sockaddr_ctl);
1717 unsafe fn from_raw(addr: *const libc::sockaddr, len: Option<libc::socklen_t>)
1721 if l != mem::size_of::<libc::sockaddr_ctl>() as libc::socklen_t {
1725 if unsafe { (*addr).sa_family as i32 != libc::AF_SYSTEM } {
1732 impl AsRef<libc::sockaddr_ctl> for SysControlAddr {
1733 fn as_ref(&self) -> &libc::sockaddr_ctl {
1742 let addr = libc::sockaddr_ctl {
1743 sc_len: mem::size_of::<libc::sockaddr_ctl>() as c_uchar,
1745 ss_sysaddr: libc::AF_SYS_CONTROL as u16,
1798 pub struct LinkAddr(pub(in super::super) libc::sockaddr_ll);
1857 unsafe fn from_raw(addr: *const libc::sockaddr,
1858 len: Option<libc::socklen_t>)
1862 if l != mem::size_of::<libc::sockaddr_ll>() as libc::socklen_t {
1866 if unsafe { (*addr).sa_family as i32 != libc::AF_PACKET } {
1873 impl AsRef<libc::sockaddr_ll> for LinkAddr {
1874 fn as_ref(&self) -> &libc::sockaddr_ll {
1891 pub struct LinkAddr(pub(in super::super) libc::sockaddr_dl);
1971 unsafe fn from_raw(addr: *const libc::sockaddr,
1972 len: Option<libc::socklen_t>)
1976 if l != mem::size_of::<libc::sockaddr_dl>() as libc::socklen_t {
1980 if unsafe { (*addr).sa_family as i32 != libc::AF_LINK } {
1987 impl AsRef<libc::sockaddr_dl> for LinkAddr {
1988 fn as_ref(&self) -> &libc::sockaddr_dl {
1999 use libc::{sa_family_t, sockaddr_vm};
2015 addr: *const libc::sockaddr, in from_raw()
2016 len: Option<libc::socklen_t>, in from_raw()
2022 if l != mem::size_of::<libc::sockaddr_vm>() as libc::socklen_t { in from_raw()
2026 if unsafe { (*addr).sa_family as i32 != libc::AF_VSOCK } { in from_raw()
2033 impl AsRef<libc::sockaddr_vm> for VsockAddr {
2034 fn as_ref(&self) -> &libc::sockaddr_vm { in as_ref()
2167 let la = LinkAddr(libc::sockaddr_dl { in test_datalink_display()
2229 let sa = ptr as *const libc::sockaddr; in macos_tap() constant
2248 let sa = ptr as *const libc::sockaddr; in solarish_tap() constant
2267 let l = mem::size_of::<libc::sockaddr_dl>(); in size()
2269 let l = mem::size_of::<libc::sockaddr_ll>(); in size()
2288 mem::size_of::<libc::sockaddr_in>(), in size()
2315 mem::size_of::<libc::sockaddr_in6>(), in size()
2395 mem::size_of::<libc::sockaddr_un>(), in size()