Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first change "wlan0" on the source code with your interface, after
- "gcc filename.c -lpcap"
- #include <pcap.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <unistd.h>
- pcap_t *pcap = NULL;
- pcap_dumper_t *pdump;
- void decode(u_char* param, const struct pcap_pkthdr *pkthdr, const u_char *pkt)
- {
- pcap_dump((u_char*)param, pkthdr, pkt);
- }
- static void close_network()
- {
- fprintf(stderr,"closing network \n");
- pcap_close(pcap);
- pcap_dump_close(pdump);
- }
- void disable_interface_offload(void)
- {
- char *newargv[] = {"ethtool", "-K", "wlan0", "tso", "off", "gso", "off", "gro", "off", "lro", "off", NULL };
- int ret_val;
- switch(fork()) {
- case 0:
- execvp("ethtool", newargv);
- fprintf(stderr,"problem, ethtool not found!\n\n");
- exit(10); // this one causes the double header inclusion
- //_exit(10); // while this one does not
- default:
- wait(&ret_val);
- }
- int main()
- {
- char pcap_errbuf[PCAP_ERRBUF_SIZE];
- pcap = pcap_open_live("wlan0", UINT16_MAX, 1, 0, pcap_errbuf);
- if(pcap==NULL)
- printf("\n\nPCAP NULL\n\n");
- pdump = pcap_dump_open(pcap, "out.pcap");
- if(pcap==NULL)
- printf("\n\nPDUMP NULL\n\n");
- disable_interface_offload();
- pcap_loop(pcap, 2, decode, (unsigned char *)pdump);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement