From 93555482a4b196dc7730e9c88c0c522868a17048 Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Mon, 12 May 2025 09:25:55 +0200 Subject: [PATCH 1/3] Create IDHCPServer.h and remove the old .json file --- interfaces/IDHCPServer.h | 76 ++++++++++++++++++ interfaces/Ids.h | 5 +- jsonrpc/DHCPServer.json | 168 --------------------------------------- 3 files changed, 80 insertions(+), 169 deletions(-) create mode 100644 interfaces/IDHCPServer.h delete mode 100644 jsonrpc/DHCPServer.json diff --git a/interfaces/IDHCPServer.h b/interfaces/IDHCPServer.h new file mode 100644 index 00000000..cd06aefb --- /dev/null +++ b/interfaces/IDHCPServer.h @@ -0,0 +1,76 @@ +/* +* If not stated otherwise in this file or this component's LICENSE file the +* following copyright and licenses apply: +* +* Copyright 2021 Metrological +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "Module.h" + +// @insert + +namespace Thunder { + +namespace Exchange { + + // @json 1.0.0 @text:legacy_lowercase + struct EXTERNAL IDHCPServer : virtual public Core::IUnknown { + + enum { ID = ID_DHCP_SERVER }; + + struct Lease { + string name /* @brief Client identifier (or client hardware address if identifier is absent) (e.g. 00e04c326c56) */; + string ip /* @brief Client IP address (e.g. 192.168.0.10) */; + Core::OptionalType expires /* @brief Client IP expiration time (in ISO8601 format, empty: never expires) (e.g. 2019-05-07T07:20:26Z) */; + }; + + struct Server { + string interface /* @brief Network interface name (e.g. eth0) */; + bool active /* @brief Denotes if server is currently active (e.g. true) */; + Core::OptionalType begin /* @brief IP address pool start (e.g. 192.168.0.10) */; + Core::OptionalType end /* @brief IP address pool end (e.g. 192.168.0.100) */; + Core::OptionalType router /* @brief Router IP address (e.g. 192.168.0.1) */; + Core::OptionalType> leases /* @brief List of IP address leases @restrict:100 */; + }; + + typedef RPC::IIteratorType IServerIterator; + + // @brief Activates a DHCP server + // @param interface: Network interface name (e.g. eth0) + // @retval ERROR_GENERAL: Failed to activate server + // @retval ERROR_UNKNOWN_KEY: Invalid interface name given + // @retval ERROR_ILLEGAL_STATE: Server is already activated + virtual Core::hresult Activate(const string& interface) = 0; + + // @brief Deactivates a DHCP server + // @param interface: Network interface name (e.g. eth0) + // @retval ERROR_GENERAL: Failed to deactivate server + // @retval ERROR_UNKNOWN_KEY: Invalid interface name given + // @retval ERROR_ILLEGAL_STATE: Server is not activated + virtual Core::hresult Deactivate(const string& interface) = 0; + + // @property + // @brief Server status + // @param interface: Server name, if omitted, status of all configured servers is returned (e.g. eth0) + // @param servers: List of configured servers + // @retval ERROR_UNKNOWN_KEY: Invalid server name given + virtual Core::hresult Status(const Core::OptionalType& interface /* @index */, IServerIterator*& servers /* @out @extract */) const = 0; + }; + +} // namespace Exchange + +} diff --git a/interfaces/Ids.h b/interfaces/Ids.h index f367d646..ab00c551 100644 --- a/interfaces/Ids.h +++ b/interfaces/Ids.h @@ -408,7 +408,10 @@ namespace Exchange { ID_MEMORY_MONITOR_NOTIFICATION = ID_MEMORY_MONITOR + 1, ID_IOCONNECTOR = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x580, - ID_IOCONNECTOR_NOTIFICATION = ID_IOCONNECTOR + 1 + ID_IOCONNECTOR_NOTIFICATION = ID_IOCONNECTOR + 1, + + ID_DHCP_SERVER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x590, + ID_DHCP_SERVER_SERVERS = ID_DHCP_SERVER + 1 }; } } diff --git a/jsonrpc/DHCPServer.json b/jsonrpc/DHCPServer.json deleted file mode 100644 index b9949345..00000000 --- a/jsonrpc/DHCPServer.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "$schema": "interface.schema.json", - "jsonrpc": "2.0", - "info": { - "version": "1.0.0", - "title": "DHCP Server API", - "class": "DHCPServer", - "description": "DHCP Server JSON-RPC interface" - }, - "common": { - "$ref": "common.json" - }, - "definitions": - { - "interface": { - "description": "Network interface name", - "type": "string", - "example": "eth0" - }, - "lease": { - "type": "object", - "description": "Lease description", - "properties": { - "name": { - "description": "Client identifier (or client hardware address if identifier is absent)", - "type": "string", - "example": "00e04c326c56" - }, - "ip": { - "description": "Client IP address", - "type": "string", - "example": "192.168.0.10" - }, - "expires": { - "description": "Client IP expiration time (in ISO8601 format, empty: never expires)", - "type": "string", - "example": "2019-05-07T07:20:26Z" - } - }, - "required": [ - "name", - "ip" - ] - }, - "server": { - "type": "object", - "properties": { - "interface": { - "$ref": "#/definitions/interface" - }, - "active": { - "description": "Denotes if server is currently active", - "type": "boolean", - "example": true - }, - "begin": { - "description": "IP address pool start", - "type": "string", - "example": "192.168.0.10" - }, - "end": { - "description": "IP address pool end", - "type": "string", - "example": "192.168.0.100" - }, - "router": { - "description": "Router IP address", - "type": "string", - "example": "192.168.0.1" - }, - "leases": { - "description": "List of IP address leases", - "type": "array", - "items": { - "$ref": "#/definitions/lease" - } - } - }, - "required": [ - "interface", - "active" - ] - } - }, - "methods": { - "activate": { - "summary": "Activates a DHCP server", - "params": { - "type": "object", - "properties": { - "interface": { - "$ref": "#/definitions/interface" - } - } - }, - "result": { - "$ref": "#/common/results/void" - }, - "errors": [ - { - "$ref": "#/common/errors/general", - "description": "Failed to activate server" - }, - { - "$ref": "#/common/errors/unknownkey", - "description": "Invalid interface name given" - }, - { - "$ref": "#/common/errors/illegalstate", - "description": "Server is already activated" - } - ] - }, - "deactivate": { - "summary": "Deactivates a DHCP server", - "params": { - "type": "object", - "properties": { - "interface": { - "$ref": "#/definitions/interface" - } - } - }, - "result": { - "$ref": "#/common/results/void" - }, - "errors": [ - { - "$ref": "#/common/errors/general", - "description": "Failed to deactivate server" - }, - { - "$ref": "#/common/errors/unknownkey", - "description": "Invalid interface name given" - }, - { - "$ref": "#/common/errors/illegalstate", - "description": "Server is not activated" - } - ] - } - }, - "properties": { - "status": { - "summary": "Server status", - "readonly": true, - "index": { - "description": "If omitted, status of all configured servers is returned", - "name": "server", - "example": "eth0" - }, - "params": { - "type": "array", - "description": "List of configured servers", - "items": { - "$ref": "#/definitions/server" - } - }, - "errors": [ - { - "$ref": "#/common/errors/unknownkey", - "description": "Invalid server name given" - } - ] - } - } -} - From 47e9c95a4fd4ab5678cec1474fdadb943b813cd4 Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Mon, 12 May 2025 11:04:03 +0200 Subject: [PATCH 2/3] Adjust the Windows project files --- definitions/Definitions.vcxproj | 17 ++++++++++++++--- definitions/Definitions.vcxproj.filters | 13 ++++--------- interfaces/Interfaces.vcxproj | 1 + interfaces/Interfaces.vcxproj.filters | 1 + 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/definitions/Definitions.vcxproj b/definitions/Definitions.vcxproj index aa5b652b..9b76e251 100644 --- a/definitions/Definitions.vcxproj +++ b/definitions/Definitions.vcxproj @@ -206,6 +206,20 @@ $(ProjectDir)../interfaces/json/JIOConnector.h $(ProjectDir)../interfaces/json/JIOConnector.h + + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + ClInclude + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + ClInclude + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + ClInclude + python "$(ToolPath)\JsonGenerator\JsonGenerator.py" -I "$(FrameworkPath)\" -I "$(ProjectDir)\" --keep-empty --case-convention legacy -c -j "$(ProjectDir)../interfaces" -o "$(ProjectDir)../interfaces/json" "%(FullPath)" --force + ClInclude + $(ProjectDir)../interfaces/json/JDHCPServer.h + $(ProjectDir)../interfaces/json/JDHCPServer.h + $(ProjectDir)../interfaces/json/JDHCPServer.h + $(ProjectDir)../interfaces/json/JDHCPServer.h + $(ProjectDir)../interfaces/json/JMath.h @@ -370,9 +384,6 @@ Document - - Document - Document diff --git a/definitions/Definitions.vcxproj.filters b/definitions/Definitions.vcxproj.filters index 54122634..85e5816a 100644 --- a/definitions/Definitions.vcxproj.filters +++ b/definitions/Definitions.vcxproj.filters @@ -79,9 +79,6 @@ Generated Files - - Generated Files - Generated Files @@ -152,9 +149,6 @@ JSON Files - - JSON Files - JSON Files @@ -230,9 +224,6 @@ JSON Files - - JSON Files - JSON Files @@ -260,6 +251,10 @@ Interface Files + + + Interface Files + diff --git a/interfaces/Interfaces.vcxproj b/interfaces/Interfaces.vcxproj index dd8d5522..ab774abc 100644 --- a/interfaces/Interfaces.vcxproj +++ b/interfaces/Interfaces.vcxproj @@ -112,6 +112,7 @@ + diff --git a/interfaces/Interfaces.vcxproj.filters b/interfaces/Interfaces.vcxproj.filters index 2b6fda8c..23d50169 100644 --- a/interfaces/Interfaces.vcxproj.filters +++ b/interfaces/Interfaces.vcxproj.filters @@ -142,6 +142,7 @@ + From ff7eaa676d9211454cb2dda6e6ae555a687f137c Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Tue, 13 May 2025 12:38:01 +0200 Subject: [PATCH 3/3] Use Core::Time for the expires member of Lease --- interfaces/IDHCPServer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/IDHCPServer.h b/interfaces/IDHCPServer.h index cd06aefb..b871f001 100644 --- a/interfaces/IDHCPServer.h +++ b/interfaces/IDHCPServer.h @@ -35,7 +35,7 @@ namespace Exchange { struct Lease { string name /* @brief Client identifier (or client hardware address if identifier is absent) (e.g. 00e04c326c56) */; string ip /* @brief Client IP address (e.g. 192.168.0.10) */; - Core::OptionalType expires /* @brief Client IP expiration time (in ISO8601 format, empty: never expires) (e.g. 2019-05-07T07:20:26Z) */; + Core::OptionalType expires /* @brief Client IP expiration time (in ISO8601 format, empty: never expires) (e.g. 2019-05-07T07:20:26Z) */; }; struct Server {