初级会员

- 积分
- 94
- 金钱
- 94
- 注册时间
- 2020-1-10
- 在线时间
- 45 小时
|
1金钱
PACK_STRUCT_BEGIN
/* The IPv4 header */
struct ip_hdr {
/* version / header length */
PACK_STRUCT_FLD_8(u8_t _v_hl);
/* type of service */
PACK_STRUCT_FLD_8(u8_t _tos);
/* total length */
PACK_STRUCT_FIELD(u16_t _len);
/* identification */
PACK_STRUCT_FIELD(u16_t _id);
/* fragment offset field */
PACK_STRUCT_FIELD(u16_t _offset);
#define IP_RF 0x8000U /* reserved fragment flag */
#define IP_DF 0x4000U /* don't fragment flag */
#define IP_MF 0x2000U /* more fragments flag */
#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */
/* time to live */
PACK_STRUCT_FLD_8(u8_t _ttl);
/* protocol*/
PACK_STRUCT_FLD_8(u8_t _proto);
/* checksum */
PACK_STRUCT_FIELD(u16_t _chksum);
/* source and destination IP addresses */
PACK_STRUCT_FLD_S(ip4_addr_p_t src);
PACK_STRUCT_FLD_S(ip4_addr_p_t dest);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
_v_hl = 0x3004120e, _tos = 0x3004120f, _len = 0x30041210, id = 0x30041212, _offset = 0x30041214, _ttl = 0x30041216, _proto = 0x30041217 _chksum = 0x30041218, src = 0x3004121a, dest = 0x3004121e, src.addr = 0x3004121a, dest.addr = 0x3004121e
IP协议的header结构体因为需要未进行四字节对齐,src.addr为u32_t类型,而src.addr的地址不是四字节对齐,导致访问src.addr时进入HardFault
请问有大佬知道这个问题应该怎么解决么
|
|