5 bool do_qos_mode (int argc, const char **argv, struct ngadmin *nga)
8 const struct swi_attr *sa;
12 printf("usage: qos mode port|802.1p\n");
16 sa = ngadmin_getCurrentSwitch(nga);
18 printf("must be logged\n");
23 if (strcasecmp(argv[0], "port") == 0) {
25 } else if (strcasecmp(argv[0], "802.1p") == 0) {
28 printf("Unknown QOS mode\n");
33 i = ngadmin_setQOSMode(nga, s);
42 bool do_qos_set (int argc, const char **argv, struct ngadmin *nga)
45 const struct swi_attr *sa;
47 char d = PRIO_UNSPEC, *ports = NULL;
51 printf("usage: qos set (all <prio0>)|(<port1> <prio1> [<port2> <prio2> ...])\n");
56 sa = ngadmin_getCurrentSwitch(nga);
58 printf("must be logged\n");
63 ports = malloc(sa->ports * sizeof(char));
66 if (strcmp(argv[0], "all") == 0) {
67 d = parsePrio(argv[1]);
73 for (i = 0; i < sa->ports; i++)
76 /* read and apply port specifics */
77 for (i = 0; i < argc; i += 2) {
78 p = strtol(argv[i], NULL, 0);
79 if (p < 1 || p > sa->ports)
81 ports[p - 1] = parsePrio(argv[i + 1]);
84 /* send the new configuration to the switch */
85 i = ngadmin_setQOSValues(nga, ports);
95 bool do_qos_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
97 int i, s = 0, ret = true;
98 const struct swi_attr *sa;
103 printf("this command takes no argument\n");
108 sa = ngadmin_getCurrentSwitch(nga);
110 printf("must be logged\n");
115 i = ngadmin_getQOSMode(nga, &s);
122 printf("QoS mode: ");
130 printf("port based\n");
134 printf("unknown (%i)\n", s);
138 ports = malloc(sa->ports * sizeof(char));
139 i = ngadmin_getQOSValues(nga, ports);
146 for (i = 0; i < sa->ports; i++)
147 printf("port %i: %s\n", i + 1, prio[(int)ports[i]]);