X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-netflow.c;h=c37eeafe68e5a1fd3509124071cc3f911b4b4457;hb=8c0f519f6ee6c8cb17c3113401827296e7fa1481;hp=5a88ada3cde0f6fe031b19da253575723c6b11df;hpb=17f7f7e02cfd44dc7755fbebcfb942c07f937858;p=sliver-openvswitch.git diff --git a/tests/test-netflow.c b/tests/test-netflow.c index 5a88ada3c..c37eeafe6 100644 --- a/tests/test-netflow.c +++ b/tests/test-netflow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Nicira Networks. + * Copyright (c) 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include "command-line.h" #include "daemon.h" +#include "dynamic-string.h" #include "netflow.h" #include "ofpbuf.h" #include "packets.h" @@ -73,7 +74,7 @@ print_netflow(struct ofpbuf *buf) return; } - printf("rec: "IP_FMT" > "IP_FMT, + printf("seq %"PRIu32": "IP_FMT" > "IP_FMT, ntohl(hdr->flow_seq), IP_ARGS(&rec->src_addr), IP_ARGS(&rec->dst_addr)); printf(", if %"PRIu16" > %"PRIu16, @@ -87,31 +88,10 @@ print_netflow(struct ofpbuf *buf) printf(", TCP %"PRIu16" > %"PRIu16, ntohs(rec->src_port), ntohs(rec->dst_port)); if (rec->tcp_flags) { - putchar(' '); - if (rec->tcp_flags & TCP_SYN) { - putchar('S'); - } - if (rec->tcp_flags & TCP_FIN) { - putchar('F'); - } - if (rec->tcp_flags & TCP_PSH) { - putchar('P'); - } - if (rec->tcp_flags & TCP_RST) { - putchar('R'); - } - if (rec->tcp_flags & TCP_URG) { - putchar('U'); - } - if (rec->tcp_flags & TCP_ACK) { - putchar('.'); - } - if (rec->tcp_flags & 0x40) { - printf("[40]"); - } - if (rec->tcp_flags & 0x80) { - printf("[80]"); - } + struct ds s = DS_EMPTY_INITIALIZER; + packet_format_tcp_flags(&s, rec->tcp_flags); + printf(" %s", ds_cstr(&s)); + ds_destroy(&s); } break; @@ -190,7 +170,6 @@ main(int argc, char *argv[]) bool exiting = false; int error; int sock; - int fd; int n; proctitle_init(argc, argv); @@ -203,15 +182,12 @@ main(int argc, char *argv[]) } target = argv[optind]; - sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL); + sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL, 0); if (sock < 0) { ovs_fatal(0, "%s: failed to open (%s)", argv[1], strerror(-sock)); } - /* Daemonization will close stdout but we really want to keep it, so make a - * copy. */ - fd = dup(STDOUT_FILENO); - + daemon_save_fd(STDOUT_FILENO); daemonize_start(); error = unixctl_server_create(NULL, &server); @@ -222,9 +198,6 @@ main(int argc, char *argv[]) daemonize_complete(); - /* Now get stdout back. */ - dup2(fd, STDOUT_FILENO); - ofpbuf_init(&buf, MAX_RECV); n = 0; for (;;) { @@ -319,5 +292,5 @@ test_netflow_exit(struct unixctl_conn *conn, { bool *exiting = exiting_; *exiting = true; - unixctl_command_reply(conn, 200, ""); + unixctl_command_reply(conn, NULL); }