Changeset 121b7e2 for lib/format_dag24.c


Ignore:
Timestamp:
03/11/08 16:19:32 (13 years ago)
Author:
Shane Alcock <salcock@…>
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:
a9a91d1
Parents:
6033b99
Message:
  • Updated format_dag25 to support multiple streams - the new uri format for dag is "dag:/dev/dagX,<stream number>"
  • As each dag card can only be opened by a single process, thread-safety is now incorporated to allow separate threads to read from each dag stream
  • format_dag24 also supports the new uri format, although the stream number is ignored because old dags only have the one stream
  • Updated dagformat.h to include a whole bunch of new erf types
  • Added explicit support for the DSM Coloured Ethernet record type which will be required to deal with streamed packets
  • Fixed erf_get_padding() code that was comparing the return value of trace_get_link_type against an erf type rather than a libtrace link type
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag24.c

    r2b7750a r121b7e2  
    100100static int dag_init_input(libtrace_t *libtrace) {
    101101        struct stat buf;
    102         libtrace->format_data = (struct dag_format_data_t *)
     102        char *dag_dev_name = NULL;
     103        char *scan = NULL;
     104
     105        /* Since DAG 2.5 has been changed to support a slightly different URI
     106         * format, it's probably a good idea to deal with URIs specified in
     107         * such a fashion even if we just end up ignoring the stream number */
     108        if ((scan = strchr(libtrace->uridata,',')) == NULL) {
     109                dag_dev_name = strdup(libtrace->uridata);
     110        } else {
     111                dag_dev_name = (char *)strndup(libtrace->uridata,
     112                                (size_t)(scan - libtrace->uridata));
     113        }
     114
     115       
     116        if (stat(dag_dev_name, &buf) == -1) {
     117                trace_set_err(libtrace,errno,"stat(%s)",dag_dev_name);
     118                free(dag_dev_name);
     119                return -1;
     120        }
     121       
     122        libtrace->format_data = (struct dag_format_data_t *)
    103123                malloc(sizeof(struct dag_format_data_t));
    104         if (stat(libtrace->uridata, &buf) == -1) {
    105                 trace_set_err(libtrace,errno,"stat(%s)",libtrace->uridata);
    106                 return -1;
    107         }
    108 
    109124        FORMAT_DATA->top = 0;
    110125        FORMAT_DATA->bottom = 0;
    111126        if (S_ISCHR(buf.st_mode)) {
    112127                /* DEVICE */
    113                 if((FORMAT_DATA->fd = dag_open(libtrace->uridata)) < 0) {
     128                if((FORMAT_DATA->fd = dag_open(dag_dev_name)) < 0) {
    114129                        trace_set_err(libtrace,errno,"Cannot open DAG %s",
    115                                         libtrace->uridata);
     130                                        dag_dev_name);
     131                        free(dag_dev_name);
    116132                        return -1;
    117133                }
    118134                if((FORMAT_DATA->buf = (void *)dag_mmap(FORMAT_DATA->fd)) == MAP_FAILED) {
    119135                        trace_set_err(libtrace,errno,"Cannot mmap DAG %s",
    120                                         libtrace->uridata);
     136                                        dag_dev_name);
     137                        free(dag_dev_name);
    121138                        return -1;
    122139                }
    123140        } else {
    124141                trace_set_err(libtrace,errno,"Not a valid dag device: %s",
    125                                 libtrace->uridata);
     142                                dag_dev_name);
     143                free(dag_dev_name);
    126144                return -1;
    127145        }
     
    132150        DUCK.dummy_duck = NULL;
    133151        FORMAT_DATA->drops = 0;
     152        free(dag_dev_name);
    134153
    135154        return 0;
Note: See TracChangeset for help on using the changeset viewer.