Annotation of embedaddon/arping/src/fuzz_pingmac.c, revision 1.1
1.1 ! misho 1: #include<errno.h>
! 2: #include<string.h>
! 3: #include<stdio.h>
! 4: #include<stdlib.h>
! 5: #include<unistd.h>
! 6: #include<inttypes.h>
! 7:
! 8: #include<pcap.h>
! 9:
! 10: #include"arping.h"
! 11:
! 12: int
! 13: main()
! 14: {
! 15: const size_t maxpacket = 1500;
! 16: char* const packet = calloc(1, maxpacket);
! 17: size_t packet_size = 0;
! 18:
! 19: // Read packet.
! 20: {
! 21: char* p = packet;
! 22: size_t size = maxpacket;
! 23: while (size > 0) {
! 24: const ssize_t n = read(STDIN_FILENO, p, size);
! 25: if (n == 0) {
! 26: break;
! 27: }
! 28: if (n < 0) {
! 29: fprintf(stderr, "read(): %s\n", strerror(errno));
! 30: return 1;
! 31: }
! 32: size -= n;
! 33: p += n;
! 34: }
! 35: packet_size = p - packet;
! 36: }
! 37:
! 38: struct pcap_pkthdr pkthdr;
! 39: pkthdr.ts.tv_sec = time(NULL);
! 40: pkthdr.ts.tv_usec = 0;
! 41: pkthdr.len = packet_size;
! 42: pkthdr.caplen = packet_size;
! 43:
! 44: verbose = 9;
! 45: dstip = htonl(0x12345678);
! 46: pingip_recv(NULL, &pkthdr, packet);
! 47:
! 48: free(packet);
! 49: return 0;
! 50: }
! 51: /* ---- Emacs Variables ----
! 52: * Local Variables:
! 53: * c-basic-offset: 8
! 54: * indent-tabs-mode: nil
! 55: * End:
! 56: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>