Changeset 52656ed
- Timestamp:
- 09/04/07 16:50:19 (15 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:
- 5798dc6
- Parents:
- 2cf30f6
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.in
r994beed r52656ed 173 173 ]) 174 174 175 # DAG 3.0 actually puts header files and shared libraries into sensible 176 # places now, so we should be able to do a simple CHECK_LIB to see if 177 # they're there! 178 179 # Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here 180 # also. This isn't such a bad thing, the DAG2.5 API is essentially the same as 181 # DAG 3.0 and libtrace will use the same format_dagXX source for both 182 libtrace_dag=false 183 libtrace_dag_version=none 184 185 if test "$with_dag" != no; then 186 AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0) 187 if test "$dag_found" = 1; then 188 ADD_LIBS="$ADD_LIBS -ldag" 189 AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) 190 AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) 191 libtrace_dag=true 192 193 AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version]) 194 libtrace_dag_version=30 195 fi 196 fi 197 175 198 # turn the test part of the next block into a function, so it can be 176 199 # called multiple times for $dag_root, /root/dag, /usr/local/lib 177 libtrace_dag=false 178 libtrace_dag2_4=false 179 dag_drv_v="DAG not present" 180 if test "$with_dag" != no ; then181 AC_MSG_CHECKING(whether we have DAG API)200 #dag_drv_v="DAG not present" 201 202 # Now check for 2.4 DAG drivers which don't install as cleanly! 203 if test "$with_dag" != no -a "$libtrace_dag" = false; then 204 AC_MSG_CHECKING(whether we have DAG 2.4 API) 182 205 183 206 if test -r "$dag_root/lib"; then … … 206 229 AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) 207 230 AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) 231 AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version]) 232 libtrace_dag_version=24 208 233 else 209 234 if test "$want_dag" = yes; then … … 215 240 AC_MSG_RESULT($libtrace_dag) 216 241 217 if test "$libtrace_dag" != false; then 218 AC_MSG_CHECKING(if we are using DAG 2.4) 219 if grep '2.4.' $dag_root/VERSION > /dev/null 2>&1; then 220 libtrace_dag2_4=true 221 AC_DEFINE(DAG_VERSION_2_4, 1, [define if using DAG 2.4]) 222 else 223 libtrace_dag2_4=false 224 fi 225 AC_MSG_RESULT($libtrace_dag2_4) 226 dag_drv_v=`cat $dag_root/VERSION` 227 fi 228 fi 229 DAG_VERSION_NUM=$dag_drv_v 242 fi 243 230 244 AC_CHECK_LIB(z, gzopen) 231 245 232 246 AM_CONDITIONAL([HAVE_BPF], [test "$ac_cv_have_decl_BIOCSETIF" = yes ]) 233 247 AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) 234 AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag2_4" = true]) 248 AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24]) 249 AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25]) 250 AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30]) 235 251 AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_gzopen" = yes]) 236 252 AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) … … 269 285 reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_gzopen 270 286 if test x"$libtrace_dag" = xtrue; then 271 if test x"$libtrace_dag2_4"; then287 if test "$libtrace_dag_version" = 24; then 272 288 AC_MSG_NOTICE([Compiled with DAG support: 2.4]) 289 elif test "$libtrace_dag_version" = 30; then 290 AC_MSG_NOTICE([Compiled with DAG support: 3.0]) 273 291 else 274 292 AC_MSG_NOTICE([Compiled with DAG support: 2.5]) 275 fi 293 fi 276 294 else 277 295 AC_MSG_NOTICE([Compiled with DAG support: No]) -
lib/format_dag25.c
r708f9ae r52656ed 75 75 int fd; 76 76 unsigned int dagstream; 77 int stream_attached; 78 uint8_t *bottom; 79 uint8_t *top; 77 80 }; 78 81 … … 105 108 DUCK.last_pkt = 0; 106 109 DUCK.dummy_duck = NULL; 107 110 FORMAT_DATA->stream_attached = 0; 111 108 112 return 0; 109 113 } … … 111 115 static int dag_config_input(libtrace_t *libtrace, trace_option_t option, 112 116 void *data) { 113 switch(option) { 117 char conf_str[4096]; 118 switch(option) { 114 119 case TRACE_OPTION_META_FREQ: 115 120 DUCK.duck_freq = *(int *)data; 116 121 return 0; 117 122 case TRACE_OPTION_SNAPLEN: 118 /* Surely we can set this?? Fall through for now*/ 119 return -1; 123 snprintf(conf_str, 4096, "varlen slen=%i", *(int *)data); 124 if (dag_configure(FORMAT_DATA->fd, conf_str) != 0) { 125 trace_set_err(libtrace, errno, "Failed to configure snaplen on DAG card: %s", libtrace->uridata); 126 return -1; 127 } 128 return 0; 120 129 case TRACE_OPTION_PROMISC: 121 130 /* DAG already operates in a promisc fashion */ … … 152 161 return -1; 153 162 } 163 FORMAT_DATA->stream_attached = 1; 154 164 /* We don't want the dag card to do any sleeping */ 155 165 dag_set_stream_poll(FORMAT_DATA->fd, … … 158 168 159 169 /* Should probably flush the memory hole now */ 170 160 171 do { 161 172 top = dag_advance_stream(FORMAT_DATA->fd, … … 164 175 assert(top && bottom); 165 176 diff = top - bottom; 177 bottom -= diff; 166 178 } while (diff != 0); 167 179 … … 180 192 return -1; 181 193 } 182 194 FORMAT_DATA->stream_attached = 0; 183 195 return 0; 184 196 } 185 197 186 198 static int dag_fin_input(libtrace_t *libtrace) { 199 if (FORMAT_DATA->stream_attached) 200 dag_pause_input(libtrace); 201 dag_close(FORMAT_DATA->fd); 187 202 if (DUCK.dummy_duck) 188 203 trace_destroy_dead(DUCK.dummy_duck); … … 193 208 static int dag_get_duckinfo(libtrace_t *libtrace, 194 209 libtrace_packet_t *packet) { 195 daginf_t lt_dag_inf;196 197 210 if (packet->buf_control == TRACE_CTRL_EXTERNAL || 198 211 !packet->buffer) { … … 224 237 } 225 238 226 dag_record_t *dag_get_record(libtrace_t *libtrace) { 239 static int dag_available(libtrace_t *libtrace) { 240 uint32_t diff = FORMAT_DATA->top - FORMAT_DATA->bottom; 241 if (diff >= dag_record_size) 242 return diff; 243 FORMAT_DATA->top = dag_advance_stream(FORMAT_DATA->fd, 244 FORMAT_DATA->dagstream, 245 &(FORMAT_DATA->bottom)); 246 if (FORMAT_DATA->top == NULL) { 247 trace_set_err(libtrace, errno, "dag_advance_stream failed!"); 248 return -1; 249 } 250 diff = FORMAT_DATA->top - FORMAT_DATA->bottom; 251 return diff; 252 } 253 254 static dag_record_t *dag_get_record(libtrace_t *libtrace) { 227 255 dag_record_t *erfptr = NULL; 228 256 uint16_t size; 229 erfptr = (dag_record_t *) dag_rx_stream_next_record(FORMAT_DATA->fd, 230 FORMAT_DATA->dagstream); 257 erfptr = (dag_record_t *)FORMAT_DATA->bottom; 231 258 if (!erfptr) 232 259 return NULL; 233 260 size = ntohs(erfptr->rlen); 234 261 assert( size >= dag_record_size ); 262 /* Make certain we have the full packet available */ 263 if (size > (FORMAT_DATA->top - FORMAT_DATA->bottom)) 264 return NULL; 265 FORMAT_DATA->bottom += size; 235 266 return erfptr; 236 267 } 237 268 238 void dag_form_packet(dag_record_t *erfptr, libtrace_packet_t *packet) {269 static void dag_form_packet(dag_record_t *erfptr, libtrace_packet_t *packet) { 239 270 packet->buffer = erfptr; 240 271 packet->header = erfptr; … … 257 288 struct timeval tv; 258 289 dag_record_t *erfptr = NULL; 259 290 int numbytes = 0; 291 260 292 if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq && 261 293 DUCK.duck_freq != 0) { … … 276 308 277 309 do { 310 numbytes = dag_available(libtrace); 311 if (numbytes < 0) 312 return numbytes; 313 if (numbytes < dag_record_size) 314 /* Block until we see a packet */ 315 continue; 278 316 erfptr = dag_get_record(libtrace); 279 317 } while (erfptr == NULL); -
lib/libtrace_int.h
re1fdc05 r52656ed 109 109 # include "dagnew.h" 110 110 # include "dagapi.h" 111 # if ndef DAG_VERSION_2_4111 # if DAG_VERSION == 25 112 112 # include <daginf.h> 113 113 # endif
Note: See TracChangeset
for help on using the changeset viewer.