[Zrouter-src] ZRouter.org: push to zconf++ zconf++/zconfig.cc
zrouter-src at zrouter.org
zrouter-src at zrouter.org
Wed Dec 7 23:05:35 UTC 2011
details: /rev/092d0ce69f6c
changeset: 26:092d0ce69f6c
user: "Nicolai Petri <nicolai at petri.dk>"
date: Thu Dec 08 00:05:15 2011 +0100
description:
Slightly change interface model.
Add rough action_add_ip for adding an extra ip to an interface. (no parameter validation at all)
diffstat:
zconf++/zconfig.cc | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diffs (81 lines):
diff -r ec53a4362b71 -r 092d0ce69f6c zconf++/zconfig.cc
--- a/zconf++/zconfig.cc Wed Dec 07 23:59:22 2011 +0100
+++ b/zconf++/zconfig.cc Thu Dec 08 00:05:15 2011 +0100
@@ -43,7 +43,24 @@
Leaf *m_configured;
LeafRef running();
LeafRef configured();
+ Leaf m_dummy;
+ virtual Leaf action_add_ip(const std::string &uri, LeafRef pRequest ) {
+ LeafRef lIf = (*m_running)["networking"]["interfaces"][pRequest["parent"]];
+ lIf["addresses"][pRequest["address"]] = pRequest;
+ return Leaf("Success");
+ }
+ virtual LeafRef describe_dummy() {
+ return m_dummy;
+ }
+
+ Leaf clear_interface(std::string &p_if_name) {
+ return Leaf(true);
+ }
+ Leaf clear_all_interfaces() {
+
+ return Leaf(true);
+ }
Leaf build_default_configuration() {
Leaf l;
// Build dummy default config
@@ -65,12 +82,12 @@
l["networking"]["interfaces"]["em0"]["description"] = "LAN";
l["networking"]["interfaces"]["em0"]["enabled"] = Leaf(true);
l["networking"]["interfaces"]["em0"]["virtual"] = Leaf(false);
- l["networking"]["interfaces"]["em0"]["addresses"][0]["type"] = "ipv4";
- l["networking"]["interfaces"]["em0"]["addresses"][0]["address"] = "192.168.1.100";
- l["networking"]["interfaces"]["em0"]["addresses"][0]["netmask"] = "255.255.255.0";
- l["networking"]["interfaces"]["em0"]["addresses"][1]["type"] = "ipv4";
- l["networking"]["interfaces"]["em0"]["addresses"][1]["address"] = "192.168.1.101";
- l["networking"]["interfaces"]["em0"]["addresses"][1]["netmask"] = "255.255.255.255";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.100"]["type"] = "ipv4";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.100"]["address"] = "192.168.1.100";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.100"]["netmask"] = "255.255.255.0";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.101"]["type"] = "ipv4";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.101"]["address"] = "192.168.1.101";
+ l["networking"]["interfaces"]["em0"]["addresses"]["192.168.1.101"]["netmask"] = "255.255.255.255";
l["networking"]["interfaces"]["em0"]["mtu"] = 1500;
l["networking"]["interfaces"]["em1"]["static"] = Leaf(true);
l["networking"]["interfaces"]["em1"]["name"] = "em1";
@@ -78,9 +95,9 @@
l["networking"]["interfaces"]["em1"]["description"] = "WAN";
l["networking"]["interfaces"]["em1"]["enabled"] = Leaf(true);
l["networking"]["interfaces"]["em1"]["virtual"] = Leaf(false);
- l["networking"]["interfaces"]["em1"]["addresses"][0]["address"] = "172.16.1.2";
- l["networking"]["interfaces"]["em1"]["addresses"][0]["netmask"] = "255.255.255.252";
- l["networking"]["interfaces"]["em1"]["addresses"][0]["type"] = "ipv4";
+ l["networking"]["interfaces"]["em1"]["addresses"]["172.16.1.2"]["address"] = "172.16.1.2";
+ l["networking"]["interfaces"]["em1"]["addresses"]["172.16.1.2"]["netmask"] = "255.255.255.252";
+ l["networking"]["interfaces"]["em1"]["addresses"]["172.16.1.2"]["type"] = "ipv4";
l["networking"]["interfaces"]["em1"]["mtu"] = 1500;
l["networking"]["interfaces"]["em2"]["static"] = Leaf(true);
l["networking"]["interfaces"]["em2"]["name"] = "em2";
@@ -88,8 +105,8 @@
l["networking"]["interfaces"]["em2"]["description"] = "OPT";
l["networking"]["interfaces"]["em2"]["enabled"] = Leaf(true);
l["networking"]["interfaces"]["em2"]["virtual"] = Leaf(false);
- l["networking"]["interfaces"]["em2"]["addresses"][0]["type"] = "ipv4";
- l["networking"]["interfaces"]["em2"]["addresses"][0]["address"] = "DHCP";
+ l["networking"]["interfaces"]["em2"]["addresses"]["DHCP"]["type"] = "ipv4";
+ l["networking"]["interfaces"]["em2"]["addresses"]["DHCP"]["address"] = "DHCP";
l["networking"]["services"]["sshd"]["name"] = "Secure Shell Daemon";
l["networking"]["services"]["sshd"]["enabled"] = Leaf(true);
l["networking"]["services"]["sshd"]["port"] = 22;
@@ -98,6 +115,9 @@
l["networking"]["services"]["ntpd"]["name"] = "Network Time Protocol daemon";
l["networking"]["services"]["ntpd"]["servers"][0] = "1.2.3.4";
l["networking"]["services"]["ntpd"]["servers"][1] = "pool.ntp.org";
+ LeafRef ifs = l["networking"]["interfaces"];
+ ifs["add_ip"] = ACTION_HANDLER(Z_Config_Module, this, action_add_ip, describe_dummy);
+
return l;
}
bool self_init(boost::asio::io_service &io, Model &model) {
More information about the Zrouter-src
mailing list