OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::DnsName Struct Reference
Inheritance diagram for Slic3r::DnsName:
Collaboration diagram for Slic3r::DnsName:

Public Types

enum  { MAX_RECURSION = 10 }

Static Public Member Functions

static optional< DnsName > decode (const std::vector< char > &buffer, size_t &offset, unsigned depth=0)

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_RECURSION 
66 {
67 MAX_RECURSION = 10, // Keep this low
68 };
@ MAX_RECURSION
Definition Bonjour.cpp:67

Member Function Documentation

◆ decode()

optional< DnsName > Slic3r::DnsName::decode ( const std::vector< char > & buffer,
size_t & offset,
unsigned depth = 0 )
inlinestatic
71 {
72 // Check offset sanity:
73 if (offset + 1 >= buffer.size()) {
74 return boost::none;
75 }
76
77 // Check for recursion depth to prevent parsing names that are nested too deeply or end up cyclic:
78 if (depth >= MAX_RECURSION) {
79 return boost::none;
80 }
81
82 DnsName res;
83 const size_t bsize = buffer.size();
84
85 while (true) {
86 const char* ptr = buffer.data() + offset;
87 unsigned len = static_cast<unsigned char>(*ptr);
88 if (len & 0xc0) {
89 // This is a recursive label
90 unsigned len_2 = static_cast<unsigned char>(ptr[1]);
91 size_t pointer = (len & 0x3f) << 8 | len_2;
92 const auto nested = decode(buffer, pointer, depth + 1);
93 if (!nested) {
94 return boost::none;
95 } else {
96 if (res.size() > 0) {
97 res.push_back('.');
98 }
99 res.append(*nested);
100 offset += 2;
101 return std::move(res);
102 }
103 } else if (len == 0) {
104 // This is a name terminator
105 offset++;
106 break;
107 } else {
108 // This is a regular label
109 len &= 0x3f;
110 if (len + offset + 1 >= bsize) {
111 return boost::none;
112 }
113
114 res.reserve(len);
115 if (res.size() > 0) {
116 res.push_back('.');
117 }
118
119 ptr++;
120 for (const auto end = ptr + len; ptr < end; ptr++) {
121 char c = *ptr;
122 if (c >= 0x20 && c <= 0x7f) {
123 res.push_back(c);
124 } else {
125 return boost::none;
126 }
127 }
128
129 offset += len + 1;
130 }
131 }
132
133 if (res.size() > 0) {
134 return std::move(res);
135 } else {
136 return boost::none;
137 }
138 }
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
static optional< DnsName > decode(const std::vector< char > &buffer, size_t &offset, unsigned depth=0)
Definition Bonjour.cpp:70

References decode(), MAX_RECURSION, and Slic3r::offset().

Referenced by decode(), Slic3r::DnsQuestion::decode(), Slic3r::DnsResource::decode(), and Slic3r::DnsRR_SRV::decode().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.cpp