Changeset 80a2e99


Ignore:
Timestamp:
11/11/04 10:54:36 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
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:
a48d246
Parents:
533d7c1
Message:

set_direction
truncate_packet

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r678048a r80a2e99  
    347347uint8_t *trace_get_source_mac(struct libtrace_packet_t *packet);
    348348
     349/** Truncate the packet at the suggested length
     350 * @param packet        the packet opaque pointer
     351 * @param len           the new length of the packet
     352 * @returns the new length of the packet, or the original length of the
     353 * packet if unchanged
     354 * @author Daniel Lawson
     355 */
     356size_t trace_truncate_packet(struct libtrace_packet_t *packet, size_t size);
     357
     358/** Set the direction flag, if it has one
     359 * @param packet        the packet opaque pointer
     360 * @param direction     the new direction (0,1,2,3)
     361 * @returns a signed value containing the direction flag, or -1 if this is not supported
     362 * @author Daniel Lawson
     363 */
     364int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction);
     365
    349366/** Get the direction flag, if it has one
    350367 * @param packet        the packet opaque pointer
  • lib/trace.c

    ra6d38b6 r80a2e99  
    12991299}
    13001300
     1301/** Set the direction flag, if it has one
     1302 * @param packet the packet opaque pointer
     1303 * @param direction the new direction (0,1,2,3)
     1304 * @returns a signed value containing the direction flag, or -1 if this is not supported
     1305 * @author Daniel Lawson
     1306 */
     1307int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) {
     1308       
     1309        dag_record_t *erfptr = 0;
     1310        assert(packet);
     1311
     1312        switch(packet->trace->format) {
     1313                case DAG:
     1314                case ERF:
     1315                case RTCLIENT:
     1316                        erfptr = (dag_record_t *)packet->buffer;
     1317                        erfptr->flags.iface = direction;
     1318                        break;
     1319                default:
     1320                        direction = -1;
     1321        }
     1322       
     1323        return direction;
     1324       
     1325       
     1326}
     1327
    13011328/** Get the direction flag, if it has one
    13021329 * @param libtrace the libtrace opaque pointer
     
    14431470       
    14441471}
     1472
     1473/** Truncate the packet at the suggested length
     1474 * @param packet        the packet opaque pointer
     1475 * @param len           the new length of the packet
     1476 * @returns the new length of the packet, or the original length of the
     1477 * packet if unchanged
     1478 * @author Daniel Lawson
     1479 */
     1480size_t trace_truncate_packet(struct libtrace_packet_t *packet, size_t size) {
     1481        dag_record_t *erfptr;
     1482        struct pcap_pkthdr *pcaphdr;
     1483
     1484        assert(packet);
     1485
     1486        if (size > packet->size) {
     1487                // can't make a packet larger
     1488                return packet->size;
     1489        }
     1490        switch (packet->trace->format) {
     1491                case PCAPINT:
     1492                case PCAP:
     1493                        pcaphdr = (struct pcap_pkthdr *)packet->buffer;
     1494                        pcaphdr->caplen = size;
     1495                        packet->size = size;
     1496                        break;
     1497                case ERF:
     1498                case DAG:
     1499                case RTCLIENT:
     1500                        erfptr = (dag_record_t *)packet->buffer;
     1501                        erfptr->rlen = ntohs(size);
     1502                        packet->size = size;
     1503                        break;
     1504                case WAGINT:
     1505                case WAG:
     1506                        // don't know how to do this?
     1507                        break;
     1508        }
     1509        return packet->size;
     1510}
     1511
Note: See TracChangeset for help on using the changeset viewer.