Example #1
0
void
capture_packet_time_sorter(vector_t *vector, void *item)
{
    struct timeval curts, prevts;
    int count = vector_count(vector);
    int i;

    // TODO Implement multiframe packets
    curts = packet_time(item);
    prevts = packet_time(vector_last(vector));

    // Check if the item is already sorted
    if (timeval_is_older(curts, prevts)) {
        return;
    }

    for (i = count - 2 ; i >= 0; i--) {
        // Get previous packet
        prevts = packet_time(vector_item(vector, i));
        // Check if the item is already in a sorted position
        if (timeval_is_older(curts, prevts)) {
            vector_insert(vector, item, i + 1);
            return;
        }
    }

    // Put this item at the begining of the vector
    vector_insert(vector, item, 0);
}
Example #2
0
void
capture_packet_time_sorter(vector_t *vector, void *item)
{
    capture_packet_t *prev, *cur;
    int count = vector_count(vector);
    int i;

    // Get current item
    cur = (capture_packet_t *) item;
    prev = vector_item(vector, count - 2);

    // Check if the item is already sorted
    if (prev && timeval_is_older(cur->header->ts, prev->header->ts)) {
        return;
    }

    for (i = count - 2 ; i >= 0; i--) {
        // Get previous packet
        prev = vector_item(vector, i);
        // Check if the item is already in a sorted position
        if (timeval_is_older(cur->header->ts, prev->header->ts)) {
            vector_insert(vector, item, i + 1);
            return;
        }
    }

    // Put this item at the begining of the vector
    vector_insert(vector, item, 0);
}
Example #3
0
int
msg_is_older(sip_msg_t *one, sip_msg_t *two)
{
    // Yes, you are older than nothing
    if (!two)
        return 1;

    // Otherwise
    return timeval_is_older(msg_get_time(one), msg_get_time(two));
}