ipdump 源码
#include<
#include<>
#include<>
#include<sys/>
#include<sys/>
#include<sys/>
#/.h>
#inet/>
#inet/>
#inet/>
#inet/>
#define __FAVOR_BSD
#inet/>
#inet/>
#inet/>
#include<arpa/>
#ifdef _linux
#include<linux/>
#include<linux/>
#else
#include<sys/>
//#i />
#/>
#include<>
#endif
#define MAXSIZE 65535
#define EXIT_FAILURE 0
void (struct ether_header *eth);
void print_arp(struct ether_arp *arp);
void print_ip(struct ip *ip);
void print_tcp(struct tcphdr *tcp);
void print_icmp(struct icmp *icmp);
void print_udp(struct udphdr *udp);
char *mac_ntoa(u_char *d);
char *ip_ttoa(int flag);
char *ip_ftoa(int flag);
char *tcp_ftoa(int flag);
int main(int argc, char *argv[]) {
struct ether_header *eth;
struct ether_arp *arp;
struct ip *ip;
struct icmp *icmp;
struct tcphdr *tcp;
struct udphdr *udp;
int sock;
int len;
char buff[MAXSIZE];
char *p;
printf("begin!\n");
if ( (sock = socket(, SOCK_PACKET, htons(ETH_P_ALL))) < 0) {
perror(" socket");
return(EXIT_FAILURE);
}
/*
struct socket local;
memset(&local, 0, sizeof(local));
= ;
= 0;
= INADDR_ANY;
*/
while (1) {
printf("+++++begin+++++++++++++++++++++++++++++++++++\n");
if ((len = rea
ipdump源码 来自淘豆网m.daumloan.com转载请标明出处.