diff --git a/.zuul.yaml b/.zuul.yaml index 54d3abe3..d1c54e1e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -110,7 +110,6 @@ fm-api: true fm-rest-api: true fm-mgr: true - guest-client: true nfv-common: true nfv-vim: true nfv-client: true diff --git a/centos_guest_image.inc b/centos_guest_image.inc index 035f2897..99df1589 100644 --- a/centos_guest_image.inc +++ b/centos_guest_image.inc @@ -5,7 +5,3 @@ # # guest extensions # - -# guest-client -guest-client - diff --git a/centos_guest_image_rt.inc b/centos_guest_image_rt.inc index 93efb565..7d24528b 100644 --- a/centos_guest_image_rt.inc +++ b/centos_guest_image_rt.inc @@ -5,7 +5,3 @@ # # guest extensions # - -# guest-client -guest-client - diff --git a/centos_pkg_dirs b/centos_pkg_dirs index 5673ceb5..9a2062c0 100644 --- a/centos_pkg_dirs +++ b/centos_pkg_dirs @@ -1,4 +1,3 @@ nova-api-proxy -guest-client nfv mtce-guest diff --git a/devstack/lib/stx-nfv b/devstack/lib/stx-nfv index 07d0ff74..9fedbce0 100644 --- a/devstack/lib/stx-nfv +++ b/devstack/lib/stx-nfv @@ -4,6 +4,8 @@ # # Copyright (C) 2019 Intel Corporation # +# Copyright (c) 2019 Wind River Systems, Inc. +# # lib/stx-nfv @@ -35,11 +37,6 @@ MTCE_GUEST_DIR=$STXNFV_DIR/mtce-guest MTCE_GUEST_CONF=$STXNFV_SYSCONFDIR/mtc MTCE_GUEST_OCF_DIR=$STXNFV_OCF_ROOT/resource.d/platform -# guest-client -GUEST_CLIENT_VERSION="3.0.1" - -STX_SDK_DEPLOY_DIR=${STX_SDK_DEPLOY_DIR:-/opt/deploy/cgcs_sdk} - # STX_INST_DIR should be a non-root-writable place to install build artifacts STX_INST_DIR=${STX_INST_DIR:-/usr/local} STX_BIN_DIR=$STX_INST_DIR/bin @@ -61,16 +58,6 @@ function cleanup_guest_agent { sudo rm -rf $STXNFV_SYSCONFDIR/logrotate.d/guestAgent.logrotate } -function cleanup_guest_client { - $STX_SUDO rm -rf $STX_INST_DIR/include/guest-client - sudo rm -rf $STX_SDK_DEPLOY_DIR - sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/guest-client.service - sudo rm -rf $STXNFV_SYSCONFDIR/guest-client - $STX_SUDO rm -rf $STX_INST_DIR/bin/guest-client - $STX_SUDO rm -rf $STX_INST_DIR/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION - $STX_SUDO rm -rf $STX_INST_DIR/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION -} - function cleanup_guest_server { sudo rm -rf $MTCE_GUEST_CONF/guestServer.ini $STX_SUDO rm -rf $STX_INST_DIR/bin/guestServer @@ -105,10 +92,6 @@ function cleanup_nfv { cleanup_nova_api_proxy fi - if is_service_enabled guest-client; then - cleanup_guest_client - fi - if is_service_enabled guest-agent || is_service_enabled guest-server; then pushd $MTCE_GUEST_DIR/src make clean @@ -291,36 +274,6 @@ function install_guest_agent { popd } -function install_guest_client { - pushd $STXNFV_DIR/guest-client/guest-client-$GUEST_CLIENT_VERSION - - make clean - make build sysconfdir=$STXNFV_SYSCONFDIR - make sample - make tar ARCHIVE_NAME=wrs-guest-heartbeat-$GUEST_CLIENT_VERSION - find build - - # Sudo Install for guest-client package - $STX_SUDO install -m 755 -d $STX_INST_DIR/include/guest-client - $STX_SUDO install -m 644 -p -D guest_client/src/heartbeat/guest_heartbeat_msg_defs.h $STX_INST_DIR/include/guest-client/guest_heartbeat_msg_defs.h - sudo install -d $STX_SDK_DEPLOY_DIR - sudo install -m 640 build/wrs-guest-heartbeat-$GUEST_CLIENT_VERSION.tgz $STX_SDK_DEPLOY_DIR - - # Systemd services - sudo install -m 644 -p -D guest_client/scripts/guest-client.service $STXNFV_SYSCONFDIR/systemd/system/guest-client.service - sudo install -m 744 -p -D guest_client/scripts/guest-client.systemd $STXNFV_SYSCONFDIR/guest-client/guest-client.systemd - - sudo install -m 750 -d $STXNFV_SYSCONFDIR/guest-client/heartbeat - sudo install -m 755 -p -D guest_client/scripts/guest_heartbeat.conf $STXNFV_SYSCONFDIR/guest-client/heartbeat/guest_heartbeat.conf - sudo install -m 755 -p -D guest_client/scripts/sample_event_handling_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_event_handling_script - sudo install -m 755 -p -D guest_client/scripts/sample_health_check_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_health_check_script - $STX_SUDO install -m 640 -p -D build/guest-client $STX_INST_DIR/bin/guest-client - $STX_SUDO install -m 640 -p -D build/libguest_common_api.so.$GUEST_CLIENT_VERSION $STX_INST_DIR/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION - $STX_SUDO install -m 640 -p -D build/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION $STX_INST_DIR/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION - - popd -} - function install_guest_server { pushd $MTCE_GUEST_DIR/src @@ -354,9 +307,6 @@ function install_nfv { if is_service_enabled nova-api-proxy; then install_nova_api_proxy fi - if is_service_enabled guest-client; then - install_guest_client - fi if is_service_enabled guest-agent || is_service_enabled guest-server; then install_mtce_guest_common diff --git a/devstack/settings b/devstack/settings index 2dce8596..b99733b0 100644 --- a/devstack/settings +++ b/devstack/settings @@ -4,6 +4,8 @@ # # Copyright (C) 2019 Intel Corporation # +# Copyright (c) 2019 Wind River Systems, Inc. +# # Devstack settings @@ -38,10 +40,9 @@ fi # prereqs are not configured? if is_service_enabled guest-agent || is_service_enabled guest-server; then # These guest- services require additional prerequisites - # guest-client: to install guest_heartbeat_api_msg_defs.h # stx-metal: to install mtce_common header files and libraries # fm-common: to install fmcommon library - local req_services="guest-client stx-metal fm-common" + local req_services="stx-metal fm-common" for srv in $req_services;do if ! is_service_enabled "$srv"; then die $LINENO "$srv should be enabled for guestAgent/guestServer" diff --git a/guest-client/LICENSE b/guest-client/LICENSE deleted file mode 100644 index d6456956..00000000 --- a/guest-client/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/guest-client/PKG-INFO b/guest-client/PKG-INFO deleted file mode 100644 index e738a302..00000000 --- a/guest-client/PKG-INFO +++ /dev/null @@ -1,12 +0,0 @@ -Metadata-Version: 1.1 -Name: guest-client -Version: 3.0.1 -Summary: Titanium Cloud Platform Guest-Client Heartbeat Package -Home-page: -Author: Windriver -Author-email: info@windriver.com -License: Apache-2.0 - -Description: Guest-Client with heartbeat functionality. - -Platform: UNKNOWN diff --git a/guest-client/centos/build_srpm.data b/guest-client/centos/build_srpm.data deleted file mode 100644 index 6b9c084e..00000000 --- a/guest-client/centos/build_srpm.data +++ /dev/null @@ -1,3 +0,0 @@ -SRC_DIR="$PKG_BASE/guest-client-3.0.1" -COPY_LIST="$PKG_BASE/LICENSE" -TIS_PATCH_VER=6 diff --git a/guest-client/centos/guest-client.spec b/guest-client/centos/guest-client.spec deleted file mode 100644 index 300deb52..00000000 --- a/guest-client/centos/guest-client.spec +++ /dev/null @@ -1,92 +0,0 @@ -Summary: Guest-Client -Name: guest-client -Version: 3.0.1 -Release: %{tis_patch_ver}%{?_tis_dist} -License: Apache-2.0 -Group: base -Packager: Wind River -URL: unknown - -Source0: %{name}-%{version}.tar.gz - -%define cgcs_sdk_deploy_dir /opt/deploy/cgcs_sdk - -%bcond_without systemd - -%if %{with systemd} -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd -BuildRequires: systemd -%endif - -%package -n %{name}-devel -Summary: Guest-Client - Development files -Group: devel -Provides: guest-client-dev(x86_64) = 3.0.1-r1.0 - -%package -n %{name}-cgts-sdk -Summary: Guest-Client - SDK files -Group: devel -BuildRequires: json-c-devel - -%description -Guest-Client with heartbeat functionality. - -%description -n %{name}-devel -Guest-Client with heartbeat functionality. This package contains symbolic -links, header files, and related items necessary for software development. - -%description -n %{name}-cgts-sdk -Guest-Client SDK files - -%prep -%setup -# Build for guest-client package -make build sysconfdir=%{_sysconfdir} -make sample -make tar ARCHIVE_NAME=wrs-guest-heartbeat-%{version} - -# Install for guest-client package -%install -make install \ - prefix=%{buildroot}/usr \ - includedir=%{buildroot}%{_includedir} \ - SDK_DEPLOY_DIR=%{buildroot}%{cgcs_sdk_deploy_dir} \ - unitdir=%{buildroot}%{_unitdir} \ - sysconfdir=%{buildroot}%{_sysconfdir} - -%files -%defattr(755,root,root,-) -%{_sysconfdir}/guest-client/heartbeat/guest_heartbeat.conf -%{_sysconfdir}/guest-client/heartbeat/sample_event_handling_script -%{_sysconfdir}/guest-client/heartbeat/sample_health_check_script -%defattr(644,root,root,-) -/usr/local/lib/libguest_common_api.so.%{version} -/usr/local/lib/libguest_heartbeat_api.so.%{version} -%attr(744,-,-) /usr/local/bin/guest-client -%if %{with systemd} -%{_unitdir}/guest-client.service -%attr(744,-,-) %{_sysconfdir}/guest-client/guest-client.systemd -%endif - -%preun -%if %{with systemd} -/usr/bin/systemctl stop guest-client >/dev/null 2>&1 -%systemd_preun guest-client.service -systemctl reload -%endif - -%post -%if %{with systemd} -%systemd_post guest-client.service -systemctl reload -/usr/bin/systemctl enable guest-client >/dev/null 2>&1 -%endif - -%files -n guest-client-devel -%defattr(644,root,root,-) -/usr/include/guest-client/guest_heartbeat_msg_defs.h - -%files -n %{name}-cgts-sdk -%{cgcs_sdk_deploy_dir}/wrs-guest-heartbeat-%{version}.tgz diff --git a/guest-client/guest-client-3.0.1/LICENSE b/guest-client/guest-client-3.0.1/LICENSE deleted file mode 100644 index d6456956..00000000 --- a/guest-client/guest-client-3.0.1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/guest-client/guest-client-3.0.1/Makefile b/guest-client/guest-client-3.0.1/Makefile deleted file mode 100755 index 403d1c2f..00000000 --- a/guest-client/guest-client-3.0.1/Makefile +++ /dev/null @@ -1,136 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -VERSION := 3.0.1 - -## Configuration Directory Variables -prefix := /usr -exec_prefix := $(prefix) -sysconfdir := /etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin -unitdir := /usr/lib/systemd/system - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) -PARENT_DIR := $(patsubst %/,%,$(dir $(CURRENT_DIR))) -BUILD_DIR := $(CURRENT_DIR)/build -PACKAGE_DIR := $(BUILD_DIR)/package -PACKAGE_ROOT_DIR := $(PACKAGE_DIR)/rootdir -SDK_DEPLOY_DIR := /opt/deploy/cgcs_sdk - -ARCHIVE_NAME := wrs-guest-client-3.0.1 -ARCHIVE_PKG_NAME := wrs-guest-client-3.0.1_pkg - -INIT_TYPE := sysv - -.PHONY: all build sample clean distclean tar package install uninstall - -all: build - -build: - mkdir -p --mode 755 $(BUILD_DIR) - @(cd guest_client_api; make --no-print-directory build \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - @(cd guest_client; make --no-print-directory build \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - -tar: - @(mkdir -p --mode 755 $(BUILD_DIR)) - @(ln -sf $(CURRENT_DIR) $(BUILD_DIR)/$(ARCHIVE_NAME)) - @(cd $(BUILD_DIR); tar -pczf $(ARCHIVE_NAME).tgz \ - $(ARCHIVE_NAME)/Makefile \ - $(ARCHIVE_NAME)/LICENSE \ - $(ARCHIVE_NAME)/README \ - $(ARCHIVE_NAME)/README.build \ - $(ARCHIVE_NAME)/README.usage \ - $(ARCHIVE_NAME)/TiS-Guest-Heartbeat-Service.pdf \ - $(ARCHIVE_NAME)/packaging \ - $(ARCHIVE_NAME)/include \ - $(ARCHIVE_NAME)/guest_client \ - $(ARCHIVE_NAME)/guest_client_api \ - --exclude $(ARCHIVE_NAME)/guest_client/build \ - --exclude $(ARCHIVE_NAME)/guest_client/src/test \ - --exclude $(ARCHIVE_NAME)/guest_client_api/build \ - --directory $(BUILD_DIR)) - -sample: - mkdir -p --mode 755 $(BUILD_DIR) - @(cd guest_client_api; make --no-print-directory sample \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - @(cd guest_client; make --no-print-directory sample \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - -clean: - @-(cd guest_client_api; make --no-print-directory clean BUILD_DIR=$(BUILD_DIR)) - @-(cd guest_client; make --no-print-directory clean BUILD_DIR=$(BUILD_DIR)) - -distclean: clean - -package: - @(mkdir -p --mode 755 $(PACKAGE_DIR)) - @(mkdir -p --mode 755 $(PACKAGE_ROOT_DIR)) - @(ln -sf $(PACKAGE_DIR) $(BUILD_DIR)/$(ARCHIVE_PKG_NAME)) - @(echo "Packaging guest-client.pkg in $(PACKAGE_DIR)") - @(cp $(CURRENT_DIR)/packaging/guest-client.pkg $(PACKAGE_DIR)/guest-client.pkg) - @(chmod 755 $(PACKAGE_DIR)/guest-client.pkg) - @-(cd guest_client_api; make --no-print-directory package BUILD_DIR=$(BUILD_DIR) \ - PACKAGE_DIR=$(PACKAGE_DIR) prefix=$(prefix) exec_prefix=$(exec_prefix) \ - sysconfdir=$(sysconfdir) includedir=$(includedir) libdir=$(libdir) \ - bindir=$(bindir)) - @-(cd guest_client; make --no-print-directory package BUILD_DIR=$(BUILD_DIR) \ - PACKAGE_DIR=$(PACKAGE_DIR) prefix=$(prefix) exec_prefix=$(exec_prefix) \ - sysconfdir=$(sysconfdir) includedir=$(includedir) libdir=$(libdir) \ - bindir=$(bindir)) - @(cd $(BUILD_DIR); tar -pczf $(ARCHIVE_PKG_NAME).tgz \ - $(ARCHIVE_PKG_NAME)/* --directory $(PACKAGE_DIR)) - -install: - install -m 750 -d $(prefix) - install -m 750 -d $(includedir) - install -m 750 -d $(includedir)/guest-client - install -m 640 -p -D guest_client/src/heartbeat/guest_heartbeat_msg_defs.h $(includedir)/guest-client/guest_heartbeat_msg_defs.h - install -m 755 -d $(SDK_DEPLOY_DIR) - install -m 640 build/wrs-guest-heartbeat-$(VERSION).tgz $(SDK_DEPLOY_DIR) - install -m 644 -p -D guest_client/scripts/guest-client.service $(unitdir)/guest-client.service - install -m 744 -p -D guest_client/scripts/guest-client.systemd $(sysconfdir)/guest-client/guest-client.systemd - install -m 750 -d $(sysconfdir)/guest-client/heartbeat - install -m 755 -p -D guest_client/scripts/guest_heartbeat.conf $(sysconfdir)/guest-client/heartbeat/guest_heartbeat.conf - install -m 755 -p -D guest_client/scripts/sample_event_handling_script $(sysconfdir)/guest-client/heartbeat/sample_event_handling_script - install -m 755 -p -D guest_client/scripts/sample_health_check_script $(sysconfdir)/guest-client/heartbeat/sample_health_check_script - install -m 640 -p -D build/guest-client $(prefix)/local/bin/guest-client - install -m 640 -p -D build/libguest_common_api.so.$(VERSION) $(prefix)/local/lib/libguest_common_api.so.$(VERSION) - install -m 640 -p -D build/libguest_heartbeat_api.so.$(VERSION) $(prefix)/local/lib/libguest_heartbeat_api.so.$(VERSION) - -uninstall: package - @(echo "Uninstalling ...") - @(cd $(PACKAGE_DIR); ./guest-client.pkg uninstall $(INIT_TYPE) $(DESTDIR)) diff --git a/guest-client/guest-client-3.0.1/README b/guest-client/guest-client-3.0.1/README deleted file mode 100755 index 178d7f58..00000000 --- a/guest-client/guest-client-3.0.1/README +++ /dev/null @@ -1,72 +0,0 @@ -Copyright(c) 2013-2017, Wind River Systems, Inc. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Wind River Systems nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------ - -TITANIUM CLOUD - GUEST HEARTBEAT SDK -=========================================== - -DESCRIPTION -=========== - Titanium Cloud Guest-Client provides a heartbeat service to monitor the - health of guest application(s) within a VM running under WindRiver's - Titanium Cloud. Loss of heartbeat will result in a corrective action - being taken against the VM. The heartbeat interval and corrective action - is specified by the VM. - - Titanium Cloud Guest-Client also provides guest application(s) within - a VM running under WindRiver's Titanium Cloud, the ability to receive - notification of and vote to accept or reject actions about to be performed - against the VM. On notifications, the guest application within the VM can - take this opportunity to cleanly shut down or transfer its service to a - peer VM. - - +-------- Virtual Machine ------------------------+ - | | - | VM-Health-Check-Script | - | / | - | / Guest-Application-1 | - Titanium Cloud <----> TiS-Guest-Client <-----> ... | - | \ Guest-Application-8 | - | \ | - | VM-Event-Script | - | | - +-------------------------------------------------+ - - See also: - - README.build - building and installing. - - README.usage - configuring and using the heartbeat, notification - and voting functionality. - - -DELIVERY -======== - Titanium Cloud Guest-Client is delivered as source in a compressed - tarball, wrs-guest-client-v3.0.0.tgz, such that it can be compiled for - the applicable VM Linux distribution. diff --git a/guest-client/guest-client-3.0.1/README.build b/guest-client/guest-client-3.0.1/README.build deleted file mode 100755 index f08a2397..00000000 --- a/guest-client/guest-client-3.0.1/README.build +++ /dev/null @@ -1,296 +0,0 @@ -Copyright(c) 2013-2017, Wind River Systems, Inc. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Wind River Systems nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------ - -This file contains instructions for building and installing the Titanium Cloud -Guest-Client. - - -REQUIREMENTS -============ - The Guest-Client uses the SIGIO functionality of the virtio-serial device - to track host connection up, down and port unplug events. This functionality - requires a kernel version equal to or greater than 2.6.37. - - Compilation: - Linux OS ## Same architecture as the VM. - - gnu make - gcc compiler - - development libraries and headers for: - libc ## C library - rt ## Real-Time library - json-c ## JSON-C library - - VM Runtime: - Linux OS - - runtime libraries: - libc ## C library - rt ## Real-Time library - json-c ## JSON-C library - - -COMPILE -======= - Extract the tarball contents ... - - tar -xvf wrs-guest-heartbeat-v3.0.0.tgz - - To compile, simply run ... - - cd wrs-guest-heartbeat-3.0.0 - make - - This will create a build output directory called "build" in the - wrs-guest-heartbeat-3.0.0 directory. The build output directory - contains the following relevant files: - - libguest_common_api.so.3.0.0 - libguest_heartbeat_api.so.3.0.0 - guest-client - - The libguest_common_api library contains all the common code for - the Guest-Client API libraries. - - The libguest_heartbeat_api library contains the heartbeat, voting, - and notification functionality to interact with the Guest-Client. - A guest application wanting to use this functionality needs to link - in the libguest_common_api and libguest_heartbeat_api libraries. - - The guest-client executable is the Guest-Client daemon that heartbeats - guest applications, and orchestrates votes on and notifications of - pending actions against the VM. The Guest-Client reports the health, - notification and voting results of guest application(s) to the - Titanium Cloud. - - The following variables are available to change the build output - directory and where the system configuration files will be located: - - BUILD_DIR - used to change the build output directory, defaults - to the wrs-guest-heartbeat-3.0.0/build directory. - - prefix - used to construct other variables below, defaults to - the /usr/local directory. - - sysconfdir - directory for configuration files, set to - $(prefix)/etc - - Note: all directory variables must specify an absolute path. - - Usage: make = - - To compile the sample-guest-app, simply run ... - - cd wrs-guest-heartbeat-3.0.0 - make sample - - The sample-guest-app executable is for demonstration purposes only. - It demonstrates how a guest application can use the guest heartbeat - library, libguest_heartbeat_api, to interact with the Guest-Client. - - To compile with a different compiler, simply run ... - - cd wrs-guest-heartbeat-3.0.0 - make CC=/x86_64/buildroot/host/usr/bin/x86_64-buildroot-linux-uclibc-cc - - -PACKAGE -======= - To build a tar package for installation, simply run ... - - cd wrs-guest-heartbeat-3.0.0 - make package - - This will create a tar file called wrs-guest-heartbeat-3.0.0_pkg.tgz - in the wrs-guest-heartbeat-3.0.0 build directory. - - If you changed the build output directory during compile, the BUILD_DIR - variable will have to be specified on the make package. Also if you - specified a different system configuration directory, the sysconfdir - variable, during compile, it will also have to be specified on the - make package. - - The following package configuration variables are available to customize - the package for installation: - - prefix - used to construct other variables below, defaults to - the /usr/local directory. - - exec_prefix - used to construct other executable variables, set to - the 'prefix' variable. - - sysconfdir - directory for configuration files, set to - $(prefix)/etc - - includedir - directory for installing header files, set to - $(prefix)/include - - libdir - directory for installing libraries, set to - $(exec_prefix)/lib - - bindir - directory for installing executable programs, set to - $(exec_prefix)/bin - - Note: all directory variables must specify an absolute path. - - Usage: make package = ... - - -INSTALL -======= - To install from source directories, simply run ... - - cd wrs-guest-heartbeat-3.0.0 - make install - - This will install the default configuration file, include files, - compiled libraries and executable into the following directories: - - guest_heartbeat.conf --> /etc/guest-client/heartbeat - guest_api_types.h --> /usr/include/ - guest_heartbeat_api.h --> /usr/include - libguest_common_api.so.3.0.0 --> /usr/local/lib - libguest_heartbeat_api.so.3.0.0 --> /usr/local/lib - guest-client --> /usr/local/bin - - If you changed the build output directory during compile, the BUILD_DIR - variable will have to be specified on the make install. Also if you - specified a different system configuration directory, the sysconfdir - variable, during compile, it will also have to be specified on the - make install. - - The following install configuration variables are available to customize - installation: - - INIT_TYPE - the type of initialization the OS is using, one of - ( systemd or sysv ). Default to sysv. - - DESTDIR - prepended to each install target file, used to provide - an alternate environment to install in (i.e. support - for staged installs). - - prefix - used to construct other variables below, defaults to - the /usr/local directory. - - exec_prefix - used to construct other executable variables, set to - the 'prefix' variable. - - sysconfdir - directory for configuration files, set to - $(prefix)/etc - - includedir - directory for installing header files, set to - $(prefix)/include - - libdir - directory for installing libraries, set to - $(exec_prefix)/lib - - bindir - directory for installing executable programs, set to - $(exec_prefix)/bin - - unitdir - directory for installing systemd unit files, set by - default to /usr/lib/systemd/system - - SDK_DEPLOY_DIR - directory to store the cgcs sdk file. - - Note: all directory variables must specify an absolute path. - - Usage: make = ... - - - - To install from a tar package file, simply run ... - - tar -xvf wrs-guest-heartbeat-v3.0.0_pkg.tgz - - cd wrs-guest-heartbeat-v3.0.0_pkg - guest-client.pkg install - - This will install the default configuration file, include files, - compiled libraries and executable into the following directories: - - guest_heartbeat.conf --> /usr/local/etc/guest-client/heartbeat - guest_api_types.h --> /usr/local/include - guest_heartbeat_api.h --> /usr/local/include - libguest_common_api.so.3.0.0 --> /usr/local/lib - libguest_heartbeat_api.so.3.0.0 --> /usr/local/lib - guest-client --> /usr/local/bin - - To uninstall: guest-client.pkg uninstall - - The following install configuration variables can be provided to - customize installation: - - INIT_TYPE - the type of initialization the OS is using, one of - ( systemd, sysv ). Optional parameter, defaults to - sysv. - - DESTDIR - prepended to each install target file, used to provide - an alternate environment to install in (i.e. support - for staged installs). Optional parameter. - - Note: all directory variables must specify an absolute path. - - guest-client.pkg [DESTDIR] - - -POST-INSTALL -============ - Running in the VM: - - Test if your platform is using systemd. First look for the systemd - process and then verify that the systemctl tool is available - - ps -ef | grep systemd - systemctl --version - - In this case use the systemd instructions, otherwise the sysv - instructions. - - systemd: - As the root user, - systemctl daemon-reload - systemctl start guest-client.service - systemctl enable guest-client.service - - sysv: - As the root user, - chkconfig --add guest-client - /etc/init.d/guest-client start - - Building into the VM Image: - - systemd: - No post install steps required. - - sysv: - ln -s /etc/init.d/guest-client /etc/rc#.d/K##guest-client - ln -s /etc/init.d/guest-client /etc/rc#.d/S##guest-client - - ... and build the VM image. diff --git a/guest-client/guest-client-3.0.1/README.usage b/guest-client/guest-client-3.0.1/README.usage deleted file mode 100755 index 184d5429..00000000 --- a/guest-client/guest-client-3.0.1/README.usage +++ /dev/null @@ -1,385 +0,0 @@ -Copyright(c) 2013-2017, Wind River Systems, Inc. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Wind River Systems nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------ - -This file contains instructions for using the Titanium Cloud Guest-Client. - - -Titanium Cloud Setup -===================== - The following steps are required to setup the Titanium Cloud to heartbeat - a VM. - - 1. Create and modify a Flavor for your VM. - - A flavor extraspec, 'Guest Heartbeat', is used to indicate - that VMs of this flavor support Titanium Cloud Guest Heartbeat. - The default value is 'False'. - - If support is indicated, then as soon as the VM's Titanium Cloud - Guest-Client daemon registers with the Titanium Cloud Compute - Services on the worker node host, heartbeating will be enabled. - - a) Create a new flavor: - - via dashboard ... - - Select 'Admin->Flavors' to bring up the list of flavors - - Select '+ Create Flavor' in the upper right. - - Fill in the fields as desired - - Select 'Create Flavor' - - via command line ... - - nova flavor-create ... - - b) Modify the newly created flavor or an existing flavor: - - via dashboard ... - - Select 'Admin->Flavors' to bring up the list of flavors - - Choose a flavor to modify. - - Select the to go to the Flavor Detail page - - Select the Extra Specs TAB - - Select '+ Create' - - Select 'Guest Heartbeat' from pull-down Extra Spec menu - - Check the 'Guest Heartbeat' checkbox - - Select 'Create' - - via command line ... - - nova flavor-key set sw:wrs:guest:heartbeat=True - - Note: already running instances that were launched with this - flavor are NOT affected. - - 2) Launch a new instance of your VM. - - 3) Verify your VM is running with Guest Heartbeat enabled. - - Log into the VM. - - Guest-Client logs are written to syslog's 'daemon' facility, which - are typically logged by the syslog service to /var/log/daemon.log. - Please refer to syslog for details on log settings in order to - determine location of logged Guest-Client messages. - - Guest-Client logs are easy to identify. The logs always contain the - string 'Guest-Client'. A recursive grep of /var/log is one way to - determine where your syslog is sending the Guest-Client logs. - - LOG=`grep -r -l 'Guest-Client' /var/log` - echo $LOG - - /var/log/daemon.log - - A successful connection can be verified by looking for the - following log. - - grep "Guest-Client" $USER_LOG | grep "heartbeat state change" - - Guest-Client heartbeat state change from enabling to enabled - - -VM Setup -======== - Configuring Guest-Client Initialization/Start Scripts - ----------------------------------------------------- - The Titanium Cloud communicates with the Guest-Client through a character - device. The packaged initialization/startup scripts need to be updated to - specify the character device exposed by QEMU to the VM. - - +-- Virtual Machine ---+ - | | - | | - Titanium Cloud <-------------------> QEMU <------------> Guest-Client | - unix-stream-socket char-device | - | | - +----------------------+ - - The variable that needs updating in the initialization/start scripts is - called GUEST_CLIENT_DEVICE. - - Also the location of the Guest-Client binary needs to be updated in the - initialization/start scripts. The variable that needs updating is called - GUEST_CLIENT. - - - Configuring Guest Heartbeat & Application Health Check - ------------------------------------------------------ - The Guest-Client within your VM will register with the Titanium Cloud - Compute Services on the worker node host. Part of that registration - process is the specification of a heartbeat interval and a corrective - action for a failed/unhealthy VM. The values of heartbeat interval and - corrective action come from the guest_heartbeat.conf file and is located - in /etc/guest-client/heartbeat directory by default. - - Guest heartbeat works on a challenge response model. The Titanium - Server Compute Services on the worker node host will challenge the - Guest-Client daemon with a message each interval. The Guest-Client - must respond prior to the next interval with a message indicating good - health. If the Titanium Cloud Compute Services does not receive a valid - response, or if the response specifies that the VM is in ill health, then - corrective action is taken. - - The mechanism can be extended by allowing additional VM resident application - specific scripts and processes, to register for heartbeating. Each script - or process can specify its own heartbeat interval, and its own corrective - action to be taken against the VM as a whole. On ill health the Guest-Client - reports ill health to the Titanium Cloud Compute Services on the worker node - host on the next challenge, and provoke the corrective action. - - This mechanism allows for detection of a failed or hung QEMU/KVM instance, - or a failure of the OS within the VM to schedule the Guest-Client process - or to route basic IO, or an application level error/failure. - - Configuring the Guest-Client Heartbeat & Application Health Check ... - - The heartbeat interval defaults to every second and can be overridden - by the VM in the guest_heartbeat.conf. - - /etc/guest-client/heartbeat/guest_heartbeat.conf: - ## This specifies the interval between heartbeats in milliseconds between the - ## guest-client heartbeat and the Titanium Cloud Compute Services on the - ## worker node host. - HB_INTERVAL=1000 - - The corrective action defaults to 'reboot' and can be overridden by the - VM in the guest_heartbeat.conf. - - /etc/guest-client/heartbeat/guest_heartbeat.conf: - ## This specifies the corrective action against the VM in the case of a - ## heartbeat failure between the guest-client and Titanium Cloud Compute - ## Services on the worker node host and also when the health script - ## configured below fails. - ## - ## Your options are: - ## "log" Only a log is issued. - ## "reboot" Issue a reboot against this VM. - ## "stop" Issue a stop against this VM. - ## - CORRECTIVE_ACTION="reboot" - - A health check script can be registered to run periodically to verify - the health of the VM. This is specified in the guest_heartbeat.conf. - - /etc/guest-client/heartbeat/guest_heartbeat.conf: - ## The Path to the health check script. This is optional. - ## The script will be called periodically to check for the health of the VM. - ## The health check interval is specified in seconds. - HEALTH_CHECK_INTERVAL=30 - HEALTH_CHECK_SCRIPT="/etc/guest-client/heartbeat/sample_health_check_script" - - - Configuring Guest Notifications and Voting - ------------------------------------------ - The Guest-Client running in the VM can be used as a conduit for - notifications of VM lifecycle events being taken by the Titanium Cloud that - will impact this VM. Reboots, pause/resume and migrations are examples of - the types of events your VM can be notified of. Depending on the event, a - vote on the event maybe required before a notification is sent. Notifications - may precede the event, follow it or both. The full table of events and - notifications is found below. - - Titanium Action Event Name Vote* Pre-notification Post-notification Timeout - --------------- ----------------- ---- ---------------- ----------------- ------- - stop stop yes yes no shutdown - reboot reboot yes yes no shutdown - pause pause yes yes no suspend - unpause unpause no no yes resume - suspend suspend yes yes no suspend - resume resume no no yes resume - resize resize_begin yes yes no suspend - resize_end no no yes resume - live-migrate live_migrate_begin yes yes no suspend - live_migrate_end no no yes resume - cold-migrate cold_migrate_begin yes yes no suspend - cold_migrate_end no no yes resume** - - * voting has its own timeout called 'vote' that is event independent. - ** after VM reboot and reconnection which is subject to the 'restart' timeout. - - Notifications are an opportunity for the VM to take preparatory actions - in anticipation of the forthcoming event, or recovery actions after - the event has completed. A few examples - - A reboot or stop notification might allow the application to stop - accepting transactions and cleanly wrap up existing transactions. - - A 'resume' notification after a suspend might trigger a time - adjustment. - - Pre and post migrate notifications might trigger the application - to de-register and then re-register with a network load balancer. - - If you register a notification handler, it will receive all events. If - an event is not of interest, it should return immediately with a - successful return code. - - A process may only register a single notification handler. However - multiple processes may independently register handlers. Also a script - based handler may be registered via the guest_heartbeat.conf. When - multiple processes and scripts register notification handlers, they - will be run in parallel. - - Notifications are subject to configurable timeouts. Timeouts are - specified by each registered process and in the guest_heartbeat.conf. - The timeouts in the guest_heartbeat.conf govern the maximum time all - registered notification handlers have to complete. - - While pre-notification handlers are running, the event will be delayed. - If the timeout is reached, the event will be allowed to proceed. - - While post-notification handlers are running, or waiting to be run, - the Titanium Cloud will not be able to declare the action complete. - Keep in mind that many events that offer a post notification will - require the VM's Guest-Client to reconnect to the worker host, and - that may be further delayed while the VM is rebooted as in a cold - migration. When post-notification is finally triggered, it is subject - to a timeout as well. If the timeout is reached, the event will be - declared complete. - - NOTE: A post-event notification that follows a reboot, as in the - cold_migrate_end event, is a special case. It will be triggered as - soon as the local heartbeat server reconnects with the worker host, - and likely before any processes have a chance to register a handler. - The only handler guaranteed to see such a notification is a script - directly registered by the Guest-Client itself via guest_heartbeat.conf. - - - In addition to notifications, there is also an opportunity for the VM - to vote on any proposed event. Voting precedes all notifications, - and offers the VM a chance to reject the event the Titanium Cloud wishes - to initiate. If multiple handlers are registered, it only takes one - rejection to abort the event. - - The same handler that handles notifications also handles voting. - - Voting is subject to a configurable timeout. The same timeout applies - regardless of the event. The timeout is specified when the Guest-Client - registers with compute services on the host. The timeout is specified in - the guest_heartbeat.conf file. This timeout governs the maximum time all - registered voting handlers have to complete the vote. - - Any voters that fail to vote within the timeout are assumed to have agreed - with the proposed action. - - Rejecting an event should be the exception, not the rule, reserved for - cases when the VM is handling an exceptionally sensitive operation, - as well as a slow operation that can't complete in the notification timeout. - An example - - an active-standby application deployment (1:1), where the active - rejects a shutdown or pause or ... due to its peer standby is not - ready or synchronized. - - A vote handler should generally not take any action beyond returning its - vote. Just because you vote to accept, doesn't mean all your peers - will also accept (i.e. the event might not happen). Taking an action - against an event that never happens is almost certainly NOT what you want. - Instead save your actions for the notification that follows if no one - rejects. The one exception might be to temporarily block the initiation of - any new task that would cause you to vote to reject an event in the near - future. The theory being that the requester of the event may retry in - the near future. - - The Titanium Cloud is not required to offer a vote. Voting may be - bypassed on certain recovery scenarios. - - Configuring Guest-Client Notification and Voting ... - - ## The overall time to vote in seconds regardless of the event being voted - ## upon. It should reflect the slowest of all expected voters when in a sane - ## and healthy condition, plus some allowance for scheduling and messaging. - VOTE=8 - - ## The overall time to handle a stop or reboot notification in seconds. - ## It should reflect the slowest of all expected notification handlers - ## when in a sane and healthy condition, plus some allowance for scheduling - ## and messaging. - SHUTDOWN_NOTICE=8 - - ## The overall time to handle a pause, suspend or migrate-begin notification - ## in seconds. It should reflect the slowest of all expected notification - ## handlers when in a sane and healthy condition, plus some allowance for - ## scheduling and messaging. - SUSPEND_NOTICE=8 - - ## The overall time to handle an unpause, resume or migrate-end notification - ## in seconds. It should reflect the slowest of all expected notification - ## handlers when in a sane and healthy condition, plus some allowance for - ## scheduling and messaging. It does not include reboot time. - RESUME_NOTICE=13 - - ## The overall time to reboot, up to the point the guest-client heartbeat - ## starts in seconds. Allow for some I/O contention. - RESTART=300 - - ## The Path to the event notification script. This is optional. - ## The script will be called when an action is initiated that will impact - ## the VM. - ## - ## The event handling script is invoked with two parameters: - ## - ## event_handling_script - ## - ## MSG_TYPE is one of: - ## 'revocable' Indicating a vote is called for. Return zero to accept, - ## non-zero to reject. For a rejection, the first line of - ## stdout emitted by the script will be captured and logged - ## logged indicating why the event was rejected. - ## - ## 'irrevocable' Indicating this is a notification only. Take preparatory - ## actions and return zero if successful, or non-zero on - ## failure. For a failure, the first line of stdout - ## emitted by the script will be captured and logged - ## indicating the cause of the failure. - ## - ## EVENT is one of: ( 'stop', 'reboot', 'pause', 'unpause', 'suspend', - ## 'resume', 'live_migrate_begin', - ## 'live_migrate_end', 'cold_migrate_begin', - ## 'cold_migrate_end' ) - ## - EVENT_NOTIFICATION_SCRIPT="/etc/guest-client/heartbeat/sample_event_handling_script" - - -VM Application Setup -==================== - An application running in the VM may wish to register directly for voting - and notifications. See the guest_heartbeat_api.h for more details. A - working example can be found in the guest_client_api source directory in the - sample_guest_app.c file. - - To compile the sample-guest-app run ... - cd wrs-guest-heartbeat-3.0.0 - make sample - - This will create an executable called sample-guest-app in the 'build' - directory. - - When compiling the guest application ... - - include headers: - #include - #include - #include - - link with: - -lguest_common_api -lguest_heartbeat_api diff --git a/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.doc b/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.doc deleted file mode 100644 index 17bf86ca..00000000 Binary files a/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.doc and /dev/null differ diff --git a/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.pdf b/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.pdf deleted file mode 100644 index f2e90b7c..00000000 Binary files a/guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.pdf and /dev/null differ diff --git a/guest-client/guest-client-3.0.1/guest_client/Makefile b/guest-client/guest-client-3.0.1/guest_client/Makefile deleted file mode 100755 index 5bccc9fc..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -## Configuration Directory Variables -prefix := /usr/local -exec_prefix := $(prefix) -sysconfdir := $(prefix)/etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) -BUILD_DIR := $(CURRENT_DIR)/build -CONFIG_DIR := $(sysconfdir)/guest-client/heartbeat -PACKAGE_DIR := $(BUILD_DIR)/package -PACKAGE_ROOT_DIR := $(PACKAGE_DIR)/rootdir - -.PHONY: all build sample clean distclean package - -all: build - -build: - mkdir -p --mode 755 $(BUILD_DIR) - @(cd src; make --no-print-directory build \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - -sample: - @: - -clean: - @-(cd src; make --no-print-directory clean BUILD_DIR=$(BUILD_DIR)) - -distclean: clean - -package: - @(mkdir -p --mode 755 $(PACKAGE_DIR)) - @(echo "Packaging guest-client.init in $(PACKAGE_DIR)") - @(cp $(CURRENT_DIR)/scripts/guest-client.init $(PACKAGE_DIR)/guest-client.init) - @(chmod 755 $(PACKAGE_DIR)/guest-client.init) - @(echo "Packaging guest-client.service in $(PACKAGE_DIR)") - @(cp $(CURRENT_DIR)/scripts/guest-client.service $(PACKAGE_DIR)/guest-client.service) - @(chmod 644 $(PACKAGE_DIR)/guest-client.service) - @(echo "Packaging guest-client.systemd in $(PACKAGE_DIR)") - @(cp $(CURRENT_DIR)/scripts/guest-client.systemd $(PACKAGE_DIR)/guest-client.systemd) - @(mkdir -p --mode 755 $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)) - @(echo "Packaging guest_heartbeat.conf in $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)") - @(cp $(CURRENT_DIR)/scripts/guest_heartbeat.conf $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)/guest_heartbeat.conf) - @(echo "Packaging sample_event_handling_script in $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)") - @(cp $(CURRENT_DIR)/scripts/sample_event_handling_script $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)/sample_event_handling_script) - @(echo "Packaging sample_health_check_script in $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)") - @(cp $(CURRENT_DIR)/scripts/sample_health_check_script $(PACKAGE_ROOT_DIR)/$(CONFIG_DIR)/sample_health_check_script) - @-(cd src; make --no-print-directory package BUILD_DIR=$(BUILD_DIR) \ - PACKAGE_DIR=$(PACKAGE_DIR) prefix=$(prefix) exec_prefix=$(exec_prefix) \ - sysconfdir=$(sysconfdir) includedir=$(includedir) libdir=$(libdir) \ - bindir=$(bindir)) diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.init b/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.init deleted file mode 100755 index f4cc6df0..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.init +++ /dev/null @@ -1,183 +0,0 @@ -#! /bin/sh -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# -# chkconfig: - 96 96 -# -### BEGIN INIT INFO -# Short-Description: Guest-Client -# Provides: guest-client -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Required-Start: -# Required-Stop: -### END INIT INFO - -# Assumes that LSB (Linux Standard Base) scripts are available. On Fedora and -# other Red Hat related distros, the redhat-lsb package is optional. -if [ -f /etc/init.d/functions ] -then - . /etc/init.d/functions -else - . /lib/lsb/init-functions -fi - -# LSB Exit Codes -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess arguments -# 3 - unimplemented feature -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# -# LSB Exit Status Codes -# 0 - program is running or service OK -# 1 - program is dead and /var/run pid file exists -# 2 - program is dead and /var/lock lock file exists -# 3 - program is not running -# 4 - program or service status is unknown -# -RETVAL=0 - -# Update binary location and device to be used, if necessary. -GUEST_CLIENT_NAME="guest-client" -GUEST_CLIENT_PIDFILE="/var/run/${GUEST_CLIENT_NAME}.pid" -GUEST_CLIENT="/usr/bin/${GUEST_CLIENT_NAME}" -GUEST_CLIENT_DEVICE="/dev/virtio-ports/cgcs.heartbeat" - -if [ ! -e "${GUEST_CLIENT}" ] -then - echo "${GUEST_CLIENT} is missing" - exit 5 -fi - -PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin - -case "$1" in - start) - args="" - if [ -n ${GUEST_CLIENT_DEVICE} ] - then - args="--device ${GUEST_CLIENT_DEVICE}" - fi - - echo -n "Starting ${GUEST_CLIENT_NAME}: " - if [ -n "`pidof ${GUEST_CLIENT}`" ] - then - # Something might have started guest-client already. - RETVAL=0 - else - start-stop-daemon --start --background --make-pidfile --pidfile ${GUEST_CLIENT_PIDFILE} --exec ${GUEST_CLIENT} -- ${args} - RETVAL=$? - fi - if [ ${RETVAL} -eq 0 ] - then - echo "OK" - else - echo "FAIL" - RETVAL=1 - fi - ;; - - stop) - echo -n "Stopping ${GUEST_CLIENT_NAME}: " - if [ -n "`pidof ${GUEST_CLIENT}`" ] - then - killproc ${GUEST_CLIENT} - fi - - SHUTDOWN_TIMEOUT=10 - count=0 - while [ ${count} -lt ${SHUTDOWN_TIMEOUT} ] - do - pidof ${GUEST_CLIENT} &> /dev/null - rc=$? - if [ ${rc} -eq 1 ] - then - echo "OK" - break - fi - count=`expr ${count} + 1` - sleep 1 - done - - pidof ${GUEST_CLIENT} &> /dev/null - rc=$? - if [ ${rc} -eq 0 ] - then - echo "FAIL" - RETVAL=1 - fi - - rm -f ${GUEST_CLIENT_PIDFILE} - ;; - - status) - pid=`cat ${GUEST_CLIENT_PIDFILE} 2>/dev/null` - if [ -n "${pid}" ] - then - if ps -p ${pid} &>/dev/null - then - echo "${GUEST_CLIENT_NAME} is running" - RETVAL=0 - else - echo "${GUEST_CLIENT_NAME} is not running but has pid file" - RETVAL=1 - fi - else - echo "${GUEST_CLIENT_NAME} is not running" - RETVAL=3 - fi - ;; - - restart) - $0 stop - sleep 1 - $0 start - ;; - - reload) - pid=`cat ${GUEST_CLIENT_PIDFILE} 2>/dev/null` - if [ -n "${pid}" ] - then - echo "${GUEST_CLIENT_NAME} reload" - kill -HUP ${pid} - fi - ;; - - *) - echo "usage: $0 { start | stop | status | restart | reload }" - ;; -esac - -exit ${RETVAL} diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.service b/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.service deleted file mode 100755 index 837a617f..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.service +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -[Unit] -Description=Titanium Guest-Client -After=network.target - -[Service] -Type=forking -PIDFile=/var/run/guest-client.pid -EnvironmentFile=/etc/guest-client/heartbeat/guest_heartbeat.conf -ExecStart=/etc/guest-client/guest-client.systemd start -ExecStop=/etc/guest-client/guest-client.systemd stop -ExecReload=/etc/guest-client/guest-client.systemd restart -# We want systemd to give guest-client some time to finish gracefully, but -# still want it to kill guest-client after TimeoutStopSec if something went -# wrong during the graceful stop. Normally, systemd sends SIGTERM signal right -# after the ExecStop, which would kill heartbeat. We are sending useless SIGCONT -# here to give guest-client time to finish. -KillSignal=SIGCONT -# Exit code of 6 indicates it is not configured and no restart. -# if /dev/virtio-ports/cgcs.heartbeat is not found, guest-client -# returns 6 on exit. We don't want to keep restarting guest-client -# if it is not configured. -RestartPreventExitStatus=6 -Restart=always -RestartSec=15 - -[Install] -WantedBy=multi-user.target diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.systemd b/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.systemd deleted file mode 100755 index ba688efb..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.systemd +++ /dev/null @@ -1,171 +0,0 @@ -#! /bin/sh -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# Assumes that LSB (Linux Standard Base) scripts are available. On Fedora and -# other Red Hat related distros, the redhat-lsb package is optional. -if [ -f /etc/init.d/functions ] -then - . /etc/init.d/functions -else - . /lib/lsb/init-functions -fi - -# LSB Exit Codes -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess arguments -# 3 - unimplemented feature -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# -# LSB Exit Status Codes -# 0 - program is running or service OK -# 1 - program is dead and /var/run pid file exists -# 2 - program is dead and /var/lock lock file exists -# 3 - program is not running -# 4 - program or service status is unknown -# -RETVAL=0 - -# Update binary location and device to be used, if necessary. -GUEST_CLIENT_NAME="guest-client" -GUEST_CLIENT_PIDFILE="/var/run/${GUEST_CLIENT_NAME}.pid" -GUEST_CLIENT="/usr/local/bin/${GUEST_CLIENT_NAME}" -GUEST_CLIENT_DEVICE="/dev/virtio-ports/cgcs.heartbeat" - -if [ ! -e "${GUEST_CLIENT}" ] -then - echo "${GUEST_CLIENT} is missing" - exit 5 -fi - -PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin - -case "$1" in - start) - args="" - if [ -n ${GUEST_CLIENT_DEVICE} ] - then - args="--device ${GUEST_CLIENT_DEVICE}" - fi - - echo -n "Starting ${GUEST_CLIENT_NAME}: " - if [ -n "`pidof ${GUEST_CLIENT}`" ] - then - # Something might have started guest-client already. - RETVAL=0 - else - start-stop-daemon --start --background --make-pidfile --pidfile ${GUEST_CLIENT_PIDFILE} --exec ${GUEST_CLIENT} -- ${args} - RETVAL=$? - fi - if [ ${RETVAL} -eq 0 ] - then - echo "OK" - else - echo "FAIL" - RETVAL=1 - fi - ;; - - stop) - echo -n "Stopping ${GUEST_CLIENT_NAME}: " - if [ -n "`pidof ${GUEST_CLIENT}`" ] - then - killproc ${GUEST_CLIENT} - fi - - SHUTDOWN_TIMEOUT=10 - count=0 - while [ ${count} -lt ${SHUTDOWN_TIMEOUT} ] - do - pidof ${GUEST_CLIENT} &> /dev/null - rc=$? - if [ ${rc} -eq 1 ] - then - echo "OK" - break - fi - count=`expr ${count} + 1` - sleep 1 - done - - pidof ${GUEST_CLIENT} &> /dev/null - rc=$? - if [ ${rc} -eq 0 ] - then - echo "FAIL" - RETVAL=1 - fi - - rm -f ${GUEST_CLIENT_PIDFILE} - ;; - - status) - pid=`cat ${GUEST_CLIENT_PIDFILE} 2>/dev/null` - if [ -n "${pid}" ] - then - if ps -p ${pid} &>/dev/null - then - echo "${GUEST_CLIENT_NAME} is running" - RETVAL=0 - else - echo "${GUEST_CLIENT_NAME} is not running but has pid file" - RETVAL=1 - fi - else - echo "${GUEST_CLIENT_NAME} is not running" - RETVAL=3 - fi - ;; - - restart) - $0 stop - sleep 1 - $0 start - ;; - - reload) - pid=`cat ${GUEST_CLIENT_PIDFILE} 2>/dev/null` - if [ -n "${pid}" ] - then - echo "${GUEST_CLIENT_NAME} reload" - kill -HUP ${pid} - fi - ;; - - *) - echo "usage: $0 { start | stop | status | restart | reload }" - ;; -esac - -exit ${RETVAL} diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/guest_heartbeat.conf b/guest-client/guest-client-3.0.1/guest_client/scripts/guest_heartbeat.conf deleted file mode 100755 index 48eb41be..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/guest_heartbeat.conf +++ /dev/null @@ -1,116 +0,0 @@ -### -# Copyright (c) <2013-2017>, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# 1) Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2) Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# -# 3) Neither the name of Wind River Systems nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -### - -################################################## -## Heartbeat health check options - -## This specifies the interval between heartbeats in milliseconds between the -## guest-client heartbeat and the Titanium Cloud Compute Services on the -## worker node host. -HB_INTERVAL=1000 - -## This specifies the corrective action against the VM in the case of a -## heartbeat failure between the guest-client and Titanium Cloud Compute -## Services on the worker node host and also when the health script -## configured below fails. -## -## Your options are: -## "log" Only a log is issued. -## "reboot" Issue a reboot against this VM. -## "stop" Issue a stop against this VM. -## -CORRECTIVE_ACTION="reboot" - - -################################################## -## Heartbeat event notification and voting options - -## The overall time to vote in seconds regardless of the event being voted -## upon. It should reflect the slowest of all expected voters when in a sane -## and healthy condition, plus some allowance for scheduling and messaging. -VOTE=8 - -## The overall time to handle a stop or reboot notification in seconds. -## It should reflect the slowest of all expected notification handlers -## when in a sane and healthy condition, plus some allowance for scheduling -## and messaging. -SHUTDOWN_NOTICE=8 - -## The overall time to handle a pause, suspend or migrate-begin notification -## in seconds. It should reflect the slowest of all expected notification -## handlers when in a sane and healthy condition, plus some allowance for -## scheduling and messaging. -SUSPEND_NOTICE=8 - -## The overall time to handle an unpause, resume or migrate-end notification -## in seconds. It should reflect the slowest of all expected notification -## handlers when in a sane and healthy condition, plus some allowance for -## scheduling and messaging. It does not include reboot time. -RESUME_NOTICE=13 - -## The overall time to reboot, up to the point the guest-client heartbeat -## starts in seconds. Allow for some I/O contention. -RESTART=600 - - -################################################## -## The Path to the health check script. This is optional. -## The script will be called periodically to check for the health of the VM. -## The health check interval is specified in seconds. -HEALTH_CHECK_INTERVAL=30 -HEALTH_CHECK_SCRIPT="/etc/guest-client/heartbeat/sample_health_check_script" - - -################################################## -## The Path to the event notification script. This is optional. -## The script will be called when an action is initiated that will impact -## the VM. -## -## The event handling script is invoked with two parameters: -## -## event_handling_script -## -## MSG_TYPE is one of: -## 'revocable' Indicating a vote is called for. Return zero to accept, -## non-zero to reject. For a rejection, the first line of -## stdout emitted by the script will be captured and logged -## logged indicating why the event was rejected. -## -## 'irrevocable' Indicating this is a notification only. Take preparatory -## actions and return zero if successful, or non-zero on -## failure. For a failure, the first line of stdout -## emitted by the script will be captured and logged -## indicating the cause of the failure. -## -## EVENT is one of: ( 'stop', 'reboot', 'pause', 'unpause', 'suspend', -## 'resume', 'live_migrate_begin', -## 'live_migrate_end', 'cold_migrate_begin', -## 'cold_migrate_end' ) -## -EVENT_NOTIFICATION_SCRIPT="/etc/guest-client/heartbeat/sample_event_handling_script" diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/sample_event_handling_script b/guest-client/guest-client-3.0.1/guest_client/scripts/sample_event_handling_script deleted file mode 100755 index 3113999c..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/sample_event_handling_script +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/sh -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -MSG_TYPE=$1 -EVENT=$2 - -FILE="/tmp/event_timeout" -if [ -f $FILE ]; -then - echo "File $FILE exists." - logger "File $FILE exists. Run slowly to trigger timeout" - sleep 300 - logger "$FILE induced delay ends" -else - logger "File $FILE does not exist." -fi - -if [ "$MSG_TYPE" == "revocable" ] -then - # Vote on the proposed action ( 0 == agree, 1 == reject ) - # Take no actions yet. - # If no other parties have rejected the proposed action, an "irrevocable" - # notification will soon follow. - - if [ $EVENT == "stop" ] - then - FILE="/tmp/vote_no_to_stop" - - elif [ "$EVENT" == "reboot" ] - then - FILE="/tmp/vote_no_to_reboot" - - elif [ "$EVENT" == "suspend" ] || [ "$EVENT" == "pause" ] - then - FILE="/tmp/vote_no_to_suspend" - - elif [ "$EVENT" == "live_migrate_begin" ] || [ "$EVENT" == "cold_migrate_begin" ] - then - FILE="/tmp/vote_no_to_migrate" - - elif [ "$EVENT" == "resize_begin" ] - then - FILE="/tmp/vote_no_to_resize" - - elif [ "$EVENT" == "live_migrate_end" ] || [ "$EVENT" == "cold_migrate_end" ] || - [ "$EVENT" == "resize_end" ] || [ "$EVENT" == "unpause" ] || - [ "$EVENT" == "resume" ] - then - logger "Should never be asked to vote on $EVENT" - echo "Should never be asked to vote on $EVENT" - exit 1 - fi - - if [ -f $FILE ]; - then - echo "File $FILE exists." - logger "File $FILE exists." - logger "Vote against $EVENT at this time." - - # Vote no to shutdown. - exit 1 - else - echo "File $FILE does not exist." - logger "File $FILE does not exists." - logger "Vote to allow $EVENT" - - # Vote yes to shutdown. - exit 0 - fi - -elif [ "$MSG_TYPE" == "irrevocable" ] -then - - if [ $EVENT == "stop" ] - then - logger "Notification of pending $EVENT received." - # Place clean shutdown actions here. Idea is to hand off activity and - # cleanly stop the payload application. It is not required to stop the - # kernel, an ACPI power-off event will follow. - - elif [ "$EVENT" == "reboot" ] - then - logger "Notification of pending $EVENT received." - # Place clean shutdown actions here. Idea is to hand off activity and - # cleanly stop the application. It is not required to stop/reboot the - # kernel, an ACPI power-off event will follow, and then a power-on - - elif [ "$EVENT" == "pause" ] || [ "$EVENT" == "suspend" ] - then - logger "Notification of pending $EVENT received." - # This VM will be paused or suspended but not rebooted. - # Hand off activity and cleanly stop the application if required. - - elif [ "$EVENT" == "unpause" ] || [ "$EVENT" == "resume" ] - then - logger "Notification of $EVENT completion received." - # This VM has resumed from a paused or suspended state. - # Restart your application and take activity as required. - - elif [ "$EVENT" == "resize_begin" ] - then - logger "Notification of pending resize received. ($EVENT)" - # This VM will soon be resized. - # Hand off activity and cleanly stop the payload application if required. - - elif [ "$EVENT" == "resize_end" ] - then - logger "Notification of resize complete received." - # This VM has been resized. - # Restart your application and/or re-establish your network connectivity - # as required. - - elif [ "$EVENT" == "live_migrate_begin" ] || [ "$EVENT" == "cold_migrate_begin" ] - then - logger "Notification of pending migration received. ($EVENT)" - # This VM will soon relocate to a different host. - # Network connectivity may change. - # Hand off activity and cleanly stop the payload application if required. - - elif [ "$EVENT" == "live_migrate_end" ] || [ "$EVENT" == "cold_migrate_end" ] - then - logger "Notification of migration complete received." - # This VM has finished relocation to a new host. - # Network connectivity may have changed. - # Restart your application and/or re-establish your network connectivity - # as required. - fi - - sleep 1 - exit 0 - -else - echo "Unknown message type '$MSG_TYPE'" - logger "Unknown message type '$MSG_TYPE'" - sleep 1 - exit -1 -fi diff --git a/guest-client/guest-client-3.0.1/guest_client/scripts/sample_health_check_script b/guest-client/guest-client-3.0.1/guest_client/scripts/sample_health_check_script deleted file mode 100755 index 72924a48..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/scripts/sample_health_check_script +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -FILE="/tmp/unhealthy" -if [ -f $FILE ]; -then - echo "File $FILE exists." - rm -f $FILE - exit 1 -else - echo "File $FILE does not exist." -fi - -exit 0 diff --git a/guest-client/guest-client-3.0.1/guest_client/src/Makefile b/guest-client/guest-client-3.0.1/guest_client/src/Makefile deleted file mode 100755 index 864f52da..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -## Configuration Directory Variables -prefix := /usr/local -exec_prefix := $(prefix) -sysconfdir := $(prefix)/etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) - -ifndef BUILD_DIR -$(error BUILD_DIR undefined) -endif - -PACKAGE_DIR := $(BUILD_DIR)/package -PACKAGE_ROOT_DIR := $(PACKAGE_DIR)/rootdir - -.SUFFIXES: -.SUFFIXES: .c .o - -.PHONY: all build heartbeat clean distclean package - -heartbeat_C_SRCS := $(wildcard $(CURRENT_DIR)/heartbeat/*.c) -heartbeat_C_SRCS := $(subst $(CURRENT_DIR)/heartbeat/,,$(heartbeat_C_SRCS)) -heartbeat_C_OBJS := ${heartbeat_C_SRCS:.c=.o} - -program_NAME := guest-client -program_C_INCLUDES := -I$(CURRENT_DIR) -I$(CURRENT_DIR)/heartbeat -program_C_INCLUDES += -I$(CURRENT_DIR)/../../include -program_C_SRCS := $(wildcard *.c) -program_C_OBJS := ${program_C_SRCS:.c=.o} -program_LDLIBS := -lrt -program_BUILD_OBJS := $(addprefix $(BUILD_DIR)/, $(heartbeat_C_OBJS)) -program_BUILD_OBJS += $(addprefix $(BUILD_DIR)/, $(program_C_OBJS)) - -CFLAGS = -g -O2 -Wall -Werror -Wformat -DSYSCONFDIR=$(sysconfdir) -CFLAGS += -Wformat-security - -all: build - -heartbeat: - @(cd heartbeat; make --no-print-directory build \ - sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - -%.o: %.c - $(CC) $(CFLAGS) $(program_C_INCLUDES) -c $^ -o $(BUILD_DIR)/$@ - -$(program_NAME): heartbeat $(program_C_OBJS) - $(CC) $(CFLAGS) $(program_BUILD_OBJS) $(program_LDLIBS) \ - -o $(BUILD_DIR)/$(program_NAME) -ljson-c - -build: $(program_NAME) - -clean: - @-($(RM) -Rf $(BUILD_DIR)/*) - -distclean: clean - -package: - @(mkdir -p --mode 755 $(PACKAGE_ROOT_DIR)/$(bindir)) - @(echo "Packaging $(program_NAME) in $(PACKAGE_ROOT_DIR)/$(bindir)") - @(cp $(BUILD_DIR)/$(program_NAME) $(PACKAGE_ROOT_DIR)/$(bindir)/$(program_NAME)) - @(chmod 755 $(PACKAGE_ROOT_DIR)/$(bindir)/$(program_NAME)) diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.c deleted file mode 100755 index 557baabd..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_channel.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_unix.h" - -typedef struct { - bool inuse; - bool char_device; - int sock; - char dev_name[GUEST_DEVICE_NAME_MAX_CHAR]; -} GuestChannelT; - -static GuestChannelT _channel[GUEST_MAX_CONNECTIONS]; - -// **************************************************************************** -// Guest Channel - Find Empty -// ========================== -static GuestChannelIdT guest_channel_find_empty( void ) -{ - GuestChannelT* channel = NULL; - - unsigned int channel_id; - for (channel_id=0; GUEST_MAX_CONNECTIONS > channel_id; ++channel_id) - { - channel = &(_channel[channel_id]); - if (!channel->inuse) - return channel_id; - } - - return GUEST_CHANNEL_ID_INVALID; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Find -// ==================== -static GuestChannelT* guest_channel_find( GuestChannelIdT channel_id ) -{ - GuestChannelT* channel = NULL; - - if ((0 <= channel_id)&&(GUEST_MAX_CONNECTIONS > channel_id)) - { - channel = &(_channel[channel_id]); - if (channel->inuse) - return channel; - } - - return NULL; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Send -// ==================== -GuestErrorT guest_channel_send( - GuestChannelIdT channel_id, void* msg, int msg_size ) -{ - GuestChannelT* channel; - ssize_t result; - - channel = guest_channel_find(channel_id); - if (NULL == channel) - { - DPRINTFE("Invalid channel identifier, channel_id=%i.", channel_id); - return GUEST_FAILED; - } - - result = write(channel->sock, msg, msg_size); - if (0 > result) - { - if (ENODEV == errno) - { - DPRINTFI("Channel %i on device %s disconnected.", channel_id, - channel->dev_name); - return GUEST_OKAY; - } else { - DPRINTFE("Failed to write to channel on device %s, error=%s.", - channel->dev_name, strerror(errno)); - return GUEST_FAILED; - } - } - - DPRINTFV("Sent message over channel on device %s.", channel->dev_name); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Receive -// ======================= -GuestErrorT guest_channel_receive( - GuestChannelIdT channel_id, char* msg_buf, int msg_buf_size, - int* msg_size ) -{ - GuestChannelT* channel; - ssize_t result; - - channel = guest_channel_find(channel_id); - if (NULL == channel) - { - DPRINTFE("Invalid channel identifier, channel_id=%i.", channel_id); - return GUEST_FAILED; - } - - result = read(channel->sock, msg_buf, msg_buf_size); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on socket read, error=%s.", strerror(errno)); - return GUEST_INTERRUPTED; - - } else if (ENODEV == errno) { - DPRINTFI("Channel %i on device %s disconnected.", channel_id, - channel->dev_name); - *msg_size = 0; - return GUEST_OKAY; - - } else { - DPRINTFE("Failed to read from socket, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - } else if (0 == result) { - DPRINTFD("No message received from socket."); - *msg_size = 0; - return GUEST_OKAY; - - } else { - DPRINTFV("Received message, msg_size=%i.", result); - *msg_size = result; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Open -// ==================== -GuestErrorT guest_channel_open( char dev_name[], GuestChannelIdT* channel_id ) -{ - int fd; - int result; - struct stat stat_data; - GuestChannelIdT empty_channel_id; - GuestChannelT* channel; - GuestErrorT error; - - empty_channel_id = guest_channel_find_empty(); - if (GUEST_CHANNEL_ID_INVALID == empty_channel_id) - { - DPRINTFE("Allocation of channel failed, no free resources."); - return GUEST_FAILED; - } - - channel = &(_channel[empty_channel_id]); - memset(channel, 0, sizeof(GuestChannelT)); - - result = stat(dev_name, &stat_data); - if (0 > result) - { - int err = errno; - if (err == ENOENT) - { - DPRINTFI("Failed to stat, error=%s.", strerror(err)); - DPRINTFI("%s file does not exist, guest heartbeat not configured.", - dev_name); - return GUEST_NOT_CONFIGURED; - } - else { - DPRINTFE("Failed to stat, error=%s.", strerror(err)); - return GUEST_FAILED; - } - } - - if (S_ISCHR(stat_data.st_mode)) - { - fd = open(dev_name, O_RDWR); - if (0 > fd) - { - DPRINTFE("Failed to open device %s, error=%s.", dev_name, - strerror(errno)); - return GUEST_FAILED; - } - - result = fcntl(fd, F_SETFD, FD_CLOEXEC); - if (0 > result) - { - DPRINTFE("Failed to set to close on exec, error=%s.", - strerror(errno)); - close(fd); - return GUEST_FAILED; - } - - result = fcntl(fd, F_SETOWN, getpid()); - if (0 > result) - { - DPRINTFE("Failed to set socket ownership, error=%s.", - strerror(errno)); - close(fd); - return GUEST_FAILED; - } - - result = fcntl(fd, F_GETFL); - if (0 > result) - { - DPRINTFE("Failed to get socket options, error=%s.", - strerror(errno)); - close(fd); - return GUEST_FAILED; - } - - result = fcntl(fd, F_SETFL, result | O_NONBLOCK | O_ASYNC); - if (0 > result) - { - DPRINTFE("Failed to set socket options, error=%s.", - strerror(errno)); - close(fd); - return GUEST_FAILED; - } - - DPRINTFI("Opened character device %s", dev_name); - - } else { - error = guest_unix_open(&fd); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to open unix socket %s, error=%s.", - dev_name, guest_error_str(error)); - return error; - } - error = guest_unix_connect(fd, dev_name); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to connect unix socket %s, error=%s.", - dev_name, guest_error_str(error)); - close(fd); - return error; - } - - DPRINTFI("Opened unix socket %s", dev_name); - } - - channel->inuse = true; - snprintf(channel->dev_name, sizeof(channel->dev_name), "%s", dev_name); - channel->char_device = S_ISCHR(stat_data.st_mode); - channel->sock = fd; - *channel_id = empty_channel_id; - - DPRINTFD("Opened channel over device %s.", channel->dev_name); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Close -// ===================== -GuestErrorT guest_channel_close( GuestChannelIdT channel_id ) -{ - GuestChannelT* channel; - - channel = guest_channel_find(channel_id); - if (NULL != channel) - { - if (channel->inuse) - { - if (0 <= channel->sock) - close(channel->sock); - - DPRINTFD("Closed channel over device %s.", channel->dev_name); - memset(channel, 0, sizeof(GuestChannelT)); - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Get Selection Object -// ==================================== -int guest_channel_get_selobj( GuestChannelIdT channel_id ) -{ - GuestChannelT *channel; - - channel = guest_channel_find(channel_id); - if (NULL != channel) - return channel->sock; - - return -1; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Initialize -// ========================== -GuestErrorT guest_channel_initialize( void ) -{ - memset(_channel, 0, sizeof(_channel)); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Finalize -// ======================== -GuestErrorT guest_channel_finalize( void ) -{ - memset(_channel, 0, sizeof(_channel)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.h deleted file mode 100755 index a317cea0..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_channel.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_CHANNEL_H__ -#define __GUEST_CHANNEL_H__ - -#include - -#include "guest_limits.h" -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_CHANNEL_ID_INVALID -1 - -typedef int GuestChannelIdT; - -// **************************************************************************** -// Guest Channel - Send -// ==================== -extern GuestErrorT guest_channel_send( - GuestChannelIdT channel_id, void* msg, int msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Receive -// ======================= -extern GuestErrorT guest_channel_receive( - GuestChannelIdT channel_id, char* msg_buf, int msg_buf_size, - int* msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Open -// ==================== -extern GuestErrorT guest_channel_open( - char dev_name[], GuestChannelIdT* channel_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Close -// ===================== -extern GuestErrorT guest_channel_close( GuestChannelIdT channel_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Get Selection Object -// ==================================== -extern int guest_channel_get_selobj( GuestChannelIdT channel_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Initialize -// ========================== -extern GuestErrorT guest_channel_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Channel - Finalize -// ======================== -extern GuestErrorT guest_channel_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_CHANNEL_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.c deleted file mode 100755 index 01ae812a..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_child_death.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" - -#define GUEST_CHILD_DEATH_MAX_DISPATCH 32 - -typedef struct { - bool valid; - pid_t pid; - int exit_code; -} GuestChildDeathInfoT; - -typedef struct { - bool valid; - pid_t pid; - GuestChildDeathCallbackT death_callback; -} GuestChildDeathCallbackInfoT; - -static int _child_death_fd = -1; -static GuestChildDeathCallbackInfoT _callbacks[GUEST_CHILD_PROCESS_MAX]; -static GuestChildDeathInfoT _child_deaths[GUEST_CHILD_PROCESS_MAX]; -static uint64_t _child_death_count = 0; - -// **************************************************************************** -// Guest Child Death - Register -// ============================ -GuestErrorT guest_child_death_register( - pid_t pid, GuestChildDeathCallbackT callback ) -{ - GuestChildDeathCallbackInfoT* callback_info = NULL; - - unsigned int callbacks_i; - for (callbacks_i=0; GUEST_CHILD_PROCESS_MAX > callbacks_i; ++callbacks_i) - { - callback_info = &(_callbacks[callbacks_i]); - - if (callback_info->valid) - { - if (pid == callback_info->pid) - { - callback_info->death_callback = callback; - break; - } - } else { - callback_info->valid = true; - callback_info->pid = pid; - callback_info->death_callback = callback; - break; - } - } - - if (GUEST_CHILD_PROCESS_MAX <= callbacks_i) - { - DPRINTFE("Failed to register child death callback for pid (%i).", - (int) pid); - return GUEST_FAILED; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Deregister -// ============================== -GuestErrorT guest_child_death_deregister( pid_t pid ) -{ - GuestChildDeathCallbackInfoT* callback_info = NULL; - - unsigned int callbacks_i; - for (callbacks_i=0; GUEST_CHILD_PROCESS_MAX > callbacks_i; ++callbacks_i) - { - callback_info = &(_callbacks[callbacks_i]); - - if (!callback_info->valid) - continue; - - if (pid != callback_info->pid) - continue; - - callback_info->valid = 0; - callback_info->pid = 0; - callback_info->death_callback = NULL; - break; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Save -// ======================== -GuestErrorT guest_child_death_save( pid_t pid, int exit_code ) -{ - uint64_t child_death_count = ++_child_death_count; - GuestChildDeathInfoT* info = NULL; - int result; - - result = write(_child_death_fd, &child_death_count, - sizeof(child_death_count)); - if (0 > result) - DPRINTFE("Failed to signal child death, error=%s", strerror(errno)); - - DPRINTFD("Child process (%i) died.", (int) pid); - - unsigned int death_i; - for (death_i=0; GUEST_CHILD_PROCESS_MAX > death_i; ++death_i) - { - info = &(_child_deaths[death_i]); - - if (info->valid) - { - if (pid == info->pid) - { - info->exit_code = exit_code; - break; - } - } else { - info->valid = true; - info->pid = pid; - info->exit_code = exit_code; - break; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Dispatch -// ============================ -static void guest_child_death_dispatch( int selobj ) -{ - static unsigned int _last_entry = 0; - - uint64_t child_death_count; - GuestChildDeathInfoT* info = NULL; - GuestChildDeathCallbackInfoT* callback_info = NULL; - unsigned int num_child_death_dispatched = 0; - int result; - - result = read(_child_death_fd, &child_death_count, sizeof(child_death_count)); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on read, error=%s.", strerror(errno)); - } else { - DPRINTFE("Failed to dispatch, error=%s.", strerror(errno)); - } - } - - unsigned int death_i; - for( death_i=_last_entry; GUEST_CHILD_PROCESS_MAX > death_i; ++death_i ) - { - info = &(_child_deaths[death_i]); - - if (!info->valid) - continue; - - if (0 == info->pid) - continue; - - DPRINTFD("Child process (%i) exited with %i.", (int) info->pid, - info->exit_code); - - unsigned int callbacks_i; - for (callbacks_i=0; GUEST_CHILD_PROCESS_MAX > callbacks_i; ++callbacks_i) - { - callback_info = &(_callbacks[callbacks_i]); - - if (callback_info->valid) - { - if (info->pid == callback_info->pid) - { - if (NULL != callback_info->death_callback) - { - callback_info->death_callback(info->pid, info->exit_code); - callback_info->valid = false; - } - } - } - } - - info->valid = false; - - if (GUEST_CHILD_DEATH_MAX_DISPATCH <= ++num_child_death_dispatched) - DPRINTFD("Maximum child process death dispatches (%i) reached.", - GUEST_CHILD_DEATH_MAX_DISPATCH); - } - - if (GUEST_CHILD_PROCESS_MAX <= death_i) - _last_entry = 0; - else - _last_entry = death_i; - - // Check for outstanding child process deaths to handle. - for (death_i=0; GUEST_CHILD_PROCESS_MAX > death_i; ++death_i) - { - info = &(_child_deaths[death_i]); - - if (!info->valid) - continue; - - if (0 == info->pid) - continue; - - result = write(_child_death_fd, &child_death_count, - sizeof(child_death_count)); - if (0 > result) - DPRINTFE("Failed to signal child process death, error=%s", - strerror(errno)); - break; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Initialize -// ============================== -GuestErrorT guest_child_death_initialize( void ) -{ - GuestSelObjCallbacksT callbacks; - GuestErrorT error; - - _child_death_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (0 > _child_death_fd) - { - DPRINTFE("Failed to open child death file descriptor,error=%s.", - strerror(errno)); - return GUEST_FAILED; - } - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_child_death_dispatch; - - error = guest_selobj_register(_child_death_fd, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object, error=%s.", - guest_error_str(error)); - close(_child_death_fd); - _child_death_fd = -1; - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Finalize -// ============================ -GuestErrorT guest_child_death_finalize( void ) -{ - GuestErrorT error; - - if (0 <= _child_death_fd) - { - error = guest_selobj_deregister(_child_death_fd); - if (GUEST_OKAY != error) - DPRINTFE("Failed to deregister selection object, error=%s.", - guest_error_str(error)); - - close(_child_death_fd); - _child_death_fd = -1; - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.h deleted file mode 100755 index 718a2941..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_CHILD_DEATH_H__ -#define __GUEST_CHILD_DEATH_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_CHILD_FAILED -65536 - -typedef void (*GuestChildDeathCallbackT) (pid_t pid, int exit_code); - -// **************************************************************************** -// Guest Child Death - Register -// ============================ -extern GuestErrorT guest_child_death_register( - pid_t pid, GuestChildDeathCallbackT callback ); -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Deregister -// ============================== -extern GuestErrorT guest_child_death_deregister( pid_t pid ); -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Save -// ======================== -extern GuestErrorT guest_child_death_save( pid_t pid, int exit_code ); -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Initialize -// ============================== -extern GuestErrorT guest_child_death_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Child Death - Finalize -// ============================ -extern GuestErrorT guest_child_death_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_CHILD_DEATH_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_client.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_client.c deleted file mode 100755 index 75c137ea..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_client.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_process.h" - -// **************************************************************************** -// Guest Client - Main -// =================== -int main( int argc, char *argv[], char *envp[] ) -{ - GuestErrorT error; - - error = guest_debug_initialize("Guest-Client"); - if (GUEST_OKAY != error) - { - printf("Debug initialization failed, error=%s.\n", - guest_error_str(error)); - return EXIT_FAILURE; - } - - error = guest_process_main(argc, argv, envp); - if (GUEST_OKAY != error) - { - printf("Process failure, error=%s.\n", guest_error_str(error)); - return error; - } - - error = guest_debug_finalize(); - if (GUEST_OKAY != error) - { - printf("Debug finalization failed, error=%s.\n", - guest_error_str(error)); - } - - return EXIT_SUCCESS; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_config.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_config.c deleted file mode 100755 index 91a63ffa..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_config.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" - -#define GUEST_DEFAULT_COMM_DEVICE "/dev/vport1p1" - -static GuestConfigT _config; - -// **************************************************************************** -// Guest Configuration - Get -// ========================= -GuestConfigT* guest_config_get( void ) -{ - return &_config; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Show Usage -// ================================ -void guest_config_show_usage( void ) -{ - printf("guest-client [ARGS]\n"); - printf(" where ARGS may be any of: \n"); - printf(" --name Override the name of the instance\n"); - printf(" --device Override default communication channel device\n"); - printf("\n"); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Dump -// ========================== -static void guest_config_dump( void ) -{ - DPRINTFI("Guest-Client Configuration:"); - DPRINTFI(" name: %s", _config.name); - DPRINTFI(" device: %s", _config.comm_device); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Parse Arguments -// ===================================== -static GuestErrorT guest_config_parse_args( int argc, char *argv[] ) -{ - unsigned int arg_i; - for (arg_i=1; arg_i < argc; ++arg_i) - { - if (0 == strcmp("--name", argv[arg_i])) - { - arg_i++; - if (arg_i < argc) - snprintf(_config.name, sizeof(_config.name), "%s", argv[arg_i]); - - } else if (0 == strcmp("--device", argv[arg_i])) { - arg_i++; - if (arg_i < argc) - snprintf(_config.comm_device, sizeof(_config.comm_device), - "%s", argv[arg_i]); - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Parse Environment -// ======================================= -static GuestErrorT guest_config_parse_env( char *envp[] ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Initialize -// ================================ -GuestErrorT guest_config_initialize( int argc, char *argv[], char *envp[] ) -{ - char name[GUEST_NAME_MAX_CHAR]; - GuestErrorT error; - int result; - - result = gethostname(name, sizeof(name)); - if (0 > result) - { - DPRINTFE("Failed to get hostname, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - DPRINTFI("hostname=%s.", name); - memset(&_config, 0, sizeof(GuestConfigT)); - snprintf(_config.name, sizeof(_config.name), "%s", name); - snprintf(_config.comm_device, sizeof(_config.comm_device), "%s", - GUEST_DEFAULT_COMM_DEVICE); - - error = guest_config_parse_args(argc, argv); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to parse arguments, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_config_parse_env(envp); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to parse environment, error=%s.", - guest_error_str(error)); - return error; - } - - guest_config_dump(); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Finalize -// ============================== -GuestErrorT guest_config_finalize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_config.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_config.h deleted file mode 100755 index b32a9245..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_config.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_CONFIGURATION_H__ -#define __GUEST_CONFIGURATION_H__ - -#include "guest_limits.h" -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char name[GUEST_NAME_MAX_CHAR]; - char comm_device[GUEST_DEVICE_NAME_MAX_CHAR]; -} GuestConfigT; - -// **************************************************************************** -// Guest Configuration - Get -// ========================= -extern GuestConfigT* guest_config_get( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Show Usage -// ================================ -extern void guest_config_show_usage( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Initialize -// ================================ -extern GuestErrorT guest_config_initialize( - int argc, char *argv[], char *envp[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Configuration - Finalize -// ============================== -extern GuestErrorT guest_config_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_CONFIGURATION_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.c deleted file mode 100755 index 09a3892d..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_debug.h" - -#include -#include -#include - -#include "guest_types.h" - -#define GUEST_DEBUG_WANT_SYSLOG -#ifdef GUEST_DEBUG_WANT_SYSLOG -#include -#endif - -static char _process_name[30]; -static GuestDebugLogLevelT _log_level = GUEST_DEBUG_LOG_LEVEL_INFO; - -// **************************************************************************** -// Guest Debug - Log Level String -// ============================== -const char* guest_debug_log_level_str( GuestDebugLogLevelT level ) -{ - switch (level) { - case GUEST_DEBUG_LOG_LEVEL_ERROR: return "error"; - case GUEST_DEBUG_LOG_LEVEL_INFO: return " info"; - case GUEST_DEBUG_LOG_LEVEL_DEBUG: return "debug"; - case GUEST_DEBUG_LOG_LEVEL_VERBOSE: return " verb"; - default: - return "???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Set Log Level -// =========================== -void guest_debug_set_log_level( GuestDebugLogLevelT level ) -{ - _log_level = level; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Want Log -// ====================== -bool guest_debug_want_log( GuestDebugLogLevelT level ) -{ - return (level <= _log_level); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Log -// ================= -void guest_debug_log( const char* format, ... ) -{ - char time_str[80]; - char date_str[32]; - struct tm t_real; - struct timespec ts_real; - va_list arguments; - char log_data[512]; - - va_start(arguments, format); - vsnprintf(log_data, sizeof(log_data), format, arguments); - va_end(arguments); - - clock_gettime(CLOCK_REALTIME, &ts_real); - - if (NULL == localtime_r(&(ts_real.tv_sec), &t_real)) - { - snprintf( time_str, sizeof(time_str), - "YYYY:MM:DD HH:MM:SS.xxx" ); - } else { - strftime( date_str, sizeof(date_str), "%b %e %H:%M:%S", - &t_real ); - snprintf( time_str, sizeof(time_str), "%s.%03ld", date_str, - ts_real.tv_nsec/1000000 ); - } - -#ifdef GUEST_DEBUG_WANT_SYSLOG - syslog(LOG_INFO, "%s", log_data); -#else - printf("%s %s: %s\n", time_str, _process_name, log_data); -#endif -} -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Initialize -// ======================== -GuestErrorT guest_debug_initialize( char process_name[] ) -{ - _log_level = GUEST_DEBUG_LOG_LEVEL_INFO; - snprintf(_process_name, sizeof(_process_name), "%s", process_name); - -#ifdef GUEST_DEBUG_WANT_SYSLOG - openlog(_process_name, LOG_PID | LOG_NDELAY, LOG_DAEMON); -#endif - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Finalize -// ====================== -GuestErrorT guest_debug_finalize( void ) -{ - _log_level = GUEST_DEBUG_LOG_LEVEL_INFO; - _process_name[0] = '\0'; - -#ifdef GUEST_DEBUG_WANT_SYSLOG - closelog(); -#endif - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.h deleted file mode 100755 index 09a7d99a..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_debug.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_DEBUG_H__ -#define __GUEST_DEBUG_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_DEBUG_LOG_LEVEL_ERROR, - GUEST_DEBUG_LOG_LEVEL_INFO, - GUEST_DEBUG_LOG_LEVEL_DEBUG, - GUEST_DEBUG_LOG_LEVEL_VERBOSE, -} GuestDebugLogLevelT; - -#define DPRINTF(level, format, args...) \ - if (guest_debug_want_log(level)) \ - guest_debug_log("%s: %s(%i): " format, \ - guest_debug_log_level_str(level), \ - __FILE__, __LINE__, ##args) - -#define DPRINTFE(format, args...) \ - DPRINTF(GUEST_DEBUG_LOG_LEVEL_ERROR, format, ##args) -#define DPRINTFI(format, args...) \ - DPRINTF(GUEST_DEBUG_LOG_LEVEL_INFO, format, ##args) -#define DPRINTFD(format, args...) \ - DPRINTF(GUEST_DEBUG_LOG_LEVEL_DEBUG, format, ##args) -#define DPRINTFV(format, args... ) \ - DPRINTF(GUEST_DEBUG_LOG_LEVEL_VERBOSE, format, ##args) - -// **************************************************************************** -// Guest Debug - Log Level String -// ============================== -extern const char* guest_debug_log_level_str( GuestDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Set Log Level -// =========================== -extern void guest_debug_set_log_level( GuestDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Want Log -// ====================== -extern bool guest_debug_want_log( GuestDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Log -// ================= -extern void guest_debug_log( const char* format, ... ); -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Initialize -// ======================== -extern GuestErrorT guest_debug_initialize( char process_name[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Debug - Finalize -// ====================== -extern GuestErrorT guest_debug_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_DEBUG_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_limits.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_limits.h deleted file mode 100755 index 29953aed..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_limits.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_LIMITS_H__ -#define __GUEST_LIMITS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_NAME_MAX_CHAR 64 -#define GUEST_DEVICE_NAME_MAX_CHAR 255 -#define GUEST_MIN_TICK_INTERVAL_IN_MS 25 -#define GUEST_TICK_INTERVAL_IN_MS 300 -#define GUEST_SCHEDULING_MAX_DELAY_IN_MS 800 -#define GUEST_SCHEDULING_DELAY_DEBOUNCE_IN_MS 2000 -#define GUEST_TIMERS_MAX 128 -#define GUEST_MAX_TIMERS_PER_TICK GUEST_TIMERS_MAX / 4 -#define GUEST_SELECT_OBJS_MAX 128 -#define GUEST_MAX_SIGNALS 32 -#define GUEST_MAX_CONNECTIONS 32 -#define GUEST_CHILD_PROCESS_MAX 16 -#define GUEST_APPLICATIONS_MAX 16 -#define GUEST_HEARTBEAT_MIN_INTERVAL_MS 400 - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_LIMITS_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_process.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_process.c deleted file mode 100755 index 4f46fab4..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_process.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_process.h" - -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_signal.h" -#include "guest_config.h" -#include "guest_selobj.h" -#include "guest_timer.h" -#include "guest_channel.h" -#include "guest_stream.h" -#include "guest_unix.h" -#include "guest_script.h" -#include "guest_heartbeat.h" -#include "guest_child_death.h" - -static sig_atomic_t _stay_on = 1; -static sig_atomic_t _reload = 0; -static sig_atomic_t _reap_children = 0; - -// **************************************************************************** -// Guest Process - Reload -// ====================== -static void guest_process_reload( void ) -{ - int result; - - DPRINTFI("Reload signal handled."); - _reload = 0; - - result = access("/tmp/guest_debug_debug", F_OK); - if (0 == result) - { - DPRINTFI("Debug log level set to debug."); - guest_debug_set_log_level(GUEST_DEBUG_LOG_LEVEL_DEBUG); - return; - } - - result = access("/tmp/guest_debug_verbose", F_OK); - if (0 == result) - { - DPRINTFI("Debug log level set to verbose."); - guest_debug_set_log_level(GUEST_DEBUG_LOG_LEVEL_VERBOSE); - return; - } - - DPRINTFI("Debug log level set to info."); - guest_debug_set_log_level(GUEST_DEBUG_LOG_LEVEL_INFO); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Process - Reap Children -// ============================= -static void guest_process_reap_children( void ) -{ - pid_t pid; - int status; - - if (_reap_children) - { - _reap_children = 0; - - while (0 < (pid = waitpid(-1, &status, WNOHANG | WUNTRACED))) - { - if (WIFEXITED(status)) - guest_child_death_save(pid, WEXITSTATUS(status)); - else - guest_child_death_save(pid, GUEST_CHILD_FAILED); - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Process - Signal Handler -// ============================== -static void guest_process_signal_handler( int signum ) -{ - switch (signum) - { - case SIGINT: - case SIGTERM: - case SIGQUIT: - _stay_on = 0; - break; - - case SIGHUP: - _reload = 1; - break; - - case SIGCHLD: - _reap_children = 1; - break; - - case SIGCONT: - DPRINTFD("Ignoring signal SIGCONT (%i).", signum); - break; - - case SIGPIPE: - DPRINTFD("Ignoring signal SIGPIPE (%i).", signum); - break; - - default: - DPRINTFD("Signal (%i) ignored.", signum); - break; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Process - Initialize -// ========================== -static GuestErrorT guest_process_initialize( - int argc, char *argv[], char *envp[] ) -{ - GuestConfigT* config = NULL; - GuestErrorT error; - - error = guest_config_initialize(argc, argv, envp); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize configuration module, error=%s.", - guest_error_str(error)); - guest_config_show_usage(); - return error; - } - - error = guest_selobj_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize selection object module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_timer_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize timer module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_child_death_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize child death module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_unix_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize unix module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_channel_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize channel module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_stream_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize stream module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_script_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize script module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - config = guest_config_get(); - - error = guest_heartbeat_initialize(config->comm_device); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat module, error=%s.", - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Process - Finalize -// ======================== -static GuestErrorT guest_process_finalize( void ) -{ - GuestErrorT error; - - error = guest_heartbeat_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat module, error=%s.", - guest_error_str(error)); - } - - error = guest_script_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize script module, error=%s.", - guest_error_str(error)); - } - - error = guest_stream_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize stream module, error=%s.", - guest_error_str(error)); - } - - error = guest_channel_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize channel module, error=%s.", - guest_error_str(error)); - } - - error = guest_unix_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize unix module, error=%s.", - guest_error_str(error)); - } - - error = guest_child_death_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize child death module, error=%s.", - guest_error_str(error)); - } - - error = guest_timer_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize timer module, error=%s.", - guest_error_str(error)); - } - - error = guest_selobj_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finialize selection object module, error=%s.", - guest_error_str(error)); - } - - error = guest_config_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finialize configuration module, error=%s.", - guest_error_str(error)); - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Process - Main -// ==================== -GuestErrorT guest_process_main( int argc, char *argv[], char *envp[] ) -{ - unsigned int next_interval_in_ms; - GuestErrorT error; - - DPRINTFI("Starting."); - - guest_signal_register_handler(SIGINT, guest_process_signal_handler); - guest_signal_register_handler(SIGTERM, guest_process_signal_handler); - guest_signal_register_handler(SIGQUIT, guest_process_signal_handler); - guest_signal_register_handler(SIGHUP, guest_process_signal_handler); - guest_signal_register_handler(SIGCHLD, guest_process_signal_handler); - guest_signal_register_handler(SIGCONT, guest_process_signal_handler); - guest_signal_register_handler(SIGPIPE, guest_process_signal_handler); - guest_signal_ignore(SIGIO); - - error = guest_process_initialize(argc, argv, envp); - if (GUEST_OKAY != error) - { - if (error != GUEST_NOT_CONFIGURED) - { - DPRINTFE("Failed initialize process restarting in 20 seconds," - "error=%s.", guest_error_str(error)); - sleep(20); - } - else { - DPRINTFI("Application is not configured, will be not restarted," - " exit code=%s", guest_error_str(error)); - } - return error; - } - - DPRINTFI("Started."); - - while (_stay_on) - { - next_interval_in_ms = guest_timer_schedule(); - - error = guest_selobj_dispatch(next_interval_in_ms); - if (GUEST_OKAY != error) - { - DPRINTFE("Selection object dispatch failed, error=%s.", - guest_error_str(error)); - break; - } - - guest_process_reap_children(); - - if (_reload) - guest_process_reload(); - } - - DPRINTFI("Shutting down."); - - error = guest_process_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed finalize process, error=%s.", - guest_error_str(error) ); - } - - DPRINTFI("Shutdown complete."); - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_process.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_process.h deleted file mode 100755 index 0a380d22..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_process.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_PROCESS_H__ -#define __GUEST_PROCESS_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Process - Main -// ==================== -extern GuestErrorT guest_process_main( int argc, char *argv[], char *envp[] ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_PROCESS_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_script.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_script.c deleted file mode 100755 index 2692e6de..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_script.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_script.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" -#include "guest_utils.h" -#include "guest_child_death.h" - -#define GUEST_SCRIPT_SETUP_FAILURE -65535 - -typedef struct { - bool inuse; - int pid; - int fd; - int log_end_ptr; - char log_msg[256]; - GuestScriptIdT script_id; - GuestScriptCallbackT callback; -} GuestScriptDataT; - -static GuestScriptDataT _scripts[GUEST_CHILD_PROCESS_MAX]; - -// **************************************************************************** -// Guest Script - Abort -// ==================== -void guest_script_abort( GuestScriptIdT script_id ) -{ - int result; - GuestScriptDataT* entry; - GuestErrorT error; - - if (GUEST_SCRIPT_ID_INVALID == script_id) - return; - - if (GUEST_CHILD_PROCESS_MAX <= script_id) - return; - - entry = &(_scripts[script_id]); - - if (entry->inuse) - { - if (-1 != entry->pid) - { - error = guest_child_death_deregister(entry->pid); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister for child death %i, error=%s.", - entry->pid, guest_error_str(error)); - } - - result = kill(entry->pid, SIGKILL); - if (0 > result) - { - if (ESRCH == errno) - { - DPRINTFV("Script pid (%i) not running.", entry->pid); - } else { - DPRINTFE("Failed to send kill signal to script pid %i, " - "error=%s.", entry->pid, strerror(errno)); - } - } else { - DPRINTFD("Script pid (%i) killed.", entry->pid); - } - } - - if (-1 != entry->fd) - { - error = guest_selobj_deregister(entry->fd); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister selection object %i, error=%s.", - entry->fd, guest_error_str(error)); - } - - close(entry->fd); - } - - memset(entry, 0, sizeof(GuestScriptDataT)); - entry->pid = -1; - entry->fd = -1; - entry->script_id = GUEST_SCRIPT_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Dispatch -// ======================= -static void guest_script_dispatch( int selobj ) -{ - int bytes_avail; - int result; - GuestScriptDataT* entry; - - unsigned int script_i; - for (script_i=0; GUEST_CHILD_PROCESS_MAX > script_i; ++script_i) - { - entry = &(_scripts[script_i]); - if (entry->inuse) - if (selobj == entry->fd) - break; - } - - if (GUEST_CHILD_PROCESS_MAX <= script_i) - return; - - bytes_avail = sizeof(entry->log_msg) - entry->log_end_ptr; - - result = read(selobj, &(entry->log_msg[entry->log_end_ptr]), bytes_avail); - if (0 > result) - { - if (EINTR == errno) { - DPRINTFD("Interrupted on read, error=%s.", strerror(errno)); - return; - - } else { - DPRINTFE("Failed to read, error=%s.", strerror(errno)); - return; - } - } else if (0 == result) { - DPRINTFD("No message received."); - return; - - } else { - DPRINTFD("Received message, msg_size=%i.", result); - entry->log_end_ptr += result; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Callback -// ======================= -static void guest_script_callback( pid_t pid, int exit_code ) -{ - GuestScriptDataT* entry; - - unsigned int script_i; - for (script_i=0; GUEST_CHILD_PROCESS_MAX > script_i; ++script_i) - { - entry = &(_scripts[script_i]); - if (entry->inuse) - if ((int) pid == entry->pid) - break; - } - - if (GUEST_CHILD_PROCESS_MAX <= script_i) - return; - - DPRINTFD("PID %i exited with %i", (int) pid, exit_code); - - if (NULL != entry->callback) - entry->callback(entry->script_id, exit_code, entry->log_msg); - - guest_script_abort(entry->script_id); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Invoke -// ===================== -GuestErrorT guest_script_invoke( - char script[], char* script_argv[], GuestScriptCallbackT callback, - GuestScriptIdT* script_id ) -{ - int fd[2]; - pid_t pid; - struct stat stat_data; - char* script_name = guest_utils_basename(script); - char* script_exec = script; - int result; - GuestScriptDataT* entry; - GuestSelObjCallbacksT callbacks; - GuestErrorT error; - - *script_id = GUEST_SCRIPT_ID_INVALID; - - unsigned int script_i; - for (script_i=1; GUEST_CHILD_PROCESS_MAX > script_i; ++script_i) - { - entry = &(_scripts[script_i]); - if (!entry->inuse) - break; - } - - if (GUEST_CHILD_PROCESS_MAX <= script_i) - { - DPRINTFE("Failed to allocate script data."); - return GUEST_FAILED; - } - - memset(entry, 0, sizeof(GuestScriptDataT)); - entry->script_id = script_i; - entry->callback = callback; - entry->pid = -1; - entry->fd = -1; - - result = access(script_exec, F_OK | X_OK); - if (0 > result) - { - DPRINTFE("Script %s access failed, error=%s.", script_exec, - strerror(errno)); - return GUEST_FAILED; - } - - result = stat(script_exec, &stat_data); - if (0 > result) - { - DPRINTFE("Script %s stat failed, error=%s.", script_exec, - strerror( errno ) ); - return GUEST_FAILED; - } - - if (0 >= stat_data.st_size) - { - DPRINTFE("Script %s has zero size.", script_exec); - return GUEST_FAILED; - } - - result = pipe(fd); - if (0 > result) - { - DPRINTFE("Script %s pipe creation failed, error=%s.", script_exec, - strerror(errno)); - return GUEST_FAILED; - } - - result = fcntl(fd[0], F_SETFL, O_NONBLOCK); - if (0 > result) - { - DPRINTFE("Script %s pipe failed to make read end non-blocking, " - "error=%s.", script_exec, strerror(errno)); - close(fd[0]); - close(fd[1]); - return GUEST_FAILED; - } - - pid = fork(); - if (0 > pid) - { - DPRINTFE("Failed to fork process for script %s, error=%s.", - script_exec, strerror(errno)); - close(fd[0]); - close(fd[1]); - return GUEST_FAILED; - - } else if (0 == pid) { - // Child process. - struct rlimit file_limits; - - close(fd[0]); // close read end of pipe - - result = setpgid(0, 0); - if (0 > result) - { - DPRINTFE("Failed to set process group id for script %s, " - "error=%s.", script_exec, strerror( errno ) ); - exit(GUEST_SCRIPT_SETUP_FAILURE); - } - - result = getrlimit(RLIMIT_NOFILE, &file_limits); - if (0 > result) - { - DPRINTFE("Failed to get file limits for script %s, error=%s.", - script_exec, strerror(errno)); - exit(GUEST_SCRIPT_SETUP_FAILURE); - } - - unsigned int fd_i; - for (fd_i=0; fd_i < file_limits.rlim_cur; ++fd_i) - if (fd_i != fd[1]) - close(fd_i); - - result = dup2(fd[1], 1); // make stdout into writable end of pipe - if (0 > result) - { - DPRINTFE("Failed to make stdout into writable end of pipe for " - "script %s, error=%s.", script_exec, strerror(errno)); - exit(GUEST_SCRIPT_SETUP_FAILURE); - } - - result = execv(script_exec, (char**) script_argv); - if (0 > result) - DPRINTFE("Failed to exec command for script %s, error=%s.", - script_exec, strerror(errno)); - - exit(GUEST_SCRIPT_SETUP_FAILURE); - - } else { - // Parent process. - close(fd[1]); // close write end of pipe - entry->pid = (int) pid; - entry->fd = fd[0]; - entry->inuse = true; - - DPRINTFD("Child process %i created for script %s, script_id=%i.", - entry->pid, script_name, entry->script_id); - - error = guest_child_death_register(pid, guest_script_callback); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register for child death %i, error=%s.", - entry->pid, guest_error_str(error)); - guest_script_abort(entry->script_id); - return error; - } - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_script_dispatch; - - error = guest_selobj_register(entry->fd, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object %i, error=%s.", - entry->fd, guest_error_str(error)); - guest_script_abort(entry->script_id); - return error; - } - - *script_id = entry->script_id; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Initialize -// ========================= -GuestErrorT guest_script_initialize( void ) -{ - GuestScriptDataT* entry; - - memset(_scripts, 0, sizeof(_scripts)); - - unsigned int script_i; - for (script_i=0; GUEST_CHILD_PROCESS_MAX > script_i; ++script_i) - { - entry = &(_scripts[script_i]); - - entry->pid = -1; - entry->fd = -1; - entry->script_id = GUEST_SCRIPT_ID_INVALID; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Finalize -// ======================= -GuestErrorT guest_script_finalize( void ) -{ - GuestScriptDataT* entry; - - unsigned int script_i; - for (script_i=0; GUEST_CHILD_PROCESS_MAX > script_i; ++script_i) - { - entry = &(_scripts[script_i]); - if (entry->inuse) - guest_script_abort(entry->script_id); - } - - memset(_scripts, 0, sizeof(_scripts)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_script.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_script.h deleted file mode 100755 index e1a74c8e..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_script.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_SCRIPT_H__ -#define __GUEST_SCRIPT_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_SCRIPT_ID_INVALID -1 - -typedef int GuestScriptIdT; - -typedef void (*GuestScriptCallbackT) - (GuestScriptIdT script_id,int exit_code, char* log_msg); - -// **************************************************************************** -// Guest Script - Abort -// ==================== -extern void guest_script_abort( GuestScriptIdT script_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Invoke -// ===================== -extern GuestErrorT guest_script_invoke( - char script[], char* script_argv[], GuestScriptCallbackT callback, - GuestScriptIdT* script_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Initialize -// ========================= -extern GuestErrorT guest_script_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Script - Finalize -// ======================= -extern GuestErrorT guest_script_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_SCRIPT_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.c deleted file mode 100755 index e8ffafa4..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_selobj.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" - -typedef struct { - bool inuse; - int selobj; - GuestSelObjCallbacksT callbacks; -} GuestSelObjEntryT; - -typedef GuestSelObjEntryT GuestSelObjTableT[GUEST_SELECT_OBJS_MAX]; - -static int _num_poll_fds = 0; -static struct pollfd _poll_fds[GUEST_SELECT_OBJS_MAX]; -static GuestSelObjTableT _select_objs; - -// **************************************************************************** -// Guest Selection Object - Find Selection Object -// ============================================== -static GuestSelObjEntryT* guest_selobj_find( int selobj ) -{ - GuestSelObjEntryT* entry; - - unsigned int entry_i; - for (entry_i=0; GUEST_SELECT_OBJS_MAX > entry_i; ++entry_i) - { - entry = &(_select_objs[entry_i]); - if (entry->inuse) - if (selobj == entry->selobj) - return entry; - } - return NULL; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Register -// ================================= -GuestErrorT guest_selobj_register ( - int selobj, GuestSelObjCallbacksT* callbacks ) -{ - GuestSelObjEntryT* entry; - - entry = guest_selobj_find(selobj); - if (NULL == entry) - { - unsigned int entry_i; - for (entry_i=0; GUEST_SELECT_OBJS_MAX > entry_i; ++entry_i) - { - entry = &(_select_objs[entry_i]); - if (!entry->inuse ) - { - entry->inuse = true; - entry->selobj = selobj; - memcpy(&(entry->callbacks), callbacks, - sizeof(GuestSelObjCallbacksT)); - break; - } - } - - // Rebuild polling file descriptors. - _num_poll_fds =0; - - for (entry_i=0; GUEST_SELECT_OBJS_MAX > entry_i; ++entry_i) - { - entry = &(_select_objs[entry_i]); - if (entry->inuse) - { - memset(&_poll_fds[_num_poll_fds], 0, sizeof(struct pollfd)); - - _poll_fds[_num_poll_fds].fd = entry->selobj; - - if (NULL != entry->callbacks.read_callback) - _poll_fds[_num_poll_fds].events |= POLLIN; - - if (NULL != entry->callbacks.write_callback) - _poll_fds[_num_poll_fds].events |= POLLOUT; - - if (NULL != entry->callbacks.hangup_callback) - _poll_fds[_num_poll_fds].events |= POLLHUP; - - ++_num_poll_fds; - } - } - } else { - memcpy(&(entry->callbacks), callbacks, sizeof(GuestSelObjCallbacksT)); - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Deregister -// =================================== -GuestErrorT guest_selobj_deregister( int selobj ) -{ - GuestSelObjEntryT* entry; - - entry = guest_selobj_find(selobj); - if (NULL != entry) - memset(entry, 0, sizeof(GuestSelObjEntryT)); - - // Rebuild polling file descriptors. - _num_poll_fds =0; - - unsigned int entry_i; - for (entry_i=0; GUEST_SELECT_OBJS_MAX > entry_i; ++entry_i) - { - entry = &(_select_objs[entry_i]); - if (entry->inuse) - { - memset(&_poll_fds[_num_poll_fds], 0, sizeof(struct pollfd)); - - _poll_fds[_num_poll_fds].fd = entry->selobj; - - if (NULL != entry->callbacks.read_callback) - _poll_fds[_num_poll_fds].events |= POLLIN; - - if (NULL != entry->callbacks.write_callback) - _poll_fds[_num_poll_fds].events |= POLLOUT; - - if (NULL != entry->callbacks.hangup_callback) - _poll_fds[_num_poll_fds].events |= POLLHUP; - - ++_num_poll_fds; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Dispatch -// ================================= -GuestErrorT guest_selobj_dispatch( unsigned int timeout_in_ms ) -{ - struct pollfd* poll_entry; - GuestSelObjEntryT* entry; - int result; - - result = poll(_poll_fds, _num_poll_fds, timeout_in_ms); - if (0 > result) - { - if (errno == EINTR) - { - DPRINTFD("Interrupted by a signal."); - return GUEST_OKAY; - } else { - DPRINTFE("Select failed, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - } else if (0 == result) { - DPRINTFV("Nothing selected."); - return GUEST_OKAY; - } - - unsigned int entry_i; - for (entry_i=0; _num_poll_fds > entry_i; ++entry_i) - { - poll_entry = &(_poll_fds[entry_i]); - - entry = guest_selobj_find(poll_entry->fd); - if (NULL != entry) - { - if (0 != (poll_entry->revents & POLLIN)) - if (NULL != entry->callbacks.read_callback) - { - DPRINTFD("Read on selection object %i", poll_entry->fd); - entry->callbacks.read_callback(entry->selobj); - } - - if (0 != (poll_entry->revents & POLLOUT)) - if (NULL != entry->callbacks.write_callback) - { - DPRINTFD("Write on selection object %i", poll_entry->fd); - entry->callbacks.write_callback(entry->selobj); - } - - if (0 != (poll_entry->revents & POLLHUP)) - if (NULL != entry->callbacks.hangup_callback) - { - DPRINTFD("Hangup on selection object %i", poll_entry->fd); - entry->callbacks.hangup_callback(entry->selobj); - } - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Initialize -// =================================== -GuestErrorT guest_selobj_initialize( void ) -{ - _num_poll_fds = 0; - memset(_poll_fds, 0, sizeof(_poll_fds)); - memset(_select_objs, 0, sizeof(GuestSelObjTableT)); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Finalize -// ================================= -GuestErrorT guest_selobj_finalize( void ) -{ - _num_poll_fds = 0; - memset(_poll_fds, 0, sizeof(_poll_fds)); - memset(_select_objs, 0, sizeof(GuestSelObjTableT)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.h deleted file mode 100755 index 46bae5ed..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_SELECTION_OBJECT_H__ -#define __GUEST_SELECTION_OBJECT_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestSelObjReadCallbackT) (int selobj); -typedef void (*GuestSelObjWriteCallbackT) (int selobj); -typedef void (*GuestSelObjHangupCallbackT) (int selobj); - -typedef struct { - GuestSelObjReadCallbackT read_callback; - GuestSelObjWriteCallbackT write_callback; - GuestSelObjHangupCallbackT hangup_callback; -} GuestSelObjCallbacksT; - -// **************************************************************************** -// Guest Selection Object - Register -// ================================= -extern GuestErrorT guest_selobj_register( - int selobj, GuestSelObjCallbacksT* callbacks ); -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Deregister -// =================================== -extern GuestErrorT guest_selobj_deregister( int selobj ); -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Dispatch -// ================================= -extern GuestErrorT guest_selobj_dispatch( unsigned int timeout_in_ms ); -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Initialize -// =================================== -extern GuestErrorT guest_selobj_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Selection Object - Finalize -// ================================= -extern GuestErrorT guest_selobj_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_SELECTION_OBJECT_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.c deleted file mode 100755 index 9cc58c4b..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_signal.h" - -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" - -typedef struct { - bool inuse; - int signum; - GuestSignalHandlerT handler; -} GuestSignalT; - -static GuestSignalT _signal[GUEST_MAX_SIGNALS]; - -// **************************************************************************** -// Guest Signal - Map -// ================== -static GuestSignalT* guest_signal_map( int signum ) -{ - switch (signum) - { - case SIGINT: return &(_signal[0]); - case SIGTERM: return &(_signal[1]); - case SIGQUIT: return &(_signal[2]); - case SIGHUP: return &(_signal[3]); - case SIGCHLD: return &(_signal[4]); - case SIGCONT: return &(_signal[5]); - case SIGPIPE: return &(_signal[6]); - case SIGIO: return &(_signal[7]); - default: - DPRINTFE("Mapping for signal %i missing.", signum); - } - - return NULL; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Handler -// ====================== -static void guest_signal_handler( int signum ) -{ - GuestSignalT* entry; - - DPRINTFD("Signal %i received.", signum); - - entry = guest_signal_map(signum); - if (NULL != entry) - if (entry->inuse) - if (NULL != entry->handler) - entry->handler(signum); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Register Handler -// =============================== -void guest_signal_register_handler( int signum, GuestSignalHandlerT handler ) -{ - GuestSignalT* entry; - - entry = guest_signal_map(signum); - if (NULL != entry) - { - entry->inuse = true; - entry->signum = signum; - entry->handler = handler; - signal(signum, guest_signal_handler); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Deregister Handler -// ================================= -void guest_signal_deregister_handler( int signum ) -{ - GuestSignalT* entry; - - entry = guest_signal_map(signum); - if (NULL != entry) - { - memset(entry, 0, sizeof(GuestSignalT)); - signal(signum, SIG_DFL); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Ignore -// ===================== -void guest_signal_ignore( int signum ) -{ - guest_signal_deregister_handler(signum); - signal(signum, SIG_IGN); -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.h deleted file mode 100755 index 5c229286..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_signal.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_SIGNAL_H__ -#define __GUEST_SIGNAL_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestSignalHandlerT) (int signum); - -// **************************************************************************** -// Guest Signal - Register Handler -// =============================== -extern void guest_signal_register_handler( - int signum, GuestSignalHandlerT handler); -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Deregister Handler -// ================================= -extern void guest_signal_deregister_handler( int signum ); -// **************************************************************************** - -// **************************************************************************** -// Guest Signal - Ignore -// ===================== -extern void guest_signal_ignore( int signum ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_SIGNAL_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.c deleted file mode 100755 index 92521065..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_stream.h" - -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" - -// **************************************************************************** -// Guest Stream - Get -// ================== -int guest_stream_get( GuestStreamT* stream ) -{ - char* byte_ptr; - int delimiter_i = 0; - - if (stream->delimiter_size > stream->size) - return -1; - - for (byte_ptr = stream->bytes; byte_ptr != stream->end_ptr; ++byte_ptr) - { - if (stream->delimiter[delimiter_i] == *byte_ptr) - { - ++delimiter_i; - if (delimiter_i == stream->delimiter_size) - { - return (byte_ptr - stream->bytes); - } - } else { - delimiter_i = 0; - } - } - - return -1; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Get Next -// ======================= -bool guest_stream_get_next( GuestStreamT* stream ) -{ - char* byte_ptr; - int delimiter_i = 0; - - if (stream->delimiter_size > stream->size) - return false; - - for (byte_ptr = stream->bytes; byte_ptr != stream->end_ptr; ++byte_ptr) - { - --stream->size; - if (stream->delimiter[delimiter_i] == *byte_ptr) - { - ++delimiter_i; - if (delimiter_i == stream->delimiter_size) - { - byte_ptr -= (stream->delimiter_size-1); - stream->size += stream->delimiter_size; - memmove(stream->bytes, byte_ptr, stream->size); - stream->avail = stream->max_size - stream->size; - stream->end_ptr = stream->bytes + stream->size; - break; - } - } else { - delimiter_i = 0; - } - } - - if (byte_ptr == stream->end_ptr) - { - // Empty the stream - memset(stream->bytes, 0, stream->max_size); - stream->avail = stream->max_size; - stream->size = 0; - stream->end_ptr = stream->bytes; - return false; - } - - return true; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Advance -// ====================== -void guest_stream_advance( int adv, GuestStreamT* stream ) -{ - stream->size -= adv; - memmove(stream->bytes, stream->bytes+adv, stream->size); - stream->avail = stream->max_size - stream->size; - stream->end_ptr = stream->bytes + stream->size; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Reset -// ==================== -void guest_stream_reset( GuestStreamT* stream ) -{ - memset(stream->bytes, 0, stream->max_size); - stream->avail = stream->max_size; - stream->size = 0; - stream->end_ptr = stream->bytes; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Setup -// ==================== -GuestErrorT guest_stream_setup( - const char* delimiter, int delimiter_size, int stream_size, - GuestStreamT* stream ) -{ - stream->delimiter = malloc(delimiter_size); - if (NULL == stream->delimiter) - { - DPRINTFE("Failed to allocated delimiter storage, needed=%i.", - delimiter_size); - return GUEST_FAILED; - } - - stream->bytes = malloc(stream_size); - if (NULL == stream->delimiter) - { - DPRINTFE("Failed to allocated stream storage, needed=%i.", stream_size); - free(stream->delimiter); - return GUEST_FAILED; - } - - memcpy(stream->delimiter, delimiter, delimiter_size); - stream->delimiter_size = delimiter_size; - memset(stream->bytes, 0, stream_size); - stream->end_ptr = stream->bytes; - stream->avail = stream_size; - stream->size = 0; - stream->max_size = stream_size; - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Release -// ====================== -GuestErrorT guest_stream_release( GuestStreamT* stream ) -{ - if (NULL != stream->delimiter) - free(stream->delimiter); - - if (NULL != stream->bytes) - free(stream->bytes); - - memset(stream, 0, sizeof(GuestStreamT)); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Initialize -// ========================= -GuestErrorT guest_stream_initialize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Finalize -// ======================= -GuestErrorT guest_stream_finalize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.h deleted file mode 100755 index 63739855..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_stream.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_STREAM_H__ -#define __GUEST_STREAM_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char* delimiter; - int delimiter_size; - char* end_ptr; - char* bytes; - int avail; - int size; - int max_size; -} GuestStreamT; - -// **************************************************************************** -// Guest Stream - Get -// ================== -extern int guest_stream_get( GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Get Next -// ======================= -extern bool guest_stream_get_next( GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Advance -// ====================== -extern void guest_stream_advance( int adv, GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Reset -// ==================== -extern void guest_stream_reset( GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Setup -// ==================== -extern GuestErrorT guest_stream_setup( - const char* delimiter, int delimiter_size, int stream_size, - GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Release -// ====================== -extern GuestErrorT guest_stream_release( GuestStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Initialize -// ========================= -extern GuestErrorT guest_stream_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Stream - Finalize -// ======================= -extern GuestErrorT guest_stream_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_STREAM_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_time.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_time.c deleted file mode 100755 index cf226cf8..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_time.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_time.h" - -#include - -// **************************************************************************** -// Guest Time - Get -// ================ -void guest_time_get( GuestTimeT* time ) -{ -#ifdef CLOCK_MONOTONIC_RAW - clock_gettime(CLOCK_MONOTONIC_RAW, time); -#else - clock_gettime(CLOCK_MONOTONIC, time); -#endif -} -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Get Elapsed Milliseconds -// ===================================== -long guest_time_get_elapsed_ms( GuestTimeT* time ) -{ - GuestTimeT now; - - guest_time_get(&now); - - if (NULL == time) - return ((now.tv_sec*1000) + (now.tv_nsec/1000000)); - else - return (guest_time_delta_in_ms(&now, time)); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Delta in Milliseconds -// ================================== -long guest_time_delta_in_ms( GuestTimeT* end, GuestTimeT* start ) -{ - long start_in_ms = (start->tv_sec*1000) + (start->tv_nsec/1000000); - long end_in_ms = (end->tv_sec*1000) + (end->tv_nsec/1000000); - - return (end_in_ms - start_in_ms); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Convert Milliseconds -// ================================= -void guest_time_convert_ms( long ms, GuestTimeT* time ) -{ - time->tv_sec = ms / 1000; - time->tv_nsec = (ms % 1000) * 1000000; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_time.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_time.h deleted file mode 100755 index 61b73d58..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_time.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TIME_H__ -#define __GUEST_TIME_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct timespec GuestTimeT; - -// **************************************************************************** -// Guest Time - Get -// ================ -extern void guest_time_get( GuestTimeT* time ); -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Get Elapsed Milliseconds -// ===================================== -extern long guest_time_get_elapsed_ms( GuestTimeT* time ); -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Delta in Milliseconds -// ================================== -extern long guest_time_delta_in_ms( GuestTimeT* end, GuestTimeT* start ); -// **************************************************************************** - -// **************************************************************************** -// Guest Time - Convert Milliseconds -// ================================= -extern void guest_time_convert_ms( long ms, GuestTimeT* time ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TIME_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.c deleted file mode 100755 index b02e62c3..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_timer.h" - -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_time.h" - -typedef uint64_t GuestTimerInstanceT; - -typedef struct { - bool inuse; - GuestTimerInstanceT timer_instance; - GuestTimerIdT timer_id; - unsigned int ms_interval; - GuestTimeT arm_timestamp; - GuestTimerCallbackT callback; -} GuestTimerEntryT; - -typedef GuestTimerEntryT GuestTimerTableT[GUEST_TIMERS_MAX]; - -static bool _scheduling_on_time = true; -static GuestTimerInstanceT _timer_instance = 0; -static GuestTimerIdT _last_timer_dispatched = 0; -static GuestTimerTableT _timers; -static GuestTimeT _delay_timestamp; -static GuestTimeT _schedule_timestamp; - -// **************************************************************************** -// Guest Timer - Scheduling On Time -// ================================ -bool guest_timer_scheduling_on_time( void ) -{ - return _scheduling_on_time; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Scheduling On Time Within -// ======================================= -bool guest_timer_scheduling_on_time_within( unsigned int period_in_ms ) -{ - long ms_expired; - - ms_expired = guest_time_get_elapsed_ms(&_delay_timestamp); - return (period_in_ms < ms_expired); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Reset -// =================== -GuestErrorT guest_timer_reset( GuestTimerIdT timer_id ) -{ - GuestTimerEntryT* timer_entry = NULL; - - if ((GUEST_TIMER_ID_INVALID == timer_id)||(GUEST_TIMERS_MAX <= timer_id)) - return GUEST_FAILED; - - timer_entry = &(_timers[timer_id]); - guest_time_get(&timer_entry->arm_timestamp); - - DPRINTFD("Timer (%i) reset.", timer_entry->timer_id); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Register -// ====================== -GuestErrorT guest_timer_register( - unsigned int ms, GuestTimerCallbackT callback, GuestTimerIdT* timer_id ) -{ - GuestTimerEntryT* timer_entry; - - *timer_id = GUEST_TIMER_ID_INVALID; - - unsigned int timer_i; - for (timer_i=1; GUEST_TIMERS_MAX > timer_i; ++timer_i) - { - timer_entry = &(_timers[timer_i]); - - if (timer_entry->inuse) - continue; - - memset(timer_entry, 0, sizeof(GuestTimerEntryT)); - - timer_entry->inuse = true; - timer_entry->timer_instance = ++_timer_instance; - timer_entry->timer_id = timer_i; - timer_entry->ms_interval = ms; - guest_time_get(&timer_entry->arm_timestamp); - timer_entry->callback = callback; - break; - } - - if (GUEST_TIMERS_MAX <= timer_i) - { - DPRINTFE("No space available to create timer, exiting..."); - abort(); - } - - *timer_id = timer_i; - - DPRINTFD("Created timer, id=%i.", timer_entry->timer_id); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Deregister -// ======================== -GuestErrorT guest_timer_deregister( GuestTimerIdT timer_id ) -{ - GuestTimerEntryT* timer_entry = NULL; - - if ((GUEST_TIMER_ID_INVALID == timer_id)||(GUEST_TIMERS_MAX <= timer_id)) - return GUEST_OKAY; - - timer_entry = &(_timers[timer_id]); - timer_entry->inuse = false; - timer_entry->timer_instance = 0; - - DPRINTFD("Cancelled timer, id=%i.", timer_entry->timer_id); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Schedule Next -// =========================== -static unsigned int guest_timer_schedule_next( void ) -{ - GuestTimerEntryT* timer_entry; - long ms_expired, ms_remaining; - unsigned int interval_in_ms = GUEST_TICK_INTERVAL_IN_MS; - - unsigned int timer_i; - for (timer_i=0; GUEST_TIMERS_MAX > timer_i; ++timer_i) - { - timer_entry = &(_timers[timer_i]); - - if (timer_entry->inuse) - { - ms_expired = guest_time_get_elapsed_ms(&timer_entry->arm_timestamp); - if (ms_expired < timer_entry->ms_interval) - { - ms_remaining = timer_entry->ms_interval - ms_expired; - if (ms_remaining < interval_in_ms) - interval_in_ms = ms_remaining; - } else { - interval_in_ms = GUEST_MIN_TICK_INTERVAL_IN_MS; - break; - } - } - } - - if (GUEST_MIN_TICK_INTERVAL_IN_MS > interval_in_ms) - interval_in_ms = GUEST_MIN_TICK_INTERVAL_IN_MS; - - else if (GUEST_TICK_INTERVAL_IN_MS < interval_in_ms) - interval_in_ms = GUEST_TICK_INTERVAL_IN_MS; - - DPRINTFV("Scheduling timers in %d ms.", interval_in_ms); - return interval_in_ms; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Schedule -// ====================== -unsigned int guest_timer_schedule( void ) -{ - long ms_expired; - GuestTimeT time_prev; - GuestTimerEntryT* timer_entry; - unsigned int total_timers_fired =0; - - ms_expired = guest_time_get_elapsed_ms(&_schedule_timestamp); - if (ms_expired >= GUEST_SCHEDULING_MAX_DELAY_IN_MS) - { - if (_scheduling_on_time) - { - _scheduling_on_time = false; - DPRINTFI("Not scheduling on time, elapsed=%li ms.", ms_expired); - } - guest_time_get(&_delay_timestamp); - - } else if (!_scheduling_on_time) { - ms_expired = guest_time_get_elapsed_ms(&_delay_timestamp); - if (GUEST_SCHEDULING_DELAY_DEBOUNCE_IN_MS < ms_expired) - { - _scheduling_on_time = true; - DPRINTFI("Now scheduling on time."); - } - } - - guest_time_get(&time_prev); - - unsigned int timer_i; - for (timer_i=_last_timer_dispatched; GUEST_TIMERS_MAX > timer_i; ++timer_i) - { - timer_entry = &(_timers[timer_i]); - - if (timer_entry->inuse) - { - ms_expired = guest_time_get_elapsed_ms(&timer_entry->arm_timestamp); - - if (ms_expired >= timer_entry->ms_interval) - { - bool rearm; - GuestTimerInstanceT timer_instance; - - DPRINTFD("Timer %i fire, ms_interval=%d, ms_expired=%li.", - timer_entry->timer_id, timer_entry->ms_interval, - ms_expired); - - timer_instance = timer_entry->timer_instance; - - rearm = timer_entry->callback(timer_entry->timer_id); - - if (timer_instance == timer_entry->timer_instance) - { - if (rearm) - { - guest_time_get(&timer_entry->arm_timestamp); - DPRINTFD("Timer (%i) rearmed.", timer_entry->timer_id); - } else { - timer_entry->inuse = 0; - DPRINTFD("Timer (%i) removed.", timer_entry->timer_id); - } - } else { - DPRINTFD("Timer (%i) instance changed since callback, " - "rearm=%d.", timer_entry->timer_id, (int) rearm); - } - - if (GUEST_MAX_TIMERS_PER_TICK <= ++total_timers_fired) - { - DPRINTFD("Maximum timers per tick (%d) reached.", - GUEST_MAX_TIMERS_PER_TICK); - break; - } - } - } - } - - if (GUEST_TIMERS_MAX <= timer_i) - _last_timer_dispatched = 0; - else - _last_timer_dispatched = timer_i; - - ms_expired = guest_time_get_elapsed_ms(&time_prev); - if (ms_expired >= GUEST_SCHEDULING_MAX_DELAY_IN_MS) - { - _scheduling_on_time = false; - guest_time_get(&_delay_timestamp); - - DPRINTFI("Not scheduling on time, timer callbacks are taking too " - "long to execute, elapsed_time=%li ms.", ms_expired); - } else { - DPRINTFV("Timer callbacks took %li ms.", ms_expired); - } - - guest_time_get(&_schedule_timestamp); - - return guest_timer_schedule_next(); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Initialize -// ======================== -GuestErrorT guest_timer_initialize( void ) -{ - _scheduling_on_time = true; - _last_timer_dispatched = 0; - memset(_timers, 0, sizeof(GuestTimerTableT)); - guest_time_get(&_schedule_timestamp); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Finalize -// ====================== -GuestErrorT guest_timer_finalize( void ) -{ - memset(_timers, 0, sizeof(GuestTimerTableT)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.h deleted file mode 100755 index b3a82c07..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_timer.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TIMER_H__ -#define __GUEST_TIMER_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_TIMER_ID_INVALID -1 - -typedef int GuestTimerIdT; - -typedef bool (*GuestTimerCallbackT) (GuestTimerIdT timer_id); - -// **************************************************************************** -// Guest Timer - Scheduling On Time -// ================================ -extern bool guest_timer_scheduling_on_time( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Scheduling On Time Within -// ======================================= -extern bool guest_timer_scheduling_on_time_within( unsigned int period_in_ms ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Reset -// =================== -extern GuestErrorT guest_timer_reset( GuestTimerIdT timer_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Register -// ====================== -extern GuestErrorT guest_timer_register( - unsigned int ms, GuestTimerCallbackT callback, GuestTimerIdT* timer_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Deregister -// ======================== -extern GuestErrorT guest_timer_deregister( GuestTimerIdT timer_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Schedule -// ====================== -extern unsigned int guest_timer_schedule( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Initialize -// ======================== -extern GuestErrorT guest_timer_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Timer - Finalize -// ====================== -extern GuestErrorT guest_timer_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TIMER_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_types.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_types.c deleted file mode 100755 index ce92d6d5..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_types.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_types.h" - -// **************************************************************************** -// Guest Types - Error String -// ========================== -const char* guest_error_str( GuestErrorT error ) -{ - switch (error) - { - case GUEST_OKAY: return "OKAY"; - case GUEST_FAILED: return "FAILED"; - case GUEST_INTERRUPTED: return "INTERRUPTED"; - case GUEST_TRY_AGAIN: return "TRY_AGAIN"; - case GUEST_NOT_CONFIGURED: return "NOT_CONFIGURED"; - default: - return "???"; - } -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_types.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_types.h deleted file mode 100755 index ad569b24..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_types.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TYPES_H__ -#define __GUEST_TYPES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_OKAY, - GUEST_FAILED, - GUEST_INTERRUPTED, - GUEST_TRY_AGAIN, - GUEST_NOT_CONFIGURED=6, -} GuestErrorT; - -// **************************************************************************** -// Guest Types - Error String -// ========================== -extern const char* guest_error_str( GuestErrorT error ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TYPES_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.c deleted file mode 100755 index 9ebd0f40..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_unix.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" - -GuestUnixConnectCallbackT _callback = NULL; - -// **************************************************************************** -// Guest Unix - Connect -// ==================== -GuestErrorT guest_unix_connect( int s, char* address ) -{ - struct sockaddr_un remote; - int len, result; - - memset(&remote, 0, sizeof(remote)); - - remote.sun_family = AF_UNIX; - len = sizeof(remote.sun_family); - len += snprintf(remote.sun_path, sizeof(remote.sun_path), "%s", address); - - result = connect(s, (struct sockaddr*) &remote, sizeof(remote)); - if (0 > result) - { - DPRINTFE("Failed to connect to %s, error=%s.", address, - strerror(errno)); - return GUEST_FAILED; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Dispatch Connection -// ================================ -static void guest_unix_dispatch_connection( int s ) -{ - int sock; - struct sockaddr_un remote; - socklen_t len; - int result; - - memset(&remote, 0, sizeof(remote)); - len = sizeof(remote); - - result = accept(s, (struct sockaddr*) &remote, &len); - if (0 > result) - { - DPRINTFE("Failed to accept on socket, error=%s.", strerror(errno)); - return; - } - - sock = result; - - result = fcntl(sock, F_SETFD, FD_CLOEXEC); - if (0 > result) - { - DPRINTFE("Failed to set to close on exec, error=%s.", strerror(errno)); - close(sock); - return; - } - - result = fcntl(sock, F_GETFL); - if (0 > result) - { - DPRINTFE("Failed to get socket options, error=%s.", strerror(errno)); - close(sock); - return; - } - - result = fcntl(sock, F_SETFL, result | O_NONBLOCK); - if (0 > result) - { - DPRINTFE("Failed to set socket options, error=%s.", strerror(errno)); - close(sock); - return; - } - - if (NULL == _callback) - close(sock); - - _callback(sock, remote.sun_path); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Listen -// =================== -GuestErrorT guest_unix_listen( - int s, char* address, GuestUnixConnectCallbackT callback ) -{ - struct sockaddr_un local; - int len, result; - GuestSelObjCallbacksT callbacks; - GuestErrorT error; - - memset(&local, 0, sizeof(local)); - - local.sun_family = AF_UNIX; - len = sizeof(local.sun_family); - len += snprintf(local.sun_path, sizeof(local.sun_path), "%s", address); - - unlink(address); - - result = bind(s, (struct sockaddr*) &local, len); - if (0 > result) - { - DPRINTFE("Failed to bind socket to address %s, error=%s.", address, - strerror(errno)); - return GUEST_FAILED; - } - - result = listen(s, GUEST_MAX_CONNECTIONS); - if (0 > result) - { - DPRINTFE("Failed to listen on %s, error=%s.", address, - strerror(errno)); - return GUEST_FAILED; - } - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_unix_dispatch_connection; - - error = guest_selobj_register(s, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object, error=%s.", - guest_error_str(error)); - return error; - } - - _callback = callback; - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Send -// ================= -GuestErrorT guest_unix_send( int s, void* msg, int msg_size ) -{ - int result; - - result = write(s, msg, msg_size); - if (0 > result) - { - DPRINTFE("Failed to write to socket, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Receive -// ==================== -GuestErrorT guest_unix_receive( - int s, void* msg_buf, int msg_buf_size, int* msg_size ) -{ - int result; - - result = read(s, msg_buf, msg_buf_size); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on socket read, error=%s.", strerror(errno)); - return GUEST_INTERRUPTED; - } else if (ECONNRESET == errno) { - DPRINTFD("Peer connection reset, error=%s.", strerror(errno)); - *msg_size = 0; - return GUEST_OKAY; - } else { - DPRINTFE("Failed to read from socket, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - } else if (0 == result) { - DPRINTFD("No message received from socket."); - *msg_size = 0; - return GUEST_OKAY; - } else { - DPRINTFV("Received message, msg_size=%i.", result); - *msg_size = result; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Open -// ================= -GuestErrorT guest_unix_open( int* s ) -{ - int sock; - int reuse_addr = 1; - struct sockaddr_un local; - int result; - - *s = -1; - memset(&local, 0, sizeof(local)); - - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (0 > sock) - { - DPRINTFE("Failed to open socket, error=%s.", strerror(errno)); - return GUEST_FAILED; - } - - result = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, - sizeof(reuse_addr)); - if (0 > result) - { - DPRINTFE("Failed to set socket option (REUSEADDR), error=%s.", - strerror(errno)); - close(sock); - return GUEST_FAILED; - } - - result = fcntl(sock, F_SETFD, FD_CLOEXEC); - if (0 > result) - { - DPRINTFE("Failed to set to close on exec, error=%s.", strerror(errno)); - close(sock); - return GUEST_FAILED; - } - - result = fcntl(sock, F_GETFL); - if (0 > result) - { - DPRINTFE("Failed to get socket options, error=%s.", strerror(errno)); - close(sock); - return GUEST_FAILED; - } - - result = fcntl(sock, F_SETFL, result | O_NONBLOCK); - if (0 > result) - { - DPRINTFE("Failed to set socket options, error=%s.", strerror(errno)); - close(sock); - return GUEST_FAILED; - } - - *s = sock; - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Close -// ================== -GuestErrorT guest_unix_close( int s ) -{ - GuestErrorT error; - - if (0 <= s) - { - error = guest_selobj_deregister(s); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister selection object, error=%s.", - guest_error_str(error)); - } - - close(s); - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Initialize -// ======================= -GuestErrorT guest_unix_initialize( void ) -{ - _callback = NULL; - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Finalize -// ===================== -GuestErrorT guest_unix_finalize( void ) -{ - _callback = NULL; - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.h deleted file mode 100755 index b06f070c..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_unix.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_UNIX_H__ -#define __GUEST_UNIX_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestUnixConnectCallbackT) (int selobj, char* address); - -// **************************************************************************** -// Guest Unix - Connect -// ==================== -extern GuestErrorT guest_unix_connect( int s, char* address ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Listen -// =================== -extern GuestErrorT guest_unix_listen( - int s, char* address, GuestUnixConnectCallbackT callback ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Send -// ================= -extern GuestErrorT guest_unix_send( int s, void* msg, int msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Receive -// ==================== -extern GuestErrorT guest_unix_receive( - int s, void* msg_buf, int msg_buf_size, int* msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Open -// ================= -extern GuestErrorT guest_unix_open( int* s ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Close -// ================== -extern GuestErrorT guest_unix_close( int s ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Initialize -// ======================= -extern GuestErrorT guest_unix_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Unix - Finalize -// ===================== -extern GuestErrorT guest_unix_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_UNIX_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.c b/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.c deleted file mode 100755 index 9a31c0fb..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2013-2018, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_utils.h" -#include "guest_debug.h" - -#include -#include - -// **************************************************************************** -// Guest Utilities - Trim -// ====================== -char* guest_utils_trim( char* str, char* discard ) -{ - int len; - int max_len; - - if (NULL == str) - return NULL; - - // Remove leading characters - max_len = strlen(str); - for (len=0; max_len > len; ++len) - { - if (isspace(*str) || '\n' == *str) - ++str; - else if ((NULL != discard) && (NULL != strchr(discard, *str))) - ++str; - } - - // Remove trailing characters - for (len=strlen(str)-1; 0 <= len; --len) - { - if (isspace(str[len]) || '\n' == str[len]) - str[len] = '\0'; - else if ((NULL != discard) && (NULL != strchr(discard, str[len]))) - str[len] = '\0'; - } - - return str; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Utilities - Base Name -// =========================== -char* guest_utils_basename( char* str ) -{ - const char* basename = str; - - while ('\0' != *str) - { - if (*str++ == '/') - basename = str; - } - - return (char*) basename; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Utilities - Get JSON Value from Key -// return 0 if success, -1 if fail. -// ========================================= -int guest_utils_json_get_value( struct json_object* jobj, - const char* key, void * value ) -{ - struct json_object *jobj_value; - if (!json_object_object_get_ex(jobj, key, &jobj_value)) - { - DPRINTFE("failed to parse %s\n", key); - return -1; - } - enum json_type type = json_object_get_type(jobj_value); - switch(type) - { - case json_type_boolean: - *(unsigned int *)value = json_object_get_boolean(jobj_value); - break; - case json_type_int: - *(unsigned int *)value = json_object_get_int(jobj_value); - break; - case json_type_double: - *(double *)value = json_object_get_double(jobj_value); - break; - case json_type_string: - strcpy(value, json_object_get_string(jobj_value)); - break; - default: - DPRINTFE("failed to parse %s, type %d is not supported\n", key, type); - return -1; - break; - } - return 0; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Utilities - replace newline with space -// ====================== -char* guest_utils_remove_newline( char* str) -{ - char match = '\n'; - char replace = ' '; - char *match_found = strchr(str, match); - while (match_found){ - *match_found = replace; - match_found = strchr(match_found+1, match); - } - return str; -} -// **************************************************************************** \ No newline at end of file diff --git a/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.h b/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.h deleted file mode 100755 index 313ae2eb..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/guest_utils.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2013-2018, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_UTILITIES_H__ -#define __GUEST_UTILITIES_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define STRINGIZE(str) #str -#define MAKE_STRING(str) STRINGIZE(str) - -// **************************************************************************** -// Guest Utilities - Trim -// ====================== -extern char* guest_utils_trim( char* str, char* discard ); -// **************************************************************************** - -// **************************************************************************** -// Guest Utilities - Base Name -// =========================== -extern char* guest_utils_basename( char* str ); -// **************************************************************************** - -// **************************************************************************** -// Guest Utilities - Get JSON Value from Key -// return 0 if success, -1 if fail. -// ========================================= -extern int guest_utils_json_get_value( struct json_object* jobj, - const char* key, void * value ); - -// **************************************************************************** -// Guest Utilities - replace newline with space -// ====================== -char* guest_utils_remove_newline( char* str); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_UTILITIES_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/Makefile b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/Makefile deleted file mode 100755 index b9d9ec33..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -## Configuration Directory Variables -prefix := /usr/local -exec_prefix := $(prefix) -sysconfdir := $(prefix)/etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) - -ifndef BUILD_DIR -$(error BUILD_DIR undefined) -endif - -.SUFFIXES: -.SUFFIXES: .c .o - -.PHONY: build - -heartbeat_C_INCLUDES := -I$(CURRENT_DIR) -I$(CURRENT_DIR)/../ -heartbeat_C_INCLUDES += -I$(CURRENT_DIR)/../../../include -heartbeat_C_SRCS := $(wildcard *.c) -heartbeat_C_OBJS := ${heartbeat_C_SRCS:.c=.o} - -CFLAGS = -g -O2 -Wall -Werror -Wformat -DSYSCONFDIR=$(sysconfdir) -Wformat-security - -%.o: %.c - $(CC) $(CFLAGS) $(heartbeat_C_INCLUDES) -c $< -o $(BUILD_DIR)/$@ -ljson-c - -build: $(heartbeat_C_OBJS) diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.c deleted file mode 100755 index 48638dbc..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat.h" - -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_timer.h" - -#include "guest_heartbeat_config.h" -#include "guest_heartbeat_msg.h" -#include "guest_heartbeat_fsm.h" -#include "guest_heartbeat_health_script.h" -#include "guest_heartbeat_event_script.h" -#include "guest_heartbeat_mgmt_api.h" - -static GuestTimerIdT _release_timer_id = GUEST_TIMER_ID_INVALID; - -// **************************************************************************** -// Guest Heartbeat - Release -// ========================= -static bool guest_heartbeat_release(GuestTimerIdT timer_id) -{ - GuestErrorT error; - - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_RELEASE, - NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle release event, error=%s.", - guest_error_str(error)); - return true; - } - - return false; // don't rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Channel State Change -// ====================================== -static void guest_heartbeat_channel_state_change( bool state ) -{ - GuestErrorT error; - - if (state) - { - error = guest_heartbeat_fsm_event_handler( - GUEST_HEARTBEAT_FSM_CHANNEL_UP, NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle channel up event, error=%s.", - guest_error_str(error)); - return; - } - } else { - error = guest_heartbeat_fsm_event_handler( - GUEST_HEARTBEAT_FSM_CHANNEL_DOWN, NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle channel down event, error=%s.", - guest_error_str(error)); - return; - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Init Ack Message -// ========================================== -static void guest_heartbeat_recv_init_ack_msg( int invocation_id ) -{ - void* event_data[] = {&invocation_id}; - GuestErrorT error; - - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_INIT_ACK, - event_data); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle heartbeat-init-ack event, error=%s.", - guest_error_str(error)); - return; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Challenge Message -// =========================================== -static void guest_heartbeat_recv_challenge_msg( void ) -{ - GuestErrorT error; - - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_CHALLENGE, - NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle heartbeat-challenge event, error=%s.", - guest_error_str(error)); - return; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Action Notify Message -// =============================================== -static void guest_heartbeat_recv_action_notify_msg( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, int timeout_ms) -{ - void* event_data[] = {&invocation_id, &event, ¬ify, &timeout_ms}; - GuestHeartbeatFsmStateT state = guest_heartbeat_fsm_get_state(); - GuestErrorT error; - - if (GUEST_HEARTBEAT_FSM_ENABLED_STATE == state) - { - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_ACTION, - event_data); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle action notify for event %s, error=%s.", - guest_heartbeat_event_str(event), guest_error_str(error)); - return; - } - - } else { - error = guest_heartbeat_msg_send_action_response( - invocation_id, event, notify, - GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE, ""); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send action response for event %s, error=%s.", - guest_heartbeat_event_str(event), guest_error_str(error)); - return; - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Initialize -// ============================ -GuestErrorT guest_heartbeat_initialize( char* comm_device ) -{ - GuestHeartbeatMsgCallbacksT callbacks; - GuestErrorT error; - - _release_timer_id = GUEST_TIMER_ID_INVALID; - - error = guest_heartbeat_config_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat configuration, error=%s.", - guest_error_str(error)); - return error; - } - - memset(&callbacks, 0, sizeof(callbacks)); - - callbacks.channel_state_change = guest_heartbeat_channel_state_change; - callbacks.recv_init_ack = guest_heartbeat_recv_init_ack_msg; - callbacks.recv_challenge = guest_heartbeat_recv_challenge_msg; - callbacks.recv_action_notify = guest_heartbeat_recv_action_notify_msg; - - error = guest_heartbeat_msg_initialize(comm_device, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat messaging, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_heartbeat_fsm_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat fsm, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_heartbeat_mgmt_api_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat management api, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_heartbeat_health_script_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat health script handling, " - "error=%s.", guest_error_str(error)); - return error; - } - - error = guest_heartbeat_event_script_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat event script handling, " - "error=%s.", guest_error_str(error)); - return error; - } - - error = guest_timer_register(1000, guest_heartbeat_release, - &_release_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start release timer, error=%s.", - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Finalize -// ========================== -GuestErrorT guest_heartbeat_finalize( void ) -{ - GuestErrorT error; - - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_SHUTDOWN, - NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle shutdown event, error=%s.", - guest_error_str(error)); - } - - if (GUEST_TIMER_ID_INVALID != _release_timer_id) - { - error = guest_timer_deregister(_release_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel release timer, error=%s.", - guest_error_str(error)); - } - _release_timer_id = GUEST_TIMER_ID_INVALID; - } - - error = guest_heartbeat_event_script_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat event script handling, " - "error=%s.", guest_error_str(error)); - } - - error = guest_heartbeat_health_script_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat health script handling, " - "error=%s.", guest_error_str(error)); - } - - error = guest_heartbeat_mgmt_api_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat management api, error=%s.", - guest_error_str(error)); - } - - error = guest_heartbeat_fsm_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat fsm, error=%s.", - guest_error_str(error)); - } - - error = guest_heartbeat_msg_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat messaging, error=%s.", - guest_error_str(error)); - } - - error = guest_heartbeat_config_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat configuration, error=%s.", - guest_error_str(error)); - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.h deleted file mode 100755 index d8148674..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __GUEST_HEARTBEAT_H__ -#define __GUEST_HEARTBEAT_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Heartbeat - Initialize -// ============================ -extern GuestErrorT guest_heartbeat_initialize( char* comm_device ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Finalize -// ========================== -extern GuestErrorT guest_heartbeat_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.c deleted file mode 100755 index c1e695d6..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_config.h" - -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_utils.h" - -#include "guest_heartbeat_types.h" - -#ifndef SYSCONFDIR -#define GUEST_HEARTBEAT_DEFAULT_CONFIG_FILE \ - "/etc/guest-client/heartbeat/guest_heartbeat.conf" -#else -#define GUEST_HEARTBEAT_DEFAULT_CONFIG_FILE \ - MAKE_STRING(SYSCONFDIR) "/guest-client/heartbeat/guest_heartbeat.conf" -#endif - -#define GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_INIT_RETRY_MS 5000 -#define GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_MIN_TIMEOUT_MS 5000 -#define GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_INTERVAL_MS 1000 -#define GUEST_HEARTBEAT_DEFAULT_VOTE_MS 10000 -#define GUEST_HEARTBEAT_DEFAULT_SHUTDOWN_MS 10000 -#define GUEST_HEARTBEAT_DEFAULT_SUSPEND_MS 10000 -#define GUEST_HEARTBEAT_DEFAULT_RESUME_MS 10000 -#define GUEST_HEARTBEAT_DEFAULT_RESTART_MS 120000 - -static GuestHeartbeatConfigT _config; - -// **************************************************************************** -// Guest Heartbeat Configuration - Read -// ==================================== -static GuestErrorT guest_heartbeat_config_read( char filename[] ) -{ - char* s; - char* key; - char* value; - char delimiter[] = "="; - char discard[] = "\'\""; - char buf[1024]; - FILE* fp; - - fp = fopen(filename, "r"); - if (NULL == fp) - { - DPRINTFE("Failed to open file %s.", filename); - return GUEST_FAILED; - } - - while (NULL != (s = fgets(buf, sizeof(buf), fp))) - { - s = guest_utils_trim(s, NULL); - - // Skip empty string and comments - if (('\0' == *s) || ('#' == *s)) - continue; - - key = strtok(s, delimiter); - value = strtok(NULL, delimiter); - - key = guest_utils_trim(key, discard); - value = guest_utils_trim(value, discard); - - if ((NULL != key) && (NULL != value)) - { - if (0 == strcmp("HB_INIT_RETRY", key)) - { - _config.heartbeat_init_retry_ms = atoi(value); - - } else if (0 == strcmp("HB_MIN_TIMEOUT", key)) { - _config.heartbeat_min_timeout_ms = atoi(value); - - } else if (0 == strcmp("HB_INTERVAL", key)) { - _config.heartbeat_interval_ms = atoi(value); - - } else if (0 == strcmp("VOTE", key)) { - _config.vote_ms = atoi(value) * 1000; - - } else if (0 == strcmp("SHUTDOWN_NOTICE", key)) { - _config.shutdown_notice_ms = atoi(value) * 1000; - - } else if (0 == strcmp("SUSPEND_NOTICE", key)) { - _config.suspend_notice_ms = atoi(value) * 1000; - - } else if (0 == strcmp("RESUME_NOTICE", key)) { - _config.resume_notice_ms = atoi(value) * 1000; - - } else if (0 == strcmp("RESTART", key)) { - _config.restart_ms = atoi(value) * 1000; - - } else if (0 == strcmp("CORRECTIVE_ACTION", key)) { - if (0 == strcmp("reboot", value)) - { - _config.corrective_action = GUEST_HEARTBEAT_ACTION_REBOOT; - - } else if (0 == strcmp("stop", value)) { - _config.corrective_action = GUEST_HEARTBEAT_ACTION_STOP; - - } else if (0 == strcmp("log", value)) { - _config.corrective_action = GUEST_HEARTBEAT_ACTION_LOG; - } - - } else if (0 == strcmp("HEALTH_CHECK_INTERVAL", key)) { - _config.health_check_interval_ms = atoi(value) * 1000; - - } else if (0 == strcmp("HEALTH_CHECK_SCRIPT", key)) { - snprintf(_config.health_check_script, - sizeof(_config.health_check_script), "%s", value); - - } else if (0 == strcmp("EVENT_NOTIFICATION_SCRIPT", key)) { - snprintf(_config.event_handling_script, - sizeof(_config.event_handling_script), "%s", value); - - } else { - DPRINTFE("Unknown key %s in configuration file %s.", key, - filename); - } - } - } - - fclose(fp); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Dump -// ==================================== -static void guest_heartbeat_config_dump( void ) -{ - DPRINTFI("Guest-Client Heartbeat Configuration:"); - DPRINTFI(" heartbeat-init-retry: %i ms", _config.heartbeat_init_retry_ms); - DPRINTFI(" heartbeat-interval: %i ms", _config.heartbeat_interval_ms); - DPRINTFI(" heartbeat-min-timeout: %i ms", _config.heartbeat_min_timeout_ms); - DPRINTFI(" vote: %i ms", _config.vote_ms); - DPRINTFI(" shutdown-notice: %i ms", _config.shutdown_notice_ms); - DPRINTFI(" suspend-notice: %i ms", _config.suspend_notice_ms); - DPRINTFI(" resume-notice: %i ms", _config.resume_notice_ms); - DPRINTFI(" restart: %i ms", _config.restart_ms); - DPRINTFI(" health-check-interval: %i ms", _config.health_check_interval_ms); - DPRINTFI(" health-check-script: %s", _config.health_check_script); - DPRINTFI(" event-handling-script: %s", _config.event_handling_script); - DPRINTFI(" corrective-action: %s", - guest_heartbeat_action_str(_config.corrective_action)); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Get -// =================================== -GuestHeartbeatConfigT* guest_heartbeat_config_get( void ) -{ - return &_config; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Initialize -// ========================================== -GuestErrorT guest_heartbeat_config_initialize( void ) -{ - GuestErrorT error; - - memset(&_config, 0, sizeof(GuestHeartbeatConfigT)); - - _config.heartbeat_init_retry_ms = GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_INIT_RETRY_MS; - _config.heartbeat_min_timeout_ms = GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_MIN_TIMEOUT_MS; - _config.heartbeat_interval_ms = GUEST_HEARTBEAT_DEFAULT_HEARTBEAT_INTERVAL_MS; - _config.vote_ms = GUEST_HEARTBEAT_DEFAULT_VOTE_MS; - _config.shutdown_notice_ms = GUEST_HEARTBEAT_DEFAULT_SHUTDOWN_MS; - _config.suspend_notice_ms = GUEST_HEARTBEAT_DEFAULT_SUSPEND_MS; - _config.resume_notice_ms = GUEST_HEARTBEAT_DEFAULT_RESUME_MS; - _config.restart_ms = GUEST_HEARTBEAT_DEFAULT_RESTART_MS; - _config.corrective_action = GUEST_HEARTBEAT_ACTION_REBOOT; - - error = guest_heartbeat_config_read(GUEST_HEARTBEAT_DEFAULT_CONFIG_FILE); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to read guest heartbeat configuration, error=%s.", - guest_error_str(error)); - return error; - } - - guest_heartbeat_config_dump(); - - if (GUEST_HEARTBEAT_MIN_INTERVAL_MS > _config.heartbeat_interval_ms) - { - DPRINTFE("Guest heartbeat interval configuration is less than %i ms.", - GUEST_HEARTBEAT_MIN_INTERVAL_MS); - return GUEST_FAILED; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Finalize -// ======================================== -GuestErrorT guest_heartbeat_config_finalize( void ) -{ - memset(&_config, 0, sizeof(GuestHeartbeatConfigT)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.h deleted file mode 100755 index 6fd54a49..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HERATBEAT_CONFIGURATION_H__ -#define __GUEST_HEARTBEAT_CONFIGURATION_H__ - -#include "guest_limits.h" -#include "guest_types.h" - -#include "guest_heartbeat_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int heartbeat_init_retry_ms; - int heartbeat_interval_ms; - int heartbeat_min_timeout_ms; - int vote_ms; - int shutdown_notice_ms; - int suspend_notice_ms; - int resume_notice_ms; - int restart_ms; - GuestHeartbeatActionT corrective_action; - int health_check_interval_ms; - char health_check_script[255]; - char event_handling_script[255]; -} GuestHeartbeatConfigT; - -// **************************************************************************** -// Guest Heartbeat Configuration - Get -// =================================== -extern GuestHeartbeatConfigT* guest_heartbeat_config_get( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Initialize -// ========================================== -extern GuestErrorT guest_heartbeat_config_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Configuration - Finalize -// ======================================== -extern GuestErrorT guest_heartbeat_config_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_CONFIGURATION_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.c deleted file mode 100755 index 97af2984..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_disabled_state.h" - -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_timer.h" - -#include "guest_heartbeat_fsm.h" - -// **************************************************************************** -// Guest Heartbeat Disabled State - Enter -// ====================================== -GuestErrorT guest_heartbeat_disabled_state_enter( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Exit -// ===================================== -GuestErrorT guest_heartbeat_disabled_state_exit( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Transition -// =========================================== -GuestErrorT guest_heartbeat_disabled_state_transition( - GuestHeartbeatFsmStateT from_state ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Event Handler -// ============================================== -GuestErrorT guest_heartbeat_disabled_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ) -{ - switch (event) - { - case GUEST_HEARTBEAT_FSM_RELEASE: - case GUEST_HEARTBEAT_FSM_INIT_ACK: - case GUEST_HEARTBEAT_FSM_CHALLENGE: - case GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT: - case GUEST_HEARTBEAT_FSM_CHANNEL_DOWN: - case GUEST_HEARTBEAT_FSM_ACTION: - // Ignore - break; - - case GUEST_HEARTBEAT_FSM_CHANNEL_UP: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_ENABLING_STATE); - break; - - case GUEST_HEARTBEAT_FSM_SHUTDOWN: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_INITIAL_STATE); - break; - - default: - DPRINTFE("Ignoring event %s.", - guest_heartbeat_fsm_event_str(event)); - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Initialize -// =========================================== -GuestErrorT guest_heartbeat_disabled_state_initialize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Finalize -// ========================================= -GuestErrorT guest_heartbeat_disabled_state_finalize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.h deleted file mode 100755 index 38f88af9..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_DISABLED_STATE_H__ -#define __GUEST_HEARTBEAT_DISABLED_STATE_H__ - -#include "guest_types.h" -#include "guest_heartbeat_fsm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Heartbeat Disabled State - Enter -// ====================================== -extern GuestErrorT guest_heartbeat_disabled_state_enter( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Exit -// ===================================== -extern GuestErrorT guest_heartbeat_disabled_state_exit( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Transition -// =========================================== -extern GuestErrorT guest_heartbeat_disabled_state_transition( - GuestHeartbeatFsmStateT from_state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Event Handler -// ============================================== -extern GuestErrorT guest_heartbeat_disabled_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Initialize -// =========================================== -extern GuestErrorT guest_heartbeat_disabled_state_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Disabled State - Finalize -// ========================================= -extern GuestErrorT guest_heartbeat_disabled_state_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_DISABLED_STATE_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.c deleted file mode 100755 index 609cebcb..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_enabled_state.h" - -#include -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_time.h" -#include "guest_timer.h" - -#include "guest_heartbeat_config.h" -#include "guest_heartbeat_msg.h" -#include "guest_heartbeat_fsm.h" -#include "guest_heartbeat_health_script.h" -#include "guest_heartbeat_event_script.h" -#include "guest_heartbeat_mgmt_api.h" - -static bool _wait_application; -static bool _wait_script; -static int _action_invocation_id; -static GuestHeartbeatEventT _action_event; -static GuestHeartbeatNotifyT _action_notify; -GuestHeartbeatVoteResultT _vote_result; -static int _action_timeout_ms; -static GuestTimerIdT _health_check_timer_id = GUEST_TIMER_ID_INVALID; -static GuestTimerIdT _challenge_timeout_timer_id = GUEST_TIMER_ID_INVALID; -static GuestTimerIdT _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; -static bool _health = true; -static char _health_log_msg[GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE]; -static char _action_log_msg[GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE]; -static GuestTimeT _last_time_reported; -static bool _last_health_reported = true; -static GuestHeartbeatActionT _last_corrective_action_reported; - -// **************************************************************************** -// Guest Heartbeat Enabled State - Health Callback -// =============================================== -static void guest_heartbeat_enabled_state_health_callback( - bool health, char* log_msg ) -{ - if (_health && !health) - { - DPRINTFI("Transition from healthy to unhealthy, msg=%s.", log_msg); - - } else if (!_health && health) { - DPRINTFI("Transition from unhealthy to healthy, msg=%s.", log_msg); - } - - _health = health; - snprintf(_health_log_msg, sizeof(_health_log_msg), "%s", log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Health Check -// ============================================ -static bool guest_heartbeat_enabled_state_health_check( - GuestTimerIdT timer_id ) -{ - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - - guest_heartbeat_health_script_abort(); - - if ('\0' != config->health_check_script[0]) - { - error = guest_heartbeat_health_script_invoke( - config->health_check_script, - guest_heartbeat_enabled_state_health_callback); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to invoke health script %s.", - config->health_check_script); - return true; // rearm - } - } - - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Challenge Timeout -// ================================================= -static bool guest_heartbeat_enabled_state_challenge_timeout( - GuestTimerIdT timer_id ) -{ - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - int max_heartbeat_delay; - - max_heartbeat_delay = config->heartbeat_interval_ms*2; - if (max_heartbeat_delay < config->heartbeat_min_timeout_ms) - max_heartbeat_delay = config->heartbeat_min_timeout_ms; - - if (!guest_timer_scheduling_on_time_within(max_heartbeat_delay)) - { - DPRINTFE("Failed to receive a challenge in %i ms, but we are not " - "scheduling on time.", max_heartbeat_delay); - return true; // rearm - } - - DPRINTFE("Failed to receive a challenge in %i ms.", max_heartbeat_delay); - - error = guest_heartbeat_fsm_event_handler(GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT, - NULL); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to handle heartbeat-challenge-timeout event, " - "error=%s.", guest_error_str(error)); - return true; // rearm - } - - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Action Timeout -// ============================================== -static bool guest_heartbeat_enabled_state_action_timeout( - GuestTimerIdT timer_id ) -{ - char log_msg[GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE]; - GuestHeartbeatVoteResultT vote_result; - GuestErrorT error; - - if (!guest_timer_scheduling_on_time_within(_action_timeout_ms)) - { - DPRINTFE("Failed to receive action script response in %i ms, but we " - "are not scheduling on time.", _action_timeout_ms); - return true; - } - - DPRINTFE("Failed to receive action responses in %i ms.", - _action_timeout_ms); - - guest_heartbeat_mgmt_api_action_abort(); - guest_heartbeat_event_script_abort(); - - if (((!_wait_application) || (!_wait_script)) && - (GUEST_HEARTBEAT_VOTE_RESULT_REJECT == _vote_result)) - { - vote_result = _vote_result; - snprintf(log_msg, sizeof(log_msg), "%s", _action_log_msg); - } else { - vote_result = GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT; - snprintf(log_msg, sizeof(log_msg), "Timeout on application and/or " - "script action responses."); - } - - error = guest_heartbeat_msg_send_action_response( - _action_invocation_id, _action_event, _action_notify, - vote_result, log_msg); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send action script response for event %s, " - "notification=%s, error=%s.", - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify), - guest_error_str(error)); - } - - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - return false; // don't rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Action Application Callback -// =========================================================== -static void guest_heartbeat_enabled_state_action_app_callback( - GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatVoteResultT vote_result, char* log_msg ) -{ - bool update; - GuestErrorT error; - - DPRINTFI("Received action application response, event=%s, notify=%s, " - "vote-result=%s, msg=%s.", guest_heartbeat_event_str(event), - guest_heartbeat_notify_str(notify), - guest_heartbeat_vote_result_str(vote_result), log_msg); - - _wait_application = false; - update = false; - - switch (vote_result) - { - case GUEST_HEARTBEAT_VOTE_RESULT_REJECT: - update = true; - break; - - case GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT: - case GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE: - if (GUEST_HEARTBEAT_VOTE_RESULT_REJECT != _vote_result) - update = true; - break; - - default: - update = false; - break; - } - - if (update) - { - _action_event = event; - _action_notify = notify; - _vote_result = vote_result; - snprintf(_action_log_msg, sizeof(_action_log_msg), "%s", log_msg); - } - - if (!_wait_script) - { - error = guest_heartbeat_msg_send_action_response( - _action_invocation_id, _action_event, _action_notify, - _vote_result, _action_log_msg); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send action response for event %s, " - "notification=%s, error=%s.", - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify), - guest_error_str(error)); - } - - if (GUEST_TIMER_ID_INVALID != _action_timeout_timer_id) - { - error = guest_timer_deregister(_action_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action script timeout timer, " - "error=%s.", guest_error_str(error)); - } - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Action Script Callback -// ====================================================== -static void guest_heartbeat_enabled_state_action_script_callback( - GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatVoteResultT vote_result, char* log_msg ) -{ - bool update; - GuestErrorT error; - - DPRINTFI("Received event script response, event=%s, notify=%s, " - "vote-result=%s, msg=%s.", guest_heartbeat_event_str(event), - guest_heartbeat_notify_str(notify), - guest_heartbeat_vote_result_str(vote_result), log_msg); - - _wait_script = false; - update = false; - - switch (vote_result) - { - case GUEST_HEARTBEAT_VOTE_RESULT_REJECT: - update = true; - break; - - case GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT: - case GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE: - if (GUEST_HEARTBEAT_VOTE_RESULT_REJECT != _vote_result) - update = true; - break; - - default: - update = false; - break; - } - - if (update) - { - _action_event = event; - _action_notify = notify; - _vote_result = vote_result; - snprintf(_action_log_msg, sizeof(_action_log_msg), "%s", log_msg); - } - - if (!_wait_application) - { - error = guest_heartbeat_msg_send_action_response( - _action_invocation_id, _action_event, _action_notify, - _vote_result, _action_log_msg); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send action response for event %s, " - "notification=%s, error=%s.", - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify), - guest_error_str(error)); - } - - if (GUEST_TIMER_ID_INVALID != _action_timeout_timer_id) - { - error = guest_timer_deregister(_action_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action script timeout timer, " - "error=%s.", guest_error_str(error)); - } - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Enter -// ===================================== -GuestErrorT guest_heartbeat_enabled_state_enter( void ) -{ - int heartbeat_timeout; - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - - _health = true; - _last_health_reported = true; - - heartbeat_timeout = config->heartbeat_interval_ms*2; - if (heartbeat_timeout < config->heartbeat_min_timeout_ms) - heartbeat_timeout = config->heartbeat_min_timeout_ms; - - error = guest_timer_register(heartbeat_timeout, - guest_heartbeat_enabled_state_challenge_timeout, - &_challenge_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start challenge timeout timer, error=%s.", - guest_error_str(error)); - return error; - } - - if ((0 != config->health_check_interval_ms) && - ('\0' != config->health_check_script[0])) - { - error = guest_timer_register(config->health_check_interval_ms, - guest_heartbeat_enabled_state_health_check, - &_health_check_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start health check timer, error=%s.", - guest_error_str(error)); - return error; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Exit -// ==================================== -GuestErrorT guest_heartbeat_enabled_state_exit( void ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _challenge_timeout_timer_id) - { - error = guest_timer_deregister(_challenge_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel challenge timeout timer, error=%s.", - guest_error_str(error)); - } - _challenge_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _health_check_timer_id) - { - error = guest_timer_deregister(_health_check_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel health check timer, error=%s.", - guest_error_str(error)); - } - _health_check_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _action_timeout_timer_id) - { - error = guest_timer_deregister(_action_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action timeout timer, error=%s.", - guest_error_str(error)); - } - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - guest_heartbeat_health_script_abort(); - guest_heartbeat_event_script_abort(); - guest_heartbeat_mgmt_api_action_abort(); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Transition -// ========================================== -GuestErrorT guest_heartbeat_enabled_state_transition( - GuestHeartbeatFsmStateT from_state ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Event Handler -// ============================================= -GuestErrorT guest_heartbeat_enabled_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ) -{ - bool health = true; - GuestHeartbeatActionT corrective_action = GUEST_HEARTBEAT_ACTION_NONE; - char log_msg[GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE]; - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - - switch (event) { - case GUEST_HEARTBEAT_FSM_RELEASE: - case GUEST_HEARTBEAT_FSM_INIT_ACK: - case GUEST_HEARTBEAT_FSM_CHANNEL_UP: - // Ignore. - break; - - case GUEST_HEARTBEAT_FSM_CHANNEL_DOWN: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_DISABLED_STATE); - break; - - case GUEST_HEARTBEAT_FSM_CHALLENGE: - guest_timer_reset(_challenge_timeout_timer_id); - - error = guest_heartbeat_mgmt_api_get_health(&health, - &corrective_action, log_msg, - GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to get application health, error=%s.", - guest_error_str(error)); - } - - if (health) - { - // Applications are healthy, use the last health script status. - health = _health; - corrective_action = config->corrective_action; - snprintf(log_msg, GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE, "%s", - _health_log_msg); - - } else if (!_health) { - // Applications are not healthy and the health script status - // is not healthy, need to merge the corrective action taken. - corrective_action = guest_heartbeat_merge_action( - corrective_action, - config->corrective_action); - - if (corrective_action == config->corrective_action) - { - snprintf(log_msg, GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE, "%s", - _health_log_msg); - } - } - - if (!health) - { - if ((health == _last_health_reported) && - (corrective_action == _last_corrective_action_reported) && - (60000 > guest_time_get_elapsed_ms(&_last_time_reported))) - { - DPRINTFD("Unhealthy, already reported corrective action " - "%s, setting corrective action to none.", - guest_heartbeat_action_str(corrective_action)); - - // Don't keep asking for a corrective action to be taken - // over and over again at the heartbeat interval if it has - // already been reported. - corrective_action = GUEST_HEARTBEAT_ACTION_NONE; - - } else { - _last_health_reported = health; - _last_corrective_action_reported = corrective_action; - memset(&_last_time_reported, 0, sizeof(_last_time_reported)); - - DPRINTFI("Unhealthy, reporting corrective action %s.", - guest_heartbeat_action_str(corrective_action)); - } - } else { - _last_health_reported = true; - _last_corrective_action_reported = GUEST_HEARTBEAT_ACTION_NONE; - memset(&_last_time_reported, 0, sizeof(_last_time_reported)); - } - - error = guest_heartbeat_msg_send_challenge_response(health, - corrective_action, log_msg); - if (GUEST_OKAY == error) - { - if (GUEST_HEARTBEAT_ACTION_NONE != corrective_action) - { - guest_time_get(&_last_time_reported); - } - } else { - DPRINTFE("Failed to send challenge response, error=%s.", - guest_error_str(error)); - return GUEST_OKAY; - } - break; - - case GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_ENABLING_STATE); - break; - - case GUEST_HEARTBEAT_FSM_ACTION: - guest_heartbeat_mgmt_api_action_abort(); - guest_heartbeat_event_script_abort(); - - _wait_application = false; - _wait_script = false; - _action_invocation_id = *(int*) event_data[0]; - _action_event = *(GuestHeartbeatEventT*) event_data[1]; - _action_notify = *(GuestHeartbeatNotifyT*) event_data[2]; - _action_timeout_ms = *(int*) event_data[3]; - _vote_result = GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - - error = guest_heartbeat_mgmt_api_action_notify( - _action_event, _action_notify, &_wait_application, - guest_heartbeat_enabled_state_action_app_callback); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to notify applications for event %s, " - "notification=%s.", - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify)); - } - - if ('\0' != config->event_handling_script[0]) - { - DPRINTFI("Invoke event script %s for event %s, " - "notification=%s.", config->event_handling_script, - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify)); - - error = guest_heartbeat_event_script_invoke( - config->event_handling_script, - _action_event, _action_notify, - guest_heartbeat_enabled_state_action_script_callback); - if (GUEST_OKAY == error) - { - _wait_script = true; - - } else { - DPRINTFE("Failed to invoke event script %s for event %s, " - "notification=%s.", config->event_handling_script, - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify)); - } - } - - if (_wait_application || _wait_script) - { - error = guest_timer_register(_action_timeout_ms, - guest_heartbeat_enabled_state_action_timeout, - &_action_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start action timeout timer, error=%s.", - guest_error_str(error)); - guest_heartbeat_mgmt_api_action_abort(); - guest_heartbeat_event_script_abort(); - return GUEST_OKAY; - } - } else { - error = guest_heartbeat_msg_send_action_response( - _action_invocation_id, _action_event, - _action_notify, GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE, - ""); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send action response for event %s, " - "notification=%s, error=%s.", - guest_heartbeat_event_str(_action_event), - guest_heartbeat_notify_str(_action_notify), - guest_error_str(error)); - } - } - break; - - case GUEST_HEARTBEAT_FSM_SHUTDOWN: - error = guest_heartbeat_msg_send_exit("Exiting..."); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send exit, error=%s.", - guest_error_str(error)); - } - - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_INITIAL_STATE); - break; - - default: - DPRINTFE("Ignoring event %s.", - guest_heartbeat_fsm_event_str(event)); - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Initialize -// ========================================== -GuestErrorT guest_heartbeat_enabled_state_initialize( void ) -{ - _health = true; - _health_check_timer_id = GUEST_TIMER_ID_INVALID; - _challenge_timeout_timer_id = GUEST_TIMER_ID_INVALID; - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Finalize -// ======================================== -GuestErrorT guest_heartbeat_enabled_state_finalize( void ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _challenge_timeout_timer_id) - { - error = guest_timer_deregister(_challenge_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel challenge timeout timer, error=%s.", - guest_error_str(error)); - } - _challenge_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _health_check_timer_id) - { - error = guest_timer_deregister(_health_check_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel health check timer, error=%s.", - guest_error_str(error)); - } - _health_check_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _action_timeout_timer_id) - { - error = guest_timer_deregister(_action_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action timeout timer, error=%s.", - guest_error_str(error)); - } - _action_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - _health = false; - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.h deleted file mode 100755 index 7b71065b..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_ENABLED_STATE_H__ -#define __GUEST_HEARTBEAT_ENABLED_STATE_H__ - -#include "guest_types.h" -#include "guest_heartbeat_fsm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Heartbeat Enabled State - Enter -// ===================================== -extern GuestErrorT guest_heartbeat_enabled_state_enter( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Exit -// ==================================== -extern GuestErrorT guest_heartbeat_enabled_state_exit( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Transition -// ========================================== -extern GuestErrorT guest_heartbeat_enabled_state_transition( - GuestHeartbeatFsmStateT from_state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Event Handler -// ============================================= -extern GuestErrorT guest_heartbeat_enabled_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Initialize -// ========================================== -extern GuestErrorT guest_heartbeat_enabled_state_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabled State - Finalize -// ======================================== -extern GuestErrorT guest_heartbeat_enabled_state_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_ENABLED_STATE_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.c deleted file mode 100755 index 826f2a36..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_enabling_state.h" - -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_timer.h" -#include "guest_config.h" - -#include "guest_heartbeat_config.h" -#include "guest_heartbeat_msg.h" -#include "guest_heartbeat_fsm.h" - -static int _prev_invocation_id; -static int _invocation_id; -static GuestTimerIdT _connect_timer_id = GUEST_TIMER_ID_INVALID; - -// **************************************************************************** -// Guest Heartbeat Enabling State - Attempt Connect -// ================================================ -static bool guest_heartbeat_enabling_state_connect( GuestTimerIdT timer_id ) -{ - GuestConfigT* cfg = guest_config_get(); - GuestHeartbeatMsgInitDataT data; - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - - _prev_invocation_id = _invocation_id; - _invocation_id = rand(); - - memset(&data, 0, sizeof(data)); - snprintf(data.name, GUEST_NAME_MAX_CHAR, "%s", cfg->name); - data.heartbeat_interval_ms = config->heartbeat_interval_ms; - data.vote_ms = config->vote_ms; - data.shutdown_notice_ms = config->shutdown_notice_ms; - data.suspend_notice_ms = config->suspend_notice_ms; - data.resume_notice_ms = config->resume_notice_ms; - data.restart_ms = config->restart_ms; - data.corrective_action = config->corrective_action; - - error = guest_heartbeat_msg_send_init(_invocation_id, &data); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send heartbeat init message, error=%s.", - guest_error_str(error)); - return true; - } - - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Enter -// ====================================== -GuestErrorT guest_heartbeat_enabling_state_enter( void ) -{ - GuestHeartbeatConfigT* config = guest_heartbeat_config_get(); - GuestErrorT error; - - error = guest_timer_register(config->heartbeat_init_retry_ms, - guest_heartbeat_enabling_state_connect, - &_connect_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start connect timer, error=%s.", - guest_error_str(error)); - return error; - } - - guest_heartbeat_enabling_state_connect(_connect_timer_id); - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Exit -// ===================================== -GuestErrorT guest_heartbeat_enabling_state_exit( void ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _connect_timer_id) - { - error = guest_timer_deregister(_connect_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel connect timer, error=%s.", - guest_error_str(error)); - } - _connect_timer_id = GUEST_TIMER_ID_INVALID; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Transition -// =========================================== -GuestErrorT guest_heartbeat_enabling_state_transition( - GuestHeartbeatFsmStateT from_state ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Event Handler -// ============================================== -GuestErrorT guest_heartbeat_enabling_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ) -{ - int invocation_id; - - switch (event) - { - case GUEST_HEARTBEAT_FSM_RELEASE: - case GUEST_HEARTBEAT_FSM_CHALLENGE: - case GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT: - case GUEST_HEARTBEAT_FSM_ACTION: - case GUEST_HEARTBEAT_FSM_CHANNEL_UP: - // Ignore. - break; - - case GUEST_HEARTBEAT_FSM_CHANNEL_DOWN: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_DISABLED_STATE); - break; - - case GUEST_HEARTBEAT_FSM_INIT_ACK: - invocation_id = *(int*) event_data[0]; - - if ((invocation_id == _invocation_id) || - (invocation_id == _prev_invocation_id)) - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_ENABLED_STATE); - break; - - case GUEST_HEARTBEAT_FSM_SHUTDOWN: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_INITIAL_STATE); - break; - - default: - DPRINTFE("Ignoring event %s.", - guest_heartbeat_fsm_event_str(event)); - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Initialize -// =========================================== -GuestErrorT guest_heartbeat_enabling_state_initialize( void ) -{ - _connect_timer_id = GUEST_TIMER_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Finalize -// ========================================= -GuestErrorT guest_heartbeat_enabling_state_finalize( void ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _connect_timer_id) - { - error = guest_timer_deregister(_connect_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel connect timer, error=%s.", - guest_error_str(error)); - } - _connect_timer_id = GUEST_TIMER_ID_INVALID; - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.h deleted file mode 100755 index df17931f..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_ENABLING_STATE_H__ -#define __GUEST_HEARTBEAT_ENABLING_STATE_H__ - -#include "guest_types.h" -#include "guest_heartbeat_fsm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Heartbeat Enabling State - Enter -// ====================================== -extern GuestErrorT guest_heartbeat_enabling_state_enter( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Exit -// ===================================== -extern GuestErrorT guest_heartbeat_enabling_state_exit( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Transition -// =========================================== -extern GuestErrorT guest_heartbeat_enabling_state_transition( - GuestHeartbeatFsmStateT from_state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Event Handler -// ============================================== -extern GuestErrorT guest_heartbeat_enabling_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Initialize -// =========================================== -extern GuestErrorT guest_heartbeat_enabling_state_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Enabling State - Finalize -// ========================================= -extern GuestErrorT guest_heartbeat_enabling_state_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_ENABLING_STATE_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.c deleted file mode 100755 index c66d44c6..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_event_script.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_script.h" - -#include "guest_heartbeat_types.h" - -static GuestScriptIdT _script_id = GUEST_SCRIPT_ID_INVALID; -static GuestHeartbeatEventT _event; -static GuestHeartbeatNotifyT _notify; -static GuestHeartbeatEventScriptCallbackT _callback = NULL; - -// **************************************************************************** -// Guest Heartbeat Event Script - Event Argument -// ============================================= -const char* guest_heartbeat_event_script_event_arg( GuestHeartbeatEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_EVENT_STOP: return "stop"; - case GUEST_HEARTBEAT_EVENT_REBOOT: return "reboot"; - case GUEST_HEARTBEAT_EVENT_SUSPEND: return "suspend"; - case GUEST_HEARTBEAT_EVENT_PAUSE: return "pause"; - case GUEST_HEARTBEAT_EVENT_UNPAUSE: return "unpause"; - case GUEST_HEARTBEAT_EVENT_RESUME: return "resume"; - case GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN: return "resize_begin"; - case GUEST_HEARTBEAT_EVENT_RESIZE_END: return "resize_end"; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN: return "live_migrate_begin"; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END: return "live_migrate_end"; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN: return "cold_migrate_begin"; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END: return "cold_migrate_end"; - default: - return NULL; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Notify Argument -// ============================================== -const char* guest_heartbeat_event_script_notify_arg( GuestHeartbeatNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_NOTIFY_REVOCABLE: return "revocable"; - case GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE: return "irrevocable"; - default: - return NULL; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Abort -// ==================================== -void guest_heartbeat_event_script_abort( void ) -{ - if (GUEST_SCRIPT_ID_INVALID != _script_id) - { - DPRINTFI("Aborting event script for event %s, notification=%s, " - "script_id=%i.", guest_heartbeat_event_str(_event), - guest_heartbeat_notify_str(_notify), _script_id); - guest_script_abort(_script_id); - _script_id = GUEST_SCRIPT_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Callback -// ======================================= -static void guest_heartbeat_event_script_callback( - GuestScriptIdT script_id, int exit_code, char* log_msg ) -{ - GuestHeartbeatVoteResultT vote_result; - - if (script_id == _script_id) - { - switch (exit_code) - { - case 0: - vote_result = GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT; - break; - case 1: - vote_result = GUEST_HEARTBEAT_VOTE_RESULT_REJECT; - break; - default: - vote_result = GUEST_HEARTBEAT_VOTE_RESULT_ERROR; - break; - } - - if (NULL != _callback) - _callback(_event, _notify, vote_result, log_msg); - - _script_id = GUEST_SCRIPT_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Invoke -// ===================================== -GuestErrorT guest_heartbeat_event_script_invoke( - char script[], GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatEventScriptCallbackT callback) -{ - const char* event_arg = guest_heartbeat_event_script_event_arg(event); - const char* notify_arg = guest_heartbeat_event_script_notify_arg(notify); - const char* script_argv[] = {script, notify_arg, event_arg, NULL}; - GuestErrorT error; - - _event = event; - _notify = notify; - _callback = callback; - - if (NULL == event_arg) - { - DPRINTFE("Event argument invalid, event=%s.", - guest_heartbeat_event_str(event)); - return GUEST_FAILED; - } - - if (NULL == notify_arg) - { - DPRINTFE("Notify argument invalid, event=%s.", - guest_heartbeat_notify_str(notify)); - return GUEST_FAILED; - } - - error = guest_script_invoke(script, (char**) script_argv, - guest_heartbeat_event_script_callback, - &_script_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to invoke script %s, error=%s.", script, - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Initialize -// ========================================= -GuestErrorT guest_heartbeat_event_script_initialize( void ) -{ - _script_id = GUEST_SCRIPT_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Finalize -// ======================================= -GuestErrorT guest_heartbeat_event_script_finalize( void ) -{ - guest_heartbeat_event_script_abort(); - _script_id = GUEST_SCRIPT_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.h deleted file mode 100755 index 6b16931f..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_EVENT_SCRIPT_H__ -#define __GUEST_HEARTBEAT_EVENT_SCRIPT_H__ - -#include "guest_types.h" -#include "guest_heartbeat_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestHeartbeatEventScriptCallbackT) - (GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatVoteResultT vote_result, char* log_msg); - -// **************************************************************************** -// Guest Heartbeat Event Script - Abort -// ==================================== -extern void guest_heartbeat_event_script_abort( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Invoke -// ===================================== -extern GuestErrorT guest_heartbeat_event_script_invoke( - char script[], GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatEventScriptCallbackT callback ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Initialize -// ========================================= -extern GuestErrorT guest_heartbeat_event_script_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Event Script - Finalize -// ======================================= -extern GuestErrorT guest_heartbeat_event_script_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_EVENT_SCRIPT_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.c deleted file mode 100755 index 21719ce7..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.c +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_fsm.h" - -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_heartbeat_initial_state.h" -#include "guest_heartbeat_enabling_state.h" -#include "guest_heartbeat_enabled_state.h" -#include "guest_heartbeat_disabled_state.h" - -typedef GuestErrorT (*GuestHeartbeatFsmStateEnterT) (void); -typedef GuestErrorT (*GuestHeartbeatFsmStateExitT) (void); -typedef GuestErrorT (*GuestHeartbeatFsmStateTransitionT) - (GuestHeartbeatFsmStateT from_state); -typedef GuestErrorT (*GuestHeartbeatFsmStateEventHandlerT) - (GuestHeartbeatFsmEventT event, void* event_data[]); -typedef GuestErrorT (*GuestHeartbeatFsmStateInitializeT) (void); -typedef GuestErrorT (*GuestHeartbeatFsmStateFinalizeT) (void); - -typedef struct { - char name[40]; - GuestHeartbeatFsmStateEnterT enter; - GuestHeartbeatFsmStateExitT exit; - GuestHeartbeatFsmStateTransitionT transition; - GuestHeartbeatFsmStateEventHandlerT event_handler; - GuestHeartbeatFsmStateInitializeT initialize; - GuestHeartbeatFsmStateFinalizeT finalize; -} GuestHeartbeatFsmStateEntryT; - -static GuestHeartbeatFsmStateEntryT _states[GUEST_HEARTBEAT_FSM_MAX_STATES]; -static GuestHeartbeatFsmStateT _current_state = GUEST_HEARTBEAT_FSM_INITIAL_STATE; - -// **************************************************************************** -// Guest Heartbeat FSM - State String -// ================================== -const char* guest_heartbeat_fsm_state_str( GuestHeartbeatFsmStateT state ) -{ - if ((0 > state) || (GUEST_HEARTBEAT_FSM_MAX_STATES <= state)) - { - return "state-???"; - } - - return _states[state].name; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Event String -// ================================== -const char* guest_heartbeat_fsm_event_str( GuestHeartbeatFsmEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_FSM_RELEASE: return "release"; - case GUEST_HEARTBEAT_FSM_INIT_ACK: return "init-ack"; - case GUEST_HEARTBEAT_FSM_CHALLENGE: return "challenge"; - case GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT: return "challenge-timeout"; - case GUEST_HEARTBEAT_FSM_ACTION: return "action"; - case GUEST_HEARTBEAT_FSM_CHANNEL_UP: return "channel-up"; - case GUEST_HEARTBEAT_FSM_CHANNEL_DOWN: return "channel-down"; - case GUEST_HEARTBEAT_FSM_SHUTDOWN: return "shutdown"; - default: - return "event-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Get State -// =============================== -GuestHeartbeatFsmStateT guest_heartbeat_fsm_get_state( void ) -{ - return _current_state; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Enter State -// ================================= -static GuestErrorT guest_heartbeat_fsm_enter_state( GuestHeartbeatFsmStateT state ) -{ - GuestHeartbeatFsmStateEntryT* entry = &(_states[state]); - GuestErrorT error; - - if (NULL != entry->enter) - { - error = entry->enter(); - if (GUEST_OKAY != error) - { - DPRINTFE("Unable to enter state %s, error=%s.", entry->name, - guest_error_str(error)); - return error; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Exit State -// ================================ -static GuestErrorT guest_heartbeat_fsm_exit_state( GuestHeartbeatFsmStateT state ) -{ - GuestHeartbeatFsmStateEntryT* entry = &(_states[state]); - GuestErrorT error; - - if (NULL != entry->exit) - { - error = entry->exit(); - if (GUEST_OKAY != error) - { - DPRINTFE("Unable to exit state %s, error=%s.", entry->name, - guest_error_str(error)); - return error; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Transition State -// ====================================== -static GuestErrorT guest_heartbeat_fsm_transition_state( - GuestHeartbeatFsmStateT from_state ) -{ - GuestHeartbeatFsmStateEntryT* entry = &(_states[from_state]); - GuestErrorT error; - - if (NULL != entry->transition) - { - error = entry->transition(from_state); - if (GUEST_OKAY != error) - { - DPRINTFE("Unable to transition from state %s, error=%s.", - entry->name, guest_error_str(error)); - return error; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Set State -// =============================== -GuestErrorT guest_heartbeat_fsm_set_state( GuestHeartbeatFsmStateT state ) -{ - GuestHeartbeatFsmStateT prev_state = _current_state; - GuestHeartbeatFsmStateEntryT* prev_entry; - GuestHeartbeatFsmStateEntryT* entry; - GuestErrorT error, error2; - - if ((0 > state) || (GUEST_HEARTBEAT_FSM_MAX_STATES <= state)) - { - DPRINTFE("Invalid state %i given.", state); - return GUEST_FAILED; - } - - prev_entry = &(_states[prev_state]); - entry = &(_states[state]); - - error = guest_heartbeat_fsm_exit_state(prev_state); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to exit state %s, error=%s.", prev_entry->name, - guest_error_str(error)); - return( error ); - } - - _current_state = state; - - error = guest_heartbeat_fsm_transition_state(prev_state); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to transition to state %s, error=%s.", - prev_entry->name, guest_error_str(error)); - goto STATE_CHANGE_TRANSITION_ERROR; - } - - error = guest_heartbeat_fsm_enter_state(state); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to enter state %s, error=%s.", entry->name, - guest_error_str(error)); - goto STATE_CHANGE_ENTER_ERROR; - } - - return( GUEST_OKAY ); - -STATE_CHANGE_ENTER_ERROR: - error2 = guest_heartbeat_fsm_transition_state(state); - if (GUEST_OKAY != error2) - { - DPRINTFE("Failed to transition from state %s, error=%s.", - entry->name, guest_error_str(error2)); - abort(); - } - -STATE_CHANGE_TRANSITION_ERROR: - _current_state = prev_state; - - error2 = guest_heartbeat_fsm_enter_state(prev_state); - if (GUEST_OKAY != error2) - { - DPRINTFE("Failed to enter state (%s), error=%s.", prev_entry->name, - guest_error_str(error2)); - abort(); - } - - return error; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Event Handler -// =================================== -GuestErrorT guest_heartbeat_fsm_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ) -{ - GuestHeartbeatFsmStateT prev_state = _current_state; - GuestHeartbeatFsmStateEntryT* entry = &(_states[_current_state]); - GuestErrorT error; - - if (NULL != entry->event_handler) - { - error = entry->event_handler(event, event_data); - if (GUEST_OKAY != error) - { - DPRINTFE("Unable to handle event %s in state %s, error=%s.", - guest_heartbeat_fsm_event_str(event), entry->name, - guest_error_str(error)); - return error; - } - - if (prev_state != _current_state) - { - DPRINTFI("Guest-Client heartbeat state change from %s to %s, " - "event=%s.", guest_heartbeat_fsm_state_str(prev_state), - guest_heartbeat_fsm_state_str(_current_state), - guest_heartbeat_fsm_event_str(event)); - } else { - DPRINTFV("Guest-Client heartbeat no state change from %s, " - "event=%s.", guest_heartbeat_fsm_state_str(prev_state), - guest_heartbeat_fsm_event_str(event)); - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Initialize -// ================================ -GuestErrorT guest_heartbeat_fsm_initialize( void ) -{ - GuestHeartbeatFsmStateEntryT* entry; - - memset(_states, 0, sizeof(_states)); - _current_state = GUEST_HEARTBEAT_FSM_INITIAL_STATE; - - // Initial State - entry = &(_states[GUEST_HEARTBEAT_FSM_INITIAL_STATE]); - snprintf(entry->name, sizeof(entry->name), "initial"); - entry->enter = guest_heartbeat_initial_state_enter; - entry->exit = guest_heartbeat_initial_state_exit; - entry->transition = guest_heartbeat_initial_state_transition; - entry->event_handler = guest_heartbeat_initial_state_event_handler; - entry->initialize = guest_heartbeat_initial_state_initialize; - entry->finalize = guest_heartbeat_initial_state_finalize; - - // Enabling State - entry = &(_states[GUEST_HEARTBEAT_FSM_ENABLING_STATE]); - snprintf(entry->name, sizeof(entry->name), "enabling"); - entry->enter = guest_heartbeat_enabling_state_enter; - entry->exit = guest_heartbeat_enabling_state_exit; - entry->transition = guest_heartbeat_enabling_state_transition; - entry->event_handler = guest_heartbeat_enabling_state_event_handler; - entry->initialize = guest_heartbeat_enabling_state_initialize; - entry->finalize = guest_heartbeat_enabling_state_finalize; - - // Enabled State - entry = &(_states[GUEST_HEARTBEAT_FSM_ENABLED_STATE]); - snprintf(entry->name, sizeof(entry->name), "enabled"); - entry->enter = guest_heartbeat_enabled_state_enter; - entry->exit = guest_heartbeat_enabled_state_exit; - entry->transition = guest_heartbeat_enabled_state_transition; - entry->event_handler = guest_heartbeat_enabled_state_event_handler; - entry->initialize = guest_heartbeat_enabled_state_initialize; - entry->finalize = guest_heartbeat_enabled_state_finalize; - - // Disabled State - entry = &(_states[GUEST_HEARTBEAT_FSM_DISABLED_STATE]); - snprintf(entry->name, sizeof(entry->name), "disabled"); - entry->enter = guest_heartbeat_disabled_state_enter; - entry->exit = guest_heartbeat_disabled_state_exit; - entry->transition = guest_heartbeat_disabled_state_transition; - entry->event_handler = guest_heartbeat_disabled_state_event_handler; - entry->initialize = guest_heartbeat_disabled_state_initialize; - entry->finalize = guest_heartbeat_disabled_state_finalize; - - unsigned int state_i; - for (state_i=0; GUEST_HEARTBEAT_FSM_MAX_STATES > state_i; ++state_i) - { - entry = &(_states[state_i]); - if (NULL != entry->initialize) - entry->initialize(); - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Finalize -// ============================== -GuestErrorT guest_heartbeat_fsm_finalize( void ) -{ - GuestHeartbeatFsmStateEntryT* entry; - - unsigned int state_i; - for (state_i=0; GUEST_HEARTBEAT_FSM_MAX_STATES > state_i; ++state_i) - { - entry = &(_states[state_i]); - if (NULL != entry->finalize) - entry->finalize(); - } - - memset(_states, 0, sizeof(_states)); - _current_state = GUEST_HEARTBEAT_FSM_INITIAL_STATE; - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.h deleted file mode 100755 index 6ff54456..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_FSM_H__ -#define __GUEST_HEARTBEAT_FSM_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_HEARTBEAT_FSM_INITIAL_STATE, - GUEST_HEARTBEAT_FSM_ENABLING_STATE, - GUEST_HEARTBEAT_FSM_ENABLED_STATE, - GUEST_HEARTBEAT_FSM_DISABLED_STATE, - GUEST_HEARTBEAT_FSM_MAX_STATES -} GuestHeartbeatFsmStateT; - -typedef enum { - GUEST_HEARTBEAT_FSM_RELEASE, - GUEST_HEARTBEAT_FSM_INIT_ACK, - GUEST_HEARTBEAT_FSM_CHALLENGE, - GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT, - GUEST_HEARTBEAT_FSM_ACTION, - GUEST_HEARTBEAT_FSM_CHANNEL_UP, - GUEST_HEARTBEAT_FSM_CHANNEL_DOWN, - GUEST_HEARTBEAT_FSM_SHUTDOWN, - GUEST_HEARTBEAT_FSM_MAX_EVENTS -} GuestHeartbeatFsmEventT; - -// **************************************************************************** -// Guest Heartbeat FSM - State String -// ================================== -extern const char* guest_heartbeat_fsm_state_str( GuestHeartbeatFsmStateT state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Event String -// ================================== -extern const char* guest_heartbeat_fsm_event_str( GuestHeartbeatFsmEventT event ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Get State -// =============================== -extern GuestHeartbeatFsmStateT guest_heartbeat_fsm_get_state( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Set State -// =============================== -extern GuestErrorT guest_heartbeat_fsm_set_state( GuestHeartbeatFsmStateT state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Event Handler -// =================================== -extern GuestErrorT guest_heartbeat_fsm_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Initialize -// ================================ -extern GuestErrorT guest_heartbeat_fsm_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat FSM - Finalize -// ============================== -extern GuestErrorT guest_heartbeat_fsm_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_FSM_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.c deleted file mode 100755 index 73c4a38c..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_health_script.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_script.h" - -static GuestScriptIdT _script_id = GUEST_SCRIPT_ID_INVALID; -static GuestHeartbeatHealthScriptCallbackT _callback = NULL; - -// **************************************************************************** -// Guest Heartbeat Health Script - Abort -// ===================================== -void guest_heartbeat_health_script_abort( void ) -{ - if (GUEST_SCRIPT_ID_INVALID != _script_id) - { - DPRINTFI("Aborting health script, script_id=%i.", _script_id); - guest_script_abort(_script_id); - _script_id = GUEST_SCRIPT_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Callback -// ======================================== -static void guest_heartbeat_health_script_callback( - GuestScriptIdT script_id, int exit_code, char* log_msg ) -{ - if (script_id == _script_id) - { - if (NULL != _callback) - _callback((1 != exit_code), log_msg); - - _script_id = GUEST_SCRIPT_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Invoke -// ====================================== -GuestErrorT guest_heartbeat_health_script_invoke( - char script[], GuestHeartbeatHealthScriptCallbackT callback) -{ - const char* script_argv[] = {script, NULL}; - GuestErrorT error; - - _callback = callback; - - error = guest_script_invoke(script, (char**) script_argv, - guest_heartbeat_health_script_callback, - &_script_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to invoke script %s, error=%s.", script, - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Initialize -// ========================================== -GuestErrorT guest_heartbeat_health_script_initialize( void ) -{ - _script_id = GUEST_SCRIPT_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Finalize -// ======================================== -GuestErrorT guest_heartbeat_health_script_finalize( void ) -{ - guest_heartbeat_health_script_abort(); - _script_id = GUEST_SCRIPT_ID_INVALID; - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.h deleted file mode 100755 index 6e52119e..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_HEALTH_SCRIPT_H__ -#define __GUEST_HEARTBEAT_HEALTH_SCRIPT_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestHeartbeatHealthScriptCallbackT) (bool health, char* log_msg); - -// **************************************************************************** -// Guest Heartbeat Health Script - Abort -// ===================================== -extern void guest_heartbeat_health_script_abort( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Invoke -// ====================================== -extern GuestErrorT guest_heartbeat_health_script_invoke( - char script[], GuestHeartbeatHealthScriptCallbackT callback ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Initialize -// ========================================== -extern GuestErrorT guest_heartbeat_health_script_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Health Script - Finalize -// ======================================== -extern GuestErrorT guest_heartbeat_health_script_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_HEALTH_SCRIPT_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.c deleted file mode 100755 index 9df06f6d..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_initial_state.h" - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_heartbeat_fsm.h" - -// **************************************************************************** -// Guest Heartbeat Initial State - Enter -// ===================================== -GuestErrorT guest_heartbeat_initial_state_enter( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Exit -// ==================================== -GuestErrorT guest_heartbeat_initial_state_exit( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Transition -// ========================================== -GuestErrorT guest_heartbeat_initial_state_transition( - GuestHeartbeatFsmStateT from_state ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Event Handler -// ============================================= -GuestErrorT guest_heartbeat_initial_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ) -{ - switch (event) - { - case GUEST_HEARTBEAT_FSM_INIT_ACK: - case GUEST_HEARTBEAT_FSM_CHALLENGE: - case GUEST_HEARTBEAT_FSM_CHALLENGE_TIMEOUT: - case GUEST_HEARTBEAT_FSM_ACTION: - case GUEST_HEARTBEAT_FSM_SHUTDOWN: - // Ignore - break; - - case GUEST_HEARTBEAT_FSM_RELEASE: - case GUEST_HEARTBEAT_FSM_CHANNEL_UP: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_ENABLING_STATE); - break; - - case GUEST_HEARTBEAT_FSM_CHANNEL_DOWN: - guest_heartbeat_fsm_set_state(GUEST_HEARTBEAT_FSM_DISABLED_STATE); - break; - - default: - DPRINTFV("Ignoring event %s.", - guest_heartbeat_fsm_event_str(event)); - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Initialize -// ========================================== -GuestErrorT guest_heartbeat_initial_state_initialize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Finalize -// ======================================== -GuestErrorT guest_heartbeat_initial_state_finalize( void ) -{ - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.h deleted file mode 100755 index db05cf83..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_INITIAL_STATE_H__ -#define __GUEST_HEARTBEAT_INITIAL_STATE_H__ - -#include "guest_types.h" -#include "guest_heartbeat_fsm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Heartbeat Initial State - Enter -// ===================================== -extern GuestErrorT guest_heartbeat_initial_state_enter( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Exit -// ==================================== -extern GuestErrorT guest_heartbeat_initial_state_exit( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Transition -// ========================================== -extern GuestErrorT guest_heartbeat_initial_state_transition( - GuestHeartbeatFsmStateT from_state ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Event Handler -// ============================================= -extern GuestErrorT guest_heartbeat_initial_state_event_handler( - GuestHeartbeatFsmEventT event, void* event_data[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Initialize -// ========================================== -extern GuestErrorT guest_heartbeat_initial_state_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Initial State - Finalize -// ======================================== -extern GuestErrorT guest_heartbeat_initial_state_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_INITIAL_STATE_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.c deleted file mode 100755 index 00ee9dc3..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.c +++ /dev/null @@ -1,1400 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_mgmt_api.h" - -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" -#include "guest_unix.h" -#include "guest_stream.h" -#include "guest_timer.h" - -#include "guest_heartbeat_types.h" -#include "guest_heartbeat_api_msg_defs.h" - -#define GUEST_HEARTBEAT_MGMT_API_CHALLENGE_DEPTH 4 - -typedef struct { - char name[GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE]; - int heartbeat_interval_ms; - int vote_ms; - int shutdown_notice_ms; - int suspend_notice_ms; - int resume_notice_ms; - GuestHeartbeatActionT corrective_action; -} GuestHeartbeatMgmtApiAppConfigT; - -typedef struct { - bool healthy; - GuestHeartbeatActionT corrective_action; - char log_msg[GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE]; -} GuestHeartbeatMgmtApiAppHealthT; - -typedef struct { - bool running; - int invocation_id; - GuestHeartbeatEventT event; - GuestHeartbeatNotifyT notify; - GuestHeartbeatVoteResultT vote_result; - char log_msg[GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE]; -} GuestHeartbeatMgmtApiAppActionT; - -typedef struct { - bool inuse; - bool registered; - bool final; - int sock; - GuestStreamT stream; - int challenge_depth; - int last_challenge[GUEST_HEARTBEAT_MGMT_API_CHALLENGE_DEPTH]; - bool send_challenge_response; - GuestTimerIdT heartbeat_timer; - GuestTimerIdT heartbeat_timeout_timer; - GuestTimerIdT action_timer; - GuestHeartbeatMgmtApiAppConfigT application_config; - GuestHeartbeatMgmtApiAppHealthT application_health; - GuestHeartbeatMgmtApiAppActionT application_action; -} GuestHeartbeatMgmtApiConnectionT; - -static int _sock = -1; -static uint32_t _msg_sequence; -static GuestHeartbeatMgmtApiActionResponseT _callback; -static GuestHeartbeatMgmtApiConnectionT _connections[GUEST_APPLICATIONS_MAX]; - -// **************************************************************************** -// Guest Heartbeat Management API - Handle Action Completed -// ======================================================== -static void guest_heartbeat_mgmt_api_handle_action_completed( void ) -{ - bool update; - bool invoke_callback; - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppActionT* app_action; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestHeartbeatEventT event; - GuestHeartbeatNotifyT notify; - GuestHeartbeatVoteResultT vote_result; - char* log_msg; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse && connection->registered) - { - if (connection->application_action.running) - { - DPRINTFD("Still waiting for application %s to respond.", - connection->application_config.name); - return; - } - } - } - - if (NULL == _callback) - return; - - vote_result = GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - invoke_callback = false; - - // All action responses received or timed out. - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse && connection->registered) - { - app_config = &(connection->application_config); - app_action = &(connection->application_action); - - DPRINTFI("Application %s vote %s for event %s, notification=%s.", - app_config->name, - guest_heartbeat_vote_result_str(app_action->vote_result), - guest_heartbeat_event_str(app_action->event), - guest_heartbeat_notify_str(app_action->notify)); - - update = false; - - switch (app_action->vote_result) - { - case GUEST_HEARTBEAT_VOTE_RESULT_REJECT: - update = true; - break; - - case GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT: - case GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE: - if (GUEST_HEARTBEAT_VOTE_RESULT_REJECT != vote_result) - update = true; - break; - - default: - update = false; - break; - } - - if (update) - { - event = app_action->event; - notify = app_action->notify; - vote_result = app_action->vote_result; - log_msg = &(app_action->log_msg[0]); - invoke_callback = true; - } - } - } - - if (invoke_callback) - _callback(event, notify, vote_result, log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Close Connection -// ================================================= -static void guest_heartbeat_mgmt_api_close_connection( - GuestHeartbeatMgmtApiConnectionT* connection ) -{ - GuestErrorT error; - - if (0 <= connection->sock) - { - error = guest_selobj_deregister(connection->sock); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister select on unix socket, error=%s.", - guest_error_str(error)); - } - - close(connection->sock); - } - - if (GUEST_TIMER_ID_INVALID != connection->heartbeat_timer) - { - error = guest_timer_deregister(connection->heartbeat_timer); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - } - - if (GUEST_TIMER_ID_INVALID != connection->heartbeat_timeout_timer) - { - error = guest_timer_deregister(connection->heartbeat_timeout_timer); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - } - - if (GUEST_TIMER_ID_INVALID != connection->action_timer) - { - error = guest_timer_deregister(connection->action_timer); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action timer, error=%s.", - guest_error_str(error)); - } - } - - memset(connection, 0, sizeof(GuestHeartbeatMgmtApiConnectionT)); - connection->sock = -1; - connection->heartbeat_timer = GUEST_TIMER_ID_INVALID; - connection->heartbeat_timeout_timer = GUEST_TIMER_ID_INVALID; - connection->action_timer = GUEST_TIMER_ID_INVALID; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action (Network to Host) -// ========================================================= -static GuestHeartbeatActionT guest_heartbeat_mgmt_api_action_ntoh( - GuestHeartbeatApiMsgActionT action ) -{ - switch (action) - { - case GUEST_HEARTBEAT_API_MSG_ACTION_NONE: - return GUEST_HEARTBEAT_ACTION_NONE; - case GUEST_HEARTBEAT_API_MSG_ACTION_REBOOT: - return GUEST_HEARTBEAT_ACTION_REBOOT; - case GUEST_HEARTBEAT_API_MSG_ACTION_STOP: - return GUEST_HEARTBEAT_ACTION_STOP; - case GUEST_HEARTBEAT_API_MSG_ACTION_LOG: - return GUEST_HEARTBEAT_ACTION_LOG; - default: - DPRINTFE("Unknown action %i.", action); - return GUEST_HEARTBEAT_ACTION_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Event (Host to Network) -// ======================================================== -static GuestHeartbeatApiMsgEventT guest_heartbeat_mgmt_api_event_hton( - GuestHeartbeatEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_EVENT_STOP: - return GUEST_HEARTBEAT_API_MSG_EVENT_STOP; - case GUEST_HEARTBEAT_EVENT_REBOOT: - return GUEST_HEARTBEAT_API_MSG_EVENT_REBOOT; - case GUEST_HEARTBEAT_EVENT_SUSPEND: - return GUEST_HEARTBEAT_API_MSG_EVENT_SUSPEND; - case GUEST_HEARTBEAT_EVENT_PAUSE: - return GUEST_HEARTBEAT_API_MSG_EVENT_PAUSE; - case GUEST_HEARTBEAT_EVENT_UNPAUSE: - return GUEST_HEARTBEAT_API_MSG_EVENT_UNPAUSE; - case GUEST_HEARTBEAT_EVENT_RESUME: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESUME; - case GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_BEGIN; - case GUEST_HEARTBEAT_EVENT_RESIZE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_END; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_END; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_END; - default: - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_API_MSG_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Event (Network to Host) -// ======================================================== -static GuestHeartbeatEventT guest_heartbeat_mgmt_api_event_ntoh( - GuestHeartbeatApiMsgEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_API_MSG_EVENT_STOP: - return GUEST_HEARTBEAT_EVENT_STOP; - case GUEST_HEARTBEAT_API_MSG_EVENT_REBOOT: - return GUEST_HEARTBEAT_EVENT_REBOOT; - case GUEST_HEARTBEAT_API_MSG_EVENT_SUSPEND: - return GUEST_HEARTBEAT_EVENT_SUSPEND; - case GUEST_HEARTBEAT_API_MSG_EVENT_PAUSE: - return GUEST_HEARTBEAT_EVENT_PAUSE; - case GUEST_HEARTBEAT_API_MSG_EVENT_UNPAUSE: - return GUEST_HEARTBEAT_EVENT_UNPAUSE; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESUME: - return GUEST_HEARTBEAT_EVENT_RESUME; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_BEGIN: - return GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_END: - return GUEST_HEARTBEAT_EVENT_RESIZE_END; - case GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_END: - return GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END; - case GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_END: - return GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END; - default: - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Notify (Host to Network) -// ========================================================= -static GuestHeartbeatApiMsgNotifyT guest_heartbeat_mgmt_api_notify_hton( - GuestHeartbeatNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_NOTIFY_REVOCABLE: - return GUEST_HEARTBEAT_API_MSG_NOTIFY_REVOCABLE; - case GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE: - return GUEST_HEARTBEAT_API_MSG_NOTIFY_IRREVOCABLE; - default: - DPRINTFE("Unknown notify type %i.", notify); - return GUEST_HEARTBEAT_API_MSG_NOTIFY_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Notify (Network to Host) -// ========================================================= -static GuestHeartbeatNotifyT guest_heartbeat_mgmt_api_notify_ntoh( - GuestHeartbeatApiMsgNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_API_MSG_NOTIFY_REVOCABLE: - return GUEST_HEARTBEAT_NOTIFY_REVOCABLE; - case GUEST_HEARTBEAT_API_MSG_NOTIFY_IRREVOCABLE: - return GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE; - default: - DPRINTFE("Unknown notify type %i.", notify); - return GUEST_HEARTBEAT_NOTIFY_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Vote Result (Network to Host) -// ============================================================== -static GuestHeartbeatVoteResultT guest_heartbeat_mgmt_api_vote_result_ntoh( - GuestHeartbeatApiMsgVoteResultT vote_result ) -{ - switch (vote_result) - { - case GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_ACCEPT: - return GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT; - case GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_REJECT: - return GUEST_HEARTBEAT_VOTE_RESULT_REJECT; - case GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_COMPLETE: - return GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE; - default: - DPRINTFE("Unknown vote result %i.", vote_result); - return GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Send Init Ack -// ============================================== -static GuestErrorT guest_heartbeat_mgmt_api_send_init_ack( int s, bool accept ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT *hdr = &(msg.header); - GuestHeartbeatApiMsgInitAckT *bdy = &(msg.body.init_ack); - GuestErrorT error; - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_INIT_ACK; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - bdy->accepted = accept; - - error = guest_unix_send(s, &msg, sizeof(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat register ack message, " - "error=%s.", guest_error_str(error)); - return error; - } - - DPRINTFD("Sent register ack."); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Send Heartbeat -// =============================================== -static GuestErrorT guest_heartbeat_mgmt_api_send_heartbeat( int s, int challenge ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT *hdr = &(msg.header); - GuestHeartbeatApiMsgChallengeT *bdy = &(msg.body.challenge); - GuestErrorT error; - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_CHALLENGE; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - bdy->heartbeat_challenge = challenge; - - error = guest_unix_send(s, &msg, sizeof(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat message, error=%s.", - guest_error_str(error)); - return error; - } - - DPRINTFD("Sent heartbeat message."); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Send Action Notify -// =================================================== -static GuestErrorT guest_heartbeat_mgmt_api_send_action_notify( - int s, int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT *hdr = &(msg.header); - GuestHeartbeatApiMsgActionNotifyT *bdy = &(msg.body.action_notify); - GuestErrorT error; - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_ACTION_NOTIFY; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - bdy->invocation_id = invocation_id; - bdy->event_type = guest_heartbeat_mgmt_api_event_hton(event); - bdy->notification_type = guest_heartbeat_mgmt_api_notify_hton(notify); - - error = guest_unix_send(s, &msg, sizeof(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat action notify message, " - "error=%s.", guest_error_str(error)); - return error; - } - - DPRINTFD("Sent action notify."); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Heartbeat Interval -// =================================================== -static bool guest_heartbeat_mgmt_api_heartbeat_interval( GuestTimerIdT timer_id ) -{ - int challenge; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse) - if (timer_id == connection->heartbeat_timer) - break; - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - DPRINTFE("Uknown timer %i.", timer_id); - return false; // don't rearm - } - - if (!(connection->send_challenge_response)) - { - DPRINTFD("Waiting for challenge response for previous iteration."); - return true; // rearm - } - - challenge = rand(); - ++connection->challenge_depth; - if (GUEST_HEARTBEAT_MGMT_API_CHALLENGE_DEPTH <= connection->challenge_depth) - connection->challenge_depth = 0; - - connection->last_challenge[connection->challenge_depth] = challenge; - - error = guest_heartbeat_mgmt_api_send_heartbeat( connection->sock, - challenge ); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send heartbeat, error=%s.", guest_error_str(error)); - return true; // rearm - } - - connection->send_challenge_response = false; - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Heartbeat Timeout -// ================================================== -static bool guest_heartbeat_mgmt_api_heartbeat_timeout( GuestTimerIdT timer_id ) -{ - bool prev_health; - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppHealthT* app_health; - GuestHeartbeatMgmtApiConnectionT* connection; - int max_heartbeat_delay; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse) - if (timer_id == connection->heartbeat_timeout_timer) - break; - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - DPRINTFE("Uknown timer %i.", timer_id); - return false; // don't rearm - } - - app_config = &(connection->application_config); - app_health = &(connection->application_health); - - max_heartbeat_delay = app_config->heartbeat_interval_ms*2; - - if (!guest_timer_scheduling_on_time_within(max_heartbeat_delay)) - { - DPRINTFE("Failed to receive a heartbeat in %i ms, but we are not " - "scheduling on time.", max_heartbeat_delay); - return true; // rearm - } - - prev_health = app_health->healthy; - app_health->healthy = false; - app_health->corrective_action = app_config->corrective_action; - snprintf(app_health->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, - "Application %s heartbeat timeout %i ms.", app_config->name, - app_config->heartbeat_interval_ms*2); - - if (prev_health) - { - DPRINTFI("Application %s heartbeat timeout %i ms, " - "corrective_action=%s, log_msg=%s.", app_config->name, - max_heartbeat_delay, - guest_heartbeat_action_str(app_health->corrective_action), - app_health->log_msg); - } - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Receive Init -// ============================================= -static void guest_heartbeat_mgmt_api_recv_init( - GuestHeartbeatMgmtApiConnectionT* connection ) -{ - bool accepted = true; - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppHealthT* app_health; - GuestHeartbeatMgmtApiAppActionT* app_action; - char* ptr = connection->stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - GuestErrorT error; - - DPRINTFD("Heartbeat Init received..."); - - app_config = &(connection->application_config); - app_health = &(connection->application_health); - app_action = &(connection->application_action); - - snprintf(app_config->name, - GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE, "%s", ptr); - ptr += GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE; - app_config->heartbeat_interval_ms = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - app_config->vote_ms = (*(uint32_t*) ptr) * 1000; - ptr += sizeof(uint32_t); - app_config->shutdown_notice_ms = (*(uint32_t*) ptr) * 1000; - ptr += sizeof(uint32_t); - app_config->suspend_notice_ms = (*(uint32_t*) ptr) * 1000; - ptr += sizeof(uint32_t); - app_config->resume_notice_ms = (*(uint32_t*) ptr) * 1000; - ptr += sizeof(uint32_t); - app_config->corrective_action - = guest_heartbeat_mgmt_api_action_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - - if (GUEST_HEARTBEAT_MIN_INTERVAL_MS > app_config->heartbeat_interval_ms) - { - DPRINTFE("Not accepting application %s registration, unsupported " - "heartbeat interval, less than %s ms.", app_config->name, - GUEST_HEARTBEAT_MIN_INTERVAL_MS); - accepted = false; - } - - error = guest_heartbeat_mgmt_api_send_init_ack(connection->sock, accepted); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send register ack message, error=%s.", - guest_error_str(error)); - return; - } - - if (!accepted) - return; - - error = guest_timer_register(app_config->heartbeat_interval_ms, - guest_heartbeat_mgmt_api_heartbeat_interval, - &(connection->heartbeat_timer)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register heartbeat timer, error=%s.", - guest_error_str(error)); - return; - } - - error = guest_timer_register(app_config->heartbeat_interval_ms*2, - guest_heartbeat_mgmt_api_heartbeat_timeout, - &(connection->heartbeat_timeout_timer)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register heartbeat timeout timer, error=%s.", - guest_error_str(error)); - return; - } - - app_health->healthy = true; - app_health->corrective_action = GUEST_HEARTBEAT_ACTION_NONE; - app_health->log_msg[0] = '\0'; - - app_action->event = GUEST_HEARTBEAT_EVENT_UNKNOWN; - app_action->notify = GUEST_HEARTBEAT_NOTIFY_UNKNOWN; - app_action->vote_result = GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - app_action->log_msg[0] = '\0'; - - connection->send_challenge_response = true; - connection->registered = true; - connection->final = false; - - DPRINTFI("Connection accepted from %s.", app_config->name); - DPRINTFI(" socket: %i", connection->sock); - DPRINTFI(" heartbeat_interval_ms: %i", app_config->heartbeat_interval_ms); - DPRINTFI(" vote_ms: %i", app_config->vote_ms); - DPRINTFI(" shutdown_notice_ms: %i", app_config->shutdown_notice_ms); - DPRINTFI(" resume_notice_ms: %i", app_config->resume_notice_ms); - DPRINTFI(" corrective_action: %s", - guest_heartbeat_action_str(app_config->corrective_action)); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Receive Final -// ============================================== -static void guest_heartbeat_mgmt_api_recv_final( - GuestHeartbeatMgmtApiConnectionT* connection ) -{ - char* log_msg; - char* ptr = connection->stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - - log_msg = ptr; - ptr += GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE; - - DPRINTFD("Heartbeat Final Response received..."); - - DPRINTFI("Application %s has deregistered, msg=%s.", - connection->application_config.name, log_msg); - - connection->registered = false; - connection->final = true; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Receive Challenge Response -// =========================================================== -static void guest_heartbeat_mgmt_api_recv_challenge_response( - GuestHeartbeatMgmtApiConnectionT* connection ) -{ - uint32_t heartbeat_response; - uint32_t health; - GuestHeartbeatActionT corrective_action; - char* log_msg; - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppHealthT* app_health; - char* ptr = connection->stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - - heartbeat_response = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - health = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - corrective_action - = guest_heartbeat_mgmt_api_action_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - log_msg = ptr; - ptr += GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE; - - unsigned int challenge_i; - for (challenge_i=0; GUEST_HEARTBEAT_MGMT_API_CHALLENGE_DEPTH > challenge_i; - ++challenge_i) - { - if (connection->last_challenge[challenge_i] == heartbeat_response) - break; - } - - if (GUEST_HEARTBEAT_MGMT_API_CHALLENGE_DEPTH == challenge_i) - { - DPRINTFE("Mismatch between last transmitted challenges and received " - "challenge."); - return; - } - - DPRINTFD("Heartbeat Challenge Response received..."); - connection->send_challenge_response = true; - - app_config = &(connection->application_config); - app_health = &(connection->application_health); - - if (health != app_health->healthy) - { - DPRINTFI("Application %s health state change, prev_health=%i, " - "health=%i, corrective_action=%s, log_msg=%s.", - app_config->name, app_health->healthy, health, - guest_heartbeat_action_str(corrective_action), - log_msg); - } - - app_health->healthy = health; - app_health->corrective_action = corrective_action; - snprintf(app_health->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, "%s", - log_msg); - - guest_timer_reset(connection->heartbeat_timeout_timer); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Receive Action Response -// ======================================================== -static void guest_heartbeat_mgmt_api_recv_action_response( - GuestHeartbeatMgmtApiConnectionT* connection ) -{ - int invocation_id; - GuestHeartbeatEventT event; - GuestHeartbeatNotifyT notify; - GuestHeartbeatVoteResultT vote_result; - GuestHeartbeatMgmtApiAppActionT* app_action; - char* log_msg; - char* ptr = connection->stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - GuestErrorT error; - - app_action = &(connection->application_action); - - invocation_id = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - event = guest_heartbeat_mgmt_api_event_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - notify = guest_heartbeat_mgmt_api_notify_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - vote_result = guest_heartbeat_mgmt_api_vote_result_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - log_msg = ptr; - ptr += GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE; - - if (!(app_action->running)) - { - DPRINTFD("No action inprogress."); - return; - } - - if (invocation_id != app_action->invocation_id) - { - DPRINTFE("Unexpected action invocation %i received for %s.", - invocation_id, guest_heartbeat_event_str(event)); - return; - } - - DPRINTFD("Heartbeat Action Response received..."); - - app_action->running = false; - app_action->event = event; - app_action->notify = notify; - app_action->vote_result = vote_result; - snprintf(app_action->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, "%s", - log_msg); - - if (GUEST_TIMER_ID_INVALID != connection->action_timer) - { - error = guest_timer_deregister(connection->action_timer); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action timer, error=%s.", - guest_error_str(error)); - } - - connection->action_timer = GUEST_TIMER_ID_INVALID; - } - - guest_heartbeat_mgmt_api_handle_action_completed(); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Dispatch -// ========================================= -static void guest_heartbeat_mgmt_api_dispatch( int selobj ) -{ - static bool have_start = false; - static bool have_header = false; - static GuestHeartbeatApiMsgHeaderT hdr; - - bool more; - int bytes_received; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse) - if (selobj == connection->sock) - break; - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - DPRINTFE("Uknown selection object %i.", selobj); - close(selobj); - return; - } - - error = guest_unix_receive(connection->sock, connection->stream.end_ptr, - connection->stream.avail, &bytes_received); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to receive message, error=%s.", - guest_error_str(error)); - return; - } - - if (0 == bytes_received) - { - DPRINTFI("Connection closed on %i.", connection->sock); - guest_heartbeat_mgmt_api_close_connection(connection); - return; - } - - DPRINTFD("Bytes received is %i.", bytes_received); - - connection->stream.end_ptr += bytes_received; - connection->stream.avail -= bytes_received; - connection->stream.size += bytes_received; - - do - { - more = false; - - if (!have_start) - { - memset(&hdr, 0 ,sizeof(GuestHeartbeatApiMsgHeaderT)); - have_start = guest_stream_get_next(&(connection->stream)); - } - - if (have_start && !have_header) - { - if (sizeof(GuestHeartbeatApiMsgHeaderT) <= connection->stream.size) - { - char* ptr = connection->stream.bytes - + GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE; - - hdr.version = *(uint8_t*) ptr; - ptr += sizeof(uint8_t); - hdr.revision = *(uint8_t*) ptr; - ptr += sizeof(uint8_t); - hdr.msg_type = *(uint16_t*) ptr; - ptr += sizeof(uint16_t); - hdr.sequence = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - hdr.size = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - - DPRINTFD("Message header: version=%i, revision=%i, " - "msg_type=%i, sequence=%u, size=%u", hdr.version, - hdr.revision, hdr.msg_type, hdr.sequence, hdr.size); - - if (GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT == hdr.version) - { - have_header = true; - } else { - have_start = false; - have_header = false; - guest_stream_advance(GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE, - &connection->stream); - more = true; - } - } - } - - if (have_start && have_header) - { - if (sizeof(GuestHeartbeatApiMsgT) <= connection->stream.size) - { - switch(hdr.msg_type) - { - case GUEST_HEARTBEAT_API_MSG_INIT: - guest_heartbeat_mgmt_api_recv_init(connection); - break; - - case GUEST_HEARTBEAT_API_MSG_FINAL: - guest_heartbeat_mgmt_api_recv_final(connection); - break; - - case GUEST_HEARTBEAT_API_MSG_CHALLENGE_RESPONSE: - guest_heartbeat_mgmt_api_recv_challenge_response(connection); - break; - - case GUEST_HEARTBEAT_API_MSG_ACTION_RESPONSE: - guest_heartbeat_mgmt_api_recv_action_response(connection); - break; - - default: - DPRINTFV("Unknown message type %i.", - (int) hdr.msg_type); - break; - } - - have_start = false; - have_header = false; - guest_stream_advance(sizeof(GuestHeartbeatApiMsgT), - &(connection->stream)); - more = true; - } - } - } while (more); - - if (0 >= connection->stream.avail) - guest_stream_reset(&(connection->stream)); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Connect Handler -// ================================================ -static void guest_heartbeat_mgmt_api_connect_handler( int selobj, char* address ) -{ - int stream_size; - GuestSelObjCallbacksT callbacks; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - DPRINTFD("Connect on socket %i.", selobj); - - // Find unused connection. - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (!connection->inuse) - { - memset(connection, 0, sizeof(GuestHeartbeatMgmtApiConnectionT)); - connection->inuse = true; - connection->registered = false; - connection->sock = selobj; - connection->heartbeat_timer = GUEST_TIMER_ID_INVALID; - connection->heartbeat_timeout_timer = GUEST_TIMER_ID_INVALID; - connection->action_timer = GUEST_TIMER_ID_INVALID; - break; - } - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - // Find unregistered connection and replace. - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if ((connection->inuse) && (!connection->registered)) - { - guest_heartbeat_mgmt_api_close_connection(connection); - connection->inuse = true; - connection->registered = false; - connection->sock = selobj; - break; - } - } - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - DPRINTFE("Failed to allocate connection."); - close(selobj); - return; - } - - stream_size = sizeof(GuestHeartbeatApiMsgT)*4; - if (8192 > stream_size) - stream_size = 8192; - - error = guest_stream_setup(GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE, - stream_size, &(connection->stream)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to setup stream, error=%s.", guest_error_str(error)); - close(connection->sock); - memset(connection, 0, sizeof(GuestHeartbeatMgmtApiConnectionT)); - connection->sock = -1; - connection->heartbeat_timer = GUEST_TIMER_ID_INVALID; - connection->heartbeat_timeout_timer = GUEST_TIMER_ID_INVALID; - connection->action_timer = GUEST_TIMER_ID_INVALID; - - return; - } - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_heartbeat_mgmt_api_dispatch; - - error = guest_selobj_register(connection->sock, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register select on unix socket, error=%s.", - guest_error_str(error)); - close(connection->sock); - guest_stream_release(&(connection->stream)); - memset(connection, 0, sizeof(GuestHeartbeatMgmtApiConnectionT)); - connection->sock = -1; - connection->heartbeat_timer = GUEST_TIMER_ID_INVALID; - connection->heartbeat_timeout_timer = GUEST_TIMER_ID_INVALID; - connection->action_timer = GUEST_TIMER_ID_INVALID; - return; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Get Health -// =========================================== -GuestErrorT guest_heartbeat_mgmt_api_get_health( - bool* health, GuestHeartbeatActionT* corrective_action, char log_msg[], - int log_msg_size ) -{ - GuestHeartbeatMgmtApiAppHealthT* app_health; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestHeartbeatActionT update; - - *health = true; - *corrective_action = GUEST_HEARTBEAT_ACTION_NONE; - log_msg[0] = '\0'; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if ((connection->inuse) && (connection->registered)) - { - app_health = &(connection->application_health); - if (!(app_health->healthy)) - { - update = guest_heartbeat_merge_action( - *corrective_action, app_health->corrective_action); - - if (update == app_health->corrective_action) - { - *health = false; - *corrective_action = update; - snprintf(log_msg, log_msg_size, "%s", app_health->log_msg); - } - } - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action Timeout -// =============================================== -static bool guest_heartbeat_mgmt_api_action_timeout( GuestTimerIdT timer_id ) -{ - GuestHeartbeatMgmtApiAppActionT* app_action; - GuestHeartbeatMgmtApiConnectionT* connection; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse) - if (timer_id == connection->action_timer) - break; - } - - if (GUEST_APPLICATIONS_MAX <= connection_i) - { - DPRINTFE("Uknown timer %i.", timer_id); - return false; // don't rearm - } - - app_action = &(connection->application_action); - - if (app_action->running) - { - app_action->running = false; - app_action->vote_result = GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT; - } - - guest_heartbeat_mgmt_api_handle_action_completed(); - connection->action_timer = GUEST_TIMER_ID_INVALID; - return false; // don't rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action Abort -// ============================================= -void guest_heartbeat_mgmt_api_action_abort( void ) -{ - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppActionT* app_action; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse && connection->registered) - { - app_config = &(connection->application_config); - app_action = &(connection->application_action); - - if (app_action->running) - { - DPRINTFI("Aborting action %s for application %s, " - "notification=%s.", app_config->name, - guest_heartbeat_event_str(app_action->event), - guest_heartbeat_notify_str(app_action->notify)); - } - - app_action->running = false; - - if (GUEST_TIMER_ID_INVALID != connection->action_timer) - { - error = guest_timer_deregister(connection->action_timer); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel action timer, error=%s.", - guest_error_str(error)); - } - connection->action_timer = GUEST_TIMER_ID_INVALID; - } - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action Notify -// ============================================== -GuestErrorT guest_heartbeat_mgmt_api_action_notify( - GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, bool* wait, - GuestHeartbeatMgmtApiActionResponseT callback ) -{ - int action_timeout_ms; - GuestHeartbeatMgmtApiAppConfigT* app_config; - GuestHeartbeatMgmtApiAppActionT* app_action; - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - *wait = false; - _callback = NULL; - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - if (connection->inuse && connection->registered) - { - app_config = &(connection->application_config); - app_action = &(connection->application_action); - - app_action->running = true; - app_action->invocation_id = rand(); - app_action->event = event; - app_action->notify = notify; - app_action->vote_result = GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - - error = guest_heartbeat_mgmt_api_send_action_notify( - connection->sock, app_action->invocation_id, event, - notify ); - if (GUEST_OKAY == error) - { - DPRINTFI("Sent action to appplication %s for event %s, " - "notification=%s.", app_config->name, - guest_heartbeat_event_str(event), - guest_heartbeat_notify_str(notify)); - } else { - DPRINTFE("Failed to send action to application %s for " - "event %s, notification=%s.", app_config->name, - guest_heartbeat_event_str(event), - guest_heartbeat_notify_str(notify)); - } - - if (GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE == notify) - { - switch (event) - { - case GUEST_HEARTBEAT_EVENT_STOP: - case GUEST_HEARTBEAT_EVENT_REBOOT: - action_timeout_ms = app_config->shutdown_notice_ms; - break; - - case GUEST_HEARTBEAT_EVENT_PAUSE: - case GUEST_HEARTBEAT_EVENT_SUSPEND: - case GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN: - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN: - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN: - action_timeout_ms = app_config->suspend_notice_ms; - break; - - case GUEST_HEARTBEAT_EVENT_UNPAUSE: - case GUEST_HEARTBEAT_EVENT_RESUME: - case GUEST_HEARTBEAT_EVENT_RESIZE_END: - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END: - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END: - action_timeout_ms = app_config->resume_notice_ms; - break; - - default: - action_timeout_ms = app_config->shutdown_notice_ms; - break; - } - } else { - action_timeout_ms = app_config->vote_ms; - } - - error = guest_timer_register(action_timeout_ms, - guest_heartbeat_mgmt_api_action_timeout, - &(connection->action_timer)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register action timeout timer, error=%s.", - guest_error_str(error)); - abort(); - } - - *wait = true; - _callback = callback; - } - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Initialize -// =========================================== -GuestErrorT guest_heartbeat_mgmt_api_initialize( void ) -{ - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - memset(&_connections, 0, sizeof(_connections)); - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - connection->sock = -1; - connection->heartbeat_timer = GUEST_TIMER_ID_INVALID; - connection->heartbeat_timeout_timer = GUEST_TIMER_ID_INVALID; - connection->action_timer = GUEST_TIMER_ID_INVALID; - } - - error = guest_unix_open(&_sock); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to open unix socket, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_unix_listen(_sock, GUEST_HEARTBEAT_API_MSG_ADDRESS, - guest_heartbeat_mgmt_api_connect_handler); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to listen on unix socket, error=%s.", - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Finalize -// ========================================= -GuestErrorT guest_heartbeat_mgmt_api_finalize( void ) -{ - GuestHeartbeatMgmtApiConnectionT* connection; - GuestErrorT error; - - if (0 <= _sock) - { - error = guest_selobj_deregister(_sock); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister select on unix socket, error=%s.", - guest_error_str(error)); - } - - error = guest_unix_close(_sock); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to close unix socket, error=%s.", - guest_error_str(error)); - } - _sock = -1; - } - - unsigned int connection_i; - for (connection_i=0; GUEST_APPLICATIONS_MAX > connection_i; ++connection_i) - { - connection = &(_connections[connection_i]); - guest_heartbeat_mgmt_api_close_connection(connection); - } - - memset(&_connections, 0, sizeof(_connections)); - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.h deleted file mode 100755 index d5663322..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HERATBEAT_MGMT_API_H__ -#define __GUEST_HEARTBEAT_MGMT_API_H__ - -#include - -#include "guest_types.h" -#include "guest_heartbeat_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*GuestHeartbeatMgmtApiActionResponseT) - (GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, - GuestHeartbeatVoteResultT vote_result, char log_msg[]); - -// **************************************************************************** -// Guest Heartbeat Management API - Get Health -// =========================================== -extern GuestErrorT guest_heartbeat_mgmt_api_get_health( - bool* health, GuestHeartbeatActionT* corrective_action, char log_msg[], - int log_msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action Abort -// ============================================= -extern void guest_heartbeat_mgmt_api_action_abort( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Action Notify -// ============================================== -extern GuestErrorT guest_heartbeat_mgmt_api_action_notify( - GuestHeartbeatEventT event, GuestHeartbeatNotifyT notify, bool* wait, - GuestHeartbeatMgmtApiActionResponseT callback ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Initialize -// =========================================== -extern GuestErrorT guest_heartbeat_mgmt_api_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Management API - Finalize -// ========================================= -extern GuestErrorT guest_heartbeat_mgmt_api_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_MGMT_API_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.c deleted file mode 100755 index 87aa977d..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* - * Copyright (c) 2013-2018, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_msg_defs.h" -#include "guest_heartbeat_msg.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" -#include "guest_channel.h" -#include "guest_signal.h" -#include "guest_utils.h" - -#include "guest_heartbeat_types.h" - -#define GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS 1 -#define GUEST_HEARTBEAT_CHALLENGE_DEPTH 6 - -static int _signal_fd = -1; -static int _challenge_depth; -static uint32_t _last_tx_challenge[GUEST_HEARTBEAT_CHALLENGE_DEPTH]; -static uint32_t _last_rx_challenge; -static uint32_t _msg_sequence; -static GuestChannelIdT _channel_id = GUEST_CHANNEL_ID_INVALID; -static GuestHeartbeatMsgCallbacksT _callbacks; -// Tokener serves as reassembly buffer for host connection. -static struct json_tokener* tok; - -// **************************************************************************** -// Guest Heartbeat Message - Action (Host to Network) -// ================================================== -static const char *guest_heartbeat_msg_action_hton( - GuestHeartbeatActionT action ) -{ - switch (action) - { - case GUEST_HEARTBEAT_ACTION_NONE: - return GUEST_HEARTBEAT_MSG_ACTION_NONE; - case GUEST_HEARTBEAT_ACTION_REBOOT: - return GUEST_HEARTBEAT_MSG_ACTION_REBOOT; - case GUEST_HEARTBEAT_ACTION_STOP: - return GUEST_HEARTBEAT_MSG_ACTION_STOP; - case GUEST_HEARTBEAT_ACTION_LOG: - return GUEST_HEARTBEAT_MSG_ACTION_LOG; - default: - DPRINTFE("Unknown action %i.", action); - return GUEST_HEARTBEAT_MSG_ACTION_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Action (Network to Host) -// ================================================== -static GuestHeartbeatActionT guest_heartbeat_msg_action_ntoh( - const char *action ) -{ - if (!strcmp(action, GUEST_HEARTBEAT_MSG_ACTION_REBOOT)) - { - return GUEST_HEARTBEAT_ACTION_REBOOT; - } - else if (!strcmp(action, GUEST_HEARTBEAT_MSG_ACTION_STOP)) { - return GUEST_HEARTBEAT_ACTION_STOP; - } - else if (!strcmp(action, GUEST_HEARTBEAT_MSG_ACTION_LOG)) { - return GUEST_HEARTBEAT_ACTION_LOG; - } - else { - DPRINTFE("Unknown action %i.", action); - return GUEST_HEARTBEAT_ACTION_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Event (Host to Network) -// ================================================== -static const char *guest_heartbeat_msg_event_hton( - GuestHeartbeatEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_EVENT_STOP: - return GUEST_HEARTBEAT_MSG_EVENT_STOP; - case GUEST_HEARTBEAT_EVENT_REBOOT: - return GUEST_HEARTBEAT_MSG_EVENT_REBOOT; - case GUEST_HEARTBEAT_EVENT_SUSPEND: - return GUEST_HEARTBEAT_MSG_EVENT_SUSPEND; - case GUEST_HEARTBEAT_EVENT_PAUSE: - return GUEST_HEARTBEAT_MSG_EVENT_PAUSE; - case GUEST_HEARTBEAT_EVENT_UNPAUSE: - return GUEST_HEARTBEAT_MSG_EVENT_UNPAUSE; - case GUEST_HEARTBEAT_EVENT_RESUME: - return GUEST_HEARTBEAT_MSG_EVENT_RESUME; - case GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN: - return GUEST_HEARTBEAT_MSG_EVENT_RESIZE_BEGIN; - case GUEST_HEARTBEAT_EVENT_RESIZE_END: - return GUEST_HEARTBEAT_MSG_EVENT_RESIZE_END; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_MSG_EVENT_LIVE_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END: - return GUEST_HEARTBEAT_MSG_EVENT_LIVE_MIGRATE_END; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_MSG_EVENT_COLD_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END: - return GUEST_HEARTBEAT_MSG_EVENT_COLD_MIGRATE_END; - default: - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_MSG_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Event (Network to Host) -// ================================================= -static GuestHeartbeatEventT guest_heartbeat_msg_event_ntoh( - const char *event ) -{ - if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_STOP)) - { - return GUEST_HEARTBEAT_EVENT_STOP; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_REBOOT)) { - return GUEST_HEARTBEAT_EVENT_REBOOT; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_SUSPEND)) { - return GUEST_HEARTBEAT_EVENT_SUSPEND; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_PAUSE)) { - return GUEST_HEARTBEAT_EVENT_PAUSE; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_UNPAUSE)) { - return GUEST_HEARTBEAT_EVENT_UNPAUSE; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_RESUME)) { - return GUEST_HEARTBEAT_EVENT_RESUME; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_RESIZE_BEGIN)) { - return GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_RESIZE_END)) { - return GUEST_HEARTBEAT_EVENT_RESIZE_END; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_LIVE_MIGRATE_BEGIN)) { - return GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_LIVE_MIGRATE_END)) { - return GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_COLD_MIGRATE_BEGIN)) { - return GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN; - } - else if (!strcmp(event, GUEST_HEARTBEAT_MSG_EVENT_COLD_MIGRATE_END)) { - return GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END; - } - else { - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Notify (Host to Network) -// ================================================== -static const char *guest_heartbeat_msg_notify_hton( - GuestHeartbeatNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_NOTIFY_REVOCABLE: - return GUEST_HEARTBEAT_MSG_NOTIFY_REVOCABLE; - case GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE: - return GUEST_HEARTBEAT_MSG_NOTIFY_IRREVOCABLE; - default: - DPRINTFE("Unknown notify %i.", notify); - return GUEST_HEARTBEAT_MSG_NOTIFY_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Notify (Network to Host) -// ================================================== -static GuestHeartbeatNotifyT guest_heartbeat_msg_notify_ntoh( - const char *notify ) -{ - if (!strcmp(notify, GUEST_HEARTBEAT_MSG_NOTIFY_REVOCABLE)) - { - return GUEST_HEARTBEAT_NOTIFY_REVOCABLE; - } - else if (!strcmp(notify, GUEST_HEARTBEAT_MSG_NOTIFY_IRREVOCABLE)) { - return GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE; - } - else { - DPRINTFE("Unknown notify %i.", notify); - return GUEST_HEARTBEAT_NOTIFY_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Vote Result (Host to Network) -// ======================================================= -static const char * guest_heartbeat_msg_vote_result_hton( - GuestHeartbeatVoteResultT vote_result ) -{ - switch (vote_result) - { - case GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT: - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_ACCEPT; - case GUEST_HEARTBEAT_VOTE_RESULT_REJECT: - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_REJECT; - case GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE: - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_COMPLETE; - case GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT: - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_TIMEOUT; - case GUEST_HEARTBEAT_VOTE_RESULT_ERROR: - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_ERROR; - default: - DPRINTFE("Unknown vote result %i.", vote_result); - return GUEST_HEARTBEAT_MSG_VOTE_RESULT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Vote Result (Network to Host) -// ======================================================= -static GuestHeartbeatVoteResultT guest_heartbeat_msg_vote_result_ntoh( - const char *vote_result ) -{ - if (!strcmp(vote_result, GUEST_HEARTBEAT_MSG_VOTE_RESULT_ACCEPT)) - { - return GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT; - } - else if (!strcmp(vote_result, GUEST_HEARTBEAT_MSG_VOTE_RESULT_REJECT)) { - return GUEST_HEARTBEAT_VOTE_RESULT_REJECT; - } - else if (!strcmp(vote_result, GUEST_HEARTBEAT_MSG_VOTE_RESULT_COMPLETE)) { - return GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE; - } - else if (!strcmp(vote_result, GUEST_HEARTBEAT_MSG_VOTE_RESULT_TIMEOUT)) { - return GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT; - } - else if (!strcmp(vote_result, GUEST_HEARTBEAT_MSG_VOTE_RESULT_ERROR)) { - return GUEST_HEARTBEAT_VOTE_RESULT_ERROR; - } - else { - DPRINTFE("Unknown vote result %i.", vote_result); - return GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Init -// =================================== -GuestErrorT guest_heartbeat_msg_send_init( - int invocation_id, GuestHeartbeatMsgInitDataT* data ) -{ - GuestErrorT error; - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d,\"%s\":\"%s\"," - "\"%s\":%d,\"%s\":%d,\"%s\":%d,\"%s\":%d,\"%s\":%d,\"%s\":%d," - "\"%s\":\"%s\"}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_INIT, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_INVOCATION_ID, invocation_id, - GUEST_HEARTBEAT_MSG_NAME, data->name, - - GUEST_HEARTBEAT_MSG_HEARTBEAT_INTERVAL_MS, - data->heartbeat_interval_ms, - GUEST_HEARTBEAT_MSG_VOTE_SECS, - data->vote_ms/1000 + GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS, - GUEST_HEARTBEAT_MSG_SHUTDOWN_NOTICE_SECS, - data->shutdown_notice_ms/1000 + GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS, - GUEST_HEARTBEAT_MSG_SUSPEND_NOTICE_SECS, - data->suspend_notice_ms/1000 + GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS, - GUEST_HEARTBEAT_MSG_RESUME_NOTICE_SECS, - data->resume_notice_ms/1000 + GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS, - GUEST_HEARTBEAT_MSG_RESTART_SECS, - data->restart_ms/1000 + GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS, - - GUEST_HEARTBEAT_MSG_CORRECTIVE_ACTION, - guest_heartbeat_msg_action_hton(data->corrective_action)); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat init message, error=%s.", - guest_error_str(error)); - return error; - } - - DPRINTFI("Sent heartbeat init message, invocation_id=%i.", invocation_id); - DPRINTFD("Sent heartbeat init message: %s", msg); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Init Ack -// ======================================= -GuestErrorT guest_heartbeat_msg_send_init_ack( int invocation_id ) -{ - GuestErrorT error; - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_INIT_ACK, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_INVOCATION_ID, invocation_id); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat init ack message, error=%s.", - guest_error_str(error)); - return error; - } - - DPRINTFI("Sent heartbeat init ack message: %s", msg); - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Exit -// =================================== -GuestErrorT guest_heartbeat_msg_send_exit( char log_msg[] ) -{ - GuestErrorT error; - - char log_msg_buf[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - snprintf(log_msg_buf, GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE, "%s", - guest_utils_remove_newline(log_msg)); - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":\"%s\"}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_EXIT, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_LOG_MSG, log_msg_buf); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat exit message, error=%s.", - guest_error_str(error)); - return error; - } - - DPRINTFI("Sent heartbeat exit message: %s", msg); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Challenge -// ======================================== -GuestErrorT guest_heartbeat_msg_send_challenge( void ) -{ - GuestErrorT error; - - ++_challenge_depth; - if (GUEST_HEARTBEAT_CHALLENGE_DEPTH <= _challenge_depth) - _challenge_depth = 0; - - _last_tx_challenge[_challenge_depth] = rand(); - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_CHALLENGE, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_HEARTBEAT_CHALLENGE, _last_tx_challenge[_challenge_depth]); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat challenge message, " - "error=%s.", guest_error_str(error)); - return error; - } - - DPRINTFD("Sent heartbeat challenge message, challenge=%i.", - _last_tx_challenge[_challenge_depth]); - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Challenge Response -// ================================================= -GuestErrorT guest_heartbeat_msg_send_challenge_response( - bool health, GuestHeartbeatActionT corrective_action, char log_msg[] ) -{ - GuestErrorT error; - - char log_msg_buf[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - snprintf(log_msg_buf, GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE, "%s", - guest_utils_remove_newline(log_msg)); - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d,\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\"}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_CHALLENGE_RESPONSE, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_HEARTBEAT_RESPONSE, _last_rx_challenge, - GUEST_HEARTBEAT_MSG_HEARTBEAT_HEALTH, - health ? GUEST_HEARTBEAT_MSG_HEALTHY : GUEST_HEARTBEAT_MSG_UNHEALTHY, - GUEST_HEARTBEAT_MSG_CORRECTIVE_ACTION, - guest_heartbeat_msg_action_hton(corrective_action), - GUEST_HEARTBEAT_MSG_LOG_MSG, log_msg_buf); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat challenge response message, " - "error=%s.", guest_error_str(error)); - return error; - } - // print info logs with message content only if not healthy - if (!health) - { - DPRINTFI("Unhealthy, sent heartbeat challenge response message: %s", msg); - } - else { - DPRINTFD("Sent heartbeat challenge response message, challenge=%i.", - _last_rx_challenge); - } - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Action Notify -// ============================================ -GuestErrorT guest_heartbeat_msg_send_action_notify( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, int timeout_ms ) -{ - GuestErrorT error; - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d,\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":%d}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_ACTION_NOTIFY, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_INVOCATION_ID, invocation_id, - GUEST_HEARTBEAT_MSG_EVENT_TYPE, guest_heartbeat_msg_event_hton(event), - GUEST_HEARTBEAT_MSG_NOTIFICATION_TYPE, guest_heartbeat_msg_notify_hton(notify), - GUEST_HEARTBEAT_MSG_TIMEOUT_MS, timeout_ms); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat action notify message, " - "error=%s.", guest_error_str(error)); - return error; - } - - DPRINTFI("Sent heartbeat action notify message, invocation_id=%i.", - invocation_id); - DPRINTFD("Sent heartbeat action notify message: %s", msg); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Action Response -// ============================================== -GuestErrorT guest_heartbeat_msg_send_action_response( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, GuestHeartbeatVoteResultT vote_result, - char log_msg[] ) -{ - GuestErrorT error; - - char log_msg_buf[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - snprintf(log_msg_buf, GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE, "%s", - guest_utils_remove_newline(log_msg)); - - - char msg[GUEST_HEARTBEAT_MSG_MAX_MSG_SIZE]; - snprintf(msg, sizeof(msg), "\n{\"%s\":%d,\"%s\":%d,\"%s\":\"%s\",\"%s\":%d," - "\"%s\":%d,\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\"}\n", - GUEST_HEARTBEAT_MSG_VERSION, GUEST_HEARTBEAT_MSG_VERSION_CURRENT, - GUEST_HEARTBEAT_MSG_REVISION, GUEST_HEARTBEAT_MSG_REVISION_CURRENT, - GUEST_HEARTBEAT_MSG_MSG_TYPE, GUEST_HEARTBEAT_MSG_ACTION_RESPONSE, - GUEST_HEARTBEAT_MSG_SEQUENCE, ++_msg_sequence, - - GUEST_HEARTBEAT_MSG_INVOCATION_ID, invocation_id, - GUEST_HEARTBEAT_MSG_EVENT_TYPE, guest_heartbeat_msg_event_hton(event), - GUEST_HEARTBEAT_MSG_NOTIFICATION_TYPE, guest_heartbeat_msg_notify_hton(notify), - GUEST_HEARTBEAT_MSG_VOTE_RESULT, guest_heartbeat_msg_vote_result_hton(vote_result), - GUEST_HEARTBEAT_MSG_LOG_MSG, log_msg_buf); - - error = guest_channel_send(_channel_id, msg, strlen(msg)); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat action response message, " - "error=%s.", guest_error_str(error)); - return error; - } - - DPRINTFI("Sent heartbeat action response message: %s", msg); - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Init -// ====================================== -static void guest_heartbeat_msg_recv_init( struct json_object *jobj_msg ) -{ - char name[GUEST_HEARTBEAT_MSG_MAX_NAME_SIZE]; - uint32_t invocation_id; - char corrective_action[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - GuestHeartbeatMsgInitDataT data; - uint32_t vote_secs, shutdown_notice_secs, suspend_notice_secs; - uint32_t resume_notice_secs, restart_secs; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_INVOCATION_ID, &invocation_id)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_NAME, &name)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_HEARTBEAT_INTERVAL_MS, &data.heartbeat_interval_ms)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_VOTE_SECS, &vote_secs)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_SHUTDOWN_NOTICE_SECS, &shutdown_notice_secs)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_SUSPEND_NOTICE_SECS, &suspend_notice_secs)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_RESUME_NOTICE_SECS, &resume_notice_secs)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_RESTART_SECS, &restart_secs)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_CORRECTIVE_ACTION, &corrective_action)) - return; - - data.vote_ms = vote_secs*1000; - data.shutdown_notice_ms = shutdown_notice_secs*1000; - data.suspend_notice_ms = suspend_notice_secs*1000; - data.resume_notice_ms= resume_notice_secs*1000; - data.restart_ms = restart_secs*1000; - - snprintf(data.name, GUEST_NAME_MAX_CHAR, "%s", name); - data.corrective_action = guest_heartbeat_msg_action_ntoh(corrective_action); - - DPRINTFI("Heartbeat Init received, invocation_id=%i", invocation_id); - - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Init message received: %s", msg); - - if (NULL != _callbacks.recv_init) - _callbacks.recv_init(invocation_id, &data); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Init Ack -// ========================================== -static void guest_heartbeat_msg_recv_init_ack( struct json_object *jobj_msg ) -{ - uint32_t invocation_id; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_INVOCATION_ID, &invocation_id)) - return; - - DPRINTFI("Heartbeat Init Ack received, invocation_id=%i.", - invocation_id); - - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Init Ack message received: %s", msg); - - if (NULL != _callbacks.recv_init_ack) - _callbacks.recv_init_ack(invocation_id); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Exit -// ====================================== -static void guest_heartbeat_msg_recv_exit( struct json_object *jobj_msg ) -{ - char log_msg[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_LOG_MSG, &log_msg)) - return; - - DPRINTFI("Heartbeat Exit received, msg=%s.", log_msg); - - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Exit message received: %s", msg); - - if (NULL != _callbacks.recv_exit) - _callbacks.recv_exit(log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Challenge -// =========================================== -static void guest_heartbeat_msg_recv_challenge( struct json_object *jobj_msg ) -{ - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_HEARTBEAT_CHALLENGE, &_last_rx_challenge)) - return; - - DPRINTFD("Heartbeat Challenge received, challenge=%i.", _last_rx_challenge); - - if (NULL != _callbacks.recv_challenge) - _callbacks.recv_challenge(); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Challenge Ack -// =============================================== -static void guest_heartbeat_msg_recv_challenge_ack( struct json_object *jobj_msg ) -{ - char health[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - char corrective_action_str[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - GuestHeartbeatActionT corrective_action; - char log_msg[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_HEARTBEAT_RESPONSE, &_last_rx_challenge)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_HEARTBEAT_HEALTH, &health)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_CORRECTIVE_ACTION, &corrective_action_str)) - return; - - corrective_action = guest_heartbeat_msg_action_ntoh(corrective_action_str); - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_LOG_MSG, &log_msg)) - return; - - DPRINTFD("Heartbeat Challenge Response received, challenge=%i.", - _last_rx_challenge); - - unsigned int challenge_i; - for (challenge_i=0; GUEST_HEARTBEAT_CHALLENGE_DEPTH > challenge_i; - ++challenge_i) - { - if (_last_tx_challenge[challenge_i] == _last_rx_challenge) - break; - } - - if (GUEST_HEARTBEAT_CHALLENGE_DEPTH == challenge_i) - { - DPRINTFE("Mismatch between last transmitted challenges and last " - "received challenge."); - return; - } - if (NULL != _callbacks.recv_challenge_ack) - _callbacks.recv_challenge_ack(!strcmp(health, GUEST_HEARTBEAT_MSG_HEALTHY), - corrective_action, log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Action Notify -// =============================================== -static void guest_heartbeat_msg_recv_action_notify( struct json_object *jobj_msg ) -{ - uint32_t invocation_id; - char event_type[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - char notification_type[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - uint32_t timeout_ms; - GuestHeartbeatEventT event; - GuestHeartbeatNotifyT notify; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_INVOCATION_ID, &invocation_id)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_EVENT_TYPE, &event_type)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_NOTIFICATION_TYPE, ¬ification_type)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_TIMEOUT_MS, &timeout_ms)) - return; - - if (timeout_ms > (GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS*1000)) - timeout_ms -= (GUEST_HEARTBEAT_PROPAGATION_DELAY_IN_SECS * 1000); - - event = guest_heartbeat_msg_event_ntoh(event_type); - notify = guest_heartbeat_msg_notify_ntoh(notification_type); - - DPRINTFI("Heartbeat Action Notify received, invocation_id=%i.", - invocation_id); - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Action Notify message received: %s", msg); - - if (NULL != _callbacks.recv_action_notify) - _callbacks.recv_action_notify(invocation_id, event, notify, timeout_ms); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Action Response -// ================================================= -static void guest_heartbeat_msg_recv_action_response( struct json_object *jobj_msg ) -{ - uint32_t invocation_id; - char event_type[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - char notification_type[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - char vote_result[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - GuestHeartbeatEventT event; - GuestHeartbeatNotifyT notify; - GuestHeartbeatVoteResultT result; - char log_msg[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_INVOCATION_ID, &invocation_id)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_EVENT_TYPE, &event_type)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_NOTIFICATION_TYPE, ¬ification_type)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_VOTE_RESULT, &vote_result)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_LOG_MSG, &log_msg)) - return; - - event = guest_heartbeat_msg_event_ntoh(event_type); - notify = guest_heartbeat_msg_notify_ntoh(notification_type); - result = guest_heartbeat_msg_vote_result_ntoh(vote_result); - - DPRINTFI("Heartbeat Action Response received, invocation_id=%i.", - invocation_id); - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Action Response message received: %s", msg); - - if (NULL != _callbacks.recv_action_response) - _callbacks.recv_action_response(invocation_id, event, notify, - result, log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive Nack -// ================================================= -static void guest_heartbeat_msg_recv_nack( struct json_object *jobj_msg ) -{ - uint32_t invocation_id; - char log_msg[GUEST_HEARTBEAT_MSG_MAX_LOG_SIZE]; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_INVOCATION_ID, &invocation_id)) - return; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_LOG_MSG, &log_msg)) - return; - - DPRINTFE("Heartbeat Nack message received, invocation_id=%i, error msg: %s", - invocation_id, log_msg); - - const char *msg = json_object_to_json_string_ext(jobj_msg, JSON_C_TO_STRING_PLAIN); - DPRINTFD("Heartbeat Nack message received: %s", msg); - -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Dispatch -// ================================== -void guest_heartbeat_msg_dispatch(json_object *jobj_msg) -{ - int version; - char msg_type[GUEST_HEARTBEAT_MSG_MAX_VALUE_SIZE]; - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_VERSION, &version)) - return; - - if (GUEST_HEARTBEAT_MSG_VERSION_CURRENT > version) - { - DPRINTFI("message received version %d, expected %d, dropping\n", - version, GUEST_HEARTBEAT_MSG_VERSION_CURRENT); - return; - } - - if (guest_utils_json_get_value(jobj_msg, GUEST_HEARTBEAT_MSG_MSG_TYPE, &msg_type)) - return; - - if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_INIT)) { - guest_heartbeat_msg_recv_init(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_INIT_ACK)) { - guest_heartbeat_msg_recv_init_ack(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_EXIT)) { - guest_heartbeat_msg_recv_exit(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_CHALLENGE)) { - guest_heartbeat_msg_recv_challenge(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_CHALLENGE_RESPONSE)) { - guest_heartbeat_msg_recv_challenge_ack(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_ACTION_NOTIFY)) { - guest_heartbeat_msg_recv_action_notify(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_ACTION_RESPONSE)) { - guest_heartbeat_msg_recv_action_response(jobj_msg); - } else if (!strcmp(msg_type, GUEST_HEARTBEAT_MSG_NACK)) { - guest_heartbeat_msg_recv_nack(jobj_msg); - } else { - DPRINTFV("Unknown message type %s.", msg_type); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Parser -// ================================== -/** - Multiple messages from the host can be bundled together into a single "read" - so we need to check message boundaries and handle breaking the message apart. - Assume a valid message does not contain newline '\n', and newline is added to - the beginning and end of each message by the sender to delimit the boundaries. -*/ -void guest_heartbeat_msg_parser(void *buf, ssize_t len, json_tokener* tok, int newline_found) -{ - json_object *jobj = json_tokener_parse_ex(tok, buf, len); - enum json_tokener_error jerr = json_tokener_get_error(tok); - - if (jerr == json_tokener_success) { - guest_heartbeat_msg_dispatch(jobj); - json_object_put(jobj); - return; - } - - else if (jerr == json_tokener_continue) { - // partial JSON is parsed , continue to read from socket. - if (newline_found) { - // if newline was found in the middle of the buffer, the message - // should be completed at this point. Throw out incomplete message - // by resetting tokener. - json_tokener_reset(tok); - } - } - else - { - // parsing error - json_tokener_reset(tok); - } -} -// **************************************************************************** - - -// **************************************************************************** -// Guest Heartbeat Message - Handler -// ================================== -void guest_heartbeat_msg_handler(void *buf, ssize_t len,json_tokener* tok) -{ - void *newline; - ssize_t len_head; - -next: - if (len == 0) - return; - - // search for newline as delimiter - newline = memchr(buf, '\n', len); - - if (newline) { - // split buffer to head and tail at the location of newline. - // feed the head to the parser and recursively process the tail. - len_head = newline-buf; - - // parse head - if (len_head > 0) - guest_heartbeat_msg_parser(buf, len_head, tok, 1); - - // start of the tail: skip newline - buf += len_head+1; - // length of the tail: deduct 1 for the newline character - len -= len_head+1; - - // continue to process the tail. - goto next; - } - else { - guest_heartbeat_msg_parser(buf, len, tok, 0); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Receive -// ================================== -static void guest_heartbeat_msg_receiver( int selobj ) -{ - int bytes_received; - GuestErrorT error; - char buf[4096]; - - error = guest_channel_receive(_channel_id, buf, sizeof(buf), - &bytes_received); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to receive message, error=%s.", - guest_error_str(error)); - return; - } - - DPRINTFV("Bytes received is %i.", bytes_received); - guest_heartbeat_msg_handler(buf, bytes_received, tok); - -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Signal Handler -// ======================================== -static void guest_heartbeat_msg_signal_handler( int signum ) -{ - int64_t sigval = signum; - int result; - - if ((SIGIO == signum) && (0 <= _signal_fd)) - { - result = write(_signal_fd, &sigval, sizeof(sigval)); - if (0 > result) - { - DPRINTFE("Failed to write signal, error=%s", strerror(errno)); - return; - } - - guest_signal_ignore(signum); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Hangup -// ================================ -static void guest_heartbeat_msg_hangup( int selobj ) -{ - DPRINTFI("Heartbeat messaging hangup."); - - if (GUEST_CHANNEL_ID_INVALID != _channel_id) - { - int selobj; - - selobj = guest_channel_get_selobj(_channel_id); - if (0 <= selobj) - { - GuestErrorT error; - - error = guest_selobj_deregister(selobj); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister selection object %i, " - "error=%s.", selobj, guest_error_str(error)); - } - - guest_signal_register_handler(SIGIO, - guest_heartbeat_msg_signal_handler); - - if (NULL != _callbacks.channel_state_change) - _callbacks.channel_state_change(false); - } - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Signal Dispatch -// ========================================= -static void guest_heartbeat_msg_signal_dispatch( int selobj ) -{ - int signum; - int64_t sigval = 0; - int result; - GuestSelObjCallbacksT callbacks; - GuestErrorT error; - - result = read(_signal_fd, &sigval, sizeof(sigval)); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on signal read, error=%s.", strerror(errno)); - } else { - DPRINTFE("Failed to dispatch signal, error=%s.", strerror(errno)); - } - return; - } - - signum = sigval; - - if (SIGIO == signum) - { - DPRINTFI("Heartbeat messaging available."); - - if (GUEST_CHANNEL_ID_INVALID != _channel_id) - { - selobj = guest_channel_get_selobj(_channel_id); - if (0 <= selobj) - { - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_heartbeat_msg_receiver; - callbacks.hangup_callback = guest_heartbeat_msg_hangup; - - error = guest_selobj_register(selobj, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object %i, " - "error=%s.", selobj, guest_error_str(error)); - abort(); - } - - if (NULL != _callbacks.channel_state_change) - _callbacks.channel_state_change(true); - } - } - } else { - DPRINTFI("Ignoring signal %i.", signum); - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Initialize -// ==================================== -GuestErrorT guest_heartbeat_msg_initialize( - char* comm_device, GuestHeartbeatMsgCallbacksT* callbacks ) -{ - int selobj; - GuestSelObjCallbacksT selobj_callbacks; - GuestErrorT error; - - _channel_id = GUEST_CHANNEL_ID_INVALID; - - error = guest_channel_open(comm_device, &_channel_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to open communication channel over device %s, " - "error=%s.", comm_device, guest_error_str(error)); - return error; - } - - selobj = guest_channel_get_selobj(_channel_id); - if (0 <= selobj) - { - memset(&selobj_callbacks, 0, sizeof(selobj_callbacks)); - selobj_callbacks.read_callback = guest_heartbeat_msg_receiver; - selobj_callbacks.hangup_callback = guest_heartbeat_msg_hangup; - - error = guest_selobj_register(selobj, &selobj_callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object %i, error=%s.", - selobj, guest_error_str(error)); - return error; - } - } - - _signal_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); - if (0 > _signal_fd) - { - DPRINTFE("Failed to open signal file descriptor,error=%s.", - strerror(errno)); - return GUEST_FAILED; - } - - memset(&selobj_callbacks, 0, sizeof(selobj_callbacks)); - selobj_callbacks.read_callback = guest_heartbeat_msg_signal_dispatch; - - error = guest_selobj_register(_signal_fd, &selobj_callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register selection object, error=%s.", - guest_error_str(error)); - close(_signal_fd); - _signal_fd = -1; - return error; - } - - memcpy(&_callbacks, callbacks, sizeof(GuestHeartbeatMsgCallbacksT)); - - tok = json_tokener_new(); - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Finalize -// ================================== -GuestErrorT guest_heartbeat_msg_finalize( void ) -{ - int selobj; - GuestErrorT error; - - memset(&_callbacks, 0, sizeof(GuestHeartbeatMsgCallbacksT)); - free(tok); - - if (0 <= _signal_fd) - { - error = guest_selobj_deregister(_signal_fd); - if (GUEST_OKAY != error) - DPRINTFE("Failed to deregister selection object, error=%s.", - guest_error_str(error)); - - close(_signal_fd); - _signal_fd = -1; - } - - if (GUEST_CHANNEL_ID_INVALID != _channel_id) - { - selobj = guest_channel_get_selobj(_channel_id); - if (0 <= selobj) - { - error = guest_selobj_deregister(selobj); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister selection object %i, error=%s.", - selobj, guest_error_str(error)); - } - } - - error = guest_channel_close(_channel_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed close communication channel, error=%s.", - guest_error_str(error)); - } - _channel_id = GUEST_CHANNEL_ID_INVALID; - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.h deleted file mode 100755 index 4bb296c3..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HERATBEAT_MESSAGE_H__ -#define __GUEST_HEARTBEAT_MESSAGE_H__ - -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" - -#include "guest_heartbeat_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_HEARTBEAT_MAX_LOG_MSG_SIZE 192 - -typedef struct { - char name[GUEST_NAME_MAX_CHAR]; - unsigned int heartbeat_interval_ms; - unsigned int vote_ms; - unsigned int shutdown_notice_ms; - unsigned int suspend_notice_ms; - unsigned int resume_notice_ms; - unsigned int restart_ms; - GuestHeartbeatActionT corrective_action; -} GuestHeartbeatMsgInitDataT; - -typedef void (*GuestHeartbeatMsgChannelStateChangeT) (bool state); -typedef void (*GuestHeartbeatMsgRecvInitT) - (int invocation_id, GuestHeartbeatMsgInitDataT* data); -typedef void (*GuestHeartbeatMsgRecvInitAckT) (int invocation_id); -typedef void (*GuestHeartbeatMsgRecvExitT) (char log_msg[]); -typedef void (*GuestHeartbeatMsgRecvChallengeT) (void); -typedef void (*GuestHeartbeatMsgRecvChallengeAckT) - (bool health, GuestHeartbeatActionT corrective_action, char log_msg[]); -typedef void (*GuestHeartbeatMsgRecvActionNotifyT) - (int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, int timeout_ms); -typedef void (*GuestHeartbeatMsgRecvActionResponseT) - (int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, GuestHeartbeatVoteResultT vote_result, - char log_msg[]); - -typedef struct { - GuestHeartbeatMsgChannelStateChangeT channel_state_change; - GuestHeartbeatMsgRecvInitT recv_init; - GuestHeartbeatMsgRecvInitAckT recv_init_ack; - GuestHeartbeatMsgRecvExitT recv_exit; - GuestHeartbeatMsgRecvChallengeT recv_challenge; - GuestHeartbeatMsgRecvChallengeAckT recv_challenge_ack; - GuestHeartbeatMsgRecvActionNotifyT recv_action_notify; - GuestHeartbeatMsgRecvActionResponseT recv_action_response; -} GuestHeartbeatMsgCallbacksT; - -// **************************************************************************** -// Guest Heartbeat Message - Send Init -// =================================== -extern GuestErrorT guest_heartbeat_msg_send_init( int invocation_id, - GuestHeartbeatMsgInitDataT* data ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Init Ack -// ======================================= -extern GuestErrorT guest_heartbeat_msg_send_init_ack( int invocation_id ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Exit -// =================================== -extern GuestErrorT guest_heartbeat_msg_send_exit( char log_msg[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Challenge -// ======================================== -extern GuestErrorT guest_heartbeat_msg_send_challenge( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Challenge Response -// ================================================= -extern GuestErrorT guest_heartbeat_msg_send_challenge_response( - bool health, GuestHeartbeatActionT corrective_action, char log_msg[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Action Notify -// ============================================ -extern GuestErrorT guest_heartbeat_msg_send_action_notify( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, int timeout_ms ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Send Action Response -// ============================================== -GuestErrorT guest_heartbeat_msg_send_action_response( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, GuestHeartbeatVoteResultT vote_result, - char log_msg[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Initialize -// ==================================== -extern GuestErrorT guest_heartbeat_msg_initialize( - char* comm_device, GuestHeartbeatMsgCallbacksT* callbacks ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Message - Finalize -// ================================== -extern GuestErrorT guest_heartbeat_msg_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_MESSAGE_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.c b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.c deleted file mode 100755 index 6edcc9c8..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_types.h" - -// **************************************************************************** -// Guest Heartbeat Types - Action String -// ===================================== -const char* guest_heartbeat_action_str( GuestHeartbeatActionT action ) -{ - switch (action) - { - case GUEST_HEARTBEAT_ACTION_NONE: return "none"; - case GUEST_HEARTBEAT_ACTION_REBOOT: return "reboot"; - case GUEST_HEARTBEAT_ACTION_STOP: return "stop"; - case GUEST_HEARTBEAT_ACTION_LOG: return "log"; - default: - return "action-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Event String -// ==================================== -const char* guest_heartbeat_event_str( GuestHeartbeatEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_EVENT_STOP: return "stop"; - case GUEST_HEARTBEAT_EVENT_REBOOT: return "reboot"; - case GUEST_HEARTBEAT_EVENT_SUSPEND: return "suspend"; - case GUEST_HEARTBEAT_EVENT_PAUSE: return "pause"; - case GUEST_HEARTBEAT_EVENT_UNPAUSE: return "unpause"; - case GUEST_HEARTBEAT_EVENT_RESUME: return "resume"; - case GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN: return "resize-begin"; - case GUEST_HEARTBEAT_EVENT_RESIZE_END: return "resize-end"; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN: return "live-migrate-begin"; - case GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END: return "live-migrate-end"; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN: return "cold-migrate-begin"; - case GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END: return "cold-migrate-end"; - default: - return "event-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Notify String -// ===================================== -const char* guest_heartbeat_notify_str( GuestHeartbeatNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_NOTIFY_REVOCABLE: return "revocable"; - case GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE: return "irrevocable"; - default: - return "notify-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Vote Result String -// ========================================== -const char* guest_heartbeat_vote_result_str( GuestHeartbeatVoteResultT result ) -{ - switch (result) - { - case GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT: return "accept"; - case GUEST_HEARTBEAT_VOTE_RESULT_REJECT: return "reject"; - case GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE: return "complete"; - case GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT: return "timeout"; - case GUEST_HEARTBEAT_VOTE_RESULT_ERROR: return "error"; - default: - return "vote-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Merge Action -// ==================================== -GuestHeartbeatActionT guest_heartbeat_merge_action( - GuestHeartbeatActionT current_action, GuestHeartbeatActionT new_action ) -{ - switch (new_action) - { - case GUEST_HEARTBEAT_ACTION_STOP: - return new_action; - - case GUEST_HEARTBEAT_ACTION_REBOOT: - if (GUEST_HEARTBEAT_ACTION_STOP != current_action) - return new_action; - return current_action; - - case GUEST_HEARTBEAT_ACTION_LOG: - if ((GUEST_HEARTBEAT_ACTION_STOP != current_action) && - (GUEST_HEARTBEAT_ACTION_REBOOT != current_action)) - return new_action; - return current_action; - - default: - return current_action; - } -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.h b/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.h deleted file mode 100755 index bf0a5463..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_TYPES_H__ -#define __GUEST_HEARTBEAT_TYPES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_HEARTBEAT_ACTION_UNKNOWN, - GUEST_HEARTBEAT_ACTION_NONE, - GUEST_HEARTBEAT_ACTION_REBOOT, - GUEST_HEARTBEAT_ACTION_STOP, - GUEST_HEARTBEAT_ACTION_LOG, - GUEST_HEARTBEAT_ACTION_MAX, -} GuestHeartbeatActionT; - -typedef enum { - GUEST_HEARTBEAT_EVENT_UNKNOWN, - GUEST_HEARTBEAT_EVENT_STOP, - GUEST_HEARTBEAT_EVENT_REBOOT, - GUEST_HEARTBEAT_EVENT_SUSPEND, - GUEST_HEARTBEAT_EVENT_PAUSE, - GUEST_HEARTBEAT_EVENT_UNPAUSE, - GUEST_HEARTBEAT_EVENT_RESUME, - GUEST_HEARTBEAT_EVENT_RESIZE_BEGIN, - GUEST_HEARTBEAT_EVENT_RESIZE_END, - GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_BEGIN, - GUEST_HEARTBEAT_EVENT_LIVE_MIGRATE_END, - GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_BEGIN, - GUEST_HEARTBEAT_EVENT_COLD_MIGRATE_END, - GUEST_HEARTBEAT_EVENT_MAX, -} GuestHeartbeatEventT; - -typedef enum { - GUEST_HEARTBEAT_NOTIFY_UNKNOWN, - GUEST_HEARTBEAT_NOTIFY_REVOCABLE, - GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE, - GUEST_HEARTBEAT_NOTIFY_MAX, -} GuestHeartbeatNotifyT; - -typedef enum { - GUEST_HEARTBEAT_VOTE_RESULT_UNKNOWN, - GUEST_HEARTBEAT_VOTE_RESULT_ACCEPT, - GUEST_HEARTBEAT_VOTE_RESULT_REJECT, - GUEST_HEARTBEAT_VOTE_RESULT_COMPLETE, - GUEST_HEARTBEAT_VOTE_RESULT_TIMEOUT, - GUEST_HEARTBEAT_VOTE_RESULT_ERROR, - GUEST_HEARTBEAT_VOTE_RESULT_MAX, -} GuestHeartbeatVoteResultT; - -// **************************************************************************** -// Guest Heartbeat Types - Action String -// ===================================== -extern const char* guest_heartbeat_action_str( GuestHeartbeatActionT action ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Event String -// ==================================== -extern const char* guest_heartbeat_event_str( GuestHeartbeatEventT event ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Notify String -// ===================================== -extern const char* guest_heartbeat_notify_str( GuestHeartbeatNotifyT notify ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Vote Result String -// ========================================== -extern const char* guest_heartbeat_vote_result_str( GuestHeartbeatVoteResultT result ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Types - Merge Action -// ==================================== -extern GuestHeartbeatActionT guest_heartbeat_merge_action( - GuestHeartbeatActionT current_action, GuestHeartbeatActionT new_action ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_TYPES_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/Makefile b/guest-client/guest-client-3.0.1/guest_client/src/test/Makefile deleted file mode 100755 index b58cb799..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -## Configuration Directory Variables -prefix := /usr/local -exec_prefix := $(prefix) -sysconfdir := $(prefix)/etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) -BUILD_DIR := $(CURRENT_DIR)/build - -.SUFFIXES: -.SUFFIXES: .c .o - -.PHONY: all build create_build_dir clean distclean - -program_NAME := guest-client-test -program_C_INCLUDES := -I$(CURRENT_DIR) -I$(CURRENT_DIR)/../ -program_C_INCLUDES += -I$(CURRENT_DIR)/../heartbeat -program_C_INCLUDES += -I$(CURRENT_DIR)/../../include -program_C_SRCS := $(wildcard *.c) -program_C_OBJS := ${program_C_SRCS:.c=.o} -program_LDLIBS := -lrt - -CFLAGS = -g -O2 -Wall -Werror -Wformat -DSYSCONFDIR=$(sysconfdir) - -all: build - -%.o: %.c - $(CC) $(CFLAGS) $(program_C_INCLUDES) -c $^ -o $(BUILD_DIR)/$@ -ljson-c - -$(program_NAME): $(program_C_OBJS) - @(cd ../; make --no-print-directory build sysconfdir=$(sysconfdir) BUILD_DIR=$(BUILD_DIR)) - @-($(RM) $(BUILD_DIR)/guest_client.o $(BUILD_DIR)/guest-client) - $(CC) $(CFLAGS) $(BUILD_DIR)/*.o $(program_LDLIBS) -o $(BUILD_DIR)/$(program_NAME) -ljson-c - -create_build_dir: - mkdir -p --mode 755 $(BUILD_DIR) - -build: create_build_dir $(program_NAME) - -clean: - @-($(RM) $(BUILD_DIR)/*) - -distclean: clean diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.c b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.c deleted file mode 100755 index a321f372..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_test.h" - -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_timer.h" - -#include "guest_heartbeat_types.h" -#include "guest_heartbeat_msg.h" - -static bool _challenge_response_recvd = false; -static GuestTimerIdT _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; -static GuestTimerIdT _heartbeat_timeout_timer_id = GUEST_TIMER_ID_INVALID; - -// **************************************************************************** -// Guest Heartbeat - Timeout -// ========================= -static bool guest_heartbeat_timeout( GuestTimerIdT timer_id ) -{ - GuestErrorT error; - - DPRINTFE("--------> HEARTBEAT TIMEOUT <--------"); - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timer_id) - { - error = guest_timer_deregister(_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; - } - - return false; // don't rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Periodic -// ========================== -static bool guest_heartbeat_periodic( GuestTimerIdT timer_id ) -{ - GuestErrorT error; - - if (_challenge_response_recvd) - { - error = guest_heartbeat_msg_send_challenge(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send challenge, error=%s.", - guest_error_str(error)); - } - _challenge_response_recvd = false; - } - return true; // rearm -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Init Message -// ====================================== -static void guest_heartbeat_recv_init_msg( - int invocation_id, GuestHeartbeatMsgInitDataT* data ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timer_id) - { - error = guest_timer_deregister(_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; - } - - error = guest_timer_register(data->heartbeat_interval_ms, - guest_heartbeat_periodic, - &_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start heartbeat timer, error=%s.", - guest_error_str(error)); - return; - } - - error = guest_heartbeat_msg_send_init_ack(invocation_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send init ack, error=%s.", guest_error_str(error)); - } - - error = guest_heartbeat_msg_send_challenge(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to send challenge, error=%s.", guest_error_str(error)); - } - - _challenge_response_recvd = false; - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timeout_timer_id) - { - error = guest_timer_deregister(_heartbeat_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timeout timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - error = guest_timer_register(data->heartbeat_interval_ms*2, - guest_heartbeat_timeout, - &_heartbeat_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to start heartbeat timeout timer, error=%s.", - guest_error_str(error)); - return; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Exit Message -// ====================================== -static void guest_heartbeat_recv_exit_msg( char log_msg[] ) -{ - GuestErrorT error; - - DPRINTFI("--------> HEARTBEAT EXIT <--------"); - DPRINTFI("reason=%s", log_msg); - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timer_id) - { - error = guest_timer_deregister(_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timeout_timer_id) - { - error = guest_timer_deregister(_heartbeat_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timeout timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Challenge Ack Message -// =============================================== -static void guest_heartbeat_recv_challenge_ack_msg( - bool health, GuestHeartbeatActionT corrective_action, char log_msg[] ) -{ - GuestErrorT error; - - _challenge_response_recvd = true; - - if (!health) - { - DPRINTFE("--------> HEARTBEAT UNHEALTHY <--------"); - DPRINTFE("corrective_action=%s, reason=%s", - guest_heartbeat_action_str(corrective_action), log_msg); - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timer_id) - { - error = guest_timer_deregister(_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timeout_timer_id) - { - error = guest_timer_deregister(_heartbeat_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timeout timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - return; - } - - guest_timer_reset(_heartbeat_timeout_timer_id); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat - Receive Action Response Message -// ================================================= -static void guest_heartbeat_recv_action_response_msg( - int invocation_id, GuestHeartbeatEventT event, - GuestHeartbeatNotifyT notify, GuestHeartbeatVoteResultT vote_result, - char log_msg[] ) -{ - DPRINTFI("--------> ACTION RESPONSE <--------"); - DPRINTFI("invocation_id=%i event=%s, notify=%s, vote-result=%s, reason=%s", - invocation_id, guest_heartbeat_event_str(event), - guest_heartbeat_notify_str(notify), - guest_heartbeat_vote_result_str(vote_result), log_msg); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test - Initialize -// ======================= -GuestErrorT guest_test_initialize( char* comm_device ) -{ - GuestHeartbeatMsgCallbacksT callbacks; - GuestErrorT error; - - memset(&callbacks, 0, sizeof(callbacks)); - - callbacks.recv_init = guest_heartbeat_recv_init_msg; - callbacks.recv_exit = guest_heartbeat_recv_exit_msg; - callbacks.recv_challenge_ack = guest_heartbeat_recv_challenge_ack_msg; - callbacks.recv_action_response = guest_heartbeat_recv_action_response_msg; - - error = guest_heartbeat_msg_initialize(comm_device, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize heartbeat messaging, error=%s.", - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test - Finalize -// ===================== -GuestErrorT guest_test_finalize( void ) -{ - GuestErrorT error; - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timer_id) - { - error = guest_timer_deregister(_heartbeat_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timer_id = GUEST_TIMER_ID_INVALID; - } - - if (GUEST_TIMER_ID_INVALID != _heartbeat_timeout_timer_id) - { - error = guest_timer_deregister(_heartbeat_timeout_timer_id); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to cancel heartbeat timeout timer, error=%s.", - guest_error_str(error)); - } - _heartbeat_timeout_timer_id = GUEST_TIMER_ID_INVALID; - } - - error = guest_heartbeat_msg_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize heartbeat messaging, error=%s.", - guest_error_str(error)); - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.h b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.h deleted file mode 100755 index 409cac3c..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TEST_H__ -#define __GUEST_TEST_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Test - Initialize -// ======================= -extern GuestErrorT guest_test_initialize( char* comm_device ); -// **************************************************************************** - -// **************************************************************************** -// Guest Test - Finalize -// ===================== -extern GuestErrorT guest_test_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TEST_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.c b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.c deleted file mode 100755 index 094ce171..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_test_cli.h" - -#include -#include -#include -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_selobj.h" -#include "guest_stream.h" - -#include "guest_heartbeat_msg.h" - -static GuestStreamT _stream; - -// **************************************************************************** -// Guest Test CLI - Usage -// ====================== -void guest_test_cli_usage( void ) -{ - printf("***************************************************\n"); - printf("* CLI Options: *\n"); - printf("* 1 - send action request [pause, revocable] *\n"); - printf("* 2 - send action request [pause, irrevocable] *\n"); - printf("***************************************************\n"); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test CLI - Dispatch -// ========================= -static void guest_test_cli_dispatch( int selobj ) -{ - int msg_size; - int bytes_received; - int result; - GuestErrorT error; - - result = read(STDIN_FILENO, _stream.end_ptr, _stream.avail); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on socket read, error=%s.", strerror(errno)); - return; - - } else { - DPRINTFE("Failed to read from socket, error=%s.", strerror(errno)); - return; - } - } else if (0 == result) { - DPRINTFD("No message received from socket."); - return; - - } else { - DPRINTFV("Received message, msg_size=%i.", result); - bytes_received = result; - } - - _stream.end_ptr += bytes_received; - _stream.avail -= bytes_received; - _stream.size += bytes_received; - - msg_size = guest_stream_get(&_stream); - if (0 <= msg_size) - { - _stream.bytes[msg_size] = '\0'; - DPRINTFD("CLI message: %s, msg_size=%i", _stream.bytes, msg_size); - - switch(_stream.bytes[0]) - { - case 'h': - guest_test_cli_usage(); - break; - - case '1': - error = guest_heartbeat_msg_send_action_notify( - rand(), GUEST_HEARTBEAT_EVENT_PAUSE, - GUEST_HEARTBEAT_NOTIFY_REVOCABLE, 5); - if (GUEST_OKAY != error) - DPRINTFE("Failed to send action notify, error=%s.", - guest_error_str(error)); - break; - - case '2': - error = guest_heartbeat_msg_send_action_notify( - rand(), GUEST_HEARTBEAT_EVENT_PAUSE, - GUEST_HEARTBEAT_NOTIFY_IRREVOCABLE, 5); - if (GUEST_OKAY != error) - DPRINTFE("Failed to send action notify, error=%s.", - guest_error_str(error)); - break; - - default: - break; - } - - guest_stream_advance(msg_size+1, &_stream); - } - - if (0 >= _stream.avail) - guest_stream_reset(&_stream); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test CLI - Initialize -// =========================== -GuestErrorT guest_test_cli_initialize( void ) -{ - GuestSelObjCallbacksT callbacks; - GuestErrorT error; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read_callback = guest_test_cli_dispatch; - - error = guest_selobj_register(STDIN_FILENO, &callbacks); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to register stdin selection object, error=%s.", - guest_error_str(error)); - return error; - } - - error = guest_stream_setup("\n", 1, 256*2, &_stream); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to setup stdin stream, error=%s.", - guest_error_str(error)); - return error; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test CLI - Finalize -// ========================= -GuestErrorT guest_test_cli_finalize( void ) -{ - GuestErrorT error; - - error = guest_stream_release(&_stream); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed release stream, error=%s.", guest_error_str(error)); - } - - error = guest_selobj_deregister(STDIN_FILENO); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to deregister stdin selection object, error=%s.", - guest_error_str(error)); - } - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.h b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.h deleted file mode 100755 index 82be5861..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_cli.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TEST_CLI_H__ -#define __GUEST_TEST_CLI_H__ - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Test CLI - Usage -// ====================== -extern void guest_test_cli_usage( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Test CLI - Initialize -// =========================== -extern GuestErrorT guest_test_cli_initialize( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Test CLI - Finalize -// ========================= -extern GuestErrorT guest_test_cli_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TEST_CLI_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_client.c b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_client.c deleted file mode 100755 index 9626cfec..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_client.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include - -#include "guest_types.h" -#include "guest_debug.h" - -#include "guest_test_process.h" - -// **************************************************************************** -// Guest Test Client - Main -// ======================== -int main( int argc, char *argv[], char *envp[] ) -{ - GuestErrorT error; - - error = guest_debug_initialize("Guest-Client-Test"); - if (GUEST_OKAY != error) - { - printf("Debug initialization failed, error=%s.\n", - guest_error_str(error)); - return EXIT_FAILURE; - } - - error = guest_test_process_main(argc, argv, envp); - if (GUEST_OKAY != error) - { - printf("Process failure, error=%s.\n", guest_error_str(error)); - return EXIT_FAILURE; - } - - error = guest_debug_finalize(); - if (GUEST_OKAY != error) - { - printf("Debug finalization failed, error=%s.\n", - guest_error_str(error)); - } - - return EXIT_SUCCESS; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.c b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.c deleted file mode 100755 index e80be3bd..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_test_process.h" - -#include -#include -#include -#include - -#include "guest_limits.h" -#include "guest_types.h" -#include "guest_debug.h" -#include "guest_signal.h" -#include "guest_config.h" -#include "guest_selobj.h" -#include "guest_timer.h" -#include "guest_channel.h" -#include "guest_stream.h" -#include "guest_test.h" -#include "guest_test_cli.h" - -static sig_atomic_t _stay_on = 1; - -// **************************************************************************** -// Guest Test Process - Signal Handler -// =================================== -static void guest_test_process_signal_handler( int signum ) -{ - switch (signum) - { - case SIGINT: - case SIGTERM: - case SIGQUIT: - _stay_on = 0; - break; - - case SIGCONT: - DPRINTFD("Ignoring signal SIGCONT (%i).", signum); - break; - - case SIGPIPE: - DPRINTFD("Ignoring signal SIGPIPE (%i).", signum); - break; - - default: - DPRINTFD("Signal (%i) ignored.", signum); - break; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test Process - Initialize -// =============================== -static GuestErrorT guest_test_process_initialize( - int argc, char *argv[], char *envp[] ) -{ - GuestConfigT* config = NULL; - GuestErrorT error; - - error = guest_config_initialize(argc, argv, envp); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize configuration module, error=%s.", - guest_error_str(error)); - guest_config_show_usage(); - return GUEST_FAILED; - } - - error = guest_selobj_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize selection object module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_timer_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize timer module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_channel_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize channel module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_stream_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize stream module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - config = guest_config_get(); - - error = guest_test_initialize(config->comm_device); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize test module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - error = guest_test_cli_initialize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to initialize test cli module, error=%s.", - guest_error_str(error)); - return GUEST_FAILED; - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test Process - Finalize -// ============================= -static GuestErrorT guest_test_process_finalize( void ) -{ - GuestErrorT error; - - error = guest_test_cli_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize test cli module, error=%s.", - guest_error_str(error)); - } - - error = guest_test_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize test module, error=%s.", - guest_error_str(error)); - } - - error = guest_stream_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize stream module, error=%s.", - guest_error_str(error)); - } - - error = guest_channel_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize channel module, error=%s.", - guest_error_str(error)); - } - - error = guest_timer_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finalize timer module, error=%s.", - guest_error_str(error)); - } - - error = guest_selobj_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finialize selection object module, error=%s.", - guest_error_str(error)); - } - - error = guest_config_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed to finialize configuration module, error=%s.", - guest_error_str(error)); - } - - return GUEST_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Test Process - Main -// ========================= -GuestErrorT guest_test_process_main( int argc, char *argv[], char *envp[] ) -{ - unsigned int next_interval_in_ms; - GuestErrorT error; - - DPRINTFI("Starting."); - - guest_signal_register_handler(SIGINT, guest_test_process_signal_handler); - guest_signal_register_handler(SIGTERM, guest_test_process_signal_handler); - guest_signal_register_handler(SIGQUIT, guest_test_process_signal_handler); - guest_signal_register_handler(SIGCONT, guest_test_process_signal_handler); - guest_signal_register_handler(SIGPIPE, guest_test_process_signal_handler); - - error = guest_test_process_initialize(argc, argv, envp); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed initialize test process, error=%s.", - guest_error_str(error)); - return error; - } - - DPRINTFI("Started."); - - guest_test_cli_usage(); - - while (_stay_on) - { - next_interval_in_ms = guest_timer_schedule(); - - error = guest_selobj_dispatch(next_interval_in_ms); - if (GUEST_OKAY != error) - { - DPRINTFE("Selection object dispatch failed, error=%s.", - guest_error_str(error)); - break; - } - } - - DPRINTFI("Shutting down."); - - error = guest_test_process_finalize(); - if (GUEST_OKAY != error) - { - DPRINTFE("Failed finalize test process, error=%s.", - guest_error_str(error) ); - } - - DPRINTFI("Shutdown complete."); - - return GUEST_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.h b/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.h deleted file mode 100755 index e582093c..00000000 --- a/guest-client/guest-client-3.0.1/guest_client/src/test/guest_test_process.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_TEST_PROCESS_H__ -#define __GUEST_TEST_PROCESS_H__ - -#include - -#include "guest_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest Test Process - Main -// ==================== -extern GuestErrorT guest_test_process_main( int argc, char *argv[], char *envp[] ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_TEST_PROCESS_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/Makefile b/guest-client/guest-client-3.0.1/guest_client_api/Makefile deleted file mode 100755 index 4fce699d..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/Makefile +++ /dev/null @@ -1,123 +0,0 @@ -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -SHELL = /bin/sh - -## Configuration Directory Variables -prefix := /usr/local -exec_prefix := $(prefix) -sysconfdir := $(prefix)/etc -includedir := $(prefix)/include -libdir := $(exec_prefix)/lib -bindir := $(exec_prefix)/bin - -MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -CURRENT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) -BUILD_DIR := $(CURRENT_DIR)/build -PACKAGE_DIR := $(BUILD_DIR)/package -PACKAGE_ROOT_DIR := $(PACKAGE_DIR)/rootdir - -.PHONY: all build create_build_dir sample common heartbeat clean distclean package - -C_INCLUDES = -I$(CURRENT_DIR) -I$(CURRENT_DIR)/../include - -common_NAME := guest_common_api -common_C_SRCS := guest_api_types.c guest_api_debug.c guest_api_stream.c -common_C_SRCS += guest_api_unix.c -common_C_OBJS := ${common_C_SRCS:.c=.o} -common_LDFLAGS := -fPIC -g -shared -common_LIB_NAME := lib$(common_NAME).so -common_LIB_VER_MJR_NAME := $(common_LIB_NAME).3 -common_LIB_VER_NAME := $(common_LIB_VER_MJR_NAME).0.1 -common_BUILD_OBJS := $(addprefix $(BUILD_DIR)/, $(common_C_OBJS)) - -heartbeat_NAME := guest_heartbeat_api -heartbeat_C_SRCS := guest_heartbeat_api.c -heartbeat_C_OBJS := ${heartbeat_C_SRCS:.c=.o} -heartbeat_LDFLAGS := -fPIC -g -shared -heartbeat_LIB_NAME := lib$(heartbeat_NAME).so -heartbeat_LIB_VER_MJR_NAME := $(heartbeat_LIB_NAME).3 -heartbeat_LIB_VER_NAME := $(heartbeat_LIB_VER_MJR_NAME).0.1 -heartbeat_BUILD_OBJS := $(addprefix $(BUILD_DIR)/, $(heartbeat_C_OBJS)) - -sample_NAME := sample-guest-app -sample_C_SRCS := sample_guest_app.c -sample_C_OBJS := ${sample_C_SRCS:.c=.o} -sample_LDLIBS := -L$(BUILD_DIR) -l$(common_NAME) -l$(heartbeat_NAME) -lrt -sample_BUILD_OBJS := $(addprefix $(BUILD_DIR)/, $(sample_C_OBJS)) - -CFLAGS = -g -O2 -Wall -Werror -Wformat -fPIC -DSYSCONFDIR=$(sysconfdir) -Wformat-security - -all: build - -%.o: %.c - $(CC) $(CFLAGS) $(C_INCLUDES) -c $^ -o $(BUILD_DIR)/$@ - -common: $(common_C_OBJS) - $(CC) $(CFLAGS) $(common_BUILD_OBJS) -Wl,-soname,$(common_LIB_VER_MJR_NAME) \ - -o $(BUILD_DIR)/$(common_LIB_VER_NAME) $(common_LDFLAGS) - ln -sf $(common_LIB_VER_NAME) $(BUILD_DIR)/$(common_LIB_NAME) - ln -sf $(common_LIB_VER_NAME) $(BUILD_DIR)/$(common_LIB_VER_MJR_NAME) - -heartbeat: common $(heartbeat_C_OBJS) - $(CC) $(CFLAGS) $(heartbeat_BUILD_OBJS) -Wl,-soname,$(heartbeat_LIB_VER_MJR_NAME) \ - -o $(BUILD_DIR)/$(heartbeat_LIB_VER_NAME) $(heartbeat_LDFLAGS) - ln -sf $(heartbeat_LIB_VER_NAME) $(BUILD_DIR)/$(heartbeat_LIB_NAME) - ln -sf $(heartbeat_LIB_VER_NAME) $(BUILD_DIR)/$(heartbeat_LIB_VER_MJR_NAME) - -create_build_dir: - mkdir -p --mode 755 $(BUILD_DIR) - -build: create_build_dir common heartbeat - -sample: create_build_dir common heartbeat $(sample_C_OBJS) - $(CC) $(CFLAGS) $(sample_BUILD_OBJS) -o $(BUILD_DIR)/$(sample_NAME) $(sample_LDLIBS) - -clean: - @-($(RM) -Rf $(BUILD_DIR)/*) - -distclean: clean - -package: - @(mkdir -p --mode 755 $(PACKAGE_ROOT_DIR)/$(includedir)) - @(mkdir -p --mode 755 $(PACKAGE_ROOT_DIR)/$(libdir)) - @(echo "Packaging guest_api_types.h in $(PACKAGE_ROOT_DIR)/$(includedir)") - @(cp $(CURRENT_DIR)/guest_api_types.h $(PACKAGE_ROOT_DIR)/$(includedir)/guest_api_types.h) - @(echo "Packaging guest_heartbeat_api.h in $(PACKAGE_ROOT_DIR)/$(includedir)") - @(cp $(CURRENT_DIR)/guest_heartbeat_api.h $(PACKAGE_ROOT_DIR)/$(includedir)/guest_heartbeat_api.h) - @(echo "Packaging $(common_LIB_NAME) in $(PACKAGE_ROOT_DIR)/$(libdir)") - @(cp $(BUILD_DIR)/$(common_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(common_LIB_VER_NAME)) - @(chmod 644 $(PACKAGE_ROOT_DIR)/$(libdir)/$(common_LIB_VER_NAME)) - ln -sf $(common_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(common_LIB_NAME) - ln -sf $(common_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(common_LIB_VER_MJR_NAME) - @(echo "Packaging $(heartbeat_LIB_NAME) in $(PACKAGE_ROOT_DIR)/$(libdir)") - @(cp $(BUILD_DIR)/$(heartbeat_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(heartbeat_LIB_VER_NAME)) - @(chmod 644 $(PACKAGE_ROOT_DIR)/$(libdir)/$(heartbeat_LIB_VER_NAME)) - ln -sf $(heartbeat_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(heartbeat_LIB_NAME) - ln -sf $(heartbeat_LIB_VER_NAME) $(PACKAGE_ROOT_DIR)/$(libdir)/$(heartbeat_LIB_VER_MJR_NAME) diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.c b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.c deleted file mode 100755 index dac09405..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_api_debug.h" - -#include -#include -#include - -#include "guest_api_types.h" - -#define GUEST_DEBUG_WANT_SYSLOG -#ifdef GUEST_DEBUG_WANT_SYSLOG -#include -#endif - -static char _process_name[30]; -static GuestApiDebugLogLevelT _log_level = GUEST_API_DEBUG_LOG_LEVEL_INFO; - -// **************************************************************************** -// Guest API Debug - Log Level String -// ================================== -const char* guest_api_debug_log_level_str( GuestApiDebugLogLevelT level ) -{ - switch (level) { - case GUEST_API_DEBUG_LOG_LEVEL_ERROR: return "error"; - case GUEST_API_DEBUG_LOG_LEVEL_INFO: return " info"; - case GUEST_API_DEBUG_LOG_LEVEL_DEBUG: return "debug"; - case GUEST_API_DEBUG_LOG_LEVEL_VERBOSE: return " verb"; - default: - return "???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Set Log Level -// =============================== -void guest_api_debug_set_log_level( GuestApiDebugLogLevelT level ) -{ - _log_level = level; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Want Log -// ========================== -bool guest_api_debug_want_log( GuestApiDebugLogLevelT level ) -{ - return (level <= _log_level); -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Log -// ===================== -void guest_api_debug_log( const char* format, ... ) -{ - char time_str[80]; - char date_str[32]; - struct tm t_real; - struct timespec ts_real; - va_list arguments; - char log_data[256]; - - va_start(arguments, format); - vsnprintf(log_data, sizeof(log_data), format, arguments); - va_end(arguments); - - clock_gettime(CLOCK_REALTIME, &ts_real); - - if (NULL == localtime_r(&(ts_real.tv_sec), &t_real)) - { - snprintf( time_str, sizeof(time_str), - "YYYY:MM:DD HH:MM:SS.xxx" ); - } else { - strftime( date_str, sizeof(date_str), "%b %e %H:%M:%S", - &t_real ); - snprintf( time_str, sizeof(time_str), "%s.%03ld", date_str, - ts_real.tv_nsec/1000000 ); - } - -#ifdef GUEST_DEBUG_WANT_SYSLOG - syslog(LOG_INFO, "%s", log_data); -#else - printf("%s %s: %s\n", time_str, _process_name, log_data); -#endif -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Initialize -// ============================ -GuestApiErrorT guest_api_debug_initialize( char process_name[] ) -{ - _log_level = GUEST_API_DEBUG_LOG_LEVEL_INFO; - snprintf(_process_name, sizeof(_process_name), "%s", process_name); - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Finalize -// ========================== -GuestApiErrorT guest_api_debug_finalize( void ) -{ - _log_level = GUEST_API_DEBUG_LOG_LEVEL_INFO; - _process_name[0] = '\0'; - - return GUEST_API_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.h b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.h deleted file mode 100755 index f276fbae..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_debug.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_API_DEBUG_H__ -#define __GUEST_API_DEBUG_H__ - -#include - -#include "guest_api_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_API_DEBUG_LOG_LEVEL_ERROR, - GUEST_API_DEBUG_LOG_LEVEL_INFO, - GUEST_API_DEBUG_LOG_LEVEL_DEBUG, - GUEST_API_DEBUG_LOG_LEVEL_VERBOSE, -} GuestApiDebugLogLevelT; - -#define DPRINTF(level, format, args...) \ - if (guest_api_debug_want_log(level)) \ - guest_api_debug_log("%s: %s(%i): " format, \ - guest_api_debug_log_level_str(level), \ - __FILE__, __LINE__, ##args) -#define DPRINTFE(format, args...) \ - DPRINTF(GUEST_API_DEBUG_LOG_LEVEL_ERROR, format, ##args) -#define DPRINTFI(format, args...) \ - DPRINTF(GUEST_API_DEBUG_LOG_LEVEL_INFO, format, ##args) -#define DPRINTFD(format, args...) \ - DPRINTF(GUEST_API_DEBUG_LOG_LEVEL_DEBUG, format, ##args) -#define DPRINTFV(format, args... ) \ - DPRINTF(GUEST_API_DEBUG_LOG_LEVEL_VERBOSE, format, ##args) - -// **************************************************************************** -// Guest API Debug - Log Level String -// ================================== -extern const char* guest_api_debug_log_level_str( GuestApiDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Set Log Level -// =============================== -extern void guest_api_debug_set_log_level( GuestApiDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Want Log -// ========================== -extern bool guest_api_debug_want_log( GuestApiDebugLogLevelT level ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Log -// ===================== -extern void guest_api_debug_log( const char* format, ... ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Initialize -// ============================ -extern GuestApiErrorT guest_api_debug_initialize( char process_name[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Debug - Finalize -// ========================== -extern GuestApiErrorT guest_api_debug_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_API_DEBUG_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.c b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.c deleted file mode 100755 index 5f21a39e..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_api_stream.h" - -#include -#include -#include - -#include "guest_api_types.h" -#include "guest_api_debug.h" - -// **************************************************************************** -// Guest API Stream - Get -// ====================== -int guest_api_stream_get( GuestApiStreamT* stream ) -{ - char* byte_ptr; - int delimiter_i = 0; - - if (stream->delimiter_size > stream->size) - return -1; - - for (byte_ptr = stream->bytes; byte_ptr != stream->end_ptr; ++byte_ptr) - { - if (stream->delimiter[delimiter_i] == *byte_ptr) - { - ++delimiter_i; - if (delimiter_i == stream->delimiter_size) - { - return (byte_ptr - stream->bytes); - } - } else { - delimiter_i = 0; - } - } - - return -1; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Get Next -// =========================== -bool guest_api_stream_get_next( GuestApiStreamT* stream ) -{ - char* byte_ptr; - int delimiter_i = 0; - - if (stream->delimiter_size > stream->size) - return false; - - for (byte_ptr = stream->bytes; byte_ptr != stream->end_ptr; ++byte_ptr) - { - --stream->size; - if (stream->delimiter[delimiter_i] == *byte_ptr) - { - ++delimiter_i; - if (delimiter_i == stream->delimiter_size) - { - byte_ptr -= (stream->delimiter_size-1); - stream->size += stream->delimiter_size; - memmove(stream->bytes, byte_ptr, stream->size); - stream->avail = stream->max_size - stream->size; - stream->end_ptr = stream->bytes + stream->size; - break; - } - } else { - delimiter_i = 0; - } - } - - if (byte_ptr == stream->end_ptr) - { - // Empty the stream - memset(stream->bytes, 0, stream->max_size); - stream->avail = stream->max_size; - stream->size = 0; - stream->end_ptr = stream->bytes; - return false; - } - - return true; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Advance -// ========================== -void guest_api_stream_advance( int adv, GuestApiStreamT* stream ) -{ - stream->size -= adv; - memmove(stream->bytes, stream->bytes+adv, stream->size); - stream->avail = stream->max_size - stream->size; - stream->end_ptr = stream->bytes + stream->size; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Reset -// ======================== -void guest_api_stream_reset( GuestApiStreamT* stream ) -{ - memset(stream->bytes, 0, stream->max_size); - stream->avail = stream->max_size; - stream->size = 0; - stream->end_ptr = stream->bytes; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Setup -// ======================== -GuestApiErrorT guest_api_stream_setup( - const char* delimiter, int delimiter_size, int stream_size, - GuestApiStreamT* stream ) -{ - stream->delimiter = malloc(delimiter_size); - if (NULL == stream->delimiter) - { - DPRINTFE("Failed to allocated delimiter storage, needed=%i.", - delimiter_size); - return GUEST_API_FAILED; - } - - stream->bytes = malloc(stream_size); - if (NULL == stream->delimiter) - { - DPRINTFE("Failed to allocated stream storage, needed=%i.", stream_size); - free(stream->delimiter); - return GUEST_API_FAILED; - } - - memcpy(stream->delimiter, delimiter, delimiter_size); - stream->delimiter_size = delimiter_size; - memset(stream->bytes, 0, stream_size); - stream->end_ptr = stream->bytes; - stream->avail = stream_size; - stream->size = 0; - stream->max_size = stream_size; - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Release -// ========================== -GuestApiErrorT guest_api_stream_release( GuestApiStreamT* stream ) -{ - if (NULL != stream->delimiter) - free(stream->delimiter); - - if (NULL != stream->bytes) - free(stream->bytes); - - memset(stream, 0, sizeof(GuestApiStreamT)); - return GUEST_API_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.h b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.h deleted file mode 100755 index 3a71ea06..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_stream.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_API_STREAM_H__ -#define __GUEST_API_STREAM_H__ - -#include - -#include "guest_api_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char* delimiter; - int delimiter_size; - char* end_ptr; - char* bytes; - int avail; - int size; - int max_size; -} GuestApiStreamT; - -// **************************************************************************** -// Guest API Stream - Get -// ====================== -extern int guest_api_stream_get( GuestApiStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Get Next -// =========================== -extern bool guest_api_stream_get_next( GuestApiStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Advance -// ========================== -extern void guest_api_stream_advance( int adv, GuestApiStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Reset -// ======================== -extern void guest_api_stream_reset( GuestApiStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Setup -// ======================== -extern GuestApiErrorT guest_api_stream_setup( - const char* delimiter, int delimiter_size, int stream_size, - GuestApiStreamT* stream ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Stream - Release -// ========================== -extern GuestApiErrorT guest_api_stream_release( GuestApiStreamT* stream ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_API_STREAM_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.c b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.c deleted file mode 100755 index 4a0fe2e9..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_api_types.h" - -// **************************************************************************** -// Guest API - Error String -// ======================== -const char* guest_api_error_str( GuestApiErrorT error ) -{ - switch (error) - { - case GUEST_API_OKAY: return "OKAY"; - case GUEST_API_FAILED: return "FAILED"; - case GUEST_API_INTERRUPTED: return "INTERRUPTED"; - case GUEST_API_TRY_AGAIN: return "TRY_AGAIN"; - default: - return "???"; - } -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.h b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.h deleted file mode 100755 index 486c943a..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_types.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_API_TYPES_H__ -#define __GUEST_API_TYPES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GUEST_API_OKAY, - GUEST_API_FAILED, - GUEST_API_INTERRUPTED, - GUEST_API_TRY_AGAIN, -} GuestApiErrorT; - -// **************************************************************************** -// Guest API - Error String -// ======================== -extern const char* guest_api_error_str( GuestApiErrorT error ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_API_TYPES_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.c b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.c deleted file mode 100755 index c6035131..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_api_unix.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "guest_api_types.h" -#include "guest_api_debug.h" - -// **************************************************************************** -// Guest API Unix - Connect -// ======================== -GuestApiErrorT guest_api_unix_connect( int s, char* address ) -{ - struct sockaddr_un remote; - int len, result; - - memset(&remote, 0, sizeof(remote)); - - remote.sun_family = AF_UNIX; - len = sizeof(remote.sun_family); - len += snprintf(remote.sun_path, sizeof(remote.sun_path), "%s", address); - - result = connect(s, (struct sockaddr*) &remote, sizeof(remote)); - if (0 > result) - { - if ((ENOENT == errno) || (ECONNREFUSED == errno)) - { - DPRINTFD("Failed to connect to %s, error=%s.", address, - strerror(errno)); - return GUEST_API_TRY_AGAIN; - } else { - DPRINTFE("Failed to connect to %s, error=%s.", address, - strerror(errno)); - return GUEST_API_FAILED; - } - } - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Send -// ===================== -GuestApiErrorT guest_api_unix_send( int s, void* msg, int msg_size ) -{ - int result; - - result = write(s, msg, msg_size); - if (0 > result) - { - if (errno == EPIPE) - { - DPRINTFI("Failed to write to socket, error=%s.", strerror(errno)); - return GUEST_API_TRY_AGAIN; - } else { - DPRINTFE("Failed to write to socket, error=%s.", strerror(errno)); - return GUEST_API_FAILED; - } - } - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Receive -// ======================== -GuestApiErrorT guest_api_unix_receive( - int s, void* msg_buf, int msg_buf_size, int* msg_size ) -{ - int result; - - result = read(s, msg_buf, msg_buf_size); - if (0 > result) - { - if (EINTR == errno) - { - DPRINTFD("Interrupted on socket read, error=%s.", strerror(errno)); - return GUEST_API_INTERRUPTED; - } else if (ECONNRESET == errno) { - DPRINTFD("Peer connection reset, error=%s.", strerror(errno)); - *msg_size = 0; - return GUEST_API_OKAY; - } else{ - DPRINTFE("Failed to read from socket, error=%s.", strerror(errno)); - return GUEST_API_FAILED; - } - } else if (0 == result) { - DPRINTFD("No message received from socket."); - *msg_size = 0; - return GUEST_API_OKAY; - } else { - DPRINTFV("Received message, msg_size=%i.", result); - *msg_size = result; - } - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Open -// ===================== -GuestApiErrorT guest_api_unix_open( int* s ) -{ - int sock; - int reuse_addr = 1; - struct sockaddr_un local; - int result; - - *s = -1; - memset(&local, 0, sizeof(local)); - - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (0 > sock) - { - DPRINTFE("Failed to open socket, error=%s.", strerror(errno)); - return GUEST_API_FAILED; - } - - result = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, - sizeof(reuse_addr)); - if (0 > result) - { - DPRINTFE("Failed to set socket option (REUSEADDR), error=%s.", - strerror(errno)); - close(sock); - return GUEST_API_FAILED; - } - - result = fcntl(sock, F_SETFD, FD_CLOEXEC); - if (0 > result) - { - DPRINTFE("Failed to set to close on exec, error=%s.", strerror(errno)); - close(sock); - return GUEST_API_FAILED; - } - - result = fcntl(sock, F_GETFL); - if (0 > result) - { - DPRINTFE("Failed to get socket options, error=%s.", strerror(errno)); - close(sock); - return GUEST_API_FAILED; - } - - result = fcntl(sock, F_SETFL, result | O_NONBLOCK); - if (0 > result) - { - DPRINTFE("Failed to set socket options, error=%s.", strerror(errno)); - close(sock); - return GUEST_API_FAILED; - } - - *s = sock; - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Close -// ====================== -GuestApiErrorT guest_api_unix_close( int s ) -{ - if (0 <= s) - close(s); - - return GUEST_API_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.h b/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.h deleted file mode 100755 index 6e0b71c5..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_api_unix.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_API_UNIX_H__ -#define __GUEST_API_UNIX_H__ - -#include "guest_api_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// **************************************************************************** -// Guest API Unix - Connect -// ======================== -extern GuestApiErrorT guest_api_unix_connect( int s, char* address ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Send -// ===================== -extern GuestApiErrorT guest_api_unix_send( int s, void* msg, int msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Receive -// ======================== -extern GuestApiErrorT guest_api_unix_receive( - int s, void* msg_buf, int msg_buf_size, int* msg_size ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Open -// ===================== -extern GuestApiErrorT guest_api_unix_open( int* s ); -// **************************************************************************** - -// **************************************************************************** -// Guest API Unix - Close -// ====================== -extern GuestApiErrorT guest_api_unix_close( int s ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_API_UNIX_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.c b/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.c deleted file mode 100755 index 99e7d31a..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.c +++ /dev/null @@ -1,748 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "guest_heartbeat_api.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "guest_api_types.h" -#include "guest_api_debug.h" -#include "guest_api_unix.h" -#include "guest_api_stream.h" - -#include "guest_heartbeat_api_msg_defs.h" - -static int _sock = -1; -static bool _connected = false; -static uint32_t _msg_sequence; -static GuestApiStreamT _stream; -static GuestHeartbeatApiCallbacksT _callbacks; - -// **************************************************************************** -// Guest Heartbeat API - Action String -// =================================== -const char* guest_heartbeat_api_action_str( GuestHeartbeatApiActionT action ) -{ - switch (action) - { - case GUEST_HEARTBEAT_API_ACTION_NONE: return "none"; - case GUEST_HEARTBEAT_API_ACTION_REBOOT: return "reboot"; - case GUEST_HEARTBEAT_API_ACTION_STOP: return "stop"; - case GUEST_HEARTBEAT_API_ACTION_LOG: return "log"; - default: - return "action-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Event String -// ================================== -const char* guest_heartbeat_api_event_str( GuestHeartbeatApiEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_API_EVENT_STOP: return "stop"; - case GUEST_HEARTBEAT_API_EVENT_REBOOT: return "reboot"; - case GUEST_HEARTBEAT_API_EVENT_SUSPEND: return "suspend"; - case GUEST_HEARTBEAT_API_EVENT_PAUSE: return "pause"; - case GUEST_HEARTBEAT_API_EVENT_UNPAUSE: return "unpause"; - case GUEST_HEARTBEAT_API_EVENT_RESUME: return "resume"; - case GUEST_HEARTBEAT_API_EVENT_RESIZE_BEGIN: return "resize-begin"; - case GUEST_HEARTBEAT_API_EVENT_RESIZE_END: return "resize-end"; - case GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_BEGIN: return "live-migrate-begin"; - case GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_END: return "live-migrate-end"; - case GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_BEGIN: return "cold-migrate-begin"; - case GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_END: return "cold-migrate-end"; - default: - return "event-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Notify String -// =================================== -const char* guest_heartbeat_api_notify_str( - GuestHeartbeatApiNotifyTypeT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_API_NOTIFY_TYPE_REVOCABLE: return "revocable"; - case GUEST_HEARTBEAT_API_NOTIFY_TYPE_IRREVOCABLE: return "irrevocable"; - default: - return "notify-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Vote Result String -// ======================================== -const char* guest_heartbeat_api_vote_result_str( - GuestHeartbeatApiVoteResultT vote_result ) -{ - switch (vote_result) - { - case GUEST_HEARTBEAT_API_VOTE_RESULT_ACCEPT: return "accept"; - case GUEST_HEARTBEAT_API_VOTE_RESULT_REJECT: return "reject"; - case GUEST_HEARTBEAT_API_VOTE_RESULT_COMPLETE: return "complete"; - default: - return "vote-???"; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Action (Host to Network) -// ============================================== -static GuestHeartbeatApiMsgActionT guest_heartbeat_api_action_hton( - GuestHeartbeatApiActionT action ) -{ - switch (action) - { - case GUEST_HEARTBEAT_API_ACTION_NONE: - return GUEST_HEARTBEAT_API_MSG_ACTION_NONE; - case GUEST_HEARTBEAT_API_ACTION_REBOOT: - return GUEST_HEARTBEAT_API_MSG_ACTION_REBOOT; - case GUEST_HEARTBEAT_API_ACTION_STOP: - return GUEST_HEARTBEAT_API_MSG_ACTION_STOP; - case GUEST_HEARTBEAT_API_ACTION_LOG: - return GUEST_HEARTBEAT_API_MSG_ACTION_LOG; - default: - DPRINTFE("Unknown action %i.", action); - return GUEST_HEARTBEAT_API_MSG_ACTION_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Event (Host to Network) -// ============================================= -static GuestHeartbeatApiMsgEventT guest_heartbeat_api_event_hton( - GuestHeartbeatApiEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_API_EVENT_STOP: - return GUEST_HEARTBEAT_API_MSG_EVENT_STOP; - case GUEST_HEARTBEAT_API_EVENT_REBOOT: - return GUEST_HEARTBEAT_API_MSG_EVENT_REBOOT; - case GUEST_HEARTBEAT_API_EVENT_SUSPEND: - return GUEST_HEARTBEAT_API_MSG_EVENT_SUSPEND; - case GUEST_HEARTBEAT_API_EVENT_PAUSE: - return GUEST_HEARTBEAT_API_MSG_EVENT_PAUSE; - case GUEST_HEARTBEAT_API_EVENT_UNPAUSE: - return GUEST_HEARTBEAT_API_MSG_EVENT_UNPAUSE; - case GUEST_HEARTBEAT_API_EVENT_RESUME: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESUME; - case GUEST_HEARTBEAT_API_EVENT_RESIZE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_BEGIN; - case GUEST_HEARTBEAT_API_EVENT_RESIZE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_END; - case GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_END; - case GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_END: - return GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_END; - default: - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_API_MSG_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Event (Network to Host) -// ============================================= -static GuestHeartbeatApiEventT guest_heartbeat_api_event_ntoh( - GuestHeartbeatApiMsgEventT event ) -{ - switch (event) - { - case GUEST_HEARTBEAT_API_MSG_EVENT_STOP: - return GUEST_HEARTBEAT_API_EVENT_STOP; - case GUEST_HEARTBEAT_API_MSG_EVENT_REBOOT: - return GUEST_HEARTBEAT_API_EVENT_REBOOT; - case GUEST_HEARTBEAT_API_MSG_EVENT_SUSPEND: - return GUEST_HEARTBEAT_API_EVENT_SUSPEND; - case GUEST_HEARTBEAT_API_MSG_EVENT_PAUSE: - return GUEST_HEARTBEAT_API_EVENT_PAUSE; - case GUEST_HEARTBEAT_API_MSG_EVENT_UNPAUSE: - return GUEST_HEARTBEAT_API_EVENT_UNPAUSE; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESUME: - return GUEST_HEARTBEAT_API_EVENT_RESUME; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_BEGIN: - return GUEST_HEARTBEAT_API_EVENT_RESIZE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_END: - return GUEST_HEARTBEAT_API_EVENT_RESIZE_END; - case GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_END: - return GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_END; - case GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_BEGIN: - return GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_BEGIN; - case GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_END: - return GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_END; - default: - DPRINTFE("Unknown event %i.", event); - return GUEST_HEARTBEAT_API_EVENT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Notify (Host to Network) -// ============================================== -static GuestHeartbeatApiMsgNotifyT guest_heartbeat_api_notify_hton( - GuestHeartbeatApiNotifyTypeT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_API_NOTIFY_TYPE_REVOCABLE: - return GUEST_HEARTBEAT_API_MSG_NOTIFY_REVOCABLE; - case GUEST_HEARTBEAT_API_NOTIFY_TYPE_IRREVOCABLE: - return GUEST_HEARTBEAT_API_MSG_NOTIFY_IRREVOCABLE; - default: - DPRINTFE("Unknown notify type %i.", notify); - return GUEST_HEARTBEAT_API_MSG_NOTIFY_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Notify (Network to Host) -// ============================================== -static GuestHeartbeatApiNotifyTypeT guest_heartbeat_api_notify_ntoh( - GuestHeartbeatApiMsgNotifyT notify ) -{ - switch (notify) - { - case GUEST_HEARTBEAT_API_MSG_NOTIFY_REVOCABLE: - return GUEST_HEARTBEAT_API_NOTIFY_TYPE_REVOCABLE; - case GUEST_HEARTBEAT_API_MSG_NOTIFY_IRREVOCABLE: - return GUEST_HEARTBEAT_API_NOTIFY_TYPE_IRREVOCABLE; - default: - DPRINTFE("Unknown notify type %i.", notify); - return GUEST_HEARTBEAT_API_NOTIFY_TYPE_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Vote Result (Host to Network) -// =================================================== -static GuestHeartbeatApiMsgVoteResultT guest_heartbeat_api_vote_result_hton( - GuestHeartbeatApiVoteResultT vote_result ) -{ - switch (vote_result) - { - case GUEST_HEARTBEAT_API_VOTE_RESULT_ACCEPT: - return GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_ACCEPT; - case GUEST_HEARTBEAT_API_VOTE_RESULT_REJECT: - return GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_REJECT; - case GUEST_HEARTBEAT_API_VOTE_RESULT_COMPLETE: - return GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_COMPLETE; - default: - DPRINTFE("Unknown vote result %i.", vote_result); - return GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_UNKNOWN; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Register -// ============================== -GuestApiErrorT guest_heartbeat_api_register( - GuestHeartbeatApiInitDataT* init_data ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT* hdr = &(msg.header); - GuestHeartbeatApiMsgInitT* bdy = &(msg.body.init); - GuestApiErrorT error; - - if (0 > _sock) - { - error = guest_api_unix_open(&_sock); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to open unix socket, error=%s.", - guest_api_error_str(error)); - return error; - } - } - - if (!_connected) - { - error = guest_api_unix_connect(_sock, GUEST_HEARTBEAT_API_MSG_ADDRESS); - if (GUEST_API_OKAY != error) - { - if (GUEST_API_TRY_AGAIN != error) - { - DPRINTFD("Failed to connect unix socket, error=%s.", - guest_api_error_str(error)); - return error; - } else { - DPRINTFE("Failed to connect unix socket, error=%s.", - guest_api_error_str(error)); - return error; - } - } - - _connected = true; - } - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_INIT; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - snprintf(bdy->application_name, - GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE, "%s", - init_data->application_name); - bdy->heartbeat_interval_ms = init_data->heartbeat_interval_ms; - bdy->vote_secs = init_data->vote_secs; - bdy->shutdown_notice_secs = init_data->shutdown_notice_secs; - bdy->suspend_notice_secs = init_data->suspend_notice_secs; - bdy->resume_notice_secs = init_data->resume_notice_secs; - bdy->corrective_action - = guest_heartbeat_api_action_hton(init_data->corrective_action); - - error = guest_api_unix_send(_sock, &msg, sizeof(msg)); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat register message, error=%s.", - guest_api_error_str(error)); - return error; - } - - DPRINTFD("Sent register request."); - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Deregister -// ================================ -GuestApiErrorT guest_heartbeat_api_deregister( char log_msg[] ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT* hdr = &(msg.header); - GuestHeartbeatApiMsgFinalT* bdy = &(msg.body.final); - GuestApiErrorT error; - - if (!_connected) - { - DPRINTFD("Not connected."); - return GUEST_API_OKAY; - } - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_FINAL; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - snprintf(bdy->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, "%s", log_msg); - - error = guest_api_unix_send(_sock, &msg, sizeof(msg)); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat api deregister message, " - "error=%s.", guest_api_error_str(error)); - return error; - } - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Send Action Response -// ========================================== -GuestApiErrorT guest_heartbeat_api_send_action_response( - int invocation_id, GuestHeartbeatApiEventT event, - GuestHeartbeatApiNotifyTypeT notify_type, - GuestHeartbeatApiVoteResultT vote_result, char log_msg[] ) -{ - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT* hdr = &(msg.header); - GuestHeartbeatApiMsgActionResponseT* bdy = &(msg.body.action_response); - GuestApiErrorT error; - - if (!_connected) - { - DPRINTFD("Not connected."); - return GUEST_API_OKAY; - } - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_ACTION_RESPONSE; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - bdy->invocation_id = invocation_id; - bdy->event_type = guest_heartbeat_api_event_hton(event); - bdy->notification_type = guest_heartbeat_api_notify_hton(notify_type); - bdy->vote_result = guest_heartbeat_api_vote_result_hton(vote_result); - snprintf(bdy->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, "%s", log_msg); - - error = guest_api_unix_send(_sock, &msg, sizeof(msg)); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat api action response message, " - "error=%s.", guest_api_error_str(error)); - return error; - } - - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Api - Receive Init Ack -// ====================================== -static void guest_heartbeat_api_recv_init_ack( void ) -{ - uint32_t accepted; - char* ptr = _stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - - accepted = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - - DPRINTFI("Registration %s.", accepted ? "accepted" : "not accepted"); - - if (NULL != _callbacks.register_state) - _callbacks.register_state(accepted); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Api - Receive Challenge -// ======================================= -static void guest_heartbeat_api_recv_challenge( void ) -{ - bool health = true; - GuestHeartbeatApiActionT corrective_action = GUEST_HEARTBEAT_API_ACTION_NONE; - char log_msg[GUEST_HEARTBEAT_API_LOG_MAX] = ""; - int heartbeat_challenge; - GuestHeartbeatApiMsgT msg; - GuestHeartbeatApiMsgHeaderT* hdr = &(msg.header); - GuestHeartbeatApiMsgChallengeResponseT* bdy = &(msg.body.challenge_response); - GuestApiErrorT error; - char* ptr = _stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - - heartbeat_challenge = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - - if (NULL != _callbacks.health_check) - _callbacks.health_check(&health, &corrective_action, log_msg); - - memset(&msg, 0, sizeof(msg)); - - memcpy(&(hdr->magic), GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE); - hdr->version = GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT; - hdr->revision = GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT; - hdr->msg_type = GUEST_HEARTBEAT_API_MSG_CHALLENGE_RESPONSE; - hdr->sequence = ++_msg_sequence; - hdr->size = sizeof(msg); - - bdy->heartbeat_response = heartbeat_challenge; - bdy->health = health; - bdy->corrective_action - = guest_heartbeat_api_action_hton(corrective_action); - snprintf(bdy->log_msg, GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE, "%s", log_msg); - - error = guest_api_unix_send(_sock, &msg, sizeof(msg)); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to send guest heartbeat api challenge response " - "message, error=%s.", guest_api_error_str(error)); - return; - } - - DPRINTFD("Sent guest heartbeat api challenge response sent."); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat Api - Receive Action Notify -// =========================================== -static void guest_heartbeat_api_recv_action_notify( void ) -{ - int invocation_id; - GuestHeartbeatApiEventT event; - GuestHeartbeatApiNotifyTypeT notify_type; - char* ptr = _stream.bytes + sizeof(GuestHeartbeatApiMsgHeaderT); - - invocation_id = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - event = guest_heartbeat_api_event_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - notify_type = guest_heartbeat_api_notify_ntoh(*(uint32_t*) ptr); - ptr += sizeof(uint32_t); - - if (NULL != _callbacks.action_notify) - _callbacks.action_notify(invocation_id, event, notify_type); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Dispatch -// ============================== -void guest_heartbeat_api_dispatch( int selobj ) -{ - static bool have_start = false; - static bool have_header = false; - static GuestHeartbeatApiMsgHeaderT hdr; - - bool more; - int bytes_received; - GuestApiErrorT error; - - if (selobj != _sock) - return; - - error = guest_api_unix_receive(_sock, _stream.end_ptr, _stream.avail, - &bytes_received); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to receive message, error=%s.", - guest_api_error_str(error)); - return; - } - - if (0 == bytes_received) - { - DPRINTFI("Registration dropped."); - _connected = false; - - error = guest_api_unix_close(_sock); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to close unix socket, error=%s.", - guest_api_error_str(error)); - } - _sock = -1; - - if (NULL != _callbacks.register_state) - _callbacks.register_state(false); - } - - DPRINTFV("Bytes received is %i.", bytes_received); - - _stream.end_ptr += bytes_received; - _stream.avail -= bytes_received; - _stream.size += bytes_received; - - do - { - more = false; - - if (!have_start) - { - memset(&hdr, 0, sizeof(GuestHeartbeatApiMsgHeaderT)); - have_start = guest_api_stream_get_next(&_stream); - } - - if (have_start && !have_header) - { - if (sizeof(GuestHeartbeatApiMsgHeaderT) <= _stream.size) - { - char *ptr = _stream.bytes + GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE; - - hdr.version = *(uint8_t*) ptr; - ptr += sizeof(uint8_t); - hdr.revision = *(uint8_t*) ptr; - ptr += sizeof(uint8_t); - hdr.msg_type = *(uint16_t*) ptr; - ptr += sizeof(uint16_t); - hdr.sequence = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - hdr.size = *(uint32_t*) ptr; - ptr += sizeof(uint32_t); - - DPRINTFD("Message header: version=%i, revision=%i, " - "msg_type=%i, sequence=%u, size=%u", hdr.version, - hdr.revision, hdr.msg_type, hdr.sequence, hdr.size); - - if (GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT == hdr.version) - { - have_header = true; - } else { - have_start = false; - have_header = false; - guest_api_stream_advance(GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE, - &_stream); - more = true; - } - } - } - - if (have_start && have_header) - { - if (sizeof(GuestHeartbeatApiMsgT) <= _stream.size) - { - switch (hdr.msg_type) - { - case GUEST_HEARTBEAT_API_MSG_INIT_ACK: - guest_heartbeat_api_recv_init_ack(); - break; - - case GUEST_HEARTBEAT_API_MSG_CHALLENGE: - guest_heartbeat_api_recv_challenge(); - break; - - case GUEST_HEARTBEAT_API_MSG_ACTION_NOTIFY: - guest_heartbeat_api_recv_action_notify(); - break; - - default: - DPRINTFV("Unknown message type %i.", - (int) hdr.msg_type); - break; - } - - have_start = false; - have_header = false; - guest_api_stream_advance(sizeof(GuestHeartbeatApiMsgT), - &_stream); - more = true; - } - } - } while (more); - - if (0 >= _stream.avail) - guest_api_stream_reset(&_stream); -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Get Selection Object -// ========================================== -int guest_heartbeat_api_get_selobj( void ) -{ - return _sock; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Initialize -// ================================ -GuestApiErrorT guest_heartbeat_api_initialize( - GuestHeartbeatApiCallbacksT* callbacks ) -{ - int stream_size; - GuestApiErrorT error; - - if ((NULL == callbacks->register_state) || - (NULL == callbacks->health_check) || - (NULL == callbacks->action_notify)) - { - DPRINTFE("Not all callbacks are valid."); - return GUEST_API_FAILED; - } - - _sock = -1; - - stream_size = sizeof(GuestHeartbeatApiMsgT)*4; - if (8192 > stream_size) - stream_size = 8192; - - error = guest_api_stream_setup(GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE, - GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE, - stream_size, &_stream); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to setup stream, error=%s.", - guest_api_error_str(error)); - return error; - } - - memcpy(&_callbacks, callbacks, sizeof(_callbacks)); - return GUEST_API_OKAY; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Finalize -// ============================== -GuestApiErrorT guest_heartbeat_api_finalize( void ) -{ - GuestApiErrorT error; - - memset(&_callbacks, 0, sizeof(_callbacks)); - - error = guest_api_stream_release(&_stream); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed release stream, error=%s.", - guest_api_error_str(error)); - } - - if (0 <= _sock) - { - error = guest_api_unix_close(_sock); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to close unix socket, error=%s.", - guest_api_error_str(error)); - } - _sock = -1; - } - - return GUEST_API_OKAY; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.h b/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.h deleted file mode 100755 index 5f03365b..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/guest_heartbeat_api.h +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HERATBEAT_API_H__ -#define __GUEST_HEARTBEAT_API_H__ - -#include - -#include "guest_api_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_HEARTBEAT_API_APPLICATION_NAME_MAX 40 -#define GUEST_HEARTBEAT_API_LOG_MAX 192 - -typedef enum { - - GUEST_HEARTBEAT_API_ACTION_UNKNOWN, - GUEST_HEARTBEAT_API_ACTION_NONE, - GUEST_HEARTBEAT_API_ACTION_REBOOT, - GUEST_HEARTBEAT_API_ACTION_STOP, - GUEST_HEARTBEAT_API_ACTION_LOG, - GUEST_HEARTBEAT_API_ACTION_MAX, -} GuestHeartbeatApiActionT; - -typedef enum { - GUEST_HEARTBEAT_API_EVENT_UNKNOWN, - GUEST_HEARTBEAT_API_EVENT_STOP, - GUEST_HEARTBEAT_API_EVENT_REBOOT, - GUEST_HEARTBEAT_API_EVENT_SUSPEND, - GUEST_HEARTBEAT_API_EVENT_PAUSE, - GUEST_HEARTBEAT_API_EVENT_UNPAUSE, - GUEST_HEARTBEAT_API_EVENT_RESUME, - GUEST_HEARTBEAT_API_EVENT_RESIZE_BEGIN, - GUEST_HEARTBEAT_API_EVENT_RESIZE_END, - GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_BEGIN, - GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_END, - GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_BEGIN, - GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_END, - GUEST_HEARTBEAT_API_EVENT_MAX, -} GuestHeartbeatApiEventT; - -typedef enum { - GUEST_HEARTBEAT_API_NOTIFY_TYPE_UNKNOWN, - GUEST_HEARTBEAT_API_NOTIFY_TYPE_REVOCABLE, // vote on an action - GUEST_HEARTBEAT_API_NOTIFY_TYPE_IRREVOCABLE, // notification of an action - GUEST_HEARTBEAT_API_NOTIFY_TYPE_MAX, -} GuestHeartbeatApiNotifyTypeT; - -typedef enum { -// - GUEST_HEARTBEAT_API_VOTE_RESULT_UNKNOWN, - GUEST_HEARTBEAT_API_VOTE_RESULT_ACCEPT, // vote to accept an action - GUEST_HEARTBEAT_API_VOTE_RESULT_REJECT, // vote to reject an action - GUEST_HEARTBEAT_API_VOTE_RESULT_COMPLETE, // ready for action - GUEST_HEARTBEAT_API_VOTE_RESULT_MAX, -} GuestHeartbeatApiVoteResultT; - -// **************************************************************************** -// Guest Heartbeat API - Initialization Data -// ========================================= -// Description: -// Configuration data used on registration. -// -// Fields: -// application_name name of the application, used for logging -// heartbeat_interval_ms the interval for heartbeat challenges -// vote_secs maximum time to wait for a vote to complete -// shutdown_notice_secs maximum time to wait for a shutdown prep -// suspend_notice_secs maximum time to wait for a suspend prep -// resume_notice_secs maximum time to wait for a resume prep -// corrective_action corrective action on heartbeat timeouts -// -// Note: minimum heartbeat interval is 400 milliseconds. Anything below this -// interval will cause the registration to be rejected. -// -typedef struct { - char application_name[GUEST_HEARTBEAT_API_APPLICATION_NAME_MAX]; - int heartbeat_interval_ms; - int vote_secs; - int shutdown_notice_secs; - int suspend_notice_secs; - int resume_notice_secs; - GuestHeartbeatApiActionT corrective_action; -} GuestHeartbeatApiInitDataT; -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Register State Callback -// ============================================= -// Description: -// Called when the registration with the Guest-Client changes. Situations -// this callback can be invoked are the following: -// - Guest-Client accepts the registration, -// - Guest-Client rejects the registration, and -// - Guest-Client connection fails. -// -// If the registration state is False, the application needs to register -// again with the Guest-Client. -// -// Parameters: -// state the registration state of the application. -// -typedef void (*GuestHeartbeatApiRegisterStateCallbackT) - (bool state); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Health Check Callback -// =========================================== -// Description: -// Called by the Guest-Client to request the current health of the -// application. -// -// Parameters: -// health the health of the application -// corrective_action the corrective action to be taken when unhealthy -// log_msg an indication of why the application is unhealthy. -// -typedef void (*GuestHeartbeatApiHealthCheckCallbackT) - (bool* health, GuestHeartbeatApiActionT* corrective_action, - char log_msg[]); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Action Notify Callback -// ============================================ -// Description: -// Called when the Guest-Client wants to notify the application of an -// action. The notification type indicates if this is a vote or a -// notification. -// -// Parameters: -// invocation_id the unique identifier for the action. -// event the type of event for the action. -// notify_type the type of notification for the action. -// -typedef void (*GuestHeartbeatApiActionNotifyCallbackT) - (int invocation_id, GuestHeartbeatApiEventT event, - GuestHeartbeatApiNotifyTypeT notify_type); -// **************************************************************************** - -typedef struct { - GuestHeartbeatApiRegisterStateCallbackT register_state; - GuestHeartbeatApiHealthCheckCallbackT health_check; - GuestHeartbeatApiActionNotifyCallbackT action_notify; -} GuestHeartbeatApiCallbacksT; - -// **************************************************************************** -// Guest Heartbeat API - Action String -// =================================== -extern const char* guest_heartbeat_api_action_str( - GuestHeartbeatApiActionT action ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Event String -// ================================== -extern const char* guest_heartbeat_api_event_str( - GuestHeartbeatApiEventT event ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Notify String -// =================================== -extern const char* guest_heartbeat_api_notify_str( - GuestHeartbeatApiNotifyTypeT notify ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Vote Result String -// ======================================== -extern const char* guest_heartbeat_api_vote_result_str( - GuestHeartbeatApiVoteResultT vote_result ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Register -// ============================== -// Description: -// Sends a registration request to the Guest-Client. A try-again can be -// returned which indicates that registration should be attempted again -// at a later time. -// -// Parameters: -// init_data configuration parameters and timeout values for -// this application. -// -// Returns: -// GUEST_API_OKAY on success, GUEST_API_TRY_AGAIN if Guest-Client could -// not be reached, otherwise failure. -// -extern GuestApiErrorT guest_heartbeat_api_register( - GuestHeartbeatApiInitDataT* init_data ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Deregister -// ================================ -// Description: -// Sends a deregister to the Guest-Client. -// -// Parameters: -// log_msg indication of the reason for the de-registration. -// -// Returns: -// GUEST_API_OKAY on success, otherwise failure. -// -extern GuestApiErrorT guest_heartbeat_api_deregister( char log_msg[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Send Action Response -// ========================================== -// Description: -// Sends an action response to the Guest-Client indicating the action -// is accepted, rejected or completed. -// -// Parameters: -// invocation_id the unique identifier from the action callback. -// event the type of event from the action callback. -// notify_type the type of notification from the action callback. -// vote_result indication of acceptance of the action. -// log_msg an indication of why the action was rejected. -// -// Returns: -// GUEST_API_OKAY on success, otherwise failure. -// -extern GuestApiErrorT guest_heartbeat_api_send_action_response( - int invocation_id, GuestHeartbeatApiEventT event, - GuestHeartbeatApiNotifyTypeT notify_type, - GuestHeartbeatApiVoteResultT vote_result, char log_msg[] ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Dispatch -// ============================== -// Description: -// Called when the selection object returned by guest_heartbeat_api_get_selobj -// becomes readable. -// -// Parameters: -// selobj the selection object that has become readable. -// -// Returns: -// Nothing -// -extern void guest_heartbeat_api_dispatch( int selobj ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Get Selection Object -// ========================================== -// Description: -// Returns a selection object that can be used with poll or select. -// -// Parameters: -// None -// -// Returns: -// A valid selection object, otherwise -1. -// -extern int guest_heartbeat_api_get_selobj( void ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Initialize -// ================================ -// Description: -// Initialize the Guest Heartbeat API library for use. -// -// Parameters: -// callbacks a listing of callbacks for receiving registration -// state changes, health checks, and action notifications -// (all are required to be non-NULL). -// -// Returns: -// GUEST_API_OKAY on success, otherwise failure. -// -extern GuestApiErrorT guest_heartbeat_api_initialize( - GuestHeartbeatApiCallbacksT* callbacks ); -// **************************************************************************** - -// **************************************************************************** -// Guest Heartbeat API - Finalize -// ============================== -// Description: -// Finalize the Guest Heartbeat API library. -// -// Parameters: -// None -// -// Returns: -// GUEST_API_OKAY on success, otherwise failure. -// -extern GuestApiErrorT guest_heartbeat_api_finalize( void ); -// **************************************************************************** - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_API_H__ */ diff --git a/guest-client/guest-client-3.0.1/guest_client_api/sample_guest_app.c b/guest-client/guest-client-3.0.1/guest_client_api/sample_guest_app.c deleted file mode 100755 index c9ae5b77..00000000 --- a/guest-client/guest-client-3.0.1/guest_client_api/sample_guest_app.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include -#include -#include -#include - -#include "guest_api_types.h" -#include "guest_api_debug.h" -#include "guest_heartbeat_api.h" - -static int _heartbeat_selobj = -1; -static bool _heartbeat_registered = false; -static bool _heartbeat_registering = false; -static char _application_name[40] = "sample-guest-app"; -static GuestHeartbeatApiActionT _corrective_action; - -static sig_atomic_t _stay_on = 1; - -// **************************************************************************** -// Guest Application - Register State Callback -// =========================================== -static void guest_app_register_state_callback( bool state ) -{ - if (state) - _heartbeat_registering = false; - - _heartbeat_registered = state; -} -// **************************************************************************** - -// **************************************************************************** -// Guest Application - Health Check Callback -// ========================================= -static void guest_app_health_check_callback( - bool* healthy, GuestHeartbeatApiActionT* corrective_action, - char log_msg[GUEST_HEARTBEAT_API_LOG_MAX] ) -{ - char filename[80]; - int result; - - snprintf(filename, sizeof(filename), "/tmp/%s_unhealthy", - _application_name); - - result = access(filename, F_OK); - if (0 == result) - { - *healthy = false; - *corrective_action = _corrective_action; - snprintf(log_msg, GUEST_HEARTBEAT_API_LOG_MAX, "File %s exists.", - filename); - } else { - *healthy = true; - *corrective_action = GUEST_HEARTBEAT_API_ACTION_NONE; - log_msg[0] = '\0'; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Application - Action Notify Callback -// ========================================== -static void guest_app_action_notify_callback( - int invocation_id, GuestHeartbeatApiEventT event, - GuestHeartbeatApiNotifyTypeT notify_type ) -{ - char filename[80]; - GuestHeartbeatApiVoteResultT vote_result; - char log_msg[GUEST_HEARTBEAT_API_LOG_MAX]; - GuestApiErrorT error; - int result; - - snprintf(filename, sizeof(filename), "/tmp/%s_event_timeout", - _application_name); - - result = access(filename, F_OK); - if (0 == result) - return; - - if (GUEST_HEARTBEAT_API_NOTIFY_TYPE_REVOCABLE == notify_type) - { - switch (event) - { - case GUEST_HEARTBEAT_API_EVENT_STOP: - snprintf(filename, sizeof(filename), - "/tmp/%s_vote_no_to_stop", _application_name); - break; - - case GUEST_HEARTBEAT_API_EVENT_REBOOT: - snprintf(filename, sizeof(filename), - "/tmp/%s_vote_no_to_reboot", _application_name); - break; - case GUEST_HEARTBEAT_API_EVENT_SUSPEND: - case GUEST_HEARTBEAT_API_EVENT_PAUSE: - snprintf(filename, sizeof(filename), - "/tmp/%s_vote_no_to_suspend", _application_name); - break; - case GUEST_HEARTBEAT_API_EVENT_RESIZE_BEGIN: - snprintf(filename, sizeof(filename), - "/tmp/%s_vote_no_to_resize", _application_name); - break; - case GUEST_HEARTBEAT_API_EVENT_LIVE_MIGRATE_BEGIN: - case GUEST_HEARTBEAT_API_EVENT_COLD_MIGRATE_BEGIN: - snprintf(filename, sizeof(filename), - "/tmp/%s_vote_no_to_migrate", _application_name); - break; - default: - DPRINTFE("Should never be asked to vote on event %s.", - guest_heartbeat_api_event_str(event)); - return; - } - - result = access(filename, F_OK); - if (0 == result) - { - vote_result = GUEST_HEARTBEAT_API_VOTE_RESULT_REJECT; - snprintf(log_msg, GUEST_HEARTBEAT_API_LOG_MAX, "File %s exists.", - filename); - } else { - vote_result = GUEST_HEARTBEAT_API_VOTE_RESULT_ACCEPT; - log_msg[0] = '\0'; - } - } else { - vote_result = GUEST_HEARTBEAT_API_VOTE_RESULT_COMPLETE; - } - - error = guest_heartbeat_api_send_action_response(invocation_id, event, - notify_type, vote_result, log_msg); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to send action response, error=%s.", - guest_api_error_str(error)); - return; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Application - Signal Handler -// ================================== -static void guest_app_signal_handler( int signum ) -{ - switch (signum) - { - case SIGINT: - case SIGTERM: - case SIGQUIT: - _stay_on = 0; - break; - - case SIGCONT: - DPRINTFD("Ignoring signal SIGCONT (%i).", signum); - break; - - case SIGPIPE: - DPRINTFD("Ignoring signal SIGPIPE (%i).", signum); - break; - - default: - DPRINTFD("Signal (%i) ignored.", signum); - break; - } -} -// **************************************************************************** - -// **************************************************************************** -// Guest Application - Main -// ======================== -int main( int argc, char *argv[], char *envp[] ) -{ - GuestHeartbeatApiCallbacksT callbacks; - GuestApiErrorT error; - - error = guest_api_debug_initialize("Guest-Application"); - if (GUEST_API_OKAY != error) - { - printf("Debug initialization failed, error=%s.\n", - guest_api_error_str(error)); - return EXIT_FAILURE; - } - - DPRINTFI("Starting."); - - signal(SIGINT, guest_app_signal_handler); - signal(SIGTERM, guest_app_signal_handler); - signal(SIGQUIT, guest_app_signal_handler); - signal(SIGCONT, guest_app_signal_handler); - signal(SIGPIPE, guest_app_signal_handler); - - _corrective_action = GUEST_HEARTBEAT_API_ACTION_REBOOT; - - unsigned int arg_i; - for (arg_i=1; arg_i < argc; ++arg_i) - { - if (0 == strcmp("--name", argv[arg_i])) - { - arg_i++; - if (arg_i < argc) - snprintf(_application_name, sizeof(_application_name), "%s", - argv[arg_i]); - - } else if (0 == strcmp("--corrective-action", argv[arg_i])) { - arg_i++; - if (arg_i < argc) - { - if (0 == strcmp("reboot", argv[arg_i])) - { - _corrective_action = GUEST_HEARTBEAT_API_ACTION_REBOOT; - - } else if (0 == strcmp("stop", argv[arg_i])) { - _corrective_action = GUEST_HEARTBEAT_API_ACTION_STOP; - - } else if (0 == strcmp("log", argv[arg_i])) { - _corrective_action = GUEST_HEARTBEAT_API_ACTION_LOG; - } - } - } - } - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.register_state = guest_app_register_state_callback; - callbacks.health_check = guest_app_health_check_callback; - callbacks.action_notify = guest_app_action_notify_callback; - - error = guest_heartbeat_api_initialize(&callbacks); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to initialize guest heartbeat api, error=%s.", - guest_api_error_str(error)); - return EXIT_FAILURE; - } - - DPRINTFI("Started."); - - while (_stay_on) - { - int num_fds; - fd_set fds; - struct timeval tv; - int result; - - tv.tv_sec = 1; - tv.tv_usec = 0; - - num_fds = 0; - FD_ZERO(&fds); - - if (!_heartbeat_registered) - { - GuestHeartbeatApiInitDataT init_data; - - snprintf(init_data.application_name, - sizeof(init_data.application_name), "%s", - _application_name); - init_data.heartbeat_interval_ms = 1000; - init_data.vote_secs = 8; - init_data.shutdown_notice_secs = 5; - init_data.suspend_notice_secs = 5; - init_data.resume_notice_secs = 5; - init_data.corrective_action = _corrective_action; - - error = guest_heartbeat_api_register(&init_data); - if (GUEST_API_OKAY == error) - { - _heartbeat_registering = true; - } else { - _heartbeat_registering = false; - - if (GUEST_API_TRY_AGAIN != error) - { - DPRINTFE("Failed to register for guest heartbeating, " - "error=%s.", guest_api_error_str(error)); - return EXIT_FAILURE; - } - } - } - - if (_heartbeat_registering || _heartbeat_registered) - { - _heartbeat_selobj = guest_heartbeat_api_get_selobj(); - FD_SET(_heartbeat_selobj, &fds); - num_fds = _heartbeat_selobj; - } - - result = select(num_fds+1, &fds, NULL, NULL, &tv); - if (0 > result) - { - if (errno == EINTR) - { - DPRINTFD("Interrupted by a signal."); - } else { - DPRINTFE("Select failed, error=%s.", strerror(errno)); - } - } else if (0 == result) { - DPRINTFD("Nothing selected."); - } else { - if (FD_ISSET(_heartbeat_selobj, &fds)) - { - guest_heartbeat_api_dispatch(_heartbeat_selobj); - } - } - } - - DPRINTFI("Shutting down."); - - error = guest_heartbeat_api_deregister("Exiting"); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to deregister from guest heartbeat api, error=%s.", - guest_api_error_str(error)); - } - - error = guest_heartbeat_api_finalize(); - if (GUEST_API_OKAY != error) - { - DPRINTFE("Failed to finalize guest heartbeat api, error=%s.", - guest_api_error_str(error)); - } - - DPRINTFI("Shutdown complete."); - - error = guest_api_debug_finalize(); - if (GUEST_API_OKAY != error) - { - printf("Debug finalization failed, error=%s.\n", - guest_api_error_str(error)); - } - - return EXIT_SUCCESS; -} -// **************************************************************************** diff --git a/guest-client/guest-client-3.0.1/include/guest_heartbeat_api_msg_defs.h b/guest-client/guest-client-3.0.1/include/guest_heartbeat_api_msg_defs.h deleted file mode 100755 index f178c618..00000000 --- a/guest-client/guest-client-3.0.1/include/guest_heartbeat_api_msg_defs.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __GUEST_HEARTBEAT_API_MESSAGE_DEFINITIONS_H__ -#define __GUEST_HEARTBEAT_API_MESSAGE_DEFINITIONS_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define GUEST_HEARTBEAT_API_MSG_ADDRESS "/var/run/.guest_heartbeat_api" - -#define GUEST_HEARTBEAT_API_MSG_MAGIC_VALUE "FDFDA5A5" -#define GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE 8 -#define GUEST_HEARTBEAT_API_MSG_VERSION_CURRENT 2 -#define GUEST_HEARTBEAT_API_MSG_REVISION_CURRENT 1 - -#define GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE 40 -#define GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE 192 - -typedef enum { - GUEST_HEARTBEAT_API_MSG_ACTION_UNKNOWN, - GUEST_HEARTBEAT_API_MSG_ACTION_NONE, - GUEST_HEARTBEAT_API_MSG_ACTION_REBOOT, - GUEST_HEARTBEAT_API_MSG_ACTION_STOP, - GUEST_HEARTBEAT_API_MSG_ACTION_LOG, - GUEST_HEARTBEAT_API_MSG_ACTION_MAX, -} GuestHeartbeatApiMsgActionT; - -typedef enum { - GUEST_HEARTBEAT_API_MSG_EVENT_UNKNOWN, - GUEST_HEARTBEAT_API_MSG_EVENT_STOP, - GUEST_HEARTBEAT_API_MSG_EVENT_REBOOT, - GUEST_HEARTBEAT_API_MSG_EVENT_SUSPEND, - GUEST_HEARTBEAT_API_MSG_EVENT_PAUSE, - GUEST_HEARTBEAT_API_MSG_EVENT_UNPAUSE, - GUEST_HEARTBEAT_API_MSG_EVENT_RESUME, - GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_BEGIN, - GUEST_HEARTBEAT_API_MSG_EVENT_RESIZE_END, - GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_BEGIN, - GUEST_HEARTBEAT_API_MSG_EVENT_LIVE_MIGRATE_END, - GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_BEGIN, - GUEST_HEARTBEAT_API_MSG_EVENT_COLD_MIGRATE_END, - GUEST_HEARTBEAT_API_MSG_EVENT_MAX, -} GuestHeartbeatApiMsgEventT; - -typedef enum { - GUEST_HEARTBEAT_API_MSG_NOTIFY_UNKNOWN, - GUEST_HEARTBEAT_API_MSG_NOTIFY_REVOCABLE, - GUEST_HEARTBEAT_API_MSG_NOTIFY_IRREVOCABLE, - GUEST_HEARTBEAT_API_MSG_NOTIFY_MAX, -} GuestHeartbeatApiMsgNotifyT; - -typedef enum { - GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_UNKNOWN, - GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_ACCEPT, - GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_REJECT, - GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_COMPLETE, - GUEST_HEARTBEAT_API_MSG_VOTE_RESULT_MAX, -} GuestHeartbeatApiMsgVoteResultT; - -typedef enum { - GUEST_HEARTBEAT_API_MSG_INIT, - GUEST_HEARTBEAT_API_MSG_INIT_ACK, - GUEST_HEARTBEAT_API_MSG_FINAL, - GUEST_HEARTBEAT_API_MSG_CHALLENGE, - GUEST_HEARTBEAT_API_MSG_CHALLENGE_RESPONSE, - GUEST_HEARTBEAT_API_MSG_ACTION_NOTIFY, - GUEST_HEARTBEAT_API_MSG_ACTION_RESPONSE, - GUEST_HEARTBEAT_API_MSG_TYPE_MAX, -} GuestHeartbeatApiMsgTypeT; - -typedef struct { - char magic[GUEST_HEARTBEAT_API_MSG_MAGIC_SIZE]; - uint8_t version; - uint8_t revision; - uint16_t msg_type; - uint32_t sequence; - uint32_t size; -} GuestHeartbeatApiMsgHeaderT; - -typedef struct { - char application_name[GUEST_HEARTBEAT_API_MSG_MAX_APPLICATION_NAME_SIZE]; - uint32_t heartbeat_interval_ms; - uint32_t vote_secs; - uint32_t shutdown_notice_secs; - uint32_t suspend_notice_secs; - uint32_t resume_notice_secs; - uint32_t corrective_action; -} GuestHeartbeatApiMsgInitT; - -typedef struct { - uint32_t accepted; -} GuestHeartbeatApiMsgInitAckT; - -typedef struct { - char log_msg[GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE]; -} GuestHeartbeatApiMsgFinalT; - -typedef struct { - uint32_t heartbeat_challenge; -} GuestHeartbeatApiMsgChallengeT; - -typedef struct { - uint32_t heartbeat_response; - uint32_t health; - uint32_t corrective_action; - char log_msg[GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE]; -} GuestHeartbeatApiMsgChallengeResponseT; - -typedef struct { - uint32_t invocation_id; - uint32_t event_type; - uint32_t notification_type; -} GuestHeartbeatApiMsgActionNotifyT; - -typedef struct { - uint32_t invocation_id; - uint32_t event_type; - uint32_t notification_type; - uint32_t vote_result; - char log_msg[GUEST_HEARTBEAT_API_MSG_MAX_LOG_SIZE]; -} GuestHeartbeatApiMsgActionResponseT; - -typedef union { - GuestHeartbeatApiMsgInitT init; - GuestHeartbeatApiMsgInitAckT init_ack; - GuestHeartbeatApiMsgFinalT final; - GuestHeartbeatApiMsgChallengeT challenge; - GuestHeartbeatApiMsgChallengeResponseT challenge_response; - GuestHeartbeatApiMsgActionNotifyT action_notify; - GuestHeartbeatApiMsgActionResponseT action_response; -} GuestHeartbeatApiMsgBodyT; - -typedef struct { - GuestHeartbeatApiMsgHeaderT header; - GuestHeartbeatApiMsgBodyT body; -} GuestHeartbeatApiMsgT; - -#ifdef __cplusplus -} -#endif - -#endif /* __GUEST_HEARTBEAT_API_MESSAGE_DEFINITIONS_H__ */ diff --git a/guest-client/guest-client-3.0.1/packaging/guest-client.pkg b/guest-client/guest-client-3.0.1/packaging/guest-client.pkg deleted file mode 100755 index cd3df1e8..00000000 --- a/guest-client/guest-client-3.0.1/packaging/guest-client.pkg +++ /dev/null @@ -1,108 +0,0 @@ -#! /bin/bash -# -# Copyright(c) 2013-2016, Wind River Systems, Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Wind River Systems nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -RETVAL=0 - -CMD=$1 -INIT_TYPE=$2 -DESTDIR=$3 - -# Note: the variable, DESTDIR has to be an absolute path. - -if [ -z ${INIT_TYPE} ] -then - INIT_TYPE="sysv" -fi - -if [ -z ${DESTDIR} ] -then - DESTDIR="/" -fi - -case "$CMD" in - install) - find ./rootdir/ -type d | while read source_dir; do - target_dir=${source_dir#./rootdir/} - mkdir -p $DESTDIR/$target_dir - done - - cp --preserve=links -R ./rootdir/* $DESTDIR - - if [ "$INIT_TYPE" = "systemd" ] - then - mkdir -p --mode 755 $DESTDIR/etc/guest-client/ - cp guest-client.systemd $DESTDIR/etc/guest-client/ - mkdir -p --mode 755 $DESTDIR/etc/systemd/system - cp guest-client.service $DESTDIR/lib/systemd/system/guest-client.service - ln -s $DESTDIR/lib/systemd/system/guest-client.service $DESTDIR/etc/systemd/system/guest-client.service - - elif [ "$INIT_TYPE" = "sysv" ] - then - mkdir -p --mode 755 $DESTDIR/etc/init.d - cp guest-client.init $DESTDIR/etc/init.d/guest-client - - else - echo "Unknown init-type given, INIT_TYPE=$INIT_TYPE" - fi - ;; - - uninstall) - if [ "$INIT_TYPE" = "systemd" ] - then - rm $DESTDIR/etc/guest-client/guest-client.systemd - rm $DESTDIR/lib/systemd/system/guest-client.service - rm $DESTDIR/etc/systemd/system/guest-client.service - - elif [ "$INIT_TYPE" = "sysv" ] - then - rm $DESTDIR/etc/init.d/guest-client - - else - echo "Unknown init type given, INIT_TYPE=$INIT_TYPE" - fi - - find ./rootdir -type l | while read source_file; do - target_file=${source_file#./rootdir/} - rm $DESTDIR/$target_file - done - - find ./rootdir -type f | while read source_file; do - target_file=${source_file#./rootdir/} - rm $DESTDIR/$target_file - done - ;; - - *) - echo "usage: $0 { install | uninstall }" - ;; -esac - -exit ${RETVAL} diff --git a/mtce-guest/centos/build_srpm.data b/mtce-guest/centos/build_srpm.data index d872dde9..01e786b1 100644 --- a/mtce-guest/centos/build_srpm.data +++ b/mtce-guest/centos/build_srpm.data @@ -1,3 +1,3 @@ SRC_DIR="src" -TIS_PATCH_VER=141 +TIS_PATCH_VER=142 BUILD_IS_SLOW=5 diff --git a/mtce-guest/centos/mtce-guest.spec b/mtce-guest/centos/mtce-guest.spec index f96c65ef..8fda8ee7 100644 --- a/mtce-guest/centos/mtce-guest.spec +++ b/mtce-guest/centos/mtce-guest.spec @@ -21,7 +21,6 @@ BuildRequires: libuuid BuildRequires: libuuid-devel BuildRequires: fm-common BuildRequires: fm-common-dev -BuildRequires: guest-client-devel BuildRequires: mtce-common-dev >= 1.0 BuildRequires: systemd-devel BuildRequires: cppcheck diff --git a/mtce-guest/src/guestBase.h b/mtce-guest/src/guestBase.h index 5857bb85..25785b88 100644 --- a/mtce-guest/src/guestBase.h +++ b/mtce-guest/src/guestBase.h @@ -2,7 +2,7 @@ #define __INCLUDE_GUESTBASE_H__ /* - * Copyright (c) 2013-2016 Wind River Systems, Inc. + * Copyright (c) 2013-2019 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 * @@ -31,10 +31,10 @@ #include #include -#include using namespace std; +#include "guest_heartbeat_msg_defs.h" #include "msgClass.h" #include "nodeBase.h" #include "httpUtil.h" diff --git a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg_defs.h b/mtce-guest/src/guest_heartbeat_msg_defs.h old mode 100755 new mode 100644 similarity index 79% rename from guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg_defs.h rename to mtce-guest/src/guest_heartbeat_msg_defs.h index 2a12c86f..dce3f11e --- a/guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg_defs.h +++ b/mtce-guest/src/guest_heartbeat_msg_defs.h @@ -1,30 +1,8 @@ /* - * Copyright (c) 2013-2016, Wind River Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3) Neither the name of Wind River Systems nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Copyright (c) 2013-2019 Wind River Systems, Inc. +* +* SPDX-License-Identifier: Apache-2.0 +* */ #ifndef __GUEST_HEARTBEAT_MESSAGE_DEFINITIONS_H__ #define __GUEST_HEARTBEAT_MESSAGE_DEFINITIONS_H__