- Timestamp:
- 11/05/04 16:58:44 (16 years ago)
- 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:
- 533d7c1
- Parents:
- a6d38b6
- Location:
- examples/capture
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/capture/Makefile
ra6d38b6 r4389bd1 7 7 CFLAGS += $(INCLUDE) 8 8 libdir = -L$(PREFIX)/lib 9 LDLIBS = $(libdir) -ltrace 9 LDLIBS = $(libdir) -ltrace -lzl 10 10 11 BINS = capture 11 BINS = capture capture-gzip 12 12 .PHONY: all clean distclean install depend 13 13 -
examples/capture/capture.c
ra6d38b6 r4389bd1 40 40 #include <sys/time.h> 41 41 #include <stdint.h> 42 #include "zlib.h" 42 43 #include "libtrace.h" 43 44 #include "dagformat.h" … … 66 67 } 67 68 69 #define BUFSIZE 65536 70 71 68 72 void secondreport() { 69 73 … … 71 75 72 76 if (hdrcount >= 10) { 73 printf("Byte count: Packet count: Loss count\n");77 fprintf(stderr,"Byte count: Packet count: Loss count\n"); 74 78 hdrcount = 0; 75 79 } 76 80 hdrcount++; 77 printf("\t\t%d\t\t%d\t\t%d \n",81 fprintf(stderr,"\t\t%d\t\t%d\t\t%d \n", 78 82 counter[BYTES], 79 83 counter[PACKETS], … … 88 92 char *uri = 0; 89 93 char *filename = 0; 90 FILE*fout = 0;94 gzFile *fout = 0; 91 95 int psize = 0; 96 int offset = 0; 92 97 struct sigaction sigact; 93 98 dag_record_t *erfptr = 0; … … 95 100 96 101 struct itimerval itv; 102 void *buffer, *buffer2; 103 104 105 buffer = malloc(BUFSIZE); 106 buffer2 = buffer; 97 107 98 108 /* … … 122 132 uri = strdup(argv[1]); 123 133 filename = strdup(argv[2]); 124 fout = fopen(filename,"w");134 fout = gzopen(filename,"ab"); 125 135 } 126 136 … … 148 158 } 149 159 150 if (filename) 151 fwrite(erfptr,psize,1,fout); 160 if (filename) { 161 if (offset + psize > BUFSIZE) { 162 //gzwrite(fout,erfptr,psize); 163 fprintf(stderr,"writing to disk\n"); 164 gzwrite(fout,buffer,offset); 165 offset = 0; 166 } 167 168 memcpy(buffer + offset,erfptr,psize); 169 offset += psize; 170 171 172 } 152 173 153 174 … … 155 176 156 177 trace_destroy(trace); 157 fclose(fout);178 gzclose(fout); 158 179 return 0; 159 180 }
Note: See TracChangeset
for help on using the changeset viewer.