📄 tcp.h
字号:
/* This file is part of sniffer, a packet capture utility and network moniter The author can be contacted at <mistral@stev.org> the lastest version is avilable from http://stev.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifndef _SNIFF_TCP_H#define _SNIFF_TCP_H#include "list.h"#include "ip.h"#include "stat.h"#include "gui_main.h"struct pkt_tcp { unsigned short source; unsigned short dest; unsigned long seq; unsigned long ack_seq;#if defined(LITTLE_ENDIAN) unsigned short res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, res2:2;#elif defined(BIG_ENDIAN) unsigned short doff:4, res1:4, res2:2, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;#else#error "Please define LITTLE_ENDIAN or BIG_ENDIAN"#endif unsigned short window; unsigned short check; unsigned short urg_ptr;};/* this is for the dest and source of an tcp connection */struct tcp_info { unsigned long ip; /* the network ip address */ char *ip_str; /* the ip address in str format */ char *ip_name; /* the name of the address */ unsigned short port; /* the tcp port in network byte order */ struct pkt_tcp head; /* the last tcp header */ unsigned char state; /* the state ot the connection */ unsigned long data_len; /* the length of the data */ unsigned char *data; /* the data we are holding until the PSH flag */ struct gen_stat stat; /* the stats on this direction */};/* this is for our table of tcp connections */struct tcp_data { struct tcp_info src; /* the source packets */ struct tcp_info dest; /* the dest packets */ unsigned char cycle:7, /* how many cycles until we use this */ delme; /* a flag to say delete me */ time_t timeout; /* we have a pointer to some data here */ void *dat; void (*func_src) (struct sniff_pkt *pkt, struct tcp_data *, char *, int); void (*func_dst) (struct sniff_pkt *pkt, struct tcp_data *, char *, int); void (*func_cleanup) (struct tcp_data *); void (*func_lookup) (struct tcp_data *);};struct tcp_proto_t { unsigned short port; void (*init) (struct tcp_data *);};/* The TCP Sates *//* these are prefixed with S for the sniffer code */#define STCP_CLOSED 0#define STCP_SYN_SENT 1#define STCP_SYN_RECV 2#define STCP_ESTABLISHED 3#define STCP_FIN_WAIT1 4#define STCP_FIN_WAIT2 5#define STCP_RESET 6#define STCP_N 7 /* not known */extern int tcp_timeout;extern int tcp_cycle;extern pthread_mutex_t tcp_mutex_slist; /* lock for sorted list */extern pthread_mutex_t tcp_mutex_vlist; /* lock for view list */extern pthread_mutex_t tcp_gui_mutex;extern struct list_t *tcp_slist; /* sorted list */extern struct list_t *tcp_vlist; /* viewing list */extern struct gen_stat tcp_stat;extern WINDOW *tcp_gui_window;extern int tcp_handle (struct sniff_pkt *pkt, struct pkt_ip *ip, struct pkt_tcp *tcp );extern int tcp_set_state (struct tcp_data *dat , struct tcp_info *info );extern int tcp_tidy( void );extern int tcp_cmp (struct tcp_data *c1, struct tcp_data *c2);extern inline unsigned short tcp_check(struct pkt_tcp *th, unsigned short len, unsigned long saddr, unsigned long daddr);extern void tcp_gui_conn (struct gui_t *p, int t, int x);extern void tcp_gui (struct gui_t *p, int t, int x);extern inline int tcp_gui_print (struct pkt_ip *ip, struct pkt_tcp *tcp, unsigned short length);extern inline char *tcp_flags (struct pkt_tcp *tcp);extern inline char *tcp_gui_flags(struct tcp_info *cur);extern int tcp_init( void );#endif /* _SNIFF_TCP_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -