p_exporter->sequence_number++;
static int ipfix_prepend_header(ipfix_exporter *p_exporter, int data_length, ipfix_sendbuffer *sendbuf){        ipfix_header header;        time_t export_time;        int ret;        uint16_t total_length = 0;        int header_length = 4 * sizeof(uint32_t);        // did the user set the data_length field?        if (data_length != 0) {                total_length = header_length+data_length;        } else {                // compute it on our own:                // sum up all lengths in the iovecs:                int i;                // start the loop with 1, as 0 is reserved for the header!                for (i = 1; i< sendbuf->current;  i++) {                        total_length += sendbuf->entries[i].iov_len;                }                // add the header lenght to the total length:                total_length += header_length;        }        // write the length into the header        header.length = total_length;        // write version number and source ID        header.version = IPFIX_VERSION_NUMBER;        header.source_id = p_exporter->source_id;        //  increment and write the sequence number:        header.sequence_number = p_exporter->sequence_number;        p_exporter->sequence_number++;        // get the export time:        export_time = time(NULL);        if(export_time == (time_t)-1) {                // survive                export_time=0;                msg(MSG_DEBUG,"IPFIX: prepend_header, time() failed, using %d", export_time);        }        //  global_last_export_time = (uint32_t) export_time;        header.export_time = (uint32_t)export_time;        // write the header:        // first, get the buffer for the header        char* p_base = sendbuf->header_store;        char* p_pos = p_base;        char* p_end = p_pos + IPFIX_HEADER_LENGTH;        // write into that header        ret = write_ipfix_message_header(&header, &p_pos, p_end);        sendbuf->entries[0].iov_len = IPFIX_HEADER_LENGTH;        sendbuf->entries[0].iov_base = p_base;        return ret;}