#include <stdio.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <pcap.h>#include "../../config.h"#include "ip.h"#include "ether.h"#include "ethertype.h"Include dependency graph for adtrace.c:

Go to the source code of this file.
Functions | |
| const u_char * | printEAddr (const u_char *pkt, u_char *endp) |
| void | printIPAddr (const u_char *pkt, u_char *endp) |
| void | handler (u_char *user, const struct pcap_pkthdr *head, const u_char *packet) |
| void | usage (char *av[]) |
| int | main (int argc, char *argv[]) |
Variables | |
| pcap_t * | p |
|
||||||||||||||||
|
Definition at line 48 of file adtrace.c. References pcap_pkthdr::caplen, packet, printEAddr(), and printIPAddr(). Referenced by Event::Dispatch(), main(), RemoteSerializer::ProcessRequestEventsMsg(), EventRegistry::Register(), ID::SetVal(), and Serializer::UnserializeCall().
00048 {
00049 u_char* endp;
00050
00051 endp =(u_char*) packet + head->caplen;
00052 packet = printEAddr(packet, endp);
00053 if (packet)
00054 printIPAddr(packet, endp);
00055 }
|
|
||||||||||||
|
Definition at line 63 of file adtrace.c. References DLT_EN10MB, file, fputs(), handler(), p, pcap_close(), pcap_datalink(), PCAP_ERRBUF_SIZE, pcap_loop(), pcap_open_offline(), and usage().
00064 {
00065 char *file;
00066 char errbuf[PCAP_ERRBUF_SIZE];
00067 u_char* pkt, endp;
00068 struct pcap_pkthdr *head;
00069
00070 if ( argc != 2 )
00071 usage(argv);
00072
00073 file = argv[1];
00074
00075 p = pcap_open_offline(file, errbuf);
00076 if(p==NULL){
00077 fprintf (stderr, "cannot open %s: %s\n", file, errbuf);
00078 exit(2);
00079 }
00080
00081 if (pcap_datalink(p) != DLT_EN10MB){
00082 fputs ("sorry, currently only ethernet links supported\n", stderr);
00083 exit(1); //if it is not ethernet we are watching we won't have MACs
00084 }
00085
00086 pcap_loop(p, -1, handler, NULL);
00087 pcap_close(p);
00088 return(0);
00089 }
|
|
||||||||||||
|
Definition at line 16 of file adtrace.c. References ep, ETHER_ADDR_LEN, ETHER_HDRLEN, ETHERTYPE_IP, and printf(). Referenced by handler().
00016 {
00017 const struct ether_header *ep;
00018 int i=0;
00019 ep = (const struct ether_header*) pkt;
00020
00021 if (pkt+ETHER_HDRLEN > endp ||
00022 ntohs(ep->ether_type) != ETHERTYPE_IP){
00023 return 0;
00024 }
00025
00026 for (i = 0; i<ETHER_ADDR_LEN; i++){
00027 if (i>0) putchar(':');
00028 printf("%02x", ep->ether_shost[i]);
00029 }
00030 putchar (' ');
00031 for (i = 0; i<ETHER_ADDR_LEN; i++){
00032 if (i>0) putchar(':');
00033 printf("%02x", ep->ether_dhost[i]);
00034 }
00035 putchar(' ');
00036 return (pkt+ETHER_HDRLEN);
00037 }
|
|
||||||||||||
|
Definition at line 39 of file adtrace.c. References fputs(), and puts(). Referenced by handler().
|
|
|
Definition at line 57 of file adtrace.c.
00058 {
00059 fprintf(stderr,"usage: %s filename \n", av[0]);
00060 exit(1);
00061 }
|
|
1.3.5