~ubuntu-branches/ubuntu/trusty/conntrack/trusty-proposed

« back to all changes in this revision

Viewing changes to src/cache_lifetime.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt, Max Kellermann
  • Date: 2008-04-14 23:09:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080414230922-9xoi1gl38tc8lyng
Tags: 1:0.9.6-4
[ Max Kellermann ]
fix compilation on SPARC (printf argument mismatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (C) 2006 by Pablo Neira Ayuso <pablo@netfilter.org>
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 */
 
18
 
 
19
#include <stdio.h>
 
20
#include "us-conntrack.h"
 
21
#include "cache.h"
 
22
#include <sys/time.h>
 
23
#include <time.h>
 
24
 
 
25
static void lifetime_add(struct us_conntrack *u, void *data)
 
26
{
 
27
        long *lifetime = data;
 
28
        struct timeval tv;
 
29
 
 
30
        gettimeofday(&tv, NULL);
 
31
 
 
32
        *lifetime = tv.tv_sec;
 
33
}
 
34
 
 
35
static void lifetime_update(struct us_conntrack *u, void *data)
 
36
{
 
37
}
 
38
 
 
39
static void lifetime_destroy(struct us_conntrack *u, void *data)
 
40
{
 
41
}
 
42
 
 
43
static int lifetime_dump(struct us_conntrack *u, 
 
44
                         void *data, 
 
45
                         char *buf, 
 
46
                         int type)
 
47
{
 
48
        long *lifetime = data;
 
49
        struct timeval tv;
 
50
 
 
51
        if (type == NFCT_O_XML)
 
52
                return 0;
 
53
 
 
54
        gettimeofday(&tv, NULL);
 
55
 
 
56
        return sprintf(buf, " [active since %lds]", tv.tv_sec - *lifetime);
 
57
}
 
58
 
 
59
struct cache_feature lifetime_feature = {
 
60
        .size           = sizeof(long),
 
61
        .add            = lifetime_add,
 
62
        .update         = lifetime_update,
 
63
        .destroy        = lifetime_destroy,
 
64
        .dump           = lifetime_dump
 
65
};