Changeset 084d95a


Ignore:
Timestamp:
09/05/05 14:44:41 (15 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:
de8c420b
Parents:
03cbfec
Message:

Fixed another reference to sizeof(dag_record_t) and added support for dummy traces

trace_create_dead and trace_destroy_dead

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r03cbfec r084d95a  
    654654                                payload,
    655655                                packet->size -
    656                                         sizeof(dag_record_t));
     656                                        (dag_record_size + 2));
    657657        } else {
    658658                // convert format - build up a new erf header
  • lib/libtrace.h

    rca87bcd r084d95a  
    236236struct libtrace_t *trace_create(char *uri);
    237237
     238/** Creates a "dummy" trace file that has only the format type set.
     239 *
     240 * @returns opaque pointer to a (sparsely initialised) libtrace_t
     241 *
     242 * IMPORTANT: Do not attempt to call trace_read_packet or other such functions with
     243 * the dummy trace. Its intended purpose is to act as a packet->trace for libtrace_packet_t's
     244 * that are not associated with a libtrace_t structure.
     245 */
     246struct libtrace_t *trace_create_dead(char *uri);
     247
    238248/** Creates a trace output file from a URI.
    239249 *
     
    263273 */
    264274void trace_destroy(struct libtrace_t *trace);
     275
     276void trace_destroy_dead(struct libtrace_t *trace);
    265277
    266278/** Close a trace output file, freeing up any resources it may have been using
  • lib/trace.c

    rb5cd711 r084d95a  
    308308}
    309309
     310struct libtrace_t * trace_create_dead (char *uri) {
     311        struct libtrace_t *libtrace = malloc(sizeof(struct libtrace_t));
     312        char *scan = calloc(sizeof(char),URI_PROTO_LINE);
     313        char *uridata;
     314        int i;
     315       
     316        trace_err.err_num = E_NOERROR;
     317
     318        if((uridata = strchr(uri,':')) == NULL) {
     319                strncpy(scan, uri, strlen(uri));
     320        } else {
     321                strncpy(scan,uri, (uridata - uri));
     322        }
     323       
     324        libtrace->format = 0;   
     325       
     326        for (i = 0; i < nformats; i++) {
     327                if (strlen(scan) == strlen(format_list[i]->name) &&
     328                                !strncasecmp(scan,
     329                                        format_list[i]->name,
     330                                        strlen(scan))) {
     331                                libtrace->format=format_list[i];
     332                                break;
     333                                }
     334        }
     335        if (libtrace->format == 0) {
     336                trace_err.err_num = E_BAD_FORMAT;
     337                trace_err.problem = scan;
     338                return 0;
     339        }
     340
     341        return libtrace;
     342
     343}
     344       
    310345/** Creates a libtrace_out_t structure and the socket / file through which output will be directed.
    311346 *
     
    421456}
    422457
     458
     459void trace_destroy_dead(struct libtrace_t *libtrace) {
     460        assert(libtrace);
     461        free(libtrace);
     462}
    423463/** Close an output trace file, freeing up any resources it may have been using
    424464 *
Note: See TracChangeset for help on using the changeset viewer.