1#![no_std]
18#![cfg_attr(docs_rs, feature(doc_auto_cfg))]
19#![allow(non_upper_case_globals)]
20#![allow(non_camel_case_types)]
21#![allow(non_snake_case)]
22
23pub mod config;
24
25include!(concat!(env!("OUT_DIR"), "/autoconfig.rs"));
29
30#[repr(C)]
31#[derive(Debug, Copy, Clone)]
32pub struct csp_timestamp_t {
33 pub tv_sec: u32,
34 pub tv_nsec: u32,
35}
36
37#[doc = "CSP identifier/header."]
38#[repr(C)]
39#[derive(Debug, Copy, Clone, Default)]
40pub struct csp_id_t {
41 pub pri: u8,
42 pub flags: u8,
43 pub src: u16,
44 pub dst: u16,
45 pub dport: u8,
46 pub sport: u8,
47}
48
49#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"]
50#[repr(C)]
51#[derive(Copy, Clone)]
52pub struct csp_packet_s {
53 pub packet_info: csp_packet_s_anon_union,
54 pub length: u16,
55 pub id: csp_id_t,
56 pub next: *mut csp_packet_s,
57 #[doc = " Additional header bytes, to prepend packed data before transmission\n This must be minimum 6 bytes to accomodate CSP 2.0. But some implementations\n require much more scratch working area for encryption for example.\n\n Ultimately after csp_id_pack() this area will be filled with the CSP header"]
58 pub header: [u8; 8usize],
59 pub packet_data_union: csp_packet_s_data_union,
60}
61
62#[repr(C)]
63#[derive(Copy, Clone)]
64pub union csp_packet_s_anon_union {
65 pub rdp_only: csp_packet_s_anon_union_field_rdp_only,
66 pub rx_tx_only: csp_packet_s_anon_union_field_rx_tx_only,
67}
68
69impl Default for csp_packet_s_anon_union {
70 fn default() -> Self {
71 Self {
72 rdp_only: Default::default(),
73 }
74 }
75}
76
77#[repr(C)]
78#[derive(Debug, Copy, Clone)]
79pub struct csp_packet_s_anon_union_field_rdp_only {
80 pub rdp_quarantine: u32,
81 pub timestamp_tx: u32,
82 pub timestamp_rx: u32,
83 pub conn: *mut csp_conn_s,
84}
85
86impl Default for csp_packet_s_anon_union_field_rdp_only {
87 fn default() -> Self {
88 Self {
89 rdp_quarantine: Default::default(),
90 timestamp_tx: Default::default(),
91 timestamp_rx: Default::default(),
92 conn: core::ptr::null_mut(),
93 }
94 }
95}
96
97#[repr(C)]
98#[derive(Debug, Copy, Clone)]
99pub struct csp_packet_s_anon_union_field_rx_tx_only {
100 pub rx_count: u16,
101 pub remain: u16,
102 pub cfpid: u32,
103 pub last_used: u32,
104 pub frame_begin: *mut u8,
105 pub frame_length: u16,
106}
107
108impl Default for csp_packet_s_anon_union_field_rx_tx_only {
109 fn default() -> Self {
110 Self {
111 rx_count: Default::default(),
112 remain: Default::default(),
113 cfpid: Default::default(),
114 last_used: Default::default(),
115 frame_begin: core::ptr::null_mut(),
116 frame_length: Default::default(),
117 }
118 }
119}
120
121#[doc = " Data part of packet:"]
122#[repr(C)]
123#[derive(Copy, Clone)]
124pub union csp_packet_s_data_union {
125 pub data: [u8; CSP_BUFFER_SIZE],
126 pub data16: [u16; CSP_BUFFER_SIZE / 2usize],
127 pub data32: [u32; CSP_BUFFER_SIZE / 4usize],
128}
129
130impl Default for csp_packet_s_data_union {
131 fn default() -> Self {
132 Self {
133 data: [0; CSP_BUFFER_SIZE],
134 }
135 }
136}
137
138#[doc = " CSP Packet.\n\n This structure is constructed to fit with all interface and protocols to prevent the\n need to copy data (zero copy).\n\n .. note:: In most cases a CSP packet cannot be reused in case of send failure, because the\n \t\t\t lower layers may add additional data causing increased length (e.g. CRC32), convert\n \t\t\t the CSP id to different endian (e.g. I2C), etc.\n"]
139pub type csp_packet_t = csp_packet_s;
140
141pub type csp_queue_handle_t = *mut core::ffi::c_void;
142pub type csp_static_queue_t = *mut core::ffi::c_void;
143
144#[doc = " @brief Connection struct"]
145#[repr(C)]
146#[derive(Debug, Copy, Clone)]
147pub struct csp_socket_s {
148 pub rx_queue: csp_queue_handle_t,
149 pub rx_queue_static: csp_static_queue_t,
150 pub rx_queue_static_data:
151 [core::ffi::c_char; CSP_CONN_RXQUEUE_LEN * core::mem::size_of::<*const csp_packet_s>()],
152 pub opts: u32,
153}
154
155impl Default for csp_socket_s {
156 fn default() -> Self {
157 Self {
158 rx_queue: core::ptr::null_mut(),
159 rx_queue_static: core::ptr::null_mut(),
160 rx_queue_static_data: [0; CSP_CONN_RXQUEUE_LEN
161 * core::mem::size_of::<*const csp_packet_s>()],
162 opts: Default::default(),
163 }
164 }
165}
166
167#[doc = " Forward declaration of socket structure"]
168pub type csp_socket_t = csp_socket_s;
169
170#[doc = " Forward declaration of connection structure"]
171pub type csp_conn_t = csp_conn_s;
172
173pub type atomic_int = u32;
174
175#[doc = " Connection states"]
176pub type csp_conn_state_t = ::core::ffi::c_uint;
177
178#[doc = " Connection types"]
179pub type csp_conn_type_t = ::core::ffi::c_uint;
180
181#[doc = " RDP Connection states"]
182pub type csp_rdp_state_t = ::core::ffi::c_uint;
183
184#[cfg(unix)]
185pub type csp_bin_sem_t = libc::sem_t;
186
187#[doc = " RDP Connection"]
188#[repr(C)]
189#[derive(Copy, Clone)]
190pub struct csp_rdp_t {
191 #[doc = "< Connection state"]
192 pub state: csp_rdp_state_t,
193 #[doc = "< Tracks 'who' have closed the RDP connection"]
194 pub closed_by: u8,
195 #[doc = "< The sequence number of the next segment that is to be sent"]
196 pub snd_nxt: u16,
197 #[doc = "< The sequence number of the oldest unacknowledged segment"]
198 pub snd_una: u16,
199 #[doc = "< The initial send sequence number"]
200 pub snd_iss: u16,
201 #[doc = "< The sequence number of the last segment received correctly and in sequence"]
202 pub rcv_cur: u16,
203 #[doc = "< The initial receive sequence number"]
204 pub rcv_irs: u16,
205 #[doc = "< The last sequence number acknowledged by the receiver"]
206 pub rcv_lsa: u16,
207 pub window_size: u32,
208 pub conn_timeout: u32,
209 pub packet_timeout: u32,
210 pub delayed_acks: u32,
211 pub ack_timeout: u32,
212 pub ack_delay_count: u32,
213 pub ack_timestamp: u32,
214 pub tx_wait: csp_bin_sem_t,
215}
216
217#[doc = " @brief Connection struct"]
218#[repr(C)]
219#[derive(Copy, Clone)]
220pub struct csp_conn_s {
221 pub type_: atomic_int,
222 pub state: atomic_int,
223 pub idin: csp_id_t,
224 pub idout: csp_id_t,
225 pub sport_outgoing: u8,
226 pub rx_queue: csp_queue_handle_t,
227 pub rx_queue_static: csp_static_queue_t,
228 pub rx_queue_static_data:
229 [core::ffi::c_char; CSP_CONN_RXQUEUE_LEN * core::mem::size_of::<*const csp_packet_s>()],
230 pub callback: ::core::option::Option<unsafe extern "C" fn(packet: *mut csp_packet_t)>,
231 pub dest_socket: *mut csp_socket_t,
232 pub timestamp: u32,
233 pub opts: u32,
234 pub rdp: csp_rdp_t,
235}
236
237#[doc = " Interface Tx function.\n\n @return #CSP_ERR_NONE on success, otherwise an error code."]
238pub type nexthop_t = ::core::option::Option<
239 unsafe extern "C" fn(
240 iface: *mut csp_iface_t,
241 via: u16,
242 packet: *mut csp_packet_t,
243 from_me: ::core::ffi::c_int,
244 ) -> ::core::ffi::c_int,
245>;
246
247#[doc = " This struct is referenced in documentation.\n Update doc when you change this."]
248#[repr(C)]
249#[derive(Debug, Copy, Clone)]
250pub struct csp_iface_s {
251 #[doc = "< Host address on this subnet"]
252 pub addr: u16,
253 #[doc = "< Subnet mask"]
254 pub netmask: u16,
255 #[doc = "< Name, max compare length is #CSP_IFLIST_NAME_MAX"]
256 pub name: *const ::core::ffi::c_char,
257 #[doc = "< Interface data, only known/used by the interface layer, e.g. state information."]
258 pub interface_data: *mut ::core::ffi::c_void,
259 #[doc = "< Driver data, only known/used by the driver layer, e.g. device/channel references."]
260 pub driver_data: *mut ::core::ffi::c_void,
261 #[doc = "< Next hop (Tx) function"]
262 pub nexthop: nexthop_t,
263 #[doc = "< Set default IF flag (CSP supports multiple defaults)"]
264 pub is_default: u8,
265 #[doc = "< Successfully transmitted packets"]
266 pub tx: u32,
267 #[doc = "< Successfully received packets"]
268 pub rx: u32,
269 #[doc = "< Transmit errors (packets)"]
270 pub tx_error: u32,
271 #[doc = "< Receive errors, e.g. too large message"]
272 pub rx_error: u32,
273 #[doc = "< Dropped packets"]
274 pub drop: u32,
275 #[doc = "< Authentication errors (packets)"]
276 pub autherr: u32,
277 #[doc = "< Frame format errors (packets)"]
278 pub frame: u32,
279 #[doc = "< Transmitted bytes"]
280 pub txbytes: u32,
281 #[doc = "< Received bytes"]
282 pub rxbytes: u32,
283 #[doc = "< Interrupts"]
284 pub irq: u32,
285 pub next: *mut csp_iface_s,
286}
287
288impl Default for csp_iface_s {
289 fn default() -> Self {
290 Self {
291 addr: Default::default(),
292 netmask: Default::default(),
293 name: core::ptr::null(),
294 interface_data: core::ptr::null_mut(),
295 driver_data: core::ptr::null_mut(),
296 nexthop: None,
297 is_default: Default::default(),
298 tx: Default::default(),
299 rx: Default::default(),
300 tx_error: Default::default(),
301 rx_error: Default::default(),
302 drop: Default::default(),
303 autherr: Default::default(),
304 frame: Default::default(),
305 txbytes: Default::default(),
306 rxbytes: Default::default(),
307 irq: Default::default(),
308 next: core::ptr::null_mut(),
309 }
310 }
311}
312
313#[doc = " Forward declaration of CSP interface, see #csp_iface_s for details."]
314pub type csp_iface_t = csp_iface_s;
315
316#[repr(C)]
317#[derive(Copy, Clone)]
318pub struct csp_if_udp_conf_t {
319 pub host: *mut ::core::ffi::c_char,
320 pub lport: ::core::ffi::c_int,
321 pub rport: ::core::ffi::c_int,
322 pub server_handle: libc::pthread_t,
323 pub peer_addr: libc::sockaddr_in,
324 pub sockfd: ::core::ffi::c_int,
325}
326
327impl Default for csp_if_udp_conf_t {
328 fn default() -> Self {
329 Self {
330 host: core::ptr::null_mut(),
331 lport: Default::default(),
332 rport: Default::default(),
333 server_handle: Default::default(),
334 peer_addr: libc::sockaddr_in {
335 sin_family: Default::default(),
336 sin_port: Default::default(),
337 sin_addr: libc::in_addr {
338 s_addr: Default::default(),
339 },
340 sin_zero: Default::default(),
341 },
342 sockfd: Default::default(),
343 }
344 }
345}
346
347extern "C" {
348 #[doc = " Error counters"]
349 pub static mut csp_dbg_buffer_out: u8;
350 pub static mut csp_dbg_conn_out: u8;
351 pub static mut csp_dbg_conn_ovf: u8;
352 pub static mut csp_dbg_conn_noroute: u8;
353 pub static mut csp_dbg_inval_reply: u8;
354 pub static mut csp_dbg_errno: u8;
355 pub static mut csp_dbg_can_errno: u8;
356 pub static mut csp_dbg_eth_errno: u8;
357 pub static mut csp_dbg_rdp_print: u8;
358 pub static mut csp_dbg_packet_print: u8;
359
360 #[doc = " Initialize CSP.\n This will configure basic structures."]
361 pub fn csp_init();
362
363 pub fn csp_print_func(fmt: *const core::ffi::c_char, ...);
364
365 #[doc = " Bind port to socket.\n\n @param[in] socket socket to bind port to\n @param[in] port port number to bind, use #CSP_ANY for all ports. Bindnig to a specific will take precedence over #CSP_ANY.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
366 pub fn csp_bind(socket: *mut csp_socket_t, port: u8) -> core::ffi::c_int;
367
368 #[doc = " Set socket to listen for incoming connections.\n\n @param[in] socket socket\n @param[in] backlog max length of backlog queue. The backlog queue holds incoming connections, waiting to be returned by call to csp_accept().\n @return #CSP_ERR_NONE on success, otherwise an error code."]
369 pub fn csp_listen(socket: *mut csp_socket_t, backlog: usize) -> ::core::ffi::c_int;
370
371 #[doc = " Route packet from the incoming router queue and check RDP timeouts.\n In order for incoming packets to routed and RDP timeouts to be checked, this function must be called reguarly.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
372 pub fn csp_route_work() -> ::core::ffi::c_int;
373
374 #[doc = " Wait/accept a new connection.\n\n @param[in] socket socket to accept connections on, created by calling csp_socket().\n @param[in] timeout timeout in mS to wait for a connection, use CSP_MAX_TIMEOUT for infinite timeout.\n @return New connection on success, NULL on failure or timeout."]
375 pub fn csp_accept(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_conn_t;
376
377 #[doc = " Read packet from a connection.\n This fuction will wait on the connection's RX queue for the specified timeout.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a packet, use CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet or NULL in case of failure or timeout."]
378 pub fn csp_read(conn: *mut csp_conn_t, timeout: u32) -> *mut csp_packet_t;
379
380 #[doc = " Send packet on a connection.\n The packet buffer is automatically freed, and cannot be used after the call to csp_send()\n\n @param[in] conn connection\n @param[in] packet packet to send"]
381 pub fn csp_send(conn: *mut csp_conn_t, packet: *mut csp_packet_t);
382
383 #[doc = " Change the default priority of the connection and send a packet.\n\n .. note:: The priority of the connection will be changed.\n If you need to change it back, call csp_send_prio() again.\n\n @param[in] prio priority to set on the connection\n @param[in] conn connection\n @param[in] packet packet to send"]
384 pub fn csp_send_prio(prio: u8, conn: *mut csp_conn_t, packet: *mut csp_packet_t);
385
386 #[doc = " Send a packet as a reply to a request (without a connection).\n Calls csp_sendto() with the source address and port from the request.\n\n @param[in] request incoming request\n @param[out] reply reply packet\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS."]
387 pub fn csp_sendto_reply(request: *const csp_packet_t, reply: *mut csp_packet_t, opts: u32);
388
389 #[doc = " Read data from a connection-less server socket.\n\n @param[in] socket connection-less socket.\n @param[in] timeout timeout in mS to wait for a packet, use #CSP_MAX_TIMEOUT for infinite timeout.\n @return Packet on success, or NULL on failure or timeout."]
390 pub fn csp_recvfrom(socket: *mut csp_socket_t, timeout: u32) -> *mut csp_packet_t;
391
392 #[doc = " Perform an entire request & reply transaction.\n Creates a connection, send \\a outbuf, wait for reply, copy reply to \\a inbuf and close the connection.\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst destination address\n @param[in] dst_port destination port\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n\n Returns:\n int: 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"]
393 pub fn csp_transaction_w_opts(
394 prio: u8,
395 dst: u16,
396 dst_port: u8,
397 timeout: u32,
398 outbuf: *const ::core::ffi::c_void,
399 outlen: ::core::ffi::c_int,
400 inbuf: *mut ::core::ffi::c_void,
401 inlen: ::core::ffi::c_int,
402 opts: u32,
403 ) -> ::core::ffi::c_int;
404
405 #[doc = " Handle CSP service request.\n If the given packet is a service-request (the destination port matches one of CSP service ports #csp_service_port_t),\n the packet will be processed by the specific CSP service handler.\n The packet will either process it or free it, so this function is typically called in the last \"default\" clause of\n a switch/case statement in a CSP listener task.\n In order to listen to csp service ports, bind your listener to the specific services ports #csp_service_port_t or\n use #CSP_ANY to all ports.\n\n @param[in] packet first packet, obtained by using csp_read()"]
406 pub fn csp_service_handler(packet: *mut csp_packet_t);
407
408 #[doc = " Close an open connection.\n Any packets in the RX queue will be freed.\n\n @param[in] conn connection. Closing a NULL connection is acceptable.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
409 pub fn csp_close(conn: *mut csp_conn_t) -> ::core::ffi::c_int;
410
411 #[doc = " Send a single ping/echo packet.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in ms to wait for reply.\n @param[in] size payload size in bytes.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return >=0 echo time in mS on success, otherwise -1 for error."]
412 pub fn csp_ping(
413 node: u16,
414 timeout: u32,
415 size: ::core::ffi::c_uint,
416 opts: u8,
417 ) -> ::core::ffi::c_int;
418
419 #[doc = " Send a single ping/echo packet without waiting for reply.\n Payload is 1 byte.\n\n @param[in] node address of subsystem."]
420 pub fn csp_ping_noreply(node: u16);
421
422 #[doc = " Request process list.\n\n .. note:: This is currently only supported on FreeRTOS systems.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for replies. The function will not return until the timeout occurrs."]
423 pub fn csp_ps(node: u16, timeout: u32);
424
425 #[doc = " Request free memory.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free memory on subsystem.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
426 pub fn csp_get_memfree(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int;
427
428 #[doc = " Request free memory and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."]
429 pub fn csp_memfree(node: u16, timeout: u32);
430
431 #[doc = " Request free buffers.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] size free buffers.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
432 pub fn csp_get_buf_free(node: u16, timeout: u32, size: *mut u32) -> ::core::ffi::c_int;
433
434 #[doc = " Request free buffers and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply."]
435 pub fn csp_buf_free(node: u16, timeout: u32);
436
437 #[doc = " Reboot subsystem.\n If handled by the standard CSP service handler, the reboot handler set by csp_sys_set_reboot() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"]
438 pub fn csp_reboot(node: u16);
439
440 #[doc = " Shutdown subsystem.\n If handled by the standard CSP service handler, the shutdown handler set by csp_sys_set_shutdown() on the subsystem, will be invoked.\n\n @param[in] node address of subsystem.\n"]
441 pub fn csp_shutdown(node: u16);
442
443 #[doc = " Request uptime and print to stdout.\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n"]
444 pub fn csp_uptime(node: u16, timeout: u32);
445
446 #[doc = " Request uptime\n\n @param[in] node address of subsystem.\n @param[in] timeout timeout in mS to wait for reply.\n @param[out] uptime uptime in seconds.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
447 pub fn csp_get_uptime(node: u16, timeout: u32, uptime: *mut u32) -> ::core::ffi::c_int;
448
449 #[doc = " Perform an entire request & reply transaction on an existing connection.\n Send \\a outbuf, wait for reply and copy reply to \\a inbuf.\n\n @param[in] conn connection\n @param[in] timeout timeout in mS to wait for a reply\n @param[in] outbuf outgoing data (request)\n @param[in] outlen length of data in \\a outbuf (request)\n @param[out] inbuf user provided buffer for receiving data (reply)\n @param[in] inlen length of expected reply, -1 for unknown size (inbuf MUST be large enough), 0 for no reply.\n @return 1 or reply size on success, 0 on failure (error, incoming length does not match, timeout)"]
450 pub fn csp_transaction_persistent(
451 conn: *mut csp_conn_t,
452 timeout: u32,
453 outbuf: *const ::core::ffi::c_void,
454 outlen: ::core::ffi::c_int,
455 inbuf: *mut ::core::ffi::c_void,
456 inlen: ::core::ffi::c_int,
457 ) -> ::core::ffi::c_int;
458
459 #[doc = " Establish outgoing connection.\n The call will return immediately, unless it is a RDP connection (#CSP_O_RDP) in which case it will wait until the other\n end acknowleges the connection (timeout is determined by the current connection timeout set by csp_rdp_set_opt()).\n\n @param[in] prio priority, see #csp_prio_t\n @param[in] dst Destination address\n @param[in] dst_port Destination port\n @param[in] timeout unused.\n @param[in] opts connection options, see @ref CSP_CONNECTION_OPTIONS.\n @return Established connection or NULL on failure (no free connections, timeout)."]
460 pub fn csp_connect(
461 prio: u8,
462 dst: u16,
463 dst_port: u8,
464 timeout: u32,
465 opts: u32,
466 ) -> *mut csp_conn_t;
467
468 #[doc = " Close a socket, freeing it's RX queue and unbinding it from the associated\n port.\n\n @param[in] sock Socket\n @return #CSP_ERR_NONE on success, otherwise an error code."]
469 pub fn csp_socket_close(sock: *mut csp_socket_t) -> ::core::ffi::c_int;
470
471 #[doc = " Return destination port of connection.\n\n @param[in] conn connection\n @return destination port of an incoming connection"]
472 pub fn csp_conn_dport(conn: *const csp_conn_t) -> ::core::ffi::c_int;
473 #[doc = " Return source port of connection.\n\n @param[in] conn connection\n @return source port of an incoming connection"]
474 pub fn csp_conn_sport(conn: *const csp_conn_t) -> ::core::ffi::c_int;
475 #[doc = " Return destination address of connection.\n\n @param[in] conn connection\n @return destination address of an incoming connection"]
476 pub fn csp_conn_dst(conn: *const csp_conn_t) -> ::core::ffi::c_int;
477 #[doc = " Return source address of connection.\n\n @param[in] conn connection\n @return source address of an incoming connection"]
478 pub fn csp_conn_src(conn: *const csp_conn_t) -> ::core::ffi::c_int;
479 #[doc = " Return flags of connection.\n\n @param[in] conn connection\n @return flags of an incoming connection, see @ref CSP_HEADER_FLAGS"]
480 pub fn csp_conn_flags(conn: *const csp_conn_t) -> ::core::ffi::c_int;
481
482 #[doc = " Get free buffer from task context.\n\n @param[in] unused OBSOLETE ignored field, csp packets have a fixed size now\n @return Buffer pointer to #csp_packet_t or NULL if no buffers available"]
483 pub fn csp_buffer_get(unused: usize) -> *mut csp_packet_t;
484
485 #[doc = " Free buffer (from task context).\n\n @param[in] buffer buffer to free. NULL is handled gracefully."]
486 pub fn csp_buffer_free(buffer: *mut ::core::ffi::c_void);
487
488 #[doc = " Print connection table to stdout."]
489 pub fn csp_conn_print_table();
490}
491
492pub mod iflist {
493 use super::*;
494
495 extern "C" {
496 #[doc = " Add interface to the list.\n\n @param[in] iface The interface must remain valid as long as the application is running.\n @return #CSP_ERR_NONE on success, otherwise an error code."]
497 pub fn csp_iflist_add(iface: *mut csp_iface_t) -> ::core::ffi::c_int;
498
499 pub fn csp_iflist_print();
500
501 }
502}
503
504pub mod udp {
505 use super::*;
506
507 extern "C" {
508
509 #[doc = " Setup UDP peer\n\n RX task:\n A server task will attempt at binding to ip 0.0.0.0 port 9600\n If this fails, it is because another udp server is already running.\n The server task will continue attemting the bind and will not exit before the application is closed.\n\n TX peer:\n Outgoing CSP packets will be transferred to the peer specified by the host argument"]
510 pub fn csp_if_udp_init(iface: *mut csp_iface_t, ifconf: *mut csp_if_udp_conf_t);
511
512 }
513}
514
515pub mod hooks {
520 use super::*;
521
522 extern "C" {
523 pub fn csp_output_hook(
524 idout: *mut csp_id_t,
525 packet: *mut csp_packet_t,
526 iface: *mut csp_iface_t,
527 via: u16,
528 from_me: ::core::ffi::c_int,
529 );
530 pub fn csp_input_hook(iface: *mut csp_iface_t, packet: *mut csp_packet_t);
531 pub fn csp_reboot_hook();
532 pub fn csp_shutdown_hook();
533 pub fn csp_memfree_hook() -> u32;
534 pub fn csp_ps_hook(packet: *mut csp_packet_t) -> ::core::ffi::c_uint;
535 #[doc = " Implement these, if you use csp_if_tun"]
536 pub fn csp_crypto_decrypt(
537 ciphertext_in: *mut u8,
538 ciphertext_len: u8,
539 msg_out: *mut u8,
540 ) -> ::core::ffi::c_int;
541 pub fn csp_crypto_encrypt(
542 msg_begin: *mut u8,
543 msg_len: u8,
544 ciphertext_out: *mut u8,
545 ) -> ::core::ffi::c_int;
546 pub fn csp_clock_get_time(time: *mut csp_timestamp_t);
547 pub fn csp_clock_set_time(time: *const csp_timestamp_t) -> ::core::ffi::c_int;
548 }
549}
550
551#[cfg(test)]
552mod tests {
553 use super::*;
554 use core::mem::{align_of, size_of, MaybeUninit};
555
556 #[test]
557 fn bindgen_test_layout_csp_timestamp_t() {
558 const UNINIT: MaybeUninit<csp_timestamp_t> = MaybeUninit::uninit();
559 let ptr = UNINIT.as_ptr();
560 assert_eq!(
561 ::core::mem::size_of::<csp_timestamp_t>(),
562 8usize,
563 concat!("Size of: ", stringify!(csp_timestamp_t))
564 );
565 assert_eq!(
566 core::mem::align_of::<csp_timestamp_t>(),
567 4usize,
568 concat!("Alignment of ", stringify!(csp_timestamp_t))
569 );
570 assert_eq!(
571 unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize },
572 0usize,
573 concat!(
574 "Offset of field: ",
575 stringify!(csp_timestamp_t),
576 "::",
577 stringify!(tv_sec)
578 )
579 );
580 assert_eq!(
581 unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize },
582 4usize,
583 concat!(
584 "Offset of field: ",
585 stringify!(csp_timestamp_t),
586 "::",
587 stringify!(tv_nsec)
588 )
589 );
590 }
591
592 #[test]
593 fn bindgen_test_layout_csp_id() {
594 const UNINIT: MaybeUninit<csp_id_t> = MaybeUninit::uninit();
595 let ptr = UNINIT.as_ptr();
596 assert_eq!(
597 size_of::<csp_id_t>(),
598 8usize,
599 concat!("Size of: ", stringify!(__packed))
600 );
601 assert_eq!(
602 align_of::<csp_id_t>(),
603 2usize,
604 concat!("Alignment of ", stringify!(__packed))
605 );
606 assert_eq!(
607 unsafe { ::core::ptr::addr_of!((*ptr).pri) as usize - ptr as usize },
608 0usize,
609 concat!(
610 "Offset of field: ",
611 stringify!(__packed),
612 "::",
613 stringify!(pri)
614 )
615 );
616 assert_eq!(
617 unsafe { core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize },
618 1usize,
619 concat!(
620 "Offset of field: ",
621 stringify!(__packed),
622 "::",
623 stringify!(flags)
624 )
625 );
626 assert_eq!(
627 unsafe { core::ptr::addr_of!((*ptr).src) as usize - ptr as usize },
628 2usize,
629 concat!(
630 "Offset of field: ",
631 stringify!(__packed),
632 "::",
633 stringify!(src)
634 )
635 );
636 assert_eq!(
637 unsafe { core::ptr::addr_of!((*ptr).dst) as usize - ptr as usize },
638 4usize,
639 concat!(
640 "Offset of field: ",
641 stringify!(__packed),
642 "::",
643 stringify!(dst)
644 )
645 );
646 assert_eq!(
647 unsafe { core::ptr::addr_of!((*ptr).dport) as usize - ptr as usize },
648 6usize,
649 concat!(
650 "Offset of field: ",
651 stringify!(__packed),
652 "::",
653 stringify!(dport)
654 )
655 );
656 assert_eq!(
657 unsafe { core::ptr::addr_of!((*ptr).sport) as usize - ptr as usize },
658 7usize,
659 concat!(
660 "Offset of field: ",
661 stringify!(__packed),
662 "::",
663 stringify!(sport)
664 )
665 );
666 }
667
668 #[test]
669 fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_1() {
670 const UNINIT: MaybeUninit<csp_packet_s_anon_union_field_rdp_only> = MaybeUninit::uninit();
671 let ptr = UNINIT.as_ptr();
672 assert_eq!(
673 size_of::<csp_packet_s_anon_union_field_rdp_only>(),
674 24usize,
675 concat!(
676 "Size of: ",
677 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1)
678 )
679 );
680 assert_eq!(
681 align_of::<csp_packet_s_anon_union_field_rdp_only>(),
682 8usize,
683 concat!(
684 "Alignment of ",
685 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1)
686 )
687 );
688 assert_eq!(
689 unsafe { core::ptr::addr_of!((*ptr).rdp_quarantine) as usize - ptr as usize },
690 0usize,
691 concat!(
692 "Offset of field: ",
693 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1),
694 "::",
695 stringify!(rdp_quarantine)
696 )
697 );
698 assert_eq!(
699 unsafe { core::ptr::addr_of!((*ptr).timestamp_tx) as usize - ptr as usize },
700 4usize,
701 concat!(
702 "Offset of field: ",
703 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1),
704 "::",
705 stringify!(timestamp_tx)
706 )
707 );
708 assert_eq!(
709 unsafe { core::ptr::addr_of!((*ptr).timestamp_rx) as usize - ptr as usize },
710 8usize,
711 concat!(
712 "Offset of field: ",
713 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1),
714 "::",
715 stringify!(timestamp_rx)
716 )
717 );
718 assert_eq!(
719 unsafe { core::ptr::addr_of!((*ptr).conn) as usize - ptr as usize },
720 16usize,
721 concat!(
722 "Offset of field: ",
723 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_1),
724 "::",
725 stringify!(conn)
726 )
727 );
728 }
729
730 #[test]
731 fn bindgen_test_layout_csp_packet_s__bindgen_ty_1__bindgen_ty_2() {
732 const UNINIT: MaybeUninit<csp_packet_s_anon_union_field_rx_tx_only> = MaybeUninit::uninit();
733 let ptr = UNINIT.as_ptr();
734 assert_eq!(
735 size_of::<csp_packet_s_anon_union_field_rx_tx_only>(),
736 32usize,
737 concat!(
738 "Size of: ",
739 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2)
740 )
741 );
742 assert_eq!(
743 align_of::<csp_packet_s_anon_union_field_rx_tx_only>(),
744 8usize,
745 concat!(
746 "Alignment of ",
747 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2)
748 )
749 );
750 assert_eq!(
751 unsafe { core::ptr::addr_of!((*ptr).rx_count) as usize - ptr as usize },
752 0usize,
753 concat!(
754 "Offset of field: ",
755 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
756 "::",
757 stringify!(rx_count)
758 )
759 );
760 assert_eq!(
761 unsafe { core::ptr::addr_of!((*ptr).remain) as usize - ptr as usize },
762 2usize,
763 concat!(
764 "Offset of field: ",
765 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
766 "::",
767 stringify!(remain)
768 )
769 );
770 assert_eq!(
771 unsafe { core::ptr::addr_of!((*ptr).cfpid) as usize - ptr as usize },
772 4usize,
773 concat!(
774 "Offset of field: ",
775 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
776 "::",
777 stringify!(cfpid)
778 )
779 );
780 assert_eq!(
781 unsafe { core::ptr::addr_of!((*ptr).last_used) as usize - ptr as usize },
782 8usize,
783 concat!(
784 "Offset of field: ",
785 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
786 "::",
787 stringify!(last_used)
788 )
789 );
790 assert_eq!(
791 unsafe { core::ptr::addr_of!((*ptr).frame_begin) as usize - ptr as usize },
792 16usize,
793 concat!(
794 "Offset of field: ",
795 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
796 "::",
797 stringify!(frame_begin)
798 )
799 );
800 assert_eq!(
801 unsafe { core::ptr::addr_of!((*ptr).frame_length) as usize - ptr as usize },
802 24usize,
803 concat!(
804 "Offset of field: ",
805 stringify!(csp_packet_s__bindgen_ty_1__bindgen_ty_2),
806 "::",
807 stringify!(frame_length)
808 )
809 );
810 }
811 #[test]
812 fn bindgen_test_layout_csp_packet_s__bindgen_ty_1() {
813 assert_eq!(
814 size_of::<csp_packet_s_anon_union>(),
815 32usize,
816 concat!("Size of: ", stringify!(csp_packet_s_anon_union))
817 );
818 assert_eq!(
819 align_of::<csp_packet_s_anon_union>(),
820 8usize,
821 concat!("Alignment of ", stringify!(csp_packet_s_anon_union))
822 );
823 }
824
825 #[test]
826 fn bindgen_test_layout_csp_packet_s__bindgen_ty_2() {
827 const UNINIT: MaybeUninit<csp_packet_s_data_union> = MaybeUninit::uninit();
828 let ptr = UNINIT.as_ptr();
829 assert_eq!(
830 size_of::<csp_packet_s_data_union>(),
831 256usize,
832 concat!("Size of: ", stringify!(csp_packet_s__bindgen_ty_2))
833 );
834 assert_eq!(
835 align_of::<csp_packet_s_data_union>(),
836 4usize,
837 concat!("Alignment of ", stringify!(csp_packet_s__bindgen_ty_2))
838 );
839 assert_eq!(
840 unsafe { core::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
841 0usize,
842 concat!(
843 "Offset of field: ",
844 stringify!(csp_packet_s__bindgen_ty_2),
845 "::",
846 stringify!(data)
847 )
848 );
849 assert_eq!(
850 unsafe { core::ptr::addr_of!((*ptr).data16) as usize - ptr as usize },
851 0usize,
852 concat!(
853 "Offset of field: ",
854 stringify!(csp_packet_s__bindgen_ty_2),
855 "::",
856 stringify!(data16)
857 )
858 );
859 assert_eq!(
860 unsafe { core::ptr::addr_of!((*ptr).data32) as usize - ptr as usize },
861 0usize,
862 concat!(
863 "Offset of field: ",
864 stringify!(csp_packet_s__bindgen_ty_2),
865 "::",
866 stringify!(data32)
867 )
868 );
869 }
870 #[test]
871 fn bindgen_test_layout_csp_packet_s() {
872 const UNINIT: MaybeUninit<csp_packet_s> = MaybeUninit::uninit();
873 let ptr = UNINIT.as_ptr();
874 assert_eq!(
875 size_of::<csp_packet_s>(),
876 320usize,
877 concat!("Size of: ", stringify!(csp_packet_s))
878 );
879 assert_eq!(
880 align_of::<csp_packet_s>(),
881 8usize,
882 concat!("Alignment of ", stringify!(csp_packet_s))
883 );
884 assert_eq!(
885 unsafe { core::ptr::addr_of!((*ptr).length) as usize - ptr as usize },
886 32usize,
887 concat!(
888 "Offset of field: ",
889 stringify!(csp_packet_s),
890 "::",
891 stringify!(length)
892 )
893 );
894 assert_eq!(
895 unsafe { core::ptr::addr_of!((*ptr).id) as usize - ptr as usize },
896 34usize,
897 concat!(
898 "Offset of field: ",
899 stringify!(csp_packet_s),
900 "::",
901 stringify!(id)
902 )
903 );
904 assert_eq!(
905 unsafe { core::ptr::addr_of!((*ptr).next) as usize - ptr as usize },
906 48usize,
907 concat!(
908 "Offset of field: ",
909 stringify!(csp_packet_s),
910 "::",
911 stringify!(next)
912 )
913 );
914 assert_eq!(
915 unsafe { core::ptr::addr_of!((*ptr).header) as usize - ptr as usize },
916 56usize,
917 concat!(
918 "Offset of field: ",
919 stringify!(csp_packet_s),
920 "::",
921 stringify!(header)
922 )
923 );
924 }
925
926 #[test]
927 fn bindgen_test_layout_csp_socket_s() {
928 const UNINIT: core::mem::MaybeUninit<csp_socket_s> = core::mem::MaybeUninit::uninit();
929 let ptr = UNINIT.as_ptr();
930 assert_eq!(
931 core::mem::size_of::<csp_socket_s>(),
932 152usize,
933 concat!("Size of: ", stringify!(csp_socket_s))
934 );
935 assert_eq!(
936 core::mem::align_of::<csp_socket_s>(),
937 8usize,
938 concat!("Alignment of ", stringify!(csp_socket_s))
939 );
940 assert_eq!(
941 unsafe { core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize },
942 0usize,
943 concat!(
944 "Offset of field: ",
945 stringify!(csp_socket_s),
946 "::",
947 stringify!(rx_queue)
948 )
949 );
950 assert_eq!(
951 unsafe { core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize },
952 8usize,
953 concat!(
954 "Offset of field: ",
955 stringify!(csp_socket_s),
956 "::",
957 stringify!(rx_queue_static)
958 )
959 );
960 assert_eq!(
961 unsafe { core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize },
962 16usize,
963 concat!(
964 "Offset of field: ",
965 stringify!(csp_socket_s),
966 "::",
967 stringify!(rx_queue_static_data)
968 )
969 );
970 assert_eq!(
971 unsafe { core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize },
972 144usize,
973 concat!(
974 "Offset of field: ",
975 stringify!(csp_socket_s),
976 "::",
977 stringify!(opts)
978 )
979 );
980 }
981
982 #[test]
983 fn bindgen_test_layout_csp_if_udp_conf_t() {
984 const UNINIT: ::core::mem::MaybeUninit<csp_if_udp_conf_t> =
985 ::core::mem::MaybeUninit::uninit();
986 let ptr = UNINIT.as_ptr();
987 assert_eq!(
988 ::core::mem::size_of::<csp_if_udp_conf_t>(),
989 48usize,
990 concat!("Size of: ", stringify!(csp_if_udp_conf_t))
991 );
992 assert_eq!(
993 ::core::mem::align_of::<csp_if_udp_conf_t>(),
994 8usize,
995 concat!("Alignment of ", stringify!(csp_if_udp_conf_t))
996 );
997 assert_eq!(
998 unsafe { ::core::ptr::addr_of!((*ptr).host) as usize - ptr as usize },
999 0usize,
1000 concat!(
1001 "Offset of field: ",
1002 stringify!(csp_if_udp_conf_t),
1003 "::",
1004 stringify!(host)
1005 )
1006 );
1007 assert_eq!(
1008 unsafe { ::core::ptr::addr_of!((*ptr).lport) as usize - ptr as usize },
1009 8usize,
1010 concat!(
1011 "Offset of field: ",
1012 stringify!(csp_if_udp_conf_t),
1013 "::",
1014 stringify!(lport)
1015 )
1016 );
1017 assert_eq!(
1018 unsafe { ::core::ptr::addr_of!((*ptr).rport) as usize - ptr as usize },
1019 12usize,
1020 concat!(
1021 "Offset of field: ",
1022 stringify!(csp_if_udp_conf_t),
1023 "::",
1024 stringify!(rport)
1025 )
1026 );
1027 assert_eq!(
1028 unsafe { ::core::ptr::addr_of!((*ptr).server_handle) as usize - ptr as usize },
1029 16usize,
1030 concat!(
1031 "Offset of field: ",
1032 stringify!(csp_if_udp_conf_t),
1033 "::",
1034 stringify!(server_handle)
1035 )
1036 );
1037 assert_eq!(
1038 unsafe { ::core::ptr::addr_of!((*ptr).peer_addr) as usize - ptr as usize },
1039 24usize,
1040 concat!(
1041 "Offset of field: ",
1042 stringify!(csp_if_udp_conf_t),
1043 "::",
1044 stringify!(peer_addr)
1045 )
1046 );
1047 assert_eq!(
1048 unsafe { ::core::ptr::addr_of!((*ptr).sockfd) as usize - ptr as usize },
1049 40usize,
1050 concat!(
1051 "Offset of field: ",
1052 stringify!(csp_if_udp_conf_t),
1053 "::",
1054 stringify!(sockfd)
1055 )
1056 );
1057 }
1058
1059 #[test]
1060 fn bindgen_test_layout_csp_conn_s() {
1061 const UNINIT: ::core::mem::MaybeUninit<csp_conn_s> = ::core::mem::MaybeUninit::uninit();
1062 let ptr = UNINIT.as_ptr();
1063 assert_eq!(
1064 ::core::mem::size_of::<csp_conn_s>(),
1065 280usize,
1066 concat!("Size of: ", stringify!(csp_conn_s))
1067 );
1068 assert_eq!(
1069 ::core::mem::align_of::<csp_conn_s>(),
1070 8usize,
1071 concat!("Alignment of ", stringify!(csp_conn_s))
1072 );
1073 assert_eq!(
1074 unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize },
1075 0usize,
1076 concat!(
1077 "Offset of field: ",
1078 stringify!(csp_conn_s),
1079 "::",
1080 stringify!(type_)
1081 )
1082 );
1083 assert_eq!(
1084 unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize },
1085 4usize,
1086 concat!(
1087 "Offset of field: ",
1088 stringify!(csp_conn_s),
1089 "::",
1090 stringify!(state)
1091 )
1092 );
1093 assert_eq!(
1094 unsafe { ::core::ptr::addr_of!((*ptr).idin) as usize - ptr as usize },
1095 8usize,
1096 concat!(
1097 "Offset of field: ",
1098 stringify!(csp_conn_s),
1099 "::",
1100 stringify!(idin)
1101 )
1102 );
1103 assert_eq!(
1104 unsafe { ::core::ptr::addr_of!((*ptr).idout) as usize - ptr as usize },
1105 16usize,
1106 concat!(
1107 "Offset of field: ",
1108 stringify!(csp_conn_s),
1109 "::",
1110 stringify!(idout)
1111 )
1112 );
1113 assert_eq!(
1114 unsafe { ::core::ptr::addr_of!((*ptr).sport_outgoing) as usize - ptr as usize },
1115 24usize,
1116 concat!(
1117 "Offset of field: ",
1118 stringify!(csp_conn_s),
1119 "::",
1120 stringify!(sport_outgoing)
1121 )
1122 );
1123 assert_eq!(
1124 unsafe { ::core::ptr::addr_of!((*ptr).rx_queue) as usize - ptr as usize },
1125 32usize,
1126 concat!(
1127 "Offset of field: ",
1128 stringify!(csp_conn_s),
1129 "::",
1130 stringify!(rx_queue)
1131 )
1132 );
1133 assert_eq!(
1134 unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static) as usize - ptr as usize },
1135 40usize,
1136 concat!(
1137 "Offset of field: ",
1138 stringify!(csp_conn_s),
1139 "::",
1140 stringify!(rx_queue_static)
1141 )
1142 );
1143 assert_eq!(
1144 unsafe { ::core::ptr::addr_of!((*ptr).rx_queue_static_data) as usize - ptr as usize },
1145 48usize,
1146 concat!(
1147 "Offset of field: ",
1148 stringify!(csp_conn_s),
1149 "::",
1150 stringify!(rx_queue_static_data)
1151 )
1152 );
1153 assert_eq!(
1154 unsafe { ::core::ptr::addr_of!((*ptr).callback) as usize - ptr as usize },
1155 176usize,
1156 concat!(
1157 "Offset of field: ",
1158 stringify!(csp_conn_s),
1159 "::",
1160 stringify!(callback)
1161 )
1162 );
1163 assert_eq!(
1164 unsafe { ::core::ptr::addr_of!((*ptr).dest_socket) as usize - ptr as usize },
1165 184usize,
1166 concat!(
1167 "Offset of field: ",
1168 stringify!(csp_conn_s),
1169 "::",
1170 stringify!(dest_socket)
1171 )
1172 );
1173 assert_eq!(
1174 unsafe { ::core::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize },
1175 192usize,
1176 concat!(
1177 "Offset of field: ",
1178 stringify!(csp_conn_s),
1179 "::",
1180 stringify!(timestamp)
1181 )
1182 );
1183 assert_eq!(
1184 unsafe { ::core::ptr::addr_of!((*ptr).opts) as usize - ptr as usize },
1185 196usize,
1186 concat!(
1187 "Offset of field: ",
1188 stringify!(csp_conn_s),
1189 "::",
1190 stringify!(opts)
1191 )
1192 );
1193 assert_eq!(
1194 unsafe { ::core::ptr::addr_of!((*ptr).rdp) as usize - ptr as usize },
1195 200usize,
1196 concat!(
1197 "Offset of field: ",
1198 stringify!(csp_conn_s),
1199 "::",
1200 stringify!(rdp)
1201 )
1202 );
1203 }
1204
1205 #[test]
1206 fn bindgen_test_layout_csp_iface_s() {
1207 const UNINIT: ::core::mem::MaybeUninit<csp_iface_s> = ::core::mem::MaybeUninit::uninit();
1208 let ptr = UNINIT.as_ptr();
1209 assert_eq!(
1210 ::core::mem::size_of::<csp_iface_s>(),
1211 96usize,
1212 concat!("Size of: ", stringify!(csp_iface_s))
1213 );
1214 assert_eq!(
1215 ::core::mem::align_of::<csp_iface_s>(),
1216 8usize,
1217 concat!("Alignment of ", stringify!(csp_iface_s))
1218 );
1219 assert_eq!(
1220 unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize },
1221 0usize,
1222 concat!(
1223 "Offset of field: ",
1224 stringify!(csp_iface_s),
1225 "::",
1226 stringify!(addr)
1227 )
1228 );
1229 assert_eq!(
1230 unsafe { ::core::ptr::addr_of!((*ptr).netmask) as usize - ptr as usize },
1231 2usize,
1232 concat!(
1233 "Offset of field: ",
1234 stringify!(csp_iface_s),
1235 "::",
1236 stringify!(netmask)
1237 )
1238 );
1239 assert_eq!(
1240 unsafe { ::core::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
1241 8usize,
1242 concat!(
1243 "Offset of field: ",
1244 stringify!(csp_iface_s),
1245 "::",
1246 stringify!(name)
1247 )
1248 );
1249 assert_eq!(
1250 unsafe { ::core::ptr::addr_of!((*ptr).interface_data) as usize - ptr as usize },
1251 16usize,
1252 concat!(
1253 "Offset of field: ",
1254 stringify!(csp_iface_s),
1255 "::",
1256 stringify!(interface_data)
1257 )
1258 );
1259 assert_eq!(
1260 unsafe { ::core::ptr::addr_of!((*ptr).driver_data) as usize - ptr as usize },
1261 24usize,
1262 concat!(
1263 "Offset of field: ",
1264 stringify!(csp_iface_s),
1265 "::",
1266 stringify!(driver_data)
1267 )
1268 );
1269 assert_eq!(
1270 unsafe { ::core::ptr::addr_of!((*ptr).nexthop) as usize - ptr as usize },
1271 32usize,
1272 concat!(
1273 "Offset of field: ",
1274 stringify!(csp_iface_s),
1275 "::",
1276 stringify!(nexthop)
1277 )
1278 );
1279 assert_eq!(
1280 unsafe { ::core::ptr::addr_of!((*ptr).is_default) as usize - ptr as usize },
1281 40usize,
1282 concat!(
1283 "Offset of field: ",
1284 stringify!(csp_iface_s),
1285 "::",
1286 stringify!(is_default)
1287 )
1288 );
1289 assert_eq!(
1290 unsafe { ::core::ptr::addr_of!((*ptr).tx) as usize - ptr as usize },
1291 44usize,
1292 concat!(
1293 "Offset of field: ",
1294 stringify!(csp_iface_s),
1295 "::",
1296 stringify!(tx)
1297 )
1298 );
1299 assert_eq!(
1300 unsafe { ::core::ptr::addr_of!((*ptr).rx) as usize - ptr as usize },
1301 48usize,
1302 concat!(
1303 "Offset of field: ",
1304 stringify!(csp_iface_s),
1305 "::",
1306 stringify!(rx)
1307 )
1308 );
1309 assert_eq!(
1310 unsafe { ::core::ptr::addr_of!((*ptr).tx_error) as usize - ptr as usize },
1311 52usize,
1312 concat!(
1313 "Offset of field: ",
1314 stringify!(csp_iface_s),
1315 "::",
1316 stringify!(tx_error)
1317 )
1318 );
1319 assert_eq!(
1320 unsafe { ::core::ptr::addr_of!((*ptr).rx_error) as usize - ptr as usize },
1321 56usize,
1322 concat!(
1323 "Offset of field: ",
1324 stringify!(csp_iface_s),
1325 "::",
1326 stringify!(rx_error)
1327 )
1328 );
1329 assert_eq!(
1330 unsafe { ::core::ptr::addr_of!((*ptr).drop) as usize - ptr as usize },
1331 60usize,
1332 concat!(
1333 "Offset of field: ",
1334 stringify!(csp_iface_s),
1335 "::",
1336 stringify!(drop)
1337 )
1338 );
1339 assert_eq!(
1340 unsafe { ::core::ptr::addr_of!((*ptr).autherr) as usize - ptr as usize },
1341 64usize,
1342 concat!(
1343 "Offset of field: ",
1344 stringify!(csp_iface_s),
1345 "::",
1346 stringify!(autherr)
1347 )
1348 );
1349 assert_eq!(
1350 unsafe { ::core::ptr::addr_of!((*ptr).frame) as usize - ptr as usize },
1351 68usize,
1352 concat!(
1353 "Offset of field: ",
1354 stringify!(csp_iface_s),
1355 "::",
1356 stringify!(frame)
1357 )
1358 );
1359 assert_eq!(
1360 unsafe { ::core::ptr::addr_of!((*ptr).txbytes) as usize - ptr as usize },
1361 72usize,
1362 concat!(
1363 "Offset of field: ",
1364 stringify!(csp_iface_s),
1365 "::",
1366 stringify!(txbytes)
1367 )
1368 );
1369 assert_eq!(
1370 unsafe { ::core::ptr::addr_of!((*ptr).rxbytes) as usize - ptr as usize },
1371 76usize,
1372 concat!(
1373 "Offset of field: ",
1374 stringify!(csp_iface_s),
1375 "::",
1376 stringify!(rxbytes)
1377 )
1378 );
1379 assert_eq!(
1380 unsafe { ::core::ptr::addr_of!((*ptr).irq) as usize - ptr as usize },
1381 80usize,
1382 concat!(
1383 "Offset of field: ",
1384 stringify!(csp_iface_s),
1385 "::",
1386 stringify!(irq)
1387 )
1388 );
1389 assert_eq!(
1390 unsafe { ::core::ptr::addr_of!((*ptr).next) as usize - ptr as usize },
1391 88usize,
1392 concat!(
1393 "Offset of field: ",
1394 stringify!(csp_iface_s),
1395 "::",
1396 stringify!(next)
1397 )
1398 );
1399 }
1400}