NetBurner 3.5.0
PDF Version
 
config_obj.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
47#ifndef CONFIG_OBJ_H
48#define CONFIG_OBJ_H
49
50#include <buffers.h>
51#include <nbstring.h>
52#include <string.h>
53#include <utils.h>
54
55void ShowTree();
56
57enum ConfigTestResult
58{
59 eUnchanged,
60 eOk,
61 eBad
62};
63
71const uint32_t fConfigValueLeaf = 0x01;
72const uint32_t fConfigReadOnly = 0x02;
73const uint32_t fConfigModified = 0x04;
74const uint32_t fConfigHidden = 0x08;
75const uint32_t fConfigNoSave = 0x10;
76const uint32_t fConfigNoObscure = 0x20;
77const uint32_t fConfigNeedReboot = 0x40;
78const uint32_t fConfigNoReload = 0x80;
79const uint32_t fConfigDetached = 0x100;
80const uint32_t fConfigIsDefault= 0x200;
83/* Config Mask Values */
84const uint32_t PermitFlashFromStorage = (0x80000000);
85
86class config_leaf;
87class config_obj;
89class RootParseStateInfo;
90
91typedef void(LeafCallBack)(config_leaf *p, void *pextra);
92
93/*
94 * Configuration leaf class.
95 * Used to manage the configuration tree, internal use only.
96 */
97class config_leaf
98{
99 // We explicitly *do not allow* copy construction, as the only likely usage
100 // would be passing to variadic functions *which will not know this is non-POD*
101 config_leaf(config_leaf &rhs) = delete;
102 protected:
103 config_leaf *FindChild(const char *&cp);
104 void RootParse(RootParseStateInfo &rpsi);
105 static void FixTree(config_leaf* root);
106
107
108 virtual void RemoveFromRootList();
109 void RawFdPrintTree(int fd, config_leaf *pl, int n, bool pretty, uint32_t mask, bool braw_values,bool valonly);
110
111 public:
112 inline void FdPrintValTree(int fd, config_leaf *pl, int n, bool pretty, uint32_t inhibit_mask = fConfigHidden, bool bRawValue = false)
113 {
114 RawFdPrintTree(fd,pl,n,pretty,inhibit_mask,bRawValue,true);
115 }
116 inline void FdPrintTree(int fd, config_leaf *pl, int n, bool pretty, uint32_t inhibit_mask = fConfigHidden, bool bRawValue = false)
117 {
118 RawFdPrintTree(fd,pl,n,pretty,inhibit_mask,bRawValue,false);
119 }
120
121 void FdPrintSchema(int fd, config_leaf *pl, int n, bool pretty, uint32_t inhibit_mask = fConfigHidden);
122 void SchemaOptions(int fd, int indent, bool pretty);
123 void ForEachLeaf(LeafCallBack *pc, void *pextra, bool siblings = false);
124 bool FlatParseBuffer(fifo_buffer_storage &rxbuf, uint32_t permissions, const char *where);
125 bool ParseBuffer(fifo_buffer_storage &rxbuf, uint32_t permissions, const char *where);
126 bool ParseBlob(uint8_t *pdata, int len, uint32_t permissions);
127 bool FlatParseBlob(uint8_t *pdata, int len, uint32_t permissions);
128 bool ParseFd(int fd, uint32_t permissions, config_leaf * pParseRoot = NULL);
129 config_obj *FindParent() { return pParent; };
130 static config_leaf *FindConfigLeaf(const unsigned char *name, config_leaf *pBranch = NULL);
131
132 //Call if a config object is not static
133 void FixNonStaticObject();
134
135 void RemoveFromConfigTree();
136
137 const char *pName;
138 const char *pDescription;
139 config_leaf *pNextSibling;
140 config_obj *pParent;
141 config_leaf *pChildren;
142 config_leaf *pGList;
143 static config_leaf *pRootList;
144 static config_leaf *pDetachList;
145
146 uint32_t m_Flags;
147 void DoSchemaLine(int fd, const char *name, const char *value, int indent, bool pretty, bool quoted = true);
148
149 public:
150 bool NameMatch(const char *cp);
151 virtual const char *GetSortNameValue() { return pName; };
152 virtual void GetDescriptionValue(NBString &s) { s = pDescription; };
153 virtual void GetNameValue(NBString &s) { s = pName; };
154 virtual void GetTextValue(NBString &s) { s = pName; };
155 virtual void GetRawValue(NBString &s) { return GetTextValue(s); };
156 virtual void GetTypeValue(NBString &s) { s = "unknown"; };
157 virtual void ExtendedSchema(int fd, int indent, bool pretty){};
158 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) { return eOk; };
159 // This is named so error messages make sense to user
160 // Old name was GetExtent
161 virtual int Missing_ConfigEndMarker(void *&startp) = 0;
162
163 void ClearModified();
164
165 bool MatchId(ParsedJsonDataSet &pjs);
166
167 virtual void CommitTestedValue(uint32_t permission_mask){};
168
169 virtual ~config_leaf();
170
171 config_leaf(bool bDetached=false)
172 {
173 pNextSibling = NULL;
174 pChildren = NULL;
175 m_Flags = fConfigIsDefault;
176 pParent = NULL;
177 if (bDetached)
178 {
179 pGList=pDetachList;
180 pDetachList=this;
181 m_Flags|=fConfigDetached;
182 }
183 else
184 {
185 pGList = pRootList;
186 pRootList = this;
187 }
188 }
189 config_leaf(config_leaf &&l);
190
191 static void DiagShow();
192 static void FixTree();
193 void FindUnknownParent();
194
195 void ShowOne();
196
197 int compare(config_leaf *pl)
198 {
199 if (pl == NULL) return -1;
200 return strcmp(GetSortNameValue(), pl->GetSortNameValue());
201 };
202
203 void GetFullName(NBString &s);
204 void GetBranchName(NBString &s, config_leaf *branchRoot);
205 void RenderToFd(int fd, bool pretty = false, uint32_t mask = fConfigHidden, bool bRawValue = false);
206 void RenderSchemaToFd(int fd, bool pretty = false, uint32_t mask = fConfigHidden);
207 uint32_t GetFlags() { return m_Flags; }
208 void SetFlag(uint32_t flag) { m_Flags |= flag; };
209 void SetBranchFlag(uint32_t flag);
210 void ClrFlag(uint32_t flag) { m_Flags &= (~flag); };
211 void ReloadFromFlash();
212
213 friend void HtmlLeafRender(int fd, config_leaf *pl, int eMode, int len, const char *extra);
214};
215
276class config_obj : public config_leaf
277{
278 protected:
279 config_obj(bool bDetached=false):config_leaf(bDetached){}
280 config_obj *pMasterObjectLink;
281 static config_obj *pObjList;
282
283 virtual void RemoveFromRootList();
284 public:
285 void InstallUnderMe(config_leaf &ltoadd);
286 void RemoveFromChildren(config_leaf &ltoremove);
287
300 config_obj(config_obj &owner, const char *name, const char *desc)
301 {
302 pName = name;
303 pDescription = desc;
304 pChildren = NULL;
305 pMasterObjectLink = pObjList;
306 pObjList = this;
307 pParent = &owner;
308 }
310
323 config_obj(const char *name, const char *desc)
324 {
325 pName = name;
326 pDescription = desc;
327 pChildren = NULL;
328 pParent = NULL;
329 pMasterObjectLink = pObjList;
330 pObjList = this;
331 }
332
333
334
335 bool DoIContain(config_leaf *pl);
336
337 /*
338 * These two functions, along with GetTextValue(), can be used to create a custom object
339 * class, including the responsibility for the JSON serialization.
340 *
341 * GetTextValue(): Must return a string with the object encoded in it in JSON format
342 *
343 * TestNewValue(): Takes a parsed JSON object and extracts the values from that tree.
344 * This is where parameters can be tested for validity, and if not valid,
345 * the entire set is marked as invalid.
346 *
347 * CommitTestedValue(): Commit the values extracted by TestNewValue()
348 *
349 * This enables functionality such as parsing a set of values to determine if the SET is
350 * valid, rather than just an individual value.
351 */
352 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
353 virtual void CommitTestedValue(uint32_t permission_mask);
354
355 // This is named so error messages make sense to user, old name was GetExtent
356 virtual int Missing_ConfigEndMarker(void *&startp)
357 {
358 startp = this;
359 return sizeof(*this);
360 };
361
369 virtual void GetTextValue(NBString &s);
370
378 virtual void GetTypeValue(NBString &s) { s = "object"; };
379
380 friend class config_leaf;
381};
382
383/*
384 * Configuration Root object class
385 */
386class root_obj : public config_obj
387{
388 public:
389 root_obj()
390 { pName = "Config";
391 pDescription = "Root of config tree";
392 }
393
394 // This is named so error messages make sense to user, old name was GetExtent
395 virtual int Missing_ConfigEndMarker(void *&startp)
396 {
397 startp = this;
398 return sizeof(*this);
399 };
400};
401
402class detached_root_obj : public config_obj
403{
404 public:
405 detached_root_obj():config_obj(true)
406 { pName = "detached";
407 pDescription = "Root of detached tree";
408 }
409
410 // This is named so error messages make sense to user, old name was GetExtent
411 virtual int Missing_ConfigEndMarker(void *&startp)
412 {
413 startp = this;
414 return sizeof(*this);
415 };
416};
417
418
419
420
421extern root_obj root;
422extern detached_root_obj detached;
423
445class config_value : public config_leaf
446{
447 public:
448 virtual void GetTextValue(NBString &s) = 0;
449
450 protected:
463 config_value(config_obj &owner, const char *name, const char *desc)
464 {
465 pName = name;
466 pDescription = desc;
467 owner.InstallUnderMe(*this);
468 pChildren = NULL;
469 m_Flags |= fConfigValueLeaf;
470 }
471
484 config_value(const char *name, const char *desc)
485 {
486 pName = name;
487 pDescription = desc;
488 pParent = NULL;
489 pChildren = NULL;
490 m_Flags |= fConfigValueLeaf;
491 }
492
494};
495
504{
505 protected:
506 uint32_t val;
507 uint32_t pend_val;
508
509 public:
517 virtual void GetTextValue(NBString &s) { s.siprintf("%u", val); };
518
527 config_uint(config_obj &owner, uint32_t def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
528 {
529 val = def_val;
530 pend_val = val;
531 }
532
540 config_uint(uint32_t def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
541 {
542 val = def_val;
543 pend_val = val;
544 }
545
547
548 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
549 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
550
551 // Assignment operators
552
564 operator uint32_t() const { return val; };
565
571 config_uint &operator=(const uint32_t i)
572 {
573 pend_val = val = i;
574 return *this;
575 };
576
583 {
584 pend_val = val = ci.val;
585 return *this;
586 };
587
588 // This is named so error messages make sense to user. Old name was GetExtent
589 virtual int Missing_ConfigEndMarker(void *&startp)
590 {
591 startp = this;
592 return sizeof(*this);
593 };
594
602 virtual void GetTypeValue(NBString &s) { s = "integer"; };
603};
604
605class config_hex_uint : public config_uint
606{
607
608 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
609
610public:
619 config_hex_uint(config_obj &owner, uint32_t def_val, const char *name, const char *desc = NULL) : config_uint(owner,def_val, name, desc)
620 {
621 }
622
630 config_hex_uint(uint32_t def_val, const char *name, const char *desc = NULL) : config_uint(def_val,name, desc)
631 {
632 }
633
634 virtual void GetTextValue(NBString &s) { s.siprintf("\"%08X\"", val); };
635 virtual void GetTypeValue(NBString &s) { s = "hexuint"; };
636
637};
638
639
640
649{
650 protected:
651 int val;
652 int pend_val;
653
654 public:
662 virtual void GetTextValue(NBString &s) { s.siprintf("%d", val); };
663
672 config_int(config_obj &owner, int def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
673 {
674 val = def_val;
675 pend_val = val;
676 }
677
685 config_int(int def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
686 {
687 val = def_val;
688 pend_val = val;
689 }
690
692
693 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
694
695 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
696
697 // Assignment operators
698
710 operator int() const { return val; };
711
717 config_int &operator=(const int i)
718 {
719 pend_val = val = i;
720 return *this;
721 };
722
730 {
731 pend_val = val = ci.val;
732 return *this;
733 };
734
735 // This is named so error messages make sense to user, old name was GetExtent
736 virtual int Missing_ConfigEndMarker(void *&startp)
737 {
738 startp = this;
739 return sizeof(*this);
740 };
741
749 virtual void GetTypeValue(NBString &s) { s = "integer"; };
750};
751
760{
761 double val;
762 double pend_val;
763
764 public:
772 virtual void GetTextValue(NBString &s) { s.sprintf("%g", val); };
773
782 config_double(config_obj &owner, double def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
783 {
784 val = def_val;
785 pend_val = val;
786 }
787
795 config_double(double def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
796 {
797 val = def_val;
798 pend_val = val;
799 }
800
802
803 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
804 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
805
806 // Assignment operators
807
819 operator int() const { return val; };
820
832 operator float() const { return val; };
833
845 operator double() const { return val; };
846
852 config_double &operator=(const double d)
853 {
854 pend_val = val = d;
855 return *this;
856 };
857
864 {
865 pend_val = val = ci.val;
866 return *this;
867 };
868
869 // This is named so error messages make sense to user. old name was GetExtent
870 virtual int Missing_ConfigEndMarker(void *&startp)
871 {
872 startp = this;
873 return sizeof(*this);
874 };
875
883 virtual void GetTypeValue(NBString &s) { s = "float"; };
884};
885
886/*
887 * Class used for system status reports, for internal use only
888 */
889class config_report : public config_value
890{
891 protected:
892 const char *m_value;
893
894 public:
895 config_report(config_obj &owner, const char *value, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
896 {
897 m_Flags = fConfigReadOnly | fConfigNoSave;
898 m_value = value;
899 }
900 config_report(const char *value, const char *name, const char *desc = NULL) : config_value(name, desc)
901 {
902 m_Flags = fConfigReadOnly | fConfigNoSave;
903 m_value = value;
904 }
905
906 config_report(config_report &&r);
907
908 virtual void GetTextValue(NBString &s);
909 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
910 virtual void CommitTestedValue(uint32_t permission_mask);
911 // This is named so error messages make sense to user
912 // Old name was GetExtent
913 virtual int Missing_ConfigEndMarker(void *&startp)
914 {
915 startp = this;
916 return sizeof(*this);
917 };
918 virtual void GetTypeValue(NBString &s) { s = "string"; };
919
920 const char *c_str() { return m_value; };
921 void ModifyValue(const char *nv) { m_value = nv; };
922};
923
932{
933 protected:
934 bool val;
935 bool pend_val;
936
937 public:
945 virtual void GetTextValue(NBString &s)
946 {
947 if (val)
948 s = "true";
949 else
950 s = "false";
951 };
952
961 config_bool(config_obj &owner, bool def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
962 {
963 val = def_val;
964 pend_val = val;
965 }
966
974 config_bool(bool def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
975 {
976 val = def_val;
977 pend_val = val;
978 }
980
981 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
982 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
983
984 // Assignemt operators
985
997 operator bool() const { return val; };
998
1004 config_bool &operator=(const bool v)
1005 {
1006 pend_val = val = v;
1007 return *this;
1008 };
1009
1016 {
1017 pend_val = val = cb.val;
1018 return *this;
1019 };
1020
1027 {
1028 pend_val = val = (i != 0);
1029 return *this;
1030 };
1031
1032 // This is named so error messages make sense to user, old name was GetExtent
1033 virtual int Missing_ConfigEndMarker(void *&startp)
1034 {
1035 startp = this;
1036 return sizeof(*this);
1037 };
1038
1044 virtual void GetTypeValue(NBString &s) { s = "boolean"; };
1045};
1046
1055{
1056 protected:
1057 NBString val;
1058 NBString pend_val;
1059 NBString enum_list;
1060
1061 public:
1069 virtual void GetTextValue(NBString &s);
1070// {
1071// s = "\"";
1072// s += val;
1073// s += "\"";
1074// };
1075
1077
1088 config_string(config_obj &owner, NBString def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1089 {
1090 val = def_val;
1091 pend_val = val;
1092 }
1093
1103 config_string(NBString def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1104 {
1105 pName = name;
1106 val = def_val;
1107 pend_val = val;
1108 }
1109
1120 config_string(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1121 {
1122 val = def_val;
1123 pend_val = val;
1124 }
1125
1135 config_string(const char *def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1136 {
1137 val = def_val;
1138 pend_val = val;
1139 }
1140
1141 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
1142 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
1143
1150 void SetEnumList(NBString s) { enum_list = s; };
1151
1152 // Assignment Operators
1153
1159 operator NBString() const { return val; };
1160
1166 config_string &operator=(const char *p)
1167 {
1168 pend_val = val = p;
1169 return *this;
1170 };
1171
1178 {
1179 pend_val = val = s;
1180 return *this;
1181 };
1182
1189 {
1190 pend_val = val = ci.val;
1191 return *this;
1192 };
1193
1194 // This is named so error messages make sense to user, old name was GetExtent
1195 virtual int Missing_ConfigEndMarker(void *&startp)
1196 {
1197 startp = this;
1198 return sizeof(*this);
1199 };
1200
1206 inline const char *c_str() const { return val.c_str(); };
1207
1213 inline size_t length() const { return val.length(); };
1214
1222 inline const char &operator[](size_t pos) const { return val[pos]; };
1223
1231 virtual void GetTypeValue(NBString &s) { s = "string"; };
1232
1233 virtual void ExtendedSchema(int fd, int indent, bool pretty);
1234
1235 /* *
1236 * @brief Perform a string interpolation and place the finished interpolation
1237 * in the Destination string
1238 *
1239 * @param dest Destination string
1240 *
1241 * @returns Whether the interpolation was successful
1242 */
1243 bool Interpolate(NBString &dest)
1244 {
1245 return val.Interpolate(dest);
1246 }
1247
1248 friend class config_pass;
1249 friend class config_localname;
1250 friend class config_chooser;
1251 friend class config_localname;
1252};
1253
1264{
1265 public:
1276 config_pass(config_obj &owner, NBString def_val, const char *name, const char *desc = NULL)
1277 : config_string(owner, def_val, name, desc){};
1278
1288 config_pass(NBString def_val, const char *name, const char *desc = NULL) : config_string(def_val, name, desc){};
1289
1300 config_pass(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL)
1301 : config_string(owner, def_val, name, desc){};
1302
1312 config_pass(const char *def_val, const char *name, const char *desc = NULL) : config_string(def_val, name, desc){};
1313
1315
1323 virtual void GetTextValue(NBString &s);
1324
1332 virtual void GetRawValue(NBString &s);
1333
1334 virtual void CommitTestedValue(uint32_t permission_mask);
1335
1336 // Add help pop-ups for web page display
1337 virtual void ExtendedSchema(int fd, int indent, bool pretty)
1338 {
1339 config_string::ExtendedSchema(fd, indent, pretty);
1340 DoSchemaLine(fd, "format", "password", indent, pretty);
1341 };
1342
1348 operator NBString() const { return val; };
1349
1355 config_pass &operator=(const char *p)
1356 {
1357 pend_val = val = p;
1358 return *this;
1359 };
1360
1367 {
1368 pend_val = val = s;
1369 return *this;
1370 };
1371
1378 {
1379 pend_val = val = ci.val;
1380 return *this;
1381 };
1382
1389 {
1390 pend_val = val = ci.val;
1391 return *this;
1392 };
1393};
1394
1404{
1405 IPADDR4 val;
1406 IPADDR4 pend_val;
1407
1408 public:
1417 virtual void GetTextValue(NBString &s) { s.siprintf("\"%hI\"", val); };
1418
1429 config_IPADDR4(config_obj &owner, IPADDR4 def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1430 {
1431 val = def_val;
1432 pend_val = val;
1433 }
1434
1444 config_IPADDR4(IPADDR4 def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1445 {
1446 val = def_val;
1447 pend_val = val;
1448 }
1449
1451
1462 config_IPADDR4(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1463 {
1464 IPADDR4 i4;
1465 i4.SetFromAscii(def_val);
1466 val = i4;
1467 pend_val = val;
1468 }
1469
1479 config_IPADDR4(const char *def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1480 {
1481 IPADDR4 i4;
1482 i4.SetFromAscii(def_val);
1483 val = i4;
1484 pend_val = val;
1485 }
1486
1487 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
1488 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
1489
1490 // Assignment operators
1491
1497 operator IPADDR4() const { return val; };
1498
1506 inline bool IsNull() const { return val.IsNull(); };
1507
1515 inline bool NotNull() const { return !(val.IsNull()); };
1516
1522 inline void SetNull()
1523 {
1524 val.SetNull();
1525 pend_val = val;
1526 };
1527
1534 {
1535 pend_val = val = i4;
1536 return *this;
1537 };
1538
1545 {
1546 pend_val = val = ci.val;
1547 return *this;
1548 };
1549
1550 // This is named so error messages make sense to user, old name was GetExtent
1551 virtual int Missing_ConfigEndMarker(void *&startp)
1552 {
1553 startp = this;
1554 return sizeof(*this);
1555 };
1556
1564 virtual void GetTypeValue(NBString &s) { s = "string"; };
1565
1566 // Add web page help
1567 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv4", indent, pretty); };
1568};
1569
1570#ifdef IPV6
1580{
1581 IPADDR val;
1582 IPADDR pend_val;
1583
1584 public:
1592 virtual void GetTextValue(NBString &s) { s.siprintf("\"%I\"", val); };
1593
1604 config_IPADDR(config_obj &owner, IPADDR def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1605 {
1606 val = def_val;
1607 pend_val = val;
1608 }
1609
1611
1621 config_IPADDR(IPADDR def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1622 {
1623 val = def_val;
1624 pend_val = val;
1625 }
1626
1637 config_IPADDR(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1638 {
1639 IPADDR i6;
1640 i6.SetFromAscii(def_val);
1641 val = i6;
1642 pend_val = val;
1643 }
1644
1654 config_IPADDR(const char *def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1655 {
1656 IPADDR i6;
1657 i6.SetFromAscii(def_val);
1658 val = i6;
1659 pend_val = val;
1660 }
1661
1662 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
1663 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
1664
1670 operator IPADDR() const { return val; };
1671
1679 bool IsNull() const { return val.IsNull(); }
1680
1688 bool NotNull() const { return !(val.IsNull()); }
1689
1693 void SetNull()
1694 {
1695 val.SetNull();
1696 pend_val = val;
1697 }
1698
1705 {
1706 pend_val = val = i6;
1707 return *this;
1708 };
1709
1716 {
1717 pend_val = val = ci.val;
1718 return *this;
1719 };
1720
1721 // This is named so error messages make sense to user, old name was GetExtent
1722 virtual int Missing_ConfigEndMarker(void *&startp)
1723 {
1724 startp = this;
1725 return sizeof(*this);
1726 };
1727
1735 virtual void GetTypeValue(NBString &s) { s = "string"; };
1736
1737 // Add web page help
1738 virtual void ExtendedSchema(int fd, int indent, bool pretty) { DoSchemaLine(fd, "format", "ipv6", indent, pretty); };
1739};
1740#endif
1741
1750{
1751 MACADR val;
1752 MACADR pend_val;
1753
1754 public:
1763 virtual void GetTextValue(NBString &s)
1764 {
1765 s.siprintf("\"%02X:%02X:%02X:%02X:%02X:%02X\"", val.phywadr[0] >> 8, val.phywadr[0] & 0xFF, val.phywadr[1] >> 8,
1766 val.phywadr[1] & 0xFF, val.phywadr[2] >> 8, val.phywadr[2] & 0xFF);
1767 };
1768
1779 config_MACADR(config_obj &owner, MACADR def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1780 {
1781 val = def_val;
1782 pend_val = val;
1783 }
1784
1786
1796 config_MACADR(MACADR def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1797 {
1798 val = def_val;
1799 pend_val = val;
1800 }
1801
1813 config_MACADR(config_obj &owner, const char *def_val, const char *name, const char *desc = NULL) : config_value(owner, name, desc)
1814 {
1815 MACADR ma;
1816 ma = AsciiToMac(def_val);
1817
1818 val = ma;
1819 pend_val = val;
1820 }
1821
1832 config_MACADR(const char *def_val, const char *name, const char *desc = NULL) : config_value(name, desc)
1833 {
1834 MACADR ma;
1835 ma = AsciiToMac(def_val);
1836 val = ma;
1837 pend_val = val;
1838 }
1839
1840 // Assignment Operators
1841
1847 operator MACADR() const { return val; };
1848
1855 {
1856 pend_val = val = ci.val;
1857 return *this;
1858 };
1859
1866 {
1867 pend_val = val = ci;
1868 return *this;
1869 };
1870
1871 MACADR operator+(uint32_t rhs)
1872 { return val + rhs; }
1873
1874 // This is named so error messages make sense to user, old name was GetExtent
1875 virtual int Missing_ConfigEndMarker(void *&startp)
1876 {
1877 startp = this;
1878 return sizeof(*this);
1879 };
1880
1881 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
1882 virtual void CommitTestedValue(uint32_t permission_mask) { val = pend_val; }
1883
1891 virtual void GetTypeValue(NBString &s) { s = "string"; };
1892};
1893
1894// This is named so error messages make sense to user, old name was GetExtent
1895#define ConfigEndMarker \
1896 virtual int Missing_ConfigEndMarker(void *&startp) \
1897 { \
1898 startp = this; \
1899 return sizeof(*this); \
1900 };
1901
1915{
1916 config_string value{"", "Value"};
1917 config_string choices{"", "Choices"};
1918 ConfigEndMarker;
1919
1920 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
1921
1922 public:
1932 config_chooser(config_obj &owner, const char *name, const char *in_value, const char *in_choices, const char *desc = NULL)
1933 : config_obj(owner, name, desc)
1934 {
1935 value = in_value; // Current choice
1936 choices = in_choices; // List of choices
1937 choices.m_Flags |= fConfigReadOnly | fConfigNoSave; // Confiuration flags
1938 value.SetEnumList(choices); // Create enum list from string containing all choices
1939 };
1940
1942
1951 config_chooser(const char *name, const char *in_value, const char *in_choices, const char *desc = NULL) : config_obj(name, desc)
1952 {
1953 value = in_value;
1954 choices = in_choices;
1955 choices.m_Flags |= fConfigReadOnly | fConfigNoSave;
1956 value.SetEnumList(choices);
1957 };
1958
1967 bool IsSelected(const char *choice) { return (choice == value); };
1968
1977 bool IsSelected(const NBString &s) { return (s == value); };
1978
1992 bool IsInChoices(const char *str, size_t strLen)
1993 {
1994 const char *sChoices = choices.c_str();
1995 size_t listLen = choices.length();
1996 size_t index = 0;
1997
1998 if (str == nullptr) { return false; }
1999 if (listLen == 0) { return false; }
2000
2001 while (index < listLen)
2002 {
2003 size_t curVarStart = index;
2004 size_t curVarLength;
2005
2006 // determine the length of the current element in the list of choices
2007 while (sChoices[index] != 0 && sChoices[index] != ',')
2008 {
2009 // index until the end of the current element in the list of choices
2010 index++;
2011 }
2012 curVarLength = index - curVarStart;
2013
2014 if (strncmp(str, &sChoices[curVarStart], (curVarLength > strLen) ? curVarLength : strLen) == 0)
2015 {
2016 return true; // found a match
2017 }
2018 index++; // increment past ','
2019 }
2020
2021 return false;
2022 }
2023
2037 bool IsInChoices(const NBString &str, size_t strLen)
2038 {
2039 const char *sStr = str.c_str();
2040 const char *sChoices = choices.c_str();
2041 size_t length = choices.length();
2042 size_t index = 0;
2043
2044 if (sStr == nullptr) { return false; }
2045 if (length == 0) { return false; }
2046
2047 while (index < length)
2048 {
2049 size_t curVarStart = index;
2050 size_t curVarLength;
2051
2052 // determine the length of the current element in the list of choices
2053 while (sChoices[index] != 0 && sChoices[index] != ',')
2054 {
2055 // index until the end of the current element in the list of choices
2056 index++;
2057 }
2058 curVarLength = index - curVarStart;
2059
2060 if (strncmp(sStr, &sChoices[curVarStart], curVarLength > strLen ? curVarLength : strLen) == 0)
2061 {
2062 return true; // found a match
2063 }
2064 index++; // increment past ','
2065 }
2066
2067 return false;
2068 }
2069
2075 const config_string &GetChoices() { return choices; }
2076
2084 const config_string &SetChoices(const char *in_choices)
2085 {
2086 choices = in_choices;
2087 value.SetEnumList(choices);
2088
2089 return choices;
2090 }
2091
2092 /* @brief Set the list of choices
2093 *
2094 * @param in_choices The list of option choices
2095 *
2096 * @returns A config_string object containing the list of choices
2097 */
2098 const config_string &SetChoices(const NBString &in_choices)
2099 {
2100 choices = in_choices;
2101 value.SetEnumList(choices);
2102
2103 return choices;
2104 }
2105
2106
2112 operator NBString() const { return (NBString)value; };
2113
2120 {
2121 value = p;
2122 return *this;
2123 };
2124
2131 {
2132 value = s;
2133 return *this;
2134 };
2135
2142 {
2143 value = ci.value;
2144 return *this;
2145 };
2146
2147 virtual void GetTypeValue(NBString &s) { s = "object"; };
2148};
2149
2150class reboot_obj : public config_bool
2151{
2152 virtual const char *GetSortNameValue() { return "ZZZc"; };
2153
2154 public:
2155 reboot_obj() : config_bool(root, false, "Reboot", "Cause system reboot on save"){};
2156 void clear()
2157 {
2158 val = false;
2159 pend_val = false;
2160 };
2161
2162 // This is named so error messages make sense to user, old name was GetExtent
2163 virtual int Missing_ConfigEndMarker(void *&startp)
2164 {
2165 startp = this;
2166 return sizeof(*this);
2167 };
2168};
2169
2170class version_obj : public config_int
2171{
2172 bool bNeverSet;
2173 virtual const char *GetSortNameValue() { return "ZZZb"; };
2174
2175 public:
2176 version_obj() : config_int(root, 0, "Version", "Version serial number") { bNeverSet = true; };
2177
2178 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
2179 void inc()
2180 {
2181 val++;
2182 pend_val = val;
2183 };
2184 // This is named so error messages make sense to user
2185 // Old name was GetExtent
2186 virtual int Missing_ConfigEndMarker(void *&startp)
2187 {
2188 startp = this;
2189 return sizeof(*this);
2190 };
2191};
2192
2193class empty_config_obj : public config_obj
2194{
2195 ConfigEndMarker;
2196
2197 public:
2198 empty_config_obj(const char *name, const char *desc = NULL) : config_obj(name, desc){};
2199 empty_config_obj(config_obj &owner, const char *name, const char *desc = NULL) : config_obj(owner, name, desc){};
2200 empty_config_obj(empty_config_obj &&e);
2201};
2202
2203
2204
2205
2206
2207// This class is intended for recovery applications or for devices supporting multiple
2208// application profiles to preserve unused config tree branches across configuration
2209// updates
2210// Ex:
2211// Application A has a config object at 'AppData.AppA', and Application B
2212// has a config object at 'AppData.AppB'. Normally, if Application A were
2213// to update any configuration (whether Application or System related), this
2214// would wipe out any AppB configuration as it is not known of by Application A.
2215// Using a config_preserver_obj, any configuration tree data below it's registration
2216// will be persisted across updates unless explicitly wiped.
2217class config_preserver_obj : public config_obj
2218{
2219 ConfigEndMarker;
2220 ParsedJsonDataSet &pendingTreeData;
2221 ParsedJsonDataSet &treeData;
2222
2223 public:
2224 config_preserver_obj(const char *name, const char *desc = NULL);
2225 config_preserver_obj(config_obj &owner, const char *name, const char *desc = NULL);
2226 config_preserver_obj(config_preserver_obj &&po);
2227
2228
2229 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs);
2230 virtual void CommitTestedValue(uint32_t permission_mask);
2231 virtual void GetTextValue(NBString &s);
2232 virtual void GetRawValue(NBString &s);
2233};
2234
2235extern const char *AppName;
2236extern const char PlatformName[];
2237
2238class SysRecord : public config_obj
2239{
2240 public:
2241 config_report system_platform{PlatformName, "Platform", "Hardware Platform"};
2242 config_report system_app{AppName, "Application", "Application name"};
2243 ConfigEndMarker;
2244
2245 SysRecord(const char *name, const char *desc = NULL) : config_obj(name, desc){};
2246 SysRecord(config_obj &owner, const char *name, const char *desc = NULL) : config_obj(owner, name, desc){};
2247 SysRecord(SysRecord &&sr);
2248};
2249
2250extern SysRecord sys;
2251extern empty_config_obj netif;
2252
2253extern reboot_obj rebooter;
2254extern version_obj config_cur_version;
2255
2256extern const int plat_def_baud;
2257extern const int plat_def_delay;
2258extern const int plat_def_quiet;
2259extern const int plat_def_watchdog_enabled;
2260
2261#include <plat_cfg_types.h>
2262#ifdef PRESERVE_APP_DATA
2263extern config_preserver_obj appdata;
2264#else
2265extern empty_config_obj appdata;
2266#endif
2267
2273
2274class MonitorRecord : public config_obj
2275{
2276 public:
2277 config_int Baud{plat_def_baud, "BootBaud"};
2278 config_uart Uart{plat_def_com, "BootUart"};
2279 config_int BootDelay{plat_def_delay, "BootDelay"};
2280 config_bool Quiet{plat_def_quiet, "BootQuiet"};
2281 config_chooser sercfg_action{"SerialConfig", "DuringBoot", "DuringBoot,AlwaysEnabled,PauseAfterBoot,Disabled"};
2282 config_string abortbootcmd{"A", "Abort"};
2283 config_pass system_user{"", "User"};
2284 config_pass system_pass{"", "Password"};
2285 ConfigEndMarker;
2286
2287 MonitorRecord(const char *name) : config_obj(name, "Boot monitor record")
2288 {
2289 sercfg_action.SetFlag(fConfigNeedReboot);
2290 Baud.SetFlag(fConfigNeedReboot);
2291 Uart.SetFlag(fConfigNeedReboot);
2292 };
2293 MonitorRecord(config_obj &owner, const char *name) : config_obj(owner, name, "Boot Monitor Record")
2294 {
2295 sercfg_action.SetFlag(fConfigNeedReboot);
2296 Baud.SetFlag(fConfigNeedReboot);
2297 Uart.SetFlag(fConfigNeedReboot);
2298 };
2299 MonitorRecord(MonitorRecord &&mr);
2300};
2301extern MonitorRecord monitor_config;
2302#endif
2303
NetBurner Buffers API.
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
void SetFromAscii(const char *cp)
Set the IPv4 address from a character string.
void SetNull()
Set the IP address to null.
Definition nettypes.h:278
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
void SetFromAscii(const char *cp, bool bembed_v4addresses=true)
Set the IP address value of an IPADDR6 object.
void SetNull()
Set the IP address value of an IPADDR6 object to null.
Definition ipv6_addr.h:288
bool IsNull() const
Check if the IP address is null.
Definition ipv6_addr.h:101
Used to store and manipulate MAC addresses.
Definition nettypes.h:69
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
const char * c_str() const
Method to pass a NBString as a constant char *.
size_t length() const
Returns the length of the string.
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
bool NotNull() const
Check if the IP address is not null.
Definition config_obj.h:1515
config_IPADDR4(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1479
config_IPADDR4(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1462
config_IPADDR4(IPADDR4 def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1444
config_IPADDR4(config_obj &owner, IPADDR4 def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1429
config_IPADDR4 & operator=(const config_IPADDR4 &ci)
Copy one config_IPADDR4 object to another.
Definition config_obj.h:1544
bool IsNull() const
Check if the IP address is null.
Definition config_obj.h:1506
void SetNull()
Set the IP address to null.
Definition config_obj.h:1522
config_IPADDR4 & operator=(const IPADDR4 &i4)
Copy an IPADDR4 object value to a config_IPADDR4 object.
Definition config_obj.h:1533
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:1564
virtual void GetTextValue(NBString &s)
Get the object value as a text string with quotations to the specified NBString object.
Definition config_obj.h:1417
Configuration Variable for IPADDR (IPv6) object type.
Definition config_obj.h:1580
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:1735
config_IPADDR & operator=(const config_IPADDR &ci)
Copy one config_IPADDR object to another.
Definition config_obj.h:1715
config_IPADDR & operator=(const IPADDR &i6)
Copy an IPADDR object value to a config_IPADDR object.
Definition config_obj.h:1704
config_IPADDR(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1637
config_IPADDR(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1654
void SetNull()
Set the IP address value of an config_IPADDR object to null.
Definition config_obj.h:1693
config_IPADDR(config_obj &owner, IPADDR def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1604
bool NotNull() const
Check if the IP address is not null.
Definition config_obj.h:1688
virtual void GetTextValue(NBString &s)
Get the object value as a text string with quotations to the specified NBString object.
Definition config_obj.h:1592
config_IPADDR(IPADDR def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1621
bool IsNull() const
Check if the IP address is null.
Definition config_obj.h:1679
Configuration Variable for MACADR object type.
Definition config_obj.h:1750
config_MACADR(config_obj &owner, MACADR def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1779
config_MACADR & operator=(const MACADR &ci)
Copy a MACADR object value to a MACADR object.
Definition config_obj.h:1865
virtual void GetTextValue(NBString &s)
Get the object value as a text string with quotations to the specified NBString object.
Definition config_obj.h:1763
config_MACADR(MACADR def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1796
config_MACADR & operator=(const config_MACADR &ci)
Copy one config_MACADR object to another.
Definition config_obj.h:1854
config_MACADR(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1813
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:1891
config_MACADR(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1832
Boolean Configuration Variable.
Definition config_obj.h:932
config_bool(bool def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:974
config_bool & operator=(const config_bool &cb)
Copy one config_bool object to another.
Definition config_obj.h:1015
config_bool & operator=(const int i)
Assign a config_bool object value to the specified integer value.
Definition config_obj.h:1026
virtual void GetTextValue(NBString &s)
Copy the object value as a text string to the specified NBString object.
Definition config_obj.h:945
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:1044
config_bool & operator=(const bool v)
Assign the config_bool object value to the specified bool value.
Definition config_obj.h:1004
config_bool(config_obj &owner, bool def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:961
Chooser Configuration Variable - Select From a List of Items.
Definition config_obj.h:1915
const config_string & GetChoices()
Get the list of choices.
Definition config_obj.h:2075
const config_string & SetChoices(const char *in_choices)
Set the list of choices.
Definition config_obj.h:2084
virtual void GetTypeValue(NBString &s)
Assigns the object type value to the specified NBString object.
Definition config_obj.h:2147
bool IsSelected(const char *choice)
Check if a particular choice option is selected.
Definition config_obj.h:1967
config_chooser & operator=(const char *p)
Assign the selected list item from a const char* value.
Definition config_obj.h:2119
bool IsSelected(const NBString &s)
Check if a particular choice option is selected.
Definition config_obj.h:1977
config_chooser & operator=(const config_chooser &ci)
Copy one config_chooser object to another.
Definition config_obj.h:2141
config_chooser(const char *name, const char *in_value, const char *in_choices, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1951
bool IsInChoices(const char *str, size_t strLen)
Check if a string is in the list of possible choices. A comparison will continue until a null charact...
Definition config_obj.h:1992
config_chooser(config_obj &owner, const char *name, const char *in_value, const char *in_choices, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1932
bool IsInChoices(const NBString &str, size_t strLen)
Check if a string is in the list of possible choices. A comparison will continue until a null charact...
Definition config_obj.h:2037
config_chooser & operator=(const NBString &s)
Assign the config_string object value from a NBString object.
Definition config_obj.h:2130
Double Float Configuration Variable.
Definition config_obj.h:760
virtual void GetTextValue(NBString &s)
Copy the object value as a text string to the specified NBString object.
Definition config_obj.h:772
virtual void GetTypeValue(NBString &s)
Copy the object type value in the specified NBString object.
Definition config_obj.h:883
config_double(config_obj &owner, double def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:782
config_double(double def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:795
config_double & operator=(const double d)
Assign the config_double object value from a double value.
Definition config_obj.h:852
config_double & operator=(const config_double &ci)
Copy one config_double object to another.
Definition config_obj.h:863
Signed 32-bit Integer Configuration Variable.
Definition config_obj.h:649
config_int & operator=(const int i)
Assign the config_int object value to the specified int value.
Definition config_obj.h:717
virtual void GetTypeValue(NBString &s)
Copy the object type value in the specified NBString object.
Definition config_obj.h:749
config_int(config_obj &owner, int def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:672
virtual void GetTextValue(NBString &s)
Copy the object value to the specified NBString object.
Definition config_obj.h:662
config_int(int def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:685
config_int & operator=(const config_int &ci)
Copy one config_int object to another.
Definition config_obj.h:729
Configure device network name.
Definition config_netobj.h:26
Base class used to create configuration objects.
Definition config_obj.h:277
virtual void GetTypeValue(NBString &s)
Assigns the object type value to the specified NBString object.
Definition config_obj.h:378
config_obj(const char *name, const char *desc)
Object constructor.
Definition config_obj.h:323
virtual void GetTextValue(NBString &s)
Get the object value as a text string to the specified NBString object.
config_obj(config_obj &owner, const char *name, const char *desc)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:300
Password string Configuration Variable.
Definition config_obj.h:1264
config_pass(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1312
config_pass & operator=(const config_string &ci)
Copy a config_string object to a config_pass object.
Definition config_obj.h:1377
config_pass & operator=(const char *p)
Assign the config_pass object value from a const char* value.
Definition config_obj.h:1355
virtual void GetTextValue(NBString &s)
Get the config_pass object value as a text string.
config_pass & operator=(const NBString &s)
Assign the config_pass object value from a NBString object.
Definition config_obj.h:1366
config_pass(NBString def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1288
config_pass(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1300
config_pass & operator=(const config_pass &ci)
Copy one config_pass object to another.
Definition config_obj.h:1388
config_pass(config_obj &owner, NBString def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1276
virtual void GetRawValue(NBString &s)
Copy the raw config_string object value to the NBString object.
String Configuration Variable.
Definition config_obj.h:1055
const char * c_str() const
Returns the object value as a string.
Definition config_obj.h:1206
virtual void GetTextValue(NBString &s)
Get the object value (as a text string with quotations) to the specified NBString object.
config_string(config_obj &owner, NBString def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1088
const char & operator[](size_t pos) const
Return the value of a character in the string.
Definition config_obj.h:1222
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:1231
config_string & operator=(const char *p)
Assign the config_string object value from a const char* string.
Definition config_obj.h:1166
config_string(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:1120
config_string & operator=(const NBString &s)
Assign the config_string object value from a NBString object.
Definition config_obj.h:1177
void SetEnumList(NBString s)
Renders the data used to explain the schema/descriptions for the list of choices.
Definition config_obj.h:1150
config_string(NBString def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1103
config_string & operator=(const config_string &ci)
Copy one config_string object to another.
Definition config_obj.h:1188
config_string(const char *def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:1135
size_t length() const
Returns the string length in bytes.
Definition config_obj.h:1213
Unsigned 32-bit Integer Configuration Variable.
Definition config_obj.h:504
config_uint(uint32_t def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_obj.h:540
virtual void GetTextValue(NBString &s)
Copy the object value to the specified NBString object.
Definition config_obj.h:517
config_uint(config_obj &owner, uint32_t def_val, const char *name, const char *desc=NULL)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:527
config_uint & operator=(const uint32_t i)
Assign the config_uint object value from a uint32_t value.
Definition config_obj.h:571
virtual void GetTypeValue(NBString &s)
Copy the object type value to the specified NBString object.
Definition config_obj.h:602
config_uint & operator=(const config_uint &ci)
Copy one config_uint object to another.
Definition config_obj.h:582
Base class used to create a configuration value.
Definition config_obj.h:446
config_value(config_obj &owner, const char *name, const char *desc)
Object constructor with the parent/owner leaf parameter.
Definition config_obj.h:463
config_value(const char *name, const char *desc)
Object constructor.
Definition config_obj.h:484
const uint32_t fConfigModified
Variable has been modified, but not yet saved.
Definition config_obj.h:73
const uint32_t fConfigNeedReboot
System reboot required for changes to take effect.
Definition config_obj.h:77
const uint32_t fConfigNoObscure
Do not obscure the value.
Definition config_obj.h:76
const uint32_t fConfigValueLeaf
Value is a leaf.
Definition config_obj.h:71
const uint32_t fConfigHidden
Not visible to configuration web server display.
Definition config_obj.h:74
const uint32_t fConfigNoSave
Do not save to flash memory when save functions are called.
Definition config_obj.h:75
const uint32_t fConfigNoReload
Disable reloading value from flash during a call to ReloadFromFlash.
Definition config_obj.h:78
const uint32_t fConfigDetached
Disable reloading value from flash during a call to ReloadFromFlash.
Definition config_obj.h:79
const uint32_t fConfigIsDefault
Value is unchanged from the default, i.e. wes never set.
Definition config_obj.h:80
const uint32_t fConfigReadOnly
Variable is read-only.
Definition config_obj.h:72
void SaveConfigToStorage()
Save configuration to flash storage.
IPADDR6 IPADDR
IPADDR Object Type (either v4 or v6)
Definition nettypes.h:543
class MACADR MACADR
Used to store and manipulate MAC addresses.
NetBurner String Class.