"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/flow.cpp" between
tcpflow-1.5.0.tar.gz and tcpflow-1.6.1.tar.gz

About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.

flow.cpp  (tcpflow-1.5.0):flow.cpp  (tcpflow-1.6.1)
skipping to change at line 45 skipping to change at line 45
std::cout << " %A/%a - source IP address/port; %B/%b - dest IP add ress/port\n"; std::cout << " %A/%a - source IP address/port; %B/%b - dest IP add ress/port\n";
std::cout << " %E/%e - source/dest Ethernet Mac address\n"; std::cout << " %E/%e - source/dest Ethernet Mac address\n";
std::cout << " %V/%v - VLAN number, '--' if no vlan/'' if no vlan\n"; std::cout << " %V/%v - VLAN number, '--' if no vlan/'' if no vlan\n";
std::cout << " %T/%t - Timestamp in ISO8601 format/unix time_t\n"; std::cout << " %T/%t - Timestamp in ISO8601 format/unix time_t\n";
std::cout << " %c - connection_count for connections>0 / %# for all connect ions;"; std::cout << " %c - connection_count for connections>0 / %# for all connect ions;";
std::cout << " %C - 'c' if connection_count >0\n"; std::cout << " %C - 'c' if connection_count >0\n";
std::cout << " %N - (connection_number ) % 1000\n"; std::cout << " %N - (connection_number ) % 1000\n";
std::cout << " %K - (connection_number / 1000) % 1000\n"; std::cout << " %K - (connection_number / 1000) % 1000\n";
std::cout << " %M - (connection_number / 1000000) % 1000\n"; std::cout << " %M - (connection_number / 1000000) % 1000\n";
std::cout << " %G - (connection_number / 1000000000) % 1000\n"; std::cout << " %G - (connection_number / 1000000000) % 1000\n";
std::cout << " %S - session ID\n";
std::cout << " %% - Output a '%'\n"; std::cout << " %% - Output a '%'\n";
std::cout << "\n"; std::cout << "\n";
std::cout << "Default value is: '"<< flow::filename_template <<"'\n"; std::cout << "Default value is: '"<< flow::filename_template <<"'\n";
std::cout << "\n"; std::cout << "\n";
std::cout << "Note: Using the option -T will ignore options -Fk, -Fm and -Fg .\n"; std::cout << "Note: Using the option -T will ignore options -Fk, -Fm and -Fg .\n";
std::cout << " Filename template format handles '/' to create sub-direc tories.\n"; std::cout << " Filename template format handles '/' to create sub-direc tories.\n";
} }
std::string flow::filename(uint32_t connection_count) std::string flow::filename(uint32_t connection_count, bool is_pcap)
{ {
std::stringstream ss; std::stringstream ss;
/* Add the outdir */ /* Add the outdir */
if(flow::outdir!="." && flow::outdir!=""){ if(flow::outdir!="." && flow::outdir!=""){
ss << flow::outdir; ss << flow::outdir;
ss << '/'; ss << '/';
} }
for(unsigned int i=0;i<filename_template.size();i++){ for(unsigned int i=0;i<filename_template.size();i++){
skipping to change at line 138 skipping to change at line 139
break; break;
case 'v': // VLAN number if VLAN is present case 'v': // VLAN number if VLAN is present
if(vlan!=be13::packet_info::NO_VLAN) ss << vlan; if(vlan!=be13::packet_info::NO_VLAN) ss << vlan;
break; break;
case 'C': // 'c' if connection_count >0 case 'C': // 'c' if connection_count >0
if(connection_count>0) ss << "c"; if(connection_count>0) ss << "c";
break; break;
case 'c': // connection_count if connection_count >0 case 'c': // connection_count if connection_count >0
if(connection_count>0) ss << connection_count; if(connection_count>0) ss << connection_count;
break; break;
case 'S': // session ID
ss << std::setfill('0') << std::setw(20) << session_id;
break;
case '#': // always output connection count case '#': // always output connection count
ss << connection_count; ss << connection_count;
break; break;
case '%': // Output a '%' case '%': // Output a '%'
ss << "%"; ss << "%";
break; break;
default: default:
std::cerr << "Invalid filename_template: " << filename_template < < "\n"; std::cerr << "Invalid filename_template: " << filename_template < < "\n";
std::cerr << "unknown character: " << filename_template.at(i+1) < < "\n"; std::cerr << "unknown character: " << filename_template.at(i+1) < < "\n";
exit(1); exit(1);
} }
if(buf[0]) ss << buf; if(buf[0]) ss << buf;
} }
} }
if(is_pcap){
ss << ".pcap"; // file extension
}
return ss.str(); return ss.str();
} }
/** /**
* Find an unused filename for the flow and optionally open it. * Find an unused filename for the flow and optionally open it.
* This is called from tcpip::open_file(). * This is called from tcpip::open_file().
*/ */
std::string flow::new_filename(int *fd,int flags,int mode) std::string flow::new_filename(int *fd,int flags,int mode)
{ {
/* Loop connection count until we find a file that doesn't exist */ /* Loop connection count until we find a file that doesn't exist */
for(uint32_t connection_count=0;;connection_count++){ for(uint32_t connection_count=0;;connection_count++){
std::string nfn = filename(connection_count); std::string nfn = filename(connection_count, false);
if(nfn.find('/')!=std::string::npos) mkdirs_for_path(nfn.c_str()); if(nfn.find('/')!=std::string::npos) mkdirs_for_path(nfn.c_str());
int nfd = tcpdemux::getInstance()->retrying_open(nfn,flags,mode); int nfd = tcpdemux::getInstance()->retrying_open(nfn,flags,mode);
if(nfd>=0){ if(nfd>=0){
*fd = nfd; *fd = nfd;
return nfn; return nfn;
} }
if(errno!=EEXIST) die("Cannot open: %s",nfn.c_str()); if(errno!=EEXIST) die("Cannot open: %s",nfn.c_str());
} }
return std::string("<<CANNOT CREATE FILE>>"); // error; no fil e return std::string("<<CANNOT CREATE FILE>>"); // error; no fil e
} }
std::string flow::new_pcap_filename()
{
/* Loop connection count until we find a file that doesn't exist */
for(uint32_t connection_count=0;;connection_count++){
std::string nfn = filename(connection_count, true);
if(nfn.find('/')!=std::string::npos) mkdirs_for_path(nfn.c_str());
return nfn;
}
return std::string("<<CANNOT CREATE FILE>>"); // error; no fil
e
}
 End of changes. 6 change blocks. 
2 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)