7 bool do_qos_mode (int nb, const char **com, struct ngadmin *nga) {
10 const struct swi_attr *sa;
14 printf("Usage: qos mode port|802.1p\n");
18 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
19 printf("must be logged\n");
25 if ( strcasecmp(com[0], "port")==0 ) {
27 } else if ( strcasecmp(com[0], "802.1p")==0 ) {
30 printf("Unknown QOS mode\n");
36 i=ngadmin_setQOSMode(nga, s);
48 bool do_qos_set (int nb, const char **com, struct ngadmin *nga) {
51 const struct swi_attr *sa;
53 char d=PRIO_UNSPEC, *ports=NULL;
57 printf("Usage: qos set (all <prio0>)|(<port1> <prio1> [<port2> <prio2> ...])\n");
62 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
63 printf("must be logged\n");
69 ports=malloc(sa->ports*sizeof(char));
71 if ( strcmp(com[0], "all")==0 ) {
77 for (i=0; i<sa->ports; ++i) {
81 for (i=0; i<nb; i+=2) {
82 if ( (p=strtol(com[i], NULL, 0))<1 || p>sa->ports ) continue;
83 ports[p-1]=parsePrio(com[i+1]);
87 i=ngadmin_setQOSValues(nga, ports);
100 bool do_qos_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
102 int i, s=0, ret=true;
103 const struct swi_attr *sa;
107 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
108 printf("must be logged\n");
113 if ( (i=ngadmin_getQOSMode(nga, &s))!=ERR_OK ) {
120 printf("QoS mode: ");
125 } else if ( s!=QOS_PORT ) {
126 printf("unknown (%i)\n", s);
130 printf("port based\n");
132 ports=malloc(sa->ports*sizeof(char));
134 if ( (i=ngadmin_getQOSValues(nga, ports))!=ERR_OK ) {
140 for (i=0; i<sa->ports; ++i) {
141 printf("port %i: %s\n", i+1, prio[(int)ports[i]]);