Skip to content

Commit db8edbd

Browse files
committed
Replace hardcoded flags numbers with TCP_FLAG_ defines
1 parent 9da2593 commit db8edbd

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/wolfip.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ static void tcp_send_ack(struct tsocket *t)
20882088

20892089
static void tcp_send_finack(struct tsocket *t)
20902090
{
2091-
tcp_send_empty(t, 0x11);
2091+
tcp_send_empty(t, TCP_FLAG_FIN | TCP_FLAG_ACK);
20922092
t->sock.tcp.last = t->sock.tcp.seq;
20932093
}
20942094

@@ -3084,7 +3084,7 @@ static void tcp_input(struct wolfIP *S, unsigned int if_idx,
30843084
return; /* malformed: TCP header exceeds IP length */
30853085
}
30863086
tcplen = iplen - (IP_HEADER_LEN + (tcp->hlen >> 2));
3087-
if (tcp->flags & 0x02) {
3087+
if (tcp->flags & TCP_FLAG_SYN) {
30883088
struct tcp_parsed_opts po;
30893089
tcp_parse_options(tcp, frame_len, &po);
30903090
/* Window scale is negotiated only during SYN/SYN-ACK. */
@@ -3166,7 +3166,7 @@ static void tcp_input(struct wolfIP *S, unsigned int if_idx,
31663166
}
31673167
}
31683168
/* Check if SYN */
3169-
if (tcp->flags & 0x02) {
3169+
if (tcp->flags & TCP_FLAG_SYN) {
31703170
if (t->sock.tcp.state == TCP_LISTEN) {
31713171
ip4 syn_dst = ee32(tcp->ip.dst);
31723172
int dst_match = 0;
@@ -3217,7 +3217,7 @@ static void tcp_input(struct wolfIP *S, unsigned int if_idx,
32173217
tcp_process_ts(t, tcp, frame_len);
32183218
break;
32193219
} else if (t->sock.tcp.state == TCP_SYN_SENT) {
3220-
if (tcp->flags == 0x12) {
3220+
if (tcp->flags == (TCP_FLAG_SYN | TCP_FLAG_ACK)) {
32213221
t->sock.tcp.state = TCP_ESTABLISHED;
32223222
tcp_ctrl_rto_stop(t);
32233223
t->sock.tcp.ack = tcp_seq_inc(ee32(tcp->seq), 1);
@@ -3311,9 +3311,9 @@ static void tcp_rto_cb(void *arg)
33113311
}
33123312
ts->sock.tcp.ctrl_rto_retries++;
33133313
if (ts->sock.tcp.state == TCP_SYN_SENT) {
3314-
tcp_send_syn(ts, 0x02);
3314+
tcp_send_syn(ts, TCP_FLAG_SYN);
33153315
} else if (ts->sock.tcp.state == TCP_SYN_RCVD) {
3316-
tcp_send_syn(ts, 0x12);
3316+
tcp_send_syn(ts, TCP_FLAG_SYN | TCP_FLAG_ACK);
33173317
} else if (ts->sock.tcp.state == TCP_FIN_WAIT_1 || ts->sock.tcp.state == TCP_LAST_ACK) {
33183318
tcp_send_finack(ts);
33193319
}
@@ -3663,7 +3663,7 @@ int wolfIP_sock_connect(struct wolfIP *s, int sockfd, const struct wolfIP_sockad
36633663
return -1;
36643664
}
36653665
ts->sock.tcp.ctrl_rto_retries = 0;
3666-
tcp_send_syn(ts, 0x02);
3666+
tcp_send_syn(ts, TCP_FLAG_SYN);
36673667
tcp_ctrl_rto_start(ts, s->last_tick);
36683668
return -WOLFIP_EAGAIN;
36693669
}
@@ -3728,7 +3728,7 @@ int wolfIP_sock_accept(struct wolfIP *s, int sockfd, struct wolfIP_sockaddr *add
37283728
* the caller could still close the listening socket
37293729
* while we're still accepting.
37303730
*/
3731-
tcp_send_syn(newts, 0x12);
3731+
tcp_send_syn(newts, TCP_FLAG_SYN | TCP_FLAG_ACK);
37323732
newts->sock.tcp.seq++;
37333733
if (sin) {
37343734
sin->sin_family = AF_INET;

0 commit comments

Comments
 (0)