Changeset 80a2e99 for lib/trace.c
- Timestamp:
- 11/11/04 10:54:36 (18 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:
- a48d246
- Parents:
- 533d7c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
ra6d38b6 r80a2e99 1299 1299 } 1300 1300 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 */ 1307 int8_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 1301 1328 /** Get the direction flag, if it has one 1302 1329 * @param libtrace the libtrace opaque pointer … … 1443 1470 1444 1471 } 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 */ 1480 size_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.