2015-01-31 09:13:33 +00:00
|
|
|
/**
|
|
|
|
tcpconn.h
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (C) 1999-2000 RTFM, Inc.
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
|
|
|
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. All advertising materials mentioning features or use of this software
|
|
|
|
must display the following acknowledgement:
|
2023-08-14 10:37:08 +00:00
|
|
|
|
2015-01-31 09:13:33 +00:00
|
|
|
This product includes software developed by Eric Rescorla for
|
|
|
|
RTFM, Inc.
|
|
|
|
|
|
|
|
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
|
|
|
used to endorse or promote products derived from this
|
|
|
|
software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
2023-08-14 10:37:08 +00:00
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH
|
|
|
|
DAMAGE.
|
2015-01-31 09:13:33 +00:00
|
|
|
|
|
|
|
$Id: tcpconn.h,v 1.4 2001/07/20 23:33:15 ekr Exp $
|
|
|
|
|
|
|
|
|
|
|
|
ekr@rtfm.com Tue Dec 29 13:00:52 1998
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _tcpconn_h
|
|
|
|
#define _tcpconn_h
|
|
|
|
|
|
|
|
typedef struct segment_ {
|
2023-08-14 10:37:08 +00:00
|
|
|
u_char *data;
|
|
|
|
u_int len;
|
|
|
|
tcp_seq s_seq;
|
|
|
|
packet *p;
|
|
|
|
struct segment_ *next;
|
2015-01-31 09:13:33 +00:00
|
|
|
} segment;
|
|
|
|
|
|
|
|
typedef struct stream_data_ {
|
2023-08-14 10:37:08 +00:00
|
|
|
tcp_seq seq;
|
|
|
|
tcp_seq ack;
|
|
|
|
short close;
|
|
|
|
segment *oo_queue;
|
2015-01-31 09:13:33 +00:00
|
|
|
} stream_data;
|
|
|
|
|
2023-08-20 10:20:41 +00:00
|
|
|
extern char *state_map[];
|
|
|
|
|
2015-01-31 09:13:33 +00:00
|
|
|
typedef struct tcp_conn_ {
|
2023-08-14 10:37:08 +00:00
|
|
|
int conn_number;
|
|
|
|
int state;
|
|
|
|
#define TCP_STATE_SYN1 1
|
|
|
|
#define TCP_STATE_SYN2 2
|
|
|
|
#define TCP_STATE_ACK 3
|
|
|
|
#define TCP_STATE_ESTABLISHED 4
|
|
|
|
#define TCP_STATE_FIN1 5
|
2015-01-31 09:13:33 +00:00
|
|
|
#define TCP_STATE_CLOSED 6
|
2023-08-14 10:37:08 +00:00
|
|
|
/*The address which sent the first SYN*/
|
|
|
|
struct sockaddr_storage i_addr;
|
|
|
|
u_short i_port;
|
|
|
|
char *i_name;
|
|
|
|
char *i_num;
|
|
|
|
|
|
|
|
/*The address which sent the second SYN*/
|
|
|
|
struct sockaddr_storage r_addr;
|
|
|
|
u_short r_port;
|
|
|
|
char *r_name;
|
|
|
|
char *r_num;
|
|
|
|
|
|
|
|
stream_data i2r; /*The stream from initiator to responder*/
|
|
|
|
stream_data r2i; /*The stream from responder to initiator*/
|
|
|
|
|
|
|
|
struct timeval start_time;
|
|
|
|
struct timeval last_seen_time;
|
|
|
|
proto_handler *analyzer; /*The analyzer to call with new data*/
|
|
|
|
struct conn_struct_ *backptr;
|
2015-01-31 09:13:33 +00:00
|
|
|
} tcp_conn;
|
|
|
|
|
2023-08-20 10:20:41 +00:00
|
|
|
typedef struct conn_struct_ {
|
|
|
|
tcp_conn conn;
|
|
|
|
struct conn_struct_ *next;
|
|
|
|
struct conn_struct_ *prev;
|
|
|
|
} conn_struct;
|
|
|
|
|
2023-08-14 10:37:08 +00:00
|
|
|
int tcp_find_conn PROTO_LIST((tcp_conn * *connp,
|
|
|
|
int *directionp,
|
|
|
|
struct sockaddr_storage *src_addr,
|
|
|
|
u_short src_port,
|
|
|
|
struct sockaddr_storage *dst_addr,
|
|
|
|
u_short dst_port));
|
2015-01-31 09:13:33 +00:00
|
|
|
|
2023-08-14 10:37:08 +00:00
|
|
|
int tcp_create_conn PROTO_LIST((tcp_conn * *connp,
|
|
|
|
struct sockaddr_storage *initiator_addr,
|
|
|
|
u_short initiator_port,
|
|
|
|
struct sockaddr_storage *responder_addr,
|
|
|
|
u_short responder_port));
|
2015-01-31 09:13:33 +00:00
|
|
|
|
2023-08-14 10:37:08 +00:00
|
|
|
int tcp_destroy_conn PROTO_LIST((tcp_conn * conn));
|
|
|
|
int free_tcp_segment_queue PROTO_LIST((segment * seg));
|
|
|
|
int copy_tcp_segment_queue PROTO_LIST((segment * *out, segment *in));
|
2020-08-27 14:39:01 +00:00
|
|
|
|
|
|
|
int clean_old_conn(void);
|
2023-08-20 10:20:41 +00:00
|
|
|
void list_all_conn(void);
|
2020-08-27 14:39:01 +00:00
|
|
|
int destroy_all_conn(void);
|
|
|
|
|
2023-08-20 10:20:41 +00:00
|
|
|
extern conn_struct *first_conn;
|
|
|
|
|
2015-01-31 09:13:33 +00:00
|
|
|
#endif
|