diff options
-rw-r--r-- | tests/expectations/tests/layout_array_too_long.rs | 207 | ||||
-rw-r--r-- | tests/headers/layout_array_too_long.h | 60 |
2 files changed, 267 insertions, 0 deletions
diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs new file mode 100644 index 00000000..c395f08d --- /dev/null +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -0,0 +1,207 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; +pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; +pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX; +pub const IP_FIRST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_FIRST_FRAG_IDX; +pub const IP_MIN_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MIN_FRAG_NUM; +pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum _bindgen_ty_1 { + IP_LAST_FRAG_IDX = 0, + IP_FIRST_FRAG_IDX = 1, + IP_MIN_FRAG_NUM = 2, + IP_MAX_FRAG_NUM = 4, +} +/** @internal fragmented mbuf */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ip_frag { + /**< offset into the packet */ + pub ofs: u16, + /**< length of fragment */ + pub len: u16, + /**< fragment mbuf */ + pub mb: *mut rte_mbuf, +} +#[test] +fn bindgen_test_layout_ip_frag() { + assert_eq!(::std::mem::size_of::<ip_frag>() , 16usize , concat ! ( + "Size of: " , stringify ! ( ip_frag ) )); + assert_eq! (::std::mem::align_of::<ip_frag>() , 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( ofs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . len as * const _ as usize } + , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as usize } + , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( mb ) )); +} +impl Clone for ip_frag { + fn clone(&self) -> Self { *self } +} +impl Default for ip_frag { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/** @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram. */ +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct ip_frag_key { + /**< src address, first 8 bytes used for IPv4 */ + pub src_dst: [u64; 4usize], + /**< dst address */ + pub id: u32, + /**< src/dst key length */ + pub key_len: u32, +} +#[test] +fn bindgen_test_layout_ip_frag_key() { + assert_eq!(::std::mem::size_of::<ip_frag_key>() , 40usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_key ) )); + assert_eq! (::std::mem::align_of::<ip_frag_key>() , 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag_key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , + stringify ! ( src_dst ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as + usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , + stringify ! ( id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const _ as + usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , + stringify ! ( key_len ) )); +} +impl Clone for ip_frag_key { + fn clone(&self) -> Self { *self } +} +/** + * @internal Fragmented packet to reassemble. + * First two entries in the frags[] array are for the last and first fragments. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ip_frag_pkt { + /**< LRU list */ + pub lru: ip_frag_pkt__bindgen_ty_1, + /**< fragmentation key */ + pub key: ip_frag_key, + /**< creation timestamp */ + pub start: u64, + /**< expected reassembled size */ + pub total_size: u32, + /**< size of fragments received */ + pub frag_size: u32, + /**< index of next entry to fill */ + pub last_idx: u32, + /**< fragments */ + pub frags: [ip_frag; 4usize], + pub __bindgen_padding_0: [u64; 6usize], +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ip_frag_pkt__bindgen_ty_1 { + pub tqe_next: *mut ip_frag_pkt, + pub tqe_prev: *mut *mut ip_frag_pkt, +} +#[test] +fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<ip_frag_pkt__bindgen_ty_1>() , 16usize , + concat ! ( + "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::<ip_frag_pkt__bindgen_ty_1>() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_next + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_next ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_prev + as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_prev ) + )); +} +impl Clone for ip_frag_pkt__bindgen_ty_1 { + fn clone(&self) -> Self { *self } +} +impl Default for ip_frag_pkt__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn bindgen_test_layout_ip_frag_pkt() { + assert_eq!(::std::mem::size_of::<ip_frag_pkt>() , 192usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_pkt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( lru ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ as + usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( start ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * const _ + as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( total_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * const _ + as usize } , 68usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( frag_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const _ + as usize } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( last_idx ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ as + usize } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , + stringify ! ( frags ) )); +} +impl Clone for ip_frag_pkt { + fn clone(&self) -> Self { *self } +} +impl Default for ip_frag_pkt { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +/**< fragment mbuf */ +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf { + pub _address: u8, +} +impl Clone for rte_mbuf { + fn clone(&self) -> Self { *self } +} diff --git a/tests/headers/layout_array_too_long.h b/tests/headers/layout_array_too_long.h new file mode 100644 index 00000000..9be037ab --- /dev/null +++ b/tests/headers/layout_array_too_long.h @@ -0,0 +1,60 @@ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define RTE_CACHE_LINE_SIZE 64 + +/** + * Force alignment + */ +#define __rte_aligned(a) __attribute__((__aligned__(a))) + +/** + * Force alignment to cache line. + */ +#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) + +#define RTE_LIBRTE_IP_FRAG_MAX_FRAG 4 + +enum { + IP_LAST_FRAG_IDX, /**< index of last fragment */ + IP_FIRST_FRAG_IDX, /**< index of first fragment */ + IP_MIN_FRAG_NUM, /**< minimum number of fragments */ + IP_MAX_FRAG_NUM = RTE_LIBRTE_IP_FRAG_MAX_FRAG, + /**< maximum number of fragments per packet */ +}; + +/** @internal fragmented mbuf */ +struct ip_frag { + uint16_t ofs; /**< offset into the packet */ + uint16_t len; /**< length of fragment */ + struct rte_mbuf *mb; /**< fragment mbuf */ +}; + +/** @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram. */ +struct ip_frag_key { + uint64_t src_dst[4]; /**< src address, first 8 bytes used for IPv4 */ + uint32_t id; /**< dst address */ + uint32_t key_len; /**< src/dst key length */ +}; + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/** + * @internal Fragmented packet to reassemble. + * First two entries in the frags[] array are for the last and first fragments. + */ +struct ip_frag_pkt { + TAILQ_ENTRY(ip_frag_pkt) lru; /**< LRU list */ + struct ip_frag_key key; /**< fragmentation key */ + uint64_t start; /**< creation timestamp */ + uint32_t total_size; /**< expected reassembled size */ + uint32_t frag_size; /**< size of fragments received */ + uint32_t last_idx; /**< index of next entry to fill */ + struct ip_frag frags[IP_MAX_FRAG_NUM]; /**< fragments */ +} __rte_cache_aligned; |