diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-09-18 17:29:00 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-09-18 17:50:45 +0200 |
commit | c0fc3e67185c1e0ff2d083572c6ad3983ba4ef25 (patch) | |
tree | 9fe17603f4fec18b7f9fbd8d8efc1f13a9bef8ee /sysdep/unix/io.c | |
parent | afa14f1868f2c753efdc81ce8e2c2d44e6bdd80e (diff) |
The MRT protocol
The new MRT protocol is responsible for periodic RIB table dumps in the
MRT format (RFC 6396). Also the existing code for BGP4MP MRT dumps is
refactored and splitted between BGP to MRT protocols, will be more
integrated into MRT in the future.
Example:
protocol mrt {
table "*";
filename "%N_%F_%T.mrt";
period 60;
}
It is partially based on the old MRT code from Pavel Tvrdik.
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r-- | sysdep/unix/io.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 786c6a56..f7a9e29f 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -54,6 +54,7 @@ this to gen small latencies */ #define MAX_RX_STEPS 4 + /* * Tracked Files */ @@ -88,19 +89,32 @@ static struct resclass rf_class = { NULL }; -void * -tracked_fopen(pool *p, char *name, char *mode) +struct rfile * +rf_open(pool *p, char *name, char *mode) { FILE *f = fopen(name, mode); - if (f) - { - struct rfile *r = ralloc(p, &rf_class); - r->f = f; - } - return f; + if (!f) + return NULL; + + struct rfile *r = ralloc(p, &rf_class); + r->f = f; + return r; +} + +void * +rf_file(struct rfile *f) +{ + return f->f; +} + +int +rf_fileno(struct rfile *f) +{ + return fileno(f->f); } + /** * DOC: Timers * @@ -478,6 +492,20 @@ tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t) strcpy(x, "<too-long>"); } +int +tm_format_real_time(char *x, size_t max, const char *fmt, bird_clock_t t) +{ + struct tm tm; + + if (!localtime_r(&t, &tm)) + return 0; + + if (!strftime(x, max, fmt, &tm)) + return 0; + + return 1; +} + /** * DOC: Sockets |