original files of m241
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,576 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptcp_debug.c,v $ $Revision: 1.25.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/iptcp/src/iptcp_debug.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_KERNEL
|
||||
#define IPCOM_KERNEL
|
||||
#endif
|
||||
#include "iptcp_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#include "iptcp_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_state_to_str
|
||||
*===========================================================================
|
||||
* Description: Returns a string representation of the state.
|
||||
* Parameters: state - One of the TCP states.
|
||||
* Returns: A string representation.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL IP_CONST char *
|
||||
iptcp_state_to_str(int state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case IPTCP_STATE_CLOSED:
|
||||
return "CLOSED";
|
||||
case IPTCP_STATE_LISTEN:
|
||||
return "LISTEN";
|
||||
case IPTCP_STATE_SYN_SENT:
|
||||
return "SYN_SENT";
|
||||
case IPTCP_STATE_SYN_RCVD:
|
||||
return "SYN_RECV";
|
||||
case IPTCP_STATE_ESTABLISHED:
|
||||
return "ESTABLISHED";
|
||||
case IPTCP_STATE_CLOSE_WAIT:
|
||||
return "CLOSE_WAIT";
|
||||
case IPTCP_STATE_FIN_WAIT_1:
|
||||
return "FIN_WAIT_1";
|
||||
case IPTCP_STATE_CLOSING:
|
||||
return "CLOSING";
|
||||
case IPTCP_STATE_LAST_ACK:
|
||||
return "LAST_ACK";
|
||||
case IPTCP_STATE_FIN_WAIT_2:
|
||||
return "FIN_WAIT_2";
|
||||
case IPTCP_STATE_TIME_WAIT:
|
||||
return "TIME_WAIT";
|
||||
case IPTCP_STATE_DELETE_TCB:
|
||||
return "DELETE_TCB";
|
||||
default:
|
||||
return "Unknown state";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_timer_to_str
|
||||
*===========================================================================
|
||||
* Description: Returns a string representation of the timer type.
|
||||
* Parameters: state - One of the TCP timer types.
|
||||
* Returns: A string representation.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL IP_CONST char *
|
||||
iptcp_timer_to_str(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IPTCP_TMRT_CONN:
|
||||
return "CONN";
|
||||
case IPTCP_TMRT_RETR:
|
||||
return "RETR";
|
||||
case IPTCP_TMRT_DACK:
|
||||
return "DACK";
|
||||
case IPTCP_TMRT_PERS:
|
||||
return "PERS";
|
||||
case IPTCP_TMRT_LOPE:
|
||||
return "LOPE";
|
||||
case IPTCP_TMRT_TIWA:
|
||||
return "TIWA";
|
||||
case IPTCP_TMRT_KEEP:
|
||||
return "KEEP";
|
||||
case IPTCP_TMRT_LNGR:
|
||||
return "LNGR";
|
||||
case IPTCP_TMRT_RSRT:
|
||||
return "RSRT";
|
||||
case IPTCP_TMRT_ZWP:
|
||||
return "ZWP";
|
||||
default:
|
||||
return "Unkown timer type";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef IPNET_DEBUG
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_tick_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: unused -
|
||||
* buf -
|
||||
* buf_len -
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_tick_to_string(void *unused, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
IPCOM_UNUSED_ARG(unused);
|
||||
return ipcom_snprintf(buf, buf_len, "TCP tick timer.");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
iptcp_to_string(Iptcp_socket *sock, const char *type, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return ipcom_snprintf(buf, buf_len, "TCP %s timer on socket %d",
|
||||
type, sock->ipcom.fd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_pers_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_pers_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
int offset = iptcp_to_string(sock, "persist", buf, buf_len);
|
||||
offset += ipcom_snprintf(&buf[offset], buf_len - offset, " response %sseen retrans %u",
|
||||
sock->tcb->peer_responded_to_pers ? "" : "not ",
|
||||
sock->tcb->retr_count);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_keep_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_keep_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "keep-alive", buf, buf_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_conn_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_conn_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "connection", buf, buf_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_dack_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_dack_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "delayed ack", buf, buf_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_retr_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_retr_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
Iptcp_tcb *tcb = sock->tcb;
|
||||
Iptcp_segment *seg = tcb->send.resend_head;
|
||||
int offset;
|
||||
|
||||
if (seg == IP_NULL)
|
||||
return 0;
|
||||
offset = iptcp_to_string(sock, "retransmission", buf, buf_len);
|
||||
offset += ipcom_snprintf(&buf[offset], buf_len - offset, " seg %u retrans %u",
|
||||
(unsigned) seg->seq_start,
|
||||
tcb->retr_count);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_tiwa_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_tiwa_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "time wait", buf, buf_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_lope_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_lope_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "lost peer", buf, buf_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_lngr_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_lngr_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "linger", buf, buf_len);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_zwp_to_string
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
iptcp_zwp_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len)
|
||||
{
|
||||
return iptcp_to_string(sock, "iptcp_zwp_to_string", buf, buf_len);
|
||||
}
|
||||
#endif /* IPNET_DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPTCP_DEBUG
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_pkt_freecheck
|
||||
*===========================================================================
|
||||
* Description: Called from ipcom_pkt_free to verify pkt not in timerlist.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
iptcp_pkt_freecheck(Ipcom_pkt *pkt)
|
||||
{
|
||||
Ip_u32 isr;
|
||||
int i;
|
||||
Iptcp_segment *tcp_seg;
|
||||
Ipcom_pkt *spkt;
|
||||
Iptcp_socket *sock;
|
||||
|
||||
isr = ipcom_interrupt_disable();
|
||||
|
||||
if (IPCOM_PKT_HAS_MULTIPLE_OWNERS(pkt) == IP_FALSE)
|
||||
{
|
||||
for (i = 0; i < IP_STACK(conf_max_sockets); i++)
|
||||
{
|
||||
sock = ipstack->sockets[i];
|
||||
if (sock == IP_NULL || sock->tcb == IP_NULL)
|
||||
continue;
|
||||
ipcom_atomic_inc(&sock->ref_count);
|
||||
for (tcp_seg = sock->tcb->send.resend_head;
|
||||
tcp_seg != IP_NULL;
|
||||
tcp_seg = tcp_seg->next)
|
||||
{
|
||||
ip_assert(pkt != tcp_seg->pkt);
|
||||
}
|
||||
for (spkt = sock->tcb->send.head;
|
||||
spkt != IP_NULL;
|
||||
spkt = spkt->next)
|
||||
{
|
||||
ip_assert(spkt != pkt);
|
||||
}
|
||||
ipcom_atomic_dec(&sock->ref_count);
|
||||
}
|
||||
}
|
||||
|
||||
ipcom_interrupt_enable(isr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_ctrl_verify_retransq
|
||||
*===========================================================================
|
||||
* Description: Verifies that a packet can be found in the retransmission
|
||||
* queue on one of the TCP sockets.
|
||||
* Parameters: pkt - Packet to find.
|
||||
* Returns: The socket descriptor where the packet is in retrasmission queue.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_fd
|
||||
iptcp_ctrl_verify_retransq(Ipcom_pkt *pkt)
|
||||
{
|
||||
int i;
|
||||
Iptcp_socket *sock;
|
||||
Iptcp_segment *seg;
|
||||
|
||||
for (i = 0; i < IP_STACK(conf_max_sockets); i++)
|
||||
{
|
||||
sock = ipstack->sockets[i];
|
||||
if (sock == IP_NULL || sock->tcb == IP_NULL)
|
||||
/* Not a TCP socket */
|
||||
continue;
|
||||
|
||||
for (seg = sock->tcb->send.resend_head; seg != IP_NULL; seg = seg->next)
|
||||
{
|
||||
if (seg->pkt == pkt)
|
||||
return sock->ipcom.fd;
|
||||
}
|
||||
}
|
||||
return IP_SOCKERR;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_ctrl_verify_sockrecvq
|
||||
*===========================================================================
|
||||
* Description: Verifies that a packet can be found in the receive
|
||||
* queue on one of the sockets.
|
||||
* Parameters: pkt - Packet to find.
|
||||
* Returns: The socket descriptor where the packet is queued.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_fd
|
||||
iptcp_ctrl_verify_sockrecvq(Ipcom_pkt *pkt)
|
||||
{
|
||||
int i;
|
||||
Iptcp_socket *sock;
|
||||
Ipcom_pkt *rpkt;
|
||||
|
||||
for (i = 0; i < IP_STACK(conf_max_sockets); i++)
|
||||
{
|
||||
sock = ipstack->sockets[i];
|
||||
if (sock == IP_NULL)
|
||||
continue;
|
||||
if (sock->tcb == IP_NULL)
|
||||
rpkt = sock->rcv_head;
|
||||
else
|
||||
rpkt = sock->rcv_head;
|
||||
|
||||
for (; rpkt != IP_NULL; rpkt = rpkt->next)
|
||||
{
|
||||
if (rpkt == pkt)
|
||||
return sock->ipcom.fd;
|
||||
}
|
||||
}
|
||||
return IP_SOCKERR;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_ctrl_verify_sockooorecvq
|
||||
*===========================================================================
|
||||
* Description: Verifies that a packet can be found in the receive queue
|
||||
* for out-of-order packets on one of the TCP sockets.
|
||||
* Parameters: pkt - Packet to find.
|
||||
* str - Buffer to print the status.
|
||||
* Returns: The socket descriptor where the packet is queued in the
|
||||
* out-of-order queue.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_fd
|
||||
iptcp_ctrl_verify_sockooorecvq(Ipcom_pkt *pkt)
|
||||
{
|
||||
int i;
|
||||
Iptcp_socket *sock;
|
||||
Iptcp_segment *seg;
|
||||
|
||||
for (i = 0; i < IP_STACK(conf_max_sockets); i++)
|
||||
{
|
||||
sock = ipstack->sockets[i];
|
||||
if (sock == IP_NULL || sock->tcb == IP_NULL)
|
||||
/* Not a TCP socket */
|
||||
continue;
|
||||
|
||||
for (seg = sock->tcb->recv.out_of_order_seg; seg != IP_NULL; seg = seg->next)
|
||||
{
|
||||
if (seg->pkt == pkt)
|
||||
return sock->ipcom.fd;
|
||||
}
|
||||
}
|
||||
return IP_SOCKERR;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptcp_print_tcb_flags
|
||||
*===========================================================================
|
||||
* Description: Converts the flags field from a TCB to a human readable form
|
||||
* Parameters: flags - flags from the TCB field of a TCP socket.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef NOT_CALLED_BY_ANY_OTHER_FUNCTION
|
||||
IP_PUBLIC void
|
||||
iptcp_print_tcb_flags(Ip_u32 flags)
|
||||
{
|
||||
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
flags & IPTCP_TCPC_FLAG_PASSIVE_OPEN ? "PASSIVE_OPEN\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_SOCK_CLOSED ? "SOCK_CLOSED\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_CONNABORTED ? "CONNABORTED\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_SMALL_PKT_OUT ? "SMALL_PKT_OUT\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_NO_SMDE ? "NO_SMDE\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_RTT ? "RTT\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_ACK_PENDING ? "ACK_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_DACK_PENDING ? "DACK_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_PERS_PENDING ? "PERS_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_KEEP_PENDING ? "KEEP_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_FIN_PENDING ? "FIN_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_TIMESTAMP_OPT ? "TIMESTAMP_OPT\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_WND_SCALE_OPT ? "WND_SCALE_OPT\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_RESENDING ? "RESENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_FAST_RETRANS ? "FAST_RETRANS\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_SENDER_URG ? "SENDER_URG\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_RECEIVER_URG ? "RECVEIVER_URG\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_SACK ? "SACK\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_CORK ? "CORK\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_RFC_1122_URG ? "RFC_1122_URG\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_KCLOSE_PENDING ? "KCLOSE_PENDING\n" : "",
|
||||
flags & IPTCP_TCPC_FLAG_USER_REF ? "USER_REF\n" : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPTCP_DEBUG */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptcp_h.h,v $ $Revision: 1.28.10.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/iptcp/src/iptcp_h.h,v $
|
||||
* $Author: jli7 $ $Date: 2015-02-09 03:38:14 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPTCP_H_H
|
||||
#define IPTCP_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/* Definitions that are private to the TCP module */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "iptcp_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPNET
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_h.h>
|
||||
#endif
|
||||
|
||||
#ifdef IPLITE
|
||||
#include <iplite.h>
|
||||
#include <iplite_h.h>
|
||||
#endif
|
||||
|
||||
#include "iptcp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* syslog
|
||||
*===========================================================================
|
||||
*/
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_PRIORITY IPTCP_SYSLOG_PRIORITY
|
||||
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPTCP
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DEBUG/ASSERT
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#ifdef IPTCP_DEBUG
|
||||
#define IPTCP_DEBUG_LINE(x) x
|
||||
#else
|
||||
#define IPTCP_DEBUG_LINE(x) IP_NOOP
|
||||
#endif /* IPTCP_DEBUG */
|
||||
|
||||
|
||||
/* Stack specific defines */
|
||||
# define IP_STACK(x) ipnet_ ## x
|
||||
# define IP_STACK_CONST(x) IPNET_ ## x
|
||||
# define IPTCP_SOCK_VR(s) ((s)->vr_index)
|
||||
# define IPTCP_SOCK_MRIO(s) ((s)->mprio)
|
||||
# define IPTCP_SOCK_ADD_WAITING_RECEIVER(s) IPNET_SOCK_ADD_WAITING_RECEIVER(s)
|
||||
# define IPTCP_SOCK_DEL_WAITING_RECEIVER(s) \
|
||||
do { \
|
||||
if (IPTCP_SOCK_HAS_WAITING_RECEIVERS(s)) \
|
||||
IPNET_SOCK_DEL_WAITING_RECEIVER(s); \
|
||||
} while (0)
|
||||
# define IPTCP_SOCK_HAS_WAITING_RECEIVERS(s) IPNET_SOCK_HAS_WAITING_RECEIVERS(s)
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPTCP code lock
|
||||
*===========================================================================
|
||||
*/
|
||||
#ifdef IPNET
|
||||
# define IPTCP_DATA_LOCK(sl) IPNET_DATA_LOCK(sl)
|
||||
# define IPTCP_DATA_UNLOCK(sl) IPNET_DATA_UNLOCK(sl)
|
||||
# define IPTCP_DATA_ISLOCKED(sl) IPNET_DATA_ISLOCKED(sl)
|
||||
# define IPTCP_DATA_ISLOCKED_ASSERT(sl) IPNET_DATA_ISLOCKED_ASSERT(sl)
|
||||
#else /* IPLITE */
|
||||
# define IPTCP_CODE_LOCK_READ() IPLITE_CODE_LOCK()
|
||||
# define IPTCP_CODE_LOCK_WRITE() IPLITE_CODE_LOCK()
|
||||
# define IPTCP_CODE_LOCK() IPTCP_CODE_LOCK_WRITE()
|
||||
# define IPTCP_CODE_UNLOCK() IPLITE_CODE_UNLOCK()
|
||||
# define IPTCP_DATA_LOCK(x) IP_NOOP
|
||||
# define IPTCP_DATA_UNLOCK(x) IP_NOOP
|
||||
# define IPTCP_DATA_ISLOCKED(x) IP_FALSE
|
||||
# define IPTCP_DATA_ISLOCKED_ASSERT(sl) IP_NOOP
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Parameters for one TCP segment
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Iptcp_segment_struct
|
||||
{
|
||||
struct Iptcp_segment_struct *next;
|
||||
/* Next packet in resend list for outgoing and next
|
||||
out-of-order package for incoming */
|
||||
Ipcom_pkt *pkt; /* Pointer to the packet that holds the TCP segment data */
|
||||
Ip_u32 seq_start; /* First sequence number for segment */
|
||||
Ip_u32 seq_end; /* Last sequence number for segment */
|
||||
int app_start; /* (Only send) Start of application data */
|
||||
int app_end; /* (Only send) End of application data */
|
||||
Ip_u16 flags_n; /* The TCP flags for this segment */
|
||||
#ifdef IPTCP_USE_SACK_OPT
|
||||
Ip_u8 is_sacked; /* (Only send) IP_TRUE if the segment has
|
||||
been ACK:ed in a selective ACK option
|
||||
(Only receiver) IP_FALSE if this segment
|
||||
has not been included in a SACK option yet */
|
||||
#endif
|
||||
Ip_s64 last_msec; /* Last timestamp this segment was processed */
|
||||
}
|
||||
Iptcp_segment;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Iptcp_stats
|
||||
*===========================================================================
|
||||
* IPTCP debug statistics useful for debugging the TCP module if things go wrong.
|
||||
*/
|
||||
#ifdef IPNET_STATISTICS
|
||||
#define IPTCP_STATISTICS
|
||||
#endif
|
||||
|
||||
#if defined(IPTCP_DEBUG) || defined(IPTCP_STATISTICS)
|
||||
typedef struct Iptcp_stats_struct
|
||||
{
|
||||
int tcp_input;
|
||||
int tcp_input_hdr_trunc;
|
||||
int tcp_input_badchksum;
|
||||
#ifdef IPTCP_USE_AO
|
||||
int tcp_input_badauth;
|
||||
#endif
|
||||
int tcp_input_sock_match;
|
||||
int tcp_input_sock_nomatch;
|
||||
int tcp_input_sock_closed;
|
||||
int tcp_input_sock_closed2;
|
||||
int tcp_input_sock_data_in_close_wait;
|
||||
int tcp_input_rst_listen;
|
||||
int tcp_input_nosyn_listen;
|
||||
int tcp_input_backlog_enobufs;
|
||||
int tcp_input_qrecv_enobufs;
|
||||
int tcp_input_syn_inval_state;
|
||||
int tcp_input_syn_inval_option;
|
||||
int tcp_input_inval_win;
|
||||
int tcp_input_rst;
|
||||
int tcp_input_must_have_ack;
|
||||
int tcp_input_must_not_have_ack;
|
||||
int tcp_input_toohigh_ack;
|
||||
int tcp_input_fin;
|
||||
int tcp_input_fin_err;
|
||||
int tcp_input_fin_ok;
|
||||
int tcp_input_queue_pkt_ok;
|
||||
int tcp_input_queue_pkt_outoforder;
|
||||
int tcp_input_queue_pkt_err;
|
||||
int tcp_input_state_err;
|
||||
int tcp_input_listen_invalid_src_addr;
|
||||
|
||||
int tcp_output;
|
||||
int tcp_output_err;
|
||||
int tcp_output_pkt_nomem;
|
||||
int tcp_output_pkt_enobufs2;
|
||||
|
||||
int tcp_send;
|
||||
int tcp_send_err;
|
||||
int tcp_send_slept;
|
||||
int tcp_send_sock_errno;
|
||||
int tcp_send_enotconn;
|
||||
int tcp_send_ewouldblock;
|
||||
int tcp_sendto;
|
||||
int tcp_timer_nomem;
|
||||
int tcp_timer_enobufs;
|
||||
int tcp_state_enobufs;
|
||||
int tcp_sock_enobufs;
|
||||
int tcp_listen_backlog_enobufs;
|
||||
|
||||
int tcp_pkt_drain_outoforder;
|
||||
}
|
||||
Iptcp_stats;
|
||||
|
||||
#define IPTCP_STATS(xvar) iptcp->stats.xvar
|
||||
|
||||
#define IPTCP_STAT_LINE(xline) xline
|
||||
|
||||
#else /* No TCP stats */
|
||||
#define IPTCP_STATS(xvar) IP_NOOP
|
||||
#define IPTCP_STAT_LINE(xline) IP_NOOP
|
||||
#endif /* defined(IPTCP_DEBUG) || defined(IPTCP_STATISTICS) */
|
||||
|
||||
#if defined(IPTCP_USE_AO)
|
||||
typedef struct Iptcp_ao_inst_struct
|
||||
{
|
||||
Ip_u32 local_isn; /* local Initial sequence number, this is
|
||||
needed when changed to new MKT, net-byte */
|
||||
Ip_u32 remote_isn; /* remote Initial sequence number, this is
|
||||
needed when changed to new MKT, net-byte */
|
||||
Iptcp_ao_mkt_inst *current_key; /* current MKT instance for this TCB */
|
||||
Iptcp_ao_mkt_inst *rnext_key; /* next received MKT instance for this TCB */
|
||||
Iptcp_ao_mkt_inst *snext_key; /* next send MKT instance for this TCB */
|
||||
Iptcp_ao_mkt_inst *backup_key; /* backup MKT instance rnext_key or snext_key */
|
||||
Iptcp_ao_keyids *keyids;
|
||||
Ip_u8 *tkey[2]; /* 0 for send, 1 for receive
|
||||
CONNECTION INIT
|
||||
0 - Send_SYN_traffic_key
|
||||
1 - Receive_SYN_traffic_key
|
||||
ESTABLISHED
|
||||
0 - Send_other_traffic_key
|
||||
1 - Receive_other_traffic_key */
|
||||
Ip_u32 sne[2]; /* 0/1 for send/receive, detailed in RFC5925 6.2 */
|
||||
Ip_u32 prev_seq[2]; /* 0/1 for send/receive, detailed in RFC5925 6.2 */
|
||||
Ip_u8 sne_flag[2]; /* 0/1 for send/receive, detailed in RFC5925 6.2 */
|
||||
Ip_u8 accept_icmp_flag; /* whether accept the 'hard error' */
|
||||
}
|
||||
Iptcp_ao_inst;
|
||||
|
||||
typedef struct Iptcp_ao_mkt_list_struct
|
||||
{
|
||||
Iptcp_ao_mkt mkt;
|
||||
Ipcom_list next; /* MKT(Master Key Tuple) list next pointer,
|
||||
head in struct Ipsctp_ao_infor.mkt_head[x] */
|
||||
}
|
||||
Iptcp_ao_mkt_list;
|
||||
|
||||
typedef struct Ipsctp_ao_infor_struct
|
||||
{
|
||||
Ipcom_list mkt_head[2]; /* MKT(Master Key Tuple) list
|
||||
[domain: 0=inet,1=inet6]
|
||||
for struct Iptcp_ao_mkt_list */
|
||||
Ip_u32 log_rate_limit_val; /* current remained log rate limit number */
|
||||
Ip_bool log_rate_limit_restart; /* flag for restart log rate limit timer */
|
||||
}
|
||||
Ipsctp_ao_infor;
|
||||
#endif /* defined(IPTCP_USE_AO) */
|
||||
|
||||
|
||||
typedef struct Iptcp_data_struct
|
||||
{
|
||||
/*
|
||||
* TCP initial send sequence number
|
||||
*/
|
||||
Ip_u32 iss;
|
||||
/*
|
||||
* The time a socket was last created
|
||||
*/
|
||||
Ip_s64 msec_last_sock_create;
|
||||
|
||||
#ifndef IPCOM_FORWARDER_NAE
|
||||
/*
|
||||
* TCP segment header slab cache
|
||||
*/
|
||||
Ipcom_memory_cache *tcp_segment_slab;
|
||||
/*
|
||||
* List of active socket. All of the sockets in this list must be
|
||||
* checked for timeouts each tick.
|
||||
*/
|
||||
Ipcom_list active_head;
|
||||
/*
|
||||
* Timer for the closes (in time) TCP timeout.
|
||||
*/
|
||||
Ipnet_timeout *tmo;
|
||||
/*
|
||||
* Absolute time when the next IPTCP timer expires, valid only if
|
||||
* 'tmo' is != IP_NULL.
|
||||
*/
|
||||
Ip_s64 next_timeout_abs_msec;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* List of TCB in states that is short lived under normal
|
||||
* operations. SYN_RCV, FIN_WAIT_1 & LAST_ACK. The session that
|
||||
* has been in this state for the longest time is sitting at the
|
||||
* front of the list.
|
||||
*/
|
||||
Ipcom_list transient_head;
|
||||
/*
|
||||
* List of sockets that an application has called close() on
|
||||
*/
|
||||
Ipcom_list user_closed_sock_head;
|
||||
|
||||
#ifdef IPTCP_USE_AO
|
||||
Ipsctp_ao_infor ao;
|
||||
#endif
|
||||
|
||||
#if defined(IPTCP_DEBUG) || defined(IPTCP_STATISTICS)
|
||||
Iptcp_stats stats; /* Statistics */
|
||||
#endif
|
||||
|
||||
/*Secret key for generating initial sequnce number*/
|
||||
Ip_u32 key[4];
|
||||
}
|
||||
Iptcp_data;
|
||||
|
||||
|
||||
IP_EXTERN Iptcp_data *iptcp;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int iptcp_send_reset(IP_CONST void *peer_addr,
|
||||
IP_CONST void *local_addr,
|
||||
Iptcp_socket *sock,
|
||||
Iptcp_segment *seg);
|
||||
|
||||
IP_GLOBAL IP_CONST char *iptcp_state_to_str(int state);
|
||||
IP_GLOBAL IP_CONST char *iptcp_timer_to_str(int type);
|
||||
|
||||
IP_GLOBAL int iptcp_tick_to_string(void *unused, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_pers_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_keep_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_conn_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_dack_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_retr_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_tiwa_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_lope_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_lngr_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
IP_GLOBAL int iptcp_zwp_to_string(Iptcp_socket *sock, char *buf, Ip_size_t buf_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPTCP_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user