+static char *format_qos (uint8_t qos, char *buffer, size_t buffer_size) /* {{{ */
+{
+ uint8_t dscp;
+ uint8_t ecn;
+ char *dscp_str;
+ char *ecn_str;
+
+ dscp = qos >> 2;
+ ecn = qos & 0x03;
+
+ switch (dscp)
+ {
+ case 0x00: dscp_str = "be"; break;
+ case 0x2e: dscp_str = "ef"; break;
+ case 0x0a: dscp_str = "af11"; break;
+ case 0x0c: dscp_str = "af12"; break;
+ case 0x0e: dscp_str = "af13"; break;
+ case 0x12: dscp_str = "af21"; break;
+ case 0x14: dscp_str = "af22"; break;
+ case 0x16: dscp_str = "af23"; break;
+ case 0x1a: dscp_str = "af31"; break;
+ case 0x1c: dscp_str = "af32"; break;
+ case 0x1e: dscp_str = "af33"; break;
+ case 0x22: dscp_str = "af41"; break;
+ case 0x24: dscp_str = "af42"; break;
+ case 0x26: dscp_str = "af43"; break;
+ case 0x08: dscp_str = "cs1"; break;
+ case 0x10: dscp_str = "cs2"; break;
+ case 0x18: dscp_str = "cs3"; break;
+ case 0x20: dscp_str = "cs4"; break;
+ case 0x28: dscp_str = "cs5"; break;
+ case 0x30: dscp_str = "cs6"; break;
+ case 0x38: dscp_str = "cs7"; break;
+ default: dscp_str = NULL;
+ }
+
+ switch (ecn)
+ {
+ case 0x01: ecn_str = ",ecn(1)"; break;
+ case 0x02: ecn_str = ",ecn(0)"; break;
+ case 0x03: ecn_str = ",ce"; break;
+ default: ecn_str = "";
+ }
+
+ if (dscp_str == NULL)
+ snprintf (buffer, buffer_size, "0x%02x%s", dscp, ecn_str);
+ else
+ snprintf (buffer, buffer_size, "%s%s", dscp_str, ecn_str);
+ buffer[buffer_size - 1] = 0;
+
+ return (buffer);
+} /* }}} char *format_qos */
+