Back to index

natlog  0.91.0
store.cc
Go to the documentation of this file.
00001 #include "pcaprecord.ih"
00002 
00003 void PcapRecord::store(Record *record)
00004 {
00005     time_t now = time(0);
00006     size_t idx = 0;
00007 
00008     for (auto &element: d_connections)
00009     {
00010         if (element == 0)               // empty element
00011         {
00012             element = record;           // store the record in the empty spot
00013             return;
00014         }
00015                                         // delete old, incomplete records
00016         if (element->status == INCOMPLETE && seconds(*element) + TTL < now)
00017         {
00018             imsg << "Replacing incomplete #" << idx << endl;
00019             delete element;
00020             element = record;
00021             return;
00022         }
00023         ++idx;
00024     }
00025     d_connections.push_back(record);    // add the record at the end
00026     imsg << "New index #" << (d_connections.size() - 1) << endl;
00027 }
00028 
00029 
00030 
00031