// SPDX-License-Identifier: GPL-3.0-or-later#include"daemon/common.h"#define RRD_TYPE_TC "tc"#define PLUGIN_TC_NAME "tc.plugin"// ----------------------------------------------------------------------------// /sbin/tc processor// this requires the script plugins.d/tc-qos-helper.sh#define TC_LINE_MAX 1024structtc_class{avl_tavl;char*id;uint32_thash;char*name;char*leafid;uint32_tleaf_hash;char*parentid;uint32_tparent_hash;charhasparent;charisleaf;charisqdisc;charrender;unsignedlonglongbytes;unsignedlonglongpackets;unsignedlonglongdropped;unsignedlonglongoverlimits;unsignedlonglongrequeues;unsignedlonglonglended;unsignedlonglongborrowed;unsignedlonglonggiants;unsignedlonglongtokens;unsignedlonglongctokens;RRDDIM*rd_bytes;RRDDIM*rd_packets;RRDDIM*rd_dropped;RRDDIM*rd_tokens;RRDDIM*rd_ctokens;charname_updated;charupdated;// updated bytesintunupdated;// the number of times, this has been found un-updatedstructtc_class*next;structtc_class*prev;};structtc_device{avl_tavl;char*id;uint32_thash;char*name;char*family;charname_updated;charfamily_updated;charenabled;charenabled_bytes;charenabled_packets;charenabled_dropped;charenabled_tokens;charenabled_ctokens;charenabled_all_classes_qdiscs;RRDSET*st_bytes;RRDSET*st_packets;RRDSET*st_dropped;RRDSET*st_tokens;RRDSET*st_ctokens;avl_tree_typeclasses_index;structtc_class*classes;structtc_class*last_class;structtc_device*next;structtc_device*prev;};structtc_device*tc_device_root=NULL;// ----------------------------------------------------------------------------// tc_device indexstaticinttc_device_compare(void*a,void*b){if(((structtc_device*)a)->hash<((structtc_device*)b)->hash)return-1;elseif(((structtc_device*)a)->hash>((structtc_device*)b)->hash)return1;elsereturnstrcmp(((structtc_device