| 24 | const cripts::string Common::_name = "Bundle::Common"; |
| 25 | |
| 26 | bool |
| 27 | Common::Validate(std::vector<cripts::Bundle::Error> &errors) const |
| 28 | { |
| 29 | bool good = true; |
| 30 | |
| 31 | // The .dscp() can only be 0 - 63 |
| 32 | if (_dscp < 0 || _dscp > 63) { |
| 33 | errors.emplace_back("dscp must be between 0 and 63", Name(), "dscp"); |
| 34 | good = false; |
| 35 | } |
| 36 | |
| 37 | // Make sure we didn't encounter an error setting up the via headers |
| 38 | if (_client_via.first == 999 || _origin_via.first == 999) { |
| 39 | errors.emplace_back("via_header must be one of: disable, protocol, basic, detailed, full", Name(), "via_header"); |
| 40 | good = false; |
| 41 | } |
| 42 | |
| 43 | // Make sure all configurations are of the correct type |
| 44 | for (auto &[rec, value] : _configs) { |
| 45 | switch (rec->Type()) { |
| 46 | case TS_RECORDDATATYPE_INT: |
| 47 | if (!std::holds_alternative<TSMgmtInt>(value)) { |
| 48 | errors.emplace_back("Invalid value for config, expecting an integer", Name(), rec->Name()); |
| 49 | good = false; |
| 50 | } |
| 51 | break; |
| 52 | case TS_RECORDDATATYPE_FLOAT: |
| 53 | if (!std::holds_alternative<TSMgmtFloat>(value)) { |
| 54 | errors.emplace_back("Invalid value for config, expecting a float", Name(), rec->Name()); |
| 55 | good = false; |
| 56 | } |
| 57 | break; |
| 58 | case TS_RECORDDATATYPE_STRING: |
| 59 | if (!std::holds_alternative<std::string>(value)) { |
| 60 | errors.emplace_back("Invalid value for config, expecting an integer", Name(), rec->Name()); |
| 61 | good = false; |
| 62 | } |
| 63 | break; |
| 64 | |
| 65 | default: |
| 66 | errors.emplace_back("Invalid configuration type", Name(), rec->Name()); |
| 67 | good = false; |
| 68 | break; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return good; |
| 73 | } |
| 74 | |
| 75 | Common::self_type & |
| 76 | Common::via_header(const cripts::string_view &destination, const cripts::string_view &value) |
nothing calls this directly
no test coverage detected