]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ip/QosConfig.cc
Author: Andrew Beverley <andy@andybev.com>
[thirdparty/squid.git] / src / ip / QosConfig.cc
CommitLineData
575cb927
AJ
1#include "squid.h"
2
3#if USE_ZPH_QOS
4
5#include "QosConfig.h"
575cb927 6
b7ac5457
AJ
7Ip::Qos::QosConfig Ip::Qos::TheConfig;
8
9Ip::Qos::QosConfig::QosConfig() :
af6a12ee
AJ
10 tos_local_hit(0),
11 tos_sibling_hit(0),
12 tos_parent_hit(0),
13 preserve_miss_tos(1),
14 preserve_miss_tos_mask(255)
575cb927
AJ
15{
16 ;
17}
18
19void
b7ac5457 20Ip::Qos::QosConfig::parseConfigLine()
575cb927
AJ
21{
22 // %i honors 0 and 0x prefixes, which are important for things like umask
23 /* parse options ... */
24 char *token;
af6a12ee 25 while ( (token = strtok(NULL, w_space)) ) {
575cb927 26
af6a12ee 27 if (strncmp(token, "local-hit=",10) == 0) {
575cb927 28 sscanf(&token[10], "%i", &tos_local_hit);
af6a12ee 29 } else if (strncmp(token, "sibling-hit=",12) == 0) {
575cb927 30 sscanf(&token[12], "%i", &tos_sibling_hit);
af6a12ee 31 } else if (strncmp(token, "parent-hit=",11) == 0) {
575cb927 32 sscanf(&token[11], "%i", &tos_parent_hit);
af6a12ee 33 } else if (strcmp(token, "disable-preserve-miss") == 0) {
575cb927
AJ
34 preserve_miss_tos = 0;
35 preserve_miss_tos_mask = 0;
af6a12ee 36 } else if (preserve_miss_tos && strncmp(token, "miss-mask=",10) == 0) {
575cb927
AJ
37 sscanf(&token[10], "%i", &preserve_miss_tos_mask);
38 }
39 }
40}
41
dbe6f864
AJ
42/**
43 * NOTE: Due to the low-level nature of the library these
44 * objects are part of the dump function must be self-contained.
45 * which means no StoreEntry refrences. Just a basic char* buffer.
46 */
575cb927 47void
b7ac5457 48Ip::Qos::QosConfig::dumpConfigLine(char *entry, const char *name) const
575cb927 49{
dbe6f864
AJ
50 char *p = entry;
51 snprintf(p, 10, "%s", name); // strlen("qos_flows ");
52 p += strlen(name);
575cb927
AJ
53
54 if (tos_local_hit >0) {
dbe6f864
AJ
55 snprintf(p, 15, " local-hit=%2x", tos_local_hit);
56 p += 15;
575cb927
AJ
57 }
58
59 if (tos_sibling_hit >0) {
dbe6f864
AJ
60 snprintf(p, 17, " sibling-hit=%2x", tos_sibling_hit);
61 p += 17;
575cb927
AJ
62 }
63 if (tos_parent_hit >0) {
dbe6f864
AJ
64 snprintf(p, 16, " parent-hit=%2x", tos_parent_hit);
65 p += 16;
575cb927
AJ
66 }
67 if (preserve_miss_tos != 0) {
dbe6f864
AJ
68 snprintf(p, 22, " disable-preserve-miss");
69 p += 22;
575cb927
AJ
70 }
71 if (preserve_miss_tos && preserve_miss_tos_mask != 0) {
dbe6f864
AJ
72 snprintf(p, 15, " miss-mask=%2x", preserve_miss_tos_mask);
73 p += 15;
575cb927 74 }
dbe6f864
AJ
75 snprintf(p, 1, "\n");
76// p += 1;
575cb927
AJ
77}
78
79#endif /* USE_ZPH_QOS */