Changeset 8013711


Ignore:
Timestamp:
11/01/05 13:34:32 (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:
77509e9
Parents:
d18312c
Message:

Fixed rt_protocol.h so that it is no longer dependent on libfifo.
Updated format for rt protocol header - it is now 1 byte for a
packet type, 1 byte reserved and then 2 bytes to specify
any messages.
Updated various formats to use the new rt protocol header correctly.

Location:
lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r78f750e r8013711  
    486486        memcpy(packet->buffer, erfptr, size);
    487487       
    488         packet->status = 0;
     488        packet->status.type = RT_DATA;
     489        packet->status.message = 0;
    489490        packet->size = size;
    490491        DAG.offset += size;
     
    526527                return -1;
    527528        }
    528         packet->status = 0;
     529        packet->status.type = RT_DATA;
     530        packet->status.message = 0;
    529531        packet->size = rlen;
    530532        return rlen;
     
    565567                return -1;
    566568        }
    567         packet->status = 0;
     569        packet->status.type = RT_DATA;
     570        packet->status.message = 0;
    568571        packet->size = rlen;
    569572        return rlen;
     
    619622                // Read status byte
    620623                if (tracefifo_out_read(libtrace->fifo,
    621                                 &packet->status, sizeof(uint32_t)) == 0) {
     624                                &packet->status, sizeof(rt_status_t)) == 0) {
    622625                        read_required = 1;
    623626                        continue;
    624627                }
    625                 tracefifo_out_update(libtrace->fifo,sizeof(uint32_t));
     628                tracefifo_out_update(libtrace->fifo,sizeof(rt_status_t));
    626629
    627630                // read in the ERF header
     
    633636                }
    634637               
    635                 if (packet->status >= S_MESSAGE_ONLY) {
     638                if (packet->status.type == RT_MSG) {
    636639                        // Need to skip this packet as it is a message packet
    637640                        tracefifo_out_update(libtrace->fifo, dag_record_size);
    638                         tracefifo_ack_update(libtrace->fifo, dag_record_size + sizeof(uint32_t));
     641                        tracefifo_ack_update(libtrace->fifo, dag_record_size + sizeof(rt_status_t));
    639642                        continue;
    640643                }
     
    653656                tracefifo_out_update(libtrace->fifo,size);
    654657
    655                 tracefifo_ack_update(libtrace->fifo,size + sizeof(uint32_t));
     658                tracefifo_ack_update(libtrace->fifo,size + sizeof(rt_status_t));
    656659
    657660                packet->size = numbytes;
  • lib/format_pcap.c

    r7c8eacf r8013711  
    228228                return pcapbytes;
    229229        }
    230         packet->status = 0;
     230        packet->status.type = RT_DATA;
     231        packet->status.message = 0;
    231232        return (packet->size - sizeof(struct pcap_pkthdr));
    232233}
  • lib/format_wag.c

    r7c8eacf r8013711  
    326326                tracefifo_ack_update(libtrace->fifo,size);
    327327
    328                 packet->status = 0;
     328                packet->status.type = RT_DATA;
     329                packet->status.message = 0;
    329330                packet->size = numbytes;
    330331                return numbytes;
  • lib/libtrace.h

    r61ecfb6 r8013711  
    3434#include <sys/types.h>
    3535#include <netinet/in.h>
    36 
     36#include "rt_protocol.h"
    3737/** API version as 2 byte hex digits, eg 0xXXYYZZ */
    3838#define LIBTRACE_API_VERSION 0x020016  /* 2.0.22 */
     
    9595        char buffer[LIBTRACE_PACKET_BUFSIZE];
    9696        size_t size;
    97         uint32_t status;
     97        rt_status_t status;
    9898};
    9999                     
  • lib/rt_protocol.h

    r9c61e13 r8013711  
    3939#endif
    4040
    41 #include <libfifo.h>
    42 
    43 #define CAPTURE_PORT 3434
    44 #define COLLECTOR_PORT 3435
    45 
    4641#define MAXDATASIZE 65536
    4742
    48 // Server status codes
    49 #define S_KEYCHANGE 1 // Encryption key has changed, flush collection to disk
    50 #define S_DISKWARN 2 // Disk-backed fifo is > 75% used
    51 #define S_DISKCRIT 4 // Disk-backed fifo  is > 90% used
    52 #define S_DISKFULL 8 // Disk-backed fifo is > 95% used
    53 #define S_STATUS 16 // Packet is a fifo_status packet
    54 #define S_LOSTDATA 32 // capture restarted, flush collection to disk
    55 #define S_LOSTCONN 64 // connection to collector restarted, flush collection to disk
    56 /* ----------------------*/
    57 /* Codes for messages that cannot be parsed by libtrace */
    58 #define S_ALLCONN 128 // Already someone connected. Go away
    59 #define S_DUCKINFO 256 // Duck information packet
    60 #define S_FINISH 512 // No more data - close connection
    61 #define S_ACCEPT 1024 // Connection accepted
     43#define RT_DATA 1
     44#define RT_MSG 2
    6245
    63 #define S_MESSAGE_ONLY S_ALLCONN
     46typedef struct rt_status {
     47        uint8_t type;
     48        uint8_t reserved;
     49        uint16_t message;
     50} rt_status_t;
    6451
    65 // fifo_state_t is a tricky data type to transmit and receive so
    66 // it's easier to create a specialised structure
    67 typedef struct fifo_info {
    68         fifo_offset_t length;
    69         fifo_offset_t used;
    70         fifo_offset_t in;
    71         fifo_offset_t out;
    72         fifo_offset_t ack;
    73 } fifo_info_t;
    74 
    75 typedef struct fifo_status {
    76         fifo_info_t fifo;
    77 } fifo_status_t;
    78 
    79 typedef struct duck_info {
    80         duck_inf duck;
    81 } duck_info_t;
    8252
    8353typedef struct packet_header {
    84         uint32_t message;
     54        rt_status_t header;
    8555        dag_record_t erf;
    8656} packet_header_t;
    8757
    8858typedef struct ack_packet {
    89         uint32_t header;
     59        rt_status_t header;
    9060        long long int ts;
    9161} ack_packet_t;
    9262
    93 // Client message codes
    94 #define M_HALT_CAPTURE 1        // Request to halt capture
    95 #define M_START_CAPTURE 2       // Request to restart capture
    96 #define M_CONFIGURE 4           // Configuration info follows
    97 #define M_ACK 8                 // Ack
    98 
    9963#endif // _RT_PROTOCOL_H_
Note: See TracChangeset for help on using the changeset viewer.