]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - fwp/mngr/fwp_mngr.c
Merge branch 'master' of rtime.felk.cvut.cz:frescor/fwp
[frescor/fwp.git] / fwp / mngr / fwp_mngr.c
index 4d21f2f0c3bc1f440d05f1be3c1f2c72fdc72ba2..c94328ae063c82f4907b01f912e9794f2203335e 100644 (file)
 #include <forb.h>
 #include <error.h>
 #include <errno.h>
+#include <getopt.h>
 #include <fres_sa_scenario.h>
 #include <stdbool.h>
 #include <ul_log.h>
+#include <ul_logreg.h>
 #include <fwp_res.h>
 #include <stdio.h>
 #include "fwp_admctrl.h"
 
+#if 0
 static
 int dummy_admission_test(struct fres_sa_scenario *scenario, void *priv, 
                                bool *schedulable)
@@ -79,6 +82,13 @@ int dummy_admission_test(struct fres_sa_scenario *scenario, void *priv,
                
        return 0;
 }
+#endif
+
+struct frm_fwp_priv priv = {
+       .rate_mbps = 1,
+       .erp_ofdm = false,
+       .short_preamble = false,
+};
 
 static const struct fres_res_manager frm = {
        .res_type = FRSH_RT_NETWORK,
@@ -86,15 +96,69 @@ static const struct fres_res_manager frm = {
        //.admission_test = dummy_admission_test,
        .name = "WLAN",
        .admission_test = fwp_admctrl_utilization,
-       .priv = NULL
+       .priv = &priv,
+};
+
+static struct option long_opts[] = {
+    { "loglevel",         required_argument, 0, 'l' },
+    { "bitrate",         required_argument, 0, 'b' },
+    { "ofdm",                    no_argument,       0, 'o' },
+    { "short-preamble",  no_argument,       0, 's' },
+    { 0, 0, 0, 0}
 };
 
+static void
+usage(void)
+{
+       printf("usage: fwpmngr [ options ]\n");
+       printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
+       printf("  -b, --bitrate <mbits/s>\n");
+       printf("  -o, --ofdm\n");
+       printf("  -s, --short-preamble\n");
+       printf("  -h, --help\n");
+}
+
 int main(int argc, char *argv[])
 {
        forb_orb orb;
        int ret;
-
        forb_init_attr_t attr = { .orb_id = "org.frescor.frm.fwp" };
+       int  opt;
+       bool opt_daemon = false;
+       char *opt_pidfile = NULL;
+
+       if (getenv("FWP_BYPASS"))
+               priv.bypass = true;
+
+
+       while ((opt = getopt_long(argc, argv, "b:d:hl:os", &long_opts[0], NULL)) != EOF) {
+               switch (opt) {
+                       case 'd':
+                               opt_daemon = true;
+                               opt_pidfile = optarg;
+                               break;
+                       case 'l':
+                               ul_log_domain_arg2levels(optarg);
+                               break;
+                       case 'b':
+                               priv.rate_mbps = atol(optarg);
+                               break;
+                       case 's':
+                               priv.short_preamble = true;
+                               break;
+                       case 'o':
+                               priv.erp_ofdm = true;
+                               break;
+                       case 'h':
+                       /*default:*/
+                               usage();
+                               exit(opt == 'h' ? 0 : 1);
+               }
+       }
+
+       if (opt_daemon)
+               forb_daemon_prepare(opt_pidfile);
+
        orb = forb_init(&argc, &argv, &attr);
        if (!orb) error(1, errno, "forb_init");