diff options
author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-06-02 12:04:33 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-06-02 12:04:33 +0200 |
commit | 1265927c7bcd40c5db213d4a9b42254a008f01d6 (patch) | |
tree | 6299da36751625cd5eb09938fd4e5d614d5695d0 /src/tsnifd.c | |
parent | 23367a9167c0ee1efb700a474e1a40ac28856da1 (diff) | |
download | tsnif-1265927c7bcd40c5db213d4a9b42254a008f01d6.tar.gz tsnif-1265927c7bcd40c5db213d4a9b42254a008f01d6.tar.xz tsnif-1265927c7bcd40c5db213d4a9b42254a008f01d6.zip |
aliveudp
Diffstat (limited to 'src/tsnifd.c')
-rw-r--r-- | src/tsnifd.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/tsnifd.c b/src/tsnifd.c index 52393d5..ca8c78d 100644 --- a/src/tsnifd.c +++ b/src/tsnifd.c @@ -23,6 +23,10 @@ static struct tsnif_handle handle; static int foreground = 0; static int killed = 0; +static int local = 0; +static int udp = 1; +static int udp_port = 4321; +static int udp_fd = -1; static int terminal_add(struct tsnif_term *term) { @@ -158,6 +162,7 @@ static int get_args(int argc, char **argv) {"version", no_argument, 0, 'v'}, {"foreground", no_argument, 0, 'f'}, {"store-dir", required_argument, 0, 's'}, + {"udp", optional_argument, 0, 'u'}, {"version", no_argument, 0, 'V'}, {"verbose", required_argument, 0, 'v'}, {"debug", required_argument, 0, 'd'}, @@ -180,6 +185,12 @@ static int get_args(int argc, char **argv) storage_dir = optarg; break; + case 'u': + udp = 1; + if (optarg) + udp_port = atoi(optarg); + break; + case 'V': print_version(argv[0]); break; @@ -218,17 +229,28 @@ int main(int argc, char **argv) if ((ret = setjmp(env))) { - if (ret > 1) + if (ret > 2) release_terms(); + if (udp && (ret > 1)) + udp_close(udp_fd); + tsnif_close(&handle); printf("done err = %d\n", err); return err; } + if (udp) { + err = udp_init(udp_port); + if (err) + longjmp(env, 1); + + udp_fd = err; + } + err = tsnif_list(&handle); if (err) - longjmp(env, 1); + longjmp(env, 2); signal(SIGINT, sig_handler); @@ -250,9 +272,9 @@ int main(int argc, char **argv) if (FD_ISSET(ts_fd, &rfds)) { err = tsnif_process(&handle); if (err) - longjmp(env, 2); + longjmp(env, 3); } } - longjmp(env, 2); + longjmp(env, 3); } |