Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp.h
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
#define TH_PUSH 0x08 | #define TH_PUSH 0x08 | ||||
#define TH_ACK 0x10 | #define TH_ACK 0x10 | ||||
#define TH_URG 0x20 | #define TH_URG 0x20 | ||||
#define TH_ECE 0x40 | #define TH_ECE 0x40 | ||||
#define TH_CWR 0x80 | #define TH_CWR 0x80 | ||||
#define TH_AE 0x100 /* maps into th_x2 */ | #define TH_AE 0x100 /* maps into th_x2 */ | ||||
#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR) | #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR) | ||||
#define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE" | #define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE" | ||||
#define TCP_GET_FLAGS(th) (((th)->th_x2 << 8) | ((th)->th_flags)) | |||||
tuexen: C question: th_x2 is part of a unsigned char. Doesn't shifting it 8 steps to the left basically… | |||||
rscheffAuthorUnsubmitted Done Inline ActionsI guess it would cast it to int automagically. But I added an explicit cast in the inline function now. thx. rscheff: I guess it would cast it to int automagically. But I added an explicit cast in the inline… | |||||
#define TCP_SET_FLAGS(th, flags) do { \ | |||||
(th)->th_x2 = (((flags) >> 8) & 0xF); \ | |||||
(th)->th_flags = ((flags) & 0xFF); \ | |||||
} while (0) | |||||
u_short th_win; /* window */ | u_short th_win; /* window */ | ||||
u_short th_sum; /* checksum */ | u_short th_sum; /* checksum */ | ||||
u_short th_urp; /* urgent pointer */ | u_short th_urp; /* urgent pointer */ | ||||
}; | }; | ||||
#define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4) | #define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4) | ||||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |
C question: th_x2 is part of a unsigned char. Doesn't shifting it 8 steps to the left basically clear it? In other words: Don't you need to cast it to uint16_t first? Why is this code working?