diff options
author | osdl.org!shemminger <osdl.org!shemminger> | 2004-04-15 20:56:59 +0000 |
---|---|---|
committer | osdl.org!shemminger <osdl.org!shemminger> | 2004-04-15 20:56:59 +0000 |
commit | aba5acdfdb347d2c21fc67d613d83d4430ca3937 (patch) | |
tree | 20a89d844444d062bac7e2a945251068f8e39d18 /tc/m_estimator.c | |
parent | 86fdf0e47be697587efcf9602cd1f952a1d73170 (diff) | |
download | platform_external_iproute2-aba5acdfdb347d2c21fc67d613d83d4430ca3937.tar.gz platform_external_iproute2-aba5acdfdb347d2c21fc67d613d83d4430ca3937.tar.bz2 platform_external_iproute2-aba5acdfdb347d2c21fc67d613d83d4430ca3937.zip |
(Logical change 1.3)
Diffstat (limited to 'tc/m_estimator.c')
-rw-r--r-- | tc/m_estimator.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tc/m_estimator.c b/tc/m_estimator.c index e69de29b..0f9808e5 100644 --- a/tc/m_estimator.c +++ b/tc/m_estimator.c @@ -0,0 +1,64 @@ +/* + * m_estimator.c Parse/print estimator module options. + * + * This program is free software; you can u32istribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <syslog.h> +#include <fcntl.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <string.h> + +#include "utils.h" +#include "tc_util.h" + +static void est_help(void) __attribute__((noreturn)); + +static void est_help(void) +{ + fprintf(stderr, "Usage: ... estimator INTERVAL TIME-CONST\n"); + fprintf(stderr, " INTERVAL is interval between measurements\n"); + fprintf(stderr, " TIME-CONST is averaging time constant\n"); + fprintf(stderr, "Example: ... est 1sec 8sec\n"); + exit(-1); +} + +int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est) +{ + int argc = *p_argc; + char **argv = *p_argv; + unsigned A, time_const; + + NEXT_ARG(); + if (est->ewma_log) + duparg("estimator", *argv); + if (matches(*argv, "help") == 0) + est_help(); + if (get_usecs(&A, *argv)) + invarg("estimator", "invalid estimator interval"); + NEXT_ARG(); + if (matches(*argv, "help") == 0) + est_help(); + if (get_usecs(&time_const, *argv)) + invarg("estimator", "invalid estimator time constant"); + if (tc_setup_estimator(A, time_const, est) < 0) { + fprintf(stderr, "Error: estimator parameters are out of range.\n"); + exit(-1); + } + if (show_raw) + fprintf(stderr, "[estimator i=%u e=%u]\n", est->interval, est->ewma_log); + *p_argc = argc; + *p_argv = argv; + return 0; +} |