Skip to content

Commit 3088294

Browse files
committed
EthernetClient - status() added
1 parent 2535523 commit 3088294

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/EthernetClient.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,13 @@ uint16_t
369369
UIPClient::remotePort(void)
370370
{
371371
return data ? ntohs(uip_conns[data->conn_index].rport) : 0;
372-
}
372+
}
373+
374+
uint8_t
375+
UIPClient::status()
376+
{
377+
return !data ? UIP_CLOSED : uip_conns[data->conn_index].tcpstateflags & UIP_TS_MASK;
378+
}
373379

374380
void
375381
uipclient_appcall(void)

src/EthernetClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class EthernetClient : public Client {
7777

7878
IPAddress remoteIP();
7979
uint16_t remotePort();
80+
81+
uint8_t status();
8082

8183
private:
8284
EthernetClient(struct uip_conn *_conn);

src/tcp_states.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#ifndef UIP_TCP_STATES_H
3+
#define UIP_TCP_STATES_H
4+
5+
#include <utility/uip.h>
6+
7+
// common constants for client.state() return values
8+
enum uip_tcp_state {
9+
CLOSED = UIP_CLOSED,
10+
SYN_SENT = UIP_SYN_SENT,
11+
SYN_RCVD = UIP_SYN_RCVD,
12+
ESTABLISHED = UIP_ESTABLISHED,
13+
FIN_WAIT_1 = UIP_FIN_WAIT_1,
14+
FIN_WAIT_2 = UIP_FIN_WAIT_2,
15+
CLOSE_WAIT = 10, // not used
16+
CLOSING = UIP_CLOSING,
17+
LAST_ACK = UIP_LAST_ACK,
18+
TIME_WAIT = UIP_TIME_WAIT
19+
};
20+
21+
#endif

0 commit comments

Comments
 (0)