+static inline int add_htb_node(const char *iface, const uint32_t parent_major, const uint32_t parent_minor,
+ const uint32_t classid_major, const uint32_t classid_minor,
+ const uint64_t rate, const uint64_t ceil) {
+ char cmd[300];
+
+ sprintf(cmd, "tc class add dev %s parent %x:%x classid %x:%x htb rate %llubit ceil %llubit",
+ iface, parent_major, parent_minor, classid_major, classid_minor, rate, ceil);
+ printlog(LOG_WARN, "INIT: HTB_cmd: %s\n", cmd);
+
+ return execute_cmd(cmd);
+}
+
+static inline int add_htb_netem(const char *iface, const uint32_t parent_major,
+ const uint32_t parent_minor, const uint32_t handle,
+ const int loss, const int delay) {
+ char cmd[300];
+
+ sprintf(cmd, "/sbin/tc qdisc del dev %s parent %x:%x handle %x pfifo", iface, parent_major,
+ parent_minor, handle);
+ printlog(LOG_DEBUG, "HTB_cmd: %s\n", cmd);
+ if (execute_cmd(cmd))
+ printlog(LOG_DEBUG, "HTB_cmd: Previous deletion did not succeed.\n");
+
+ sprintf(cmd, "/sbin/tc qdisc replace dev %s parent %x:%x handle %x netem loss %d%% delay %dms",
+ iface, parent_major, parent_minor, handle, loss, delay);
+ printlog(LOG_DEBUG, "HTB_cmd: %s\n", cmd);
+ return execute_cmd(cmd);
+}
+