NetBurner 3.5.6
PDF Version
config_netobj.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
17#ifndef CONFIG_NETOBJ_H
18#define CONFIG_NETOBJ_H
19#include <config_obj.h>
20
26{
27 public:
38 config_localname(config_obj &owner, NBString def_val, const char *name, const char *desc = NULL)
39 : config_string(owner, def_val, name, desc){};
40
43 { }
44
54 config_localname(NBString def_val, const char *name, const char *desc = NULL) : config_string(def_val, name, desc){};
55
66 config_localname(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL)
67 : config_string(owner, def_val, name, desc){};
68
78 config_localname(const char *def_val, const char *name, const char *desc = NULL) : config_string(def_val, name, desc){};
79
80 virtual void CommitTestedValue(uint32_t permission_mask);
86 operator NBString() const { return val; };
87
94 {
95 pend_val = val = p;
96 if (GetFlags(fConfigIsDefault))
97 ClrBranchFlag(fConfigIsDefault, true);
98 return *this;
99 };
100
107 {
108 pend_val = val = s;
109 if (GetFlags(fConfigIsDefault))
110 ClrBranchFlag(fConfigIsDefault, true);
111 return *this;
112 };
113
120 {
121 pend_val = val = ci.val;
122 if (GetFlags(fConfigIsDefault))
123 ClrBranchFlag(fConfigIsDefault, true);
124 return *this;
125 };
126
133 {
134 pend_val = val = ci.val;
135 if (GetFlags(fConfigIsDefault))
136 ClrBranchFlag(fConfigIsDefault, true);
137 return *this;
138 }
139};
140
141
142class I4Record;
147{
148 protected:
149 virtual int FdPrintValue(int fd, bool raw) override;
150 public:
151 IPADDR4 i4;
152 ConfigEndMarker;
154 CUR_IPADDR4(const char *name, const char *desc = NULL) : config_value(name, desc)
155 {
157 i4 = 0;
158 }
159
161 : config_value((config_value&&)I), i4(I.i4)
162 {
163
164 }
165
167 virtual void GetTextValue(NBString &s) { s.siprintf("\"%hI\"", i4); };
169 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) { return eUnchanged; }
171 virtual void CommitTestedValue(uint32_t permission_mask){};
172
173 CUR_IPADDR4 &operator=(const CUR_IPADDR4 &v)
174 {
175 if(i4!=v.i4)
176 {
177 i4 = v.i4;
178 if (GetFlags(fConfigIsDefault))
179 ClrBranchFlag(fConfigIsDefault, true);
180 AssignmentNotify();
181 }
182 return *this;
183 };
184 CUR_IPADDR4 &operator=(const IPADDR4 &v)
185 {
186 if(i4!=v)
187 {
188 i4 = v;
189 if (GetFlags(fConfigIsDefault))
190 ClrBranchFlag(fConfigIsDefault, true);
191 AssignmentNotify();
192 }
193 return *this;
194 };
195 CUR_IPADDR4 &operator=(const uint32_t v)
196 {
197 if(i4!=v)
198 {
199 i4 = v;
200 if (GetFlags(fConfigIsDefault))
201 ClrBranchFlag(fConfigIsDefault, true);
202 AssignmentNotify();
203 }
204 return *this;
205 };
206
208 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv4", indent, pretty); };
210 virtual void GetTypeValue(NBString &s) { s = "string"; };
212 operator IPADDR4() { return i4; };
213
215 inline bool IsNull() const { return i4.IsNull(); };
217 inline bool NotNull() const { return i4.NotNull(); };
219 inline void SetNull() { return i4.SetNull(); };
221 inline bool IsLoopBack() const { return i4.IsLoopBack(); };
223 inline bool IsMultiCast() const { return i4.IsMultiCast(); };
225 inline bool IsGlobalBroadCast() const { return i4.IsGlobalBroadCast(); };
227 inline bool IsAutoIP() { return i4.IsAutoIP(); };
228};
229
230inline bool operator==(const IPADDR4 i, const CUR_IPADDR4 &j)
231{
232 return i == j.i4;
233}
234inline bool operator!=(const IPADDR4 i, const CUR_IPADDR4 &j)
235{
236 return i != j.i4;
237}
238inline bool operator>(const IPADDR4 i, const CUR_IPADDR4 &j)
239{
240 return i > j.i4;
241}
242inline bool operator<(const IPADDR4 i, const CUR_IPADDR4 &j)
243{
244 return i > j.i4;
245}
246
247inline bool operator==(const CUR_IPADDR4 & i, const IPADDR4 j)
248{
249 return i.i4 == j;
250}
251inline bool operator!=(const CUR_IPADDR4 & i, const IPADDR4 j)
252{
253 return i.i4 != j;
254}
255inline bool operator>(const CUR_IPADDR4 & i, const IPADDR4 j)
256{
257 return i.i4 > j;
258}
259inline bool operator<(const CUR_IPADDR4 & i, const IPADDR4 j)
260{
261 return i.i4 > j;
262}
263
264inline bool operator==(const uint32_t i, const CUR_IPADDR4 &j)
265{
266 return i == j.i4;
267}
268inline bool operator!=(const uint32_t i, const CUR_IPADDR4 &j)
269{
270 return i != j.i4;
271}
272inline bool operator>(const uint32_t i, const CUR_IPADDR4 &j)
273{
274 return i > j.i4;
275}
276inline bool operator<(const uint32_t i, const CUR_IPADDR4 &j)
277{
278 return i < j.i4;
279}
280
281inline bool operator==(const CUR_IPADDR4 &i, const uint32_t j)
282{
283 return i.i4 == j;
284}
285inline bool operator!=(const CUR_IPADDR4 &i, const uint32_t j)
286{
287 return i.i4 != j;
288}
289inline bool operator>(const CUR_IPADDR4 &i, const uint32_t j)
290{
291 return i.i4 > j;
292}
293inline bool operator<(const CUR_IPADDR4 &i, const uint32_t j)
294{
295 return i.i4 < j;
296}
297
301class I4Record : public config_obj
302{
303 void *m_pBlock_if;
304
305 public:
306 config_chooser mode{"Mode", "DHCP", "DHCP,DHCP w Fallback,Static,Disabled",
307 "DHCP,DHCP with backup static address,Static preconfigured address,Disabled"};
308 config_IPADDR4 addr{"0.0.0.0", "StaticAddr", "Configured IP Address"};
309 config_IPADDR4 mask{"0.0.0.0", "StaticMask", "Configured IP Mask"};
310 config_IPADDR4 gate{"0.0.0.0", "StaticGate", "Configured IP Gateway"};
311 config_IPADDR4 dns1{"0.0.0.0", "StaticDNS1", "Configured IP DNS(1)"};
312 config_IPADDR4 dns2{"0.0.0.0", "StaticDNS2", "Configured IP DNS(2)"};
313
314 config_bool autoip{true, "AutoIPEn", "Enable Auto IP"};
315
316 //These are the only values used activly by the system
317 CUR_IPADDR4 cur_addr{"ActiveAddr", "Current IPV4 address in use"};
318 CUR_IPADDR4 cur_mask{"ActiveMask", "Current IPV4 mask in use"};
319 CUR_IPADDR4 cur_gate{"ActiveGate", "Current IPV4 gateway in use"};
320 CUR_IPADDR4 cur_dns1{"ActiveDNS1", "Current IPV4 dns(1) in use"};
321 CUR_IPADDR4 cur_dns2{"ActiveDNS2", "Current IPV4 dns(2) in use"};
322 CUR_IPADDR4 cur_auto{"AutoIPAddr", "Current IPV4 auto address in use"};
323 config_bool mac_dns {true,"EnableMacmDNS","Enable nburnxxxxxx.local using mac address"};
324 config_localname local_name{"","LocalName","The local name to resolve with mDNS (.local assumed)"};
325
326 ConfigEndMarker;
327
329 I4Record(const char *name, const char *desc = NULL) : config_obj(name, desc) { m_pBlock_if = 0; };
330
331 I4Record(I4Record &&IR);
332
334 void Attach(void *pb) { m_pBlock_if = pb; }
336 void GetReportItem(NBString &s, int item);
337};
338
339#ifdef IPV6
340class I6Record;
341
346{
347 int m_nItem;
348 I6Record *m_pI6;
349 ConfigEndMarker;
350
351 protected:
352 virtual int FdPrintValue(int fd, bool raw) override;
353 public:
355 virtual void GetTextValue(NBString &s);
356
358 Dynamic_IPADDR(const char *name, int item, I6Record *pI6, const char *desc = NULL) : config_value(name, desc)
359 {
360 m_nItem = item;
361 m_pI6 = pI6;
363 }
365
367 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) { return eUnchanged; }
369 virtual void CommitTestedValue(uint32_t permission_mask){};
371 void AddToJsonOutObject(ParsedJsonDataSet &jo, const char *name);
373 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv6", indent, pretty); };
375 virtual void GetTypeValue(NBString &s) { s = "array"; };
376};
377
381class I6Record : public config_obj
382{
383 int m_nIf;
384
385 public:
386 config_chooser mode{"Mode", "DHCP", "DHCP,DHCP w Fallback,Static,Disabled",
387 "DHCP,DHCP with backup static address,Static preconfigured address,Disabled"};
388 config_IPADDR addr{"0::0", "StaticAddr", "Configured IPV6 address"};
389 config_IPADDR dns1{"0::0", "StaticDNS1", "Configured IPV6 DNS(1)"};
390 config_IPADDR dns2{"0::0", "StaticDNS2", "Configured IPV6 DNS(2)"};
391
392 Dynamic_IPADDR address_list{"ActiveAddr", 0, this, "Active currently in user IPV6 addres(s)"};
393 Dynamic_IPADDR dns_list{"ActiveDNS", 1, this, "Active currently in user IPV6 DNS(s)"};
394 Dynamic_IPADDR route_list{"ActiveRoute", 2, this, "Active currently in user IPV6 routes"};
395
396 ConfigEndMarker;
397
399 I6Record(const char *name, const char *desc = NULL) : config_obj(name, desc) { m_nIf = -1; };
400 I6Record(I6Record &&i6);
402 void Attach(int nif) { m_nIf = nif; };
404 void ReportGetTextValue(NBString &s, int item);
406 int GetnIf() { return m_nIf; };
407};
408#endif
409
410#endif
411
Definition config_netobj.h:147
virtual void CommitTestedValue(uint32_t permission_mask)
Definition config_netobj.h:171
virtual void ExtendedSchema(int fd, int indent, bool pretty)
Definition config_netobj.h:208
bool NotNull() const
Definition config_netobj.h:217
bool IsGlobalBroadCast() const
Definition config_netobj.h:225
CUR_IPADDR4(const char *name, const char *desc=NULL)
Definition config_netobj.h:154
virtual void GetTextValue(NBString &s)
Definition config_netobj.h:167
virtual void GetTypeValue(NBString &s)
Definition config_netobj.h:210
bool IsMultiCast() const
Definition config_netobj.h:223
bool IsNull() const
Definition config_netobj.h:215
bool IsLoopBack() const
Definition config_netobj.h:221
bool IsAutoIP()
Definition config_netobj.h:227
virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs)
Definition config_netobj.h:169
void SetNull()
Definition config_netobj.h:219
Dynamic_IPADDR.
Definition config_netobj.h:346
virtual void ExtendedSchema(int fd, int indent, bool pretty)
Definition config_netobj.h:373
virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs)
Definition config_netobj.h:367
void AddToJsonOutObject(ParsedJsonDataSet &jo, const char *name)
Dynamic_IPADDR(const char *name, int item, I6Record *pI6, const char *desc=NULL)
Definition config_netobj.h:358
virtual void GetTypeValue(NBString &s)
Definition config_netobj.h:375
virtual void GetTextValue(NBString &s)
virtual void CommitTestedValue(uint32_t permission_mask)
Definition config_netobj.h:369
Definition config_netobj.h:302
void Attach(void *pb)
Definition config_netobj.h:334
I4Record(const char *name, const char *desc=NULL)
Definition config_netobj.h:329
void GetReportItem(NBString &s, int item)
Definition config_netobj.h:382
void Attach(int nif)
Definition config_netobj.h:402
I6Record(const char *name, const char *desc=NULL)
Definition config_netobj.h:399
int GetnIf()
Definition config_netobj.h:406
void ReportGetTextValue(NBString &s, int item)
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:225
bool IsNull() const
Check if the IP address is null.
Definition nettypes.h:279
bool IsLoopBack() const
Check if the IP address is the loopback address for the interface.
Definition nettypes.h:304
bool IsAutoIP()
Check if the IPADDR4 object contains an AutoIP address.
Definition nettypes.h:341
bool IsMultiCast() const
Check if the IPADDR4 object contains a Multicast IP address the interface.
Definition nettypes.h:313
bool NotNull() const
Check if the IP address is not null.
Definition nettypes.h:288
void SetNull()
Set the IP address to null.
Definition nettypes.h:295
bool IsGlobalBroadCast() const
Check if the IPADDR4 object contains a global broadcast address: 255.255.255.255.
Definition nettypes.h:332
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
A class to create, read, and modify a JSON object.
Definition json_lexer.h:535
Configuration Variable for IPADDR4 (IPv4) object types.
Definition config_obj.h:1493
Configuration Variable for IPADDR (IPv6) object type.
Definition config_obj.h:1675
Boolean Configuration Variable.
Definition config_obj.h:997
Chooser Configuration Variable - Select From a List of Items.
Definition config_obj.h:2027
Configure device network name.
Definition config_netobj.h:26
config_localname & operator=(const NBString &s)
Assign the config_localname object value from a NBString object.
Definition config_netobj.h:106
config_localname(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_netobj.h:66
config_localname & operator=(const char *p)
Assign the config_localname object value from a const char* value.
Definition config_netobj.h:93
config_localname(config_obj &owner, NBString def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_netobj.h:38
config_localname & operator=(const config_localname &ci)
Copy one config_localname object to another.
Definition config_netobj.h:132
config_localname & operator=(const config_string &ci)
Copy a config_string object to a config_localname object.
Definition config_netobj.h:119
config_localname(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_netobj.h:78
config_localname(NBString def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_netobj.h:54
Base class used to create configuration objects.
Definition config_obj.h:320
String Configuration Variable.
Definition config_obj.h:1127
Base class used to create a configuration value.
Definition config_obj.h:490
const uint32_t fConfigNoSave
Do not save to flash memory when save functions are called.
Definition config_obj.h:79
const uint32_t fConfigIsDefault
Value is unchanged from the default, i.e. wes never set.
Definition config_obj.h:84
const uint32_t fConfigReadOnly
Variable is read-only.
Definition config_obj.h:76