summaryrefslogtreecommitdiffstats
path: root/lib/route/tc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/route/tc.c')
-rw-r--r--lib/route/tc.c108
1 files changed, 0 insertions, 108 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c
index 97faef4..9d85801 100644
--- a/lib/route/tc.c
+++ b/lib/route/tc.c
@@ -465,113 +465,5 @@ int rtnl_tc_build_rate_table(uint32_t *dst, uint8_t mpu, uint8_t overhead,
/** @} */
-/**
- * @name Traffic Control Handle Translations
- * @{
- */
-
-/**
- * Convert a traffic control handle to a character string (Reentrant).
- * @arg handle traffic control handle
- * @arg buf destination buffer
- * @arg len buffer length
- *
- * Converts a tarffic control handle to a character string in the
- * form of \c MAJ:MIN and stores it in the specified destination buffer.
- *
- * @return The destination buffer or the type encoded in hexidecimal
- * form if no match was found.
- */
-char * rtnl_tc_handle2str(uint32_t handle, char *buf, size_t len)
-{
- if (TC_H_ROOT == handle)
- snprintf(buf, len, "root");
- else if (TC_H_UNSPEC == handle)
- snprintf(buf, len, "none");
- else if (0 == TC_H_MAJ(handle))
- snprintf(buf, len, ":%02x", TC_H_MIN(handle));
- else if (0 == TC_H_MIN(handle))
- snprintf(buf, len, "%02x:", TC_H_MAJ(handle) >> 16);
- else
- snprintf(buf, len, "%02x:%02x",
- TC_H_MAJ(handle) >> 16, TC_H_MIN(handle));
-
- return buf;
-}
-
-/**
- * Convert a charactering strint to a traffic control handle
- * @arg name traffic control handle as character string
- * @arg res destination buffer
- *
- * Converts the provided character string specifying a traffic
- * control handle to the corresponding numeric value.
- *
- * The handle must be provided in one of the following formats:
- * - root
- * - none
- * - XXXX:
- * - :YYYY
- * - XXXX:YYYY
- * - XXXXYYYY
- *
- * @return 0 on success or a negative error code
- */
-int rtnl_tc_str2handle(const char *name, uint32_t *res)
-{
- char *colon, *end;
- uint32_t h;
-
- if (!strcasecmp(name, "root")) {
- *res = TC_H_ROOT;
- return 0;
- }
-
- if (!strcasecmp(name, "none")) {
- *res = TC_H_UNSPEC;
- return 0;
- }
-
- h = strtoul(name, &colon, 16);
-
- if (colon == name) {
- /* :YYYY */
- h = 0;
- if (':' != *colon)
- return -NLE_INVAL;
- }
-
- if (':' == *colon) {
- /* check if we would lose bits */
- if (TC_H_MAJ(h))
- return -NLE_RANGE;
- h <<= 16;
-
- if ('\0' == colon[1]) {
- /* XXXX: */
- *res = h;
- } else {
- /* XXXX:YYYY */
- uint32_t l = strtoul(colon+1, &end, 16);
-
- /* check if we overlap with major part */
- if (TC_H_MAJ(l))
- return -NLE_RANGE;
-
- if ('\0' != *end)
- return -NLE_INVAL;
-
- *res = (h | l);
- }
- } else if ('\0' == *colon) {
- /* XXXXYYYY */
- *res = h;
- } else
- return -NLE_INVAL;
-
- return 0;
-}
-
-/** @} */
/** @} */