Changeset c5ebbaa for lib/trace.c


Ignore:
Timestamp:
06/23/06 12:00:34 (15 years ago)
Author:
Perry Lorier <perry@…>
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:
d3fd4d3
Parents:
f875681
Message:

Fix TRACE_TYPE enum (some entries had been reordered since libtrace2)
Add new trace_construct_packet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r8a1fb3c rc5ebbaa  
    973973                        return -1;
    974974                }
    975                 if (libtrace_to_pcap_dlt(linktype) == -1) {
     975                if (libtrace_to_pcap_dlt(linktype) == ~0U) {
    976976                        trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET,
    977977                                        "Unknown pcap equivilent linktype");
     
    13991399}
    14001400
     1401DLLEXPORT
     1402void trace_construct_packet(libtrace_packet_t *packet,
     1403                libtrace_linktype_t linktype,
     1404                const void *data,
     1405                uint16_t len)
     1406{
     1407        libtrace_t *deadtrace=NULL;
     1408        libtrace_pcapfile_pkt_hdr_t hdr;
     1409        struct timeval tv;
     1410        if (NULL == deadtrace) deadtrace=trace_create_dead("pcapfile");
     1411        gettimeofday(&tv,NULL);
     1412        hdr.ts_sec=tv.tv_sec;
     1413        hdr.ts_usec=tv.tv_usec;
     1414        hdr.caplen=len;
     1415        hdr.wirelen=len;
     1416
     1417        packet->trace=deadtrace;
     1418        packet->size=len+sizeof(hdr);
     1419        if (packet->buf_control==TRACE_CTRL_PACKET) {
     1420                packet->buffer=realloc(packet->buffer,packet->size);
     1421        }
     1422        else {
     1423                packet->buffer=malloc(packet->size);
     1424        }
     1425        packet->buf_control=TRACE_CTRL_PACKET;
     1426        packet->header=packet->buffer;
     1427        packet->payload=(void*)((char*)packet->buffer+sizeof(hdr));
     1428        memcpy(packet->header,&hdr,sizeof(hdr));
     1429        memcpy(packet->payload,data,len);
     1430        packet->type=pcap_dlt_to_rt(libtrace_to_pcap_dlt(linktype));
     1431}
Note: See TracChangeset for help on using the changeset viewer.