igmp.c

来自「Nast是一个基于Libnet 和Libpcap的sniffer包和LAN分析器」· C语言 代码 · 共 56 行

C
56
字号
/*    nast    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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#include "include/nast.h"void handle_IGMP (FILE *output){   struct libnet_ipv4_hdr *ip;   struct libnet_igmp_hdr *igmp;      ip = (struct libnet_ipv4_hdr *) (packet + offset);   igmp = (struct libnet_igmp_hdr *) (packet + LIBNET_IPV4_H + offset);   fprintf(output, "\n---[ IGMP ]----------------------------------------------------------\n");   fprintf(output, "%s -> %s\n", inet_ntoa(ip->ip_src), inet_ntoa(ip->ip_dst));   fprintf(output, "IP Version: %d\t Lenght: %d\t", ip->ip_v, ntohs(ip->ip_len));   fprintf(output, "TTL: %d\t Code: %d\n", ip->ip_ttl, igmp->igmp_code);   fprintf(output, "Type: ");   switch(igmp->igmp_type)     {      case 0x11:	fprintf(output, "Membreship Query v1 [get address %s]\n", inet_ntoa(igmp->igmp_group));	break;      case 0x12:	fprintf(output, "Membership Report v1  %s\n", inet_ntoa(igmp->igmp_group));	break;      case 0x16:	fprintf(output, "Membership Report v2  %s\n", inet_ntoa(igmp->igmp_group));	break;      case 0x17:	fprintf(output, "Leave %s (v2)\n", inet_ntoa(igmp->igmp_group));	break;      default:	fprintf(output, "%d\n", igmp->igmp_type);	break;     }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?