1#![allow(non_camel_case_types)]
2
3use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_void};
4
5pub const DLPI_PHYSADDR_MAX: usize = 64;
7
8pub const DLPI_EXCL: c_uint = 0x0001;
12pub const DLPI_PASSIVE: c_uint = 0x0002;
14pub const DLPI_RAW: c_uint = 0x0004;
16pub const DLPI_SERIAL: c_uint = 0x0008;
18pub const DLPI_NOATTACH: c_uint = 0x0010;
20pub const DLPI_NATIVE: c_uint = 0x0020;
22pub const DLPI_DEVONLY: c_uint = 0x0040;
24pub const DLPI_DEVIPNET: c_uint = 0x0080;
26pub const DLPI_IPNETINFO: c_uint = 0x0100;
28pub const DL_PROMISC_PHYS: c_uint = 0x01;
30pub const DL_PROMISC_SAP: c_uint = 0x02;
32pub const DL_PROMISC_MULTI: c_uint = 0x03;
34pub const DL_PROMISC_RX_ONLY: c_uint = 0x04;
36
37pub const DLPI_SUCCESS: c_int = 10000;
39pub const DLPI_EINVAL: c_int = 10001;
41pub const DLPI_ELINKNAMEINVAL: c_int = 10002;
43pub const DLPI_ENOLINK: c_int = 10003;
45pub const DLPI_EBADLINK: c_int = 10004;
47pub const DLPI_EINHANDLE: c_int = 10005;
49pub const DLPI_ETIMEDOUT: c_int = 10006;
51pub const DLPI_EVERNOTSUP: c_int = 10007;
53pub const DLPI_EMODENOTSUP: c_int = 10008;
55pub const DLPI_EUNAVAILSAP: c_int = 10009;
57pub const DLPI_FAILURE: c_int = 10010;
59pub const DLPI_ENOTSTYLE2: c_int = 10011;
61pub const DLPI_EBADMSG: c_int = 10012;
63pub const DLPI_ERAWNOTSUP: c_int = 10013;
65pub const DLPI_ENOTEINVAL: c_int = 10014;
67pub const DLPI_ENOTENOTSUP: c_int = 10015;
69pub const DLPI_ENOTEIDINVAL: c_int = 10016;
71pub const DLPI_EIPNETINFONOTSUP: c_int = 10017;
73
74#[repr(C)]
76#[derive(Debug)]
77pub struct dlpi_sendinfo_t {
78 pub dsi_sap: c_uint,
80 pub dsi_prio: dl_priority_t,
82}
83
84#[repr(C)]
86pub struct dlpi_recvinfo_t {
87 pub dri_destaddr: [c_uchar; DLPI_PHYSADDR_MAX],
88 pub dri_destaddrlen: c_uchar,
89 pub dri_destaddrtype: dlpi_addrtype_t,
90 pub dri_totmsglen: usize,
91}
92
93impl Default for dlpi_recvinfo_t {
94 fn default() -> Self {
95 dlpi_recvinfo_t {
96 dri_destaddr: [0; DLPI_PHYSADDR_MAX],
97 dri_destaddrlen: 0,
98 dri_destaddrtype: dlpi_addrtype_t::DLPI_ADDRTYPE_UNICAST,
99 dri_totmsglen: 0,
100 }
101 }
102}
103
104#[repr(C)]
106pub enum dlpi_addrtype_t {
107 DLPI_ADDRTYPE_UNICAST,
108 DLPI_ADDRTYPE_GROUP,
109}
110
111#[repr(C)]
113#[derive(Debug)]
114pub struct dl_priority_t {
115 pub dl_min: u32,
116 pub dl_max: u32,
117}
118
119pub const DL_SYSERR: c_int = 0x04;
121
122#[derive(Clone)]
124pub enum dlpi_handle_t {}
125unsafe impl Send for dlpi_handle_t {}
126unsafe impl Sync for dlpi_handle_t {}
127
128extern "C" {
129 pub fn dlpi_open(
136 linkname: *const c_char,
137 dhp: *mut *mut dlpi_handle_t,
138 flags: c_uint,
139 ) -> i32;
140
141 pub fn dlpi_close(dh: *mut dlpi_handle_t);
143
144 pub fn dlpi_send(
147 dh: *mut dlpi_handle_t,
148 daddrp: *const c_void,
149 daddrlen: usize,
150 msgbuf: *const c_void,
151 msglen: usize,
152 sendp: *const dlpi_sendinfo_t,
153 ) -> i32;
154
155 pub fn dlpi_recv(
158 dh: *mut dlpi_handle_t,
159 saddrp: *mut c_void,
160 saddrlenp: *mut usize,
161 msgbuf: *mut c_void,
162 msglenp: *mut usize,
163 msec: c_int,
164 recvp: *mut dlpi_recvinfo_t,
165 ) -> i32;
166
167 pub fn dlpi_bind(
170 dh: *mut dlpi_handle_t,
171 sap: c_uint,
172 boundsap: *mut c_uint,
173 ) -> i32;
174
175 pub fn dlpi_enabmulti(
178 dh: *mut dlpi_handle_t,
179 addrp: *const c_void,
180 addrlen: usize,
181 ) -> i32;
182
183 pub fn dlpi_disabmulti(
186 dh: *mut dlpi_handle_t,
187 addrp: *const c_void,
188 addrlen: usize,
189 ) -> i32;
190
191 pub fn dlpi_promiscon(dh: *mut dlpi_handle_t, level: c_uint) -> i32;
194
195 pub fn dlpi_promiscoff(dh: *mut dlpi_handle_t, level: c_uint) -> i32;
198
199 pub fn dlpi_fd(dh: *mut dlpi_handle_t) -> i32;
202
203}
204
205pub fn null_dlpi_handle() -> *mut dlpi_handle_t {
208 std::ptr::null_mut::<dlpi_handle_t>()
209}