1#![doc = include_str!("../README.md")]
2#![no_std]
3
4pub mod arp;
5pub mod bitfield;
6pub mod eth;
7pub mod geneve;
8pub mod icmp;
9pub mod ip;
10pub mod llc;
11pub mod mac;
12pub mod mpls;
13pub mod sctp;
14pub mod tcp;
15pub mod udp;
16pub mod vlan;
17pub mod vxlan;
18
19#[cfg(target_endian = "big")]
27#[macro_export]
28macro_rules! getter_be {
29 ($self:expr, $field:ident, $ty:ty) => {
30 ::core::ptr::read_unaligned(
31 (($self as *const Self as usize) + ::memoffset::offset_of!(Self, $field)) as *const $ty,
32 )
33 };
34}
35#[cfg(target_endian = "little")]
36#[macro_export]
37macro_rules! getter_be {
38 ($self:expr, $field:ident, $ty:ty) => {
39 ::core::ptr::read_unaligned(
40 (($self as *const Self as usize) + ::memoffset::offset_of!(Self, $field)) as *const $ty,
41 )
42 .swap_bytes()
43 };
44}
45
46#[cfg(target_endian = "big")]
54#[macro_export]
55macro_rules! setter_be {
56 ($self:expr, $field:ident, $val:expr) => {
57 $self.$field = *((&$val as *const _ as usize) as *const _);
59 };
60}
61#[cfg(target_endian = "little")]
62#[macro_export]
63macro_rules! setter_be {
64 ($self:expr, $field:ident, $val:expr) => {
65 $self.$field = *((&$val.swap_bytes() as *const _ as usize) as *const _)
67 };
68}