2 #ifndef __SC_WRITER_H__
3 #define __SC_WRITER_H__
14 #define MAX_SNAPLEN 262144
16 #define SC_PARTIAL_BUFFER (1 << 12)
18 static inline int on_error_from_str(
const char* str,
enum on_error* on_error_out)
20 if( ! strcasecmp(str,
"exit") ) {
21 *on_error_out = ON_ERROR_EXIT;
24 if( ! strcasecmp(str,
"abort") ) {
25 *on_error_out = ON_ERROR_ABORT;
28 if( ! strcasecmp(str,
"message") ) {
29 *on_error_out = ON_ERROR_MESSAGE;
32 if( ! strcasecmp(str,
"silent") ) {
33 *on_error_out = ON_ERROR_SILENT;
39 static inline int ts_type_from_str(
const char* str,
enum ts_type* ts_type_out)
41 if( ! strcasecmp(str,
"pcap") ) {
42 *ts_type_out = ts_micro;
45 if( ! strcasecmp(str,
"pcap-ns") ) {
46 *ts_type_out = ts_nano;
52 static inline int sc_pcap_filename(
char* buf,
int buf_len,
const char* template_in,
53 bool timed,
bool indexed,
54 struct timespec ts,
int index)
58 const char* needle =
"$i";
59 const char* p = strstr(template_in, needle);
61 if( snprintf(tmpl, buf_len,
"%.*s%d%s", (
int)(p-template_in), template_in,
62 index, p + strlen(needle)) == buf_len )
66 if( snprintf(tmpl, buf_len,
"%s%d", template_in, index) == buf_len )
72 if( snprintf(tmpl, buf_len,
"%s", template_in) == buf_len )
78 if( strftime(buf, buf_len,
79 tmpl, localtime_r(&ts.tv_sec, &tm)) == 0 )
83 if( snprintf(buf, buf_len,
"%s", tmpl) == buf_len )
89 struct sc_pcap_packer_state;
91 int sc_perf_writer_init(
struct sc_node* node,
const struct sc_attr* attr,
94 void sc_pcap_packer_set_file_byte_count(
struct sc_pcap_packer_state* st,
95 uint64_t file_byte_count);
101 void sc_pcap_packer_end_of_stream(
struct sc_node* node);
103 void sc_pcap_packer_add_input(
struct sc_node* packer_node,
struct sc_node* input_node);
Struct to hold information about how to create an instance of this node.
Definition: ext_node.h:69
A list of packets or packet buffers.
Definition: ext_packet_list.h:14
Description of a node.
Definition: ext_node.h:17