NetBurner 3.5.0
PDF Version
 
config_netobj.h
Go to the documentation of this file.
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 return *this;
97 };
98
105 {
106 pend_val = val = s;
107 return *this;
108 };
109
116 {
117 pend_val = val = ci.val;
118 return *this;
119 };
120
127 {
128 pend_val = val = ci.val;
129 return *this;
130 }
131};
132
133
134class I4Record;
139{
140 public:
141 IPADDR4 i4;
142 ConfigEndMarker;
144 CUR_IPADDR4(const char *name, const char *desc = NULL) : config_value(name, desc)
145 {
147 i4 = 0;
148 }
149
151 : config_value((config_value&&)I), i4(I.i4)
152 {
153
154 }
155
157 virtual void GetTextValue(NBString &s) { s.siprintf("\"%hI\"", i4); };
159 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) { return eUnchanged; }
161 virtual void CommitTestedValue(uint32_t permission_mask){};
162
163 CUR_IPADDR4 &operator=(const CUR_IPADDR4 &v)
164 {
165 i4 = v.i4;
166 return *this;
167 };
168 CUR_IPADDR4 &operator=(const IPADDR4 &v)
169 {
170 i4 = v;
171 return *this;
172 };
173 CUR_IPADDR4 &operator=(const uint32_t v)
174 {
175 i4 = v;
176 return *this;
177 };
178
180 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv4", indent, pretty); };
182 virtual void GetTypeValue(NBString &s) { s = "string"; };
184 operator IPADDR4() { return i4; };
185
187 inline bool IsNull() const { return i4.IsNull(); };
189 inline bool NotNull() const { return i4.NotNull(); };
191 inline void SetNull() { return i4.SetNull(); };
193 inline bool IsLoopBack() const { return i4.IsLoopBack(); };
195 inline bool IsMultiCast() const { return i4.IsMultiCast(); };
197 inline bool IsGlobalBroadCast() const { return i4.IsGlobalBroadCast(); };
199 inline bool IsAutoIP() { return i4.IsAutoIP(); };
200};
201
202inline bool operator==(const IPADDR4 i, const CUR_IPADDR4 &j)
203{
204 return i == j.i4;
205}
206inline bool operator!=(const IPADDR4 i, const CUR_IPADDR4 &j)
207{
208 return i != j.i4;
209}
210inline bool operator>(const IPADDR4 i, const CUR_IPADDR4 &j)
211{
212 return i > j.i4;
213}
214inline bool operator<(const IPADDR4 i, const CUR_IPADDR4 &j)
215{
216 return i > j.i4;
217}
218
219inline bool operator==(const CUR_IPADDR4 & i, const IPADDR4 j)
220{
221 return i.i4 == j;
222}
223inline bool operator!=(const CUR_IPADDR4 & i, const IPADDR4 j)
224{
225 return i.i4 != j;
226}
227inline bool operator>(const CUR_IPADDR4 & i, const IPADDR4 j)
228{
229 return i.i4 > j;
230}
231inline bool operator<(const CUR_IPADDR4 & i, const IPADDR4 j)
232{
233 return i.i4 > j;
234}
235
236inline bool operator==(const uint32_t i, const CUR_IPADDR4 &j)
237{
238 return i == j.i4;
239}
240inline bool operator!=(const uint32_t i, const CUR_IPADDR4 &j)
241{
242 return i != j.i4;
243}
244inline bool operator>(const uint32_t i, const CUR_IPADDR4 &j)
245{
246 return i > j.i4;
247}
248inline bool operator<(const uint32_t i, const CUR_IPADDR4 &j)
249{
250 return i < j.i4;
251}
252
253inline bool operator==(const CUR_IPADDR4 &i, const uint32_t j)
254{
255 return i.i4 == j;
256}
257inline bool operator!=(const CUR_IPADDR4 &i, const uint32_t j)
258{
259 return i.i4 != j;
260}
261inline bool operator>(const CUR_IPADDR4 &i, const uint32_t j)
262{
263 return i.i4 > j;
264}
265inline bool operator<(const CUR_IPADDR4 &i, const uint32_t j)
266{
267 return i.i4 < j;
268}
269
273class I4Record : public config_obj
274{
275 void *m_pBlock_if;
276
277 public:
278 config_chooser mode{"Mode", "DHCP", "DHCP,DHCP w Fallback,Static,Disabled",
279 "DHCP,DHCP with backup static address,Static preconfigured address,Disabled"};
280 config_IPADDR4 addr{"0.0.0.0", "StaticAddr", "Configured IP Address"};
281 config_IPADDR4 mask{"0.0.0.0", "StaticMask", "Configured IP Mask"};
282 config_IPADDR4 gate{"0.0.0.0", "StaticGate", "Configured IP Gateway"};
283 config_IPADDR4 dns1{"0.0.0.0", "StaticDNS1", "Configured IP DNS(1)"};
284 config_IPADDR4 dns2{"0.0.0.0", "StaticDNS2", "Configured IP DNS(2)"};
285
286 config_bool autoip{true, "AutoIPEn", "Enable Auto IP"};
287
288 //These are the only values used activly by the system
289 CUR_IPADDR4 cur_addr{"ActiveAddr", "Current IPV4 address in use"};
290 CUR_IPADDR4 cur_mask{"ActiveMask", "Current IPV4 mask in use"};
291 CUR_IPADDR4 cur_gate{"ActiveGate", "Current IPV4 gateway in use"};
292 CUR_IPADDR4 cur_dns1{"ActiveDNS1", "Current IPV4 dns(1) in use"};
293 CUR_IPADDR4 cur_dns2{"ActiveDNS2", "Current IPV4 dns(2) in use"};
294 CUR_IPADDR4 cur_auto{"AutoIPAddr", "Current IPV4 auto address in use"};
295 config_bool mac_dns {true,"EnableMacmDNS","Enable nburnxxxxxx.local using mac address"};
296 config_localname local_name{"","LocalName","The local name to resolve with mDNS (.local assumed)"};
297
298 ConfigEndMarker;
299
301 I4Record(const char *name, const char *desc = NULL) : config_obj(name, desc) { m_pBlock_if = 0; };
302
303 I4Record(I4Record &&IR);
304
306 void Attach(void *pb) { m_pBlock_if = pb; }
308 void GetReportItem(NBString &s, int item);
309};
310
311#ifdef IPV6
312class I6Record;
313
318{
319 int m_nItem;
320 I6Record *m_pI6;
321 ConfigEndMarker;
322
323 public:
325 virtual void GetTextValue(NBString &s);
326
328 Dynamic_IPADDR(const char *name, int item, I6Record *pI6, const char *desc = NULL) : config_value(name, desc)
329 {
330 m_nItem = item;
331 m_pI6 = pI6;
333 }
335
337 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) { return eUnchanged; }
339 virtual void CommitTestedValue(uint32_t permission_mask){};
341 void AddToJsonOutObject(ParsedJsonDataSet &jo, const char *name);
343 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv6", indent, pretty); };
345 virtual void GetTypeValue(NBString &s) { s = "array"; };
346};
347
351class I6Record : public config_obj
352{
353 int m_nIf;
354
355 public:
356 config_chooser mode{"Mode", "DHCP", "DHCP,DHCP w Fallback,Static,Disabled",
357 "DHCP,DHCP with backup static address,Static preconfigured address,Disabled"};
358 config_IPADDR addr{"0::0", "StaticAddr", "Configured IPV6 address"};
359 config_IPADDR dns1{"0::0", "StaticDNS1", "Configured IPV6 DNS(1)"};
360 config_IPADDR dns2{"0::0", "StaticDNS2", "Configured IPV6 DNS(2)"};
361
362 Dynamic_IPADDR address_list{"ActiveAddr", 0, this, "Active currently in user IPV6 addres(s)"};
363 Dynamic_IPADDR dns_list{"ActiveDNS", 1, this, "Active currently in user IPV6 DNS(s)"};
364 Dynamic_IPADDR route_list{"ActiveRoute", 2, this, "Active currently in user IPV6 routes"};
365
366 ConfigEndMarker;
367
369 I6Record(const char *name, const char *desc = NULL) : config_obj(name, desc) { m_nIf = -1; };
370 I6Record(I6Record &&i6);
372 void Attach(int nif) { m_nIf = nif; };
374 void ReportGetTextValue(NBString &s, int item);
376 int GetnIf() { return m_nIf; };
377};
378#endif
379
380#endif
381
Definition config_netobj.h:139
virtual void CommitTestedValue(uint32_t permission_mask)
Definition config_netobj.h:161
virtual void ExtendedSchema(int fd, int indent, bool pretty)
Definition config_netobj.h:180
bool NotNull() const
Definition config_netobj.h:189
bool IsGlobalBroadCast() const
Definition config_netobj.h:197
CUR_IPADDR4(const char *name, const char *desc=NULL)
Definition config_netobj.h:144
virtual void GetTextValue(NBString &s)
Definition config_netobj.h:157
virtual void GetTypeValue(NBString &s)
Definition config_netobj.h:182
bool IsMultiCast() const
Definition config_netobj.h:195
bool IsNull() const
Definition config_netobj.h:187
bool IsLoopBack() const
Definition config_netobj.h:193
bool IsAutoIP()
Definition config_netobj.h:199
virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs)
Definition config_netobj.h:159
void SetNull()
Definition config_netobj.h:191
Dynamic_IPADDR.
Definition config_netobj.h:318
virtual void ExtendedSchema(int fd, int indent, bool pretty)
Definition config_netobj.h:343
virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs)
Definition config_netobj.h:337
void AddToJsonOutObject(ParsedJsonDataSet &jo, const char *name)
Dynamic_IPADDR(const char *name, int item, I6Record *pI6, const char *desc=NULL)
Definition config_netobj.h:328
virtual void GetTypeValue(NBString &s)
Definition config_netobj.h:345
virtual void GetTextValue(NBString &s)
virtual void CommitTestedValue(uint32_t permission_mask)
Definition config_netobj.h:339
Definition config_netobj.h:274
void Attach(void *pb)
Definition config_netobj.h:306
I4Record(const char *name, const char *desc=NULL)
Definition config_netobj.h:301
void GetReportItem(NBString &s, int item)
Definition config_netobj.h:352
void Attach(int nif)
Definition config_netobj.h:372
I6Record(const char *name, const char *desc=NULL)
Definition config_netobj.h:369
int GetnIf()
Definition config_netobj.h:376
void ReportGetTextValue(NBString &s, int item)
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:208
bool IsNull() const
Check if the IP address is null.
Definition nettypes.h:262
bool IsLoopBack() const
Check if the IP address is the loopback address for the interface.
Definition nettypes.h:287
bool IsAutoIP()
Check if the IPADDR4 object contains an AutoIP address.
Definition nettypes.h:324
bool IsMultiCast() const
Check if the IPADDR4 object contains a Multicast IP address the interface.
Definition nettypes.h:296
bool NotNull() const
Check if the IP address is not null.
Definition nettypes.h:271
void SetNull()
Set the IP address to null.
Definition nettypes.h:278
bool IsGlobalBroadCast() const
Check if the IPADDR4 object contains a global broadcast address: 255.255.255.255.
Definition nettypes.h:315
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
A class to create, read, and modify a JSON object.
Definition json_lexer.h:530
Configuration Variable for IPADDR4 (IPv4) object types.
Definition config_obj.h:1404
Configuration Variable for IPADDR (IPv6) object type.
Definition config_obj.h:1580
Boolean Configuration Variable.
Definition config_obj.h:932
Chooser Configuration Variable - Select From a List of Items.
Definition config_obj.h:1915
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:104
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:126
config_localname & operator=(const config_string &ci)
Copy a config_string object to a config_localname object.
Definition config_netobj.h:115
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:277
String Configuration Variable.
Definition config_obj.h:1055
Base class used to create a configuration value.
Definition config_obj.h:446
Configuration object header file.
const uint32_t fConfigNoSave
Do not save to flash memory when save functions are called.
Definition config_obj.h:75
const uint32_t fConfigReadOnly
Variable is read-only.
Definition config_obj.h:72