📄 icmp.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_ICMP_H#define _SNIFF_ICMP_H#include <ncurses.h>#include "sniff.h"#include "locks.h"#include "list.h"#include "gui_main.h"#include "ip.h"#include "tcp.h"#include "udp.h"/* ICMP Types */#define ICMP_ECHOREPLY 0 /* Echo Reply RFC 792 *//* #define ICMP_ 1 Unassigned *//* #define ICMP_ 2 Unassigned */#define ICMP_DESTUNREACH 3 /* RFC 792 See ICMP_UNRECH_* */#define ICMP_SOURCEQUENCH 4 /* RFC 792 No Codes */#define ICMP_REDIRECT 5 /* RFC 792 See ICMP_REDIRECT_* */#define ICMP_ALT_HOST 6 /* No Ref No Codes *//* #define ICMP_ 7 Unassigned */#define ICMP_ECHO 8 /* RFC 792 No Codes */#define ICMP_ROUTER_ADVERT 9 /* RFC 1256 No Code */#define ICMP_ROUTER_SELECT 10 /* RFC 1256 No Code */#define ICMP_TIMEEXCEEDED 11 /* RFC 792 See ICMP_TTL_* */#define ICMP_PARMPROBLEM 12 /* RFC 792 See ICMP_PARAM_* */#define ICMP_TIMESTAMP 13 /* RFC 792 No CODES */#define ICMP_TIMESTAMP_REPLY 14 /* RFC 792 No Codes */#define ICMP_INFO_REQUEST 15 /* RFC 792 No Codes */#define ICMP_INFO_REPLY 16 /* RFC 792 No Codes */#define ICMP_ADDRMASK_REQUEST 17 /* RFC 950 No Codes */#define ICMP_ADDRMASK_REPLY 18 /* RFC 950 No Codes *//* #define ICMP_ 19 Reserved (Security) *//* #define ICMP_ 20-29 Reserved for Experiment */#define ICMP_TRACEROUTE 30 /* RFC 1393 */#define ICMP_DATAGRAM_CONVERROR 31 /* RFC 1475 */#define ICMP_MOBILE_HOST_REDIRECT 32/* David Johnson */#define ICMP_IPV6_WHEREAREYOU 33 /* Bill Simpson */#define ICMP_IPV6_IAMHERE 34 /* Bill Simpson */#define ICMP_MOBILE_REG_REQUEST 35 /* Bill Simpson */#define ICMP_MOBILE_REG_REPLY 36 /* Bill Simpson */#define ICMP_DOMAIN_NAME_REQUEST 37 /* Simpson */#define ICMP_DOMAIN_NAME_REPLY 38 /* Simpson */#define ICMP_SKIP 39 /* Markson */#define ICMP_PHOTURIS 40 /* Simpson *//* #define ICMP_ 41-255 Reserved *//* the following are in RFC 792 if not otherwise stated */#define ICMP_UNREACH_NET 0 /* Net Unreachable */#define ICMP_UNREACH_HOST 1 /* Host Unmreachable */#define ICMP_UNREACH_PROTOCOL 2 /* Protocol */#define ICMP_UNREACH_PORT 3 /* Port */#define ICMP_UNREACH_FRAGNEEDED 4 /* Only When Dont Frag was set */#define ICMP_UNREACH_SOURCEROUTE 5 /* Source Route Failed */#define ICMP_UNREACH_DESTNETWORK 6 /* Dest Network Unreachable */#define ICMP_UNREACH_DESTHOST 7 /* Dest Host Unreachable */#define ICMP_UNREACH_SOURCEHOST 8 /* Source Host Unreach */#define ICMP_UNREACH_PROHIB_NETWORK 9 /* Filted */#define ICMP_UNREACH_PROHIB_HOST 10 /* Filted */#define ICMP_UNREACH_DESTNETWORK_TOS 11 /* Network for TOS */#define ICMP_UNREACH_DESTHOST_TOS 12 /* Host for TOS */#define ICMP_UNREACH_PROHIB_ADMIN 13 /* RFC 1812 */#define ICMP_UNREACH_PRECEDENCE_HOST 14 /* RFC 1812 */#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* RFC 1812 */#define ICMP_REDIRECT_NETWORK 0 /* redirect whole network */#define ICMP_REDIRECT_HOST 1#define ICMP_REDIRECT_TOS_NETWORK 2#define ICMP_REDIRECT_TOS_HOST 3#define ICMP_TTL_TTL 0 /* TTL in ip header */#define ICMP_TTL_FRAG 1 /* Fragment reassemlt timeout */#define ICMP_PARAM_POINTER 0 /* pointer indicates the error */#define ICMP_PARAM_MISSING 1 /* missing an option RFC 1108 */#define ICMP_PARAM_BADLEN 2 /* bad length */struct pkt_icmp { unsigned char type; unsigned char code; unsigned short check; union { struct { unsigned short id; unsigned short sequence; } echo; unsigned long gateway; struct { unsigned short unused; unsigned short mtu; } frag; } un;};struct icmp_type_t { unsigned char type; /* icmp->type */ char *desc; /* description of the type */ int (*func) (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp); /* function for further processing */ struct list_t *code; /* code only if required */ unsigned char log:1; /* log this data ? */};struct icmp_code_t { unsigned code; char *desc; int (*func) (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp); /* further processing ? */ unsigned char log:1; /* log this data ? */};extern struct list_t *icmp_type;extern struct list_t *icmp_unreach;extern struct list_t *icmp_redirect;extern struct list_t *icmp_ttl;extern struct list_t *icmp_param;extern struct gen_stat icmp_stat;extern WINDOW *icmp_gui_window;extern pthread_mutex_t icmp_gui_mutex;extern FILE *icmp_log;extern struct icmp_type_t icmp_base_type[];extern struct icmp_code_t icmp_base_unreach[];extern struct icmp_code_t icmp_base_redirect[];extern struct icmp_code_t icmp_base_ttl[];extern struct icmp_code_t icmp_base_param[];extern int icmp_handle (struct sniff_pkt *pkt, struct pkt_ip *ip , struct pkt_icmp *icmp);extern inline int icmp_log_any (struct sniff_pkt *pkt, char *ip_source, char *ip_dest, struct pkt_ip *ip, struct pkt_icmp *icmp);extern inline int icmp_log_type(struct sniff_pkt *pkt, char *ip_source, char *ip_dest, struct icmp_type_t *type, struct pkt_ip *ip, struct pkt_icmp *icmp);extern inline int icmp_log_code(struct sniff_pkt *pkt, char *ip_source, char *ip_dest, struct icmp_type_t *type, struct pkt_ip *ip, struct pkt_icmp *icmp);extern int icmp_ping (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp);extern int icmp_ping_reply (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp);extern int icmp_do (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp);extern int icmp_proto (struct sniff_pkt *pkt, char *buf, int buffleft, struct pkt_ip *ip, struct pkt_icmp *icmp);extern int icmp_cmp_type (const struct icmp_type_t *c1, const struct icmp_type_t *c2);extern int icmp_cmp_code (const struct icmp_code_t *c1, const struct icmp_code_t *c2);extern int icmp_init ( void );extern struct list_t *icmp_init_codes (int type, struct icmp_code_t codes[]);extern void icmp_gui(struct gui_t *p, int y, int x);extern int icmp_gui_print(char *fmt, ...);#endif /* _SNIFF_ICMP_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -