mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-20 23:26:56 +08:00
altcp: added 'addrinfo' and 'tcp_state' functions
This commit is contained in:
@@ -242,4 +242,24 @@ altcp_setprio(struct altcp_pcb *conn, u8_t prio)
|
||||
}
|
||||
}
|
||||
|
||||
err_t
|
||||
altcp_get_tcp_addrinfo(struct altcp_pcb *conn, int local, ip_addr_t *addr, u16_t *port)
|
||||
{
|
||||
if (conn && conn->fns && conn->fns->addrinfo) {
|
||||
return conn->fns->addrinfo(conn, local, addr, port);
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
enum tcp_state
|
||||
altcp_dbg_get_tcp_state(struct altcp_pcb *conn)
|
||||
{
|
||||
if (conn && conn->fns && conn->fns->dbg_get_tcp_state) {
|
||||
return conn->fns->dbg_get_tcp_state(conn);
|
||||
}
|
||||
return CLOSED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ALTCP */
|
||||
|
||||
@@ -343,6 +343,29 @@ altcp_tcp_dealloc(struct altcp_pcb *conn)
|
||||
/* no private state to clean up */
|
||||
}
|
||||
|
||||
err_t
|
||||
altcp_tcp_get_tcp_addrinfo(struct altcp_pcb *conn, int local, ip_addr_t *addr, u16_t *port)
|
||||
{
|
||||
if (conn) {
|
||||
struct tcp_pcb *pcb = (struct tcp_pcb *)conn->inner_conn;
|
||||
return tcp_tcp_get_tcp_addrinfo(pcb, local, addr, port);
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
enum tcp_state
|
||||
altcp_tcp_dbg_get_tcp_state(struct altcp_pcb *conn)
|
||||
{
|
||||
if (conn) {
|
||||
struct tcp_pcb *pcb = (struct tcp_pcb *)conn->inner_conn;
|
||||
if (pcb) {
|
||||
return pcb->state;
|
||||
}
|
||||
}
|
||||
return CLOSED;
|
||||
}
|
||||
#endif
|
||||
const struct altcp_functions altcp_tcp_functions = {
|
||||
altcp_tcp_set_poll,
|
||||
altcp_tcp_recved,
|
||||
@@ -358,7 +381,11 @@ const struct altcp_functions altcp_tcp_functions = {
|
||||
altcp_tcp_sndbuf,
|
||||
altcp_tcp_sndqueuelen,
|
||||
altcp_tcp_setprio,
|
||||
altcp_tcp_dealloc
|
||||
altcp_tcp_dealloc,
|
||||
altcp_tcp_get_tcp_addrinfo
|
||||
#ifdef LWIP_DEBUG
|
||||
,altcp_tcp_dbg_get_tcp_state
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* LWIP_ALTCP */
|
||||
|
||||
@@ -2055,6 +2055,30 @@ tcp_debug_state_str(enum tcp_state s)
|
||||
return tcp_state_str[s];
|
||||
}
|
||||
|
||||
err_t
|
||||
tcp_tcp_get_tcp_addrinfo(struct tcp_pcb *pcb, int local, ip_addr_t *addr, u16_t *port)
|
||||
{
|
||||
if (pcb) {
|
||||
if (local) {
|
||||
if (addr) {
|
||||
*addr = pcb->local_ip;
|
||||
}
|
||||
if (port) {
|
||||
*port = pcb->local_port;
|
||||
}
|
||||
} else {
|
||||
if (addr) {
|
||||
*addr = pcb->remote_ip;
|
||||
}
|
||||
if (port) {
|
||||
*port = pcb->remote_port;
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
|
||||
/**
|
||||
* Print a tcp header for debugging purposes.
|
||||
|
||||
Reference in New Issue
Block a user