|
|
调用tcpheader->th_sport = htons (9877)时不知道为何出现以下错误?
syn.c:106: 错误:‘struct tcphdr’ 没有名为 ‘th_sport’ 的成员
syn.c:108: 错误:‘struct tcphdr’ 没有名为 ‘th_dport’ 的成员
syn.c:109: 错误:‘struct tcphdr’ 没有名为 ‘th_seq’ 的成员
syn.c:110: 错误:‘struct tcphdr’ 没有名为 ‘th_flags’ 的成员
经查看文件/usr/include/netinet/tcp.h,
得知:
#ifdef __FAVOR_BSD
struct tcphdr
{
u_int16_t th_sport; /* source port */
u_int16_t th_dport;
......
};
#else /* !__FAVOR_BSD */
struct tcphdr
{
u_int16_t source;
u_int16_t dest;
u_int32_t seq;
u_int32_t ack_seq;
......
}; |
|