Skip to content

Commit c90622b

Browse files
authored
Merge pull request #59 from thearossman/main
Convert tcp flag accessors to u8 to support filtering
2 parents 71a754d + 674a413 commit c90622b

File tree

1 file changed

+20
-20
lines changed
  • core/src/protocols/packet

1 file changed

+20
-20
lines changed

core/src/protocols/packet/tcp.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -103,62 +103,62 @@ impl<'a> Tcp<'a> {
103103

104104
/// Returns `true` if the (historical) nonce sum flag is set.
105105
#[inline]
106-
pub fn ns(&self) -> bool {
107-
(self.header.data_offset_to_ns & 0x01) != 0
106+
pub fn ns(&self) -> u8 {
107+
((self.header.data_offset_to_ns & 0x01) != 0) as u8
108108
}
109109

110110
/// Returns `true` if the congestion window reduced flag is set.
111111
#[inline]
112-
pub fn cwr(&self) -> bool {
113-
(self.flags() & CWR) != 0
112+
pub fn cwr(&self) -> u8 {
113+
((self.flags() & CWR) != 0) as u8
114114
}
115115

116116
/// Returns `true` if the ECN-Echo flag is set.
117117
#[inline]
118-
pub fn ece(&self) -> bool {
119-
(self.flags() & ECE) != 0
118+
pub fn ece(&self) -> u8 {
119+
((self.flags() & ECE) != 0) as u8
120120
}
121121

122122
/// Returns `true` if the urgent pointer flag is set.
123123
#[inline]
124-
pub fn urg(&self) -> bool {
125-
(self.flags() & URG) != 0
124+
pub fn urg(&self) -> u8 {
125+
((self.flags() & URG) != 0) as u8
126126
}
127127

128128
/// Returns `true` if the acknowledgment flag is set.
129129
#[inline]
130-
pub fn ack(&self) -> bool {
131-
(self.flags() & ACK) != 0
130+
pub fn ack(&self) -> u8 {
131+
((self.flags() & ACK) != 0) as u8
132132
}
133133

134134
/// Returns `true` if the push flag is set.
135135
#[inline]
136-
pub fn psh(&self) -> bool {
137-
(self.flags() & PSH) != 0
136+
pub fn psh(&self) -> u8 {
137+
((self.flags() & PSH) != 0) as u8
138138
}
139139

140140
/// Returns `true` if the reset flag is set.
141141
#[inline]
142-
pub fn rst(&self) -> bool {
143-
(self.flags() & RST) != 0
142+
pub fn rst(&self) -> u8 {
143+
((self.flags() & RST) != 0) as u8
144144
}
145145

146146
/// Returns `true` if the synchronize flag is set.
147147
#[inline]
148-
pub fn syn(&self) -> bool {
149-
(self.flags() & SYN) != 0
148+
pub fn syn(&self) -> u8 {
149+
((self.flags() & SYN) != 0) as u8
150150
}
151151

152152
/// Returns `true` if the FIN flag is set.
153153
#[inline]
154-
pub fn fin(&self) -> bool {
155-
(self.flags() & FIN) != 0
154+
pub fn fin(&self) -> u8 {
155+
((self.flags() & FIN) != 0) as u8
156156
}
157157

158158
/// Returns `true` if both `SYN` and `ACK` flags are set.
159159
#[inline]
160-
pub fn synack(&self) -> bool {
161-
(self.flags() & (ACK | SYN)) != 0
160+
pub fn synack(&self) -> u8 {
161+
((self.flags() & (ACK | SYN)) != 0) as u8
162162
}
163163
}
164164

0 commit comments

Comments
 (0)