Changeset 05e83dc


Ignore:
Timestamp:
03/24/05 16:56:06 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
1b67314
Parents:
23c13e8
Message:

some assorted fixes in the examples tree, to support building under freebsd. Isn't quite there yet.

Changed trace_read_packet to use pcap_next_ex, and to set a timeout of 1ms on pcap_open. This fixes the blocking under freebsd, it seems

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • examples/capture/capture.c

    r4389bd1 r05e83dc  
    3232#include <stdlib.h>
    3333#include <assert.h>
     34#include <unistd.h>
    3435#include <string.h>
     36#include <inttypes.h>
     37#include <sys/types.h>
    3538#include <netinet/in.h>
    3639#include <netinet/ip.h>
    3740#include <signal.h>
    3841#include <setjmp.h>
    39 #include <unistd.h>
    4042#include <sys/time.h>
    41 #include <stdint.h>
    4243#include "zlib.h"
    4344#include "libtrace.h"
  • examples/erfsplit/Makefile

    rc773929 r05e83dc  
    22CFLAGS= -Wall -Wimplicit -Wformat -O2 -pipe -g
    33
    4 INCLUDE = -I/usr/local/wand/include -I/usr/local/dag/include
     4INCLUDE = -I/usr/local/include -I/usr/local/dag/include
    55CFLAGS += $(INCLUDE)
    6 LDLIBS =  -L/usr/local/wand/lib -ltrace
     6LDLIBS =  -L/usr/local/lib -ltrace
    77
    88BINS    = erfsplit
  • examples/munge/Makefile

    r5959435 r05e83dc  
    1 CFLAGS=-W -Wall -g -I/tmp/include
     1CFLAGS=-W -Wall -g -I/usr/local/include
    22LDLIBS=-ltrace lib/libtrace_enc.a
    33LDFLAGS=-L/tmp/lib
  • examples/munge/lib/Makefile

    r0013085 r05e83dc  
    33
    44CFLAGS = -Wall -Wimplicit -Wformat -pipe -O2 -fPIC -g
    5 CFLAGS += -I ../../../ -I/tmp/include
     5CFLAGS += -I ../../../ -I/usr/local/include
    66LDFLAGS = -L/tmp/lib -L/usr/local/lib -L.
    77
  • examples/sample/Makefile

    r10b165c r05e83dc  
    99LDLIBS = $(libdir) -ltrace
    1010
    11 BINS = sample
     11BINS = sample printip
    1212.PHONY: all clean distclean install depend
    1313
     
    1515
    1616clean:
    17         $(RM) *~ *.o $(BINS) $(OBJS) core
     17        $(RM) $(BINS) $(OBJS)
    1818
    1919distclean:
    20         $(RM) *~ *.o $(BINS) $(OBJS) core
     20        $(RM) $(BINS) $(OBJS)
    2121
    2222install:
  • lib/trace.c

    r23c13e8 r05e83dc  
    464464                                                4096,
    465465                                                1,
    466                                                 0,
     466                                                1,
    467467                                                errbuf);
    468468                                        break;
     
    632632        char buf[RP_BUFSIZE];
    633633#if HAVE_PCAP
    634         struct pcap_pkthdr pcaphdr;
     634        struct pcap_pkthdr *pcaphdr = malloc(sizeof(struct pcap_pkthdr));
    635635        const u_char *pcappkt;
     636        int pcapbytes = 0;
    636637#endif
    637638        dag_record_t *erfptr;
     
    653654        /* PCAP gives us it's own per-packet interface. Let's use it */
    654655        if (libtrace->format == PCAP || libtrace->format == PCAPINT) {
    655                 if ((pcappkt = pcap_next(libtrace->input.pcap, &pcaphdr)) == NULL) {
    656                         return 0;
     656                /* pcap_next doesn't return enough information for us
     657                 * newer libpcap has pcap_next_ex, which does, but we'd
     658                 * really rather have it all the time. Also, pcap_next
     659                 * works differently under freebsd! */
     660                //if ((pcappkt = pcap_next(libtrace->input.pcap, &pcaphdr)) == NULL) {
     661                if ((pcapbytes = pcap_next_ex(libtrace->input.pcap,
     662                                                &pcaphdr,
     663                                                &pcappkt)) < 0 ) {
     664                        return -1;
    657665                }
     666                if (pcapbytes == 0) {
     667                        return 0;
     668                }
    658669                memcpy(buffer,&pcaphdr,sizeof(struct pcap_pkthdr));
    659                 memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,pcaphdr.len);
    660                 numbytes = pcaphdr.len;
     670                numbytes = pcaphdr->len;
     671                memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,numbytes);
    661672       
    662673                packet->size = numbytes + sizeof(struct pcap_pkthdr);
     
    16351646                                default:
    16361647                                        /* pass */
     1648                                        break;
    16371649                        }
    16381650                default:
    16391651                        /* pass */
     1652                        break;
    16401653        }
    16411654       
Note: See TracChangeset for help on using the changeset viewer.