(1)获取网络接口名字和掩码等信息
(2)捕获数据包(单个数据包和多个数据包两种情况)
(3)以太网数据报捕获
(4)ARP数据包捕获
(5)IP数据包捕获
(6)TCP数据包捕获
(7)UDP数据包捕获
(8)ICMP数据包捕获
环境fedora13,vim,gcc
#include<stdio.h>
#include<string.h>
#include<pcap.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netinet/if_ether.h>
#include<netinet/ip.h>
#include<netinet/udp.h>
#include<netinet/tcp.h>
#include<netinet/ip_icmp.h>
#define max 1024
/*
typedef u_int32_t int_addr_t;
struct in_addr
{
int_addr_t s_addr;
};*/
int call(u_char *argument,const struct pcap_pkthdr* pack,const u_char *content)
{
int m=0,n;
const u_char *buf,*iphead;
u_char *p;
struct ether_header *ethernet;
struct iphdr *ip;
struct tcphdr *tcp;
struct udphdr *udp;
struct icmphdr *icmp;
buf=content;
printf("==================================================\n");
printf("The Frame is \n");
w

本文介绍了如何在Linux(Fedora 13)中使用libpcap库进行网络数据包捕获,包括获取网络接口信息、以太网、ARP、IP、TCP、UDP和ICMP数据包的捕获方法。通过实例展示了从单个到多个数据包的捕获过程。
&spm=1001.2101.3001.5002&articleId=7336448&d=1&t=3&u=fc39fc644793451dad19642c7e903ec1)
596

被折叠的 条评论
为什么被折叠?



